Spaces:
Running
Running
github-actions[bot]
commited on
Commit
·
b5e1f18
1
Parent(s):
f890a25
Update from GitHub Actions
Browse files- package-lock.json +18 -769
- package.json +0 -1
- src/app.js +202 -1
- src/config/config.js +98 -1
- src/middleware/auth.js +51 -1
- src/models/admin.js +114 -1
- src/public/scripts.js +1342 -1
- src/routes/index.js +8 -1
- src/routes/v1.js +0 -0
- src/utils/cookieRefresher.js +818 -1
- src/utils/envChecker.js +89 -1
- src/utils/extractCookieFromCsv.js +269 -1
- src/utils/keyManager.js +410 -1
- src/utils/logger.js +392 -1
- src/utils/utils.js +206 -1
package-lock.json
CHANGED
@@ -27,7 +27,6 @@
|
|
27 |
"uuid": "11.0.5"
|
28 |
},
|
29 |
"devDependencies": {
|
30 |
-
"javascript-obfuscator": "^4.1.1",
|
31 |
"protobufjs-cli": "^1.1.3"
|
32 |
}
|
33 |
},
|
@@ -81,35 +80,6 @@
|
|
81 |
"node": ">=6.9.0"
|
82 |
}
|
83 |
},
|
84 |
-
"node_modules/@javascript-obfuscator/escodegen": {
|
85 |
-
"version": "2.3.0",
|
86 |
-
"resolved": "https://registry.npmjs.org/@javascript-obfuscator/escodegen/-/escodegen-2.3.0.tgz",
|
87 |
-
"integrity": "sha512-QVXwMIKqYMl3KwtTirYIA6gOCiJ0ZDtptXqAv/8KWLG9uQU2fZqTVy7a/A5RvcoZhbDoFfveTxuGxJ5ibzQtkw==",
|
88 |
-
"dev": true,
|
89 |
-
"license": "BSD-2-Clause",
|
90 |
-
"dependencies": {
|
91 |
-
"@javascript-obfuscator/estraverse": "^5.3.0",
|
92 |
-
"esprima": "^4.0.1",
|
93 |
-
"esutils": "^2.0.2",
|
94 |
-
"optionator": "^0.8.1"
|
95 |
-
},
|
96 |
-
"engines": {
|
97 |
-
"node": ">=6.0"
|
98 |
-
},
|
99 |
-
"optionalDependencies": {
|
100 |
-
"source-map": "~0.6.1"
|
101 |
-
}
|
102 |
-
},
|
103 |
-
"node_modules/@javascript-obfuscator/estraverse": {
|
104 |
-
"version": "5.4.0",
|
105 |
-
"resolved": "https://registry.npmjs.org/@javascript-obfuscator/estraverse/-/estraverse-5.4.0.tgz",
|
106 |
-
"integrity": "sha512-CZFX7UZVN9VopGbjTx4UXaXsi9ewoM1buL0kY7j1ftYdSs7p2spv9opxFjHlQ/QGTgh4UqufYqJJ0WKLml7b6w==",
|
107 |
-
"dev": true,
|
108 |
-
"license": "BSD-2-Clause",
|
109 |
-
"engines": {
|
110 |
-
"node": ">=4.0"
|
111 |
-
}
|
112 |
-
},
|
113 |
"node_modules/@jsdoc/salty": {
|
114 |
"version": "0.2.9",
|
115 |
"resolved": "https://registry.npmjs.org/@jsdoc/salty/-/salty-0.2.9.tgz",
|
@@ -367,13 +337,6 @@
|
|
367 |
"dev": true,
|
368 |
"license": "MIT"
|
369 |
},
|
370 |
-
"node_modules/@types/minimatch": {
|
371 |
-
"version": "3.0.5",
|
372 |
-
"resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.5.tgz",
|
373 |
-
"integrity": "sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==",
|
374 |
-
"dev": true,
|
375 |
-
"license": "MIT"
|
376 |
-
},
|
377 |
"node_modules/@types/node": {
|
378 |
"version": "22.10.5",
|
379 |
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.5.tgz",
|
@@ -383,13 +346,6 @@
|
|
383 |
"undici-types": "~6.20.0"
|
384 |
}
|
385 |
},
|
386 |
-
"node_modules/@types/validator": {
|
387 |
-
"version": "13.15.1",
|
388 |
-
"resolved": "https://registry.npmjs.org/@types/validator/-/validator-13.15.1.tgz",
|
389 |
-
"integrity": "sha512-9gG6ogYcoI2mCMLdcO0NYI0AYrbxIjv0MDmy/5Ywo6CpWWrqYayc+mmgxRsCgtcGJm9BSbXkMsmxGah1iGHAAQ==",
|
390 |
-
"dev": true,
|
391 |
-
"license": "MIT"
|
392 |
-
},
|
393 |
"node_modules/accepts": {
|
394 |
"version": "1.3.8",
|
395 |
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
|
@@ -458,77 +414,18 @@
|
|
458 |
"dev": true,
|
459 |
"license": "Python-2.0"
|
460 |
},
|
461 |
-
"node_modules/array-differ": {
|
462 |
-
"version": "3.0.0",
|
463 |
-
"resolved": "https://registry.npmjs.org/array-differ/-/array-differ-3.0.0.tgz",
|
464 |
-
"integrity": "sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg==",
|
465 |
-
"dev": true,
|
466 |
-
"license": "MIT",
|
467 |
-
"engines": {
|
468 |
-
"node": ">=8"
|
469 |
-
}
|
470 |
-
},
|
471 |
"node_modules/array-flatten": {
|
472 |
"version": "1.1.1",
|
473 |
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
|
474 |
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
|
475 |
"license": "MIT"
|
476 |
},
|
477 |
-
"node_modules/array-union": {
|
478 |
-
"version": "2.1.0",
|
479 |
-
"resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz",
|
480 |
-
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==",
|
481 |
-
"dev": true,
|
482 |
-
"license": "MIT",
|
483 |
-
"engines": {
|
484 |
-
"node": ">=8"
|
485 |
-
}
|
486 |
-
},
|
487 |
-
"node_modules/arrify": {
|
488 |
-
"version": "2.0.1",
|
489 |
-
"resolved": "https://registry.npmjs.org/arrify/-/arrify-2.0.1.tgz",
|
490 |
-
"integrity": "sha512-3duEwti880xqi4eAMN8AyR4a0ByT90zoYdLlevfrvU43vb0YZwZVfxOgxWrLXXXpyugL0hNZc9G6BiB5B3nUug==",
|
491 |
-
"dev": true,
|
492 |
-
"license": "MIT",
|
493 |
-
"engines": {
|
494 |
-
"node": ">=8"
|
495 |
-
}
|
496 |
-
},
|
497 |
-
"node_modules/assert": {
|
498 |
-
"version": "2.0.0",
|
499 |
-
"resolved": "https://registry.npmjs.org/assert/-/assert-2.0.0.tgz",
|
500 |
-
"integrity": "sha512-se5Cd+js9dXJnu6Ag2JFc00t+HmHOen+8Q+L7O9zI0PqQXr20uk2J0XQqMxZEeo5U50o8Nvmmx7dZrl+Ufr35A==",
|
501 |
-
"dev": true,
|
502 |
-
"license": "MIT",
|
503 |
-
"dependencies": {
|
504 |
-
"es6-object-assign": "^1.1.0",
|
505 |
-
"is-nan": "^1.2.1",
|
506 |
-
"object-is": "^1.0.1",
|
507 |
-
"util": "^0.12.0"
|
508 |
-
}
|
509 |
-
},
|
510 |
"node_modules/asynckit": {
|
511 |
"version": "0.4.0",
|
512 |
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
513 |
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
|
514 |
"license": "MIT"
|
515 |
},
|
516 |
-
"node_modules/available-typed-arrays": {
|
517 |
-
"version": "1.0.7",
|
518 |
-
"resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz",
|
519 |
-
"integrity": "sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==",
|
520 |
-
"dev": true,
|
521 |
-
"license": "MIT",
|
522 |
-
"dependencies": {
|
523 |
-
"possible-typed-array-names": "^1.0.0"
|
524 |
-
},
|
525 |
-
"engines": {
|
526 |
-
"node": ">= 0.4"
|
527 |
-
},
|
528 |
-
"funding": {
|
529 |
-
"url": "https://github.com/sponsors/ljharb"
|
530 |
-
}
|
531 |
-
},
|
532 |
"node_modules/axios": {
|
533 |
"version": "1.8.3",
|
534 |
"resolved": "https://registry.npmjs.org/axios/-/axios-1.8.3.tgz",
|
@@ -618,13 +515,6 @@
|
|
618 |
"integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==",
|
619 |
"license": "BSD-3-Clause"
|
620 |
},
|
621 |
-
"node_modules/buffer-from": {
|
622 |
-
"version": "1.1.2",
|
623 |
-
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
|
624 |
-
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
|
625 |
-
"dev": true,
|
626 |
-
"license": "MIT"
|
627 |
-
},
|
628 |
"node_modules/bundle-name": {
|
629 |
"version": "4.1.0",
|
630 |
"resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-4.1.0.tgz",
|
@@ -649,29 +539,10 @@
|
|
649 |
"node": ">= 0.8"
|
650 |
}
|
651 |
},
|
652 |
-
"node_modules/call-bind": {
|
653 |
-
"version": "1.0.8",
|
654 |
-
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.8.tgz",
|
655 |
-
"integrity": "sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww==",
|
656 |
-
"dev": true,
|
657 |
-
"license": "MIT",
|
658 |
-
"dependencies": {
|
659 |
-
"call-bind-apply-helpers": "^1.0.0",
|
660 |
-
"es-define-property": "^1.0.0",
|
661 |
-
"get-intrinsic": "^1.2.4",
|
662 |
-
"set-function-length": "^1.2.2"
|
663 |
-
},
|
664 |
-
"engines": {
|
665 |
-
"node": ">= 0.4"
|
666 |
-
},
|
667 |
-
"funding": {
|
668 |
-
"url": "https://github.com/sponsors/ljharb"
|
669 |
-
}
|
670 |
-
},
|
671 |
"node_modules/call-bind-apply-helpers": {
|
672 |
-
"version": "1.0.
|
673 |
-
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.
|
674 |
-
"integrity": "sha512-
|
675 |
"license": "MIT",
|
676 |
"dependencies": {
|
677 |
"es-errors": "^1.3.0",
|
@@ -682,13 +553,13 @@
|
|
682 |
}
|
683 |
},
|
684 |
"node_modules/call-bound": {
|
685 |
-
"version": "1.0.
|
686 |
-
"resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.
|
687 |
-
"integrity": "sha512
|
688 |
"license": "MIT",
|
689 |
"dependencies": {
|
690 |
-
"call-bind-apply-helpers": "^1.0.
|
691 |
-
"get-intrinsic": "^1.
|
692 |
},
|
693 |
"engines": {
|
694 |
"node": ">= 0.4"
|
@@ -727,45 +598,6 @@
|
|
727 |
"url": "https://github.com/chalk/chalk?sponsor=1"
|
728 |
}
|
729 |
},
|
730 |
-
"node_modules/chance": {
|
731 |
-
"version": "1.1.9",
|
732 |
-
"resolved": "https://registry.npmjs.org/chance/-/chance-1.1.9.tgz",
|
733 |
-
"integrity": "sha512-TfxnA/DcZXRTA4OekA2zL9GH8qscbbl6X0ZqU4tXhGveVY/mXWvEQLt5GwZcYXTEyEFflVtj+pG8nc8EwSm1RQ==",
|
734 |
-
"dev": true,
|
735 |
-
"license": "MIT"
|
736 |
-
},
|
737 |
-
"node_modules/char-regex": {
|
738 |
-
"version": "1.0.2",
|
739 |
-
"resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz",
|
740 |
-
"integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==",
|
741 |
-
"dev": true,
|
742 |
-
"license": "MIT",
|
743 |
-
"engines": {
|
744 |
-
"node": ">=10"
|
745 |
-
}
|
746 |
-
},
|
747 |
-
"node_modules/charenc": {
|
748 |
-
"version": "0.0.2",
|
749 |
-
"resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz",
|
750 |
-
"integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==",
|
751 |
-
"dev": true,
|
752 |
-
"license": "BSD-3-Clause",
|
753 |
-
"engines": {
|
754 |
-
"node": "*"
|
755 |
-
}
|
756 |
-
},
|
757 |
-
"node_modules/class-validator": {
|
758 |
-
"version": "0.14.1",
|
759 |
-
"resolved": "https://registry.npmjs.org/class-validator/-/class-validator-0.14.1.tgz",
|
760 |
-
"integrity": "sha512-2VEG9JICxIqTpoK1eMzZqaV+u/EiwEJkMGzTrZf6sU/fwsnOITVgYJ8yojSy6CaXtO9V0Cc6ZQZ8h8m4UBuLwQ==",
|
761 |
-
"dev": true,
|
762 |
-
"license": "MIT",
|
763 |
-
"dependencies": {
|
764 |
-
"@types/validator": "^13.11.8",
|
765 |
-
"libphonenumber-js": "^1.10.53",
|
766 |
-
"validator": "^13.9.0"
|
767 |
-
}
|
768 |
-
},
|
769 |
"node_modules/color-convert": {
|
770 |
"version": "2.0.1",
|
771 |
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
@@ -798,23 +630,6 @@
|
|
798 |
"node": ">= 0.8"
|
799 |
}
|
800 |
},
|
801 |
-
"node_modules/commander": {
|
802 |
-
"version": "10.0.0",
|
803 |
-
"resolved": "https://registry.npmjs.org/commander/-/commander-10.0.0.tgz",
|
804 |
-
"integrity": "sha512-zS5PnTI22FIRM6ylNW8G4Ap0IEOyk62fhLSD0+uHRT9McRCLGpkVNvao4bjimpK/GShynyQkFFxHhwMcETmduA==",
|
805 |
-
"dev": true,
|
806 |
-
"license": "MIT",
|
807 |
-
"engines": {
|
808 |
-
"node": ">=14"
|
809 |
-
}
|
810 |
-
},
|
811 |
-
"node_modules/concat-map": {
|
812 |
-
"version": "0.0.1",
|
813 |
-
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
814 |
-
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
|
815 |
-
"dev": true,
|
816 |
-
"license": "MIT"
|
817 |
-
},
|
818 |
"node_modules/content-disposition": {
|
819 |
"version": "0.5.4",
|
820 |
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
|
@@ -873,16 +688,6 @@
|
|
873 |
"integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==",
|
874 |
"license": "MIT"
|
875 |
},
|
876 |
-
"node_modules/crypt": {
|
877 |
-
"version": "0.0.2",
|
878 |
-
"resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz",
|
879 |
-
"integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==",
|
880 |
-
"dev": true,
|
881 |
-
"license": "BSD-3-Clause",
|
882 |
-
"engines": {
|
883 |
-
"node": "*"
|
884 |
-
}
|
885 |
-
},
|
886 |
"node_modules/csv-parser": {
|
887 |
"version": "3.2.0",
|
888 |
"resolved": "https://registry.npmjs.org/csv-parser/-/csv-parser-3.2.0.tgz",
|
@@ -939,24 +744,6 @@
|
|
939 |
"url": "https://github.com/sponsors/sindresorhus"
|
940 |
}
|
941 |
},
|
942 |
-
"node_modules/define-data-property": {
|
943 |
-
"version": "1.1.4",
|
944 |
-
"resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz",
|
945 |
-
"integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==",
|
946 |
-
"dev": true,
|
947 |
-
"license": "MIT",
|
948 |
-
"dependencies": {
|
949 |
-
"es-define-property": "^1.0.0",
|
950 |
-
"es-errors": "^1.3.0",
|
951 |
-
"gopd": "^1.0.1"
|
952 |
-
},
|
953 |
-
"engines": {
|
954 |
-
"node": ">= 0.4"
|
955 |
-
},
|
956 |
-
"funding": {
|
957 |
-
"url": "https://github.com/sponsors/ljharb"
|
958 |
-
}
|
959 |
-
},
|
960 |
"node_modules/define-lazy-prop": {
|
961 |
"version": "3.0.0",
|
962 |
"resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz",
|
@@ -969,24 +756,6 @@
|
|
969 |
"url": "https://github.com/sponsors/sindresorhus"
|
970 |
}
|
971 |
},
|
972 |
-
"node_modules/define-properties": {
|
973 |
-
"version": "1.2.1",
|
974 |
-
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz",
|
975 |
-
"integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==",
|
976 |
-
"dev": true,
|
977 |
-
"license": "MIT",
|
978 |
-
"dependencies": {
|
979 |
-
"define-data-property": "^1.0.1",
|
980 |
-
"has-property-descriptors": "^1.0.0",
|
981 |
-
"object-keys": "^1.1.1"
|
982 |
-
},
|
983 |
-
"engines": {
|
984 |
-
"node": ">= 0.4"
|
985 |
-
},
|
986 |
-
"funding": {
|
987 |
-
"url": "https://github.com/sponsors/ljharb"
|
988 |
-
}
|
989 |
-
},
|
990 |
"node_modules/delayed-stream": {
|
991 |
"version": "1.0.0",
|
992 |
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
@@ -1103,9 +872,9 @@
|
|
1103 |
}
|
1104 |
},
|
1105 |
"node_modules/es-object-atoms": {
|
1106 |
-
"version": "1.
|
1107 |
-
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.
|
1108 |
-
"integrity": "sha512-
|
1109 |
"license": "MIT",
|
1110 |
"dependencies": {
|
1111 |
"es-errors": "^1.3.0"
|
@@ -1129,13 +898,6 @@
|
|
1129 |
"node": ">= 0.4"
|
1130 |
}
|
1131 |
},
|
1132 |
-
"node_modules/es6-object-assign": {
|
1133 |
-
"version": "1.1.0",
|
1134 |
-
"resolved": "https://registry.npmjs.org/es6-object-assign/-/es6-object-assign-1.1.0.tgz",
|
1135 |
-
"integrity": "sha512-MEl9uirslVwqQU369iHNWZXsI8yaZYGg/D65aOgZkeyFJwHYSxilf7rQzXKI7DdDuBPrBXbfk3sl9hJhmd5AUw==",
|
1136 |
-
"dev": true,
|
1137 |
-
"license": "MIT"
|
1138 |
-
},
|
1139 |
"node_modules/escape-html": {
|
1140 |
"version": "1.0.3",
|
1141 |
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
|
@@ -1185,20 +947,6 @@
|
|
1185 |
"node": ">=4.0"
|
1186 |
}
|
1187 |
},
|
1188 |
-
"node_modules/eslint-scope": {
|
1189 |
-
"version": "7.1.1",
|
1190 |
-
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz",
|
1191 |
-
"integrity": "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==",
|
1192 |
-
"dev": true,
|
1193 |
-
"license": "BSD-2-Clause",
|
1194 |
-
"dependencies": {
|
1195 |
-
"esrecurse": "^4.3.0",
|
1196 |
-
"estraverse": "^5.2.0"
|
1197 |
-
},
|
1198 |
-
"engines": {
|
1199 |
-
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
1200 |
-
}
|
1201 |
-
},
|
1202 |
"node_modules/eslint-visitor-keys": {
|
1203 |
"version": "3.4.3",
|
1204 |
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz",
|
@@ -1244,19 +992,6 @@
|
|
1244 |
"node": ">=4"
|
1245 |
}
|
1246 |
},
|
1247 |
-
"node_modules/esrecurse": {
|
1248 |
-
"version": "4.3.0",
|
1249 |
-
"resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz",
|
1250 |
-
"integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==",
|
1251 |
-
"dev": true,
|
1252 |
-
"license": "BSD-2-Clause",
|
1253 |
-
"dependencies": {
|
1254 |
-
"estraverse": "^5.2.0"
|
1255 |
-
},
|
1256 |
-
"engines": {
|
1257 |
-
"node": ">=4.0"
|
1258 |
-
}
|
1259 |
-
},
|
1260 |
"node_modules/estraverse": {
|
1261 |
"version": "5.3.0",
|
1262 |
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz",
|
@@ -1332,13 +1067,6 @@
|
|
1332 |
"url": "https://opencollective.com/express"
|
1333 |
}
|
1334 |
},
|
1335 |
-
"node_modules/fast-deep-equal": {
|
1336 |
-
"version": "3.1.3",
|
1337 |
-
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
|
1338 |
-
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
|
1339 |
-
"dev": true,
|
1340 |
-
"license": "MIT"
|
1341 |
-
},
|
1342 |
"node_modules/fast-levenshtein": {
|
1343 |
"version": "2.0.6",
|
1344 |
"resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz",
|
@@ -1384,22 +1112,6 @@
|
|
1384 |
}
|
1385 |
}
|
1386 |
},
|
1387 |
-
"node_modules/for-each": {
|
1388 |
-
"version": "0.3.5",
|
1389 |
-
"resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.5.tgz",
|
1390 |
-
"integrity": "sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==",
|
1391 |
-
"dev": true,
|
1392 |
-
"license": "MIT",
|
1393 |
-
"dependencies": {
|
1394 |
-
"is-callable": "^1.2.7"
|
1395 |
-
},
|
1396 |
-
"engines": {
|
1397 |
-
"node": ">= 0.4"
|
1398 |
-
},
|
1399 |
-
"funding": {
|
1400 |
-
"url": "https://github.com/sponsors/ljharb"
|
1401 |
-
}
|
1402 |
-
},
|
1403 |
"node_modules/form-data": {
|
1404 |
"version": "4.0.2",
|
1405 |
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.2.tgz",
|
@@ -1450,17 +1162,17 @@
|
|
1450 |
}
|
1451 |
},
|
1452 |
"node_modules/get-intrinsic": {
|
1453 |
-
"version": "1.
|
1454 |
-
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.
|
1455 |
-
"integrity": "sha512-
|
1456 |
"license": "MIT",
|
1457 |
"dependencies": {
|
1458 |
-
"call-bind-apply-helpers": "^1.0.
|
1459 |
"es-define-property": "^1.0.1",
|
1460 |
"es-errors": "^1.3.0",
|
1461 |
-
"es-object-atoms": "^1.
|
1462 |
"function-bind": "^1.1.2",
|
1463 |
-
"get-proto": "^1.0.
|
1464 |
"gopd": "^1.2.0",
|
1465 |
"has-symbols": "^1.1.0",
|
1466 |
"hasown": "^2.0.2",
|
@@ -1536,19 +1248,6 @@
|
|
1536 |
"node": ">=8"
|
1537 |
}
|
1538 |
},
|
1539 |
-
"node_modules/has-property-descriptors": {
|
1540 |
-
"version": "1.0.2",
|
1541 |
-
"resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz",
|
1542 |
-
"integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==",
|
1543 |
-
"dev": true,
|
1544 |
-
"license": "MIT",
|
1545 |
-
"dependencies": {
|
1546 |
-
"es-define-property": "^1.0.0"
|
1547 |
-
},
|
1548 |
-
"funding": {
|
1549 |
-
"url": "https://github.com/sponsors/ljharb"
|
1550 |
-
}
|
1551 |
-
},
|
1552 |
"node_modules/has-symbols": {
|
1553 |
"version": "1.1.0",
|
1554 |
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
|
@@ -1634,13 +1333,6 @@
|
|
1634 |
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
|
1635 |
"license": "ISC"
|
1636 |
},
|
1637 |
-
"node_modules/inversify": {
|
1638 |
-
"version": "6.0.1",
|
1639 |
-
"resolved": "https://registry.npmjs.org/inversify/-/inversify-6.0.1.tgz",
|
1640 |
-
"integrity": "sha512-B3ex30927698TJENHR++8FfEaJGqoWOgI6ZY5Ht/nLUsFCwHn6akbwtnUAPCgUepAnTpe2qHxhDNjoKLyz6rgQ==",
|
1641 |
-
"dev": true,
|
1642 |
-
"license": "MIT"
|
1643 |
-
},
|
1644 |
"node_modules/ipaddr.js": {
|
1645 |
"version": "1.9.1",
|
1646 |
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
|
@@ -1650,43 +1342,6 @@
|
|
1650 |
"node": ">= 0.10"
|
1651 |
}
|
1652 |
},
|
1653 |
-
"node_modules/is-arguments": {
|
1654 |
-
"version": "1.2.0",
|
1655 |
-
"resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.2.0.tgz",
|
1656 |
-
"integrity": "sha512-7bVbi0huj/wrIAOzb8U1aszg9kdi3KN/CyU19CTI7tAoZYEZoL9yCDXpbXN+uPsuWnP02cyug1gleqq+TU+YCA==",
|
1657 |
-
"dev": true,
|
1658 |
-
"license": "MIT",
|
1659 |
-
"dependencies": {
|
1660 |
-
"call-bound": "^1.0.2",
|
1661 |
-
"has-tostringtag": "^1.0.2"
|
1662 |
-
},
|
1663 |
-
"engines": {
|
1664 |
-
"node": ">= 0.4"
|
1665 |
-
},
|
1666 |
-
"funding": {
|
1667 |
-
"url": "https://github.com/sponsors/ljharb"
|
1668 |
-
}
|
1669 |
-
},
|
1670 |
-
"node_modules/is-buffer": {
|
1671 |
-
"version": "1.1.6",
|
1672 |
-
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
|
1673 |
-
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==",
|
1674 |
-
"dev": true,
|
1675 |
-
"license": "MIT"
|
1676 |
-
},
|
1677 |
-
"node_modules/is-callable": {
|
1678 |
-
"version": "1.2.7",
|
1679 |
-
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz",
|
1680 |
-
"integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==",
|
1681 |
-
"dev": true,
|
1682 |
-
"license": "MIT",
|
1683 |
-
"engines": {
|
1684 |
-
"node": ">= 0.4"
|
1685 |
-
},
|
1686 |
-
"funding": {
|
1687 |
-
"url": "https://github.com/sponsors/ljharb"
|
1688 |
-
}
|
1689 |
-
},
|
1690 |
"node_modules/is-docker": {
|
1691 |
"version": "3.0.0",
|
1692 |
"resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz",
|
@@ -1702,25 +1357,6 @@
|
|
1702 |
"url": "https://github.com/sponsors/sindresorhus"
|
1703 |
}
|
1704 |
},
|
1705 |
-
"node_modules/is-generator-function": {
|
1706 |
-
"version": "1.1.0",
|
1707 |
-
"resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.1.0.tgz",
|
1708 |
-
"integrity": "sha512-nPUB5km40q9e8UfN/Zc24eLlzdSf9OfKByBw9CIdw4H1giPMeA0OIJvbchsCu4npfI2QcMVBsGEBHKZ7wLTWmQ==",
|
1709 |
-
"dev": true,
|
1710 |
-
"license": "MIT",
|
1711 |
-
"dependencies": {
|
1712 |
-
"call-bound": "^1.0.3",
|
1713 |
-
"get-proto": "^1.0.0",
|
1714 |
-
"has-tostringtag": "^1.0.2",
|
1715 |
-
"safe-regex-test": "^1.1.0"
|
1716 |
-
},
|
1717 |
-
"engines": {
|
1718 |
-
"node": ">= 0.4"
|
1719 |
-
},
|
1720 |
-
"funding": {
|
1721 |
-
"url": "https://github.com/sponsors/ljharb"
|
1722 |
-
}
|
1723 |
-
},
|
1724 |
"node_modules/is-inside-container": {
|
1725 |
"version": "1.0.0",
|
1726 |
"resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz",
|
@@ -1739,58 +1375,6 @@
|
|
1739 |
"url": "https://github.com/sponsors/sindresorhus"
|
1740 |
}
|
1741 |
},
|
1742 |
-
"node_modules/is-nan": {
|
1743 |
-
"version": "1.3.2",
|
1744 |
-
"resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.3.2.tgz",
|
1745 |
-
"integrity": "sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w==",
|
1746 |
-
"dev": true,
|
1747 |
-
"license": "MIT",
|
1748 |
-
"dependencies": {
|
1749 |
-
"call-bind": "^1.0.0",
|
1750 |
-
"define-properties": "^1.1.3"
|
1751 |
-
},
|
1752 |
-
"engines": {
|
1753 |
-
"node": ">= 0.4"
|
1754 |
-
},
|
1755 |
-
"funding": {
|
1756 |
-
"url": "https://github.com/sponsors/ljharb"
|
1757 |
-
}
|
1758 |
-
},
|
1759 |
-
"node_modules/is-regex": {
|
1760 |
-
"version": "1.2.1",
|
1761 |
-
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.2.1.tgz",
|
1762 |
-
"integrity": "sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==",
|
1763 |
-
"dev": true,
|
1764 |
-
"license": "MIT",
|
1765 |
-
"dependencies": {
|
1766 |
-
"call-bound": "^1.0.2",
|
1767 |
-
"gopd": "^1.2.0",
|
1768 |
-
"has-tostringtag": "^1.0.2",
|
1769 |
-
"hasown": "^2.0.2"
|
1770 |
-
},
|
1771 |
-
"engines": {
|
1772 |
-
"node": ">= 0.4"
|
1773 |
-
},
|
1774 |
-
"funding": {
|
1775 |
-
"url": "https://github.com/sponsors/ljharb"
|
1776 |
-
}
|
1777 |
-
},
|
1778 |
-
"node_modules/is-typed-array": {
|
1779 |
-
"version": "1.1.15",
|
1780 |
-
"resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.15.tgz",
|
1781 |
-
"integrity": "sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ==",
|
1782 |
-
"dev": true,
|
1783 |
-
"license": "MIT",
|
1784 |
-
"dependencies": {
|
1785 |
-
"which-typed-array": "^1.1.16"
|
1786 |
-
},
|
1787 |
-
"engines": {
|
1788 |
-
"node": ">= 0.4"
|
1789 |
-
},
|
1790 |
-
"funding": {
|
1791 |
-
"url": "https://github.com/sponsors/ljharb"
|
1792 |
-
}
|
1793 |
-
},
|
1794 |
"node_modules/is-wsl": {
|
1795 |
"version": "3.1.0",
|
1796 |
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.0.tgz",
|
@@ -1806,98 +1390,6 @@
|
|
1806 |
"url": "https://github.com/sponsors/sindresorhus"
|
1807 |
}
|
1808 |
},
|
1809 |
-
"node_modules/javascript-obfuscator": {
|
1810 |
-
"version": "4.1.1",
|
1811 |
-
"resolved": "https://registry.npmjs.org/javascript-obfuscator/-/javascript-obfuscator-4.1.1.tgz",
|
1812 |
-
"integrity": "sha512-gt+KZpIIrrxXHEQGD8xZrL8mTRwRY0U76/xz/YX0gZdPrSqQhT/c7dYLASlLlecT3r+FxE7je/+C0oLnTDCx4A==",
|
1813 |
-
"dev": true,
|
1814 |
-
"hasInstallScript": true,
|
1815 |
-
"license": "BSD-2-Clause",
|
1816 |
-
"dependencies": {
|
1817 |
-
"@javascript-obfuscator/escodegen": "2.3.0",
|
1818 |
-
"@javascript-obfuscator/estraverse": "5.4.0",
|
1819 |
-
"acorn": "8.8.2",
|
1820 |
-
"assert": "2.0.0",
|
1821 |
-
"chalk": "4.1.2",
|
1822 |
-
"chance": "1.1.9",
|
1823 |
-
"class-validator": "0.14.1",
|
1824 |
-
"commander": "10.0.0",
|
1825 |
-
"eslint-scope": "7.1.1",
|
1826 |
-
"eslint-visitor-keys": "3.3.0",
|
1827 |
-
"fast-deep-equal": "3.1.3",
|
1828 |
-
"inversify": "6.0.1",
|
1829 |
-
"js-string-escape": "1.0.1",
|
1830 |
-
"md5": "2.3.0",
|
1831 |
-
"mkdirp": "2.1.3",
|
1832 |
-
"multimatch": "5.0.0",
|
1833 |
-
"opencollective-postinstall": "2.0.3",
|
1834 |
-
"process": "0.11.10",
|
1835 |
-
"reflect-metadata": "0.1.13",
|
1836 |
-
"source-map-support": "0.5.21",
|
1837 |
-
"string-template": "1.0.0",
|
1838 |
-
"stringz": "2.1.0",
|
1839 |
-
"tslib": "2.5.0"
|
1840 |
-
},
|
1841 |
-
"bin": {
|
1842 |
-
"javascript-obfuscator": "bin/javascript-obfuscator"
|
1843 |
-
},
|
1844 |
-
"engines": {
|
1845 |
-
"node": ">=12.22.0"
|
1846 |
-
},
|
1847 |
-
"funding": {
|
1848 |
-
"type": "opencollective",
|
1849 |
-
"url": "https://opencollective.com/javascript-obfuscator"
|
1850 |
-
}
|
1851 |
-
},
|
1852 |
-
"node_modules/javascript-obfuscator/node_modules/acorn": {
|
1853 |
-
"version": "8.8.2",
|
1854 |
-
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.2.tgz",
|
1855 |
-
"integrity": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==",
|
1856 |
-
"dev": true,
|
1857 |
-
"license": "MIT",
|
1858 |
-
"bin": {
|
1859 |
-
"acorn": "bin/acorn"
|
1860 |
-
},
|
1861 |
-
"engines": {
|
1862 |
-
"node": ">=0.4.0"
|
1863 |
-
}
|
1864 |
-
},
|
1865 |
-
"node_modules/javascript-obfuscator/node_modules/eslint-visitor-keys": {
|
1866 |
-
"version": "3.3.0",
|
1867 |
-
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz",
|
1868 |
-
"integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==",
|
1869 |
-
"dev": true,
|
1870 |
-
"license": "Apache-2.0",
|
1871 |
-
"engines": {
|
1872 |
-
"node": "^12.22.0 || ^14.17.0 || >=16.0.0"
|
1873 |
-
}
|
1874 |
-
},
|
1875 |
-
"node_modules/javascript-obfuscator/node_modules/mkdirp": {
|
1876 |
-
"version": "2.1.3",
|
1877 |
-
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-2.1.3.tgz",
|
1878 |
-
"integrity": "sha512-sjAkg21peAG9HS+Dkx7hlG9Ztx7HLeKnvB3NQRcu/mltCVmvkF0pisbiTSfDVYTT86XEfZrTUosLdZLStquZUw==",
|
1879 |
-
"dev": true,
|
1880 |
-
"license": "MIT",
|
1881 |
-
"bin": {
|
1882 |
-
"mkdirp": "dist/cjs/src/bin.js"
|
1883 |
-
},
|
1884 |
-
"engines": {
|
1885 |
-
"node": ">=10"
|
1886 |
-
},
|
1887 |
-
"funding": {
|
1888 |
-
"url": "https://github.com/sponsors/isaacs"
|
1889 |
-
}
|
1890 |
-
},
|
1891 |
-
"node_modules/js-string-escape": {
|
1892 |
-
"version": "1.0.1",
|
1893 |
-
"resolved": "https://registry.npmjs.org/js-string-escape/-/js-string-escape-1.0.1.tgz",
|
1894 |
-
"integrity": "sha512-Smw4xcfIQ5LVjAOuJCvN/zIodzA/BBSsluuoSykP+lUvScIi4U6RJLfwHet5cxFnCswUjISV8oAXaqaJDY3chg==",
|
1895 |
-
"dev": true,
|
1896 |
-
"license": "MIT",
|
1897 |
-
"engines": {
|
1898 |
-
"node": ">= 0.8"
|
1899 |
-
}
|
1900 |
-
},
|
1901 |
"node_modules/js2xmlparser": {
|
1902 |
"version": "4.0.2",
|
1903 |
"resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-4.0.2.tgz",
|
@@ -2011,13 +1503,6 @@
|
|
2011 |
"node": ">= 0.8.0"
|
2012 |
}
|
2013 |
},
|
2014 |
-
"node_modules/libphonenumber-js": {
|
2015 |
-
"version": "1.12.8",
|
2016 |
-
"resolved": "https://registry.npmjs.org/libphonenumber-js/-/libphonenumber-js-1.12.8.tgz",
|
2017 |
-
"integrity": "sha512-f1KakiQJa9tdc7w1phC2ST+DyxWimy9c3g3yeF+84QtEanJr2K77wAmBPP22riU05xldniHsvXuflnLZ4oysqA==",
|
2018 |
-
"dev": true,
|
2019 |
-
"license": "MIT"
|
2020 |
-
},
|
2021 |
"node_modules/linkify-it": {
|
2022 |
"version": "5.0.0",
|
2023 |
"resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz",
|
@@ -2142,18 +1627,6 @@
|
|
2142 |
"node": ">= 0.4"
|
2143 |
}
|
2144 |
},
|
2145 |
-
"node_modules/md5": {
|
2146 |
-
"version": "2.3.0",
|
2147 |
-
"resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz",
|
2148 |
-
"integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==",
|
2149 |
-
"dev": true,
|
2150 |
-
"license": "BSD-3-Clause",
|
2151 |
-
"dependencies": {
|
2152 |
-
"charenc": "0.0.2",
|
2153 |
-
"crypt": "0.0.2",
|
2154 |
-
"is-buffer": "~1.1.6"
|
2155 |
-
}
|
2156 |
-
},
|
2157 |
"node_modules/mdurl": {
|
2158 |
"version": "2.0.0",
|
2159 |
"resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz",
|
@@ -2291,50 +1764,6 @@
|
|
2291 |
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
|
2292 |
"license": "MIT"
|
2293 |
},
|
2294 |
-
"node_modules/multimatch": {
|
2295 |
-
"version": "5.0.0",
|
2296 |
-
"resolved": "https://registry.npmjs.org/multimatch/-/multimatch-5.0.0.tgz",
|
2297 |
-
"integrity": "sha512-ypMKuglUrZUD99Tk2bUQ+xNQj43lPEfAeX2o9cTteAmShXy2VHDJpuwu1o0xqoKCt9jLVAvwyFKdLTPXKAfJyA==",
|
2298 |
-
"dev": true,
|
2299 |
-
"license": "MIT",
|
2300 |
-
"dependencies": {
|
2301 |
-
"@types/minimatch": "^3.0.3",
|
2302 |
-
"array-differ": "^3.0.0",
|
2303 |
-
"array-union": "^2.1.0",
|
2304 |
-
"arrify": "^2.0.1",
|
2305 |
-
"minimatch": "^3.0.4"
|
2306 |
-
},
|
2307 |
-
"engines": {
|
2308 |
-
"node": ">=10"
|
2309 |
-
},
|
2310 |
-
"funding": {
|
2311 |
-
"url": "https://github.com/sponsors/sindresorhus"
|
2312 |
-
}
|
2313 |
-
},
|
2314 |
-
"node_modules/multimatch/node_modules/brace-expansion": {
|
2315 |
-
"version": "1.1.11",
|
2316 |
-
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
2317 |
-
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
2318 |
-
"dev": true,
|
2319 |
-
"license": "MIT",
|
2320 |
-
"dependencies": {
|
2321 |
-
"balanced-match": "^1.0.0",
|
2322 |
-
"concat-map": "0.0.1"
|
2323 |
-
}
|
2324 |
-
},
|
2325 |
-
"node_modules/multimatch/node_modules/minimatch": {
|
2326 |
-
"version": "3.1.2",
|
2327 |
-
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
2328 |
-
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
|
2329 |
-
"dev": true,
|
2330 |
-
"license": "ISC",
|
2331 |
-
"dependencies": {
|
2332 |
-
"brace-expansion": "^1.1.7"
|
2333 |
-
},
|
2334 |
-
"engines": {
|
2335 |
-
"node": "*"
|
2336 |
-
}
|
2337 |
-
},
|
2338 |
"node_modules/negotiator": {
|
2339 |
"version": "0.6.3",
|
2340 |
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
|
@@ -2397,33 +1826,6 @@
|
|
2397 |
"url": "https://github.com/sponsors/ljharb"
|
2398 |
}
|
2399 |
},
|
2400 |
-
"node_modules/object-is": {
|
2401 |
-
"version": "1.1.6",
|
2402 |
-
"resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.6.tgz",
|
2403 |
-
"integrity": "sha512-F8cZ+KfGlSGi09lJT7/Nd6KJZ9ygtvYC0/UYYLI9nmQKLMnydpB9yvbv9K1uSkEu7FU9vYPmVwLg328tX+ot3Q==",
|
2404 |
-
"dev": true,
|
2405 |
-
"license": "MIT",
|
2406 |
-
"dependencies": {
|
2407 |
-
"call-bind": "^1.0.7",
|
2408 |
-
"define-properties": "^1.2.1"
|
2409 |
-
},
|
2410 |
-
"engines": {
|
2411 |
-
"node": ">= 0.4"
|
2412 |
-
},
|
2413 |
-
"funding": {
|
2414 |
-
"url": "https://github.com/sponsors/ljharb"
|
2415 |
-
}
|
2416 |
-
},
|
2417 |
-
"node_modules/object-keys": {
|
2418 |
-
"version": "1.1.1",
|
2419 |
-
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
|
2420 |
-
"integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==",
|
2421 |
-
"dev": true,
|
2422 |
-
"license": "MIT",
|
2423 |
-
"engines": {
|
2424 |
-
"node": ">= 0.4"
|
2425 |
-
}
|
2426 |
-
},
|
2427 |
"node_modules/on-finished": {
|
2428 |
"version": "2.4.1",
|
2429 |
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
|
@@ -2472,16 +1874,6 @@
|
|
2472 |
"url": "https://github.com/sponsors/sindresorhus"
|
2473 |
}
|
2474 |
},
|
2475 |
-
"node_modules/opencollective-postinstall": {
|
2476 |
-
"version": "2.0.3",
|
2477 |
-
"resolved": "https://registry.npmjs.org/opencollective-postinstall/-/opencollective-postinstall-2.0.3.tgz",
|
2478 |
-
"integrity": "sha512-8AV/sCtuzUeTo8gQK5qDZzARrulB3egtLzFgteqB2tcT4Mw7B8Kt7JcDHmltjz6FOAHsvTevk70gZEbhM4ZS9Q==",
|
2479 |
-
"dev": true,
|
2480 |
-
"license": "MIT",
|
2481 |
-
"bin": {
|
2482 |
-
"opencollective-postinstall": "index.js"
|
2483 |
-
}
|
2484 |
-
},
|
2485 |
"node_modules/optionator": {
|
2486 |
"version": "0.8.3",
|
2487 |
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz",
|
@@ -2515,16 +1907,6 @@
|
|
2515 |
"integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==",
|
2516 |
"license": "MIT"
|
2517 |
},
|
2518 |
-
"node_modules/possible-typed-array-names": {
|
2519 |
-
"version": "1.1.0",
|
2520 |
-
"resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz",
|
2521 |
-
"integrity": "sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==",
|
2522 |
-
"dev": true,
|
2523 |
-
"license": "MIT",
|
2524 |
-
"engines": {
|
2525 |
-
"node": ">= 0.4"
|
2526 |
-
}
|
2527 |
-
},
|
2528 |
"node_modules/prelude-ls": {
|
2529 |
"version": "1.1.2",
|
2530 |
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz",
|
@@ -2534,16 +1916,6 @@
|
|
2534 |
"node": ">= 0.8.0"
|
2535 |
}
|
2536 |
},
|
2537 |
-
"node_modules/process": {
|
2538 |
-
"version": "0.11.10",
|
2539 |
-
"resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
|
2540 |
-
"integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==",
|
2541 |
-
"dev": true,
|
2542 |
-
"license": "MIT",
|
2543 |
-
"engines": {
|
2544 |
-
"node": ">= 0.6.0"
|
2545 |
-
}
|
2546 |
-
},
|
2547 |
"node_modules/protobufjs": {
|
2548 |
"version": "7.4.0",
|
2549 |
"resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.4.0.tgz",
|
@@ -2665,13 +2037,6 @@
|
|
2665 |
"node": ">= 0.8"
|
2666 |
}
|
2667 |
},
|
2668 |
-
"node_modules/reflect-metadata": {
|
2669 |
-
"version": "0.1.13",
|
2670 |
-
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.13.tgz",
|
2671 |
-
"integrity": "sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==",
|
2672 |
-
"dev": true,
|
2673 |
-
"license": "Apache-2.0"
|
2674 |
-
},
|
2675 |
"node_modules/requizzle": {
|
2676 |
"version": "0.2.4",
|
2677 |
"resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.4.tgz",
|
@@ -2714,24 +2079,6 @@
|
|
2714 |
],
|
2715 |
"license": "MIT"
|
2716 |
},
|
2717 |
-
"node_modules/safe-regex-test": {
|
2718 |
-
"version": "1.1.0",
|
2719 |
-
"resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.1.0.tgz",
|
2720 |
-
"integrity": "sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw==",
|
2721 |
-
"dev": true,
|
2722 |
-
"license": "MIT",
|
2723 |
-
"dependencies": {
|
2724 |
-
"call-bound": "^1.0.2",
|
2725 |
-
"es-errors": "^1.3.0",
|
2726 |
-
"is-regex": "^1.2.1"
|
2727 |
-
},
|
2728 |
-
"engines": {
|
2729 |
-
"node": ">= 0.4"
|
2730 |
-
},
|
2731 |
-
"funding": {
|
2732 |
-
"url": "https://github.com/sponsors/ljharb"
|
2733 |
-
}
|
2734 |
-
},
|
2735 |
"node_modules/safer-buffer": {
|
2736 |
"version": "2.1.2",
|
2737 |
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
@@ -2804,24 +2151,6 @@
|
|
2804 |
"node": ">= 0.8.0"
|
2805 |
}
|
2806 |
},
|
2807 |
-
"node_modules/set-function-length": {
|
2808 |
-
"version": "1.2.2",
|
2809 |
-
"resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz",
|
2810 |
-
"integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==",
|
2811 |
-
"dev": true,
|
2812 |
-
"license": "MIT",
|
2813 |
-
"dependencies": {
|
2814 |
-
"define-data-property": "^1.1.4",
|
2815 |
-
"es-errors": "^1.3.0",
|
2816 |
-
"function-bind": "^1.1.2",
|
2817 |
-
"get-intrinsic": "^1.2.4",
|
2818 |
-
"gopd": "^1.0.1",
|
2819 |
-
"has-property-descriptors": "^1.0.2"
|
2820 |
-
},
|
2821 |
-
"engines": {
|
2822 |
-
"node": ">= 0.4"
|
2823 |
-
}
|
2824 |
-
},
|
2825 |
"node_modules/setprototypeof": {
|
2826 |
"version": "1.2.0",
|
2827 |
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
|
@@ -2906,21 +2235,11 @@
|
|
2906 |
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
2907 |
"dev": true,
|
2908 |
"license": "BSD-3-Clause",
|
|
|
2909 |
"engines": {
|
2910 |
"node": ">=0.10.0"
|
2911 |
}
|
2912 |
},
|
2913 |
-
"node_modules/source-map-support": {
|
2914 |
-
"version": "0.5.21",
|
2915 |
-
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz",
|
2916 |
-
"integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==",
|
2917 |
-
"dev": true,
|
2918 |
-
"license": "MIT",
|
2919 |
-
"dependencies": {
|
2920 |
-
"buffer-from": "^1.0.0",
|
2921 |
-
"source-map": "^0.6.0"
|
2922 |
-
}
|
2923 |
-
},
|
2924 |
"node_modules/statuses": {
|
2925 |
"version": "2.0.1",
|
2926 |
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
|
@@ -2930,23 +2249,6 @@
|
|
2930 |
"node": ">= 0.8"
|
2931 |
}
|
2932 |
},
|
2933 |
-
"node_modules/string-template": {
|
2934 |
-
"version": "1.0.0",
|
2935 |
-
"resolved": "https://registry.npmjs.org/string-template/-/string-template-1.0.0.tgz",
|
2936 |
-
"integrity": "sha512-SLqR3GBUXuoPP5MmYtD7ompvXiG87QjT6lzOszyXjTM86Uu7At7vNnt2xgyTLq5o9T4IxTYFyGxcULqpsmsfdg==",
|
2937 |
-
"dev": true,
|
2938 |
-
"license": "MIT"
|
2939 |
-
},
|
2940 |
-
"node_modules/stringz": {
|
2941 |
-
"version": "2.1.0",
|
2942 |
-
"resolved": "https://registry.npmjs.org/stringz/-/stringz-2.1.0.tgz",
|
2943 |
-
"integrity": "sha512-KlywLT+MZ+v0IRepfMxRtnSvDCMc3nR1qqCs3m/qIbSOWkNZYT8XHQA31rS3TnKp0c5xjZu3M4GY/2aRKSi/6A==",
|
2944 |
-
"dev": true,
|
2945 |
-
"license": "MIT",
|
2946 |
-
"dependencies": {
|
2947 |
-
"char-regex": "^1.0.2"
|
2948 |
-
}
|
2949 |
-
},
|
2950 |
"node_modules/strip-json-comments": {
|
2951 |
"version": "3.1.1",
|
2952 |
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
|
@@ -2998,13 +2300,6 @@
|
|
2998 |
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
|
2999 |
"license": "MIT"
|
3000 |
},
|
3001 |
-
"node_modules/tslib": {
|
3002 |
-
"version": "2.5.0",
|
3003 |
-
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
|
3004 |
-
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==",
|
3005 |
-
"dev": true,
|
3006 |
-
"license": "0BSD"
|
3007 |
-
},
|
3008 |
"node_modules/type-check": {
|
3009 |
"version": "0.3.2",
|
3010 |
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz",
|
@@ -3088,20 +2383,6 @@
|
|
3088 |
"node": ">= 0.8"
|
3089 |
}
|
3090 |
},
|
3091 |
-
"node_modules/util": {
|
3092 |
-
"version": "0.12.5",
|
3093 |
-
"resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz",
|
3094 |
-
"integrity": "sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==",
|
3095 |
-
"dev": true,
|
3096 |
-
"license": "MIT",
|
3097 |
-
"dependencies": {
|
3098 |
-
"inherits": "^2.0.3",
|
3099 |
-
"is-arguments": "^1.0.4",
|
3100 |
-
"is-generator-function": "^1.0.7",
|
3101 |
-
"is-typed-array": "^1.1.3",
|
3102 |
-
"which-typed-array": "^1.1.2"
|
3103 |
-
}
|
3104 |
-
},
|
3105 |
"node_modules/utils-merge": {
|
3106 |
"version": "1.0.1",
|
3107 |
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
|
@@ -3124,16 +2405,6 @@
|
|
3124 |
"uuid": "dist/esm/bin/uuid"
|
3125 |
}
|
3126 |
},
|
3127 |
-
"node_modules/validator": {
|
3128 |
-
"version": "13.15.0",
|
3129 |
-
"resolved": "https://registry.npmjs.org/validator/-/validator-13.15.0.tgz",
|
3130 |
-
"integrity": "sha512-36B2ryl4+oL5QxZ3AzD0t5SsMNGvTtQHpjgFO5tbNxfXbMFkY822ktCDe1MnlqV3301QQI9SLHDNJokDI+Z9pA==",
|
3131 |
-
"dev": true,
|
3132 |
-
"license": "MIT",
|
3133 |
-
"engines": {
|
3134 |
-
"node": ">= 0.10"
|
3135 |
-
}
|
3136 |
-
},
|
3137 |
"node_modules/vary": {
|
3138 |
"version": "1.1.2",
|
3139 |
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
|
@@ -3159,28 +2430,6 @@
|
|
3159 |
"webidl-conversions": "^3.0.0"
|
3160 |
}
|
3161 |
},
|
3162 |
-
"node_modules/which-typed-array": {
|
3163 |
-
"version": "1.1.19",
|
3164 |
-
"resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.19.tgz",
|
3165 |
-
"integrity": "sha512-rEvr90Bck4WZt9HHFC4DJMsjvu7x+r6bImz0/BrbWb7A2djJ8hnZMrWnHo9F8ssv0OMErasDhftrfROTyqSDrw==",
|
3166 |
-
"dev": true,
|
3167 |
-
"license": "MIT",
|
3168 |
-
"dependencies": {
|
3169 |
-
"available-typed-arrays": "^1.0.7",
|
3170 |
-
"call-bind": "^1.0.8",
|
3171 |
-
"call-bound": "^1.0.4",
|
3172 |
-
"for-each": "^0.3.5",
|
3173 |
-
"get-proto": "^1.0.1",
|
3174 |
-
"gopd": "^1.2.0",
|
3175 |
-
"has-tostringtag": "^1.0.2"
|
3176 |
-
},
|
3177 |
-
"engines": {
|
3178 |
-
"node": ">= 0.4"
|
3179 |
-
},
|
3180 |
-
"funding": {
|
3181 |
-
"url": "https://github.com/sponsors/ljharb"
|
3182 |
-
}
|
3183 |
-
},
|
3184 |
"node_modules/word-wrap": {
|
3185 |
"version": "1.2.5",
|
3186 |
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz",
|
|
|
27 |
"uuid": "11.0.5"
|
28 |
},
|
29 |
"devDependencies": {
|
|
|
30 |
"protobufjs-cli": "^1.1.3"
|
31 |
}
|
32 |
},
|
|
|
80 |
"node": ">=6.9.0"
|
81 |
}
|
82 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
"node_modules/@jsdoc/salty": {
|
84 |
"version": "0.2.9",
|
85 |
"resolved": "https://registry.npmjs.org/@jsdoc/salty/-/salty-0.2.9.tgz",
|
|
|
337 |
"dev": true,
|
338 |
"license": "MIT"
|
339 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
340 |
"node_modules/@types/node": {
|
341 |
"version": "22.10.5",
|
342 |
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.5.tgz",
|
|
|
346 |
"undici-types": "~6.20.0"
|
347 |
}
|
348 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
"node_modules/accepts": {
|
350 |
"version": "1.3.8",
|
351 |
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
|
|
|
414 |
"dev": true,
|
415 |
"license": "Python-2.0"
|
416 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
417 |
"node_modules/array-flatten": {
|
418 |
"version": "1.1.1",
|
419 |
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
|
420 |
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
|
421 |
"license": "MIT"
|
422 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
423 |
"node_modules/asynckit": {
|
424 |
"version": "0.4.0",
|
425 |
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
426 |
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
|
427 |
"license": "MIT"
|
428 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
429 |
"node_modules/axios": {
|
430 |
"version": "1.8.3",
|
431 |
"resolved": "https://registry.npmjs.org/axios/-/axios-1.8.3.tgz",
|
|
|
515 |
"integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==",
|
516 |
"license": "BSD-3-Clause"
|
517 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
518 |
"node_modules/bundle-name": {
|
519 |
"version": "4.1.0",
|
520 |
"resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-4.1.0.tgz",
|
|
|
539 |
"node": ">= 0.8"
|
540 |
}
|
541 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
542 |
"node_modules/call-bind-apply-helpers": {
|
543 |
+
"version": "1.0.1",
|
544 |
+
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.1.tgz",
|
545 |
+
"integrity": "sha512-BhYE+WDaywFg2TBWYNXAE+8B1ATnThNBqXHP5nQu0jWJdVvY2hvkpyB3qOmtmDePiS5/BDQ8wASEWGMWRG148g==",
|
546 |
"license": "MIT",
|
547 |
"dependencies": {
|
548 |
"es-errors": "^1.3.0",
|
|
|
553 |
}
|
554 |
},
|
555 |
"node_modules/call-bound": {
|
556 |
+
"version": "1.0.3",
|
557 |
+
"resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.3.tgz",
|
558 |
+
"integrity": "sha512-YTd+6wGlNlPxSuri7Y6X8tY2dmm12UMH66RpKMhiX6rsk5wXXnYgbUcOt8kiS31/AjfoTOvCsE+w8nZQLQnzHA==",
|
559 |
"license": "MIT",
|
560 |
"dependencies": {
|
561 |
+
"call-bind-apply-helpers": "^1.0.1",
|
562 |
+
"get-intrinsic": "^1.2.6"
|
563 |
},
|
564 |
"engines": {
|
565 |
"node": ">= 0.4"
|
|
|
598 |
"url": "https://github.com/chalk/chalk?sponsor=1"
|
599 |
}
|
600 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
601 |
"node_modules/color-convert": {
|
602 |
"version": "2.0.1",
|
603 |
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
|
|
630 |
"node": ">= 0.8"
|
631 |
}
|
632 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
633 |
"node_modules/content-disposition": {
|
634 |
"version": "0.5.4",
|
635 |
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
|
|
|
688 |
"integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==",
|
689 |
"license": "MIT"
|
690 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
691 |
"node_modules/csv-parser": {
|
692 |
"version": "3.2.0",
|
693 |
"resolved": "https://registry.npmjs.org/csv-parser/-/csv-parser-3.2.0.tgz",
|
|
|
744 |
"url": "https://github.com/sponsors/sindresorhus"
|
745 |
}
|
746 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
747 |
"node_modules/define-lazy-prop": {
|
748 |
"version": "3.0.0",
|
749 |
"resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz",
|
|
|
756 |
"url": "https://github.com/sponsors/sindresorhus"
|
757 |
}
|
758 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
759 |
"node_modules/delayed-stream": {
|
760 |
"version": "1.0.0",
|
761 |
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
|
|
872 |
}
|
873 |
},
|
874 |
"node_modules/es-object-atoms": {
|
875 |
+
"version": "1.0.0",
|
876 |
+
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.0.0.tgz",
|
877 |
+
"integrity": "sha512-MZ4iQ6JwHOBQjahnjwaC1ZtIBH+2ohjamzAO3oaHcXYup7qxjF2fixyH+Q71voWHeOkI2q/TnJao/KfXYIZWbw==",
|
878 |
"license": "MIT",
|
879 |
"dependencies": {
|
880 |
"es-errors": "^1.3.0"
|
|
|
898 |
"node": ">= 0.4"
|
899 |
}
|
900 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
901 |
"node_modules/escape-html": {
|
902 |
"version": "1.0.3",
|
903 |
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
|
|
|
947 |
"node": ">=4.0"
|
948 |
}
|
949 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
950 |
"node_modules/eslint-visitor-keys": {
|
951 |
"version": "3.4.3",
|
952 |
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz",
|
|
|
992 |
"node": ">=4"
|
993 |
}
|
994 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
995 |
"node_modules/estraverse": {
|
996 |
"version": "5.3.0",
|
997 |
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz",
|
|
|
1067 |
"url": "https://opencollective.com/express"
|
1068 |
}
|
1069 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1070 |
"node_modules/fast-levenshtein": {
|
1071 |
"version": "2.0.6",
|
1072 |
"resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz",
|
|
|
1112 |
}
|
1113 |
}
|
1114 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1115 |
"node_modules/form-data": {
|
1116 |
"version": "4.0.2",
|
1117 |
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.2.tgz",
|
|
|
1162 |
}
|
1163 |
},
|
1164 |
"node_modules/get-intrinsic": {
|
1165 |
+
"version": "1.2.7",
|
1166 |
+
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.7.tgz",
|
1167 |
+
"integrity": "sha512-VW6Pxhsrk0KAOqs3WEd0klDiF/+V7gQOpAvY1jVU/LHmaD/kQO4523aiJuikX/QAKYiW6x8Jh+RJej1almdtCA==",
|
1168 |
"license": "MIT",
|
1169 |
"dependencies": {
|
1170 |
+
"call-bind-apply-helpers": "^1.0.1",
|
1171 |
"es-define-property": "^1.0.1",
|
1172 |
"es-errors": "^1.3.0",
|
1173 |
+
"es-object-atoms": "^1.0.0",
|
1174 |
"function-bind": "^1.1.2",
|
1175 |
+
"get-proto": "^1.0.0",
|
1176 |
"gopd": "^1.2.0",
|
1177 |
"has-symbols": "^1.1.0",
|
1178 |
"hasown": "^2.0.2",
|
|
|
1248 |
"node": ">=8"
|
1249 |
}
|
1250 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1251 |
"node_modules/has-symbols": {
|
1252 |
"version": "1.1.0",
|
1253 |
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
|
|
|
1333 |
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
|
1334 |
"license": "ISC"
|
1335 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1336 |
"node_modules/ipaddr.js": {
|
1337 |
"version": "1.9.1",
|
1338 |
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
|
|
|
1342 |
"node": ">= 0.10"
|
1343 |
}
|
1344 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1345 |
"node_modules/is-docker": {
|
1346 |
"version": "3.0.0",
|
1347 |
"resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz",
|
|
|
1357 |
"url": "https://github.com/sponsors/sindresorhus"
|
1358 |
}
|
1359 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1360 |
"node_modules/is-inside-container": {
|
1361 |
"version": "1.0.0",
|
1362 |
"resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz",
|
|
|
1375 |
"url": "https://github.com/sponsors/sindresorhus"
|
1376 |
}
|
1377 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1378 |
"node_modules/is-wsl": {
|
1379 |
"version": "3.1.0",
|
1380 |
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.0.tgz",
|
|
|
1390 |
"url": "https://github.com/sponsors/sindresorhus"
|
1391 |
}
|
1392 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1393 |
"node_modules/js2xmlparser": {
|
1394 |
"version": "4.0.2",
|
1395 |
"resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-4.0.2.tgz",
|
|
|
1503 |
"node": ">= 0.8.0"
|
1504 |
}
|
1505 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1506 |
"node_modules/linkify-it": {
|
1507 |
"version": "5.0.0",
|
1508 |
"resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-5.0.0.tgz",
|
|
|
1627 |
"node": ">= 0.4"
|
1628 |
}
|
1629 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1630 |
"node_modules/mdurl": {
|
1631 |
"version": "2.0.0",
|
1632 |
"resolved": "https://registry.npmjs.org/mdurl/-/mdurl-2.0.0.tgz",
|
|
|
1764 |
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
|
1765 |
"license": "MIT"
|
1766 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1767 |
"node_modules/negotiator": {
|
1768 |
"version": "0.6.3",
|
1769 |
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
|
|
|
1826 |
"url": "https://github.com/sponsors/ljharb"
|
1827 |
}
|
1828 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1829 |
"node_modules/on-finished": {
|
1830 |
"version": "2.4.1",
|
1831 |
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
|
|
|
1874 |
"url": "https://github.com/sponsors/sindresorhus"
|
1875 |
}
|
1876 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1877 |
"node_modules/optionator": {
|
1878 |
"version": "0.8.3",
|
1879 |
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz",
|
|
|
1907 |
"integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==",
|
1908 |
"license": "MIT"
|
1909 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1910 |
"node_modules/prelude-ls": {
|
1911 |
"version": "1.1.2",
|
1912 |
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz",
|
|
|
1916 |
"node": ">= 0.8.0"
|
1917 |
}
|
1918 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1919 |
"node_modules/protobufjs": {
|
1920 |
"version": "7.4.0",
|
1921 |
"resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-7.4.0.tgz",
|
|
|
2037 |
"node": ">= 0.8"
|
2038 |
}
|
2039 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2040 |
"node_modules/requizzle": {
|
2041 |
"version": "0.2.4",
|
2042 |
"resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.4.tgz",
|
|
|
2079 |
],
|
2080 |
"license": "MIT"
|
2081 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2082 |
"node_modules/safer-buffer": {
|
2083 |
"version": "2.1.2",
|
2084 |
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
|
|
2151 |
"node": ">= 0.8.0"
|
2152 |
}
|
2153 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2154 |
"node_modules/setprototypeof": {
|
2155 |
"version": "1.2.0",
|
2156 |
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
|
|
|
2235 |
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
2236 |
"dev": true,
|
2237 |
"license": "BSD-3-Clause",
|
2238 |
+
"optional": true,
|
2239 |
"engines": {
|
2240 |
"node": ">=0.10.0"
|
2241 |
}
|
2242 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2243 |
"node_modules/statuses": {
|
2244 |
"version": "2.0.1",
|
2245 |
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
|
|
|
2249 |
"node": ">= 0.8"
|
2250 |
}
|
2251 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2252 |
"node_modules/strip-json-comments": {
|
2253 |
"version": "3.1.1",
|
2254 |
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
|
|
|
2300 |
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
|
2301 |
"license": "MIT"
|
2302 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2303 |
"node_modules/type-check": {
|
2304 |
"version": "0.3.2",
|
2305 |
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz",
|
|
|
2383 |
"node": ">= 0.8"
|
2384 |
}
|
2385 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2386 |
"node_modules/utils-merge": {
|
2387 |
"version": "1.0.1",
|
2388 |
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
|
|
|
2405 |
"uuid": "dist/esm/bin/uuid"
|
2406 |
}
|
2407 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2408 |
"node_modules/vary": {
|
2409 |
"version": "1.1.2",
|
2410 |
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
|
|
|
2430 |
"webidl-conversions": "^3.0.0"
|
2431 |
}
|
2432 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2433 |
"node_modules/word-wrap": {
|
2434 |
"version": "1.2.5",
|
2435 |
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz",
|
package.json
CHANGED
@@ -36,7 +36,6 @@
|
|
36 |
"manage-cookies": "node manage-invalid-cookies.js"
|
37 |
},
|
38 |
"devDependencies": {
|
39 |
-
"javascript-obfuscator": "^4.1.1",
|
40 |
"protobufjs-cli": "^1.1.3"
|
41 |
}
|
42 |
}
|
|
|
36 |
"manage-cookies": "node manage-invalid-cookies.js"
|
37 |
},
|
38 |
"devDependencies": {
|
|
|
39 |
"protobufjs-cli": "^1.1.3"
|
40 |
}
|
41 |
}
|
src/app.js
CHANGED
@@ -1 +1,202 @@
|
|
1 |
-
const a0_0xe54be6=a0_0x429a;(function(_0x3ed962,_0x3c2d0a){const _0x29ddc6=a0_0x429a,_0x4935fa=_0x3ed962();while(!![]){try{const _0x5a9ec6=-parseInt(_0x29ddc6(0x112))/0x1+parseInt(_0x29ddc6(0x109))/0x2*(parseInt(_0x29ddc6(0xdc))/0x3)+parseInt(_0x29ddc6(0xe1))/0x4*(-parseInt(_0x29ddc6(0xf3))/0x5)+parseInt(_0x29ddc6(0xff))/0x6+parseInt(_0x29ddc6(0xf6))/0x7+parseInt(_0x29ddc6(0xf9))/0x8*(parseInt(_0x29ddc6(0xfd))/0x9)+-parseInt(_0x29ddc6(0x10f))/0xa*(parseInt(_0x29ddc6(0x13a))/0xb);if(_0x5a9ec6===_0x3c2d0a)break;else _0x4935fa['push'](_0x4935fa['shift']());}catch(_0x3da7d6){_0x4935fa['push'](_0x4935fa['shift']());}}}(a0_0x2781,0xbb2f4),require(a0_0xe54be6(0x11b))[a0_0xe54be6(0xed)]());function tempLog(_0x5b1422,_0x57598c){const _0x468849=a0_0xe54be6,_0x1ae502=(function(){let _0x48e219=!![];return function(_0x1b9e66,_0x3dd3d9){const _0x43d28e=_0x48e219?function(){const _0x41ff21=a0_0x429a;if(_0x3dd3d9){const _0x140190=_0x3dd3d9[_0x41ff21(0xfb)](_0x1b9e66,arguments);return _0x3dd3d9=null,_0x140190;}}:function(){};return _0x48e219=![],_0x43d28e;};}()),_0x3a1cfb=_0x1ae502(this,function(){const _0x4fa2d6=a0_0x429a;return _0x3a1cfb[_0x4fa2d6(0xf5)]()[_0x4fa2d6(0xef)]('(((.+)+)+)+$')['toString']()[_0x4fa2d6(0xe7)](_0x3a1cfb)[_0x4fa2d6(0xef)](_0x4fa2d6(0x11a));});_0x3a1cfb();const _0x148236=new Date()['toISOString']();if(_0x5b1422===_0x468849(0x11e))console['error'](_0x468849(0x132)+_0x148236+'\x20'+_0x57598c);else _0x5b1422==='WARN'?console['warn'](_0x468849(0xfe)+_0x148236+'\x20'+_0x57598c):console['log']('[INFO]\x20'+_0x148236+'\x20'+_0x57598c);}function a0_0x429a(_0x1bca4e,_0x4a81cd){const _0x4cde13=a0_0x2781();return a0_0x429a=function(_0xe5ebfc,_0x195ad9){_0xe5ebfc=_0xe5ebfc-0xd9;let _0x278172=_0x4cde13[_0xe5ebfc];if(a0_0x429a['ahOtuW']===undefined){var _0x429a89=function(_0x2bd5b9){const _0x2a0b8a='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x5846bb='',_0x5b1422='',_0x57598c=_0x5846bb+_0x429a89;for(let _0x1ae502=0x0,_0x3a1cfb,_0x148236,_0x48e219=0x0;_0x148236=_0x2bd5b9['charAt'](_0x48e219++);~_0x148236&&(_0x3a1cfb=_0x1ae502%0x4?_0x3a1cfb*0x40+_0x148236:_0x148236,_0x1ae502++%0x4)?_0x5846bb+=_0x57598c['charCodeAt'](_0x48e219+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x3a1cfb>>(-0x2*_0x1ae502&0x6)):_0x1ae502:0x0){_0x148236=_0x2a0b8a['indexOf'](_0x148236);}for(let _0x1b9e66=0x0,_0x3dd3d9=_0x5846bb['length'];_0x1b9e66<_0x3dd3d9;_0x1b9e66++){_0x5b1422+='%'+('00'+_0x5846bb['charCodeAt'](_0x1b9e66)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x5b1422);};a0_0x429a['zUuVsb']=_0x429a89,_0x1bca4e=arguments,a0_0x429a['ahOtuW']=!![];}const _0x5cd562=_0x4cde13[0x0],_0x232831=_0xe5ebfc+_0x5cd562,_0x23b2ae=_0x1bca4e[_0x232831];if(!_0x23b2ae){const _0x43d28e=function(_0x140190){this['XCsqlA']=_0x140190,this['rzZwRH']=[0x1,0x0,0x0],this['IPQwTz']=function(){return'newState';},this['FUoqKC']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['CTaWwp']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x43d28e['prototype']['jkehlG']=function(){const _0x33b97e=new RegExp(this['FUoqKC']+this['CTaWwp']),_0x4f63ac=_0x33b97e['test'](this['IPQwTz']['toString']())?--this['rzZwRH'][0x1]:--this['rzZwRH'][0x0];return this['dOXcVD'](_0x4f63ac);},_0x43d28e['prototype']['dOXcVD']=function(_0x2f7807){if(!Boolean(~_0x2f7807))return _0x2f7807;return this['nzYNJv'](this['XCsqlA']);},_0x43d28e['prototype']['nzYNJv']=function(_0x591577){for(let _0x5adb07=0x0,_0x32f2f9=this['rzZwRH']['length'];_0x5adb07<_0x32f2f9;_0x5adb07++){this['rzZwRH']['push'](Math['round'](Math['random']())),_0x32f2f9=this['rzZwRH']['length'];}return _0x591577(this['rzZwRH'][0x0]);},new _0x43d28e(a0_0x429a)['jkehlG'](),_0x278172=a0_0x429a['zUuVsb'](_0x278172),_0x1bca4e[_0x232831]=_0x278172;}else _0x278172=_0x23b2ae;return _0x278172;},a0_0x429a(_0x1bca4e,_0x4a81cd);}tempLog(a0_0xe54be6(0xfa),a0_0xe54be6(0x12d));const envChecker=require('./utils/envChecker');envChecker[a0_0xe54be6(0xdb)]();const express=require(a0_0xe54be6(0xde)),morgan=require(a0_0xe54be6(0x13c)),path=require('path'),cron=require(a0_0xe54be6(0x136)),app=express(),cookieParser=require(a0_0xe54be6(0x111)),{spawn}=require(a0_0xe54be6(0xe8)),config=require('./config/config'),logger=require(a0_0xe54be6(0x12a)),routes=require('./routes'),keyManager=require('./utils/keyManager'),cookieRefresher=require('./utils/cookieRefresher'),authMiddleware=require('./middleware/auth'),proxyLauncher=require(a0_0xe54be6(0x12f));process['env'][a0_0xe54be6(0x134)]===a0_0xe54be6(0x120)?(logger[a0_0xe54be6(0x123)](a0_0xe54be6(0x12c)),proxyLauncher[a0_0xe54be6(0x11c)]()):logger['info'](a0_0xe54be6(0x118));const v1Router=require(a0_0xe54be6(0xec));logger[a0_0xe54be6(0x123)](a0_0xe54be6(0xf0)),keyManager['initializeApiKeys'](),logger['debug'](a0_0xe54be6(0x133),JSON[a0_0xe54be6(0xda)](keyManager[a0_0xe54be6(0xfc)]()[a0_0xe54be6(0x116)]((_0x33b97e,_0x4f63ac)=>{const _0x122e55=a0_0xe54be6;return _0x33b97e[_0x4f63ac]=keyManager[_0x122e55(0xe3)](_0x4f63ac),_0x33b97e;},{}),null,0x2));const apiKeys=keyManager[a0_0xe54be6(0xfc)](),keySummary=apiKeys['map'](_0x2f7807=>{const _0x148792=a0_0xe54be6,_0x591577=keyManager['getAllCookiesForApiKey'](_0x2f7807);return _0x2f7807+':\x20'+_0x591577['length']+_0x148792(0x125);})['join'](',\x20');function a0_0x2781(){const _0x4d39c9=['5BEY5zcV55sO6iEQ5yQO5yI35PAWienVB2TPzE+8JowUMUAxTUs7U+wkOEwWHUwCQoAVJYa','Dhj1zq','BgvUz3rO','5yI35PAW6l+B56Il6l6t5yE6oIa','Aw5MBW','BgLZDgvU','5lIQq29VA2LL','lI4Vyxv0BY1YzwzYzxnOlwnVB2TPzxmUANm','zw5K','qwnJzxnZlunVBNrYB2WTqwXSB3CTtwv0Ag9KCW','C3rKzxjY','lI91DgLSCY9SB2DNzxi','zgf0yq','5Q2J5zYO5zcV5yQOveXt5lUJ55cg5PYn5yQH5zMOlI4U','5zcV5yQO5yMn5Qoa5P+L546V5Akd6ywn572UlI4U','5PYn5yQH5zMO6zsz6k+VoG','lI91DgLSCY9WCM94EuXHDw5JAgvY','zw5HyMXLza','y2XVC2u','w0vsuK9sxsa','5PYa57UiqvbjieTLExpPHy3NVA46','vvnfx1rmu19quK9ywq','5yI35PAW6l+B56Il6zsz6k+VoIa','BM9Kzs1JCM9U','u0Lhvevstq','l2zHDMLJB24UAwnV','5OMt5BYa566H55cg55wm6z2IoIbODhrWoI8VBg9JywXOB3n0oG','mtqZzNHgr1vX','5PYn5yQH5zMO5BEY5zcV5yQO77Ym55Ur5zcS56UV5y+JoIa','Bw9Yz2fU','Aw50zxj2ywW','C3rYAw5NAwz5','zw5MB3jJzuvUDKnOzwnR','otq5ofrPD09sta','ANnVBG','zxHWCMvZCW','sw50zxjUywWGC2vYDMvYigvYCM9Y','t1busu9ouW','mte1mZe2ofDJvNPIrG','C29JA2v0','z2v0qwXSq29VA2LLC0zVCKfWAuTLEq','CMvMCMvZAa','Ec1MB3j3yxjKzwqTzM9Y','CMvTB3rLlwfKzhi','y29UC3rYDwn0B3i','y2HPBgrFChjVy2vZCW','C3rHDhvZ','BwvZC2fNzq','CgLWzq','lI9YB3v0zxmVDJe','y29UzMLN','ntbTyG','C2vHCMnO','5yID5AEl5yYwqvbjieTLExmUlI4','DxnL','Dg9Rzw4','nwH0ChD5BW','AgvHzgvY','Dg9tDhjPBMC','ntK5odq0n1Hmsfzswq','BM9Kzq','l2XVz2LUlMH0BwW','mZy4vMnAEM9v','su5gtW','yxbWBhK','z2v0qwXSqxbPs2v5CW','mtiXmZGZq2Luq05r','w1DbuK5Dia','ntyWmtKZnMHPzxPJwa','tM90igzVDw5K','6iEQ5yQO5yI35PAWienVB2TPzsdLRPRML7BKU7VLIQhLVilLUlJPGidLH7RVViZKU6pNOie6ia','l2HLywX0Aa','D2fYBG','Bwv0Ag9K','zxHPDa','zxHWB3j0CW','C2nOzwr1Bgu','DxjS','nZK0tfz6zfzn','CMvZB2X2zq','z2v0','Cg9YDa','u0Lhsu5u','zw52','mteYmtKXmeTgDvzfBG','DhjPBq','y29VA2LLlxbHCNnLCG','mte1ndm5oeHts3bjsq','5PYQ5zcV55sO6iEQ5yQO5yI35PAWienVB2TPzE+8JowMGUMCGowqR+EuQoIVT+IUVUE9RUEoR+wIG+wpMoMhJYbftKfctevFqvvut19sruzsrvnipxrYDwu','6k+35Rgc55Qe6lwe5RQq5lIn5A2y5zYO','5Q2J5zYO5ygC5Q2IveXt5lUJ55cg5PYn5yQH5zMOlI4U','CMvKDwnL','ChvIBgLJ','veXt5lUJ55cg5PYn5yQH5zMO5PYQ5zcV55sO77Ym6lEZ6l+h5zcV5yQO5lUJ55cg','Cgf0Aa','kcGOlISPkYKRksSK','zg90zw52','C3rHCNrqCM94EvnLCNzLCG','zxjYB3i','rvjst1i'];a0_0x2781=function(){return _0x4d39c9;};return a0_0x2781();}logger[a0_0xe54be6(0x123)]('当前已加载\x20'+apiKeys[a0_0xe54be6(0x121)]+'\x20个API\x20Key,详情:\x20'+keySummary),app[a0_0xe54be6(0xf1)]((_0x5adb07,_0x32f2f9,_0x3ddc4c)=>{const _0x496035=a0_0xe54be6;_0x32f2f9[_0x496035(0xf4)]('Access-Control-Allow-Origin','*'),_0x32f2f9[_0x496035(0xf4)]('Access-Control-Allow-Headers','Origin,\x20X-Requested-With,\x20Content-Type,\x20Accept,\x20Authorization'),_0x32f2f9['header'](_0x496035(0x128),'GET,\x20POST,\x20PUT,\x20DELETE,\x20OPTIONS');if(_0x5adb07[_0x496035(0x104)]===_0x496035(0xe0))return _0x32f2f9[_0x496035(0xe9)](0xc8)[_0x496035(0x127)]();_0x3ddc4c();}),app[a0_0xe54be6(0xf1)](express[a0_0xe54be6(0xdd)]({'limit':a0_0xe54be6(0xee)})),app[a0_0xe54be6(0xf1)](express['urlencoded']({'extended':!![],'limit':a0_0xe54be6(0xee)})),app[a0_0xe54be6(0xf1)](cookieParser()),morgan[a0_0xe54be6(0xf2)](a0_0xe54be6(0xe6),_0x47a605=>{const _0x16881c=a0_0xe54be6;return _0x47a605['headers'][_0x16881c(0xe5)]||_0x47a605[_0x16881c(0xe2)]['remoteAddress'];});const morganLoggerStream={'write':_0x48b022=>{const _0x182149=a0_0xe54be6,_0xd6562=_0x48b022[_0x182149(0x110)]();_0xd6562&&logger['http'](_0xd6562);}};app['use'](morgan(process[a0_0xe54be6(0x10e)]['MORGAN_FORMAT']||'combined',{'stream':morganLoggerStream,'skip':(_0x1ab4c5,_0x1983e8)=>{const _0x350117=a0_0xe54be6;return _0x1ab4c5['path']===_0x350117(0x102)||_0x1ab4c5[_0x350117(0x119)]===_0x350117(0x138);}})),app[a0_0xe54be6(0xf1)](express['static'](path['join'](__dirname,a0_0xe54be6(0x117)))),app[a0_0xe54be6(0x10b)]('/',(_0x4741ee,_0x43cac1)=>{const _0x290993=a0_0xe54be6;_0x43cac1['redirect'](_0x290993(0xf8));}),app[a0_0xe54be6(0xf1)](authMiddleware),app[a0_0xe54be6(0xf1)]('/v1',v1Router),app[a0_0xe54be6(0xf1)]('/',routes);config[a0_0xe54be6(0xe4)][a0_0xe54be6(0x130)]?(logger[a0_0xe54be6(0x123)](a0_0xe54be6(0x11f)+config[a0_0xe54be6(0xe4)][a0_0xe54be6(0xd9)]+'\x20运行'),cron[a0_0xe54be6(0x107)](config[a0_0xe54be6(0xe4)][a0_0xe54be6(0xd9)],()=>{const _0x14f12f=a0_0xe54be6;logger['info']('开始定时自动刷新\x20Cookie...');const _0x1db8e0=path[_0x14f12f(0x10a)](__dirname,_0x14f12f(0x126)),_0xe61971=spawn(_0x14f12f(0xf7),[_0x1db8e0],{'stdio':['ignore',_0x14f12f(0xeb),_0x14f12f(0xeb)]});_0xe61971['stdout']['on']('data',_0x3aa57d=>{const _0x1612db=_0x14f12f;logger[_0x1612db(0x123)](_0x1612db(0x122)+_0x3aa57d[_0x1612db(0xf5)]()[_0x1612db(0x110)]());}),_0xe61971[_0x14f12f(0x129)]['on'](_0x14f12f(0x12b),_0x1e0a43=>{const _0xe6a29f=_0x14f12f;logger[_0xe6a29f(0x11d)](_0xe6a29f(0x135)+_0x1e0a43[_0xe6a29f(0xf5)]()['trim']());}),_0xe61971['on'](_0x14f12f(0x131),_0x570b94=>{const _0x2b2df2=_0x14f12f;_0x570b94===0x0?logger[_0x2b2df2(0x123)]('自动刷新\x20Cookie\x20定时任务完成'):logger[_0x2b2df2(0x11d)](_0x2b2df2(0x101)+_0x570b94);});})):logger[a0_0xe54be6(0x123)](a0_0xe54be6(0x113));app[a0_0xe54be6(0xf1)]((_0x2dd2bc,_0x50914a,_0x161173,_0x52e480)=>{const _0x94858=a0_0xe54be6;logger[_0x94858(0x11d)](_0x94858(0x12e),_0x2dd2bc),_0x161173[_0x94858(0xe9)](0x1f4)[_0x94858(0xdd)]({'error':_0x94858(0xdf),'message':_0x2dd2bc[_0x94858(0xea)]});}),app['use']((_0x26588b,_0x5b924c)=>{const _0xb5f230=a0_0xe54be6;logger[_0xb5f230(0x103)]('未找到路由:\x20'+_0x26588b[_0xb5f230(0x104)]+'\x20'+_0x26588b[_0xb5f230(0x108)]),_0x5b924c[_0xb5f230(0xe9)](0x194)['json']({'error':_0xb5f230(0x100),'message':_0xb5f230(0x114)});}),app[a0_0xe54be6(0x124)](config['port'],()=>{const _0x2c2450=a0_0xe54be6;logger[_0x2c2450(0x123)](_0x2c2450(0x13b)+config[_0x2c2450(0x10c)]),logger['info'](_0x2c2450(0x139)+config['port']);}),process['on'](a0_0xe54be6(0x10d),()=>{const _0x1bd5d8=a0_0xe54be6;logger[_0x1bd5d8(0x123)]('接收到SIGINT信号,正在优雅关闭服务...'),process[_0x1bd5d8(0x10e)][_0x1bd5d8(0x134)]==='true'&&(logger['info'](_0x1bd5d8(0x115)),proxyLauncher['stopProxyServer']()),process[_0x1bd5d8(0x105)](0x0);}),process['on'](a0_0xe54be6(0x137),()=>{const _0x51ead7=a0_0xe54be6;logger[_0x51ead7(0x123)]('接收到SIGTERM信号,正在优雅关闭服务...'),process['env'][_0x51ead7(0x134)]==='true'&&(logger['info'](_0x51ead7(0x115)),proxyLauncher['stopProxyServer']()),process[_0x51ead7(0x105)](0x0);}),module[a0_0xe54be6(0x106)]=app;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// 加载环境变量
|
2 |
+
require('dotenv').config();
|
3 |
+
|
4 |
+
// 在logger加载前添加临时日志函数
|
5 |
+
function tempLog(level, message) {
|
6 |
+
const timestamp = new Date().toISOString();
|
7 |
+
if (level === 'ERROR') {
|
8 |
+
console.error(`[ERROR] ${timestamp} ${message}`);
|
9 |
+
} else if (level === 'WARN') {
|
10 |
+
console.warn(`[WARN] ${timestamp} ${message}`);
|
11 |
+
} else {
|
12 |
+
console.log(`[INFO] ${timestamp} ${message}`);
|
13 |
+
}
|
14 |
+
}
|
15 |
+
|
16 |
+
// 环境检查
|
17 |
+
tempLog('INFO', '启动前检查环境配置...');
|
18 |
+
const envChecker = require('./utils/envChecker');
|
19 |
+
// 先执行简单检查,避免循环依赖
|
20 |
+
envChecker.enforceEnvCheck();
|
21 |
+
|
22 |
+
const express = require('express');
|
23 |
+
const morgan = require('morgan');
|
24 |
+
const path = require('path');
|
25 |
+
const cron = require('node-cron');
|
26 |
+
const app = express();
|
27 |
+
const cookieParser = require('cookie-parser');
|
28 |
+
const { spawn } = require('child_process');
|
29 |
+
|
30 |
+
// 先加载配置,再加载logger
|
31 |
+
const config = require('./config/config');
|
32 |
+
const logger = require('./utils/logger');
|
33 |
+
const routes = require('./routes');
|
34 |
+
const keyManager = require('./utils/keyManager');
|
35 |
+
const cookieRefresher = require('./utils/cookieRefresher');
|
36 |
+
const authMiddleware = require('./middleware/auth');
|
37 |
+
const proxyLauncher = require('./utils/proxyLauncher');
|
38 |
+
|
39 |
+
// 初始化代理服务器
|
40 |
+
if (process.env.USE_TLS_PROXY === 'true') {
|
41 |
+
logger.info('正在启动TLS代理服务器...');
|
42 |
+
proxyLauncher.startProxyServer();
|
43 |
+
} else {
|
44 |
+
logger.info('TLS代理服务器未启用,跳过启动代理');
|
45 |
+
}
|
46 |
+
|
47 |
+
// 加载路由
|
48 |
+
const v1Router = require('./routes/v1');
|
49 |
+
|
50 |
+
// 初始化API Keys
|
51 |
+
logger.info('初始化API Keys...');
|
52 |
+
keyManager.initializeApiKeys();
|
53 |
+
|
54 |
+
// 输出最终的API Keys配置
|
55 |
+
logger.debug('最终API Keys配置:', JSON.stringify(keyManager.getAllApiKeys().reduce((obj, key) => {
|
56 |
+
obj[key] = keyManager.getAllCookiesForApiKey(key);
|
57 |
+
return obj;
|
58 |
+
}, {}), null, 2));
|
59 |
+
|
60 |
+
// 输出每个API key的Cookie数量信息
|
61 |
+
const apiKeys = keyManager.getAllApiKeys();
|
62 |
+
const keySummary = apiKeys.map(key => {
|
63 |
+
const cookies = keyManager.getAllCookiesForApiKey(key);
|
64 |
+
return `${key}: ${cookies.length}个Cookie`;
|
65 |
+
}).join(', ');
|
66 |
+
|
67 |
+
logger.info(`当前已加载 ${apiKeys.length} 个API Key,详情: ${keySummary}`);
|
68 |
+
|
69 |
+
// 添加CORS支持
|
70 |
+
app.use((req, res, next) => {
|
71 |
+
res.header('Access-Control-Allow-Origin', '*');
|
72 |
+
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization');
|
73 |
+
res.header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
74 |
+
|
75 |
+
if (req.method === 'OPTIONS') {
|
76 |
+
return res.status(200).end();
|
77 |
+
}
|
78 |
+
|
79 |
+
next();
|
80 |
+
});
|
81 |
+
|
82 |
+
app.use(express.json({ limit: '50mb' }));
|
83 |
+
app.use(express.urlencoded({ extended: true, limit: '50mb' }));
|
84 |
+
app.use(cookieParser());
|
85 |
+
|
86 |
+
// 自定义Morgan格式,将日志输出到我们的日志系统
|
87 |
+
morgan.token('remote-addr', (req) => {
|
88 |
+
return req.headers['x-forwarded-for'] || req.socket.remoteAddress;
|
89 |
+
});
|
90 |
+
|
91 |
+
// 创建一个将 Morgan 日志写入我们的日志系统的流
|
92 |
+
const morganLoggerStream = {
|
93 |
+
write: (message) => {
|
94 |
+
// 移除行尾的换行符
|
95 |
+
const trimmedMessage = message.trim();
|
96 |
+
if (trimmedMessage) {
|
97 |
+
logger.http(trimmedMessage);
|
98 |
+
}
|
99 |
+
}
|
100 |
+
};
|
101 |
+
|
102 |
+
// 使用自定义格式的 Morgan 中间件
|
103 |
+
app.use(morgan(process.env.MORGAN_FORMAT || 'combined', {
|
104 |
+
stream: morganLoggerStream,
|
105 |
+
// 跳过健康检查等路由的日志
|
106 |
+
skip: (req, res) => {
|
107 |
+
return req.path === '/health' || req.path === '/favicon.ico';
|
108 |
+
}
|
109 |
+
}));
|
110 |
+
|
111 |
+
// 添加静态文件支持
|
112 |
+
app.use(express.static(path.join(__dirname, 'public')));
|
113 |
+
|
114 |
+
// 添加根路由,重定向到登录页面
|
115 |
+
app.get('/', (req, res) => {
|
116 |
+
res.redirect('/login.html');
|
117 |
+
});
|
118 |
+
|
119 |
+
// 添加认证中间件
|
120 |
+
app.use(authMiddleware);
|
121 |
+
|
122 |
+
// API路由
|
123 |
+
app.use('/v1', v1Router);
|
124 |
+
|
125 |
+
app.use("/", routes)
|
126 |
+
|
127 |
+
// 设置自动定时刷新Cookie任务
|
128 |
+
if (config.refresh.enabled) {
|
129 |
+
logger.info(`已启用自动刷新 Cookie,定时任务将在每 ${config.refresh.interval} 运行`);
|
130 |
+
cron.schedule(config.refresh.interval, () => {
|
131 |
+
logger.info('开始定时自动刷新 Cookie...');
|
132 |
+
const scriptPath = path.resolve(__dirname, '../auto-refresh-cookies.js');
|
133 |
+
|
134 |
+
const child = spawn('node', [scriptPath], {
|
135 |
+
stdio: ['ignore', 'pipe', 'pipe']
|
136 |
+
});
|
137 |
+
|
138 |
+
child.stdout.on('data', (data) => {
|
139 |
+
logger.info(`刷新进程输出: ${data.toString().trim()}`);
|
140 |
+
});
|
141 |
+
|
142 |
+
child.stderr.on('data', (data) => {
|
143 |
+
logger.error(`刷新进程错误: ${data.toString().trim()}`);
|
144 |
+
});
|
145 |
+
|
146 |
+
child.on('close', (code) => {
|
147 |
+
if (code === 0) {
|
148 |
+
logger.info('自动刷新 Cookie 定时任务完成');
|
149 |
+
} else {
|
150 |
+
logger.error(`自动刷新 Cookie 定时任务异常退出,代码: ${code}`);
|
151 |
+
}
|
152 |
+
});
|
153 |
+
});
|
154 |
+
} else {
|
155 |
+
logger.info('未启用自动刷新 Cookie,如需启用请设置环境变量 ENABLE_AUTO_REFRESH=true');
|
156 |
+
}
|
157 |
+
|
158 |
+
// 错误处理中间件
|
159 |
+
app.use((err, req, res, next) => {
|
160 |
+
logger.error('服务器错误:', err);
|
161 |
+
res.status(500).json({
|
162 |
+
error: 'Internal server error',
|
163 |
+
message: err.message
|
164 |
+
});
|
165 |
+
});
|
166 |
+
|
167 |
+
// 处理404请求
|
168 |
+
app.use((req, res) => {
|
169 |
+
logger.warn(`未找到路由: ${req.method} ${req.url}`);
|
170 |
+
res.status(404).json({
|
171 |
+
error: 'Not found',
|
172 |
+
message: '请求的资源不存在'
|
173 |
+
});
|
174 |
+
});
|
175 |
+
|
176 |
+
app.listen(config.port, () => {
|
177 |
+
logger.info(`服务器已启动,监听端口: ${config.port}`);
|
178 |
+
logger.info(`打开管理界面: http://localhost:${config.port}`);
|
179 |
+
});
|
180 |
+
|
181 |
+
// 处理进程退出事件,清理资源
|
182 |
+
process.on('SIGINT', () => {
|
183 |
+
logger.info('接收到SIGINT信号,正在优雅关闭服务...');
|
184 |
+
// 停止代理服务器
|
185 |
+
if (process.env.USE_TLS_PROXY === 'true') {
|
186 |
+
logger.info('正在停止TLS代理服务器...');
|
187 |
+
proxyLauncher.stopProxyServer();
|
188 |
+
}
|
189 |
+
process.exit(0);
|
190 |
+
});
|
191 |
+
|
192 |
+
process.on('SIGTERM', () => {
|
193 |
+
logger.info('接收到SIGTERM信号,正在优雅关闭服务...');
|
194 |
+
// 停止代理服务器
|
195 |
+
if (process.env.USE_TLS_PROXY === 'true') {
|
196 |
+
logger.info('正在停止TLS代理服务器...');
|
197 |
+
proxyLauncher.stopProxyServer();
|
198 |
+
}
|
199 |
+
process.exit(0);
|
200 |
+
});
|
201 |
+
|
202 |
+
module.exports = app;
|
src/config/config.js
CHANGED
@@ -1 +1,98 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// 读取并解析API_KEYS环境变量
|
2 |
+
// 避免循环依赖,不要在此处引用logger
|
3 |
+
|
4 |
+
// 添加自己的简单日志函数,防止循环依赖
|
5 |
+
function log(level, message) {
|
6 |
+
// 只在控制台输出,不写入文件
|
7 |
+
const timestamp = new Date().toISOString();
|
8 |
+
if (level === 'ERROR') {
|
9 |
+
console.error(`[ERROR] ${timestamp} ${message}`);
|
10 |
+
} else if (level === 'WARN') {
|
11 |
+
console.warn(`[WARN] ${timestamp} ${message}`);
|
12 |
+
} else {
|
13 |
+
console.log(`[INFO] ${timestamp} ${message}`);
|
14 |
+
}
|
15 |
+
}
|
16 |
+
|
17 |
+
// 解析API Keys配置
|
18 |
+
let apiKeysConfig = {};
|
19 |
+
try {
|
20 |
+
if (process.env.API_KEYS) {
|
21 |
+
// 解析API Keys字符串为对象
|
22 |
+
apiKeysConfig = JSON.parse(process.env.API_KEYS);
|
23 |
+
log('INFO', '正在从环境变量加载API Keys...');
|
24 |
+
log('INFO', `成功解析API Keys,包含 ${Object.keys(apiKeysConfig).length} 个键`);
|
25 |
+
}
|
26 |
+
} catch (error) {
|
27 |
+
log('ERROR', '解析API_KEYS环境变量失败:' + error.message);
|
28 |
+
log('ERROR', '请确保API_KEYS是有效的JSON格式');
|
29 |
+
}
|
30 |
+
|
31 |
+
// 导出配置
|
32 |
+
module.exports = {
|
33 |
+
port: process.env.PORT || 3000,
|
34 |
+
|
35 |
+
// 日志配置
|
36 |
+
log: {
|
37 |
+
level: process.env.LOG_LEVEL || 'INFO', // ERROR, WARN, INFO, DEBUG, TRACE
|
38 |
+
format: process.env.LOG_FORMAT || 'colored', // colored, json, text
|
39 |
+
toFile: process.env.LOG_TO_FILE === 'true' || false,
|
40 |
+
maxSize: parseInt(process.env.LOG_MAX_SIZE || '10', 10) * 1024 * 1024, // 默认10MB
|
41 |
+
maxFiles: parseInt(process.env.LOG_MAX_FILES || '10', 10) // 保留最近10个日志文件
|
42 |
+
},
|
43 |
+
|
44 |
+
// 合并API Keys设置
|
45 |
+
apiKeys: {
|
46 |
+
...apiKeysConfig,
|
47 |
+
...Object.fromEntries(
|
48 |
+
Object.entries(process.env)
|
49 |
+
.filter(([key]) => key.startsWith('API_KEY_'))
|
50 |
+
.map(([key, value]) => {
|
51 |
+
const apiKey = key.replace('API_KEY_', 'sk-');
|
52 |
+
try {
|
53 |
+
// 尝试解析JSON字符串,支持数组格式的cookie
|
54 |
+
const parsed = JSON.parse(value);
|
55 |
+
return [apiKey, parsed];
|
56 |
+
} catch (e) {
|
57 |
+
// 如果不是JSON,直接作为字符串处理
|
58 |
+
return [apiKey, value];
|
59 |
+
}
|
60 |
+
})
|
61 |
+
)
|
62 |
+
},
|
63 |
+
|
64 |
+
defaultRotationStrategy: process.env.ROTATION_STRATEGY || 'round-robin',
|
65 |
+
|
66 |
+
// 添加代理配置
|
67 |
+
proxy: {
|
68 |
+
enabled: process.env.PROXY_ENABLED === 'true' || false,
|
69 |
+
url: process.env.PROXY_URL || 'http://127.0.0.1:7890',
|
70 |
+
},
|
71 |
+
|
72 |
+
// GitHub相关配置
|
73 |
+
github: {
|
74 |
+
token: process.env.GITHUB_TOKEN,
|
75 |
+
owner: process.env.GITHUB_OWNER,
|
76 |
+
repo: process.env.GITHUB_REPO,
|
77 |
+
workflowId: process.env.GITHUB_WORKFLOW_ID,
|
78 |
+
triggerWorkflow: process.env.TRIGGER_WORKFLOW === 'true'
|
79 |
+
},
|
80 |
+
|
81 |
+
// 工作流参数
|
82 |
+
workflowParams: {
|
83 |
+
number: parseInt(process.env.REGISTER_NUMBER || '2', 10),
|
84 |
+
maxWorkers: parseInt(process.env.REGISTER_MAX_WORKERS || '1', 10),
|
85 |
+
emailServer: process.env.REGISTER_EMAIL_SERVER || 'TempEmail',
|
86 |
+
ingestToOneapi: process.env.REGISTER_INGEST_TO_ONEAPI === 'true',
|
87 |
+
uploadArtifact: process.env.REGISTER_UPLOAD_ARTIFACT === 'true',
|
88 |
+
useConfigFile: process.env.REGISTER_USE_CONFIG_FILE !== 'false',
|
89 |
+
emailConfigs: process.env.REGISTER_EMAIL_CONFIGS || '[]'
|
90 |
+
},
|
91 |
+
|
92 |
+
// 刷新配置
|
93 |
+
refresh: {
|
94 |
+
cron: process.env.REFRESH_CRON || '0 */6 * * *',
|
95 |
+
minCookieCount: parseInt(process.env.MIN_COOKIE_COUNT || '2', 10),
|
96 |
+
enabled: process.env.ENABLE_AUTO_REFRESH === 'true'
|
97 |
+
}
|
98 |
+
};
|
src/middleware/auth.js
CHANGED
@@ -1 +1,51 @@
|
|
1 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const admin = require('../models/admin');
|
2 |
+
|
3 |
+
// 验证管理员权限的中间件
|
4 |
+
function authMiddleware(req, res, next) {
|
5 |
+
// 跳过登录相关的路由
|
6 |
+
if (req.path.startsWith('/v1/admin/')) {
|
7 |
+
return next();
|
8 |
+
}
|
9 |
+
|
10 |
+
// 对静态HTML页面的处理
|
11 |
+
if (req.path === '/logs.html') {
|
12 |
+
// 日志页面的访问不在中间件中做验证,而是在前端页面中进行验证
|
13 |
+
return next();
|
14 |
+
}
|
15 |
+
|
16 |
+
// 修改为:只对管理相关的API进行认证
|
17 |
+
if (req.path.startsWith('/v1/api-keys') ||
|
18 |
+
req.path.startsWith('/v1/invalid-cookies') ||
|
19 |
+
req.path.startsWith('/v1/refresh-cookies') ||
|
20 |
+
req.path.startsWith('/v1/logs')) {
|
21 |
+
// 获取Authorization头
|
22 |
+
const authHeader = req.headers.authorization;
|
23 |
+
if (!authHeader || !authHeader.startsWith('Bearer ')) {
|
24 |
+
return res.status(401).json({
|
25 |
+
success: false,
|
26 |
+
message: '未提供认证token'
|
27 |
+
});
|
28 |
+
}
|
29 |
+
|
30 |
+
// 提取token
|
31 |
+
const token = authHeader.split(' ')[1];
|
32 |
+
|
33 |
+
// 验证token
|
34 |
+
const result = admin.verifyToken(token);
|
35 |
+
if (!result.success) {
|
36 |
+
return res.status(401).json({
|
37 |
+
success: false,
|
38 |
+
message: '无效的token'
|
39 |
+
});
|
40 |
+
}
|
41 |
+
|
42 |
+
// 将用户信息添加到请求对象
|
43 |
+
req.admin = {
|
44 |
+
username: result.username
|
45 |
+
};
|
46 |
+
}
|
47 |
+
|
48 |
+
next();
|
49 |
+
}
|
50 |
+
|
51 |
+
module.exports = authMiddleware;
|
src/models/admin.js
CHANGED
@@ -1 +1,114 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const fs = require('fs');
|
2 |
+
const path = require('path');
|
3 |
+
const crypto = require('crypto');
|
4 |
+
const jwt = require('jsonwebtoken');
|
5 |
+
|
6 |
+
// 管理员数据文件路径
|
7 |
+
const ADMIN_FILE = path.join(__dirname, '../../data/admin.json');
|
8 |
+
const JWT_SECRET = process.env.JWT_SECRET || 'your-secret-key';
|
9 |
+
|
10 |
+
// 确保data目录存在
|
11 |
+
const dataDir = path.dirname(ADMIN_FILE);
|
12 |
+
if (!fs.existsSync(dataDir)) {
|
13 |
+
fs.mkdirSync(dataDir, { recursive: true });
|
14 |
+
}
|
15 |
+
|
16 |
+
// 确保admin.json文件存在
|
17 |
+
if (!fs.existsSync(ADMIN_FILE)) {
|
18 |
+
fs.writeFileSync(ADMIN_FILE, JSON.stringify({ admin: null }), 'utf8');
|
19 |
+
}
|
20 |
+
|
21 |
+
class Admin {
|
22 |
+
constructor() {
|
23 |
+
this.loadAdmin();
|
24 |
+
}
|
25 |
+
|
26 |
+
// 加载管理员数据
|
27 |
+
loadAdmin() {
|
28 |
+
try {
|
29 |
+
const data = fs.readFileSync(ADMIN_FILE, 'utf8');
|
30 |
+
this.admin = JSON.parse(data).admin;
|
31 |
+
} catch (error) {
|
32 |
+
console.error('加载管理员数据失败:', error);
|
33 |
+
this.admin = null;
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
// 保存管理员数据
|
38 |
+
saveAdmin() {
|
39 |
+
try {
|
40 |
+
fs.writeFileSync(ADMIN_FILE, JSON.stringify({ admin: this.admin }), 'utf8');
|
41 |
+
} catch (error) {
|
42 |
+
console.error('保存管理员数据失败:', error);
|
43 |
+
throw error;
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
// 检查是否已有管理员
|
48 |
+
hasAdmin() {
|
49 |
+
return !!this.admin;
|
50 |
+
}
|
51 |
+
|
52 |
+
// 注册管理员
|
53 |
+
register(username, password) {
|
54 |
+
if (this.hasAdmin()) {
|
55 |
+
throw new Error('已存在管理员账号');
|
56 |
+
}
|
57 |
+
|
58 |
+
// 生成盐值
|
59 |
+
const salt = crypto.randomBytes(16).toString('hex');
|
60 |
+
// 使用盐值加密密码
|
61 |
+
const hash = crypto.pbkdf2Sync(password, salt, 1000, 64, 'sha512').toString('hex');
|
62 |
+
|
63 |
+
this.admin = {
|
64 |
+
username,
|
65 |
+
salt,
|
66 |
+
hash
|
67 |
+
};
|
68 |
+
|
69 |
+
this.saveAdmin();
|
70 |
+
return this.generateToken(username);
|
71 |
+
}
|
72 |
+
|
73 |
+
// 验证密码
|
74 |
+
verifyPassword(password, salt, hash) {
|
75 |
+
const testHash = crypto.pbkdf2Sync(password, salt, 1000, 64, 'sha512').toString('hex');
|
76 |
+
return testHash === hash;
|
77 |
+
}
|
78 |
+
|
79 |
+
// 登录验证
|
80 |
+
login(username, password) {
|
81 |
+
if (!this.admin || username !== this.admin.username) {
|
82 |
+
throw new Error('用户名或密码错误');
|
83 |
+
}
|
84 |
+
|
85 |
+
if (!this.verifyPassword(password, this.admin.salt, this.admin.hash)) {
|
86 |
+
throw new Error('用户名或密码错误');
|
87 |
+
}
|
88 |
+
|
89 |
+
return this.generateToken(username);
|
90 |
+
}
|
91 |
+
|
92 |
+
// 生成JWT token
|
93 |
+
generateToken(username) {
|
94 |
+
return jwt.sign({ username }, JWT_SECRET, { expiresIn: '24h' });
|
95 |
+
}
|
96 |
+
|
97 |
+
// 验证JWT token
|
98 |
+
verifyToken(token) {
|
99 |
+
try {
|
100 |
+
const decoded = jwt.verify(token, JWT_SECRET);
|
101 |
+
return {
|
102 |
+
success: true,
|
103 |
+
username: decoded.username
|
104 |
+
};
|
105 |
+
} catch (error) {
|
106 |
+
return {
|
107 |
+
success: false,
|
108 |
+
error: 'Invalid token'
|
109 |
+
};
|
110 |
+
}
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
module.exports = new Admin();
|
src/public/scripts.js
CHANGED
@@ -1 +1,1342 @@
|
|
1 |
-
const a0_0x2e920c=a0_0x9c1d;(function(_0x50c06,_0x324f3f){const _0x1ebe51=a0_0x9c1d,_0x1f1cdc=_0x50c06();while(!![]){try{const _0x4ec3f1=-parseInt(_0x1ebe51(0xd8))/0x1+-parseInt(_0x1ebe51(0x1c8))/0x2+-parseInt(_0x1ebe51(0xfa))/0x3*(-parseInt(_0x1ebe51(0x183))/0x4)+-parseInt(_0x1ebe51(0x138))/0x5+-parseInt(_0x1ebe51(0x105))/0x6*(parseInt(_0x1ebe51(0x118))/0x7)+parseInt(_0x1ebe51(0x18c))/0x8+parseInt(_0x1ebe51(0x13d))/0x9;if(_0x4ec3f1===_0x324f3f)break;else _0x1f1cdc['push'](_0x1f1cdc['shift']());}catch(_0x5805b8){_0x1f1cdc['push'](_0x1f1cdc['shift']());}}}(a0_0xba5c,0x3f750));const a0_0x3d41df=(function(){let _0x23c0c3=!![];return function(_0x55d6ea,_0x3bee2a){const _0x16f743=_0x23c0c3?function(){const _0x23db8a=a0_0x9c1d;if(_0x3bee2a){const _0x5cc1d6=_0x3bee2a[_0x23db8a(0x15b)](_0x55d6ea,arguments);return _0x3bee2a=null,_0x5cc1d6;}}:function(){};return _0x23c0c3=![],_0x16f743;};}()),a0_0x22c531=a0_0x3d41df(this,function(){const _0x1feea9=a0_0x9c1d;return a0_0x22c531[_0x1feea9(0xe7)]()[_0x1feea9(0xe4)](_0x1feea9(0xdc))[_0x1feea9(0xe7)]()[_0x1feea9(0x16d)](a0_0x22c531)[_0x1feea9(0xe4)](_0x1feea9(0xdc));});a0_0x22c531(),document[a0_0x2e920c(0x190)](a0_0x2e920c(0x18d),function(){const _0xc639c7=a0_0x2e920c,_0x47f003=document[_0xc639c7(0x17d)]('.modal'),_0x27409b=document[_0xc639c7(0x17d)](_0xc639c7(0xd3));function _0x479e7d(){const _0x48c3e4=_0xc639c7;_0x47f003['forEach'](_0x38ed25=>{const _0x24f79e=a0_0x9c1d;_0x38ed25[_0x24f79e(0x164)]['display']=_0x24f79e(0x11b);}),document['body'][_0x48c3e4(0x195)][_0x48c3e4(0x100)](_0x48c3e4(0x178));}_0x27409b[_0xc639c7(0xed)](_0x156e15=>{const _0x5abfcd=_0xc639c7;_0x156e15[_0x5abfcd(0x1b9)]=_0x479e7d;}),window[_0xc639c7(0x1b9)]=function(_0x1db810){const _0x2bae4d=_0xc639c7;_0x47f003[_0x2bae4d(0xed)](_0xfcb760=>{const _0x5ab2b0=_0x2bae4d;_0x1db810[_0x5ab2b0(0xdd)]==_0xfcb760&&_0x479e7d();});},checkAuth(),loadApiKeys(),renderInvalidCookies(),populateRefreshApiKeySelect(),populateCookieApiKeySelect(),renderAddCookieTags([]),bindEventListeners(),document['getElementById']('logsBtn')?.[_0xc639c7(0x190)](_0xc639c7(0x12e),function(){const _0x3bf994=_0xc639c7;window['location'][_0x3bf994(0xd4)]=_0x3bf994(0x167);});});function bindEventListeners(){const _0x52c375=a0_0x2e920c;document['getElementById'](_0x52c375(0xf3))[_0x52c375(0x190)](_0x52c375(0x1b5),handleAddKeyForm),document['getElementById'](_0x52c375(0x107))[_0x52c375(0x190)](_0x52c375(0x1b5),handleEditCookieForm),document[_0x52c375(0x137)](_0x52c375(0x1d9))[_0x52c375(0x190)](_0x52c375(0x1b5),handleInvalidCookieForm);const _0x114f2e=document[_0x52c375(0x17d)](_0x52c375(0x142));_0x114f2e[_0x52c375(0xed)](_0x528537=>{const _0x9f6ae=_0x52c375;if(_0x528537)_0x528537[_0x9f6ae(0x190)](_0x9f6ae(0x12e),testApiConnection);});const _0x3133ce=document[_0x52c375(0x17d)](_0x52c375(0x1d8));_0x3133ce['forEach'](_0x35dbe3=>{const _0x2278b7=_0x52c375;if(_0x35dbe3)_0x35dbe3[_0x2278b7(0x190)](_0x2278b7(0x12e),clearCacheAndRefresh);});if(document[_0x52c375(0x137)](_0x52c375(0x19e)))document['getElementById']('addNewCookieBtn')[_0x52c375(0x190)](_0x52c375(0x12e),handleAddNewCookie);if(document[_0x52c375(0x137)](_0x52c375(0x109)))document[_0x52c375(0x137)](_0x52c375(0x109))['addEventListener']('click',handleAddCookie);if(document[_0x52c375(0x137)](_0x52c375(0x185)))document[_0x52c375(0x137)]('addInvalidCookieBtn')['addEventListener'](_0x52c375(0x12e),handleAddInvalidCookie);if(document['getElementById'](_0x52c375(0x140)))document[_0x52c375(0x137)]('closeInvalidCookieModal')[_0x52c375(0x190)](_0x52c375(0x12e),closeInvalidCookieModal);const _0x3f2642=document['getElementById'](_0x52c375(0x1de));_0x3f2642&&(console[_0x52c375(0x120)](_0x52c375(0x14f)),_0x3f2642['addEventListener'](_0x52c375(0x12e),handleRefreshCookie));const _0x5a6695=document[_0x52c375(0x137)](_0x52c375(0x1d0));_0x5a6695&&(console[_0x52c375(0x120)](_0x52c375(0x186)),_0x5a6695[_0x52c375(0x190)](_0x52c375(0x12e),handleGenerateLink));if(document[_0x52c375(0x137)]('logoutBtn'))document[_0x52c375(0x137)](_0x52c375(0x114))[_0x52c375(0x190)](_0x52c375(0x12e),handleLogout);}async function loadApiKeys(){const _0x24fd43=a0_0x2e920c;try{console[_0x24fd43(0x120)]('开始加载API\x20Keys...');const _0x505248=await fetch(_0x24fd43(0x171),{'method':'GET','headers':{'Content-Type':'application/json','Cache-Control':_0x24fd43(0x11f)}});if(!_0x505248['ok'])throw new Error('HTTP错误:\x20'+_0x505248[_0x24fd43(0x19c)]+'\x20'+_0x505248[_0x24fd43(0x1c9)]);console[_0x24fd43(0x120)](_0x24fd43(0x1af),_0x505248['status']);const _0x504684=await _0x505248['json']();console['log'](_0x24fd43(0x1a0),_0x504684);const _0x543316=document[_0x24fd43(0x137)](_0x24fd43(0x1bd));_0x543316[_0x24fd43(0x1e2)]='',_0x504684['success']&&_0x504684[_0x24fd43(0x196)][_0x24fd43(0xe8)]>0x0?_0x504684[_0x24fd43(0x196)][_0x24fd43(0xed)](_0x278f2a=>{const _0x14b19f=_0x24fd43,_0x22b28f=document[_0x14b19f(0x1d7)]('tr');_0x22b28f[_0x14b19f(0x1e2)]=_0x14b19f(0x177)+_0x278f2a[_0x14b19f(0xdb)]+_0x14b19f(0x18f)+_0x278f2a[_0x14b19f(0x12d)]+_0x14b19f(0x175)+_0x278f2a[_0x14b19f(0xdb)]+_0x14b19f(0x12c)+_0x278f2a[_0x14b19f(0xdb)]+'\x27)\x22>删除</button>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</td>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20',_0x543316['appendChild'](_0x22b28f);}):_0x543316['innerHTML']=_0x24fd43(0xf2);}catch(_0x6786c4){console[_0x24fd43(0x1dd)](_0x24fd43(0x17b),_0x6786c4),document[_0x24fd43(0x137)](_0x24fd43(0xf1))[_0x24fd43(0x1e2)]=_0x24fd43(0xda)+_0x6786c4[_0x24fd43(0xe1)]+'</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20';}}async function handleAddKeyForm(_0x49ddcb){const _0x62bf78=a0_0x2e920c;_0x49ddcb[_0x62bf78(0x1d2)]();const _0xbfcee9=document['getElementById'](_0x62bf78(0x1ab))['value'][_0x62bf78(0x1cb)](),_0x553c86=document[_0x62bf78(0x137)]('cookieValues')[_0x62bf78(0x1ca)][_0x62bf78(0x1cb)]();if(!_0xbfcee9){document[_0x62bf78(0x137)](_0x62bf78(0x1a7))['innerHTML']=_0x62bf78(0x146);return;}const _0x3b7ca3=_0x553c86?_0x553c86[_0x62bf78(0x1d4)](',')[_0x62bf78(0x1a6)](_0x2783dd=>_0x2783dd[_0x62bf78(0x1cb)]())['filter'](_0x5cac7a=>_0x5cac7a):[];try{const _0xe35209=await fetch(_0x62bf78(0x171),{'method':_0x62bf78(0x17c),'headers':{'Content-Type':_0x62bf78(0x1a3)},'body':JSON[_0x62bf78(0x155)]({'apiKey':_0xbfcee9,'cookieValues':_0x3b7ca3})}),_0x312cd3=await _0xe35209[_0x62bf78(0x174)]();_0x312cd3['success']?(document[_0x62bf78(0x137)](_0x62bf78(0x1a7))[_0x62bf78(0x1e2)]='\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22info\x22>API\x20Key\x20添加/更新成功</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20',setTimeout(()=>{const _0x430dc3=_0x62bf78;window[_0x430dc3(0x119)][_0x430dc3(0x134)]();},0xbb8)):document[_0x62bf78(0x137)](_0x62bf78(0x1a7))[_0x62bf78(0x1e2)]=_0x62bf78(0x18b)+_0x312cd3[_0x62bf78(0x1dd)]+_0x62bf78(0x15d);}catch(_0x900bd7){console[_0x62bf78(0x1dd)](_0x62bf78(0x16e),_0x900bd7),document['getElementById'](_0x62bf78(0x1a7))[_0x62bf78(0x1e2)]=_0x62bf78(0x188)+_0x900bd7[_0x62bf78(0xe1)]+_0x62bf78(0xf8);}}async function deleteApiKey(_0x53a985){const _0x2e4bf3=a0_0x2e920c;if(!confirm(_0x2e4bf3(0x151)+_0x53a985+_0x2e4bf3(0x117)))return;try{const _0x4a7092=await fetch(_0x2e4bf3(0x15f)+encodeURIComponent(_0x53a985),{'method':_0x2e4bf3(0x1a9)}),_0x286b15=await _0x4a7092[_0x2e4bf3(0x174)]();_0x286b15['success']?(document[_0x2e4bf3(0x137)](_0x2e4bf3(0xf1))[_0x2e4bf3(0x1e2)]=_0x2e4bf3(0xe5),loadApiKeys()):document[_0x2e4bf3(0x137)](_0x2e4bf3(0xf1))['innerHTML']=_0x2e4bf3(0x1b1)+_0x286b15['error']+'</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20';}catch(_0xf8e181){console[_0x2e4bf3(0x1dd)](_0x2e4bf3(0x1d1),_0xf8e181),document[_0x2e4bf3(0x137)](_0x2e4bf3(0xf1))[_0x2e4bf3(0x1e2)]=_0x2e4bf3(0x141)+_0xf8e181[_0x2e4bf3(0xe1)]+_0x2e4bf3(0xf8);}}async function getCookiesForApiKey(_0x5c23e1){const _0x26aff1=a0_0x2e920c;try{const _0x668084=await fetch(_0x26aff1(0x15f)+encodeURIComponent(_0x5c23e1)+_0x26aff1(0xd7),{'method':_0x26aff1(0x1be),'headers':{'Content-Type':'application/json','Cache-Control':'no-cache'}});if(!_0x668084['ok'])throw new Error(_0x26aff1(0xd5)+_0x668084['status']+'\x20'+_0x668084[_0x26aff1(0x1c9)]);const _0x22527d=await _0x668084[_0x26aff1(0x174)]();return _0x22527d[_0x26aff1(0xd2)];}catch(_0x1b7c3a){console[_0x26aff1(0x1dd)](_0x26aff1(0x16c)+_0x5c23e1+_0x26aff1(0x135),_0x1b7c3a);throw _0x1b7c3a;}}async function editApiKey(_0x45a72a){const _0x25b58f=a0_0x2e920c;try{document[_0x25b58f(0x137)](_0x25b58f(0x103))[_0x25b58f(0x1e2)]='',document[_0x25b58f(0x137)](_0x25b58f(0x170))['value']=_0x45a72a;const _0x1cb873=await getCookiesForApiKey(_0x45a72a);document['getElementById']('editCookieValues')[_0x25b58f(0x1ca)]=_0x1cb873[_0x25b58f(0x16f)](','),renderCookieTags(_0x1cb873),document[_0x25b58f(0x137)](_0x25b58f(0x179))['value']='';const _0x1252ae=document['getElementById']('editModal');_0x1252ae['style'][_0x25b58f(0x144)]=_0x25b58f(0x160),document[_0x25b58f(0x192)]['classList']['add']('modal-open');}catch(_0x5eb66c){console[_0x25b58f(0x1dd)](_0x25b58f(0x139),_0x5eb66c),document[_0x25b58f(0x137)]('editModalMessage')[_0x25b58f(0x1e2)]='\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22error\x22>无法加载Cookie数据:\x20'+_0x5eb66c[_0x25b58f(0xe1)]+_0x25b58f(0xf8);const _0x527ce5=document['getElementById'](_0x25b58f(0x112));_0x527ce5[_0x25b58f(0x164)][_0x25b58f(0x144)]=_0x25b58f(0x160),document[_0x25b58f(0x192)][_0x25b58f(0x195)][_0x25b58f(0x194)](_0x25b58f(0x178));}}async function getApiKeys(){const _0x1387e2=a0_0x2e920c,_0xef71e8=await fetch(_0x1387e2(0x171),{'method':'GET','headers':{'Content-Type':_0x1387e2(0x1a3),'Cache-Control':_0x1387e2(0x11f)}});if(!_0xef71e8['ok'])throw new Error(_0x1387e2(0xd5)+_0xef71e8['status']+'\x20'+_0xef71e8[_0x1387e2(0x1c9)]);const _0x53268a=await _0xef71e8['json']();return _0x53268a[_0x1387e2(0x126)]?_0x53268a['apiKeys']:[];}async function copyTextToClipboard(_0x2573db){const _0x4b1c00=a0_0x2e920c;try{return await navigator['clipboard'][_0x4b1c00(0x1ce)](_0x2573db),!![];}catch(_0x120c5b){console[_0x4b1c00(0x1dd)](_0x4b1c00(0x127),_0x120c5b);try{const _0x51f944=document[_0x4b1c00(0x1d7)]('textarea');_0x51f944['value']=_0x2573db,_0x51f944[_0x4b1c00(0x164)]['position']='fixed',_0x51f944[_0x4b1c00(0x164)]['top']='0',_0x51f944[_0x4b1c00(0x164)][_0x4b1c00(0xf6)]='0',_0x51f944[_0x4b1c00(0x164)][_0x4b1c00(0x108)]=_0x4b1c00(0x115),_0x51f944[_0x4b1c00(0x164)][_0x4b1c00(0xdf)]=_0x4b1c00(0x115),_0x51f944[_0x4b1c00(0x164)]['padding']='0',_0x51f944['style'][_0x4b1c00(0x13b)]=_0x4b1c00(0x11b),_0x51f944[_0x4b1c00(0x164)][_0x4b1c00(0xfb)]='none',_0x51f944[_0x4b1c00(0x164)][_0x4b1c00(0xd6)]='none',_0x51f944[_0x4b1c00(0x164)][_0x4b1c00(0x162)]='transparent',document[_0x4b1c00(0x192)]['appendChild'](_0x51f944),_0x51f944['focus'](),_0x51f944[_0x4b1c00(0x10e)]();const _0x25413d=document[_0x4b1c00(0x191)](_0x4b1c00(0xd0));return document[_0x4b1c00(0x192)][_0x4b1c00(0x11a)](_0x51f944),_0x25413d;}catch(_0x507ce0){return console['error'](_0x4b1c00(0xfc),_0x507ce0),![];}}}function showCopyToast(_0x44fb2b){const _0x34fc74=a0_0x2e920c,_0x4ec55f=document['createElement'](_0x34fc74(0x101));_0x4ec55f[_0x34fc74(0x164)][_0x34fc74(0x189)]='fixed',_0x4ec55f[_0x34fc74(0x164)][_0x34fc74(0xe0)]=_0x34fc74(0x1d5),_0x4ec55f['style'][_0x34fc74(0xf6)]='50%',_0x4ec55f['style']['transform']=_0x34fc74(0x15e),_0x4ec55f[_0x34fc74(0x164)]['padding']=_0x34fc74(0xec),_0x4ec55f['style']['borderRadius']=_0x34fc74(0xeb),_0x4ec55f[_0x34fc74(0x164)][_0x34fc74(0x1e4)]=_0x34fc74(0x166),_0x4ec55f[_0x34fc74(0x164)][_0x34fc74(0xde)]=_0x34fc74(0x173),_0x44fb2b?(_0x4ec55f[_0x34fc74(0x164)][_0x34fc74(0x1e0)]=_0x34fc74(0x18e),_0x4ec55f[_0x34fc74(0x164)]['color']=_0x34fc74(0xe9),_0x4ec55f[_0x34fc74(0x1c0)]=_0x34fc74(0x128)):(_0x4ec55f['style']['backgroundColor']=_0x34fc74(0x1ae),_0x4ec55f[_0x34fc74(0x164)][_0x34fc74(0x14a)]=_0x34fc74(0xe9),_0x4ec55f['textContent']=_0x34fc74(0x181)),document['body'][_0x34fc74(0x1ac)](_0x4ec55f),setTimeout(()=>{const _0x49378e=_0x34fc74;_0x4ec55f[_0x49378e(0x164)][_0x49378e(0x176)]='0',_0x4ec55f[_0x49378e(0x164)][_0x49378e(0x129)]=_0x49378e(0xef),setTimeout(()=>{const _0x538760=_0x49378e;document[_0x538760(0x192)]['removeChild'](_0x4ec55f);},0x1f4);},0x7d0);}async function handleCopyCookie(_0x1e3686){const _0x245d51=await copyTextToClipboard(_0x1e3686);showCopyToast(_0x245d51);}function renderCookieTags(_0x3d4432){const _0x1d51b8=a0_0x2e920c,_0x3b3471=document[_0x1d51b8(0x137)]('cookieTagsContainer');_0x3b3471[_0x1d51b8(0x1e2)]='';if(_0x3d4432[_0x1d51b8(0xe8)]===0x0){_0x3b3471[_0x1d51b8(0x1e2)]='<div\x20style=\x22padding:\x2010px;\x20color:\x20#666;\x22>暂无Cookie,请添加</div>';return;}_0x3d4432[_0x1d51b8(0xed)]((_0xa957b1,_0x226583)=>{const _0x4bc1ad=_0x1d51b8,_0x3c1871=document[_0x4bc1ad(0x1d7)](_0x4bc1ad(0x13a));_0x3c1871[_0x4bc1ad(0x13e)]=_0x4bc1ad(0x168);_0xa957b1[_0x4bc1ad(0xe8)]<0x5&&_0x3c1871[_0x4bc1ad(0x195)][_0x4bc1ad(0x194)](_0x4bc1ad(0x16a));const _0x98a54d=_0xa957b1[_0x4bc1ad(0xe8)]>0x14?_0xa957b1[_0x4bc1ad(0x182)](0x0,0x8)+_0x4bc1ad(0xf9)+_0xa957b1[_0x4bc1ad(0x182)](_0xa957b1[_0x4bc1ad(0xe8)]-0x8):_0xa957b1;_0x3c1871[_0x4bc1ad(0xf7)]=_0xa957b1,_0x3c1871['innerHTML']=_0x4bc1ad(0xf0)+_0x98a54d+_0x4bc1ad(0xcf)+_0xa957b1+_0x4bc1ad(0x150)+_0x226583+_0x4bc1ad(0xee),_0x3b3471[_0x4bc1ad(0x1ac)](_0x3c1871);}),document[_0x1d51b8(0x17d)](_0x1d51b8(0x149))['forEach'](_0x51c210=>{const _0x2cac10=_0x1d51b8;_0x51c210[_0x2cac10(0x190)](_0x2cac10(0x12e),function(){const _0x4ccc48=_0x2cac10,_0x23da9e=parseInt(this[_0x4ccc48(0x1df)](_0x4ccc48(0x13c)));deleteCookieTag(_0x23da9e);});}),document[_0x1d51b8(0x17d)](_0x1d51b8(0xd1))[_0x1d51b8(0xed)](_0x3e47ae=>{const _0x12c960=_0x1d51b8;_0x3e47ae['addEventListener'](_0x12c960(0x12e),function(){const _0x543a5d=_0x12c960,_0x2e6cfe=this[_0x543a5d(0x1df)]('data-cookie');handleCopyCookie(_0x2e6cfe);});});}function deleteCookieTag(_0x471ff4){const _0xc29776=a0_0x2e920c,_0x2cdc59=document[_0xc29776(0x137)](_0xc29776(0x14b));let _0x1247f9=_0x2cdc59[_0xc29776(0x1ca)][_0xc29776(0x1d4)](',')[_0xc29776(0x1a6)](_0x405210=>_0x405210[_0xc29776(0x1cb)]())[_0xc29776(0x11c)](_0x487525=>_0x487525);_0x1247f9[_0xc29776(0x15c)](_0x471ff4,0x1),_0x2cdc59[_0xc29776(0x1ca)]=_0x1247f9[_0xc29776(0x16f)](','),renderCookieTags(_0x1247f9);}function handleAddCookie(){const _0x2d87a5=a0_0x2e920c,_0x3734c9=document[_0x2d87a5(0x137)](_0x2d87a5(0x179)),_0x302829=_0x3734c9[_0x2d87a5(0x1ca)][_0x2d87a5(0x1cb)]();if(!_0x302829)return;const _0x1c2d46=document[_0x2d87a5(0x137)](_0x2d87a5(0x14b));let _0x1e69f0=_0x1c2d46['value']?_0x1c2d46[_0x2d87a5(0x1ca)][_0x2d87a5(0x1d4)](',')[_0x2d87a5(0x1a6)](_0x1c16b6=>_0x1c16b6[_0x2d87a5(0x1cb)]())[_0x2d87a5(0x11c)](_0x860bd2=>_0x860bd2):[];_0x1e69f0[_0x2d87a5(0x1cd)](_0x302829),_0x1c2d46[_0x2d87a5(0x1ca)]=_0x1e69f0[_0x2d87a5(0x16f)](','),renderCookieTags(_0x1e69f0),_0x3734c9[_0x2d87a5(0x1ca)]='';}async function handleEditCookieForm(_0xa4875b){const _0x116576=a0_0x2e920c;_0xa4875b['preventDefault']();const _0x4702d6=document['getElementById'](_0x116576(0x170))[_0x116576(0x1ca)]['trim'](),_0x5498e2=document[_0x116576(0x137)](_0x116576(0x14b))[_0x116576(0x1ca)][_0x116576(0x1cb)]();if(!_0x4702d6){document[_0x116576(0x137)](_0x116576(0x103))[_0x116576(0x1e2)]=_0x116576(0x1ba);return;}const _0xdfee10=_0x5498e2?_0x5498e2[_0x116576(0x1d4)](',')[_0x116576(0x1a6)](_0x4a82a0=>_0x4a82a0[_0x116576(0x1cb)]())[_0x116576(0x11c)](_0x59734d=>_0x59734d):[];try{const _0x3b3aa3=await fetch(_0x116576(0x171),{'method':_0x116576(0x17c),'headers':{'Content-Type':_0x116576(0x1a3)},'body':JSON['stringify']({'apiKey':_0x4702d6,'cookieValues':_0xdfee10})}),_0x541404=await _0x3b3aa3[_0x116576(0x174)]();_0x541404[_0x116576(0x126)]?(document[_0x116576(0x137)](_0x116576(0x103))[_0x116576(0x1e2)]=_0x116576(0x1a2),setTimeout(()=>{const _0x4c419e=_0x116576;document['getElementById'](_0x4c419e(0x112))[_0x4c419e(0x164)][_0x4c419e(0x144)]=_0x4c419e(0x11b),loadApiKeys();},0x5dc)):document[_0x116576(0x137)]('editModalMessage')['innerHTML']=_0x116576(0x1ad)+_0x541404[_0x116576(0x1dd)]+_0x116576(0x15d);}catch(_0x4ac201){console['error'](_0x116576(0x11e),_0x4ac201),document['getElementById'](_0x116576(0x103))[_0x116576(0x1e2)]=_0x116576(0x19b)+_0x4ac201['message']+_0x116576(0xf8);}}function renderAddCookieTags(_0x501891){const _0x5d9c6a=a0_0x2e920c,_0x38237b=document[_0x5d9c6a(0x137)](_0x5d9c6a(0x122));_0x38237b[_0x5d9c6a(0x1e2)]='';if(_0x501891[_0x5d9c6a(0xe8)]===0x0){_0x38237b[_0x5d9c6a(0x1e2)]=_0x5d9c6a(0x1bf);return;}_0x501891[_0x5d9c6a(0xed)]((_0x32a4fe,_0x4f27df)=>{const _0x1fe46c=_0x5d9c6a,_0x527114=document[_0x1fe46c(0x1d7)](_0x1fe46c(0x13a));_0x527114[_0x1fe46c(0x13e)]=_0x1fe46c(0x168);_0x32a4fe[_0x1fe46c(0xe8)]<0x5&&_0x527114[_0x1fe46c(0x195)][_0x1fe46c(0x194)]('short-cookie');const _0x48680b=_0x32a4fe[_0x1fe46c(0xe8)]>0x14?_0x32a4fe['substring'](0x0,0x8)+'...'+_0x32a4fe[_0x1fe46c(0x182)](_0x32a4fe[_0x1fe46c(0xe8)]-0x8):_0x32a4fe;_0x527114['title']=_0x32a4fe,_0x527114['innerHTML']=_0x1fe46c(0xf0)+_0x48680b+_0x1fe46c(0xcf)+_0x32a4fe+'\x22\x20aria-label=\x22复制\x22>C</button>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<button\x20type=\x22button\x22\x20class=\x22delete-add-cookie\x22\x20data-index=\x22'+_0x4f27df+_0x1fe46c(0xee),_0x38237b['appendChild'](_0x527114);}),document['querySelectorAll'](_0x5d9c6a(0x193))[_0x5d9c6a(0xed)](_0x1a5af0=>{const _0xaf2a11=_0x5d9c6a;_0x1a5af0['addEventListener'](_0xaf2a11(0x12e),function(){const _0x1f5a69=parseInt(this['getAttribute']('data-index'));deleteAddCookieTag(_0x1f5a69);});}),document[_0x5d9c6a(0x17d)](_0x5d9c6a(0xd1))[_0x5d9c6a(0xed)](_0xeaa932=>{const _0x1574c7=_0x5d9c6a;_0xeaa932[_0x1574c7(0x190)](_0x1574c7(0x12e),function(){const _0x184d76=_0x1574c7,_0x430ffc=this[_0x184d76(0x1df)](_0x184d76(0x136));handleCopyCookie(_0x430ffc);});});}function deleteAddCookieTag(_0x3c7855){const _0x2727bc=a0_0x2e920c,_0x19921f=document[_0x2727bc(0x137)](_0x2727bc(0x172));let _0x5024ae=_0x19921f[_0x2727bc(0x1ca)]?_0x19921f[_0x2727bc(0x1ca)][_0x2727bc(0x1d4)](',')[_0x2727bc(0x1a6)](_0xe00e81=>_0xe00e81[_0x2727bc(0x1cb)]())[_0x2727bc(0x11c)](_0x2e391c=>_0x2e391c):[];_0x5024ae[_0x2727bc(0x15c)](_0x3c7855,0x1),_0x19921f[_0x2727bc(0x1ca)]=_0x5024ae[_0x2727bc(0x16f)](','),renderAddCookieTags(_0x5024ae);}function handleAddNewCookie(){const _0x3db5f9=a0_0x2e920c,_0x5c16b0=document[_0x3db5f9(0x137)](_0x3db5f9(0x12f)),_0x10cdaa=_0x5c16b0['value'][_0x3db5f9(0x1cb)]();if(!_0x10cdaa)return;const _0x47224e=document[_0x3db5f9(0x137)](_0x3db5f9(0x172));let _0x504d2c=_0x47224e[_0x3db5f9(0x1ca)]?_0x47224e[_0x3db5f9(0x1ca)]['split'](',')[_0x3db5f9(0x1a6)](_0x21a934=>_0x21a934[_0x3db5f9(0x1cb)]())['filter'](_0x4d51c2=>_0x4d51c2):[];_0x504d2c[_0x3db5f9(0x1cd)](_0x10cdaa),_0x47224e[_0x3db5f9(0x1ca)]=_0x504d2c[_0x3db5f9(0x16f)](','),renderAddCookieTags(_0x504d2c),_0x5c16b0['value']='';}function a0_0xba5c(){const _0x2a384e=['C3bSAwnL','pc9KAxy+cIaGicaGicaGicaGia','DhjHBNnSyxrLwcGTntaLkq','l3yXl2fWAs1RzxLZlW','yMXVy2S','pgrPDIbJBgfZCZ0IAw5MBYi+6zo+5O6L5BEY55sF5OIq77Ym6k+354k55yE76zo+5O6L55M75B2vq3vYC29Y6lsM5y+35BM25O6i5P2dpc9KAxy+','yMfJA2DYB3vUza','y2f0y2G','C3r5Bgu','i2LUDMfSAwrdB29RAwvuywDZq29UDgfPBMvYic5JB3b5lwj0BG','otK5oq','l2XVz3mUAhrTBa','y29VA2LLlxrHzW','cIaGicaGicaGicaGicaGicaGicaGpgrPDIbJBgfZCZ0IzxjYB3iIpUAxOoAvIenVB2TPzEs/RUAuUEwKSEI0PtOG','C2HVCNqTy29VA2LL','l3yXl3jLzNjLC2GTC3rHDhvZ','6i635y+wia','y29UC3rYDwn0B3i','5RE75yQGl+ABToAwScbbueKGs2v5iowKSEI0PtO','AM9PBG','zwrPDefWAuTLEq','l3yXl2fWAs1RzxLZ','y29VA2LLvMfSDwvZ','mtrWEa','ANnVBG','pc90zd4kicaGicaGicaGicaGicaGicaGica8DgqGzgf0ys10AxrSzt0I5Pon5l2CiJ4kicaGicaGicaGicaGicaGicaGicaGicaGpgj1DhrVBIbJBgfZCZ0IzwrPDc1IDg4Iig9Uy2XPy2S9iMvKAxrbCgLlzxKOjW','B3bHy2L0Eq','cIaGicaGicaGicaGicaGicaGicaGphrKigrHDgeTDgL0Bgu9iKfqssblzxKIpG','Bw9KywWTB3bLBG','BMv3q29VA2LL','i2LUDMfSAwrdB29RAwvuywDZq29UDgfPBMvYic5KzwXLDguTy29VA2LL','5yQG6l29iefqssblzxKG5AsX6lsLoG','ue9tva','CxvLCNLtzwXLy3rVCKfSBa','l2XVz2LUlMH0BwW','D2fPDgLUzW','6k+35Rgc5AsX6lsLoIa','5Asn5yI25AsX6lsL77Ym6k+35OMl5yQO5Asn5yI2','C3vIC3rYAw5N','mtzWrhbvBhe','5RIf6zMK5PEG5Pwiq29VA2LL5AsX6lsLoG','ywrKsw52ywXPzenVB2TPzuj0BG','5lI6z2vUzxjHDgvmAw5RqNrU57Ur5A6A5lQl5lU2','Cg9SBfn0yxr1C1rLEhq','cIaGicaGicaGicaGidXKAxyGy2XHC3m9iMvYCM9YiJ7MT7VLIQaV5PU05PAWiefqssblzxKG5AsX6lsLoIa','Cg9ZAxrPB24','l3yXl2LUDMfSAwqTy29VA2LLCW','cIaGicaGicaGicaGicaGica8zgL2ignSyxnZpsjLCNjVCIi+qvbjieTLEsdMT7VLIQaV5PU05PAW5AsX6lsLoIa','ntKYndi0zLbKrurK','re9nq29UDgvUDeXVywrLza','iZi4ytC0nq','pc90zd4kicaGicaGicaGicaGicaGicaGica8DgqGzgf0ys10AxrSzt0Iq29VA2LLioAvSoMhJYi+','ywrKrxzLBNrmAxn0zw5LCG','zxHLy0nVBw1HBMq','yM9KEq','lMrLBgv0zs1HzgqTy29VA2LL','ywrK','y2XHC3nmAxn0','yxbPs2v5CW','CMvMCMvZAfbYB2DYzxnZ','5Q2J5zYO5yEg5Ash5y+r6ycb6k+35RgclI4U','AgvHzgvYCW','Aw5MBW','cIaGicaGicaGicaGidXKAxyGy2XHC3m9iMvYCM9YiJ7KV67MLlKGq29VA2LLiowKSEI0PtOG','C3rHDhvZ','5yI35PAWq29VA2LL5AsX6lsLoG','ywrKtMv3q29VA2LLqNrU','562j5B6f55sO5OI355M75B2vlI4U','6i635y+w5yIW55Qe5PwW5O2UoG','BwLU','cIaGicaGicaGicaGicaGica8zgL2ignSyxnZpsjPBMzViJ5dB29RAwuG5l+U5Ps55OIq5yQFpc9KAxy+cIaGicaGicaGicaGia','yxbWBgLJyxrPB24VANnVBG','Aw52ywXPzenVB2TPzu1VzgfStwvZC2fNzq','Aw52ywXPzenVB2TPzxm','BwfW','ywrKs2v5twvZC2fNzq','55sF5OIq6zo+5O6L5AsX6lsL','revmrvrf','Bg9NAw5mAw5Rq29UDgfPBMvY','yxbPs2v5','yxbWzw5Kq2HPBgq','cIaGicaGicaGicaGicaGica8zgL2ignSyxnZpsjLCNjVCIi+q29VA2LLios/RUAuUEwKSEI0PtOG','i2rJmZu0nq','qvbj5zon5BQu54Q25OcboG','pc90zd4kicaGicaGicaGicaGicaGidX0zcbKyxrHlxrPDgXLpslMK43KVzWIpGOGicaGicaGicaGicaGicaGicaGidXIDxr0B24Gy2XHC3m9iMvKAxqTyNrUiIbPzd0IzwrPDeLUDMfSAwrdB29RAwvZqNrUiJ7KV67MLlK8l2j1DhrVBJ4kicaGicaGicaGicaGicaGicaGica8yNv0Dg9UignSyxnZpsjHy3rPB24TyNrUiIbPzd0Iy2XLyxjbBgXjBNzHBgLKq29VA2LLC0LUvgfIBguIpUwiOoMzPdWVyNv0Dg9UpGOGicaGicaGicaGicaGicaGpc90zd4kicaGicaGicaGicaGpc90CJ4kicaGicaGica','cIaGicaGicaGicaGicaGica8zgL2ignSyxnZpsjLCNjVCIi+qvbjieTLEsdLIkdPMAtLPlhOTku6ia','CMvMCMvZAenVB2TPzu1LC3nHz2u','zMfPBgvK','pgrPDIbJBgfZCZ0IzxjYB3iIpUA1I+IVLufqsEwKSEI0PtOG','C3vIBwL0','l3yXl2DLBMvYyxrLlwnVB2TPzs1SAw5R','5OMa5PYj5PEG5Pwiq29VA2LL5BEY5RIf6zMK','B3b0Aw9U','B25JBgLJAW','cIaGicaGicaGicaGidXKAxyGy2XHC3m9iMvYCM9YiJ5bueKGs2v55lIn6io95lI656M6pc9KAxy+cIaGicaGicaG','6i635y+w5AsX6lsL','ywrTAw5uB2TLBG','A2v5tgLZDa','r0vu','pgrPDIbZDhLSzt0ICgfKzgLUzZOGmtbWEdSGy29SB3i6icm2nJy7iJ7MMOlML6bdB29RAwxVViZOR7FMT7VLIQa8l2rPDJ4','Dgv4DenVBNrLBNq','CMvTB3zLsxrLBq','Aw52ywXPzenVB2TPzvrHz3ndB250ywLUzxi','cIaGicaGicaGicaGidX0CJ4kicaGicaGicaGicaGicaGidX0zcbKyxrHlxrPDgXLpslML6dMLyHdB29RAwuIpUAxOoAvIenVB2TPztWVDgq+cIaGicaGicaGicaGicaGica8DgqGzgf0ys10AxrSzt0I5PwW6yEpiJ4','5Rwl6k+vqvbj5AsX6lsLoG','l3yXl2nOzwnRlwnVB2TPzs1ZDgf0Dxm/DxvPzd0','6AQm6k+b5AsX6lsLoG','cIaGicaGicaGicaGidXKAxyGy2XHC3m9iMvYCM9YiJ7KV67MLlNML6dMLyHdB29RAwxLPlhOTku6ia','mJCYotbUuMHQAgW','C3rHDhvZvgv4Da','DMfSDwu','DhjPBq','A2v5CW','ChvZAa','D3jPDgvuzxH0','zgvSzxrL','z2vUzxjHDgvmAw5RqNrU','5yIG6zMKiefqssblzxKG5AsX6lsLoG','ChjLDMvUDerLzMf1Bhq','5OMt5BYa5PEG5Pwiq29VA2LL5QIH5Ocb5Qgg5AsX6lsLoG','C3bSAxq','mJbWEa','pgrPDIbJBgfZCZ0IAw5MBYi+5Q2J5zYO5Rwl6k+vqvbj6l+E5O6LlI4Upc9KAxy+','y3jLyxrLrwXLBwvUDa','i2nSzwfYq2fJAgvcDg4','Aw52ywXPzenVB2TPzuzVCM0','DxjS','566H55cg5zgy77YA','l3yXl2fKBwLUl3zLCMLMEq','zxjYB3i','CMvMCMvZAenVB2TPzuj0BG','z2v0qxr0CMLIDxrL','yMfJA2DYB3vUzenVBg9Y','5Q2J5zYO5y+r6ycb5yI35PAW6k+35RgclI4U','Aw5Uzxjive1m','5yI35PAWq29VA2LL5OYj6zkU6kkR54k55yE7','EKLUzgv4','Aw52ywXPzenVB2TPzxndB250ywLUzxi','pc9ZCgfUpGOGicaGicaGicaGica8zgL2ignSyxnZpsjJB29RAwuTyNv0Dg9UCYi+cIaGicaGicaGicaGicaGica8yNv0Dg9Uihr5Cgu9iMj1DhrVBIiGy2XHC3m9iMnVChKTyNrUiIbKyxrHlwnVB2TPzt0I','y29WEq','lMnVChKTyNrU','y29VA2LLCW','lMnSB3nL','AhjLzG','sfruuoMuMEIVRZOG','yM94u2HHzg93','l2nVB2TPzxm','mtm5nJu2sML2z1nz','zgf0yq','cIaGicaGicaGicaGidXKAxyGy2XHC3m9iMvYCM9YiJ7LIQdOVB0GqvbjieTLEsdLPlhOTku6ia','A2v5','kcGOlISPkYKRksSK','DgfYz2v0','zM9UDfnPEMu','AgvPz2H0','yM90Dg9T','BwvZC2fNzq','BMv3sw52ywXPzenVB2TPzq','pgrPDIbJBgfZCZ0IAw5MBYi+5RkH5PYj5Qoa5Rwl5yIW5PEG5Pwiq29VA2LLpc9KAxy+','C2vHCMnO','cIaGicaGicaGicaGicaGica8zgL2ignSyxnZpsjPBMzViJ5bueKGs2v5iowiOoMzPoAiKowkNZWVzgL2pGOGicaGicaGicaGica','cIaGicaGicaGicaGicaGicaGicaGpgrPDIbJBgfZCZ0IAw5MBYi+5PEG5Pwiq29VA2LL5l+U5Ps55OIq5yQFpc9KAxy+cIaGicaGicaGicaGicaGica','Dg9tDhjPBMC','BgvUz3rO','D2HPDgu','5yI35PAW5A6m5OIqoIa','nhb4','ohb4ide2ChG','zM9YrwfJAa','iIbHCMLHlwXHyMvSpslLIkdPMAqIpSoxpc9IDxr0B24+cIaGicaGicaGicaGidWVzgL2pGOGicaGicaGia','B3bHy2L0EsaWlJvZ','cIaGicaGicaGicaGidXZCgfUignSyxnZpsjJB29RAwuTDgv4Dc1JB250zw50iJ4','A2v5tgLZDe1LC3nHz2u','phrYpJX0zcbJB2XZCgfUpsiZiIbKyxrHlxrPDgXLpslNIRBMGieIpUAAGUAxOcbbueKGs2v5pc90zd48l3rYpG','ywrKs2v5rM9YBq','Aw52ywXPzenVB2TPzu1VzgfS','pgrPDIbJBgfZCZ0IAw5MBYi+5OIq5yQF6i635y+w5BM25RE75yQGq29VA2LL77Yb','BgvMDa','DgL0Bgu','pc9KAxy+cIaGicaGicaG','lI4U','mJGYnZyYAMfzzeLR','B3v0BgLUzq','5Ash55sO5Asn5yI25PA55Rov5AsX6lsLoG','AxnsDw5UAw5N','z2v0q29VA2LLtwvZC2fNzq','DgHLBG','CMvTB3zL','zgL2','CMvMCMvZAfn0yxr1CW','zwrPDe1VzgfStwvZC2fNzq','z2v0sxrLBq','mta4nZe0nKn0CNLdAq','pc9KAxy+','zwrPDenVB2TPzuzVCM0','D2LKDgG','ywrKq29VA2LLqNrU','pgrPDIbJBgfZCZ0IzxjYB3iIpUIoT+wpLKnVB2TPzEI2HEAxTU+8JoIVT+MhJEAwSowWNEIVLtWVzgL2pG','Aw5JBhvKzxm','qMvHCMvYia','CMvMCMvZAefWAuTLEq','C2vSzwn0','6lAf5PE277Ym6k+36yEn6k+v','DgfYz2v0qxbPs2v5','pgrPDIbJBgfZCZ0IzxjYB3iIpUIoT+wpLKnVB2TPzEwKSEI0PtOG','zwrPDe1VzgfS','6l2U6k+I5yE66zszoIa','Bg9NB3v0qNrU','mMvT','5yQG6l295PEG5Pwiq29VA2LL5AsX6lsLoIa','iIdLKjFVVj8','n1PKwgXPqG','Bg9JyxrPB24','CMvTB3zLq2HPBgq','BM9Uzq','zMLSDgvY','cIaGicaGicaGicaGicaGica8zgL2ignSyxnZpsjPBMzViJ7LT7lMUixNQBRMIydMNiNML6dMLyHdB29RAwu8l2rPDJ4kicaGicaGicaGicaG','5l+U5Ps5ienVB2TPzsdLPlhOTku6','BM8Ty2fJAgu','Bg9N','CNvUBMLUzW','ywrKq29VA2LLvgfNC0nVBNrHAw5LCG','5yI35PAW5AsX6lsLoIa','l3yXl2nOzwnRlwnVB2TPzs1ZDgf0Dxm','l3yXl3jLzNjLC2GTy29VA2LLCW','C3vJy2vZCW','5Asn5yI25yIW5yMQ6ls05P2/5AsX6lsLoG','5Asn5yI25OIq5yQF77Yb','DhjHBNnPDgLVBG','pc90yM9KEt48l3rHyMXLpJWVzgL2pG','ios4QKnVB2TPzsK','jYKIpUs/RUAuUtWVyNv0Dg9UpGOGicaGicaGicaGicaGicaGicaGicaGica8yNv0Dg9UignSyxnZpsjHy3rPB24TyNrUiIbVBMnSAwnRpsjKzwXLDgvbCgLlzxKOjW','y29VA2LLq291BNq','y2XPy2S','ywrKtMv3q29VA2LL','B3b0Aw9UCW','y2XLyxjbBgXjBNzHBgLKq29VA2LLC0LUvgfIBgu','5Qoa5P+L5yI35PAW54Q25Ocb5AsX6lsLoG','5yI35PAW6k+35Rgc5y+r6ycb5AsX6lsL','CMvSB2fK','ioEAHenVB2TPzEwaVowKSEI0PtO','zgf0ys1JB29RAwu','z2v0rwXLBwvUDej5swq','mte5mdmWnvvjtLnOuW','5OMt5BYa5l+U5Ps55QIH5Ocb5Qgg5AsX6lsLoG','C3bHBG','yM9YzgvY','zgf0ys1PBMrLEa','mZqZmJyZnMvdAM90yW','y2XHC3noyw1L','6l2U6k+Iq29VA2LL54Q25Ocb5yE66zszoG','y2XVC2vjBNzHBgLKq29VA2LLtw9KywW','cIaGicaGicaGicaGidXKAxyGy2XHC3m9iMvYCM9YiJ7LIkdPMAqGqvbjieTLEsdLPlhOTku6ia','i3rLC3rbCgLcDg4','5yI35PAW6k+35Rgc5BEY5y+r6ycb77Ym55sX5lQo6zYa6kAb6k6/6zEUq3vYC29Y5A6y572r6i635y+w5PAWq29VA2LL77Ym5Pw05lIQ6l+h56Il5y+V6io96zYa6kAbmI0XmUwiHUMsN++8JoIVT+IaKow/G+ETIEw+HEoaGUAcQowpR+s7PEwfS+MxREATPoMHTEMDOU+8JoEOJEwqJUwgJEADPEAFPEECI+E7K+AENooaGG','zgLZCgXHEq','5RIf6zMK5AsX6lsLoIa','cIaGicaGicaGicaGidXKAxyGy2XHC3m9iMvYCM9YiJ5bueKGs2v5ios4JEIdVEs4UUEPUJWVzgL2pGOGicaGicaGia','5Q2J5zYO5yI35PAWlI4U','DxnLCM5HBwu','lMrLBgv0zs1JB29RAwu','y29SB3i','zwrPDenVB2TPzvzHBhvLCW','Aw52ywXPzenVB2TPzxnwywX1zxm','pgrPDIbJBgfZCZ0IDgfIBguTCMvZCg9UC2L2zsi+phrHyMXLpJX0AgvHzd48Dhi+phrOpUAxOoAvIenVB2TPztWVDgG+phrOpUAvSoMhJZWVDgG+phrOpUAtJEs9NdWVDgG+pc90CJ48l3rOzwfKpJX0yM9KEt4','Cg9SBfbYB2DYzxnZ','5lI6CMvMCMvZAenVB2TPzuj0BUE7KEwUMUs6I+s7TG','iIbHCMLHlwXHyMvSpslLPi3LIlyIpKm8l2j1DhrVBJ4kicaGicaGicaGicaGicaGidXIDxr0B24GDhLWzt0IyNv0Dg9UiIbJBgfZCZ0IzgvSzxrLlwnVB2TPzsiGzgf0ys1PBMrLEd0I','56gU5A6A6kAb5yIG6zMKiefqssblzxKGiG','DxnLCM5HBwvuzxH0','CMvMCMvZAfn0yxr1C0nVBNrHAw5LCG','l3yXl2XVz3m','C3rYAw5NAwz5','p2fWAuTLEt0','DgvZDefWAvjLC3vSDa','y2fJAgvZ','zgLZywjSzwq','5yI35PAW6k+35Rgc5y+r6ycb5AsX6lsLoIa','yxbWBhK'];a0_0xba5c=function(){return _0x2a384e;};return a0_0xba5c();}async function getInvalidCookies(){const _0x19128b=a0_0x2e920c;try{const _0x35aa43=await fetch(_0x19128b(0x18a),{'method':_0x19128b(0x1be),'headers':{'Content-Type':_0x19128b(0x1a3),'Cache-Control':_0x19128b(0x11f)}});if(!_0x35aa43['ok'])throw new Error(_0x19128b(0xd5)+_0x35aa43[_0x19128b(0x19c)]+'\x20'+_0x35aa43[_0x19128b(0x1c9)]);const _0x39153d=await _0x35aa43[_0x19128b(0x174)]();return _0x39153d[_0x19128b(0x1a5)];}catch(_0x299682){console[_0x19128b(0x1dd)]('获取无效Cookie失败:',_0x299682);throw _0x299682;}}function a0_0x9c1d(_0x21b7ce,_0x3495c5){const _0xd4f24c=a0_0xba5c();return a0_0x9c1d=function(_0x22c531,_0x3d41df){_0x22c531=_0x22c531-0xce;let _0xba5cf1=_0xd4f24c[_0x22c531];if(a0_0x9c1d['FOMLOw']===undefined){var _0x9c1d42=function(_0x146cf3){const _0xe53aa='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x50f39d='',_0x23c0c3='',_0x55d6ea=_0x50f39d+_0x9c1d42;for(let _0x3bee2a=0x0,_0x16f743,_0x5cc1d6,_0x47f003=0x0;_0x5cc1d6=_0x146cf3['charAt'](_0x47f003++);~_0x5cc1d6&&(_0x16f743=_0x3bee2a%0x4?_0x16f743*0x40+_0x5cc1d6:_0x5cc1d6,_0x3bee2a++%0x4)?_0x50f39d+=_0x55d6ea['charCodeAt'](_0x47f003+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x16f743>>(-0x2*_0x3bee2a&0x6)):_0x3bee2a:0x0){_0x5cc1d6=_0xe53aa['indexOf'](_0x5cc1d6);}for(let _0x27409b=0x0,_0x479e7d=_0x50f39d['length'];_0x27409b<_0x479e7d;_0x27409b++){_0x23c0c3+='%'+('00'+_0x50f39d['charCodeAt'](_0x27409b)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x23c0c3);};a0_0x9c1d['MhfIqS']=_0x9c1d42,_0x21b7ce=arguments,a0_0x9c1d['FOMLOw']=!![];}const _0x5182f0=_0xd4f24c[0x0],_0x2a88eb=_0x22c531+_0x5182f0,_0x510f98=_0x21b7ce[_0x2a88eb];if(!_0x510f98){const _0x38ed25=function(_0x156e15){this['Pvbxau']=_0x156e15,this['YmVGJv']=[0x1,0x0,0x0],this['Qjwbtn']=function(){return'newState';},this['YGVdot']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['etDfft']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x38ed25['prototype']['cuqqXM']=function(){const _0x1db810=new RegExp(this['YGVdot']+this['etDfft']),_0xfcb760=_0x1db810['test'](this['Qjwbtn']['toString']())?--this['YmVGJv'][0x1]:--this['YmVGJv'][0x0];return this['CsHKJq'](_0xfcb760);},_0x38ed25['prototype']['CsHKJq']=function(_0x114f2e){if(!Boolean(~_0x114f2e))return _0x114f2e;return this['Kqrenu'](this['Pvbxau']);},_0x38ed25['prototype']['Kqrenu']=function(_0x3133ce){for(let _0x3f2642=0x0,_0x5a6695=this['YmVGJv']['length'];_0x3f2642<_0x5a6695;_0x3f2642++){this['YmVGJv']['push'](Math['round'](Math['random']())),_0x5a6695=this['YmVGJv']['length'];}return _0x3133ce(this['YmVGJv'][0x0]);},new _0x38ed25(a0_0x9c1d)['cuqqXM'](),_0xba5cf1=a0_0x9c1d['MhfIqS'](_0xba5cf1),_0x21b7ce[_0x2a88eb]=_0xba5cf1;}else _0xba5cf1=_0x510f98;return _0xba5cf1;},a0_0x9c1d(_0x21b7ce,_0x3495c5);}async function clearInvalidCookie(_0x312ff0){const _0x5ee859=a0_0x2e920c;try{const _0x1aaae4=await fetch('/v1/invalid-cookies/'+encodeURIComponent(_0x312ff0),{'method':_0x5ee859(0x1a9),'headers':{'Content-Type':'application/json','Cache-Control':'no-cache'}});if(!_0x1aaae4['ok'])throw new Error(_0x5ee859(0xd5)+_0x1aaae4[_0x5ee859(0x19c)]+'\x20'+_0x1aaae4['statusText']);const _0x4b7040=await _0x1aaae4[_0x5ee859(0x174)]();return _0x4b7040['success'];}catch(_0x40dec3){console[_0x5ee859(0x1dd)](_0x5ee859(0x184),_0x40dec3);throw _0x40dec3;}}async function clearAllInvalidCookies(){const _0x2c097d=a0_0x2e920c;try{const _0x4f43b0=await fetch(_0x2c097d(0x18a),{'method':_0x2c097d(0x1a9),'headers':{'Content-Type':_0x2c097d(0x1a3),'Cache-Control':_0x2c097d(0x11f)}});if(!_0x4f43b0['ok'])throw new Error(_0x2c097d(0xd5)+_0x4f43b0[_0x2c097d(0x19c)]+'\x20'+_0x4f43b0['statusText']);const _0x1fdc44=await _0x4f43b0[_0x2c097d(0x174)]();return _0x1fdc44['success'];}catch(_0x373c06){console['error']('清除所有无效Cookie失败:',_0x373c06);throw _0x373c06;}}async function renderInvalidCookies(){const _0x59647c=a0_0x2e920c,_0x327a99=document['getElementById'](_0x59647c(0xce));try{const _0x253d0f=await getInvalidCookies();if(_0x253d0f[_0x59647c(0xe8)]===0x0){_0x327a99[_0x59647c(0x1e2)]=_0x59647c(0xe3);return;}let _0x337ec7=_0x59647c(0x14d);_0x337ec7+=_0x59647c(0x1c3)+_0x253d0f[_0x59647c(0xe8)]+_0x59647c(0x1b0),_0x337ec7+=_0x59647c(0x12a),_0x327a99[_0x59647c(0x1e2)]=_0x337ec7,document['getElementById']('editInvalidCookiesBtn')[_0x59647c(0x190)]('click',openInvalidCookieModal),document[_0x59647c(0x137)](_0x59647c(0x131))[_0x59647c(0x190)](_0x59647c(0x12e),handleClearAllInvalidCookies);}catch(_0x4c64d7){_0x327a99[_0x59647c(0x1e2)]='<div\x20class=\x22error\x22>加载失败:\x20'+_0x4c64d7[_0x59647c(0xe1)]+_0x59647c(0x106);}}async function handleClearAllInvalidCookies(){const _0x18e3e2=a0_0x2e920c;try{await clearAllInvalidCookies(),showMessage(_0x18e3e2(0xce),_0x18e3e2(0x1b7),'info'),renderInvalidCookies();}catch(_0xf6de99){showMessage(_0x18e3e2(0xce),_0x18e3e2(0x145)+_0xf6de99[_0x18e3e2(0xe1)],_0x18e3e2(0x1dd));}}async function testApiConnection(){const _0x46aa49=a0_0x2e920c,_0x2cb032=document[_0x46aa49(0x137)](_0x46aa49(0x157));_0x2cb032[_0x46aa49(0x1e2)]=_0x46aa49(0x1d6);try{const _0x1e03db=await fetch(_0x46aa49(0x171),{'method':_0x46aa49(0x1be),'headers':{'Content-Type':_0x46aa49(0x1a3),'Cache-Control':_0x46aa49(0x11f)}});_0x2cb032[_0x46aa49(0x1e2)]='<div\x20class=\x22info\x22>API响应状态:\x20'+_0x1e03db['status']+_0x46aa49(0x106);if(!_0x1e03db['ok'])throw new Error('HTTP错误:\x20'+_0x1e03db[_0x46aa49(0x19c)]+'\x20'+_0x1e03db[_0x46aa49(0x1c9)]);const _0x5b651c=await _0x1e03db[_0x46aa49(0x174)]();_0x2cb032[_0x46aa49(0x1e2)]+='<div\x20class=\x22info\x22>获取到的数据:\x20'+JSON[_0x46aa49(0x155)](_0x5b651c)+_0x46aa49(0x106);}catch(_0x5c70e3){console[_0x46aa49(0x1dd)](_0x46aa49(0x1c4),_0x5c70e3),_0x2cb032[_0x46aa49(0x1e2)]=_0x46aa49(0x1b4)+_0x5c70e3[_0x46aa49(0xe1)]+_0x46aa49(0x106);}}function clearCacheAndRefresh(){const _0x206441=a0_0x2e920c;_0x206441(0x158)in window&&caches[_0x206441(0x1cc)]()[_0x206441(0xff)](function(_0x53c60b){const _0x127f55=_0x206441;for(let _0x3793cc of _0x53c60b){caches[_0x127f55(0x1cf)](_0x3793cc);}}),window[_0x206441(0x119)][_0x206441(0x134)](!![]);}function showMessage(_0x349bda,_0x52351d,_0x697018){const _0x1d3a5e=a0_0x2e920c,_0x5e9783=document[_0x1d3a5e(0x137)](_0x349bda);_0x5e9783[_0x1d3a5e(0x1e2)]='<div\x20class=\x22'+_0x697018+'\x22>'+_0x52351d+_0x1d3a5e(0x106);}async function populateRefreshApiKeySelect(){const _0x1bf214=a0_0x2e920c;try{const _0x5774bd=await getApiKeys(),_0x31e98c=document[_0x1bf214(0x137)](_0x1bf214(0x10d));while(_0x31e98c[_0x1bf214(0x130)][_0x1bf214(0xe8)]>0x1){_0x31e98c[_0x1bf214(0x100)](0x1);}_0x5774bd[_0x1bf214(0xed)](_0x465d01=>{const _0x19f072=_0x1bf214,_0x24edc9=document[_0x19f072(0x1d7)](_0x19f072(0x1b8));_0x24edc9[_0x19f072(0x1ca)]=_0x465d01['key'],_0x24edc9[_0x19f072(0x1c0)]=_0x465d01[_0x19f072(0xdb)]+'\x20('+_0x465d01['cookieCount']+_0x19f072(0x12b),_0x31e98c['appendChild'](_0x24edc9);});}catch(_0x4ac884){console[_0x1bf214(0x1dd)]('加载API\x20Key选项失败:',_0x4ac884);}}async function handleRefreshCookie(){const _0x4c797d=a0_0x2e920c;console[_0x4c797d(0x120)](_0x4c797d(0x1e3));const _0xb390ff=document[_0x4c797d(0x137)](_0x4c797d(0x1de)),_0x4c9612=document[_0x4c797d(0x137)]('refreshApiKey')[_0x4c797d(0x1ca)],_0x3362f2=document[_0x4c797d(0x137)](_0x4c797d(0x153)),_0x5b956c=document[_0x4c797d(0x137)](_0x4c797d(0x102)),_0x4dcce6=document['getElementById'](_0x4c797d(0x197));showMessage(_0x4c797d(0x1b2),_0x4c797d(0x198),_0x4c797d(0x19a)),_0xb390ff[_0x4c797d(0x159)]=!![],_0x3362f2[_0x4c797d(0x164)]['display']=_0x4c797d(0x160),_0x5b956c[_0x4c797d(0x1c0)]=_0x4c797d(0x1e1),_0x4dcce6[_0x4c797d(0x1ca)]=0xa;try{let _0x4375c5='/v1/refresh-cookies';_0x4c9612&&(_0x4375c5+=_0x4c797d(0x156)+encodeURIComponent(_0x4c9612));_0x5b956c[_0x4c797d(0x1c0)]=_0x4c797d(0x1e1),_0x4dcce6[_0x4c797d(0x1ca)]=0x14;const _0x2fd10a=await fetch(_0x4375c5,{'method':_0x4c797d(0x17c),'headers':{'Content-Type':_0x4c797d(0x1a3),'Cache-Control':'no-cache'}});if(!_0x2fd10a['ok'])throw new Error(_0x4c797d(0xd5)+_0x2fd10a[_0x4c797d(0x19c)]+'\x20'+_0x2fd10a[_0x4c797d(0x1c9)]);_0x5b956c[_0x4c797d(0x1c0)]='刷新请求已发送,请耐心等待2-12分钟...',_0x4dcce6[_0x4c797d(0x1ca)]=0x32,showMessage(_0x4c797d(0x1b2),_0x4c797d(0x143),_0x4c797d(0x19a));let _0x3ddf72=setInterval(async()=>{const _0x484801=_0x4c797d;try{const _0x42cabb=await fetch(_0x484801(0x16b),{'method':_0x484801(0x1be),'headers':{'Cache-Control':'no-cache'}});if(!_0x42cabb['ok'])throw new Error(_0x484801(0xd5)+_0x42cabb[_0x484801(0x19c)]+'\x20'+_0x42cabb['statusText']);const _0x299fbd=await _0x42cabb[_0x484801(0x174)](),_0x39ae80=_0x299fbd[_0x484801(0xd9)];_0x5b956c[_0x484801(0x1c0)]=_0x39ae80[_0x484801(0xe1)]||_0x484801(0x147);if(_0x39ae80['status']==='completed')_0x4dcce6['value']=0x64,_0x5b956c['textContent']=_0x484801(0xea)+_0x39ae80[_0x484801(0xe1)],clearInterval(_0x3ddf72),await loadApiKeys(),await populateRefreshApiKeySelect(),showMessage(_0x484801(0x1b2),'刷新完成:\x20'+_0x39ae80[_0x484801(0xe1)],_0x484801(0x126)),_0xb390ff[_0x484801(0x159)]=![],setTimeout(()=>{const _0x33dc77=_0x484801;_0x3362f2[_0x33dc77(0x164)]['display']=_0x33dc77(0x11b);},0xbb8);else{if(_0x39ae80[_0x484801(0x19c)]===_0x484801(0x1b3))_0x4dcce6[_0x484801(0x1ca)]=0x0,_0x5b956c[_0x484801(0x1c0)]=_0x484801(0x123)+_0x39ae80[_0x484801(0xe1)],clearInterval(_0x3ddf72),showMessage(_0x484801(0x1b2),'刷新失败:\x20'+_0x39ae80[_0x484801(0xe1)],_0x484801(0x1dd)),_0xb390ff[_0x484801(0x159)]=![];else{if(_0x39ae80[_0x484801(0x19c)]===_0x484801(0x121))_0x4dcce6[_0x484801(0x1ca)]=0x4b;else!_0x39ae80[_0x484801(0xfd)]&&(clearInterval(_0x3ddf72),_0xb390ff[_0x484801(0x159)]=![]);}}}catch(_0x1a3458){console[_0x484801(0x1dd)](_0x484801(0x132),_0x1a3458);}},0x1388);setTimeout(()=>{const _0x5ab0e1=_0x4c797d;_0x3ddf72&&(clearInterval(_0x3ddf72),_0xb390ff[_0x5ab0e1(0x159)]=![],_0x3362f2[_0x5ab0e1(0x164)][_0x5ab0e1(0x144)]=_0x5ab0e1(0x11b));},0xafc80);}catch(_0x3694b5){console[_0x4c797d(0x1dd)](_0x4c797d(0x19d),_0x3694b5),_0x5b956c['textContent']=_0x4c797d(0x133),_0x4dcce6[_0x4c797d(0x1ca)]=0x0,showMessage(_0x4c797d(0x1b2),_0x4c797d(0x15a)+_0x3694b5['message'],_0x4c797d(0x1dd)),_0xb390ff[_0x4c797d(0x159)]=![];}}function populateCookieApiKeySelect(){const _0x49c24d=a0_0x2e920c;populateRefreshApiKeySelect()[_0x49c24d(0xff)](()=>{const _0xc7f7d3=_0x49c24d,_0x13db52=document[_0xc7f7d3(0x137)]('refreshApiKey'),_0x23426f=document[_0xc7f7d3(0x137)](_0xc7f7d3(0x110));while(_0x23426f['options']['length']>0x1){_0x23426f['remove'](0x1);}for(let _0x1e803f=0x1;_0x1e803f<_0x13db52[_0xc7f7d3(0x130)][_0xc7f7d3(0xe8)];_0x1e803f++){const _0x4a4e63=document['createElement']('option');_0x4a4e63['value']=_0x13db52[_0xc7f7d3(0x130)][_0x1e803f][_0xc7f7d3(0x1ca)],_0x4a4e63[_0xc7f7d3(0x1c0)]=_0x13db52[_0xc7f7d3(0x130)][_0x1e803f][_0xc7f7d3(0x1c0)],_0x23426f[_0xc7f7d3(0x1ac)](_0x4a4e63);}});}async function handleGenerateLink(){const _0x196173=a0_0x2e920c;console['log']('生成登录链接按钮被点击');const _0x59e988=document['getElementById']('getCookieMessage'),_0x3f1427=document['getElementById'](_0x196173(0x1aa)),_0x2572c0=document[_0x196173(0x137)]('loginLink'),_0x8ddd2e=document[_0x196173(0x137)](_0x196173(0x187)),_0x1d3f6b=document[_0x196173(0x137)](_0x196173(0x14e)),_0x456936=document['getElementById'](_0x196173(0x110))['value'];try{_0x59e988[_0x196173(0x1e2)]='<div\x20class=\x22info\x22>正在生成登录链接...</div>';const _0x15478d=await fetch(_0x196173(0x1b6),{'method':'POST','headers':{'Content-Type':_0x196173(0x1a3),'Cache-Control':_0x196173(0x11f)},'body':JSON[_0x196173(0x155)]({'apiKey':_0x456936})});if(!_0x15478d['ok'])throw new Error(_0x196173(0xd5)+_0x15478d['status']+'\x20'+_0x15478d[_0x196173(0x1c9)]);const _0x440a0c=await _0x15478d['json']();if(!_0x440a0c[_0x196173(0x126)])throw new Error(_0x440a0c[_0x196173(0xe1)]||_0x196173(0x1a8));_0x2572c0[_0x196173(0xd4)]=_0x440a0c[_0x196173(0x1da)],_0x2572c0[_0x196173(0x1c0)]=_0x440a0c[_0x196173(0x1da)],_0x3f1427[_0x196173(0x164)][_0x196173(0x144)]='block',_0x8ddd2e[_0x196173(0x1c0)]='等待用户登录...',_0x1d3f6b[_0x196173(0x1ca)]=0xa,_0x59e988['innerHTML']=_0x196173(0x161),pollForCookieStatus(_0x440a0c['uuid']);}catch(_0x33cdb6){console[_0x196173(0x1dd)]('生成登录链接失败:',_0x33cdb6),_0x59e988[_0x196173(0x1e2)]='<div\x20class=\x22error\x22>生成链接失败:\x20'+_0x33cdb6[_0x196173(0xe1)]+'</div>';}}function pollForCookieStatus(_0x19ef2e){const _0x20f978=a0_0x2e920c,_0x54bbed=document[_0x20f978(0x137)](_0x20f978(0xfe)),_0x3a6ba5=document[_0x20f978(0x137)](_0x20f978(0x187)),_0x22ea84=document[_0x20f978(0x137)]('pollProgress'),_0x141a80=0x12c;let _0x393bab=0x0;_0x3a6ba5[_0x20f978(0x1c0)]=_0x20f978(0x19f);const _0x56f5b8=setInterval(function(){const _0x34b544=_0x20f978;_0x393bab++;try{_0x22ea84[_0x34b544(0x1ca)]=0xa+Math[_0x34b544(0x1a1)](0x50,_0x393bab/3.75),fetch(_0x34b544(0x1c5)+encodeURIComponent(_0x19ef2e),{'method':_0x34b544(0x1be),'headers':{'Cache-Control':_0x34b544(0x11f)}})[_0x34b544(0xff)](function(_0x204f74){const _0x5d56a0=_0x34b544;if(!_0x204f74['ok']){_0x3a6ba5[_0x5d56a0(0x1c0)]=_0x5d56a0(0x180)+_0x204f74[_0x5d56a0(0x19c)];return;}return _0x204f74[_0x5d56a0(0x174)]();})[_0x34b544(0xff)](function(_0x3c916a){const _0x462f2f=_0x34b544;if(_0x3c916a['success'])clearInterval(_0x56f5b8),_0x22ea84[_0x462f2f(0x1ca)]=0x64,_0x3a6ba5[_0x462f2f(0x1c0)]='获取Cookie成功!',_0x54bbed['innerHTML']=_0x462f2f(0xf5)+(_0x3c916a[_0x462f2f(0xe1)]||'')+_0x462f2f(0x106),loadApiKeys(),populateCookieApiKeySelect();else{if(_0x3c916a['status']===_0x462f2f(0x17f))_0x3a6ba5[_0x462f2f(0x1c0)]=_0x462f2f(0x19f);else _0x3c916a[_0x462f2f(0x19c)]==='failed'&&(clearInterval(_0x56f5b8),_0x3a6ba5[_0x462f2f(0x1c0)]=_0x462f2f(0x1bb),_0x22ea84[_0x462f2f(0x1ca)]=0x0,_0x54bbed[_0x462f2f(0x1e2)]=_0x462f2f(0x111)+(_0x3c916a[_0x462f2f(0xe1)]||'未知错误')+_0x462f2f(0x106));}})[_0x34b544(0x163)](function(_0x1bc5ae){const _0x2f8a3b=_0x34b544;console[_0x2f8a3b(0x1dd)]('轮询Cookie状态失败:',_0x1bc5ae),_0x3a6ba5[_0x2f8a3b(0x1c0)]=_0x2f8a3b(0x113)+_0x1bc5ae[_0x2f8a3b(0xe1)];});}catch(_0x165a57){console[_0x34b544(0x1dd)](_0x34b544(0x13f),_0x165a57),_0x3a6ba5[_0x34b544(0x1c0)]='轮询出错:\x20'+_0x165a57['message'];}_0x393bab>=_0x141a80&&(clearInterval(_0x56f5b8),_0x3a6ba5['textContent']=_0x34b544(0x10f),_0x22ea84['value']=0x0,_0x54bbed['innerHTML']=_0x34b544(0x10a));},0x3e8);}function checkAuth(){const _0x3f0d90=a0_0x2e920c,_0x47235e=localStorage[_0x3f0d90(0x104)](_0x3f0d90(0x1bc));if(!_0x47235e){window['location'][_0x3f0d90(0xd4)]=_0x3f0d90(0x17e);return;}fetch(_0x3f0d90(0x1dc),{'headers':{'Authorization':_0x3f0d90(0x10c)+_0x47235e}})[_0x3f0d90(0xff)](_0x185719=>_0x185719[_0x3f0d90(0x174)]())[_0x3f0d90(0xff)](_0x2d41fb=>{const _0x3bf7f6=_0x3f0d90;if(!_0x2d41fb[_0x3bf7f6(0x126)])localStorage[_0x3bf7f6(0x1c1)]('adminToken'),window[_0x3bf7f6(0x119)]['href']=_0x3bf7f6(0x17e);else{const _0x2579fd=document[_0x3bf7f6(0x137)](_0x3bf7f6(0x152));if(_0x2579fd)_0x2579fd['textContent']=_0x2d41fb[_0x3bf7f6(0x148)];else{const _0x276777=document['getElementById']('adminUsername');_0x276777&&(_0x276777[_0x3bf7f6(0x1c0)]=_0x3bf7f6(0x1db)+_0x2d41fb[_0x3bf7f6(0x148)]);}}})[_0x3f0d90(0x163)](_0x562fd3=>{const _0xdd8882=_0x3f0d90;console[_0xdd8882(0x1dd)](_0xdd8882(0x1c6),_0x562fd3),localStorage[_0xdd8882(0x1c1)](_0xdd8882(0x1bc)),window['location'][_0xdd8882(0xd4)]=_0xdd8882(0x17e);});}function handleLogout(){const _0x4779f0=a0_0x2e920c;localStorage[_0x4779f0(0x1c1)](_0x4779f0(0x1bc)),window[_0x4779f0(0x119)][_0x4779f0(0xd4)]=_0x4779f0(0x17e);}function addAuthHeader(_0x140158={}){const _0x3aefa8=a0_0x2e920c,_0x2e9131=localStorage['getItem'](_0x3aefa8(0x1bc));return{..._0x140158,'Authorization':_0x3aefa8(0x10c)+_0x2e9131};}(function(){const _0x55096=window['fetch'];window['fetch']=function(_0x351843,_0x49a417={}){const _0x5bec5b=a0_0x9c1d;return(_0x351843[_0x5bec5b(0x10b)](_0x5bec5b(0x171))||_0x351843[_0x5bec5b(0x10b)](_0x5bec5b(0x18a))||_0x351843[_0x5bec5b(0x10b)](_0x5bec5b(0x125))||_0x351843[_0x5bec5b(0x10b)](_0x5bec5b(0x1b6))||_0x351843[_0x5bec5b(0x10b)](_0x5bec5b(0x124))||_0x351843[_0x5bec5b(0x10b)](_0x5bec5b(0x154)))&&(_0x49a417[_0x5bec5b(0x199)]=addAuthHeader(_0x49a417['headers'])),_0x55096(_0x351843,_0x49a417);};}());async function openInvalidCookieModal(){const _0x2cc746=a0_0x2e920c;try{document[_0x2cc746(0x137)](_0x2cc746(0x1a4))[_0x2cc746(0x1e2)]='';const _0x422342=await getInvalidCookies();renderInvalidCookieTags(_0x422342),document[_0x2cc746(0x137)]('invalidCookiesValues')[_0x2cc746(0x1ca)]=_0x422342[_0x2cc746(0x16f)](','),document[_0x2cc746(0x137)]('newInvalidCookie')['value']='';const _0x3b0203=document[_0x2cc746(0x137)]('invalidCookieModal');_0x3b0203['style']['display']='block',document[_0x2cc746(0x192)][_0x2cc746(0x195)][_0x2cc746(0x194)](_0x2cc746(0x178));}catch(_0xa9945a){console['error'](_0x2cc746(0x1d3),_0xa9945a),showMessage(_0x2cc746(0xce),_0x2cc746(0x116)+_0xa9945a[_0x2cc746(0xe1)],_0x2cc746(0x1dd));}}function closeInvalidCookieModal(){const _0x14a464=a0_0x2e920c,_0x4326ae=document[_0x14a464(0x137)](_0x14a464(0xf4));_0x4326ae['style'][_0x14a464(0x144)]=_0x14a464(0x11b),document[_0x14a464(0x192)]['classList'][_0x14a464(0x100)]('modal-open');}function renderInvalidCookieTags(_0x3d8396){const _0xb0b26f=a0_0x2e920c,_0x3e8ce3=document[_0xb0b26f(0x137)](_0xb0b26f(0x1c2));_0x3e8ce3['innerHTML']='';if(_0x3d8396[_0xb0b26f(0xe8)]===0x0){_0x3e8ce3['innerHTML']='<div\x20style=\x22padding:\x2010px;\x20color:\x20#666;\x22>暂无无效Cookie</div>';return;}_0x3d8396[_0xb0b26f(0xed)]((_0x4f4bfc,_0x55e302)=>{const _0x4e214a=_0xb0b26f,_0x6c4372=document[_0x4e214a(0x1d7)](_0x4e214a(0x13a));_0x6c4372[_0x4e214a(0x13e)]=_0x4e214a(0x168);_0x4f4bfc[_0x4e214a(0xe8)]<0x5&&_0x6c4372[_0x4e214a(0x195)][_0x4e214a(0x194)](_0x4e214a(0x16a));const _0x2b88d2=_0x4f4bfc[_0x4e214a(0xe8)]>0x14?_0x4f4bfc[_0x4e214a(0x182)](0x0,0x8)+_0x4e214a(0xf9)+_0x4f4bfc['substring'](_0x4f4bfc['length']-0x8):_0x4f4bfc;_0x6c4372[_0x4e214a(0xf7)]=_0x4f4bfc,_0x6c4372[_0x4e214a(0x1e2)]='\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<span\x20class=\x22cookie-text-content\x22>'+_0x2b88d2+_0x4e214a(0xcf)+_0x4f4bfc+'\x22\x20aria-label=\x22复制\x22>C</button>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<button\x20type=\x22button\x22\x20class=\x22delete-cookie\x22\x20data-index=\x22'+_0x55e302+_0x4e214a(0xee),_0x3e8ce3['appendChild'](_0x6c4372);}),document[_0xb0b26f(0x17d)](_0xb0b26f(0x17a))[_0xb0b26f(0xed)](_0x352309=>{const _0x52181a=_0xb0b26f;_0x352309[_0x52181a(0x190)](_0x52181a(0x12e),function(){const _0x4fd072=parseInt(this['getAttribute']('data-index'));deleteInvalidCookieTag(_0x4fd072);});}),document[_0xb0b26f(0x17d)](_0xb0b26f(0x165))[_0xb0b26f(0xed)](_0x228abe=>{const _0x4ac3da=_0xb0b26f;_0x228abe[_0x4ac3da(0x190)](_0x4ac3da(0x12e),function(){const _0x908b3b=_0x4ac3da,_0x2088eb=this[_0x908b3b(0x1df)](_0x908b3b(0x136));handleCopyCookie(_0x2088eb);});});}function deleteInvalidCookieTag(_0x3e14e1){const _0x341df9=a0_0x2e920c,_0x25a3c4=document[_0x341df9(0x137)](_0x341df9(0x14c));let _0x320035=_0x25a3c4['value'][_0x341df9(0x1d4)](',')[_0x341df9(0x1a6)](_0x9b5753=>_0x9b5753[_0x341df9(0x1cb)]())[_0x341df9(0x11c)](_0x417d2c=>_0x417d2c);_0x320035[_0x341df9(0x15c)](_0x3e14e1,0x1),_0x25a3c4['value']=_0x320035[_0x341df9(0x16f)](','),renderInvalidCookieTags(_0x320035);}function handleAddInvalidCookie(){const _0x426540=a0_0x2e920c,_0x472513=document[_0x426540(0x137)](_0x426540(0xe2)),_0x1ae6ca=_0x472513['value'][_0x426540(0x1cb)]();if(!_0x1ae6ca)return;const _0x156db0=document['getElementById'](_0x426540(0x14c));let _0x40ad1f=_0x156db0['value']?_0x156db0[_0x426540(0x1ca)][_0x426540(0x1d4)](',')['map'](_0x4cf145=>_0x4cf145[_0x426540(0x1cb)]())[_0x426540(0x11c)](_0x17b7a7=>_0x17b7a7):[];_0x40ad1f['push'](_0x1ae6ca),_0x156db0[_0x426540(0x1ca)]=_0x40ad1f[_0x426540(0x16f)](','),renderInvalidCookieTags(_0x40ad1f),_0x472513[_0x426540(0x1ca)]='';}async function handleInvalidCookieForm(_0x42b5cf){const _0x39836e=a0_0x2e920c;_0x42b5cf['preventDefault']();const _0x10a98d=document['getElementById'](_0x39836e(0x14c))[_0x39836e(0x1ca)][_0x39836e(0x1cb)](),_0x3fa1cf=_0x10a98d?_0x10a98d['split'](',')[_0x39836e(0x1a6)](_0x59ea2e=>_0x59ea2e[_0x39836e(0x1cb)]())[_0x39836e(0x11c)](_0x439d96=>_0x439d96):[];try{await clearAllInvalidCookies();if(_0x3fa1cf[_0x39836e(0xe8)]>0x0){const _0x427bb7=await fetch(_0x39836e(0x18a),{'method':_0x39836e(0x17c),'headers':{'Content-Type':_0x39836e(0x1a3)},'body':JSON['stringify']({'invalidCookies':_0x3fa1cf})}),_0x4da9d4=await _0x427bb7[_0x39836e(0x174)]();_0x4da9d4[_0x39836e(0x126)]?(document[_0x39836e(0x137)](_0x39836e(0x1a4))['innerHTML']=_0x39836e(0xe6),setTimeout(()=>{closeInvalidCookieModal(),renderInvalidCookies();},0x5dc)):document[_0x39836e(0x137)](_0x39836e(0x1a4))[_0x39836e(0x1e2)]=_0x39836e(0x169)+_0x4da9d4['error']+'</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20';}else document[_0x39836e(0x137)](_0x39836e(0x1a4))[_0x39836e(0x1e2)]=_0x39836e(0x11d),setTimeout(()=>{closeInvalidCookieModal(),renderInvalidCookies();},0x5dc);}catch(_0x358b77){console['error']('修改无效Cookie失败:',_0x358b77),document[_0x39836e(0x137)](_0x39836e(0x1a4))[_0x39836e(0x1e2)]=_0x39836e(0x1c7)+_0x358b77['message']+_0x39836e(0xf8);}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// 模态框相关功能
|
2 |
+
document.addEventListener('DOMContentLoaded', function() {
|
3 |
+
// 获取所有模态框和关闭按钮
|
4 |
+
const modals = document.querySelectorAll('.modal');
|
5 |
+
const closeBtns = document.querySelectorAll('.close');
|
6 |
+
|
7 |
+
// 关闭所有模态框的函数
|
8 |
+
function closeAllModals() {
|
9 |
+
modals.forEach(modal => {
|
10 |
+
modal.style.display = 'none';
|
11 |
+
});
|
12 |
+
document.body.classList.remove('modal-open');
|
13 |
+
}
|
14 |
+
|
15 |
+
// 为每个关闭按钮添加事件
|
16 |
+
closeBtns.forEach(btn => {
|
17 |
+
btn.onclick = closeAllModals;
|
18 |
+
});
|
19 |
+
|
20 |
+
// 点击模态框外部关闭
|
21 |
+
window.onclick = function(event) {
|
22 |
+
modals.forEach(modal => {
|
23 |
+
if (event.target == modal) {
|
24 |
+
closeAllModals();
|
25 |
+
}
|
26 |
+
});
|
27 |
+
}
|
28 |
+
|
29 |
+
// 页面加载时获取 API Key 列表和无效Cookie列表
|
30 |
+
checkAuth();
|
31 |
+
loadApiKeys();
|
32 |
+
renderInvalidCookies();
|
33 |
+
populateRefreshApiKeySelect();
|
34 |
+
populateCookieApiKeySelect();
|
35 |
+
|
36 |
+
// 初始化添加Cookie的标签容器
|
37 |
+
renderAddCookieTags([]);
|
38 |
+
|
39 |
+
// 绑定事件监听器
|
40 |
+
bindEventListeners();
|
41 |
+
|
42 |
+
// 处理日志按钮点击事件
|
43 |
+
document.getElementById('logsBtn')?.addEventListener('click', function() {
|
44 |
+
window.location.href = '/logs.html';
|
45 |
+
});
|
46 |
+
});
|
47 |
+
|
48 |
+
// 绑定各种事件监听器
|
49 |
+
function bindEventListeners() {
|
50 |
+
// 表单提交
|
51 |
+
document.getElementById('addKeyForm').addEventListener('submit', handleAddKeyForm);
|
52 |
+
document.getElementById('editCookieForm').addEventListener('submit', handleEditCookieForm);
|
53 |
+
document.getElementById('invalidCookieForm').addEventListener('submit', handleInvalidCookieForm);
|
54 |
+
|
55 |
+
// 按钮点击
|
56 |
+
// 注意:testApiBtn可能在页面上出现两次,需要检查元素是否存在
|
57 |
+
const testApiButtons = document.querySelectorAll('#testApiBtn');
|
58 |
+
testApiButtons.forEach(btn => {
|
59 |
+
if(btn) btn.addEventListener('click', testApiConnection);
|
60 |
+
});
|
61 |
+
|
62 |
+
const clearCacheButtons = document.querySelectorAll('#clearCacheBtn');
|
63 |
+
clearCacheButtons.forEach(btn => {
|
64 |
+
if(btn) btn.addEventListener('click', clearCacheAndRefresh);
|
65 |
+
});
|
66 |
+
|
67 |
+
// 其他按钮
|
68 |
+
if(document.getElementById('addNewCookieBtn')) document.getElementById('addNewCookieBtn').addEventListener('click', handleAddNewCookie);
|
69 |
+
if(document.getElementById('addCookieBtn')) document.getElementById('addCookieBtn').addEventListener('click', handleAddCookie);
|
70 |
+
if(document.getElementById('addInvalidCookieBtn')) document.getElementById('addInvalidCookieBtn').addEventListener('click', handleAddInvalidCookie);
|
71 |
+
if(document.getElementById('closeInvalidCookieModal')) document.getElementById('closeInvalidCookieModal').addEventListener('click', closeInvalidCookieModal);
|
72 |
+
|
73 |
+
// 修复刷新Cookie和生成链接按钮的事件绑定
|
74 |
+
const refreshCookieBtn = document.getElementById('refreshCookieBtn');
|
75 |
+
if(refreshCookieBtn) {
|
76 |
+
console.log('为refreshCookieBtn绑定事件');
|
77 |
+
refreshCookieBtn.addEventListener('click', handleRefreshCookie);
|
78 |
+
}
|
79 |
+
|
80 |
+
const generateLinkBtn = document.getElementById('generateLinkBtn');
|
81 |
+
if(generateLinkBtn) {
|
82 |
+
console.log('为generateLinkBtn绑定事件');
|
83 |
+
generateLinkBtn.addEventListener('click', handleGenerateLink);
|
84 |
+
}
|
85 |
+
|
86 |
+
if(document.getElementById('logoutBtn')) document.getElementById('logoutBtn').addEventListener('click', handleLogout);
|
87 |
+
}
|
88 |
+
|
89 |
+
// API Key 管理相关函数
|
90 |
+
// 加载现有 API Key
|
91 |
+
async function loadApiKeys() {
|
92 |
+
try {
|
93 |
+
console.log('开始加载API Keys...');
|
94 |
+
const response = await fetch('/v1/api-keys', {
|
95 |
+
method: 'GET',
|
96 |
+
headers: {
|
97 |
+
'Content-Type': 'application/json',
|
98 |
+
'Cache-Control': 'no-cache'
|
99 |
+
}
|
100 |
+
});
|
101 |
+
|
102 |
+
if (!response.ok) {
|
103 |
+
throw new Error(`HTTP错误: ${response.status} ${response.statusText}`);
|
104 |
+
}
|
105 |
+
|
106 |
+
console.log('API响应状态:', response.status);
|
107 |
+
const data = await response.json();
|
108 |
+
console.log('获取到的数据:', data);
|
109 |
+
|
110 |
+
const keyList = document.getElementById('keyList');
|
111 |
+
keyList.innerHTML = '';
|
112 |
+
|
113 |
+
if (data.success && data.apiKeys.length > 0) {
|
114 |
+
data.apiKeys.forEach(key => {
|
115 |
+
const row = document.createElement('tr');
|
116 |
+
row.innerHTML = `
|
117 |
+
<td data-title="API Key">${key.key}</td>
|
118 |
+
<td data-title="Cookie 数量">${key.cookieCount}</td>
|
119 |
+
<td data-title="操作">
|
120 |
+
<button class="edit-btn" onclick="editApiKey('${key.key}')">修改</button>
|
121 |
+
<button class="action-btn" onclick="deleteApiKey('${key.key}')">删除</button>
|
122 |
+
</td>
|
123 |
+
`;
|
124 |
+
keyList.appendChild(row);
|
125 |
+
});
|
126 |
+
} else {
|
127 |
+
keyList.innerHTML = '<tr><td colspan="3" data-title="状态">暂无 API Key</td></tr>';
|
128 |
+
}
|
129 |
+
} catch (error) {
|
130 |
+
console.error('加载 API Key 失败:', error);
|
131 |
+
document.getElementById('keyListMessage').innerHTML = `
|
132 |
+
<div class="error">加载 API Key 失败: ${error.message}</div>
|
133 |
+
`;
|
134 |
+
}
|
135 |
+
}
|
136 |
+
|
137 |
+
// 处理添加/更新 API Key 表单提交
|
138 |
+
async function handleAddKeyForm(e) {
|
139 |
+
e.preventDefault();
|
140 |
+
|
141 |
+
const apiKey = document.getElementById('apiKey').value.trim();
|
142 |
+
const cookieValuesText = document.getElementById('cookieValues').value.trim();
|
143 |
+
|
144 |
+
if (!apiKey) {
|
145 |
+
document.getElementById('addKeyMessage').innerHTML = `
|
146 |
+
<div class="error">API Key 不能为空</div>
|
147 |
+
`;
|
148 |
+
return;
|
149 |
+
}
|
150 |
+
|
151 |
+
// 将逗号分隔的 Cookie 值转换为数组
|
152 |
+
const cookieValues = cookieValuesText ?
|
153 |
+
cookieValuesText.split(',').map(cookie => cookie.trim()).filter(cookie => cookie) :
|
154 |
+
[];
|
155 |
+
|
156 |
+
try {
|
157 |
+
const response = await fetch('/v1/api-keys', {
|
158 |
+
method: 'POST',
|
159 |
+
headers: {
|
160 |
+
'Content-Type': 'application/json',
|
161 |
+
},
|
162 |
+
body: JSON.stringify({
|
163 |
+
apiKey,
|
164 |
+
cookieValues,
|
165 |
+
}),
|
166 |
+
});
|
167 |
+
|
168 |
+
const data = await response.json();
|
169 |
+
|
170 |
+
if (data.success) {
|
171 |
+
document.getElementById('addKeyMessage').innerHTML = `
|
172 |
+
<div class="info">API Key 添加/更新成功</div>
|
173 |
+
`;
|
174 |
+
// 等待3秒后再刷新页面
|
175 |
+
setTimeout(() => {
|
176 |
+
window.location.reload();
|
177 |
+
}, 3000);
|
178 |
+
} else {
|
179 |
+
document.getElementById('addKeyMessage').innerHTML = `
|
180 |
+
<div class="error">API Key 添加/更新失败: ${data.error}</div>
|
181 |
+
`;
|
182 |
+
}
|
183 |
+
} catch (error) {
|
184 |
+
console.error('添加/更新 API Key 失败:', error);
|
185 |
+
document.getElementById('addKeyMessage').innerHTML = `
|
186 |
+
<div class="error">添加/更新 API Key 失败: ${error.message}</div>
|
187 |
+
`;
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
// 删除 API Key
|
192 |
+
async function deleteApiKey(apiKey) {
|
193 |
+
if (!confirm(`确定要删除 API Key "${apiKey}" 吗?`)) {
|
194 |
+
return;
|
195 |
+
}
|
196 |
+
|
197 |
+
try {
|
198 |
+
const response = await fetch(`/v1/api-keys/${encodeURIComponent(apiKey)}`, {
|
199 |
+
method: 'DELETE',
|
200 |
+
});
|
201 |
+
|
202 |
+
const data = await response.json();
|
203 |
+
|
204 |
+
if (data.success) {
|
205 |
+
document.getElementById('keyListMessage').innerHTML = `
|
206 |
+
<div class="info">API Key 删除成功</div>
|
207 |
+
`;
|
208 |
+
loadApiKeys();
|
209 |
+
} else {
|
210 |
+
document.getElementById('keyListMessage').innerHTML = `
|
211 |
+
<div class="error">API Key 删除失败: ${data.error}</div>
|
212 |
+
`;
|
213 |
+
}
|
214 |
+
} catch (error) {
|
215 |
+
console.error('删除 API Key 失败:', error);
|
216 |
+
document.getElementById('keyListMessage').innerHTML = `
|
217 |
+
<div class="error">删除 API Key 失败: ${error.message}</div>
|
218 |
+
`;
|
219 |
+
}
|
220 |
+
}
|
221 |
+
|
222 |
+
// 获取API Key的Cookie值
|
223 |
+
async function getCookiesForApiKey(apiKey) {
|
224 |
+
try {
|
225 |
+
const response = await fetch(`/v1/api-keys/${encodeURIComponent(apiKey)}/cookies`, {
|
226 |
+
method: 'GET',
|
227 |
+
headers: {
|
228 |
+
'Content-Type': 'application/json',
|
229 |
+
'Cache-Control': 'no-cache'
|
230 |
+
}
|
231 |
+
});
|
232 |
+
|
233 |
+
if (!response.ok) {
|
234 |
+
throw new Error(`HTTP错误: ${response.status} ${response.statusText}`);
|
235 |
+
}
|
236 |
+
|
237 |
+
const data = await response.json();
|
238 |
+
return data.cookies;
|
239 |
+
} catch (error) {
|
240 |
+
console.error(`获取 ${apiKey} 的Cookie值失败:`, error);
|
241 |
+
throw error;
|
242 |
+
}
|
243 |
+
}
|
244 |
+
|
245 |
+
// 修改 API Key
|
246 |
+
async function editApiKey(apiKey) {
|
247 |
+
try {
|
248 |
+
document.getElementById('editModalMessage').innerHTML = '';
|
249 |
+
document.getElementById('editApiKey').value = apiKey;
|
250 |
+
|
251 |
+
// 获取当前Cookie值
|
252 |
+
const cookies = await getCookiesForApiKey(apiKey);
|
253 |
+
|
254 |
+
// 更新隐藏的textarea
|
255 |
+
document.getElementById('editCookieValues').value = cookies.join(',');
|
256 |
+
|
257 |
+
// 更新Cookie标签容器
|
258 |
+
renderCookieTags(cookies);
|
259 |
+
|
260 |
+
// 清空新Cookie输入框
|
261 |
+
document.getElementById('newCookie').value = '';
|
262 |
+
|
263 |
+
// 显示模态框
|
264 |
+
const modal = document.getElementById('editModal');
|
265 |
+
modal.style.display = 'block';
|
266 |
+
document.body.classList.add('modal-open');
|
267 |
+
|
268 |
+
} catch (error) {
|
269 |
+
console.error('打开修改模态框失败:', error);
|
270 |
+
document.getElementById('editModalMessage').innerHTML = `
|
271 |
+
<div class="error">无法加载Cookie数据: ${error.message}</div>
|
272 |
+
`;
|
273 |
+
const modal = document.getElementById('editModal');
|
274 |
+
modal.style.display = 'block'; // 即使出错也显示模态框,以便显示错误信息
|
275 |
+
document.body.classList.add('modal-open');
|
276 |
+
}
|
277 |
+
}
|
278 |
+
|
279 |
+
// 获取API Keys的辅助函数
|
280 |
+
async function getApiKeys() {
|
281 |
+
const response = await fetch('/v1/api-keys', {
|
282 |
+
method: 'GET',
|
283 |
+
headers: {
|
284 |
+
'Content-Type': 'application/json',
|
285 |
+
'Cache-Control': 'no-cache'
|
286 |
+
}
|
287 |
+
});
|
288 |
+
|
289 |
+
if (!response.ok) {
|
290 |
+
throw new Error(`HTTP错误: ${response.status} ${response.statusText}`);
|
291 |
+
}
|
292 |
+
|
293 |
+
const data = await response.json();
|
294 |
+
return data.success ? data.apiKeys : [];
|
295 |
+
}
|
296 |
+
|
297 |
+
// 复制文本到剪贴板的通用函数
|
298 |
+
async function copyTextToClipboard(text) {
|
299 |
+
try {
|
300 |
+
await navigator.clipboard.writeText(text);
|
301 |
+
return true;
|
302 |
+
} catch (err) {
|
303 |
+
console.error('复制到剪贴板失败:', err);
|
304 |
+
|
305 |
+
// 如果navigator.clipboard不可用,使用备用方法
|
306 |
+
try {
|
307 |
+
const textArea = document.createElement('textarea');
|
308 |
+
textArea.value = text;
|
309 |
+
|
310 |
+
// 将元素设置为看不见
|
311 |
+
textArea.style.position = 'fixed';
|
312 |
+
textArea.style.top = '0';
|
313 |
+
textArea.style.left = '0';
|
314 |
+
textArea.style.width = '2em';
|
315 |
+
textArea.style.height = '2em';
|
316 |
+
textArea.style.padding = '0';
|
317 |
+
textArea.style.border = 'none';
|
318 |
+
textArea.style.outline = 'none';
|
319 |
+
textArea.style.boxShadow = 'none';
|
320 |
+
textArea.style.background = 'transparent';
|
321 |
+
|
322 |
+
document.body.appendChild(textArea);
|
323 |
+
textArea.focus();
|
324 |
+
textArea.select();
|
325 |
+
|
326 |
+
const successful = document.execCommand('copy');
|
327 |
+
document.body.removeChild(textArea);
|
328 |
+
return successful;
|
329 |
+
} catch (fallbackErr) {
|
330 |
+
console.error('备用复制方法失败:', fallbackErr);
|
331 |
+
return false;
|
332 |
+
}
|
333 |
+
}
|
334 |
+
}
|
335 |
+
|
336 |
+
// 显示复制成功弹窗提示
|
337 |
+
function showCopyToast(success) {
|
338 |
+
const toast = document.createElement('div');
|
339 |
+
toast.style.position = 'fixed';
|
340 |
+
toast.style.bottom = '20px';
|
341 |
+
toast.style.left = '50%';
|
342 |
+
toast.style.transform = 'translateX(-50%)';
|
343 |
+
toast.style.padding = '8px 16px';
|
344 |
+
toast.style.borderRadius = '4px';
|
345 |
+
toast.style.zIndex = '9999';
|
346 |
+
toast.style.fontSize = '14px';
|
347 |
+
|
348 |
+
if (success) {
|
349 |
+
toast.style.backgroundColor = '#28a745';
|
350 |
+
toast.style.color = 'white';
|
351 |
+
toast.textContent = '复制成功!';
|
352 |
+
} else {
|
353 |
+
toast.style.backgroundColor = '#dc3545';
|
354 |
+
toast.style.color = 'white';
|
355 |
+
toast.textContent = '复制失败,请手动复制';
|
356 |
+
}
|
357 |
+
|
358 |
+
document.body.appendChild(toast);
|
359 |
+
|
360 |
+
setTimeout(() => {
|
361 |
+
toast.style.opacity = '0';
|
362 |
+
toast.style.transition = 'opacity 0.5s';
|
363 |
+
setTimeout(() => {
|
364 |
+
document.body.removeChild(toast);
|
365 |
+
}, 500);
|
366 |
+
}, 2000);
|
367 |
+
}
|
368 |
+
|
369 |
+
// 处理复制Cookie按钮点击
|
370 |
+
async function handleCopyCookie(cookie) {
|
371 |
+
const success = await copyTextToClipboard(cookie);
|
372 |
+
showCopyToast(success);
|
373 |
+
}
|
374 |
+
|
375 |
+
// Cookie管理相关函数
|
376 |
+
// 渲染Cookie标签
|
377 |
+
function renderCookieTags(cookies) {
|
378 |
+
const container = document.getElementById('cookieTagsContainer');
|
379 |
+
container.innerHTML = '';
|
380 |
+
|
381 |
+
if (cookies.length === 0) {
|
382 |
+
container.innerHTML = '<div style="padding: 10px; color: #666;">暂无Cookie,请添加</div>';
|
383 |
+
return;
|
384 |
+
}
|
385 |
+
|
386 |
+
cookies.forEach((cookie, index) => {
|
387 |
+
// 创建标签
|
388 |
+
const tag = document.createElement('span');
|
389 |
+
tag.className = 'cookie-tag';
|
390 |
+
|
391 |
+
// 对短文本添加特殊类
|
392 |
+
if (cookie.length < 5) {
|
393 |
+
tag.classList.add('short-cookie');
|
394 |
+
}
|
395 |
+
|
396 |
+
// 截断Cookie显示
|
397 |
+
const displayText = cookie.length > 20 ?
|
398 |
+
cookie.substring(0, 8) + '...' + cookie.substring(cookie.length - 8) :
|
399 |
+
cookie;
|
400 |
+
|
401 |
+
tag.title = cookie; // 完整Cookie作为工具提示
|
402 |
+
|
403 |
+
// 增加对移动端友好的结构,添加复制按钮
|
404 |
+
tag.innerHTML = `
|
405 |
+
<span class="cookie-text-content">${displayText}</span>
|
406 |
+
<div class="cookie-buttons">
|
407 |
+
<button type="button" class="copy-btn" data-cookie="${cookie}" aria-label="复制">C</button>
|
408 |
+
<button type="button" class="delete-cookie" data-index="${index}" aria-label="删除">×</button>
|
409 |
+
</div>
|
410 |
+
`;
|
411 |
+
container.appendChild(tag);
|
412 |
+
});
|
413 |
+
|
414 |
+
// 添加删除按钮的事件监听
|
415 |
+
document.querySelectorAll('.delete-cookie').forEach(btn => {
|
416 |
+
btn.addEventListener('click', function() {
|
417 |
+
const index = parseInt(this.getAttribute('data-index'));
|
418 |
+
deleteCookieTag(index);
|
419 |
+
});
|
420 |
+
});
|
421 |
+
|
422 |
+
// 添加复制按钮的事件监听
|
423 |
+
document.querySelectorAll('.copy-btn').forEach(btn => {
|
424 |
+
btn.addEventListener('click', function() {
|
425 |
+
const cookie = this.getAttribute('data-cookie');
|
426 |
+
handleCopyCookie(cookie);
|
427 |
+
});
|
428 |
+
});
|
429 |
+
}
|
430 |
+
|
431 |
+
// 删除Cookie标签
|
432 |
+
function deleteCookieTag(index) {
|
433 |
+
// 从隐藏的textarea中获取当前的cookies
|
434 |
+
const cookieValuesElem = document.getElementById('editCookieValues');
|
435 |
+
let cookies = cookieValuesElem.value.split(',').map(c => c.trim()).filter(c => c);
|
436 |
+
|
437 |
+
// 删除指定索引的cookie
|
438 |
+
cookies.splice(index, 1);
|
439 |
+
|
440 |
+
// 更新隐藏的textarea
|
441 |
+
cookieValuesElem.value = cookies.join(',');
|
442 |
+
|
443 |
+
// 重新渲染标签
|
444 |
+
renderCookieTags(cookies);
|
445 |
+
}
|
446 |
+
|
447 |
+
// 处理添加新Cookie
|
448 |
+
function handleAddCookie() {
|
449 |
+
const newCookieInput = document.getElementById('newCookie');
|
450 |
+
const newCookie = newCookieInput.value.trim();
|
451 |
+
|
452 |
+
if (!newCookie) {
|
453 |
+
return;
|
454 |
+
}
|
455 |
+
|
456 |
+
// 获取当前的cookies
|
457 |
+
const cookieValuesElem = document.getElementById('editCookieValues');
|
458 |
+
let cookies = cookieValuesElem.value ?
|
459 |
+
cookieValuesElem.value.split(',').map(c => c.trim()).filter(c => c) :
|
460 |
+
[];
|
461 |
+
|
462 |
+
// 添加新cookie
|
463 |
+
cookies.push(newCookie);
|
464 |
+
|
465 |
+
// 更新隐藏的textarea
|
466 |
+
cookieValuesElem.value = cookies.join(',');
|
467 |
+
|
468 |
+
// 重新渲染标签
|
469 |
+
renderCookieTags(cookies);
|
470 |
+
|
471 |
+
// 清空输入框
|
472 |
+
newCookieInput.value = '';
|
473 |
+
}
|
474 |
+
|
475 |
+
// 处理编辑表单提交
|
476 |
+
async function handleEditCookieForm(e) {
|
477 |
+
e.preventDefault();
|
478 |
+
|
479 |
+
const apiKey = document.getElementById('editApiKey').value.trim();
|
480 |
+
const cookieValuesText = document.getElementById('editCookieValues').value.trim();
|
481 |
+
|
482 |
+
if (!apiKey) {
|
483 |
+
document.getElementById('editModalMessage').innerHTML = `
|
484 |
+
<div class="error">API Key不能为空</div>
|
485 |
+
`;
|
486 |
+
return;
|
487 |
+
}
|
488 |
+
|
489 |
+
// 将逗号分隔的 Cookie 值转换为数组
|
490 |
+
const cookieValues = cookieValuesText ?
|
491 |
+
cookieValuesText.split(',').map(cookie => cookie.trim()).filter(cookie => cookie) :
|
492 |
+
[];
|
493 |
+
|
494 |
+
try {
|
495 |
+
const response = await fetch('/v1/api-keys', {
|
496 |
+
method: 'POST',
|
497 |
+
headers: {
|
498 |
+
'Content-Type': 'application/json',
|
499 |
+
},
|
500 |
+
body: JSON.stringify({
|
501 |
+
apiKey,
|
502 |
+
cookieValues,
|
503 |
+
}),
|
504 |
+
});
|
505 |
+
|
506 |
+
const data = await response.json();
|
507 |
+
|
508 |
+
if (data.success) {
|
509 |
+
document.getElementById('editModalMessage').innerHTML = `
|
510 |
+
<div class="info">Cookie 修改成功</div>
|
511 |
+
`;
|
512 |
+
setTimeout(() => {
|
513 |
+
document.getElementById('editModal').style.display = 'none';
|
514 |
+
loadApiKeys();
|
515 |
+
}, 1500);
|
516 |
+
} else {
|
517 |
+
document.getElementById('editModalMessage').innerHTML = `
|
518 |
+
<div class="error">Cookie 修改失败: ${data.error}</div>
|
519 |
+
`;
|
520 |
+
}
|
521 |
+
} catch (error) {
|
522 |
+
console.error('修改 Cookie 失败:', error);
|
523 |
+
document.getElementById('editModalMessage').innerHTML = `
|
524 |
+
<div class="error">修改 Cookie 失败: ${error.message}</div>
|
525 |
+
`;
|
526 |
+
}
|
527 |
+
}
|
528 |
+
|
529 |
+
// 渲染添加API Key表单中的Cookie标签
|
530 |
+
function renderAddCookieTags(cookies) {
|
531 |
+
const container = document.getElementById('addCookieTagsContainer');
|
532 |
+
container.innerHTML = '';
|
533 |
+
|
534 |
+
if (cookies.length === 0) {
|
535 |
+
container.innerHTML = '<div style="padding: 10px; color: #666;">暂无Cookie,请添加</div>';
|
536 |
+
return;
|
537 |
+
}
|
538 |
+
|
539 |
+
cookies.forEach((cookie, index) => {
|
540 |
+
const tag = document.createElement('span');
|
541 |
+
tag.className = 'cookie-tag';
|
542 |
+
|
543 |
+
// 对短文本添加特殊类
|
544 |
+
if (cookie.length < 5) {
|
545 |
+
tag.classList.add('short-cookie');
|
546 |
+
}
|
547 |
+
|
548 |
+
const displayText = cookie.length > 20 ?
|
549 |
+
cookie.substring(0, 8) + '...' + cookie.substring(cookie.length - 8) :
|
550 |
+
cookie;
|
551 |
+
|
552 |
+
tag.title = cookie;
|
553 |
+
|
554 |
+
// 增加对移动端友好的结构,添加复制按钮
|
555 |
+
tag.innerHTML = `
|
556 |
+
<span class="cookie-text-content">${displayText}</span>
|
557 |
+
<div class="cookie-buttons">
|
558 |
+
<button type="button" class="copy-btn" data-cookie="${cookie}" aria-label="复制">C</button>
|
559 |
+
<button type="button" class="delete-add-cookie" data-index="${index}" aria-label="删除">×</button>
|
560 |
+
</div>
|
561 |
+
`;
|
562 |
+
container.appendChild(tag);
|
563 |
+
});
|
564 |
+
|
565 |
+
document.querySelectorAll('.delete-add-cookie').forEach(btn => {
|
566 |
+
btn.addEventListener('click', function() {
|
567 |
+
const index = parseInt(this.getAttribute('data-index'));
|
568 |
+
deleteAddCookieTag(index);
|
569 |
+
});
|
570 |
+
});
|
571 |
+
|
572 |
+
// 添加复制按钮的事件监听
|
573 |
+
document.querySelectorAll('.copy-btn').forEach(btn => {
|
574 |
+
btn.addEventListener('click', function() {
|
575 |
+
const cookie = this.getAttribute('data-cookie');
|
576 |
+
handleCopyCookie(cookie);
|
577 |
+
});
|
578 |
+
});
|
579 |
+
}
|
580 |
+
|
581 |
+
// 删除添加表单中的Cookie标签
|
582 |
+
function deleteAddCookieTag(index) {
|
583 |
+
const cookieValuesElem = document.getElementById('cookieValues');
|
584 |
+
let cookies = cookieValuesElem.value ?
|
585 |
+
cookieValuesElem.value.split(',').map(c => c.trim()).filter(c => c) :
|
586 |
+
[];
|
587 |
+
|
588 |
+
cookies.splice(index, 1);
|
589 |
+
cookieValuesElem.value = cookies.join(',');
|
590 |
+
renderAddCookieTags(cookies);
|
591 |
+
}
|
592 |
+
|
593 |
+
// 处理添加新Cookie标签到添加表单
|
594 |
+
function handleAddNewCookie() {
|
595 |
+
const newCookieInput = document.getElementById('addNewCookie');
|
596 |
+
const newCookie = newCookieInput.value.trim();
|
597 |
+
|
598 |
+
if (!newCookie) {
|
599 |
+
return;
|
600 |
+
}
|
601 |
+
|
602 |
+
const cookieValuesElem = document.getElementById('cookieValues');
|
603 |
+
let cookies = cookieValuesElem.value ?
|
604 |
+
cookieValuesElem.value.split(',').map(c => c.trim()).filter(c => c) :
|
605 |
+
[];
|
606 |
+
|
607 |
+
cookies.push(newCookie);
|
608 |
+
cookieValuesElem.value = cookies.join(',');
|
609 |
+
renderAddCookieTags(cookies);
|
610 |
+
newCookieInput.value = '';
|
611 |
+
}
|
612 |
+
|
613 |
+
// 无效Cookie管理相关函数
|
614 |
+
// 获取无效Cookie列表
|
615 |
+
async function getInvalidCookies() {
|
616 |
+
try {
|
617 |
+
const response = await fetch('/v1/invalid-cookies', {
|
618 |
+
method: 'GET',
|
619 |
+
headers: {
|
620 |
+
'Content-Type': 'application/json',
|
621 |
+
'Cache-Control': 'no-cache'
|
622 |
+
}
|
623 |
+
});
|
624 |
+
|
625 |
+
if (!response.ok) {
|
626 |
+
throw new Error(`HTTP错误: ${response.status} ${response.statusText}`);
|
627 |
+
}
|
628 |
+
|
629 |
+
const data = await response.json();
|
630 |
+
return data.invalidCookies;
|
631 |
+
} catch (error) {
|
632 |
+
console.error('获取无效Cookie失败:', error);
|
633 |
+
throw error;
|
634 |
+
}
|
635 |
+
}
|
636 |
+
|
637 |
+
// 清除特定无效Cookie
|
638 |
+
async function clearInvalidCookie(cookie) {
|
639 |
+
try {
|
640 |
+
const response = await fetch(`/v1/invalid-cookies/${encodeURIComponent(cookie)}`, {
|
641 |
+
method: 'DELETE',
|
642 |
+
headers: {
|
643 |
+
'Content-Type': 'application/json',
|
644 |
+
'Cache-Control': 'no-cache'
|
645 |
+
}
|
646 |
+
});
|
647 |
+
|
648 |
+
if (!response.ok) {
|
649 |
+
throw new Error(`HTTP错误: ${response.status} ${response.statusText}`);
|
650 |
+
}
|
651 |
+
|
652 |
+
const data = await response.json();
|
653 |
+
return data.success;
|
654 |
+
} catch (error) {
|
655 |
+
console.error(`清除无效Cookie失败:`, error);
|
656 |
+
throw error;
|
657 |
+
}
|
658 |
+
}
|
659 |
+
|
660 |
+
// 清除所有无效Cookie
|
661 |
+
async function clearAllInvalidCookies() {
|
662 |
+
try {
|
663 |
+
const response = await fetch('/v1/invalid-cookies', {
|
664 |
+
method: 'DELETE',
|
665 |
+
headers: {
|
666 |
+
'Content-Type': 'application/json',
|
667 |
+
'Cache-Control': 'no-cache'
|
668 |
+
}
|
669 |
+
});
|
670 |
+
|
671 |
+
if (!response.ok) {
|
672 |
+
throw new Error(`HTTP错误: ${response.status} ${response.statusText}`);
|
673 |
+
}
|
674 |
+
|
675 |
+
const data = await response.json();
|
676 |
+
return data.success;
|
677 |
+
} catch (error) {
|
678 |
+
console.error('清除所有无效Cookie失败:', error);
|
679 |
+
throw error;
|
680 |
+
}
|
681 |
+
}
|
682 |
+
|
683 |
+
// 渲染无效Cookie列表
|
684 |
+
async function renderInvalidCookies() {
|
685 |
+
const container = document.getElementById('invalidCookiesContainer');
|
686 |
+
|
687 |
+
try {
|
688 |
+
const invalidCookies = await getInvalidCookies();
|
689 |
+
|
690 |
+
if (invalidCookies.length === 0) {
|
691 |
+
container.innerHTML = '<div class="info">没有检测到无效Cookie</div>';
|
692 |
+
return;
|
693 |
+
}
|
694 |
+
|
695 |
+
let html = '<div class="table-responsive"><table><thead><tr><th>无效Cookie</th><th>数量</th><th>操作</th></tr></thead><tbody>';
|
696 |
+
|
697 |
+
// 展示为一行,类似于API Key列表
|
698 |
+
html += `
|
699 |
+
<tr>
|
700 |
+
<td data-title="无效Cookie">无效Cookie</td>
|
701 |
+
<td data-title="数量">${invalidCookies.length}</td>
|
702 |
+
<td data-title="操作">
|
703 |
+
<button class="edit-btn" id="editInvalidCookiesBtn">修改</button>
|
704 |
+
<button class="action-btn" id="clearAllInvalidCookiesInTable">删除</button>
|
705 |
+
</td>
|
706 |
+
</tr>
|
707 |
+
`;
|
708 |
+
|
709 |
+
html += '</tbody></table></div>';
|
710 |
+
container.innerHTML = html;
|
711 |
+
|
712 |
+
// 添加按钮事件监听
|
713 |
+
document.getElementById('editInvalidCookiesBtn').addEventListener('click', openInvalidCookieModal);
|
714 |
+
document.getElementById('clearAllInvalidCookiesInTable').addEventListener('click', handleClearAllInvalidCookies);
|
715 |
+
|
716 |
+
} catch (error) {
|
717 |
+
container.innerHTML = `<div class="error">加载失败: ${error.message}</div>`;
|
718 |
+
}
|
719 |
+
}
|
720 |
+
|
721 |
+
// 处理清除所有无效Cookie按钮事件
|
722 |
+
async function handleClearAllInvalidCookies() {
|
723 |
+
try {
|
724 |
+
await clearAllInvalidCookies();
|
725 |
+
showMessage('invalidCookiesContainer', '所有无效Cookie已清除', 'info');
|
726 |
+
renderInvalidCookies(); // 重新渲染列表
|
727 |
+
} catch (error) {
|
728 |
+
showMessage('invalidCookiesContainer', `清除失败: ${error.message}`, 'error');
|
729 |
+
}
|
730 |
+
}
|
731 |
+
|
732 |
+
// API 测试相关函数
|
733 |
+
// 测试API连接
|
734 |
+
async function testApiConnection() {
|
735 |
+
const resultDiv = document.getElementById('testApiResult');
|
736 |
+
resultDiv.innerHTML = '<div class="info">正在测试API连接...</div>';
|
737 |
+
|
738 |
+
try {
|
739 |
+
const response = await fetch('/v1/api-keys', {
|
740 |
+
method: 'GET',
|
741 |
+
headers: {
|
742 |
+
'Content-Type': 'application/json',
|
743 |
+
'Cache-Control': 'no-cache'
|
744 |
+
}
|
745 |
+
});
|
746 |
+
|
747 |
+
resultDiv.innerHTML = `<div class="info">API响应状态: ${response.status}</div>`;
|
748 |
+
|
749 |
+
if (!response.ok) {
|
750 |
+
throw new Error(`HTTP错误: ${response.status} ${response.statusText}`);
|
751 |
+
}
|
752 |
+
|
753 |
+
const data = await response.json();
|
754 |
+
resultDiv.innerHTML += `<div class="info">获取到的数据: ${JSON.stringify(data)}</div>`;
|
755 |
+
} catch (error) {
|
756 |
+
console.error('测试API失败:', error);
|
757 |
+
resultDiv.innerHTML = `<div class="error">测试API失败: ${error.message}</div>`;
|
758 |
+
}
|
759 |
+
}
|
760 |
+
|
761 |
+
// 清除缓存并刷新
|
762 |
+
function clearCacheAndRefresh() {
|
763 |
+
// 清除缓存
|
764 |
+
if ('caches' in window) {
|
765 |
+
caches.keys().then(function(names) {
|
766 |
+
for (let name of names) {
|
767 |
+
caches.delete(name);
|
768 |
+
}
|
769 |
+
});
|
770 |
+
}
|
771 |
+
|
772 |
+
// 强制刷新页面(绕过缓存)
|
773 |
+
window.location.reload(true);
|
774 |
+
}
|
775 |
+
|
776 |
+
// 显示消息的通用函数
|
777 |
+
function showMessage(containerId, message, type) {
|
778 |
+
const container = document.getElementById(containerId);
|
779 |
+
container.innerHTML = `<div class="${type}">${message}</div>`;
|
780 |
+
}
|
781 |
+
|
782 |
+
// Cookie刷新相关函数
|
783 |
+
// 填充刷新API Key的下拉选择框
|
784 |
+
async function populateRefreshApiKeySelect() {
|
785 |
+
try {
|
786 |
+
const apiKeys = await getApiKeys();
|
787 |
+
const select = document.getElementById('refreshApiKey');
|
788 |
+
|
789 |
+
// 清空现有选项(保留"所有API Key"选项)
|
790 |
+
while (select.options.length > 1) {
|
791 |
+
select.remove(1);
|
792 |
+
}
|
793 |
+
|
794 |
+
// 添加API Key选项
|
795 |
+
apiKeys.forEach(key => {
|
796 |
+
const option = document.createElement('option');
|
797 |
+
option.value = key.key;
|
798 |
+
option.textContent = `${key.key} (${key.cookieCount} 个Cookie)`;
|
799 |
+
select.appendChild(option);
|
800 |
+
});
|
801 |
+
} catch (error) {
|
802 |
+
console.error('加载API Key选项失败:', error);
|
803 |
+
}
|
804 |
+
}
|
805 |
+
|
806 |
+
// 处理刷新Cookie按钮事件
|
807 |
+
async function handleRefreshCookie() {
|
808 |
+
console.log('刷新Cookie按钮被点击');
|
809 |
+
const refreshBtn = document.getElementById('refreshCookieBtn');
|
810 |
+
const apiKey = document.getElementById('refreshApiKey').value;
|
811 |
+
const statusContainer = document.getElementById('refreshStatusContainer');
|
812 |
+
const statusText = document.getElementById('refreshStatus');
|
813 |
+
const progressBar = document.getElementById('refreshProgress');
|
814 |
+
|
815 |
+
// 显示调试信息
|
816 |
+
showMessage('refreshCookieMessage', '正在准备发送请求...', 'info');
|
817 |
+
|
818 |
+
// 禁用按钮,显示状态容器
|
819 |
+
refreshBtn.disabled = true;
|
820 |
+
statusContainer.style.display = 'block';
|
821 |
+
statusText.textContent = '正在发送刷新请求...';
|
822 |
+
progressBar.value = 10;
|
823 |
+
|
824 |
+
try {
|
825 |
+
// 构建请求URL
|
826 |
+
let url = '/v1/refresh-cookies';
|
827 |
+
if (apiKey) {
|
828 |
+
url += `?apiKey=${encodeURIComponent(apiKey)}`;
|
829 |
+
}
|
830 |
+
|
831 |
+
// 发送刷新请求
|
832 |
+
statusText.textContent = '正在发送刷新请求...';
|
833 |
+
progressBar.value = 20;
|
834 |
+
|
835 |
+
const response = await fetch(url, {
|
836 |
+
method: 'POST',
|
837 |
+
headers: {
|
838 |
+
'Content-Type': 'application/json',
|
839 |
+
'Cache-Control': 'no-cache'
|
840 |
+
}
|
841 |
+
});
|
842 |
+
|
843 |
+
if (!response.ok) {
|
844 |
+
throw new Error(`HTTP错误: ${response.status} ${response.statusText}`);
|
845 |
+
}
|
846 |
+
|
847 |
+
// 显示长时间等待提示
|
848 |
+
statusText.textContent = '刷新请求已发送,请耐心等待2-12分钟...';
|
849 |
+
progressBar.value = 50;
|
850 |
+
showMessage('refreshCookieMessage', '刷新请求已发送,由于需要访问Cursor官网获取新Cookie,整个过程可能需要2-12分钟,请耐心等待。您可以关闭此页面,稍后再来查看结果。', 'info');
|
851 |
+
|
852 |
+
// 启动定时检查刷新状态
|
853 |
+
let checkInterval = setInterval(async () => {
|
854 |
+
try {
|
855 |
+
const statusResponse = await fetch('/v1/refresh-status', {
|
856 |
+
method: 'GET',
|
857 |
+
headers: {
|
858 |
+
'Cache-Control': 'no-cache'
|
859 |
+
}
|
860 |
+
});
|
861 |
+
|
862 |
+
if (!statusResponse.ok) {
|
863 |
+
throw new Error(`HTTP错误: ${statusResponse.status} ${statusResponse.statusText}`);
|
864 |
+
}
|
865 |
+
|
866 |
+
const statusData = await statusResponse.json();
|
867 |
+
const refreshData = statusData.data;
|
868 |
+
|
869 |
+
// 更新状态信息
|
870 |
+
statusText.textContent = refreshData.message || '正在刷新...';
|
871 |
+
|
872 |
+
// 根据状态更新进度条和UI
|
873 |
+
if (refreshData.status === 'completed') {
|
874 |
+
// 刷新完成
|
875 |
+
progressBar.value = 100;
|
876 |
+
statusText.textContent = `刷新完成: ${refreshData.message}`;
|
877 |
+
clearInterval(checkInterval);
|
878 |
+
|
879 |
+
// 重新加载API Key列表
|
880 |
+
await loadApiKeys();
|
881 |
+
await populateRefreshApiKeySelect();
|
882 |
+
|
883 |
+
// 显示成功消息
|
884 |
+
showMessage('refreshCookieMessage', `刷新完成: ${refreshData.message}`, 'success');
|
885 |
+
|
886 |
+
// 启用按钮
|
887 |
+
refreshBtn.disabled = false;
|
888 |
+
|
889 |
+
// 3秒后隐藏状态容器
|
890 |
+
setTimeout(() => {
|
891 |
+
statusContainer.style.display = 'none';
|
892 |
+
}, 3000);
|
893 |
+
} else if (refreshData.status === 'failed') {
|
894 |
+
// 刷新失败
|
895 |
+
progressBar.value = 0;
|
896 |
+
statusText.textContent = `刷新失败: ${refreshData.message}`;
|
897 |
+
clearInterval(checkInterval);
|
898 |
+
|
899 |
+
// 显示错误消息
|
900 |
+
showMessage('refreshCookieMessage', `刷新失败: ${refreshData.message}`, 'error');
|
901 |
+
|
902 |
+
// 启用按钮
|
903 |
+
refreshBtn.disabled = false;
|
904 |
+
} else if (refreshData.status === 'running') {
|
905 |
+
// 正在刷新
|
906 |
+
progressBar.value = 75;
|
907 |
+
} else if (!refreshData.isRunning) {
|
908 |
+
// 未知状态但不在运行
|
909 |
+
clearInterval(checkInterval);
|
910 |
+
refreshBtn.disabled = false;
|
911 |
+
}
|
912 |
+
} catch (error) {
|
913 |
+
console.error('检查刷新状态失败:', error);
|
914 |
+
}
|
915 |
+
}, 5000); // 每5秒检查一次
|
916 |
+
|
917 |
+
// 设置超时检查,12分钟后如果还没完成就停止检查
|
918 |
+
setTimeout(() => {
|
919 |
+
if (checkInterval) {
|
920 |
+
clearInterval(checkInterval);
|
921 |
+
refreshBtn.disabled = false;
|
922 |
+
statusContainer.style.display = 'none';
|
923 |
+
}
|
924 |
+
}, 720000);
|
925 |
+
} catch (error) {
|
926 |
+
console.error('刷新Cookie失败:', error);
|
927 |
+
statusText.textContent = '刷新请求发送失败';
|
928 |
+
progressBar.value = 0;
|
929 |
+
showMessage('refreshCookieMessage', `刷新请求发送失败: ${error.message}`, 'error');
|
930 |
+
refreshBtn.disabled = false;
|
931 |
+
}
|
932 |
+
}
|
933 |
+
|
934 |
+
// 获取Cookie相关函数
|
935 |
+
// 为Cookie获取功能填充API Key下拉框
|
936 |
+
function populateCookieApiKeySelect() {
|
937 |
+
populateRefreshApiKeySelect().then(() => {
|
938 |
+
// 复制refreshApiKey的选项到targetApiKey
|
939 |
+
const sourceSelect = document.getElementById('refreshApiKey');
|
940 |
+
const targetSelect = document.getElementById('targetApiKey');
|
941 |
+
|
942 |
+
// 保留第一个选项("所有API Key")
|
943 |
+
while (targetSelect.options.length > 1) {
|
944 |
+
targetSelect.remove(1);
|
945 |
+
}
|
946 |
+
|
947 |
+
// 复制选项
|
948 |
+
for (let i = 1; i < sourceSelect.options.length; i++) {
|
949 |
+
const option = document.createElement('option');
|
950 |
+
option.value = sourceSelect.options[i].value;
|
951 |
+
option.textContent = sourceSelect.options[i].textContent;
|
952 |
+
targetSelect.appendChild(option);
|
953 |
+
}
|
954 |
+
});
|
955 |
+
}
|
956 |
+
|
957 |
+
// 处理生成登录链接
|
958 |
+
async function handleGenerateLink() {
|
959 |
+
console.log('生成登录链接按钮被点击');
|
960 |
+
const messageContainer = document.getElementById('getCookieMessage');
|
961 |
+
const linkContainer = document.getElementById('loginLinkContainer');
|
962 |
+
const loginLink = document.getElementById('loginLink');
|
963 |
+
const pollStatusText = document.getElementById('pollStatusText');
|
964 |
+
const pollProgress = document.getElementById('pollProgress');
|
965 |
+
const targetApiKey = document.getElementById('targetApiKey').value;
|
966 |
+
|
967 |
+
try {
|
968 |
+
// 显示加载状态
|
969 |
+
messageContainer.innerHTML = '<div class="info">正在生成登录链接...</div>';
|
970 |
+
|
971 |
+
// 请求生成登录链接
|
972 |
+
const response = await fetch('/v1/generate-cookie-link', {
|
973 |
+
method: 'POST',
|
974 |
+
headers: {
|
975 |
+
'Content-Type': 'application/json',
|
976 |
+
'Cache-Control': 'no-cache'
|
977 |
+
},
|
978 |
+
body: JSON.stringify({ apiKey: targetApiKey })
|
979 |
+
});
|
980 |
+
|
981 |
+
if (!response.ok) {
|
982 |
+
throw new Error(`HTTP错误: ${response.status} ${response.statusText}`);
|
983 |
+
}
|
984 |
+
|
985 |
+
const data = await response.json();
|
986 |
+
|
987 |
+
if (!data.success) {
|
988 |
+
throw new Error(data.message || '生成链接失败');
|
989 |
+
}
|
990 |
+
|
991 |
+
// 显示链接
|
992 |
+
loginLink.href = data.url;
|
993 |
+
loginLink.textContent = data.url;
|
994 |
+
linkContainer.style.display = 'block';
|
995 |
+
|
996 |
+
// 更新状态
|
997 |
+
pollStatusText.textContent = '等待用户登录...';
|
998 |
+
pollProgress.value = 10;
|
999 |
+
|
1000 |
+
// 开始轮询获取cookie状态
|
1001 |
+
messageContainer.innerHTML = '<div class="info">链接已生成,请点击链接登录Cursor账号并授权</div>';
|
1002 |
+
|
1003 |
+
// 开始轮询cookie状态
|
1004 |
+
pollForCookieStatus(data.uuid);
|
1005 |
+
|
1006 |
+
} catch (error) {
|
1007 |
+
console.error('生成登录链接失败:', error);
|
1008 |
+
messageContainer.innerHTML = `<div class="error">生成链接失败: ${error.message}</div>`;
|
1009 |
+
}
|
1010 |
+
}
|
1011 |
+
|
1012 |
+
// 轮询Cookie获取状态
|
1013 |
+
function pollForCookieStatus(uuid) {
|
1014 |
+
const messageContainer = document.getElementById('getCookieMessage');
|
1015 |
+
const pollStatusText = document.getElementById('pollStatusText');
|
1016 |
+
const pollProgress = document.getElementById('pollProgress');
|
1017 |
+
const maxAttempts = 300; // 最多尝试300次,相当于5分钟(原来是120次,2分钟)
|
1018 |
+
let attempt = 0;
|
1019 |
+
|
1020 |
+
// 更新状态显示
|
1021 |
+
pollStatusText.textContent = '等待用户登录...';
|
1022 |
+
|
1023 |
+
const interval = setInterval(function() {
|
1024 |
+
attempt++;
|
1025 |
+
|
1026 |
+
try {
|
1027 |
+
// 更新进度条(保持在10%-90%之间,表示等待中)
|
1028 |
+
pollProgress.value = 10 + Math.min(80, attempt / 3.75); // 调整进度条速度以适应5分钟
|
1029 |
+
|
1030 |
+
// 请求检查状态
|
1031 |
+
fetch(`/v1/check-cookie-status?uuid=${encodeURIComponent(uuid)}`, {
|
1032 |
+
method: 'GET',
|
1033 |
+
headers: {
|
1034 |
+
'Cache-Control': 'no-cache'
|
1035 |
+
}
|
1036 |
+
}).then(function(response) {
|
1037 |
+
if (!response.ok) {
|
1038 |
+
pollStatusText.textContent = `请求失败: ${response.status}`;
|
1039 |
+
return;
|
1040 |
+
}
|
1041 |
+
|
1042 |
+
return response.json();
|
1043 |
+
}).then(function(data) {
|
1044 |
+
if (data.success) {
|
1045 |
+
// Cookie获取成功
|
1046 |
+
clearInterval(interval);
|
1047 |
+
pollProgress.value = 100;
|
1048 |
+
pollStatusText.textContent = '获取Cookie成功!';
|
1049 |
+
messageContainer.innerHTML = `<div class="info">成功获取并添加Cookie!${data.message || ''}</div>`;
|
1050 |
+
|
1051 |
+
// 刷新API Keys列表
|
1052 |
+
loadApiKeys();
|
1053 |
+
populateCookieApiKeySelect();
|
1054 |
+
|
1055 |
+
} else if (data.status === 'waiting') {
|
1056 |
+
// 继续等待
|
1057 |
+
pollStatusText.textContent = '等待用户登录...';
|
1058 |
+
} else if (data.status === 'failed') {
|
1059 |
+
// 获取失败
|
1060 |
+
clearInterval(interval);
|
1061 |
+
pollStatusText.textContent = '获取失败';
|
1062 |
+
pollProgress.value = 0;
|
1063 |
+
messageContainer.innerHTML = `<div class="error">获取Cookie失败: ${data.message || '未知错误'}</div>`;
|
1064 |
+
}
|
1065 |
+
}).catch(function(error) {
|
1066 |
+
console.error('轮询Cookie状态失败:', error);
|
1067 |
+
pollStatusText.textContent = `轮询出错: ${error.message}`;
|
1068 |
+
});
|
1069 |
+
|
1070 |
+
} catch (error) {
|
1071 |
+
console.error('轮询Cookie状态出错:', error);
|
1072 |
+
pollStatusText.textContent = `轮询出错: ${error.message}`;
|
1073 |
+
}
|
1074 |
+
|
1075 |
+
// 达到最大尝试次数后停止
|
1076 |
+
if (attempt >= maxAttempts) {
|
1077 |
+
clearInterval(interval);
|
1078 |
+
pollStatusText.textContent = '超时,请重试';
|
1079 |
+
pollProgress.value = 0;
|
1080 |
+
messageContainer.innerHTML = '<div class="error">获取Cookie超时,请重新尝试</div>';
|
1081 |
+
}
|
1082 |
+
|
1083 |
+
}, 1000); // 每秒轮询一次
|
1084 |
+
}
|
1085 |
+
|
1086 |
+
// 授权相关函数
|
1087 |
+
// 检查登录状态
|
1088 |
+
function checkAuth() {
|
1089 |
+
const token = localStorage.getItem('adminToken');
|
1090 |
+
if (!token) {
|
1091 |
+
window.location.href = '/login.html';
|
1092 |
+
return;
|
1093 |
+
}
|
1094 |
+
|
1095 |
+
// 验证token
|
1096 |
+
fetch('/v1/admin/verify', {
|
1097 |
+
headers: {
|
1098 |
+
'Authorization': `Bearer ${token}`
|
1099 |
+
}
|
1100 |
+
})
|
1101 |
+
.then(response => response.json())
|
1102 |
+
.then(data => {
|
1103 |
+
if (!data.success) {
|
1104 |
+
localStorage.removeItem('adminToken');
|
1105 |
+
window.location.href = '/login.html';
|
1106 |
+
} else {
|
1107 |
+
// 更新为新的用户名显示方式
|
1108 |
+
const usernameElem = document.getElementById('usernameText');
|
1109 |
+
if (usernameElem) {
|
1110 |
+
usernameElem.textContent = data.username;
|
1111 |
+
} else {
|
1112 |
+
// 兼容旧版模板,可能没有usernameText元素
|
1113 |
+
const adminElem = document.getElementById('adminUsername');
|
1114 |
+
if (adminElem) {
|
1115 |
+
adminElem.textContent = `管理员:${data.username}`;
|
1116 |
+
}
|
1117 |
+
}
|
1118 |
+
}
|
1119 |
+
})
|
1120 |
+
.catch(error => {
|
1121 |
+
console.error('验证失败:', error);
|
1122 |
+
localStorage.removeItem('adminToken');
|
1123 |
+
window.location.href = '/login.html';
|
1124 |
+
});
|
1125 |
+
}
|
1126 |
+
|
1127 |
+
// 处理退出登录
|
1128 |
+
function handleLogout() {
|
1129 |
+
localStorage.removeItem('adminToken');
|
1130 |
+
window.location.href = '/login.html';
|
1131 |
+
}
|
1132 |
+
|
1133 |
+
// 添加token到所有API请求
|
1134 |
+
function addAuthHeader(headers = {}) {
|
1135 |
+
const token = localStorage.getItem('adminToken');
|
1136 |
+
return {
|
1137 |
+
...headers,
|
1138 |
+
'Authorization': `Bearer ${token}`
|
1139 |
+
};
|
1140 |
+
}
|
1141 |
+
|
1142 |
+
// 修改所有fetch请求,添加token
|
1143 |
+
(function() {
|
1144 |
+
const originalFetch = window.fetch;
|
1145 |
+
window.fetch = function(url, options = {}) {
|
1146 |
+
// 只对管理页面的API请求添加token
|
1147 |
+
if (url.includes('/v1/api-keys') ||
|
1148 |
+
url.includes('/v1/invalid-cookies') ||
|
1149 |
+
url.includes('/v1/refresh-cookies') ||
|
1150 |
+
url.includes('/v1/generate-cookie-link') ||
|
1151 |
+
url.includes('/v1/check-cookie-status') ||
|
1152 |
+
url.includes('/v1/logs')) {
|
1153 |
+
options.headers = addAuthHeader(options.headers);
|
1154 |
+
}
|
1155 |
+
return originalFetch(url, options);
|
1156 |
+
};
|
1157 |
+
})();
|
1158 |
+
|
1159 |
+
// 无效Cookie模态窗口相关函数
|
1160 |
+
// 打开无效Cookie模态窗口
|
1161 |
+
async function openInvalidCookieModal() {
|
1162 |
+
try {
|
1163 |
+
document.getElementById('invalidCookieModalMessage').innerHTML = '';
|
1164 |
+
const invalidCookies = await getInvalidCookies();
|
1165 |
+
renderInvalidCookieTags(invalidCookies);
|
1166 |
+
document.getElementById('invalidCookiesValues').value = invalidCookies.join(',');
|
1167 |
+
document.getElementById('newInvalidCookie').value = '';
|
1168 |
+
const modal = document.getElementById('invalidCookieModal');
|
1169 |
+
modal.style.display = 'block';
|
1170 |
+
document.body.classList.add('modal-open');
|
1171 |
+
} catch (error) {
|
1172 |
+
console.error('打开无效Cookie模态框失败:', error);
|
1173 |
+
showMessage('invalidCookiesContainer', `加载无效Cookie失败: ${error.message}`, 'error');
|
1174 |
+
}
|
1175 |
+
}
|
1176 |
+
|
1177 |
+
// 关闭无效Cookie模态框
|
1178 |
+
function closeInvalidCookieModal() {
|
1179 |
+
const modal = document.getElementById('invalidCookieModal');
|
1180 |
+
modal.style.display = 'none';
|
1181 |
+
document.body.classList.remove('modal-open');
|
1182 |
+
}
|
1183 |
+
|
1184 |
+
// 渲染无效Cookie标签
|
1185 |
+
function renderInvalidCookieTags(cookies) {
|
1186 |
+
const container = document.getElementById('invalidCookieTagsContainer');
|
1187 |
+
container.innerHTML = '';
|
1188 |
+
|
1189 |
+
if (cookies.length === 0) {
|
1190 |
+
container.innerHTML = '<div style="padding: 10px; color: #666;">暂无无效Cookie</div>';
|
1191 |
+
return;
|
1192 |
+
}
|
1193 |
+
|
1194 |
+
cookies.forEach((cookie, index) => {
|
1195 |
+
// 创建标签
|
1196 |
+
const tag = document.createElement('span');
|
1197 |
+
tag.className = 'cookie-tag';
|
1198 |
+
|
1199 |
+
// 对短文本添加特殊类
|
1200 |
+
if (cookie.length < 5) {
|
1201 |
+
tag.classList.add('short-cookie');
|
1202 |
+
}
|
1203 |
+
|
1204 |
+
// 截断Cookie显示
|
1205 |
+
const displayText = cookie.length > 20 ?
|
1206 |
+
cookie.substring(0, 8) + '...' + cookie.substring(cookie.length - 8) :
|
1207 |
+
cookie;
|
1208 |
+
|
1209 |
+
tag.title = cookie; // 完整Cookie作为工具提示
|
1210 |
+
|
1211 |
+
// 修改样式,使用与API Key相同的删除按钮样式
|
1212 |
+
tag.innerHTML = `
|
1213 |
+
<span class="cookie-text-content">${displayText}</span>
|
1214 |
+
<div class="cookie-buttons">
|
1215 |
+
<button type="button" class="copy-btn" data-cookie="${cookie}" aria-label="复制">C</button>
|
1216 |
+
<button type="button" class="delete-cookie" data-index="${index}" aria-label="删除">×</button>
|
1217 |
+
</div>
|
1218 |
+
`;
|
1219 |
+
container.appendChild(tag);
|
1220 |
+
});
|
1221 |
+
|
1222 |
+
// 添加删除按钮的事件监听
|
1223 |
+
document.querySelectorAll('#invalidCookieTagsContainer .delete-cookie').forEach(btn => {
|
1224 |
+
btn.addEventListener('click', function() {
|
1225 |
+
const index = parseInt(this.getAttribute('data-index'));
|
1226 |
+
deleteInvalidCookieTag(index);
|
1227 |
+
});
|
1228 |
+
});
|
1229 |
+
|
1230 |
+
// 添加复制按钮的事件监听
|
1231 |
+
document.querySelectorAll('#invalidCookieTagsContainer .copy-btn').forEach(btn => {
|
1232 |
+
btn.addEventListener('click', function() {
|
1233 |
+
const cookie = this.getAttribute('data-cookie');
|
1234 |
+
handleCopyCookie(cookie);
|
1235 |
+
});
|
1236 |
+
});
|
1237 |
+
}
|
1238 |
+
|
1239 |
+
// 删除无效Cookie标签
|
1240 |
+
function deleteInvalidCookieTag(index) {
|
1241 |
+
// 从隐藏的textarea中获取当前的cookies
|
1242 |
+
const cookieValuesElem = document.getElementById('invalidCookiesValues');
|
1243 |
+
let cookies = cookieValuesElem.value.split(',').map(c => c.trim()).filter(c => c);
|
1244 |
+
|
1245 |
+
// 删除指定索引的cookie
|
1246 |
+
cookies.splice(index, 1);
|
1247 |
+
|
1248 |
+
// 更新隐藏的textarea
|
1249 |
+
cookieValuesElem.value = cookies.join(',');
|
1250 |
+
|
1251 |
+
// 重新渲染标签
|
1252 |
+
renderInvalidCookieTags(cookies);
|
1253 |
+
}
|
1254 |
+
|
1255 |
+
// 处理添加新无效Cookie
|
1256 |
+
function handleAddInvalidCookie() {
|
1257 |
+
const newCookieInput = document.getElementById('newInvalidCookie');
|
1258 |
+
const newCookie = newCookieInput.value.trim();
|
1259 |
+
|
1260 |
+
if (!newCookie) {
|
1261 |
+
return;
|
1262 |
+
}
|
1263 |
+
|
1264 |
+
// 获取当前的cookies
|
1265 |
+
const cookieValuesElem = document.getElementById('invalidCookiesValues');
|
1266 |
+
let cookies = cookieValuesElem.value ?
|
1267 |
+
cookieValuesElem.value.split(',').map(c => c.trim()).filter(c => c) :
|
1268 |
+
[];
|
1269 |
+
|
1270 |
+
// 添加新cookie
|
1271 |
+
cookies.push(newCookie);
|
1272 |
+
|
1273 |
+
// 更新隐藏的textarea
|
1274 |
+
cookieValuesElem.value = cookies.join(',');
|
1275 |
+
|
1276 |
+
// 重新渲染标签
|
1277 |
+
renderInvalidCookieTags(cookies);
|
1278 |
+
|
1279 |
+
// 清空输入框
|
1280 |
+
newCookieInput.value = '';
|
1281 |
+
}
|
1282 |
+
|
1283 |
+
// 处理无效Cookie编辑表单提交
|
1284 |
+
async function handleInvalidCookieForm(e) {
|
1285 |
+
e.preventDefault();
|
1286 |
+
|
1287 |
+
const cookieValuesText = document.getElementById('invalidCookiesValues').value.trim();
|
1288 |
+
|
1289 |
+
// 将逗号分隔的 Cookie 值转换为数组
|
1290 |
+
const invalidCookies = cookieValuesText ?
|
1291 |
+
cookieValuesText.split(',').map(cookie => cookie.trim()).filter(cookie => cookie) :
|
1292 |
+
[];
|
1293 |
+
|
1294 |
+
try {
|
1295 |
+
// 先清除所有无效Cookie
|
1296 |
+
await clearAllInvalidCookies();
|
1297 |
+
|
1298 |
+
// 如果有新的无效Cookie,逐个添加
|
1299 |
+
if (invalidCookies.length > 0) {
|
1300 |
+
// 假设API提供了批量添加无效Cookie的接口
|
1301 |
+
const response = await fetch('/v1/invalid-cookies', {
|
1302 |
+
method: 'POST',
|
1303 |
+
headers: {
|
1304 |
+
'Content-Type': 'application/json',
|
1305 |
+
},
|
1306 |
+
body: JSON.stringify({
|
1307 |
+
invalidCookies,
|
1308 |
+
}),
|
1309 |
+
});
|
1310 |
+
|
1311 |
+
const data = await response.json();
|
1312 |
+
|
1313 |
+
if (data.success) {
|
1314 |
+
document.getElementById('invalidCookieModalMessage').innerHTML = `
|
1315 |
+
<div class="info">无效Cookie修改成功</div>
|
1316 |
+
`;
|
1317 |
+
setTimeout(() => {
|
1318 |
+
closeInvalidCookieModal();
|
1319 |
+
renderInvalidCookies(); // 重新渲染列表
|
1320 |
+
}, 1500);
|
1321 |
+
} else {
|
1322 |
+
document.getElementById('invalidCookieModalMessage').innerHTML = `
|
1323 |
+
<div class="error">无效Cookie修改失败: ${data.error}</div>
|
1324 |
+
`;
|
1325 |
+
}
|
1326 |
+
} else {
|
1327 |
+
// 如果清空了所有无效Cookie
|
1328 |
+
document.getElementById('invalidCookieModalMessage').innerHTML = `
|
1329 |
+
<div class="info">已清空所有无效Cookie</div>
|
1330 |
+
`;
|
1331 |
+
setTimeout(() => {
|
1332 |
+
closeInvalidCookieModal();
|
1333 |
+
renderInvalidCookies(); // 重新渲染列表
|
1334 |
+
}, 1500);
|
1335 |
+
}
|
1336 |
+
} catch (error) {
|
1337 |
+
console.error('修改无效Cookie失败:', error);
|
1338 |
+
document.getElementById('invalidCookieModalMessage').innerHTML = `
|
1339 |
+
<div class="error">修改无效Cookie失败: ${error.message}</div>
|
1340 |
+
`;
|
1341 |
+
}
|
1342 |
+
}
|
src/routes/index.js
CHANGED
@@ -1 +1,8 @@
|
|
1 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const express = require('express');
|
2 |
+
const router = express.Router();
|
3 |
+
const v1Routes = require('./v1');
|
4 |
+
|
5 |
+
// OpenAI v1 API routes
|
6 |
+
router.use('/v1', v1Routes);
|
7 |
+
|
8 |
+
module.exports = router;
|
src/routes/v1.js
CHANGED
The diff for this file is too large to render.
See raw diff
|
|
src/utils/cookieRefresher.js
CHANGED
@@ -1 +1,818 @@
|
|
1 |
-
function a0_0x43b5(_0x3ad996,_0x714fe7){const _0x510094=a0_0x5067();return a0_0x43b5=function(_0x2de226,_0x28c73f){_0x2de226=_0x2de226-0x144;let _0x506746=_0x510094[_0x2de226];if(a0_0x43b5['wTkfXZ']===undefined){var _0x43b52d=function(_0x4eec2f){const _0x16ae5b='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x138351='',_0x568619='',_0x445b78=_0x138351+_0x43b52d;for(let _0x1f7427=0x0,_0x55fe73,_0xdadbcd,_0x122802=0x0;_0xdadbcd=_0x4eec2f['charAt'](_0x122802++);~_0xdadbcd&&(_0x55fe73=_0x1f7427%0x4?_0x55fe73*0x40+_0xdadbcd:_0xdadbcd,_0x1f7427++%0x4)?_0x138351+=_0x445b78['charCodeAt'](_0x122802+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x55fe73>>(-0x2*_0x1f7427&0x6)):_0x1f7427:0x0){_0xdadbcd=_0x16ae5b['indexOf'](_0xdadbcd);}for(let _0x5225aa=0x0,_0x1a4af2=_0x138351['length'];_0x5225aa<_0x1a4af2;_0x5225aa++){_0x568619+='%'+('00'+_0x138351['charCodeAt'](_0x5225aa)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x568619);};a0_0x43b5['JnNnTc']=_0x43b52d,_0x3ad996=arguments,a0_0x43b5['wTkfXZ']=!![];}const _0x437ec4=_0x510094[0x0],_0x4c7ec5=_0x2de226+_0x437ec4,_0x42e3d3=_0x3ad996[_0x4c7ec5];if(!_0x42e3d3){const _0x533f47=function(_0x377224){this['Uxmicn']=_0x377224,this['NrNRdS']=[0x1,0x0,0x0],this['sSVazF']=function(){return'newState';},this['Payrgk']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['oZfJQU']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x533f47['prototype']['KJaRSf']=function(){const _0x171117=new RegExp(this['Payrgk']+this['oZfJQU']),_0x1841c3=_0x171117['test'](this['sSVazF']['toString']())?--this['NrNRdS'][0x1]:--this['NrNRdS'][0x0];return this['HmPCOO'](_0x1841c3);},_0x533f47['prototype']['HmPCOO']=function(_0x125163){if(!Boolean(~_0x125163))return _0x125163;return this['hapBbE'](this['Uxmicn']);},_0x533f47['prototype']['hapBbE']=function(_0x1e6e7a){for(let _0xe0c3a7=0x0,_0x582766=this['NrNRdS']['length'];_0xe0c3a7<_0x582766;_0xe0c3a7++){this['NrNRdS']['push'](Math['round'](Math['random']())),_0x582766=this['NrNRdS']['length'];}return _0x1e6e7a(this['NrNRdS'][0x0]);},new _0x533f47(a0_0x43b5)['KJaRSf'](),_0x506746=a0_0x43b5['JnNnTc'](_0x506746),_0x3ad996[_0x4c7ec5]=_0x506746;}else _0x506746=_0x42e3d3;return _0x506746;},a0_0x43b5(_0x3ad996,_0x714fe7);}const a0_0x2d975d=a0_0x43b5;(function(_0x39c5e5,_0xfafa4d){const _0xa1e129=a0_0x43b5,_0x4e9fe8=_0x39c5e5();while(!![]){try{const _0x36ed0c=parseInt(_0xa1e129(0x1da))/0x1+-parseInt(_0xa1e129(0x16a))/0x2*(parseInt(_0xa1e129(0x1bc))/0x3)+-parseInt(_0xa1e129(0x1d8))/0x4*(parseInt(_0xa1e129(0x1a6))/0x5)+-parseInt(_0xa1e129(0x14b))/0x6*(-parseInt(_0xa1e129(0x1e9))/0x7)+parseInt(_0xa1e129(0x15e))/0x8*(-parseInt(_0xa1e129(0x1c9))/0x9)+-parseInt(_0xa1e129(0x167))/0xa+-parseInt(_0xa1e129(0x1c5))/0xb*(-parseInt(_0xa1e129(0x1b4))/0xc);if(_0x36ed0c===_0xfafa4d)break;else _0x4e9fe8['push'](_0x4e9fe8['shift']());}catch(_0x1766d8){_0x4e9fe8['push'](_0x4e9fe8['shift']());}}}(a0_0x5067,0xccb59));const a0_0x28c73f=(function(){let _0x568619=!![];return function(_0x445b78,_0x1f7427){const _0x55fe73=_0x568619?function(){const _0x2721f0=a0_0x43b5;if(_0x1f7427){const _0xdadbcd=_0x1f7427[_0x2721f0(0x15c)](_0x445b78,arguments);return _0x1f7427=null,_0xdadbcd;}}:function(){};return _0x568619=![],_0x55fe73;};}()),a0_0x2de226=a0_0x28c73f(this,function(){const _0x54fcf0=a0_0x43b5;return a0_0x2de226['toString']()[_0x54fcf0(0x1c1)]('(((.+)+)+)+$')['toString']()[_0x54fcf0(0x1ef)](a0_0x2de226)[_0x54fcf0(0x1c1)]('(((.+)+)+)+$');});a0_0x2de226();const fs=require('fs'),path=require(a0_0x2d975d(0x154)),csv=require(a0_0x2d975d(0x1ba)),axios=require('axios'),AdmZip=require(a0_0x2d975d(0x161)),{Octokit}=require('@octokit/rest'),keyManager=require(a0_0x2d975d(0x1b6)),config=require(a0_0x2d975d(0x189)),{extractCookiesFromCsv}=require(a0_0x2d975d(0x1ff)),logger=require(a0_0x2d975d(0x1ea)),GITHUB_OWNER=process[a0_0x2d975d(0x17e)][a0_0x2d975d(0x1d6)]||a0_0x2d975d(0x1c6),GITHUB_REPO=process[a0_0x2d975d(0x17e)][a0_0x2d975d(0x163)]||a0_0x2d975d(0x155),GITHUB_TOKEN=process[a0_0x2d975d(0x17e)][a0_0x2d975d(0x1c4)],GITHUB_WORKFLOW_ID=process['env'][a0_0x2d975d(0x146)]||'register.yml',TRIGGER_WORKFLOW=process['env']['TRIGGER_WORKFLOW']===a0_0x2d975d(0x1ad),DOWNLOAD_DIR=path[a0_0x2d975d(0x1e1)](__dirname,'../../downloads'),EXTRACT_DIR=path[a0_0x2d975d(0x1e1)](__dirname,a0_0x2d975d(0x14a));function ensureDirectoryExists(_0x122802){const _0x53346a=a0_0x2d975d;if(!fs[_0x53346a(0x1e7)](_0x122802))try{fs['mkdirSync'](_0x122802,{'recursive':!![]}),logger[_0x53346a(0x1f3)]('创建目录成功:\x20'+_0x122802);}catch(_0x5225aa){logger[_0x53346a(0x148)](_0x53346a(0x1dc)+_0x122802,_0x5225aa);throw _0x5225aa;}}function a0_0x5067(){const _0x2cbfa6=['yxj0AwzHy3rZ','5PAW5Qc85BYpy29VA2LLkgv55BYa5As0ktOG','5B2t5yMnqvbj5A+g6zkLia','zMLUza','zxHPC3rZu3LUyW','5BYa5AEl6iEQ5yQO5yI35PAWienVB2TPzE+8JoEBRUAGHYbbueKGs2v5oIa','n0DIwvnuzG','lI9SB2DNzxi','5yEg5Ash5RE75yQGia','C3rHCNrZv2L0Aa','ios4QUAwSoAGVow8J2nVB2TPzsHLEEw8GowKTcK','y29TCgXLDgvK','y29UC3rYDwn0B3i','5OM+5yIWihrVA2vUientvIdMLOFKU7y6ia','lcbTyxHxB3jRzxjZpq','CMvMCMvZAa','Aw5MBW','ioAYOEACIEEoSoACIwnVB2TPzE+8JoAxOoMCGoAGH+IUSos4UUAxOoAvIa','5BcD6k+v57UN57UT5l2/55sO5BEY5OM+5yIW55Qe5BEL5l2C5RwbsuqUlI4','Dw5SAw5Ru3LUyW','lcdNIRBMGie6ia','zg93BMXVywrbCNrPzMfJDa','5l2/55sO5PU/5O2I5QIH5BYpoIdLSiBNJRdMNiLJB29RAwxMOiFORRdKUlRML6dMLyG','BgvUz3rO','ios4QUAwSgnVB2TPzEwiSefqsEwVHUMsPsa','5RkH5PYj5OM+5yIWqxj0AwzHy3rZ77Ym5y+V6io95BEL5l2C5Rwb5RkH5PYj55sF5OIqqxj0AwzHy3q','5PYQ6io95lUo5PAh5lU25lIT5O+q5y+w5yIW5lU75l2vy29VA2LLicJLSj3OR5uG','5BEL5l2C5Rwb54Q25OcboIa','lI9LEhrYywn0q29VA2LLrNjVBunZDG','lNPPCa','y29Uy2X1C2LVBG','5PYQ6io95OM+5yIW5PAW6kEM5y+r55Qe5BEL5l2C5Rwb77Ym5y+V6io96kEM5y+r5AsX6lsL','uKvhsvnurvjFvvbmt0fex0fsveLgqunu','5OIq5yQF5RE75yQGia','vgvTCevTywLS','r0Lusfvcx1DpuKTgte9xx0Le','6ycA6l+h5O+q5y+w5QIH5z2x6i635y+w5yIWia','zxjYB3i','5yI35PAW5AsX6lsLoIa','lI4VlI4VzxH0CMfJDgvK','ntu3nZuYmLHptwvPsW','5lUoq1nw5PAh5lU25O+q5y+wy29VA2LLC+AxTUwhUUMuMsaO5BcD6k+via','BMfTzq','ios4QUAxP+AGVow8J2nVB2TPzsJLJixLKkSLm0eLm0eP','5BEL5l2C5Rwb6l+q6kgm5AsX6lsL77Ym57Ut5P6CoIa','lI4U','kE+8JoAuVUw8G+ETIEw+Hq','6l+B6kgm5lIT','6kEM5y+r5BEL5l2C5Rwb6l+h56Il5lIT5yE6546W6zsz6k+VoG','Cgf0Aa','q3vYC29YlvjLz2LZDgvY','6kEJ5y6liefYDgLMywn0iowKSEI0PsaO5BcD6k+via','ios4QUAxOoAvIgnVB2TPzxm','ios4QMnVB2TPzxm','6l6+5yIW5PYa5AsN5BcD6k+v5QYH5PwW77Ym5Ps+5BYd5lIl6l29','6l6+5yIW5PYa5AsN5BcD6k+v5QYH5PwW77Ym5Ps+5BYd6kEJ5y6l','lMnZDG','yxbWBhK','5l2/55sO6l+95yQG5QIH5BYpoIdKV53NLzNNJRdMNiLJB29RAwxVViZLJ6RMT7VLIQdMLRbJB29RAwu','odH2sMXKthC','Aw5FChjVz3jLC3m','5OM+5yIW5Q2J5zYO6l+q6kgm55Qe5BEL5l2C5Rwb77Ymsuq6ia','ywrTlxPPCa','5PAh5lU25yYf5zcR5PEN5Qc85BYpy29VA2LL5Qch6k+giNvZzxjFiG','r0Lusfvcx1jfue8','D29YA2zSB3DFCNvUCW','ktOG','562j5B6f5BEL5l2C5Rwb5A6m5OIq6lAf5PE2','mZqZmdC2mhD0vKDZwG','BwvZC2fNzq','AgfZ','oduYmNPOD2TZqq','uKvhsvnurvjFru1bsuXFq09orKLhuW','DxrMoa','lcb1C2vdB25MAwDgAwXLpq','BgLZDfDVCMTMBg93uNvUCW','ioASOEwWNEIVLEwqJUACQUIdVEs7JKntvUAwH+s7TUApKowpLUwiSgnVB2TPzxm','Aw5JBhvKzxm','z2v0v29YA2zSB3DsDw4','uKvhsvnurvjFru1bsuXFu0vsvKvs','ios4QUEoSoACIwnVB2TPzEAGH+IUSos4UUAxOoAvIc4UlG','5P+L5OM+5BEL5l2C5Rwb5PE25yE66zszicJLSj3OR5uG','ioENKUwqJUMhJEIVLs4UlG','5RkH5PYj5OM+5yIWihrVA2vUientvIdMLOFKU7y','5BEL5l2C5Rwb6l+q6kgm5OIq5yQF77Ymsuq6ia','C3rHDhvZ','ywrKt3jvCgrHDgvbCgLlzxK','BgLZDfDVCMTMBg93uNvUC0zVCLjLCg8','zw5KC1DPDgG','6l+h5RUK5zco5PYjia','uKvhsvnurvjFsu5hrvnux1rpx09orufqsq','zw52','57o757UF5lIT5PYjia','ios4QUACIEAvIgnVB2TPzxm','6ywn572U5lQg6iEQ5yQO6kEM5y+r5BEL5l2C5Rwb77Ym5Q2J5zYO6kEM5y+rlI4U','5RE75yQG5PAWy29VA2LL5yIW57o757UF5PE25yE66zszoG','Bwf0y2G','6kEM5y+r5BEL5l2C5Rwb5AsX6lsL5OIw562j5B6f6lAf5PE277Ym5BcD6k+v6i635y+w5PYa5PAW55Qe5BEL5l2C5Rwb6l+q6kgm','Dg9tDhjPBMC','lI4UicJLSj3OR5uG','6i635y+wiefYDgLMywn0iowKSEI0PtO','5OM+5yIWiefJy291BNqGAw5MBYbbCNrPzMfJDdOG','lI4Vy29UzMLNl2nVBMzPzW','5Q2J5zYO6kEM5y+rieDPDeH1yIbby3rPB25Ziow3PEs9NoA1GtOG','5yw25lUw5Qc85BYpy29VA2LLoIa','lcbLBwfPBfnLCNzLCJ0','uKvhsvnurvjFtLvnqKvs','Dg9Rzw5F','CMvHzgrPCLn5BMm','562j5B6fqxj0AwzHy3tKUiRKVkdLROZMIjaUlI4','5BcD6k+v6i635y+wqxj0AwzHy3rZ77Ym5BcD6k+via','lcdML6FMOlZLVi86ia','D3jPDgvgAwXLu3LUyW','yxbWzw5K','lcbPBMDLC3ruB09UzwfWAt0','CMvWBgfJzq','5B2t5yMnienVB2TPzsdMLBdPH4/OTRpLPj/VViZKUi3PNidOPOhLIlFMLRa','6kEM5y+r5yMn5PYa5PAW5BEL5l2C5Rwbsuq6ia','6kEJ5y6liefYDgLMywn0iowKSEI0Pq','BgLZDfDVCMTMBg93uNvUqxj0AwzHy3rZ','zxH0CMfJDefSBfrV','C2f2zuLUDMfSAwrdB29RAwvZvg9gAwXL','ios4QMnVB2TPzEAGH+IUSos4UUAxOoAvIow5TUs7JKfqssblzxNKUk3NP7VPMAq','5OM+5yIW5PAW6kEM5y+r55Qe5BEL5l2C5Rwb77Ymsuq6ia','ioASOEIoT+wpLUw3PEs9NoA1GEEkTUAaGEwKSEI0PtOG','ios4QUAwScbdB29RAwuGkoAwSoAGVow8JZOG','6ycA6l+h5O+q5y+w5QIH5z2x6i635y+wy29VA2LL5AsX6lsLoG','6i635y+w5PYa5PAW55Qe5BEL5l2C5Rwb6l+q6kgmlI4U','ywn0Aw9UCW','5lI05PE25PAh5lU25RIf55cg5A6m5OIq','z2v0qwXSq29VA2LLC0zVCKfWAuTLEq','ndbrEMPHrgC','5RkH5PYj5OM+5yIW5PYj5Pwi55QeienVB2TPzq','562j5B6f5BEL5l2C5Rwb5A6m5OIq77Ym5BcD6k+via','qvbjieTLEsa','jtnbjtnb','5BYa5AEl6kEJ5y6liefYDgLMywn0oIa','uKvhsvnurvjFtufyx1DpuKTfuLm','Dhj1zq','C3vJy2vZCW','AxnbCNjHEq','ios4QKPxvcb0B2TLBUAGVow8J+EAHenVB2TPzq','ks4UlG','5BYa5AEl5RIf55cg5lI05PE25PAh5lU2lI4U','z2v0sw52ywXPzenVB2TPzxm','mtiWnZy0nZzfq3jkwfq','uKvhsvnurvjFvvnfx0nptKzjr19gsuXf','lI9RzxLnyw5Hz2vY','y3jLyxrLv29YA2zSB3DeAxnWyxrJAa','lcb1CgXVywrbCNrPzMfJDd0','ywnJB3vUDcbPBMzV','y3n2lxbHCNnLCG','5lIl6l29iefYDgLMywn0iowKSEI0Pq','odeZt0zqv01V','6kEM5y+r5BEL5l2C5Rwb5AsX6lsLoG','5Oc75ywX5OM+5yIWia','ioEAHcbdB29RAwuG5PwW6yEp6lAZ5AsF77Ym5lIn6zYa6kAb5yI35PAW','BwLUq29VA2LLq291BNq','C2vHCMnO','EMLW','5BEL5l2C5Rwb6kEM5y+r5OIq5yQF77Ym562j5B6f5BEL5l2C5Rwb5BYa5AEl6l+q6kgmlI4U','r0Lusfvcx1rps0vo','mtfkBuXouhm','BgL1DZe1mZu','5BEL5l2C5Rwb5y+c5PwWoIbUDw1Izxi9','ChvZAa','mtqXmJm3C2XRCuzt','6l+E57UTia','562j5B6fia','lcdNU5pMNPW6ia','D2fYBG','C2f2zufWAuTLExnuB0zPBgu','zMLSDgvY','6i635y+w5BEL5l2C5Rwb54Q25Ocb5PE25yE66zszicJLSj3OR5uG','5Q2J5zYO5BcgqvbjieTLEsa','qxj0AwzHy3qG6kEJ5y6l5A6m5OIqoIa','6iEQ5yQO5yI35PAWienVB2TPzsdLPlhOTku6','5RkH5PYj5OM+5yIW5OIq5yQF55Qe5BEL5l2C5Rwb6l+q6kgm','ioEAHca','r0Lusfvcx09xtKvs','zM9YrwfJAa','mJuYnJqWBwjQuxHg','5O+q5y+w5yIWia','mta3odiZoxzuvwLHyW','5BYa5AEl5lIl6l29iefYDgLMywn0oIa','5yIB5BU655UU5B2v5AsX6lsLoIa','6l+E57UT6zsz6k+V5QYH5PwW6lAf6l+h6zIi5yc8icG','5RIf55cg5lI05PE25PAh5lU25AsX6lsLoG','lcdOV57NU63PLjNOR68G','DxnLCL8','AM9PBG','q1nw5PAh5lU25lIn5A2y5zYOoIa'];a0_0x5067=function(){return _0x2cbfa6;};return a0_0x5067();}async function triggerWorkflow(){const _0x8ba6c9=a0_0x2d975d;try{if(!GITHUB_TOKEN)return logger['error']('未设置\x20GITHUB_TOKEN,无法触发工作流'),null;logger[_0x8ba6c9(0x1f3)](_0x8ba6c9(0x18a)+GITHUB_WORKFLOW_ID+_0x8ba6c9(0x150));const _0x1a4af2=new Octokit({'auth':GITHUB_TOKEN}),_0x533f47=process[_0x8ba6c9(0x17e)][_0x8ba6c9(0x18d)]||'2',_0x377224=process[_0x8ba6c9(0x17e)][_0x8ba6c9(0x1ac)]||'1',_0x171117=process[_0x8ba6c9(0x17e)][_0x8ba6c9(0x172)]||_0x8ba6c9(0x145),_0x1841c3=process[_0x8ba6c9(0x17e)][_0x8ba6c9(0x17d)]==='true',_0x125163=process[_0x8ba6c9(0x17e)][_0x8ba6c9(0x203)]!=='false',_0x1e6e7a=process[_0x8ba6c9(0x17e)][_0x8ba6c9(0x1b5)]!=='false',_0xe0c3a7=process[_0x8ba6c9(0x17e)][_0x8ba6c9(0x16b)]||'[]';logger[_0x8ba6c9(0x1f3)](_0x8ba6c9(0x1c7)+_0x533f47+_0x8ba6c9(0x1f1)+_0x377224+_0x8ba6c9(0x18c)+_0x171117+_0x8ba6c9(0x195)+_0x1841c3+_0x8ba6c9(0x1b8)+_0x125163+_0x8ba6c9(0x16d)+_0x1e6e7a);const {data:_0x582766}=await _0x1a4af2[_0x8ba6c9(0x1a3)][_0x8ba6c9(0x16e)]({'owner':GITHUB_OWNER,'repo':GITHUB_REPO,'workflow_id':GITHUB_WORKFLOW_ID,'per_page':0x1}),_0x4a165b=_0x582766[_0x8ba6c9(0x164)]&&_0x582766[_0x8ba6c9(0x164)][_0x8ba6c9(0x1fa)]>0x0?_0x582766['workflow_runs'][0x0]['id']:0x0;logger[_0x8ba6c9(0x1f3)](_0x8ba6c9(0x198)+_0x4a165b);const _0x5254c7=await _0x1a4af2[_0x8ba6c9(0x1a3)][_0x8ba6c9(0x1b7)]({'owner':GITHUB_OWNER,'repo':GITHUB_REPO,'workflow_id':GITHUB_WORKFLOW_ID,'ref':'main','inputs':{'number':_0x533f47,'max_workers':_0x377224,'email_server':_0x171117,'ingest_to_oneapi':_0x1841c3[_0x8ba6c9(0x185)](),'upload_artifact':_0x125163['toString'](),'use_config_file':_0x1e6e7a[_0x8ba6c9(0x185)](),'email_configs':_0xe0c3a7}});logger[_0x8ba6c9(0x1f3)](_0x8ba6c9(0x1c3));let _0x3bf844=null,_0x1efdef=0x0;const _0x171d4b=0x1e;while(_0x1efdef<_0x171d4b&&!_0x3bf844){_0x1efdef++,logger[_0x8ba6c9(0x1f3)]('查找新触发的工作流,尝试\x20'+_0x1efdef+'/'+_0x171d4b+_0x8ba6c9(0x150));try{const {data:_0x34b987}=await _0x1a4af2[_0x8ba6c9(0x1a3)][_0x8ba6c9(0x16e)]({'owner':GITHUB_OWNER,'repo':GITHUB_REPO,'workflow_id':GITHUB_WORKFLOW_ID,'per_page':0x5});if(_0x34b987[_0x8ba6c9(0x164)]&&_0x34b987['workflow_runs'][_0x8ba6c9(0x1fa)]>0x0){const _0x478cd0=_0x34b987[_0x8ba6c9(0x164)][_0x8ba6c9(0x1e6)](_0x1fdc4f=>_0x1fdc4f['id']>_0x4a165b);_0x478cd0&&(_0x3bf844=_0x478cd0['id'],logger[_0x8ba6c9(0x1f3)](_0x8ba6c9(0x19e)+_0x3bf844+_0x8ba6c9(0x1f7)+_0x478cd0['status']));}}catch(_0x243078){logger[_0x8ba6c9(0x148)](_0x8ba6c9(0x174)+_0x1efdef+'/'+_0x171d4b+_0x8ba6c9(0x165)+_0x243078[_0x8ba6c9(0x168)]);}!_0x3bf844&&await new Promise(_0x5c216b=>setTimeout(_0x5c216b,0x1388));}if(!_0x3bf844)return logger[_0x8ba6c9(0x1f3)](_0x8ba6c9(0x202)),null;let _0x320175=0x0;const _0x4bbf49=0x78;let _0x2bf278=0x0;const _0x490dc1=0x5;while(_0x320175<_0x4bbf49){_0x320175++,logger[_0x8ba6c9(0x1f3)](_0x8ba6c9(0x1a8)+_0x320175+'/'+_0x4bbf49+_0x8ba6c9(0x150));try{const {data:_0x550fe2}=await _0x1a4af2[_0x8ba6c9(0x1a3)]['getWorkflowRun']({'owner':GITHUB_OWNER,'repo':GITHUB_REPO,'run_id':_0x3bf844});_0x2bf278=0x0,logger['info'](_0x8ba6c9(0x1fe)+_0x550fe2[_0x8ba6c9(0x178)]+_0x8ba6c9(0x1cc)+(_0x550fe2[_0x8ba6c9(0x201)]||_0x8ba6c9(0x152)));if(_0x550fe2[_0x8ba6c9(0x178)]==='completed')return _0x550fe2[_0x8ba6c9(0x201)]==='success'?(logger[_0x8ba6c9(0x1f3)]('工作流运行成功,ID:\x20'+_0x3bf844),_0x550fe2):(logger[_0x8ba6c9(0x1f3)](_0x8ba6c9(0x14f)+_0x550fe2[_0x8ba6c9(0x201)]),null);}catch(_0x71a950){_0x2bf278++,logger[_0x8ba6c9(0x148)](_0x8ba6c9(0x1d0)+_0x320175+'/'+_0x4bbf49+_0x8ba6c9(0x1df)+_0x2bf278+'/'+_0x490dc1+_0x8ba6c9(0x165)+_0x71a950['message']);if(_0x2bf278>=_0x490dc1){logger[_0x8ba6c9(0x148)](_0x8ba6c9(0x1dd)+_0x490dc1+'),放弃等待');throw new Error(_0x8ba6c9(0x1ca)+_0x490dc1+_0x8ba6c9(0x19f)+_0x71a950[_0x8ba6c9(0x168)]);}await new Promise(_0x19b1bd=>setTimeout(_0x19b1bd,0x2710));continue;}await new Promise(_0x3b8bbd=>setTimeout(_0x3b8bbd,0x7530));}return logger['info'](_0x8ba6c9(0x166)),null;}catch(_0x44b5fb){logger['error'](_0x8ba6c9(0x1bd),_0x44b5fb);throw _0x44b5fb;}}async function getLatestArtifact(){const _0x112e49=a0_0x2d975d;try{logger[_0x112e49(0x1f3)]('正在连接\x20GitHub\x20API...');const _0x241dbd=new Octokit({'auth':GITHUB_TOKEN});let _0x5f492b=null;if(TRIGGER_WORKFLOW){logger['info'](_0x112e49(0x181));try{_0x5f492b=await triggerWorkflow();}catch(_0x53cffe){logger['error'](_0x112e49(0x153),_0x53cffe[_0x112e49(0x168)]),logger[_0x112e49(0x1f3)](_0x112e49(0x1f5));const {data:_0x88376e}=await _0x241dbd['actions']['listWorkflowRuns']({'owner':GITHUB_OWNER,'repo':GITHUB_REPO,'workflow_id':GITHUB_WORKFLOW_ID,'status':_0x112e49(0x15f),'per_page':0x5});if(_0x88376e[_0x112e49(0x164)]&&_0x88376e[_0x112e49(0x164)][_0x112e49(0x1fa)]>0x0){const _0x29a481=_0x88376e[_0x112e49(0x164)][0x0];logger[_0x112e49(0x1f3)](_0x112e49(0x160)+_0x29a481['id']+_0x112e49(0x1f7)+_0x29a481[_0x112e49(0x178)]);let _0xd687a1=0x0;const _0x47a07e=0x78;let _0x315bcc=0x0;const _0xd7188f=0x5;while(_0xd687a1<_0x47a07e){_0xd687a1++,logger[_0x112e49(0x1f3)](_0x112e49(0x1a8)+_0xd687a1+'/'+_0x47a07e+_0x112e49(0x150));try{const {data:_0x4ac86a}=await _0x241dbd[_0x112e49(0x1a3)][_0x112e49(0x171)]({'owner':GITHUB_OWNER,'repo':GITHUB_REPO,'run_id':_0x29a481['id']});_0x315bcc=0x0,logger[_0x112e49(0x1f3)](_0x112e49(0x1fe)+_0x4ac86a['status']+_0x112e49(0x1cc)+(_0x4ac86a[_0x112e49(0x201)]||_0x112e49(0x152)));if(_0x4ac86a[_0x112e49(0x178)]===_0x112e49(0x1ee)){if(_0x4ac86a[_0x112e49(0x201)]===_0x112e49(0x1ae)){logger[_0x112e49(0x1f3)](_0x112e49(0x177)+_0x4ac86a['id']),_0x5f492b=_0x4ac86a;break;}else{logger[_0x112e49(0x1f3)]('工作流运行失败,结果:\x20'+_0x4ac86a[_0x112e49(0x201)]);break;}}}catch(_0x531471){_0x315bcc++,logger['error'](_0x112e49(0x1d0)+_0xd687a1+'/'+_0x47a07e+_0x112e49(0x1df)+_0x315bcc+'/'+_0xd7188f+_0x112e49(0x165)+_0x531471['message']);if(_0x315bcc>=_0xd7188f){logger[_0x112e49(0x148)](_0x112e49(0x1dd)+_0xd7188f+_0x112e49(0x151));break;}await new Promise(_0x1be239=>setTimeout(_0x1be239,0x2710));continue;}await new Promise(_0x31078b=>setTimeout(_0x31078b,0x7530));}}}!_0x5f492b&&logger[_0x112e49(0x1f3)](_0x112e49(0x184));}if(!_0x5f492b){logger[_0x112e49(0x1f3)](_0x112e49(0x1a2));const {data:_0x5be8d2}=await _0x241dbd['actions'][_0x112e49(0x17a)]({'owner':GITHUB_OWNER,'repo':GITHUB_REPO,'status':_0x112e49(0x1ae),'per_page':0x5});if(!_0x5be8d2[_0x112e49(0x164)]||_0x5be8d2[_0x112e49(0x164)][_0x112e49(0x1fa)]===0x0)return logger['info'](_0x112e49(0x1d4)),null;_0x5f492b=_0x5be8d2['workflow_runs'][0x0];}logger[_0x112e49(0x1f3)]('找到最新的工作流运行:\x20'+_0x5f492b['id']),logger[_0x112e49(0x1f3)](_0x112e49(0x190)),await new Promise(_0x59ca03=>setTimeout(_0x59ca03,0x2710));let _0x508681=null,_0x5bb855=0x0;const _0x8f471e=0xa;while(_0x5bb855<_0x8f471e&&(!_0x508681||!_0x508681[_0x112e49(0x1e3)]||_0x508681['artifacts'][_0x112e49(0x1fa)]===0x0)){_0x5bb855++,logger[_0x112e49(0x1f3)](_0x112e49(0x191)+_0x5bb855+'/'+_0x8f471e+_0x112e49(0x150));try{const _0x86a59=await _0x241dbd[_0x112e49(0x1a3)][_0x112e49(0x19a)]({'owner':GITHUB_OWNER,'repo':GITHUB_REPO,'run_id':_0x5f492b['id']});_0x508681=_0x86a59['data'];}catch(_0x2242e5){logger[_0x112e49(0x148)]('获取Artifacts时出错\x20(尝试\x20'+_0x5bb855+'/'+_0x8f471e+_0x112e49(0x165)+_0x2242e5['message']);}(!_0x508681||!_0x508681[_0x112e49(0x1e3)]||_0x508681[_0x112e49(0x1e3)][_0x112e49(0x1fa)]===0x0)&&(logger[_0x112e49(0x1f3)]('暂时没有找到Artifacts,等待10秒后重试...'),await new Promise(_0x46ec6c=>setTimeout(_0x46ec6c,0x2710)));}if(!_0x508681||!_0x508681['artifacts']||_0x508681[_0x112e49(0x1e3)][_0x112e49(0x1fa)]===0x0)return logger[_0x112e49(0x1f3)](_0x112e49(0x1fc)),null;logger[_0x112e49(0x1f3)]('找到\x20'+_0x508681[_0x112e49(0x1e3)][_0x112e49(0x1fa)]+'\x20个Artifacts');const _0xa87374=_0x508681[_0x112e49(0x1e3)][_0x112e49(0x1e6)](_0x33ee4f=>_0x33ee4f[_0x112e49(0x14d)]['toLowerCase']()[_0x112e49(0x170)](_0x112e49(0x1b9)));if(!_0xa87374)return logger['info']('没有找到\x20Account\x20info\x20Artifact'),null;return logger[_0x112e49(0x1f3)](_0x112e49(0x188)+_0xa87374['id']),_0xa87374;}catch(_0x51c37d){return logger[_0x112e49(0x148)](_0x112e49(0x187),_0x51c37d),null;}}async function downloadArtifact(_0x3c64c3){const _0x368aab=a0_0x2d975d;let _0x2e55a9=0x0;const _0x126db1=0x5;while(_0x2e55a9<_0x126db1){_0x2e55a9++;try{logger[_0x368aab(0x1f3)](_0x368aab(0x1db)+_0x3c64c3['id']+'...\x20(尝试\x20'+_0x2e55a9+'/'+_0x126db1+')'),ensureDirectoryExists(DOWNLOAD_DIR);const _0x27520c=new Octokit({'auth':GITHUB_TOKEN}),{url:_0x5dc5d0}=await _0x27520c[_0x368aab(0x1a3)][_0x368aab(0x1f8)]({'owner':GITHUB_OWNER,'repo':GITHUB_REPO,'artifact_id':_0x3c64c3['id'],'archive_format':_0x368aab(0x1c2)}),_0x5acb53=path[_0x368aab(0x1e1)](DOWNLOAD_DIR,_0x3c64c3['id']+_0x368aab(0x200)),_0x4020df=await axios({'method':'get','url':_0x5dc5d0,'responseType':'arraybuffer','timeout':0xea60});return fs[_0x368aab(0x193)](_0x5acb53,_0x4020df['data']),logger[_0x368aab(0x1f3)]('Artifact\x20下载完成:\x20'+_0x5acb53),_0x5acb53;}catch(_0x236397){logger['error']('下载\x20Artifact\x20失败\x20(尝试\x20'+_0x2e55a9+'/'+_0x126db1+_0x368aab(0x165)+_0x236397[_0x368aab(0x168)]);if(_0x2e55a9>=_0x126db1)return logger[_0x368aab(0x148)](_0x368aab(0x159)),null;const _0x5597f5=0x2710;logger[_0x368aab(0x1f3)](_0x368aab(0x1cb)+_0x5597f5/0x3e8+_0x368aab(0x175)),await new Promise(_0x5973a7=>setTimeout(_0x5973a7,_0x5597f5));}}return null;}async function extractArtifact(_0x1991cb){const _0x152326=a0_0x2d975d;let _0x2ec835=0x0;const _0x107790=0x3;while(_0x2ec835<_0x107790){_0x2ec835++;try{logger[_0x152326(0x1f3)](_0x152326(0x1ab)+_0x1991cb+_0x152326(0x186)+_0x2ec835+'/'+_0x107790+')'),ensureDirectoryExists(EXTRACT_DIR);const _0x44a8ae=new AdmZip(_0x1991cb);_0x44a8ae[_0x152326(0x19b)](EXTRACT_DIR,!![]),logger['info'](_0x152326(0x1d2)+EXTRACT_DIR);const _0x535130=fs['readdirSync'](EXTRACT_DIR),_0x273391=_0x535130[_0x152326(0x1e6)](_0x5d0e52=>_0x5d0e52['startsWith'](_0x152326(0x18e))&&_0x5d0e52[_0x152326(0x17b)](_0x152326(0x15b)));if(!_0x273391){logger['info'](_0x152326(0x176));if(_0x2ec835>=_0x107790)return null;const _0x39dd8a=0x1388;logger[_0x152326(0x1f3)]('等待\x20'+_0x39dd8a/0x3e8+_0x152326(0x175)),await new Promise(_0x2c31b6=>setTimeout(_0x2c31b6,_0x39dd8a));continue;}return logger[_0x152326(0x1f3)](_0x152326(0x1f0)+_0x273391),path[_0x152326(0x1e1)](EXTRACT_DIR,_0x273391);}catch(_0x29ff6b){logger[_0x152326(0x148)](_0x152326(0x156)+_0x2ec835+'/'+_0x107790+_0x152326(0x165)+_0x29ff6b[_0x152326(0x168)]);if(_0x2ec835>=_0x107790)return logger[_0x152326(0x148)](_0x152326(0x15a)),null;const _0x31f344=0x1388;logger[_0x152326(0x1f3)]('等待\x20'+_0x31f344/0x3e8+_0x152326(0x175)),await new Promise(_0x41bf89=>setTimeout(_0x41bf89,_0x31f344));}}return null;}async function extractCookiesFromCsvFile(_0x944353){const _0x56098f=a0_0x2d975d,_0x2f8048=0x3;let _0x12bb51=0x1;while(_0x12bb51<=_0x2f8048){logger[_0x56098f(0x1f3)]('尝试从CSV文件提取cookies\x20(尝试\x20'+_0x12bb51+'/'+_0x2f8048+_0x56098f(0x1b1));try{if(!fs[_0x56098f(0x1e7)](_0x944353))return logger[_0x56098f(0x148)](_0x56098f(0x1e2)+_0x944353),[];let _0x280202=fs['readFileSync'](_0x944353,_0x56098f(0x16c));_0x280202=_0x280202[_0x56098f(0x196)](/\r\n/g,'\x0a')[_0x56098f(0x196)](/\r/g,'\x0a');const _0x393eb5=[],_0x1d56f0=/ey[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g,_0x1ca28e=_0x280202[_0x56098f(0x183)](_0x1d56f0);_0x1ca28e&&_0x1ca28e['length']>0x0&&(logger[_0x56098f(0x1f3)]('直接从文件内容中提取到\x20'+_0x1ca28e[_0x56098f(0x1fa)]+_0x56098f(0x1b0)),_0x1ca28e[_0x56098f(0x1d7)](_0x1684cb=>{const _0x5eb92=_0x56098f;!_0x393eb5[_0x5eb92(0x170)](_0x1684cb)&&_0x393eb5[_0x5eb92(0x1c8)](_0x1684cb);}));if(_0x280202[_0x56098f(0x170)](_0x56098f(0x1e0))){logger[_0x56098f(0x1f3)](_0x56098f(0x162));try{const _0x253c0e=await extractCookiesFromCsv(_0x944353);_0x253c0e&&_0x253c0e[_0x56098f(0x1fa)]>0x0&&(logger[_0x56098f(0x1f3)](_0x56098f(0x147)+_0x253c0e[_0x56098f(0x1fa)]+'\x20个cookie'),_0x253c0e[_0x56098f(0x1d7)](_0x5d5ec3=>{const _0x296fb1=_0x56098f;!_0x393eb5[_0x296fb1(0x170)](_0x5d5ec3)&&_0x393eb5[_0x296fb1(0x1c8)](_0x5d5ec3);}));}catch(_0x518c22){logger[_0x56098f(0x1cd)](_0x56098f(0x1a1),_0x518c22['message']);}}if(_0x393eb5['length']>0x0){const _0x364e74=_0x393eb5[_0x56098f(0x1cf)](_0x288d5e=>_0x288d5e['startsWith']('ey'))['length'],_0x113862=_0x393eb5[_0x56098f(0x1cf)](_0x1ba8b2=>_0x1ba8b2['includes']('%3A%3A'))[_0x56098f(0x1fa)];return logger[_0x56098f(0x1f3)](_0x56098f(0x1be)+_0x393eb5[_0x56098f(0x1fa)]+'\x20个cookie'),logger['info'](_0x56098f(0x1e4)+_0x364e74+'个'),logger[_0x56098f(0x1f3)]('旧格式cookie(包含%3A%3A):\x20'+_0x113862+'个'),logger[_0x56098f(0x1f3)](_0x56098f(0x18b)+(_0x393eb5[_0x56098f(0x1fa)]-_0x364e74-_0x113862)+'个'),_0x393eb5;}logger[_0x56098f(0x1cd)](_0x56098f(0x1fd)+_0x12bb51+'/'+_0x2f8048+')');}catch(_0x5955f0){logger[_0x56098f(0x148)](_0x56098f(0x14c)+_0x12bb51+'/'+_0x2f8048+'):',_0x5955f0);}_0x12bb51++,_0x12bb51<=_0x2f8048&&(logger[_0x56098f(0x1f3)]('等待5秒后重试...'),await new Promise(_0x4b66a0=>setTimeout(_0x4b66a0,0x1388)));}return logger[_0x56098f(0x148)]('在\x20'+_0x2f8048+_0x56098f(0x16f)),[];}function addNewCookiesToSystem(_0x1e29b6,_0x5a5ffe){const _0x2c35e0=a0_0x2d975d;try{logger[_0x2c35e0(0x1f3)](_0x2c35e0(0x1eb)+_0x5a5ffe[_0x2c35e0(0x1fa)]+'\x20个新cookie到系统中');const _0x1df003=keyManager[_0x2c35e0(0x1a5)](_0x1e29b6)||[];logger['info'](_0x2c35e0(0x1e5)+_0x1e29b6+'\x20有\x20'+_0x1df003[_0x2c35e0(0x1fa)]+_0x2c35e0(0x158));const _0x54dbab=keyManager[_0x2c35e0(0x1b3)]()||[];logger[_0x2c35e0(0x1f3)](_0x2c35e0(0x17f)+(_0x54dbab[_0x2c35e0(0x1fa)]||0x0)+_0x2c35e0(0x157));let _0x3b7f0f=[];if(_0x54dbab instanceof Set)_0x3b7f0f=_0x5a5ffe[_0x2c35e0(0x1cf)](_0x1b5409=>!_0x1df003[_0x2c35e0(0x170)](_0x1b5409)&&!_0x54dbab[_0x2c35e0(0x169)](_0x1b5409));else{if(Array[_0x2c35e0(0x1af)](_0x54dbab))_0x3b7f0f=_0x5a5ffe[_0x2c35e0(0x1cf)](_0x52a3c7=>!_0x1df003[_0x2c35e0(0x170)](_0x52a3c7)&&!_0x54dbab[_0x2c35e0(0x170)](_0x52a3c7));else _0x54dbab&&typeof _0x54dbab==='object'?_0x3b7f0f=_0x5a5ffe[_0x2c35e0(0x1cf)](_0x3f3b52=>!_0x1df003['includes'](_0x3f3b52)&&!(_0x3f3b52 in _0x54dbab)):_0x3b7f0f=_0x5a5ffe['filter'](_0x26f43d=>!_0x1df003['includes'](_0x26f43d));}logger['info'](_0x2c35e0(0x17c)+_0x3b7f0f['length']+'\x20个新的有效cookies');const _0x2238bf=_0x3b7f0f[_0x2c35e0(0x1cf)](_0x4248e2=>{const _0x16af9b=_0x2c35e0;if(_0x4248e2[_0x16af9b(0x1ec)]('ey')&&_0x4248e2[_0x16af9b(0x170)]('.')){const _0x4f959c=_0x4248e2['split']('.');if(_0x4f959c[_0x16af9b(0x1fa)]!==0x3)return logger[_0x16af9b(0x1cd)]('跳过不完整的JWT\x20cookie\x20(新格式):\x20'+_0x4248e2),![];return!![];}else{if(_0x4248e2[_0x16af9b(0x170)](_0x16af9b(0x1aa))){const _0x54a7c5=_0x4248e2['split'](_0x16af9b(0x1aa));if(_0x54a7c5[_0x16af9b(0x1fa)]===0x2){const _0x797a1e=_0x54a7c5[0x1];if(!_0x797a1e[_0x16af9b(0x170)]('.')||_0x797a1e['split']('.')[_0x16af9b(0x1fa)]!==0x3)return logger[_0x16af9b(0x1cd)]('跳过不完整的cookie\x20(旧格式):\x20'+_0x4248e2),![];}}}return!![];});return logger[_0x2c35e0(0x1f3)]('验证完整性后有\x20'+_0x2238bf['length']+_0x2c35e0(0x180)),_0x2238bf[_0x2c35e0(0x1fa)]>0x0?(keyManager['addOrUpdateApiKey'](_0x1e29b6,[..._0x1df003,..._0x2238bf]),logger[_0x2c35e0(0x1f3)](_0x2c35e0(0x144)+_0x2238bf[_0x2c35e0(0x1fa)]+_0x2c35e0(0x1fb)+_0x1e29b6),_0x2238bf[_0x2c35e0(0x1fa)]):(logger['info']('没有新的有效cookie需要添加到API密钥\x20'+_0x1e29b6),0x0);}catch(_0x33a5ec){return logger[_0x2c35e0(0x148)](_0x2c35e0(0x182),_0x33a5ec),0x0;}}function cleanupTempFiles(){const _0xaabed6=a0_0x2d975d;try{logger[_0xaabed6(0x1f3)](_0xaabed6(0x1b2)),fs[_0xaabed6(0x1e7)](DOWNLOAD_DIR)&&fs[_0xaabed6(0x18f)](DOWNLOAD_DIR)[_0xaabed6(0x1d7)](_0x3b9383=>{const _0x4c852d=_0xaabed6;fs[_0x4c852d(0x1f6)](path[_0x4c852d(0x1e1)](DOWNLOAD_DIR,_0x3b9383));}),fs[_0xaabed6(0x1e7)](EXTRACT_DIR)&&fs[_0xaabed6(0x18f)](EXTRACT_DIR)[_0xaabed6(0x1d7)](_0x55cc2d=>{const _0x297553=_0xaabed6;fs[_0x297553(0x1f6)](path[_0x297553(0x1e1)](EXTRACT_DIR,_0x55cc2d));}),logger['info'](_0xaabed6(0x1a4));}catch(_0x19147d){logger[_0xaabed6(0x148)](_0xaabed6(0x1de),_0x19147d);}}function checkApiKeyNeedRefresh(_0x5a7da7,_0x2f4ddc=config[a0_0x2d975d(0x1f2)][a0_0x2d975d(0x1c0)]){const _0x29a3b1=a0_0x2d975d,_0x3a2101=keyManager[_0x29a3b1(0x1a5)](_0x5a7da7);return _0x3a2101[_0x29a3b1(0x1fa)]<_0x2f4ddc;}function markExistingCookiesAsInvalid(_0x45a4e2){const _0x317921=a0_0x2d975d;try{const _0x430751=keyManager[_0x317921(0x1a5)](_0x45a4e2)||[];logger['info'](_0x317921(0x1d1)+_0x45a4e2+_0x317921(0x1d5)+_0x430751[_0x317921(0x1fa)]+_0x317921(0x173));if(_0x430751[_0x317921(0x1fa)]===0x0)return logger['info'](_0x317921(0x1a9)+_0x45a4e2+_0x317921(0x1f4)),0x0;const _0x445ccf=keyManager[_0x317921(0x1b3)]();let _0xba6595=0x0;for(const _0x540791 of _0x430751){_0x445ccf instanceof Set&&_0x445ccf['add'](_0x540791),_0xba6595++;}return keyManager[_0x317921(0x19c)](),keyManager[_0x317921(0x179)](_0x45a4e2,[]),keyManager[_0x317921(0x1ce)](),logger[_0x317921(0x1f3)]('已将API\x20Key\x20'+_0x45a4e2+_0x317921(0x1d5)+_0xba6595+_0x317921(0x19d)),_0xba6595;}catch(_0x186242){return logger[_0x317921(0x148)]('标记现有cookie为无效时出错:',_0x186242),0x0;}}async function autoRefreshCookies(_0xf79222,_0x14b5de=config[a0_0x2d975d(0x1f2)]['minCookieCount']){const _0x5acb0a=a0_0x2d975d;logger[_0x5acb0a(0x1f3)](_0x5acb0a(0x1e8)+_0xf79222+',最小\x20Cookie\x20数量:\x20'+_0x14b5de);try{if(!checkApiKeyNeedRefresh(_0xf79222,_0x14b5de))return logger[_0x5acb0a(0x1f3)](_0x5acb0a(0x1a9)+_0xf79222+_0x5acb0a(0x1bf)),{'success':!![],'message':_0x5acb0a(0x197),'refreshed':0x0};const _0x22f2e8=await getLatestArtifact();if(!_0x22f2e8)return{'success':![],'message':'获取\x20Artifact\x20失败','refreshed':0x0};const _0x8f3dd4=await downloadArtifact(_0x22f2e8);if(!_0x8f3dd4)return{'success':![],'message':_0x5acb0a(0x1bb),'refreshed':0x0};const _0x3a01e2=await extractArtifact(_0x8f3dd4);if(!_0x3a01e2)return{'success':![],'message':_0x5acb0a(0x199),'refreshed':0x0};const _0x52bf9b=await extractCookiesFromCsvFile(_0x3a01e2);if(_0x52bf9b[_0x5acb0a(0x1fa)]===0x0)return{'success':![],'message':_0x5acb0a(0x1a7),'refreshed':0x0};const _0x14f8cb=_0x52bf9b[_0x5acb0a(0x1cf)](_0x241c26=>_0x241c26[_0x5acb0a(0x1ec)]('ey')),_0x43b761=_0x52bf9b[_0x5acb0a(0x1cf)](_0x1be953=>_0x1be953['includes'](_0x5acb0a(0x1aa)));logger[_0x5acb0a(0x1f3)](_0x5acb0a(0x1d9)+_0x14f8cb[_0x5acb0a(0x1fa)]+_0x5acb0a(0x1ed)),logger[_0x5acb0a(0x1f3)]('提取到\x20'+_0x43b761[_0x5acb0a(0x1fa)]+_0x5acb0a(0x14e));const _0x2eb4b7=process['env']['COOKIE_REFRESH_MODE']||_0x5acb0a(0x194);_0x2eb4b7===_0x5acb0a(0x196)?(logger['info'](_0x5acb0a(0x1f9)),markExistingCookiesAsInvalid(_0xf79222)):logger[_0x5acb0a(0x1f3)](_0x5acb0a(0x15d));const _0x5519f1=addNewCookiesToSystem(_0xf79222,_0x52bf9b);return cleanupTempFiles(),{'success':!![],'message':'成功添加\x20'+_0x5519f1+_0x5acb0a(0x1a0)+_0x14f8cb['length']+_0x5acb0a(0x192)+_0x43b761['length']+')','refreshed':_0x5519f1};}catch(_0x4e2d7f){return logger['error'](_0x5acb0a(0x1d3),_0x4e2d7f),{'success':![],'message':_0x5acb0a(0x149)+_0x4e2d7f[_0x5acb0a(0x168)],'refreshed':0x0};}}module['exports']={'autoRefreshCookies':autoRefreshCookies,'checkApiKeyNeedRefresh':checkApiKeyNeedRefresh,'getLatestArtifact':getLatestArtifact,'downloadArtifact':downloadArtifact,'extractArtifact':extractArtifact,'extractCookiesFromCsvFile':extractCookiesFromCsvFile,'addNewCookiesToSystem':addNewCookiesToSystem,'cleanupTempFiles':cleanupTempFiles,'triggerWorkflow':triggerWorkflow,'markExistingCookiesAsInvalid':markExistingCookiesAsInvalid};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const fs = require('fs');
|
2 |
+
const path = require('path');
|
3 |
+
const csv = require('csv-parser');
|
4 |
+
const axios = require('axios');
|
5 |
+
const AdmZip = require('adm-zip');
|
6 |
+
const { Octokit } = require('@octokit/rest');
|
7 |
+
const keyManager = require('./keyManager');
|
8 |
+
const config = require('../config/config');
|
9 |
+
const { extractCookiesFromCsv } = require('./extractCookieFromCsv');
|
10 |
+
const logger = require('./logger');
|
11 |
+
|
12 |
+
// GitHub 仓库信息从环境变量中获取
|
13 |
+
const GITHUB_OWNER = process.env.GITHUB_OWNER || 'liuw1535';
|
14 |
+
const GITHUB_REPO = process.env.GITHUB_REPO || 'Cursor-Register';
|
15 |
+
const GITHUB_TOKEN = process.env.GITHUB_TOKEN; // 需要在环境变量中设置
|
16 |
+
const GITHUB_WORKFLOW_ID = process.env.GITHUB_WORKFLOW_ID || 'register.yml';
|
17 |
+
const TRIGGER_WORKFLOW = process.env.TRIGGER_WORKFLOW === 'true';
|
18 |
+
|
19 |
+
// 下载目��
|
20 |
+
const DOWNLOAD_DIR = path.join(__dirname, '../../downloads');
|
21 |
+
const EXTRACT_DIR = path.join(__dirname, '../../extracted');
|
22 |
+
|
23 |
+
// 确保目录存在
|
24 |
+
function ensureDirectoryExists(dir) {
|
25 |
+
if (!fs.existsSync(dir)) {
|
26 |
+
try {
|
27 |
+
fs.mkdirSync(dir, { recursive: true });
|
28 |
+
logger.info(`创建目录成功: ${dir}`);
|
29 |
+
} catch (err) {
|
30 |
+
logger.error(`创建目录失败: ${dir}`, err);
|
31 |
+
throw err;
|
32 |
+
}
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
// 触发 GitHub Actions 工作流
|
37 |
+
async function triggerWorkflow() {
|
38 |
+
try {
|
39 |
+
if (!GITHUB_TOKEN) {
|
40 |
+
logger.error('未设置 GITHUB_TOKEN,无法触发工作流');
|
41 |
+
return null;
|
42 |
+
}
|
43 |
+
|
44 |
+
logger.info(`正在触发 GitHub Actions 工作流: ${GITHUB_WORKFLOW_ID}...`);
|
45 |
+
const octokit = new Octokit({
|
46 |
+
auth: GITHUB_TOKEN
|
47 |
+
});
|
48 |
+
|
49 |
+
// 从环境变量获取工作流参数
|
50 |
+
const number = process.env.REGISTER_NUMBER || '2';
|
51 |
+
const maxWorkers = process.env.REGISTER_MAX_WORKERS || '1';
|
52 |
+
const emailServer = process.env.REGISTER_EMAIL_SERVER || 'TempEmail';
|
53 |
+
const ingestToOneapi = process.env.REGISTER_INGEST_TO_ONEAPI === 'true';
|
54 |
+
const uploadArtifact = process.env.REGISTER_UPLOAD_ARTIFACT !== 'false'; // 默认为true
|
55 |
+
const useConfigFile = process.env.REGISTER_USE_CONFIG_FILE !== 'false'; // 默认为true
|
56 |
+
const emailConfigs = process.env.REGISTER_EMAIL_CONFIGS || '[]';
|
57 |
+
|
58 |
+
logger.info(`工作流参数: number=${number}, maxWorkers=${maxWorkers}, emailServer=${emailServer}, ingestToOneapi=${ingestToOneapi}, uploadArtifact=${uploadArtifact}, useConfigFile=${useConfigFile}`);
|
59 |
+
|
60 |
+
// 获取触发前的最新工作流ID,用于后续识别新触发的工作流
|
61 |
+
const { data: beforeWorkflowRuns } = await octokit.actions.listWorkflowRuns({
|
62 |
+
owner: GITHUB_OWNER,
|
63 |
+
repo: GITHUB_REPO,
|
64 |
+
workflow_id: GITHUB_WORKFLOW_ID,
|
65 |
+
per_page: 1
|
66 |
+
});
|
67 |
+
|
68 |
+
const latestWorkflowIdBefore = beforeWorkflowRuns.workflow_runs && beforeWorkflowRuns.workflow_runs.length > 0
|
69 |
+
? beforeWorkflowRuns.workflow_runs[0].id
|
70 |
+
: 0;
|
71 |
+
|
72 |
+
logger.info(`触发前最新工作流ID: ${latestWorkflowIdBefore}`);
|
73 |
+
|
74 |
+
// 触发工作流
|
75 |
+
const response = await octokit.actions.createWorkflowDispatch({
|
76 |
+
owner: GITHUB_OWNER,
|
77 |
+
repo: GITHUB_REPO,
|
78 |
+
workflow_id: GITHUB_WORKFLOW_ID,
|
79 |
+
ref: 'main', // 默认使用 main 分支,可以根据需要修改
|
80 |
+
inputs: {
|
81 |
+
number: number,
|
82 |
+
max_workers: maxWorkers,
|
83 |
+
email_server: emailServer,
|
84 |
+
ingest_to_oneapi: ingestToOneapi.toString(),
|
85 |
+
upload_artifact: uploadArtifact.toString(),
|
86 |
+
use_config_file: useConfigFile.toString(),
|
87 |
+
email_configs: emailConfigs
|
88 |
+
}
|
89 |
+
});
|
90 |
+
|
91 |
+
logger.info('工作流触发成功,等待工作流开始运行...');
|
92 |
+
|
93 |
+
// 等待新工作流出现并获取其ID
|
94 |
+
let newWorkflowRunId = null;
|
95 |
+
let findAttempts = 0;
|
96 |
+
const maxFindAttempts = 30; // 最多等待30次,每次5秒
|
97 |
+
|
98 |
+
while (findAttempts < maxFindAttempts && !newWorkflowRunId) {
|
99 |
+
findAttempts++;
|
100 |
+
logger.info(`查找新触发的工作流,尝试 ${findAttempts}/${maxFindAttempts}...`);
|
101 |
+
|
102 |
+
try {
|
103 |
+
const { data: afterWorkflowRuns } = await octokit.actions.listWorkflowRuns({
|
104 |
+
owner: GITHUB_OWNER,
|
105 |
+
repo: GITHUB_REPO,
|
106 |
+
workflow_id: GITHUB_WORKFLOW_ID,
|
107 |
+
per_page: 5
|
108 |
+
});
|
109 |
+
|
110 |
+
if (afterWorkflowRuns.workflow_runs && afterWorkflowRuns.workflow_runs.length > 0) {
|
111 |
+
// 查找ID大于之前最新工作流ID的工作流(即新触发的工作流)
|
112 |
+
const newWorkflow = afterWorkflowRuns.workflow_runs.find(run => run.id > latestWorkflowIdBefore);
|
113 |
+
if (newWorkflow) {
|
114 |
+
newWorkflowRunId = newWorkflow.id;
|
115 |
+
logger.info(`找到新触发的工作流,ID: ${newWorkflowRunId}, 状态: ${newWorkflow.status}`);
|
116 |
+
}
|
117 |
+
}
|
118 |
+
} catch (error) {
|
119 |
+
logger.error(`查找工作流时出错 (尝试 ${findAttempts}/${maxFindAttempts}): ${error.message}`);
|
120 |
+
// 出错时继续尝试,不中断循环
|
121 |
+
}
|
122 |
+
|
123 |
+
if (!newWorkflowRunId) {
|
124 |
+
// 等待5秒后再次检查
|
125 |
+
await new Promise(resolve => setTimeout(resolve, 5000));
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
if (!newWorkflowRunId) {
|
130 |
+
logger.info('未能找到新触发的工作流,可能触发失败');
|
131 |
+
return null;
|
132 |
+
}
|
133 |
+
|
134 |
+
// 等待工作流完成
|
135 |
+
let attempts = 0;
|
136 |
+
const maxAttempts = 120; // 最多等待120次,每次30秒,总共60分钟
|
137 |
+
let consecutiveErrors = 0;
|
138 |
+
const maxConsecutiveErrors = 5; // 最多允许连续5次错误
|
139 |
+
|
140 |
+
while (attempts < maxAttempts) {
|
141 |
+
attempts++;
|
142 |
+
logger.info(`等待工作流完成,尝试 ${attempts}/${maxAttempts}...`);
|
143 |
+
|
144 |
+
try {
|
145 |
+
// 获取工作流状态
|
146 |
+
const { data: workflowRun } = await octokit.actions.getWorkflowRun({
|
147 |
+
owner: GITHUB_OWNER,
|
148 |
+
repo: GITHUB_REPO,
|
149 |
+
run_id: newWorkflowRunId
|
150 |
+
});
|
151 |
+
|
152 |
+
// 重置连续错误计数
|
153 |
+
consecutiveErrors = 0;
|
154 |
+
|
155 |
+
logger.info(`工作流状态: ${workflowRun.status}, 结果: ${workflowRun.conclusion || '进行中'}`);
|
156 |
+
|
157 |
+
// 检查工作流是否完成
|
158 |
+
if (workflowRun.status === 'completed') {
|
159 |
+
if (workflowRun.conclusion === 'success') {
|
160 |
+
logger.info(`工作流运行成功,ID: ${newWorkflowRunId}`);
|
161 |
+
return workflowRun;
|
162 |
+
} else {
|
163 |
+
logger.info(`工作流运行失败,结果: ${workflowRun.conclusion}`);
|
164 |
+
return null;
|
165 |
+
}
|
166 |
+
}
|
167 |
+
} catch (error) {
|
168 |
+
consecutiveErrors++;
|
169 |
+
logger.error(`获取工作流状态时出错 (尝试 ${attempts}/${maxAttempts}, 连续错误 ${consecutiveErrors}/${maxConsecutiveErrors}): ${error.message}`);
|
170 |
+
|
171 |
+
// 如果连续错误次数超过阈值,则放弃
|
172 |
+
if (consecutiveErrors >= maxConsecutiveErrors) {
|
173 |
+
logger.error(`连续错误次数超过阈值 (${maxConsecutiveErrors}),放弃等待`);
|
174 |
+
throw new Error(`连续 ${maxConsecutiveErrors} 次获取工作流状态失败: ${error.message}`);
|
175 |
+
}
|
176 |
+
|
177 |
+
// 错误后等待时间稍微延长
|
178 |
+
await new Promise(resolve => setTimeout(resolve, 10000));
|
179 |
+
// 继续循环,不中断
|
180 |
+
continue;
|
181 |
+
}
|
182 |
+
|
183 |
+
// 等待30秒后再次检查
|
184 |
+
await new Promise(resolve => setTimeout(resolve, 30000));
|
185 |
+
}
|
186 |
+
|
187 |
+
logger.info('等待工作流完成超时');
|
188 |
+
return null;
|
189 |
+
} catch (error) {
|
190 |
+
logger.error('触发工作流失败:', error);
|
191 |
+
throw error; // 重新抛出错误,让调用者处理
|
192 |
+
}
|
193 |
+
}
|
194 |
+
|
195 |
+
// 从 GitHub Actions 获取最新的 Artifact
|
196 |
+
async function getLatestArtifact() {
|
197 |
+
try {
|
198 |
+
logger.info('正在连接 GitHub API...');
|
199 |
+
const octokit = new Octokit({
|
200 |
+
auth: GITHUB_TOKEN
|
201 |
+
});
|
202 |
+
|
203 |
+
// 如果配置了自动触发工作流,则先触发工作流
|
204 |
+
let workflowRun = null;
|
205 |
+
if (TRIGGER_WORKFLOW) {
|
206 |
+
logger.info('配置了自动触发工作流,正在触发...');
|
207 |
+
try {
|
208 |
+
workflowRun = await triggerWorkflow();
|
209 |
+
} catch (error) {
|
210 |
+
logger.error('触发工作流过程中出现错误:', error.message);
|
211 |
+
logger.info('尝试继续使用已找到的工作流ID...');
|
212 |
+
|
213 |
+
// 尝试获取最新的工作流,看是否有正在运行的工作流
|
214 |
+
const { data: runningWorkflows } = await octokit.actions.listWorkflowRuns({
|
215 |
+
owner: GITHUB_OWNER,
|
216 |
+
repo: GITHUB_REPO,
|
217 |
+
workflow_id: GITHUB_WORKFLOW_ID,
|
218 |
+
status: 'in_progress',
|
219 |
+
per_page: 5
|
220 |
+
});
|
221 |
+
|
222 |
+
if (runningWorkflows.workflow_runs && runningWorkflows.workflow_runs.length > 0) {
|
223 |
+
// 找到正在运行的工作流
|
224 |
+
const runningWorkflow = runningWorkflows.workflow_runs[0];
|
225 |
+
logger.info(`找到正在运行的工作流,ID: ${runningWorkflow.id}, 状态: ${runningWorkflow.status}`);
|
226 |
+
|
227 |
+
// 等待工作流完成
|
228 |
+
let attempts = 0;
|
229 |
+
const maxAttempts = 120; // 最多等待120次,每次30秒,总共60分钟
|
230 |
+
let consecutiveErrors = 0;
|
231 |
+
const maxConsecutiveErrors = 5; // 最多允许连续5次错误
|
232 |
+
|
233 |
+
while (attempts < maxAttempts) {
|
234 |
+
attempts++;
|
235 |
+
logger.info(`等待工作流完成,尝试 ${attempts}/${maxAttempts}...`);
|
236 |
+
|
237 |
+
try {
|
238 |
+
// 获取工作流状态
|
239 |
+
const { data: currentWorkflow } = await octokit.actions.getWorkflowRun({
|
240 |
+
owner: GITHUB_OWNER,
|
241 |
+
repo: GITHUB_REPO,
|
242 |
+
run_id: runningWorkflow.id
|
243 |
+
});
|
244 |
+
|
245 |
+
// 重置连续错误计数
|
246 |
+
consecutiveErrors = 0;
|
247 |
+
|
248 |
+
logger.info(`工作流状态: ${currentWorkflow.status}, 结果: ${currentWorkflow.conclusion || '进行中'}`);
|
249 |
+
|
250 |
+
// 检查工作流是否完成
|
251 |
+
if (currentWorkflow.status === 'completed') {
|
252 |
+
if (currentWorkflow.conclusion === 'success') {
|
253 |
+
logger.info(`工作流运行成功,ID: ${currentWorkflow.id}`);
|
254 |
+
workflowRun = currentWorkflow;
|
255 |
+
break;
|
256 |
+
} else {
|
257 |
+
logger.info(`工作流运行失败,结果: ${currentWorkflow.conclusion}`);
|
258 |
+
break;
|
259 |
+
}
|
260 |
+
}
|
261 |
+
} catch (err) {
|
262 |
+
consecutiveErrors++;
|
263 |
+
logger.error(`获取工作流状态时出错 (尝试 ${attempts}/${maxAttempts}, 连续错误 ${consecutiveErrors}/${maxConsecutiveErrors}): ${err.message}`);
|
264 |
+
|
265 |
+
// 如果连续错误次数超过阈值,则放弃
|
266 |
+
if (consecutiveErrors >= maxConsecutiveErrors) {
|
267 |
+
logger.error(`连续错误次数超过阈值 (${maxConsecutiveErrors}),放弃等待`);
|
268 |
+
break;
|
269 |
+
}
|
270 |
+
|
271 |
+
// 错误后等待时间稍微延长
|
272 |
+
await new Promise(resolve => setTimeout(resolve, 10000));
|
273 |
+
// 继续循环,不中断
|
274 |
+
continue;
|
275 |
+
}
|
276 |
+
|
277 |
+
// 等待30秒后再次检查
|
278 |
+
await new Promise(resolve => setTimeout(resolve, 30000));
|
279 |
+
}
|
280 |
+
}
|
281 |
+
}
|
282 |
+
|
283 |
+
if (!workflowRun) {
|
284 |
+
logger.info('触发工作流失败或等待超时,尝试获取最新的工作流运行');
|
285 |
+
}
|
286 |
+
}
|
287 |
+
|
288 |
+
// 如果没有触发工作流或触发失败,则获取最新的工作流运行
|
289 |
+
if (!workflowRun) {
|
290 |
+
logger.info('获取最新的工作流运行...');
|
291 |
+
const { data: workflowRuns } = await octokit.actions.listWorkflowRunsForRepo({
|
292 |
+
owner: GITHUB_OWNER,
|
293 |
+
repo: GITHUB_REPO,
|
294 |
+
status: 'success',
|
295 |
+
per_page: 5
|
296 |
+
});
|
297 |
+
|
298 |
+
if (!workflowRuns.workflow_runs || workflowRuns.workflow_runs.length === 0) {
|
299 |
+
logger.info('没有找到成功的工作流运行');
|
300 |
+
return null;
|
301 |
+
}
|
302 |
+
|
303 |
+
// 获取最新成功运行的 Artifacts
|
304 |
+
workflowRun = workflowRuns.workflow_runs[0];
|
305 |
+
}
|
306 |
+
|
307 |
+
logger.info(`找到最新的工作流运行: ${workflowRun.id}`);
|
308 |
+
|
309 |
+
// 等待一段时间,确保Artifact已经上传完成
|
310 |
+
logger.info('等待Artifact上传完成...');
|
311 |
+
await new Promise(resolve => setTimeout(resolve, 10000));
|
312 |
+
|
313 |
+
// 获取工作流的Artifacts
|
314 |
+
let artifacts = null;
|
315 |
+
let artifactAttempts = 0;
|
316 |
+
const maxArtifactAttempts = 10; // 最多尝试10次,每次10秒
|
317 |
+
|
318 |
+
while (artifactAttempts < maxArtifactAttempts && (!artifacts || !artifacts.artifacts || artifacts.artifacts.length === 0)) {
|
319 |
+
artifactAttempts++;
|
320 |
+
logger.info(`尝试获取Artifacts,尝试 ${artifactAttempts}/${maxArtifactAttempts}...`);
|
321 |
+
|
322 |
+
try {
|
323 |
+
const response = await octokit.actions.listWorkflowRunArtifacts({
|
324 |
+
owner: GITHUB_OWNER,
|
325 |
+
repo: GITHUB_REPO,
|
326 |
+
run_id: workflowRun.id
|
327 |
+
});
|
328 |
+
|
329 |
+
artifacts = response.data;
|
330 |
+
} catch (error) {
|
331 |
+
logger.error(`获取Artifacts时出错 (尝试 ${artifactAttempts}/${maxArtifactAttempts}): ${error.message}`);
|
332 |
+
// 出错时继续尝试,不中断循环
|
333 |
+
}
|
334 |
+
|
335 |
+
if (!artifacts || !artifacts.artifacts || artifacts.artifacts.length === 0) {
|
336 |
+
logger.info('暂时没有找到Artifacts,等待10秒后重试...');
|
337 |
+
await new Promise(resolve => setTimeout(resolve, 10000));
|
338 |
+
}
|
339 |
+
}
|
340 |
+
|
341 |
+
if (!artifacts || !artifacts.artifacts || artifacts.artifacts.length === 0) {
|
342 |
+
logger.info('没有找到Artifacts,可能工作流没有生成Artifact');
|
343 |
+
return null;
|
344 |
+
}
|
345 |
+
|
346 |
+
logger.info(`找到 ${artifacts.artifacts.length} 个Artifacts`);
|
347 |
+
|
348 |
+
// 查找 Account info Artifact
|
349 |
+
const accountInfoArtifact = artifacts.artifacts.find(artifact =>
|
350 |
+
artifact.name.toLowerCase().includes('account info'));
|
351 |
+
|
352 |
+
if (!accountInfoArtifact) {
|
353 |
+
logger.info('没有找到 Account info Artifact');
|
354 |
+
return null;
|
355 |
+
}
|
356 |
+
|
357 |
+
logger.info(`找到 Account info Artifact: ${accountInfoArtifact.id}`);
|
358 |
+
return accountInfoArtifact;
|
359 |
+
} catch (error) {
|
360 |
+
logger.error('获取 Artifact 失败:', error);
|
361 |
+
return null;
|
362 |
+
}
|
363 |
+
}
|
364 |
+
|
365 |
+
// 下载 Artifact
|
366 |
+
async function downloadArtifact(artifact) {
|
367 |
+
let downloadAttempts = 0;
|
368 |
+
const maxDownloadAttempts = 5; // 最多尝试5次下载
|
369 |
+
|
370 |
+
while (downloadAttempts < maxDownloadAttempts) {
|
371 |
+
downloadAttempts++;
|
372 |
+
try {
|
373 |
+
logger.info(`开始下载 Artifact: ${artifact.id}... (尝试 ${downloadAttempts}/${maxDownloadAttempts})`);
|
374 |
+
ensureDirectoryExists(DOWNLOAD_DIR);
|
375 |
+
|
376 |
+
const octokit = new Octokit({
|
377 |
+
auth: GITHUB_TOKEN
|
378 |
+
});
|
379 |
+
|
380 |
+
// 获取下载 URL
|
381 |
+
const { url } = await octokit.actions.downloadArtifact({
|
382 |
+
owner: GITHUB_OWNER,
|
383 |
+
repo: GITHUB_REPO,
|
384 |
+
artifact_id: artifact.id,
|
385 |
+
archive_format: 'zip'
|
386 |
+
});
|
387 |
+
|
388 |
+
// 下载 zip 文件
|
389 |
+
const zipFilePath = path.join(DOWNLOAD_DIR, `${artifact.id}.zip`);
|
390 |
+
const response = await axios({
|
391 |
+
method: 'get',
|
392 |
+
url: url,
|
393 |
+
responseType: 'arraybuffer',
|
394 |
+
timeout: 60000 // 设置60秒超时
|
395 |
+
});
|
396 |
+
|
397 |
+
fs.writeFileSync(zipFilePath, response.data);
|
398 |
+
logger.info(`Artifact 下载完成: ${zipFilePath}`);
|
399 |
+
return zipFilePath;
|
400 |
+
} catch (error) {
|
401 |
+
logger.error(`下载 Artifact 失败 (尝试 ${downloadAttempts}/${maxDownloadAttempts}): ${error.message}`);
|
402 |
+
|
403 |
+
if (downloadAttempts >= maxDownloadAttempts) {
|
404 |
+
logger.error('达到最大尝试次数,放弃下载');
|
405 |
+
return null;
|
406 |
+
}
|
407 |
+
|
408 |
+
// 等待一段时间后重试
|
409 |
+
const retryDelay = 10000; // 10秒
|
410 |
+
logger.info(`等待 ${retryDelay/1000} 秒后重试...`);
|
411 |
+
await new Promise(resolve => setTimeout(resolve, retryDelay));
|
412 |
+
}
|
413 |
+
}
|
414 |
+
|
415 |
+
return null;
|
416 |
+
}
|
417 |
+
|
418 |
+
// 解压 Artifact
|
419 |
+
async function extractArtifact(zipFilePath) {
|
420 |
+
let extractAttempts = 0;
|
421 |
+
const maxExtractAttempts = 3; // 最多尝试3次解压
|
422 |
+
|
423 |
+
while (extractAttempts < maxExtractAttempts) {
|
424 |
+
extractAttempts++;
|
425 |
+
try {
|
426 |
+
logger.info(`开始解压 Artifact: ${zipFilePath}... (尝试 ${extractAttempts}/${maxExtractAttempts})`);
|
427 |
+
ensureDirectoryExists(EXTRACT_DIR);
|
428 |
+
|
429 |
+
const zip = new AdmZip(zipFilePath);
|
430 |
+
zip.extractAllTo(EXTRACT_DIR, true);
|
431 |
+
logger.info(`Artifact 解压完成: ${EXTRACT_DIR}`);
|
432 |
+
|
433 |
+
// 查找 token CSV 文件
|
434 |
+
const files = fs.readdirSync(EXTRACT_DIR);
|
435 |
+
const tokenFile = files.find(file => file.startsWith('token_') && file.endsWith('.csv'));
|
436 |
+
|
437 |
+
if (!tokenFile) {
|
438 |
+
logger.info('没有找到 token CSV 文件');
|
439 |
+
|
440 |
+
if (extractAttempts >= maxExtractAttempts) {
|
441 |
+
return null;
|
442 |
+
}
|
443 |
+
|
444 |
+
// 等待一段时间后重试
|
445 |
+
const retryDelay = 5000; // 5秒
|
446 |
+
logger.info(`等待 ${retryDelay/1000} 秒后重试...`);
|
447 |
+
await new Promise(resolve => setTimeout(resolve, retryDelay));
|
448 |
+
continue;
|
449 |
+
}
|
450 |
+
|
451 |
+
logger.info(`找到 token CSV 文件: ${tokenFile}`);
|
452 |
+
return path.join(EXTRACT_DIR, tokenFile);
|
453 |
+
} catch (error) {
|
454 |
+
logger.error(`解压 Artifact 失败 (尝试 ${extractAttempts}/${maxExtractAttempts}): ${error.message}`);
|
455 |
+
|
456 |
+
if (extractAttempts >= maxExtractAttempts) {
|
457 |
+
logger.error('达到最大尝试次数,放弃解压');
|
458 |
+
return null;
|
459 |
+
}
|
460 |
+
|
461 |
+
// 等待一段时间后重试
|
462 |
+
const retryDelay = 5000; // 5秒
|
463 |
+
logger.info(`等待 ${retryDelay/1000} 秒后重试...`);
|
464 |
+
await new Promise(resolve => setTimeout(resolve, retryDelay));
|
465 |
+
}
|
466 |
+
}
|
467 |
+
|
468 |
+
return null;
|
469 |
+
}
|
470 |
+
|
471 |
+
/**
|
472 |
+
* 从CSV文件中提取cookies
|
473 |
+
* @param {string} csvFilePath - CSV文件路径
|
474 |
+
* @returns {Promise<string[]>} - 提取到的cookie数组
|
475 |
+
*/
|
476 |
+
async function extractCookiesFromCsvFile(csvFilePath) {
|
477 |
+
const maxExtractAttempts = 3;
|
478 |
+
let attempt = 1;
|
479 |
+
|
480 |
+
while (attempt <= maxExtractAttempts) {
|
481 |
+
logger.info(`尝试从CSV文件提取cookies (尝试 ${attempt}/${maxExtractAttempts})...`);
|
482 |
+
|
483 |
+
try {
|
484 |
+
// 读取文件内容
|
485 |
+
if (!fs.existsSync(csvFilePath)) {
|
486 |
+
logger.error(`CSV文件不存在: ${csvFilePath}`);
|
487 |
+
return [];
|
488 |
+
}
|
489 |
+
|
490 |
+
// 读取文件内容并处理可能的换行符
|
491 |
+
let fileContent = fs.readFileSync(csvFilePath, 'utf8');
|
492 |
+
fileContent = fileContent.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
493 |
+
|
494 |
+
// 首先尝试直接从文件内容中提取所有可能的cookie
|
495 |
+
const cookies = [];
|
496 |
+
|
497 |
+
// 1. 检查是否有JWT格式的token (新格式)
|
498 |
+
const jwtRegex = /ey[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
|
499 |
+
const jwtMatches = fileContent.match(jwtRegex);
|
500 |
+
|
501 |
+
if (jwtMatches && jwtMatches.length > 0) {
|
502 |
+
logger.info(`直接从文件内容中提取到 ${jwtMatches.length} 个JWT token格式的Cookie`);
|
503 |
+
jwtMatches.forEach(match => {
|
504 |
+
if (!cookies.includes(match)) {
|
505 |
+
cookies.push(match);
|
506 |
+
}
|
507 |
+
});
|
508 |
+
}
|
509 |
+
|
510 |
+
// 2. 检查是否有旧格式的cookie
|
511 |
+
if (fileContent.includes('user_')) {
|
512 |
+
logger.info('文件包含旧格式cookie标识"user_"');
|
513 |
+
|
514 |
+
// 使用旧的提取函数尝试提取
|
515 |
+
try {
|
516 |
+
const oldFormatCookies = await extractCookiesFromCsv(csvFilePath);
|
517 |
+
if (oldFormatCookies && oldFormatCookies.length > 0) {
|
518 |
+
logger.info(`通过提取模块获取到 ${oldFormatCookies.length} 个cookie`);
|
519 |
+
oldFormatCookies.forEach(cookie => {
|
520 |
+
if (!cookies.includes(cookie)) {
|
521 |
+
cookies.push(cookie);
|
522 |
+
}
|
523 |
+
});
|
524 |
+
}
|
525 |
+
} catch (e) {
|
526 |
+
logger.warn('通过提取模块获取cookie失败:', e.message);
|
527 |
+
}
|
528 |
+
}
|
529 |
+
|
530 |
+
// 3. 如果找到了cookie,返回结果
|
531 |
+
if (cookies.length > 0) {
|
532 |
+
const newFormatCount = cookies.filter(c => c.startsWith('ey')).length;
|
533 |
+
const oldFormatCount = cookies.filter(c => c.includes('%3A%3A')).length;
|
534 |
+
|
535 |
+
logger.info(`总共找到 ${cookies.length} 个cookie`);
|
536 |
+
logger.info(`新格式cookie(ey开头): ${newFormatCount}个`);
|
537 |
+
logger.info(`旧格式cookie(包含%3A%3A): ${oldFormatCount}个`);
|
538 |
+
logger.info(`其他格式cookie: ${cookies.length - newFormatCount - oldFormatCount}个`);
|
539 |
+
|
540 |
+
return cookies;
|
541 |
+
}
|
542 |
+
|
543 |
+
logger.warn(`未能从文件中提取到任何cookie (尝试 ${attempt}/${maxExtractAttempts})`);
|
544 |
+
} catch (error) {
|
545 |
+
logger.error(`从CSV文件提取cookies时出错 (尝试 ${attempt}/${maxExtractAttempts}):`, error);
|
546 |
+
}
|
547 |
+
|
548 |
+
attempt++;
|
549 |
+
if (attempt <= maxExtractAttempts) {
|
550 |
+
logger.info(`等待5秒后重试...`);
|
551 |
+
await new Promise(resolve => setTimeout(resolve, 5000));
|
552 |
+
}
|
553 |
+
}
|
554 |
+
|
555 |
+
logger.error(`在 ${maxExtractAttempts} 次尝试后未能从CSV文件提取到cookies`);
|
556 |
+
return [];
|
557 |
+
}
|
558 |
+
|
559 |
+
// 将新的有效cookie添加到系统中
|
560 |
+
function addNewCookiesToSystem(apiKey, newCookies) {
|
561 |
+
try {
|
562 |
+
logger.info(`准备添加 ${newCookies.length} 个新cookie到系统中`);
|
563 |
+
|
564 |
+
// 获取当前的cookies
|
565 |
+
const currentCookies = keyManager.getAllCookiesForApiKey(apiKey) || [];
|
566 |
+
logger.info(`当前API密钥 ${apiKey} 有 ${currentCookies.length} 个cookies`);
|
567 |
+
|
568 |
+
// 获取无效的cookies
|
569 |
+
const invalidCookies = keyManager.getInvalidCookies() || [];
|
570 |
+
logger.info(`系统中有 ${invalidCookies.length || 0} 个无效cookies`);
|
571 |
+
|
572 |
+
// 过滤出新的有效cookie
|
573 |
+
let newValidCookies = [];
|
574 |
+
|
575 |
+
// 检查invalidCookies的类型并相应处理
|
576 |
+
if (invalidCookies instanceof Set) {
|
577 |
+
newValidCookies = newCookies.filter(cookie =>
|
578 |
+
!currentCookies.includes(cookie) && !invalidCookies.has(cookie)
|
579 |
+
);
|
580 |
+
} else if (Array.isArray(invalidCookies)) {
|
581 |
+
newValidCookies = newCookies.filter(cookie =>
|
582 |
+
!currentCookies.includes(cookie) && !invalidCookies.includes(cookie)
|
583 |
+
);
|
584 |
+
} else if (invalidCookies && typeof invalidCookies === 'object') {
|
585 |
+
// 如果是普通对象,检查cookie是否作为键存在
|
586 |
+
newValidCookies = newCookies.filter(cookie =>
|
587 |
+
!currentCookies.includes(cookie) && !(cookie in invalidCookies)
|
588 |
+
);
|
589 |
+
} else {
|
590 |
+
// 如果invalidCookies不是预期的类型,只过滤当前cookies
|
591 |
+
newValidCookies = newCookies.filter(cookie => !currentCookies.includes(cookie));
|
592 |
+
}
|
593 |
+
|
594 |
+
logger.info(`过滤后有 ${newValidCookies.length} 个新的有效cookies`);
|
595 |
+
|
596 |
+
// 验证cookie是否完整
|
597 |
+
const validatedCookies = newValidCookies.filter(cookie => {
|
598 |
+
// 检查是否是新格式的JWT token (ey开头)
|
599 |
+
if (cookie.startsWith('ey') && cookie.includes('.')) {
|
600 |
+
const parts = cookie.split('.');
|
601 |
+
// 检查JWT是否包含三个部分
|
602 |
+
if (parts.length !== 3) {
|
603 |
+
logger.warn(`跳过不完整的JWT cookie (新格式): ${cookie}`);
|
604 |
+
return false;
|
605 |
+
}
|
606 |
+
return true;
|
607 |
+
}
|
608 |
+
// 检查旧格式cookie是否包含JWT的三个部分
|
609 |
+
else if (cookie.includes('%3A%3A')) {
|
610 |
+
const parts = cookie.split('%3A%3A');
|
611 |
+
if (parts.length === 2) {
|
612 |
+
const jwt = parts[1];
|
613 |
+
// 检查JWT是否包含点(表示JWT的三个部分)
|
614 |
+
if (!jwt.includes('.') || jwt.split('.').length !== 3) {
|
615 |
+
logger.warn(`跳过不完整的cookie (旧格式): ${cookie}`);
|
616 |
+
return false;
|
617 |
+
}
|
618 |
+
}
|
619 |
+
}
|
620 |
+
return true;
|
621 |
+
});
|
622 |
+
|
623 |
+
logger.info(`验证完整性后有 ${validatedCookies.length} 个有效cookies`);
|
624 |
+
|
625 |
+
if (validatedCookies.length > 0) {
|
626 |
+
// 添加新的有效cookie到系统
|
627 |
+
keyManager.addOrUpdateApiKey(apiKey, [...currentCookies, ...validatedCookies]);
|
628 |
+
logger.info(`成功添加 ${validatedCookies.length} 个新cookie到API密钥 ${apiKey}`);
|
629 |
+
return validatedCookies.length; // 返回添加的cookie数量
|
630 |
+
} else {
|
631 |
+
logger.info(`没有新的有效cookie需要添加到API密钥 ${apiKey}`);
|
632 |
+
return 0; // 没有添加cookie,返回0
|
633 |
+
}
|
634 |
+
} catch (error) {
|
635 |
+
logger.error('添加新cookie到系统时出错:', error);
|
636 |
+
return 0; // 出错时返回0
|
637 |
+
}
|
638 |
+
}
|
639 |
+
|
640 |
+
// 清理临时文件
|
641 |
+
function cleanupTempFiles() {
|
642 |
+
try {
|
643 |
+
logger.info('开始清理临时文件...');
|
644 |
+
|
645 |
+
// 清理下载目录
|
646 |
+
if (fs.existsSync(DOWNLOAD_DIR)) {
|
647 |
+
fs.readdirSync(DOWNLOAD_DIR).forEach(file => {
|
648 |
+
fs.unlinkSync(path.join(DOWNLOAD_DIR, file));
|
649 |
+
});
|
650 |
+
}
|
651 |
+
|
652 |
+
// 清理解压目录
|
653 |
+
if (fs.existsSync(EXTRACT_DIR)) {
|
654 |
+
fs.readdirSync(EXTRACT_DIR).forEach(file => {
|
655 |
+
fs.unlinkSync(path.join(EXTRACT_DIR, file));
|
656 |
+
});
|
657 |
+
}
|
658 |
+
|
659 |
+
logger.info('临时文件清理完成');
|
660 |
+
} catch (error) {
|
661 |
+
logger.error('清理临时文件失败:', error);
|
662 |
+
}
|
663 |
+
}
|
664 |
+
|
665 |
+
// 检查 API Key 是否需要补充 Cookie
|
666 |
+
function checkApiKeyNeedRefresh(apiKey, minCookieCount = config.refresh.minCookieCount) {
|
667 |
+
const cookies = keyManager.getAllCookiesForApiKey(apiKey);
|
668 |
+
return cookies.length < minCookieCount;
|
669 |
+
}
|
670 |
+
|
671 |
+
// 将现有cookie全部设为无效并从API Key中移除
|
672 |
+
function markExistingCookiesAsInvalid(apiKey) {
|
673 |
+
try {
|
674 |
+
// 获取当前API Key的所有cookie
|
675 |
+
const currentCookies = keyManager.getAllCookiesForApiKey(apiKey) || [];
|
676 |
+
logger.info(`正在将API Key ${apiKey} 的 ${currentCookies.length} 个现有cookie标记为无效...`);
|
677 |
+
|
678 |
+
// 如果没有cookie,直接返回
|
679 |
+
if (currentCookies.length === 0) {
|
680 |
+
logger.info(`API Key ${apiKey} 没有现有cookie,无需标记为无效`);
|
681 |
+
return 0;
|
682 |
+
}
|
683 |
+
|
684 |
+
// 获取无效cookie列表
|
685 |
+
const invalidCookies = keyManager.getInvalidCookies();
|
686 |
+
let markedCount = 0;
|
687 |
+
|
688 |
+
// 遍历cookie并添加到无效列表
|
689 |
+
for (const cookie of currentCookies) {
|
690 |
+
// 将cookie添加到无效集合中
|
691 |
+
if (invalidCookies instanceof Set) {
|
692 |
+
invalidCookies.add(cookie);
|
693 |
+
}
|
694 |
+
markedCount++;
|
695 |
+
}
|
696 |
+
|
697 |
+
// 保存无效cookie到文件
|
698 |
+
keyManager.saveInvalidCookiesToFile();
|
699 |
+
|
700 |
+
// 清空当前API Key的cookie列表
|
701 |
+
keyManager.addOrUpdateApiKey(apiKey, []);
|
702 |
+
|
703 |
+
// 保存更新后的API Keys
|
704 |
+
keyManager.saveApiKeysToFile();
|
705 |
+
|
706 |
+
logger.info(`已将API Key ${apiKey} 的 ${markedCount} 个cookie标记为无效并从API Key中移除`);
|
707 |
+
return markedCount;
|
708 |
+
} catch (error) {
|
709 |
+
logger.error(`标记现有cookie为无效时出错:`, error);
|
710 |
+
return 0;
|
711 |
+
}
|
712 |
+
}
|
713 |
+
|
714 |
+
// 主函数:自动刷新 Cookie
|
715 |
+
async function autoRefreshCookies(apiKey, minCookieCount = config.refresh.minCookieCount) {
|
716 |
+
logger.info(`开始自动刷新 Cookie,目标 API Key: ${apiKey},最小 Cookie 数量: ${minCookieCount}`);
|
717 |
+
|
718 |
+
try {
|
719 |
+
// 检查是否需要刷新
|
720 |
+
if (!checkApiKeyNeedRefresh(apiKey, minCookieCount)) {
|
721 |
+
logger.info(`API Key ${apiKey} 的 Cookie 数量足够,不需要刷新`);
|
722 |
+
return {
|
723 |
+
success: true,
|
724 |
+
message: '当前 Cookie 数量足够,不需要刷新',
|
725 |
+
refreshed: 0
|
726 |
+
};
|
727 |
+
}
|
728 |
+
|
729 |
+
// 获取最新的 Artifact
|
730 |
+
const artifact = await getLatestArtifact();
|
731 |
+
if (!artifact) {
|
732 |
+
return {
|
733 |
+
success: false,
|
734 |
+
message: '获取 Artifact 失败',
|
735 |
+
refreshed: 0
|
736 |
+
};
|
737 |
+
}
|
738 |
+
|
739 |
+
// 下载 Artifact
|
740 |
+
const zipFilePath = await downloadArtifact(artifact);
|
741 |
+
if (!zipFilePath) {
|
742 |
+
return {
|
743 |
+
success: false,
|
744 |
+
message: '下载 Artifact 失败',
|
745 |
+
refreshed: 0
|
746 |
+
};
|
747 |
+
}
|
748 |
+
|
749 |
+
// 解压 Artifact
|
750 |
+
const csvFilePath = await extractArtifact(zipFilePath);
|
751 |
+
if (!csvFilePath) {
|
752 |
+
return {
|
753 |
+
success: false,
|
754 |
+
message: '解压 Artifact 失败',
|
755 |
+
refreshed: 0
|
756 |
+
};
|
757 |
+
}
|
758 |
+
|
759 |
+
// 提取 Cookie
|
760 |
+
const cookies = await extractCookiesFromCsvFile(csvFilePath);
|
761 |
+
if (cookies.length === 0) {
|
762 |
+
return {
|
763 |
+
success: false,
|
764 |
+
message: '没有找到有效的 Cookie',
|
765 |
+
refreshed: 0
|
766 |
+
};
|
767 |
+
}
|
768 |
+
|
769 |
+
// 分析提取到的cookie格式
|
770 |
+
const newFormatCookies = cookies.filter(cookie => cookie.startsWith('ey'));
|
771 |
+
const oldFormatCookies = cookies.filter(cookie => cookie.includes('%3A%3A'));
|
772 |
+
logger.info(`提取到 ${newFormatCookies.length} 个新格式cookie(ey开头)`);
|
773 |
+
logger.info(`提取到 ${oldFormatCookies.length} 个旧格式cookie(包含%3A%3A)`);
|
774 |
+
|
775 |
+
// 根据配置决定是否将现有cookie标记为无效
|
776 |
+
const refreshMode = process.env.COOKIE_REFRESH_MODE || 'append';
|
777 |
+
|
778 |
+
if (refreshMode === 'replace') {
|
779 |
+
// 将现有cookie标记为无效并从API Key中移除
|
780 |
+
logger.info('使用替换模式: 将现有cookie标记为无效');
|
781 |
+
markExistingCookiesAsInvalid(apiKey);
|
782 |
+
} else {
|
783 |
+
logger.info('使用追加模式: 保留现有cookie,只添加新cookie');
|
784 |
+
}
|
785 |
+
|
786 |
+
// 添加新的 Cookie 到系统
|
787 |
+
const addedCount = addNewCookiesToSystem(apiKey, cookies);
|
788 |
+
|
789 |
+
// 清理临时文件
|
790 |
+
cleanupTempFiles();
|
791 |
+
|
792 |
+
return {
|
793 |
+
success: true,
|
794 |
+
message: `成功添加 ${addedCount} 个新 Cookie (新格式: ${newFormatCookies.length}, 旧格式: ${oldFormatCookies.length})`,
|
795 |
+
refreshed: addedCount
|
796 |
+
};
|
797 |
+
} catch (error) {
|
798 |
+
logger.error('自动刷新 Cookie 失败:', error);
|
799 |
+
return {
|
800 |
+
success: false,
|
801 |
+
message: `刷新失败: ${error.message}`,
|
802 |
+
refreshed: 0
|
803 |
+
};
|
804 |
+
}
|
805 |
+
}
|
806 |
+
|
807 |
+
module.exports = {
|
808 |
+
autoRefreshCookies,
|
809 |
+
checkApiKeyNeedRefresh,
|
810 |
+
getLatestArtifact,
|
811 |
+
downloadArtifact,
|
812 |
+
extractArtifact,
|
813 |
+
extractCookiesFromCsvFile,
|
814 |
+
addNewCookiesToSystem,
|
815 |
+
cleanupTempFiles,
|
816 |
+
triggerWorkflow,
|
817 |
+
markExistingCookiesAsInvalid
|
818 |
+
};
|
src/utils/envChecker.js
CHANGED
@@ -1 +1,89 @@
|
|
1 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const fs = require('fs');
|
2 |
+
const path = require('path');
|
3 |
+
|
4 |
+
// 添加自己的简单日志函数,防止循环依赖
|
5 |
+
function log(level, message) {
|
6 |
+
// 只在控制台输出,不写入文件
|
7 |
+
const timestamp = new Date().toISOString();
|
8 |
+
if (level === 'ERROR') {
|
9 |
+
console.error(`[ERROR] ${timestamp} ${message}`);
|
10 |
+
} else if (level === 'WARN') {
|
11 |
+
console.warn(`[WARN] ${timestamp} ${message}`);
|
12 |
+
} else {
|
13 |
+
console.log(`[INFO] ${timestamp} ${message}`);
|
14 |
+
}
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* 检查 .env 文件是否存在
|
19 |
+
* @returns {boolean} 文件是否存在
|
20 |
+
*/
|
21 |
+
function checkEnvFileExists() {
|
22 |
+
const envPath = path.resolve(process.cwd(), '.env');
|
23 |
+
return fs.existsSync(envPath);
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* 检查必要的环境变量是否已设置
|
28 |
+
* @returns {Object} 检查结果,包含是否通过和缺失的变量列表
|
29 |
+
*/
|
30 |
+
function checkRequiredEnvVars() {
|
31 |
+
// 定义必要的环境变量列表
|
32 |
+
const requiredVars = [
|
33 |
+
'API_KEYS', // API Keys 配置
|
34 |
+
];
|
35 |
+
|
36 |
+
// 如果启用了自动刷新,则需要检查相关配置
|
37 |
+
if (process.env.ENABLE_AUTO_REFRESH === 'true') {
|
38 |
+
requiredVars.push(
|
39 |
+
'GITHUB_TOKEN',
|
40 |
+
'GITHUB_OWNER',
|
41 |
+
'GITHUB_REPO',
|
42 |
+
'GITHUB_WORKFLOW_ID',
|
43 |
+
'TRIGGER_WORKFLOW'
|
44 |
+
);
|
45 |
+
}
|
46 |
+
|
47 |
+
// 检查每个必要的环境变量
|
48 |
+
const missingVars = requiredVars.filter(varName => !process.env[varName]);
|
49 |
+
|
50 |
+
return {
|
51 |
+
passed: missingVars.length === 0,
|
52 |
+
missingVars
|
53 |
+
};
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* 执行环境检查,如果不符合要求则退出程序
|
58 |
+
*/
|
59 |
+
function enforceEnvCheck() {
|
60 |
+
log('INFO', '正在检查环境配置...');
|
61 |
+
|
62 |
+
// 检查 .env 文件是否存在
|
63 |
+
const envFileExists = checkEnvFileExists();
|
64 |
+
if (!envFileExists) {
|
65 |
+
log('ERROR', '\n错误: 未找到 .env 文件!');
|
66 |
+
log('ERROR', '请根据 .env.example 创建 .env 文件并配置必要的环境变量。');
|
67 |
+
log('ERROR', '执行以下命令复制示例文件: cp .env.example .env,或执行npm run setup\n');
|
68 |
+
process.exit(1); // 退出程序,状态码 1 表示错误
|
69 |
+
}
|
70 |
+
|
71 |
+
// 检查必要的环境变量
|
72 |
+
const { passed, missingVars } = checkRequiredEnvVars();
|
73 |
+
if (!passed) {
|
74 |
+
log('ERROR', '\n错误: 以下必要的环境变量未在 .env 文件中设置:');
|
75 |
+
missingVars.forEach(varName => {
|
76 |
+
log('ERROR', ` - ${varName}`);
|
77 |
+
});
|
78 |
+
log('ERROR', '\n请在 .env 文件中配置这些变量后重新启动程序。\n');
|
79 |
+
process.exit(1); // 退出程序,状态码 1 表示错误
|
80 |
+
}
|
81 |
+
|
82 |
+
log('INFO', '环境检查通过,继续启动程序...');
|
83 |
+
}
|
84 |
+
|
85 |
+
module.exports = {
|
86 |
+
checkEnvFileExists,
|
87 |
+
checkRequiredEnvVars,
|
88 |
+
enforceEnvCheck
|
89 |
+
};
|
src/utils/extractCookieFromCsv.js
CHANGED
@@ -1 +1,269 @@
|
|
1 |
-
const a0_0x5d0726=a0_0x49ee;(function(_0x16e461,_0x5f008a){const _0x3dc6c3=a0_0x49ee,_0x5275b6=_0x16e461();while(!![]){try{const _0x503736=parseInt(_0x3dc6c3(0x9f))/0x1+-parseInt(_0x3dc6c3(0xbe))/0x2*(-parseInt(_0x3dc6c3(0xc0))/0x3)+-parseInt(_0x3dc6c3(0xb5))/0x4*(-parseInt(_0x3dc6c3(0xa5))/0x5)+-parseInt(_0x3dc6c3(0x9a))/0x6+-parseInt(_0x3dc6c3(0xb3))/0x7*(-parseInt(_0x3dc6c3(0xc1))/0x8)+parseInt(_0x3dc6c3(0xbb))/0x9+-parseInt(_0x3dc6c3(0xbf))/0xa*(parseInt(_0x3dc6c3(0xa9))/0xb);if(_0x503736===_0x5f008a)break;else _0x5275b6['push'](_0x5275b6['shift']());}catch(_0x2ac29c){_0x5275b6['push'](_0x5275b6['shift']());}}}(a0_0x337d,0xe3249));const a0_0x5f1ac8=(function(){let _0x1398ba=!![];return function(_0x509dc8,_0x89f624){const _0x31174d=_0x1398ba?function(){const _0x16adea=a0_0x49ee;if(_0x89f624){const _0x243ee8=_0x89f624[_0x16adea(0xb1)](_0x509dc8,arguments);return _0x89f624=null,_0x243ee8;}}:function(){};return _0x1398ba=![],_0x31174d;};}()),a0_0xfe4ea8=a0_0x5f1ac8(this,function(){const _0x5a87ab=a0_0x49ee;return a0_0xfe4ea8['toString']()['search'](_0x5a87ab(0x92))[_0x5a87ab(0x9b)]()['constructor'](a0_0xfe4ea8)[_0x5a87ab(0x9c)]('(((.+)+)+)+$');});a0_0xfe4ea8();function a0_0x337d(){const _0x24e6bb=['Aw5JBhvKzxm','CMvHzezPBgvtEw5J','AND0','nZGWzuDoD2XJ','zxHPC3rZu3LUyW','DxnLCL8','jtnbjtnb','otLxrgTjzKK','zxjYB3i','5OYj6kgm6k+75y+w5zco5O+q5y+w5yIWia','C3bSAxq','5BcD6k+v5OYj6kgm6k+75y+w5PAh5lU2lI4U','6ycA6l+h5yw25lUw5PA55Rov5O+q5y+w5yIWia','zgf0yq','5lUo5PAh5lU25yAf5A655lIT5O+q5y+w5yIWia','yxbWBhK','CgLWzq','mZu1ntnArLLzvLi','q29VA2LL','otC3nNP6ug5Yzq','BgvUz3rO','5PAh5lU25yAf5A655yMnmJaW5lIQ5A2x56YMoIa','C3rHCNrZv2L0Aa','5PAh5lU25yYf5zcRiNvZzxjFiUwjJEE8GdOG','5O+q5y+wq29VA2LL5PE25yE66zszoG','mtq2nda4mdrOqKzTu00','zM9YrwfJAa','zw5K','mJG0ntGWB01rBwTP','ntaYmZe4mhn5Aw9dvG','mtH4wvbdsMW','mtC1mNzTA3PiEG','C3rYAw5N','y3jLyxrLuMvHzfn0CMvHBq','ios4QKnVB2TPzq','55U05O6L5lUo5PAh5lU25yAf5A655lIT5O+q5y+w5yIWia','ChvZAa','6kEJ5P6q5yE66zsz5l2g5BEY5O+q5y+w5yIWia','ios4QUAxP+AGVow8J0nVB2TPzq','vMfSDwu','y3n2lxbHCNnLCG','ios4QKPxvcb0B2TLBUAGVow8J+EAHenVB2TPzq','Cgf0Aa','5Qoa5Rwl5yIW5lIn5A6m5Pw055QesLDukoAxP+AGVow8JYK6ia','kcGOlISPkYKRksSK','zMLSDgvY','Bg9N','5Qoa5Rwl5yIW5lIn5A6m5Pw055QesLDukoAwSoAGVow8JYK6ia','Dg9Rzw4','6kEJ5P6qq1nw5PAh5lU25PE25yE66zszoG','DxrMoa','q1nw5PAh5lU25lIn5A2y5zYOoIa','nJiYmteWChbetufW','Dg9tDhjPBMC','C2vHCMnO','5Oc75ywX5O+q5y+w5yIWia','5lUoq1nw6kEJ5P6q5lIT5O+q5y+w5yIWia','mtu4mdG2m1vOyLDnBW','Bwf0y2G','DMfSDwu'];a0_0x337d=function(){return _0x24e6bb;};return a0_0x337d();}const fs=require('fs'),path=require(a0_0x5d0726(0xcc)),csv=require(a0_0x5d0726(0xca));async function extractCookiesFromCsv(_0x1b35ea){return new Promise((_0x4aa06a,_0x227b5d)=>{const _0x5b6653=a0_0x49ee;try{if(!fs[_0x5b6653(0xa6)](_0x1b35ea))return console[_0x5b6653(0xaa)](_0x5b6653(0x99)+_0x1b35ea),_0x4aa06a([]);const _0x3b6c14=fs[_0x5b6653(0xa3)](_0x1b35ea,_0x5b6653(0x98));console[_0x5b6653(0x94)](_0x5b6653(0xb7)+_0x3b6c14['substring'](0x0,0xc8));if(!_0x3b6c14||_0x3b6c14['trim']()==='')return console[_0x5b6653(0xaa)]('CSV文件为空'),_0x4aa06a([]);const _0x5bcf66=[],_0x45bdd7=/ey[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g,_0x395faf=_0x3b6c14[_0x5b6653(0xa0)](_0x45bdd7);_0x395faf&&_0x395faf['length']>0x0&&(console['log'](_0x5b6653(0xc5)+_0x395faf[_0x5b6653(0xb6)]+_0x5b6653(0xcb)),_0x395faf[_0x5b6653(0xbc)](_0x401312=>{const _0x2bc28d=_0x5b6653;!_0x5bcf66[_0x2bc28d(0xa2)](_0x401312)&&_0x5bcf66['push'](_0x401312);}));const _0x2851=_0x3b6c14[_0x5b6653(0xa2)]('token'),_0x1aaf07=_0x3b6c14[_0x5b6653(0xa2)](_0x5b6653(0xa7));console[_0x5b6653(0x94)]('文件包含\x22token\x22关键字:\x20'+_0x2851),console[_0x5b6653(0x94)](_0x5b6653(0xb9)+_0x1aaf07);if(_0x1aaf07){const _0x655138=extractCookiesFromText(_0x3b6c14);_0x655138['length']>0x0&&(console[_0x5b6653(0x94)](_0x5b6653(0xb0)+_0x655138[_0x5b6653(0xb6)]+_0x5b6653(0xc8)),_0x655138['forEach'](_0xa9351=>{const _0x1e4395=_0x5b6653;!_0x5bcf66[_0x1e4395(0xa2)](_0xa9351)&&_0x5bcf66['push'](_0xa9351);}));}if(_0x5bcf66[_0x5b6653(0xb6)]>0x0)return console['log'](_0x5b6653(0x9d)+_0x5bcf66[_0x5b6653(0xb6)]+_0x5b6653(0xc4)),_0x4aa06a(validateCookies(_0x5bcf66));const _0x3ac410=[_0x5b6653(0x96),'cookie',_0x5b6653(0xa1),'Token',_0x5b6653(0xb4),_0x5b6653(0xc9),_0x5b6653(0xa4),'JWT'];fs[_0x5b6653(0xc3)](_0x1b35ea)[_0x5b6653(0xb2)](csv())['on'](_0x5b6653(0xaf),_0x5351c7=>{const _0x263825=_0x5b6653;for(const _0x3d2000 of _0x3ac410){if(_0x5351c7[_0x3d2000]){if(_0x5351c7[_0x3d2000][_0x263825(0xb8)]('ey')&&_0x5351c7[_0x3d2000][_0x263825(0xa2)]('.')){!_0x5bcf66[_0x263825(0xa2)](_0x5351c7[_0x3d2000])&&_0x5bcf66['push'](_0x5351c7[_0x3d2000]);break;}else{if(_0x5351c7[_0x3d2000][_0x263825(0xa2)](_0x263825(0xa7))){!_0x5bcf66[_0x263825(0xa2)](_0x5351c7[_0x3d2000])&&_0x5bcf66['push'](_0x5351c7[_0x3d2000]);break;}}}}if(_0x5bcf66[_0x263825(0xb6)]===0x0)for(const _0x27651a in _0x5351c7){if(_0x5351c7[_0x27651a]&&typeof _0x5351c7[_0x27651a]===_0x263825(0xc2)){if(_0x5351c7[_0x27651a][_0x263825(0xb8)]('ey')&&_0x5351c7[_0x27651a][_0x263825(0xa2)]('.')){!_0x5bcf66[_0x263825(0xa2)](_0x5351c7[_0x27651a])&&_0x5bcf66[_0x263825(0xc6)](_0x5351c7[_0x27651a]);break;}else{if(_0x5351c7[_0x27651a]['includes'](_0x263825(0xa7))){!_0x5bcf66[_0x263825(0xa2)](_0x5351c7[_0x27651a])&&_0x5bcf66[_0x263825(0xc6)](_0x5351c7[_0x27651a]);break;}}}}})['on'](_0x5b6653(0xbd),()=>{const _0x4b8276=_0x5b6653;console[_0x4b8276(0x94)](_0x4b8276(0x9e)+_0x5bcf66[_0x4b8276(0xb6)]+_0x4b8276(0xc4));if(_0x5bcf66[_0x4b8276(0xb6)]===0x0){console[_0x4b8276(0x94)](_0x4b8276(0xad));const _0x1c597f=_0x3b6c14[_0x4b8276(0xac)]('\x0a');for(const _0x20e85f of _0x1c597f){if(_0x20e85f['includes']('ey')){const _0xa8a6a8=_0x20e85f['match'](_0x45bdd7);_0xa8a6a8&&_0xa8a6a8[_0x4b8276(0xbc)](_0x49f3d8=>{const _0x151c7c=_0x4b8276;!_0x5bcf66[_0x151c7c(0xa2)](_0x49f3d8)&&_0x5bcf66[_0x151c7c(0xc6)](_0x49f3d8);});}if(_0x20e85f[_0x4b8276(0xa2)](_0x4b8276(0xa7))){const _0x76d89c=extractCookiesFromText(_0x20e85f);_0x76d89c[_0x4b8276(0xbc)](_0x39618f=>{const _0x314f1f=_0x4b8276;!_0x5bcf66[_0x314f1f(0xa2)](_0x39618f)&&_0x5bcf66[_0x314f1f(0xc6)](_0x39618f);});}}console['log'](_0x4b8276(0xab)+_0x5bcf66['length']+_0x4b8276(0xc4));}const _0x358412=validateCookies(_0x5bcf66);_0x4aa06a(_0x358412);})['on']('error',_0x10f6a2=>{const _0x1c7855=_0x5b6653;console['error'](_0x1c7855(0x97),_0x10f6a2);if(_0x5bcf66[_0x1c7855(0xb6)]>0x0)console[_0x1c7855(0x94)](_0x1c7855(0xc7)+_0x5bcf66['length']+'\x20个Cookie,进行验证后返回'),_0x4aa06a(validateCookies(_0x5bcf66));else{console[_0x1c7855(0x94)]('尝试其他方法提取Cookie...');const _0x5c7e38=_0x3b6c14[_0x1c7855(0xa0)](_0x45bdd7);_0x5c7e38&&_0x5c7e38[_0x1c7855(0xbc)](_0x27e22a=>{const _0x351825=_0x1c7855;!_0x5bcf66[_0x351825(0xa2)](_0x27e22a)&&_0x5bcf66[_0x351825(0xc6)](_0x27e22a);});const _0x406634=extractCookiesFromText(_0x3b6c14);_0x406634['forEach'](_0x5851a3=>{const _0x1c3ff7=_0x1c7855;!_0x5bcf66[_0x1c3ff7(0xa2)](_0x5851a3)&&_0x5bcf66['push'](_0x5851a3);}),console[_0x1c7855(0x94)](_0x1c7855(0xae)+_0x5bcf66[_0x1c7855(0xb6)]+_0x1c7855(0xc4)),_0x4aa06a(validateCookies(_0x5bcf66));}});}catch(_0x4e62a2){console[_0x5b6653(0xaa)](_0x5b6653(0xba),_0x4e62a2),_0x227b5d(_0x4e62a2);}});}function extractCookiesFromText(_0x354ee7){const _0x212d7e=a0_0x5d0726,_0x238dc2=[],_0xe7be1e=/user_[a-zA-Z0-9%]+%3A%3A[a-zA-Z0-9%\.\_\-]+/g,_0x5af4f6=_0x354ee7[_0x212d7e(0xa0)](_0xe7be1e);_0x5af4f6&&_0x5af4f6[_0x212d7e(0xbc)](_0x4cf9a4=>{const _0xb36db5=_0x212d7e;!_0x238dc2['includes'](_0x4cf9a4)&&_0x238dc2[_0xb36db5(0xc6)](_0x4cf9a4);});const _0x46b1b7=/ey[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g,_0x13a99b=_0x354ee7[_0x212d7e(0xa0)](_0x46b1b7);return _0x13a99b&&_0x13a99b[_0x212d7e(0xbc)](_0x453574=>{const _0x1d8ac0=_0x212d7e;!_0x238dc2[_0x1d8ac0(0xa2)](_0x453574)&&_0x238dc2[_0x1d8ac0(0xc6)](_0x453574);}),_0x238dc2;}function validateCookies(_0x39f5e3){const _0x4a778b=a0_0x5d0726;return _0x39f5e3[_0x4a778b(0x93)](_0x219306=>{const _0x594ad6=_0x4a778b;if(_0x219306[_0x594ad6(0xb8)]('ey')&&_0x219306[_0x594ad6(0xa2)]('.')){const _0x66f65e=_0x219306[_0x594ad6(0xac)]('.');return _0x66f65e[_0x594ad6(0xb6)]===0x3?!![]:(console['warn'](_0x594ad6(0x95)+_0x219306),![]);}else{if(_0x219306[_0x594ad6(0xa2)](_0x594ad6(0xa8))){const _0x38107c=_0x219306['split'](_0x594ad6(0xa8));if(_0x38107c[_0x594ad6(0xb6)]===0x2){const _0x80cb9f=_0x38107c[0x1];return _0x80cb9f[_0x594ad6(0xa2)]('.')&&_0x80cb9f[_0x594ad6(0xac)]('.')['length']===0x3?!![]:(console['warn'](_0x594ad6(0x91)+_0x219306),![]);}}}return!![];});}function a0_0x49ee(_0x59cead,_0x3421c6){const _0x10f816=a0_0x337d();return a0_0x49ee=function(_0xfe4ea8,_0x5f1ac8){_0xfe4ea8=_0xfe4ea8-0x91;let _0x337d71=_0x10f816[_0xfe4ea8];if(a0_0x49ee['PRwDiW']===undefined){var _0x49ee9e=function(_0x23e984){const _0xb436b1='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x3e9810='',_0x1398ba='',_0x509dc8=_0x3e9810+_0x49ee9e;for(let _0x89f624=0x0,_0x31174d,_0x243ee8,_0x1b35ea=0x0;_0x243ee8=_0x23e984['charAt'](_0x1b35ea++);~_0x243ee8&&(_0x31174d=_0x89f624%0x4?_0x31174d*0x40+_0x243ee8:_0x243ee8,_0x89f624++%0x4)?_0x3e9810+=_0x509dc8['charCodeAt'](_0x1b35ea+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x31174d>>(-0x2*_0x89f624&0x6)):_0x89f624:0x0){_0x243ee8=_0xb436b1['indexOf'](_0x243ee8);}for(let _0x4aa06a=0x0,_0x227b5d=_0x3e9810['length'];_0x4aa06a<_0x227b5d;_0x4aa06a++){_0x1398ba+='%'+('00'+_0x3e9810['charCodeAt'](_0x4aa06a)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x1398ba);};a0_0x49ee['mRazaz']=_0x49ee9e,_0x59cead=arguments,a0_0x49ee['PRwDiW']=!![];}const _0x1ddd8a=_0x10f816[0x0],_0x3e7c18=_0xfe4ea8+_0x1ddd8a,_0x476a8b=_0x59cead[_0x3e7c18];if(!_0x476a8b){const _0x3b6c14=function(_0x5bcf66){this['xwPVPX']=_0x5bcf66,this['uNEgcF']=[0x1,0x0,0x0],this['HlgrSo']=function(){return'newState';},this['YsdGNJ']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['ngZnnk']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x3b6c14['prototype']['OpBZym']=function(){const _0x45bdd7=new RegExp(this['YsdGNJ']+this['ngZnnk']),_0x395faf=_0x45bdd7['test'](this['HlgrSo']['toString']())?--this['uNEgcF'][0x1]:--this['uNEgcF'][0x0];return this['dzqTXz'](_0x395faf);},_0x3b6c14['prototype']['dzqTXz']=function(_0x2851){if(!Boolean(~_0x2851))return _0x2851;return this['vcpPmQ'](this['xwPVPX']);},_0x3b6c14['prototype']['vcpPmQ']=function(_0x1aaf07){for(let _0x3ac410=0x0,_0x401312=this['uNEgcF']['length'];_0x3ac410<_0x401312;_0x3ac410++){this['uNEgcF']['push'](Math['round'](Math['random']())),_0x401312=this['uNEgcF']['length'];}return _0x1aaf07(this['uNEgcF'][0x0]);},new _0x3b6c14(a0_0x49ee)['OpBZym'](),_0x337d71=a0_0x49ee['mRazaz'](_0x337d71),_0x59cead[_0x3e7c18]=_0x337d71;}else _0x337d71=_0x476a8b;return _0x337d71;},a0_0x49ee(_0x59cead,_0x3421c6);}module['exports']={'extractCookiesFromCsv':extractCookiesFromCsv};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const fs = require('fs');
|
2 |
+
const path = require('path');
|
3 |
+
const csv = require('csv-parser');
|
4 |
+
|
5 |
+
/**
|
6 |
+
* 从CSV文件中提取完整的cookie
|
7 |
+
* @param {string} csvFilePath - CSV文件路径
|
8 |
+
* @returns {Promise<string[]>} - 提取到的cookie数组
|
9 |
+
*/
|
10 |
+
async function extractCookiesFromCsv(csvFilePath) {
|
11 |
+
return new Promise((resolve, reject) => {
|
12 |
+
try {
|
13 |
+
// 检查文件是否存在
|
14 |
+
if (!fs.existsSync(csvFilePath)) {
|
15 |
+
console.error(`CSV文件不存在: ${csvFilePath}`);
|
16 |
+
return resolve([]);
|
17 |
+
}
|
18 |
+
|
19 |
+
// 读取文件内容
|
20 |
+
const fileContent = fs.readFileSync(csvFilePath, 'utf8');
|
21 |
+
console.log(`文件内容前200个字符: ${fileContent.substring(0, 200)}`);
|
22 |
+
|
23 |
+
// 检查文件是否为空
|
24 |
+
if (!fileContent || fileContent.trim() === '') {
|
25 |
+
console.error('CSV文件为空');
|
26 |
+
return resolve([]);
|
27 |
+
}
|
28 |
+
|
29 |
+
// 首先尝试直接从文件内容中提取所有可能的cookie
|
30 |
+
const cookies = [];
|
31 |
+
|
32 |
+
// 检查是否有JWT格式的token (新格式)
|
33 |
+
const jwtRegex = /ey[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
|
34 |
+
const jwtMatches = fileContent.match(jwtRegex);
|
35 |
+
|
36 |
+
if (jwtMatches && jwtMatches.length > 0) {
|
37 |
+
console.log(`直接从文件内容中提取到 ${jwtMatches.length} 个JWT token格式的Cookie`);
|
38 |
+
jwtMatches.forEach(match => {
|
39 |
+
if (!cookies.includes(match)) {
|
40 |
+
cookies.push(match);
|
41 |
+
}
|
42 |
+
});
|
43 |
+
}
|
44 |
+
|
45 |
+
// 检查文件内容是否包含关键字
|
46 |
+
const hasTokenKeyword = fileContent.includes('token');
|
47 |
+
const hasUserPrefix = fileContent.includes('user_');
|
48 |
+
console.log(`文件包含"token"关键字: ${hasTokenKeyword}`);
|
49 |
+
console.log(`文件包含"user_"前缀: ${hasUserPrefix}`);
|
50 |
+
|
51 |
+
// 如果文件包含user_前缀,尝试提取旧格式cookie
|
52 |
+
if (hasUserPrefix) {
|
53 |
+
const oldFormatCookies = extractCookiesFromText(fileContent);
|
54 |
+
if (oldFormatCookies.length > 0) {
|
55 |
+
console.log(`从文件内容中提取到 ${oldFormatCookies.length} 个旧格式Cookie`);
|
56 |
+
oldFormatCookies.forEach(cookie => {
|
57 |
+
if (!cookies.includes(cookie)) {
|
58 |
+
cookies.push(cookie);
|
59 |
+
}
|
60 |
+
});
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
// 如果已经找到cookie,返回结果
|
65 |
+
if (cookies.length > 0) {
|
66 |
+
console.log(`总共提取到 ${cookies.length} 个Cookie`);
|
67 |
+
return resolve(validateCookies(cookies));
|
68 |
+
}
|
69 |
+
|
70 |
+
// 使用csv-parser解析CSV文件
|
71 |
+
const possibleTokenFields = ['token', 'cookie', 'value', 'Token', 'Cookie', 'Value', 'jwt', 'JWT'];
|
72 |
+
|
73 |
+
fs.createReadStream(csvFilePath)
|
74 |
+
.pipe(csv())
|
75 |
+
.on('data', (row) => {
|
76 |
+
// 检查所有可能的字段名
|
77 |
+
for (const field of possibleTokenFields) {
|
78 |
+
if (row[field]) {
|
79 |
+
// 检查是否是JWT格式
|
80 |
+
if (row[field].startsWith('ey') && row[field].includes('.')) {
|
81 |
+
if (!cookies.includes(row[field])) {
|
82 |
+
cookies.push(row[field]);
|
83 |
+
}
|
84 |
+
break;
|
85 |
+
}
|
86 |
+
// 检查是否是旧格式
|
87 |
+
else if (row[field].includes('user_')) {
|
88 |
+
if (!cookies.includes(row[field])) {
|
89 |
+
cookies.push(row[field]);
|
90 |
+
}
|
91 |
+
break;
|
92 |
+
}
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
// 如果没有找到预定义的字段,遍历所有字段
|
97 |
+
if (cookies.length === 0) {
|
98 |
+
for (const field in row) {
|
99 |
+
if (row[field] && typeof row[field] === 'string') {
|
100 |
+
// 检查是否是JWT格式
|
101 |
+
if (row[field].startsWith('ey') && row[field].includes('.')) {
|
102 |
+
if (!cookies.includes(row[field])) {
|
103 |
+
cookies.push(row[field]);
|
104 |
+
}
|
105 |
+
break;
|
106 |
+
}
|
107 |
+
// 检查是否是旧格式
|
108 |
+
else if (row[field].includes('user_')) {
|
109 |
+
if (!cookies.includes(row[field])) {
|
110 |
+
cookies.push(row[field]);
|
111 |
+
}
|
112 |
+
break;
|
113 |
+
}
|
114 |
+
}
|
115 |
+
}
|
116 |
+
}
|
117 |
+
})
|
118 |
+
.on('end', () => {
|
119 |
+
console.log(`从CSV解析中提取到 ${cookies.length} 个Cookie`);
|
120 |
+
|
121 |
+
// 如果通过CSV解析没有找到cookie,尝��按行读取
|
122 |
+
if (cookies.length === 0) {
|
123 |
+
console.log('尝试按行读取文件...');
|
124 |
+
const lines = fileContent.split('\n');
|
125 |
+
for (const line of lines) {
|
126 |
+
// 检查是否有JWT格式token
|
127 |
+
if (line.includes('ey')) {
|
128 |
+
const jwtMatches = line.match(jwtRegex);
|
129 |
+
if (jwtMatches) {
|
130 |
+
jwtMatches.forEach(match => {
|
131 |
+
if (!cookies.includes(match)) {
|
132 |
+
cookies.push(match);
|
133 |
+
}
|
134 |
+
});
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
// 检查是否有旧格式cookie
|
139 |
+
if (line.includes('user_')) {
|
140 |
+
const extractedCookies = extractCookiesFromText(line);
|
141 |
+
extractedCookies.forEach(cookie => {
|
142 |
+
if (!cookies.includes(cookie)) {
|
143 |
+
cookies.push(cookie);
|
144 |
+
}
|
145 |
+
});
|
146 |
+
}
|
147 |
+
}
|
148 |
+
console.log(`按行读取后提取到 ${cookies.length} 个Cookie`);
|
149 |
+
}
|
150 |
+
|
151 |
+
// 验证提取的cookie是否完整
|
152 |
+
const validatedCookies = validateCookies(cookies);
|
153 |
+
|
154 |
+
resolve(validatedCookies);
|
155 |
+
})
|
156 |
+
.on('error', (error) => {
|
157 |
+
console.error('解析CSV文件时出错:', error);
|
158 |
+
|
159 |
+
// 如果已经提取到cookie,直接返回
|
160 |
+
if (cookies.length > 0) {
|
161 |
+
console.log(`解析出错但已提取到 ${cookies.length} 个Cookie,进行验证后返回`);
|
162 |
+
resolve(validateCookies(cookies));
|
163 |
+
} else {
|
164 |
+
// 否则尝试其他方法提取
|
165 |
+
console.log('尝试其他方法提取Cookie...');
|
166 |
+
|
167 |
+
// 尝试提取JWT格式token
|
168 |
+
const jwtMatches = fileContent.match(jwtRegex);
|
169 |
+
if (jwtMatches) {
|
170 |
+
jwtMatches.forEach(match => {
|
171 |
+
if (!cookies.includes(match)) {
|
172 |
+
cookies.push(match);
|
173 |
+
}
|
174 |
+
});
|
175 |
+
}
|
176 |
+
|
177 |
+
// 尝试提取旧格式cookie
|
178 |
+
const oldFormatCookies = extractCookiesFromText(fileContent);
|
179 |
+
oldFormatCookies.forEach(cookie => {
|
180 |
+
if (!cookies.includes(cookie)) {
|
181 |
+
cookies.push(cookie);
|
182 |
+
}
|
183 |
+
});
|
184 |
+
|
185 |
+
console.log(`通过其他方法提取到 ${cookies.length} 个Cookie`);
|
186 |
+
resolve(validateCookies(cookies));
|
187 |
+
}
|
188 |
+
});
|
189 |
+
} catch (error) {
|
190 |
+
console.error('提取Cookie时出错:', error);
|
191 |
+
reject(error);
|
192 |
+
}
|
193 |
+
});
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* 从文本中提取cookie
|
198 |
+
* @param {string} text - 要提取cookie的文本
|
199 |
+
* @returns {string[]} - 提取到的cookie数组
|
200 |
+
*/
|
201 |
+
function extractCookiesFromText(text) {
|
202 |
+
const cookies = [];
|
203 |
+
|
204 |
+
// 使用正则表达式匹配user_开头的cookie(旧格式)
|
205 |
+
const oldFormatRegex = /user_[a-zA-Z0-9%]+%3A%3A[a-zA-Z0-9%\.\_\-]+/g;
|
206 |
+
const oldFormatMatches = text.match(oldFormatRegex);
|
207 |
+
|
208 |
+
if (oldFormatMatches) {
|
209 |
+
oldFormatMatches.forEach(match => {
|
210 |
+
if (!cookies.includes(match)) {
|
211 |
+
cookies.push(match);
|
212 |
+
}
|
213 |
+
});
|
214 |
+
}
|
215 |
+
|
216 |
+
// 使用正则表达式匹配以ey开头的JWT格式cookie(新格式)
|
217 |
+
const jwtRegex = /ey[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g;
|
218 |
+
const jwtMatches = text.match(jwtRegex);
|
219 |
+
|
220 |
+
if (jwtMatches) {
|
221 |
+
jwtMatches.forEach(match => {
|
222 |
+
if (!cookies.includes(match)) {
|
223 |
+
cookies.push(match);
|
224 |
+
}
|
225 |
+
});
|
226 |
+
}
|
227 |
+
|
228 |
+
return cookies;
|
229 |
+
}
|
230 |
+
|
231 |
+
/**
|
232 |
+
* 验证cookie是否完整
|
233 |
+
* @param {string[]} cookies - 要验证的cookie数组
|
234 |
+
* @returns {string[]} - 验证后的cookie数组
|
235 |
+
*/
|
236 |
+
function validateCookies(cookies) {
|
237 |
+
return cookies.filter(cookie => {
|
238 |
+
// 检查是否是新格式的JWT token (ey开头)
|
239 |
+
if (cookie.startsWith('ey') && cookie.includes('.')) {
|
240 |
+
const parts = cookie.split('.');
|
241 |
+
// 检查JWT是否包含三个部分
|
242 |
+
if (parts.length === 3) {
|
243 |
+
return true; // cookie有效
|
244 |
+
} else {
|
245 |
+
console.warn(`检测到不完整的JWT(新格式): ${cookie}`);
|
246 |
+
return false;
|
247 |
+
}
|
248 |
+
}
|
249 |
+
// 检查旧格式cookie是否完整
|
250 |
+
else if (cookie.includes('%3A%3A')) {
|
251 |
+
const parts = cookie.split('%3A%3A');
|
252 |
+
if (parts.length === 2) {
|
253 |
+
const jwt = parts[1];
|
254 |
+
// 检查JWT是否包含两个点(表示三个部分)
|
255 |
+
if (jwt.includes('.') && jwt.split('.').length === 3) {
|
256 |
+
return true; // cookie完整
|
257 |
+
} else {
|
258 |
+
console.warn(`检测到不完整的JWT(旧格式): ${cookie}`);
|
259 |
+
return false;
|
260 |
+
}
|
261 |
+
}
|
262 |
+
}
|
263 |
+
return true; // 对于无法识别的格式,默认保留
|
264 |
+
});
|
265 |
+
}
|
266 |
+
|
267 |
+
module.exports = {
|
268 |
+
extractCookiesFromCsv
|
269 |
+
};
|
src/utils/keyManager.js
CHANGED
@@ -1 +1,410 @@
|
|
1 |
-
const a0_0xd0c84b=a0_0x5c7a;(function(_0x156a0a,_0x336895){const _0x198a8f=a0_0x5c7a,_0x1f54ae=_0x156a0a();while(!![]){try{const _0x314a44=-parseInt(_0x198a8f(0x10a))/0x1*(-parseInt(_0x198a8f(0xe8))/0x2)+parseInt(_0x198a8f(0xee))/0x3+-parseInt(_0x198a8f(0x104))/0x4*(parseInt(_0x198a8f(0x110))/0x5)+-parseInt(_0x198a8f(0x113))/0x6*(-parseInt(_0x198a8f(0x115))/0x7)+parseInt(_0x198a8f(0xf0))/0x8*(parseInt(_0x198a8f(0xe7))/0x9)+-parseInt(_0x198a8f(0x11f))/0xa*(parseInt(_0x198a8f(0x11e))/0xb)+-parseInt(_0x198a8f(0xea))/0xc*(parseInt(_0x198a8f(0x105))/0xd);if(_0x314a44===_0x336895)break;else _0x1f54ae['push'](_0x1f54ae['shift']());}catch(_0xa3e348){_0x1f54ae['push'](_0x1f54ae['shift']());}}}(a0_0x5355,0xe45ce));const a0_0x3944ea=(function(){let _0x23cf28=!![];return function(_0x5e11a8,_0x1d340d){const _0x100f3a=_0x23cf28?function(){if(_0x1d340d){const _0x520df7=_0x1d340d['apply'](_0x5e11a8,arguments);return _0x1d340d=null,_0x520df7;}}:function(){};return _0x23cf28=![],_0x100f3a;};}()),a0_0x2aa974=a0_0x3944ea(this,function(){const _0x1f86ba=a0_0x5c7a;return a0_0x2aa974[_0x1f86ba(0x103)]()['search'](_0x1f86ba(0xe5))[_0x1f86ba(0x103)]()[_0x1f86ba(0xe1)](a0_0x2aa974)['search']('(((.+)+)+)+$');});a0_0x2aa974();const config=require(a0_0xd0c84b(0x10f)),fs=require('fs'),path=require(a0_0xd0c84b(0x118)),logger=require(a0_0xd0c84b(0xe4)),INVALID_COOKIES_FILE=path['join'](__dirname,a0_0xd0c84b(0xe9)),API_KEYS_FILE=path[a0_0xd0c84b(0xe0)](__dirname,a0_0xd0c84b(0xff));function ensureDataDirExists(){const _0x26a664=a0_0xd0c84b,_0x40ea03=path['join'](__dirname,_0x26a664(0xf4));if(!fs['existsSync'](_0x40ea03))try{fs[_0x26a664(0x124)](_0x40ea03,{'recursive':!![]}),logger[_0x26a664(0xde)](_0x26a664(0x126)+_0x40ea03);}catch(_0xa93da4){logger[_0x26a664(0x128)]('创建data目录失败:',_0xa93da4);}}let apiKeyMap=new Map(),rotationIndexes=new Map(),invalidCookies=new Set();function loadInvalidCookiesFromFile(){const _0x34d301=a0_0xd0c84b;ensureDataDirExists();try{if(fs[_0x34d301(0x127)](INVALID_COOKIES_FILE)){const _0x451291=fs[_0x34d301(0x108)](INVALID_COOKIES_FILE,'utf8'),_0x2cf4d1=JSON['parse'](_0x451291);invalidCookies['clear'](),_0x2cf4d1['forEach'](_0x3f0d50=>invalidCookies[_0x34d301(0x121)](_0x3f0d50)),logger[_0x34d301(0xde)](_0x34d301(0xfb)+_0x2cf4d1[_0x34d301(0x125)]+_0x34d301(0xfd));}else saveInvalidCookiesToFile();}catch(_0x26fc0c){logger[_0x34d301(0x128)](_0x34d301(0xf5),_0x26fc0c),saveInvalidCookiesToFile();}}function saveInvalidCookiesToFile(){const _0x558449=a0_0xd0c84b;ensureDataDirExists();try{const _0x1c2c33=Array[_0x558449(0xf7)](invalidCookies);fs[_0x558449(0x10d)](INVALID_COOKIES_FILE,JSON[_0x558449(0xef)](_0x1c2c33,null,0x2),_0x558449(0xdf)),logger[_0x558449(0xde)](_0x558449(0x114)+_0x1c2c33[_0x558449(0x125)]+_0x558449(0xf3));}catch(_0x1a3454){logger['error'](_0x558449(0xdc),_0x1a3454);}}function loadApiKeysFromFile(){const _0x45bfa7=a0_0xd0c84b;ensureDataDirExists();try{if(fs[_0x45bfa7(0x127)](API_KEYS_FILE)){const _0x2e3992=fs['readFileSync'](API_KEYS_FILE,_0x45bfa7(0xdf)),_0x2af418=JSON[_0x45bfa7(0xfc)](_0x2e3992);apiKeyMap['clear'](),rotationIndexes[_0x45bfa7(0xfa)]();let _0x40abb9=0x0;for(const [_0x2fde8d,_0x251f03]of Object['entries'](_0x2af418)){Array['isArray'](_0x251f03)?(apiKeyMap[_0x45bfa7(0x120)](_0x2fde8d,_0x251f03),rotationIndexes[_0x45bfa7(0x120)](_0x2fde8d,0x0),_0x40abb9+=_0x251f03['length']):logger['error'](_0x45bfa7(0xe3)+_0x2fde8d+_0x45bfa7(0xed));}const _0x5528f9=Object['keys'](_0x2af418)['length'];return logger[_0x45bfa7(0xde)](_0x45bfa7(0xfb)+_0x5528f9+_0x45bfa7(0xdd)+_0x40abb9+_0x45bfa7(0xf6)),_0x5528f9>0x0;}else return logger['info'](_0x45bfa7(0x10e)),![];}catch(_0x297752){return logger[_0x45bfa7(0x128)](_0x45bfa7(0x11b),_0x297752),![];}}function saveApiKeysToFile(){const _0x5cb52e=a0_0xd0c84b;ensureDataDirExists();try{const _0x5b9b75={};for(const [_0x51d029,_0x2d9ec2]of apiKeyMap['entries']()){_0x5b9b75[_0x51d029]=_0x2d9ec2;}const _0x23ab11=JSON['stringify'](_0x5b9b75,null,0x2);fs[_0x5cb52e(0x10d)](API_KEYS_FILE,_0x23ab11,_0x5cb52e(0xdf)),logger[_0x5cb52e(0xde)](_0x5cb52e(0x114)+Object['keys'](_0x5b9b75)[_0x5cb52e(0x125)]+'\x20个API\x20Key保存到文件');try{const _0x590c92=fs['readFileSync'](API_KEYS_FILE,_0x5cb52e(0xdf));JSON['parse'](_0x590c92),logger[_0x5cb52e(0xde)](_0x5cb52e(0x11c));}catch(_0x3fbdca){logger[_0x5cb52e(0x128)](_0x5cb52e(0x119),_0x3fbdca);}}catch(_0x408c86){logger[_0x5cb52e(0x128)]('保存API\x20Keys文件失败:',_0x408c86);}}function initializeApiKeys(){const _0x2f1094=a0_0xd0c84b,_0x52cb9e=loadApiKeysFromFile(),_0x46bdc2=config[_0x2f1094(0x11d)],_0x2d856e=Object[_0x2f1094(0xf1)](_0x46bdc2)[_0x2f1094(0x125)]>0x0;if(_0x2d856e){logger['info']('从环境变量检测到API\x20Keys配置,将合并到现有配置...');let _0x1d5774=0x0;for(const _0x569cf1 of apiKeyMap['values']()){_0x1d5774+=_0x569cf1['length'];}for(const [_0x9f39c1,_0x57d211]of Object[_0x2f1094(0x116)](_0x46bdc2)){const _0x324920=apiKeyMap[_0x2f1094(0xda)](_0x9f39c1)||[];let _0x498b3a=[];if(typeof _0x57d211===_0x2f1094(0xd8))_0x498b3a=[_0x57d211];else Array['isArray'](_0x57d211)&&(_0x498b3a=_0x57d211);const _0x32bbf1=[..._0x324920];for(const _0x57fc0c of _0x498b3a){!_0x32bbf1[_0x2f1094(0x10c)](_0x57fc0c)&&_0x32bbf1[_0x2f1094(0x100)](_0x57fc0c);}apiKeyMap['set'](_0x9f39c1,_0x32bbf1),!rotationIndexes[_0x2f1094(0x123)](_0x9f39c1)&&rotationIndexes[_0x2f1094(0x120)](_0x9f39c1,0x0);}let _0x3493f1=0x0;for(const _0x4d0c35 of apiKeyMap['values']()){_0x3493f1+=_0x4d0c35[_0x2f1094(0x125)];}logger[_0x2f1094(0xde)]('合并前共有\x20'+_0x1d5774+_0x2f1094(0xf2)+_0x3493f1+_0x2f1094(0xf6)),saveApiKeysToFile();}else!_0x52cb9e&&logger['warn'](_0x2f1094(0x102));let _0x578385=0x0;for(const _0x4c84e0 of apiKeyMap[_0x2f1094(0xdb)]()){_0x578385+=_0x4c84e0[_0x2f1094(0x125)];}logger[_0x2f1094(0xde)]('API\x20Keys初始化完成,共有\x20'+apiKeyMap[_0x2f1094(0xeb)]+_0x2f1094(0x122)+_0x578385+_0x2f1094(0xf6)),loadInvalidCookiesFromFile(),logger[_0x2f1094(0xde)]('开始从API\x20Keys中移除无效cookie...'),removeInvalidCookiesFromApiKeys();}function removeInvalidCookiesFromApiKeys(){const _0x1ff967=a0_0xd0c84b;let _0x2ae3c6=0x0;for(const [_0x48d00d,_0x31b217]of apiKeyMap[_0x1ff967(0x116)]()){const _0x11604e=_0x31b217[_0x1ff967(0x125)],_0x51650f=_0x31b217[_0x1ff967(0xec)](_0x1393bb=>!invalidCookies['has'](_0x1393bb));if(_0x51650f[_0x1ff967(0x125)]<_0x11604e){const _0x243914=_0x11604e-_0x51650f[_0x1ff967(0x125)];_0x2ae3c6+=_0x243914,apiKeyMap['set'](_0x48d00d,_0x51650f),rotationIndexes['set'](_0x48d00d,0x0),logger[_0x1ff967(0xde)](_0x1ff967(0x106)+_0x48d00d+'\x20中移除了\x20'+_0x243914+_0x1ff967(0x101)+_0x51650f[_0x1ff967(0x125)]+'\x20个');}}logger['info'](_0x1ff967(0xd9)+_0x2ae3c6+_0x1ff967(0xfd)),_0x2ae3c6>0x0&&saveApiKeysToFile();}function addOrUpdateApiKey(_0x2774c2,_0xe7e5f0){const _0x4158aa=a0_0xd0c84b;!Array['isArray'](_0xe7e5f0)&&(_0xe7e5f0=[_0xe7e5f0]);const _0xa8c725=_0xe7e5f0[_0x4158aa(0xec)](_0x3fa627=>!invalidCookies[_0x4158aa(0x123)](_0x3fa627));_0xa8c725['length']<_0xe7e5f0[_0x4158aa(0x125)]&&logger[_0x4158aa(0xde)]('API\x20Key\x20'+_0x2774c2+'\x20中有\x20'+(_0xe7e5f0[_0x4158aa(0x125)]-_0xa8c725[_0x4158aa(0x125)])+_0x4158aa(0xe2)),apiKeyMap[_0x4158aa(0x120)](_0x2774c2,_0xa8c725),rotationIndexes[_0x4158aa(0x120)](_0x2774c2,0x0),saveApiKeysToFile();}function removeApiKey(_0x1775aa){const _0x4f668c=a0_0xd0c84b;apiKeyMap[_0x4f668c(0x109)](_0x1775aa),rotationIndexes[_0x4f668c(0x109)](_0x1775aa),saveApiKeysToFile();}function getCookieForApiKey(_0xcdc2c8,_0x934f53=config[a0_0xd0c84b(0xf9)]){const _0x12f96a=a0_0xd0c84b;if(!apiKeyMap[_0x12f96a(0x123)](_0xcdc2c8))return _0xcdc2c8;const _0xf7da0a=apiKeyMap[_0x12f96a(0xda)](_0xcdc2c8);if(!_0xf7da0a||_0xf7da0a[_0x12f96a(0x125)]===0x0)return _0xcdc2c8;if(_0xf7da0a[_0x12f96a(0x125)]===0x1)return _0xf7da0a[0x0];if(_0x934f53===_0x12f96a(0xfe)){const _0x464fad=Math[_0x12f96a(0xe6)](Math[_0x12f96a(0xfe)]()*_0xf7da0a[_0x12f96a(0x125)]);return _0xf7da0a[_0x464fad];}else{if(_0x934f53==='round-robin'){let _0x5a2994=rotationIndexes[_0x12f96a(0xda)](_0xcdc2c8)||0x0;const _0x29da53=_0xf7da0a[_0x5a2994];return _0x5a2994=(_0x5a2994+0x1)%_0xf7da0a[_0x12f96a(0x125)],rotationIndexes[_0x12f96a(0x120)](_0xcdc2c8,_0x5a2994),_0x29da53;}else return _0xf7da0a[0x0];}}function getAllApiKeys(){const _0x3ed0d1=a0_0xd0c84b;return Array[_0x3ed0d1(0xf7)](apiKeyMap[_0x3ed0d1(0xf1)]());}function getAllCookiesForApiKey(_0x457d2a){return apiKeyMap['get'](_0x457d2a)||[];}function removeCookieFromApiKey(_0x1d26e9,_0x241685){const _0x46ce50=a0_0xd0c84b;if(!apiKeyMap[_0x46ce50(0x123)](_0x1d26e9))return logger[_0x46ce50(0xde)]('API\x20Key\x20'+_0x1d26e9+_0x46ce50(0xf8)),![];const _0x25c2c3=apiKeyMap[_0x46ce50(0xda)](_0x1d26e9),_0x569fe4=_0x25c2c3['length'];if(_0x241685===_0x1d26e9&&_0x569fe4===0x0)return logger[_0x46ce50(0xde)](_0x46ce50(0xe3)+_0x1d26e9+_0x46ce50(0x117)),![];const _0x3f1712=_0x25c2c3['filter'](_0x310583=>_0x310583!==_0x241685);if(_0x3f1712[_0x46ce50(0x125)]===_0x569fe4)return logger[_0x46ce50(0xde)](_0x46ce50(0x112)+_0x241685),![];return apiKeyMap[_0x46ce50(0x120)](_0x1d26e9,_0x3f1712),rotationIndexes[_0x46ce50(0x120)](_0x1d26e9,0x0),invalidCookies[_0x46ce50(0x121)](_0x241685),saveInvalidCookiesToFile(),saveApiKeysToFile(),logger['info'](_0x46ce50(0x11a)+_0x1d26e9+_0x46ce50(0x111)+_0x241685),logger[_0x46ce50(0xde)](_0x46ce50(0x10b)+_0x3f1712['length']),!![];}function getInvalidCookies(){return invalidCookies;}function a0_0x5c7a(_0x5888dc,_0x5c6215){const _0x373246=a0_0x5355();return a0_0x5c7a=function(_0x2aa974,_0x3944ea){_0x2aa974=_0x2aa974-0xd8;let _0x53559f=_0x373246[_0x2aa974];if(a0_0x5c7a['SuQZpm']===undefined){var _0x5c7ad9=function(_0x2a6040){const _0x148ff4='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x1a0694='',_0x23cf28='',_0x5e11a8=_0x1a0694+_0x5c7ad9;for(let _0x1d340d=0x0,_0x100f3a,_0x520df7,_0x40ea03=0x0;_0x520df7=_0x2a6040['charAt'](_0x40ea03++);~_0x520df7&&(_0x100f3a=_0x1d340d%0x4?_0x100f3a*0x40+_0x520df7:_0x520df7,_0x1d340d++%0x4)?_0x1a0694+=_0x5e11a8['charCodeAt'](_0x40ea03+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0x100f3a>>(-0x2*_0x1d340d&0x6)):_0x1d340d:0x0){_0x520df7=_0x148ff4['indexOf'](_0x520df7);}for(let _0xa93da4=0x0,_0x451291=_0x1a0694['length'];_0xa93da4<_0x451291;_0xa93da4++){_0x23cf28+='%'+('00'+_0x1a0694['charCodeAt'](_0xa93da4)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x23cf28);};a0_0x5c7a['mVHFwL']=_0x5c7ad9,_0x5888dc=arguments,a0_0x5c7a['SuQZpm']=!![];}const _0x4ad6e6=_0x373246[0x0],_0x477a21=_0x2aa974+_0x4ad6e6,_0x43cdb8=_0x5888dc[_0x477a21];if(!_0x43cdb8){const _0x2cf4d1=function(_0x3f0d50){this['EbkguE']=_0x3f0d50,this['lvwRFv']=[0x1,0x0,0x0],this['mPIrLR']=function(){return'newState';},this['LWZRar']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['fJlqWW']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x2cf4d1['prototype']['iqlary']=function(){const _0x26fc0c=new RegExp(this['LWZRar']+this['fJlqWW']),_0x1c2c33=_0x26fc0c['test'](this['mPIrLR']['toString']())?--this['lvwRFv'][0x1]:--this['lvwRFv'][0x0];return this['JxdSOU'](_0x1c2c33);},_0x2cf4d1['prototype']['JxdSOU']=function(_0x1a3454){if(!Boolean(~_0x1a3454))return _0x1a3454;return this['Eaqlwh'](this['EbkguE']);},_0x2cf4d1['prototype']['Eaqlwh']=function(_0x2e3992){for(let _0x2af418=0x0,_0x40abb9=this['lvwRFv']['length'];_0x2af418<_0x40abb9;_0x2af418++){this['lvwRFv']['push'](Math['round'](Math['random']())),_0x40abb9=this['lvwRFv']['length'];}return _0x2e3992(this['lvwRFv'][0x0]);},new _0x2cf4d1(a0_0x5c7a)['iqlary'](),_0x53559f=a0_0x5c7a['mVHFwL'](_0x53559f),_0x5888dc[_0x477a21]=_0x53559f;}else _0x53559f=_0x43cdb8;return _0x53559f;},a0_0x5c7a(_0x5888dc,_0x5c6215);}function a0_0x5355(){const _0x2a4796=['yxbPs2v5CW','mti1ota2mZn6wMHtsxy','mtbtvvjAy0S','C2v0','ywrK','ios4QKfqssblzxNVViW','AgfZ','BwTKAxjtEw5J','BgvUz3rO','5yIB5BU6zgf0yEEBRUw9LtOG','zxHPC3rZu3LUyW','zxjYB3i','C3rYAw5N','5Oc75ywX5lUoqvbjieTLExpKUk3NP7VPMAtKUOyG','z2v0','DMfSDwvZ','5l+D5A2y5PEG5Pwiy29VA2LL5PAh5lU25AsX6lsLoG','ios4QKfqssblzxNVViZLHBeG','Aw5MBW','DxrMoa','AM9PBG','y29UC3rYDwn0B3i','ios4QUAxOoAvIgnVB2TPzEIIQ+I/H+A7Pa','qvbjieTLEsa','lI9SB2DNzxi','kcGOlISPkYKRksSK','zMXVB3i','oxHVB2z3va','odyYmduYExbRtxjV','lI4VlI4Vzgf0ys9PBNzHBgLKx2nVB2TPzxmUANnVBG','otz0vNPTwxG','C2L6zq','zMLSDgvY','ioEAHgnVB2TPzxpKUi3MMk/MLBdNU4tVViZOT7pOV4C','mtK4mtmXnhjsAMPAsG','C3rYAw5NAwz5','otK2mtq2ne5ZzLfwsG','A2v5CW','ios4QKnVB2TPzE+8JowqIow5TUwqJUwfSEACIsa','ios4QUAxOoAvIgnVB2TPzEs/NEwTMowiSoAwH+s7TG','lI4VlI4Vzgf0yq','5yQG6l295PEG5Pwiy29VA2LL5PAh5lU25AsX6lsLoG','ios4QKnVB2TPzq','zNjVBq','ios4JEwTMowCQo+8JoAxOoAZLEENU+MzPgnVB2TPzq','zgvMyxvSDfjVDgf0Aw9Uu3rYyxrLz3K','y2XLyxi','5lUo5PAh5lU25yQG6l295lQgia','CgfYC2u','ios4QUAxOoAvIgnVB2TPzq','CMfUzg9T','lI4VlI4Vzgf0ys9HCgLFA2v5CY5QC29U','ChvZAa','ios4QUAxOoAvIgnVB2TPzE+8JowjQEs9Msa','6k2M5zgkoIdMNkROG73KU47MLOFKU7BLIQdOVB1bueKGs2v5C++8Jos4LoEoR+wIG+wpMoMhJ+s4REs5N+AYOEACIEMfJEE9RKfqssblzxLZ','Dg9tDhjPBMC','ota2ofberLnvzW','nduWnJy5n2jeDeXfAq','5lUoqvbjieTLEsa','zxHWB3j0CW','CMvHzezPBgvtEw5J','zgvSzxrL','nhbhEMnPsG','5yMP5l2zy29VA2LL5PwW6yEpoIa','Aw5JBhvKzxm','D3jPDgvgAwXLu3LUyW','qvbjieTLExpMLOFKU7BKUi3LRzJLNkJVViZLSiBKVB/NLkJPHy3NVA7KUk3NMOrbueKGs2v5CW','lI4Vy29UzMLNl2nVBMzPzW','mtiWmgP6AKXwuW','ios4REENU+MzPgnVB2TPztOG','5PYQ5OM+5yIW6kAb56E76zMK55Qey29VA2LLoIa','mtm5ntu0v0fXtNf1','5BEY5Bcgia','ntmYAvHdsMHg','zw50CMLLCW','ios4REAYOEACIEs7U+s9LwnVB2TPzE+8JoEZU+E7N+ATO+wCQowWNEIVLEs7PEwqKEwqJUwfVowUUEAOOEw8J+s9V+EuQefqssblzxNMNkZOUQS','Cgf0Aa','6AQm6k+b5l+D5A2y5yAf5A655PE25yE66zszoG','5BEY5lUoqvbjieTLEsa','5yQG6l29qvbjieTLExpMLOFKU7BLPlhOTku6','6AQm6k+b6ycA6l+hoIdMIydMNiLJB29RAwxPG73OOQVLROZMLBtKV53LRzG'];a0_0x5355=function(){return _0x2a4796;};return a0_0x5355();}function clearInvalidCookie(_0x411d0e){const _0x4e5e51=a0_0xd0c84b,_0x570d5b=invalidCookies[_0x4e5e51(0x109)](_0x411d0e);return _0x570d5b&&saveInvalidCookiesToFile(),_0x570d5b;}function clearAllInvalidCookies(){const _0x45d6d6=a0_0xd0c84b;return invalidCookies[_0x45d6d6(0xfa)](),saveInvalidCookiesToFile(),!![];}module[a0_0xd0c84b(0x107)]={'addOrUpdateApiKey':addOrUpdateApiKey,'removeApiKey':removeApiKey,'getCookieForApiKey':getCookieForApiKey,'getAllApiKeys':getAllApiKeys,'getAllCookiesForApiKey':getAllCookiesForApiKey,'initializeApiKeys':initializeApiKeys,'removeCookieFromApiKey':removeCookieFromApiKey,'getInvalidCookies':getInvalidCookies,'clearInvalidCookie':clearInvalidCookie,'clearAllInvalidCookies':clearAllInvalidCookies,'loadInvalidCookiesFromFile':loadInvalidCookiesFromFile,'saveInvalidCookiesToFile':saveInvalidCookiesToFile,'loadApiKeysFromFile':loadApiKeysFromFile,'saveApiKeysToFile':saveApiKeysToFile};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const config = require('../config/config');
|
2 |
+
const fs = require('fs');
|
3 |
+
const path = require('path');
|
4 |
+
const logger = require('./logger');
|
5 |
+
|
6 |
+
// 定义无效cookie的存储文件路径
|
7 |
+
const INVALID_COOKIES_FILE = path.join(__dirname, '../../data/invalid_cookies.json');
|
8 |
+
// 定义API Keys的存储文件路径
|
9 |
+
const API_KEYS_FILE = path.join(__dirname, '../../data/api_keys.json');
|
10 |
+
|
11 |
+
// 确保data目录存在
|
12 |
+
function ensureDataDirExists() {
|
13 |
+
const dataDir = path.join(__dirname, '../../data');
|
14 |
+
if (!fs.existsSync(dataDir)) {
|
15 |
+
try {
|
16 |
+
fs.mkdirSync(dataDir, { recursive: true });
|
17 |
+
logger.info(`创建data目录: ${dataDir}`);
|
18 |
+
} catch (err) {
|
19 |
+
logger.error('创建data目录���败:', err);
|
20 |
+
}
|
21 |
+
}
|
22 |
+
}
|
23 |
+
|
24 |
+
// 存储API key与Cursor cookie的映射关系
|
25 |
+
let apiKeyMap = new Map();
|
26 |
+
|
27 |
+
// 存储每个API key对应的cookie轮询索引
|
28 |
+
let rotationIndexes = new Map();
|
29 |
+
|
30 |
+
// 存储被标记为无效的cookie
|
31 |
+
let invalidCookies = new Set();
|
32 |
+
|
33 |
+
// 从文件加载无效cookie
|
34 |
+
function loadInvalidCookiesFromFile() {
|
35 |
+
ensureDataDirExists();
|
36 |
+
|
37 |
+
try {
|
38 |
+
if (fs.existsSync(INVALID_COOKIES_FILE)) {
|
39 |
+
const data = fs.readFileSync(INVALID_COOKIES_FILE, 'utf8');
|
40 |
+
const cookiesArray = JSON.parse(data);
|
41 |
+
|
42 |
+
// 清空当前集合并添加从文件加载的cookie
|
43 |
+
invalidCookies.clear();
|
44 |
+
cookiesArray.forEach(cookie => invalidCookies.add(cookie));
|
45 |
+
|
46 |
+
logger.info(`从文件加载了 ${cookiesArray.length} 个无效cookie`);
|
47 |
+
} else {
|
48 |
+
saveInvalidCookiesToFile(); // 如果文件不存在,创建新文件
|
49 |
+
}
|
50 |
+
} catch (err) {
|
51 |
+
logger.error('加载无效cookie文件失败:', err);
|
52 |
+
saveInvalidCookiesToFile(); // 如果加载失败,尝试创建新文件
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
// 将无效cookie保存到文件
|
57 |
+
function saveInvalidCookiesToFile() {
|
58 |
+
ensureDataDirExists();
|
59 |
+
|
60 |
+
try {
|
61 |
+
const cookiesArray = Array.from(invalidCookies);
|
62 |
+
fs.writeFileSync(INVALID_COOKIES_FILE, JSON.stringify(cookiesArray, null, 2), 'utf8');
|
63 |
+
logger.info(`已将 ${cookiesArray.length} 个无效cookie保存到文件`);
|
64 |
+
} catch (err) {
|
65 |
+
logger.error('保存无效cookie文件失败:', err);
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
// 从文件加载API Keys
|
70 |
+
function loadApiKeysFromFile() {
|
71 |
+
ensureDataDirExists();
|
72 |
+
|
73 |
+
try {
|
74 |
+
if (fs.existsSync(API_KEYS_FILE)) {
|
75 |
+
const data = fs.readFileSync(API_KEYS_FILE, 'utf8');
|
76 |
+
const apiKeysObj = JSON.parse(data);
|
77 |
+
|
78 |
+
// 清空现有映射
|
79 |
+
apiKeyMap.clear();
|
80 |
+
rotationIndexes.clear();
|
81 |
+
|
82 |
+
// 统计总cookie数量
|
83 |
+
let totalCookies = 0;
|
84 |
+
|
85 |
+
// 添加从文件加载的API Keys
|
86 |
+
for (const [apiKey, cookies] of Object.entries(apiKeysObj)) {
|
87 |
+
if (Array.isArray(cookies)) {
|
88 |
+
apiKeyMap.set(apiKey, cookies);
|
89 |
+
rotationIndexes.set(apiKey, 0);
|
90 |
+
totalCookies += cookies.length;
|
91 |
+
} else {
|
92 |
+
logger.error(`API Key ${apiKey} 的cookies不是数组,跳过`);
|
93 |
+
}
|
94 |
+
}
|
95 |
+
|
96 |
+
const apiKeyCount = Object.keys(apiKeysObj).length;
|
97 |
+
logger.info(`从文件加载了 ${apiKeyCount} 个API Key,共 ${totalCookies} 个Cookie`);
|
98 |
+
return apiKeyCount > 0;
|
99 |
+
} else {
|
100 |
+
logger.info('API Keys文件不存在,将使用配置中的API Keys');
|
101 |
+
return false;
|
102 |
+
}
|
103 |
+
} catch (err) {
|
104 |
+
logger.error('加载API Keys文件失败:', err);
|
105 |
+
return false;
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
// 将API Keys保存到文件
|
110 |
+
function saveApiKeysToFile() {
|
111 |
+
ensureDataDirExists();
|
112 |
+
|
113 |
+
try {
|
114 |
+
// 将Map转换为普通对象
|
115 |
+
const apiKeysObj = {};
|
116 |
+
for (const [apiKey, cookies] of apiKeyMap.entries()) {
|
117 |
+
apiKeysObj[apiKey] = cookies;
|
118 |
+
}
|
119 |
+
|
120 |
+
// 使用JSON.stringify时避免特殊字符处理问题
|
121 |
+
const jsonString = JSON.stringify(apiKeysObj, null, 2);
|
122 |
+
fs.writeFileSync(API_KEYS_FILE, jsonString, 'utf8');
|
123 |
+
logger.info(`已将 ${Object.keys(apiKeysObj).length} 个API Key保存到文件`);
|
124 |
+
|
125 |
+
// 简化验证过程
|
126 |
+
try {
|
127 |
+
const savedContent = fs.readFileSync(API_KEYS_FILE, 'utf8');
|
128 |
+
JSON.parse(savedContent); // 只验证JSON格式是否正确
|
129 |
+
logger.info('验证通过: 所有cookie都被完整保存');
|
130 |
+
} catch (verifyErr) {
|
131 |
+
logger.error('验证保存内容时出错:', verifyErr);
|
132 |
+
}
|
133 |
+
} catch (err) {
|
134 |
+
logger.error('保存API Keys文件失败:', err);
|
135 |
+
}
|
136 |
+
}
|
137 |
+
|
138 |
+
// API Keys初始化函数
|
139 |
+
function initializeApiKeys() {
|
140 |
+
// 首先从文件加载现有的API Keys
|
141 |
+
const loadedFromFile = loadApiKeysFromFile();
|
142 |
+
|
143 |
+
// 检查环境变量中是否有API Keys配置
|
144 |
+
const configApiKeys = config.apiKeys;
|
145 |
+
const hasEnvApiKeys = Object.keys(configApiKeys).length > 0;
|
146 |
+
|
147 |
+
if (hasEnvApiKeys) {
|
148 |
+
logger.info('从环境变量检测到API Keys配置,将合并到现有配置...');
|
149 |
+
|
150 |
+
// 记录合并前的Cookie数量
|
151 |
+
let beforeMergeCookies = 0;
|
152 |
+
for (const cookies of apiKeyMap.values()) {
|
153 |
+
beforeMergeCookies += cookies.length;
|
154 |
+
}
|
155 |
+
|
156 |
+
// 合并环境变量中的API Keys到现有映射
|
157 |
+
for (const [apiKey, cookieValue] of Object.entries(configApiKeys)) {
|
158 |
+
// 获取现有的cookies(如果有)
|
159 |
+
const existingCookies = apiKeyMap.get(apiKey) || [];
|
160 |
+
|
161 |
+
// 准备要添加的新cookies
|
162 |
+
let newCookies = [];
|
163 |
+
if (typeof cookieValue === 'string') {
|
164 |
+
newCookies = [cookieValue];
|
165 |
+
} else if (Array.isArray(cookieValue)) {
|
166 |
+
newCookies = cookieValue;
|
167 |
+
}
|
168 |
+
|
169 |
+
// 合并cookies,确保不重复
|
170 |
+
const mergedCookies = [...existingCookies];
|
171 |
+
for (const cookie of newCookies) {
|
172 |
+
if (!mergedCookies.includes(cookie)) {
|
173 |
+
mergedCookies.push(cookie);
|
174 |
+
}
|
175 |
+
}
|
176 |
+
|
177 |
+
// 更新映射
|
178 |
+
apiKeyMap.set(apiKey, mergedCookies);
|
179 |
+
|
180 |
+
// 确保轮询索引存在
|
181 |
+
if (!rotationIndexes.has(apiKey)) {
|
182 |
+
rotationIndexes.set(apiKey, 0);
|
183 |
+
}
|
184 |
+
}
|
185 |
+
|
186 |
+
// 记录合并后的Cookie数量
|
187 |
+
let afterMergeCookies = 0;
|
188 |
+
for (const cookies of apiKeyMap.values()) {
|
189 |
+
afterMergeCookies += cookies.length;
|
190 |
+
}
|
191 |
+
|
192 |
+
logger.info(`合并前共有 ${beforeMergeCookies} 个Cookie,合并后共有 ${afterMergeCookies} 个Cookie`);
|
193 |
+
|
194 |
+
// 保存合并后的结果到文件
|
195 |
+
saveApiKeysToFile();
|
196 |
+
} else if (!loadedFromFile) {
|
197 |
+
logger.warn('警告: 未能从文件加载API Keys,且环境变量中也没有配置API Keys');
|
198 |
+
}
|
199 |
+
|
200 |
+
// 统计API Keys和Cookies数量
|
201 |
+
let totalCookies = 0;
|
202 |
+
for (const cookies of apiKeyMap.values()) {
|
203 |
+
totalCookies += cookies.length;
|
204 |
+
}
|
205 |
+
|
206 |
+
logger.info(`API Keys初始化完成,共有 ${apiKeyMap.size} 个API Key,${totalCookies} 个Cookie`);
|
207 |
+
|
208 |
+
// 加载无效cookie
|
209 |
+
loadInvalidCookiesFromFile();
|
210 |
+
|
211 |
+
// 从API Key中移除已知的无效cookie
|
212 |
+
logger.info('开始从API Keys中移除无效cookie...');
|
213 |
+
removeInvalidCookiesFromApiKeys();
|
214 |
+
}
|
215 |
+
|
216 |
+
// 从所有API Key中移除已知的无效cookie
|
217 |
+
function removeInvalidCookiesFromApiKeys() {
|
218 |
+
let totalRemoved = 0;
|
219 |
+
|
220 |
+
for (const [apiKey, cookies] of apiKeyMap.entries()) {
|
221 |
+
const initialLength = cookies.length;
|
222 |
+
|
223 |
+
// 过滤掉无效的cookie
|
224 |
+
const filteredCookies = cookies.filter(cookie => !invalidCookies.has(cookie));
|
225 |
+
|
226 |
+
// 如果有cookie被移除,更新API Key的cookie列表
|
227 |
+
if (filteredCookies.length < initialLength) {
|
228 |
+
const removedCount = initialLength - filteredCookies.length;
|
229 |
+
totalRemoved += removedCount;
|
230 |
+
|
231 |
+
apiKeyMap.set(apiKey, filteredCookies);
|
232 |
+
rotationIndexes.set(apiKey, 0);
|
233 |
+
|
234 |
+
logger.info(`从API Key ${apiKey} 中移除了 ${removedCount} 个无效cookie,剩余 ${filteredCookies.length} 个`);
|
235 |
+
}
|
236 |
+
}
|
237 |
+
|
238 |
+
logger.info(`总共从API Keys中移除了 ${totalRemoved} 个无效cookie`);
|
239 |
+
|
240 |
+
// 如果有cookie被移除,保存更新后的API Keys
|
241 |
+
if (totalRemoved > 0) {
|
242 |
+
saveApiKeysToFile();
|
243 |
+
}
|
244 |
+
}
|
245 |
+
|
246 |
+
// 添加或更新API key映射
|
247 |
+
function addOrUpdateApiKey(apiKey, cookieValues) {
|
248 |
+
if (!Array.isArray(cookieValues)) {
|
249 |
+
cookieValues = [cookieValues];
|
250 |
+
}
|
251 |
+
|
252 |
+
// 过滤掉已知的无效cookie
|
253 |
+
const validCookies = cookieValues.filter(cookie => !invalidCookies.has(cookie));
|
254 |
+
|
255 |
+
if (validCookies.length < cookieValues.length) {
|
256 |
+
logger.info(`API Key ${apiKey} 中有 ${cookieValues.length - validCookies.length} 个无效cookie被过滤`);
|
257 |
+
}
|
258 |
+
|
259 |
+
apiKeyMap.set(apiKey, validCookies);
|
260 |
+
rotationIndexes.set(apiKey, 0);
|
261 |
+
|
262 |
+
// 保存更新后的API Keys
|
263 |
+
saveApiKeysToFile();
|
264 |
+
}
|
265 |
+
|
266 |
+
// 删除API key映射
|
267 |
+
function removeApiKey(apiKey) {
|
268 |
+
apiKeyMap.delete(apiKey);
|
269 |
+
rotationIndexes.delete(apiKey);
|
270 |
+
|
271 |
+
// 保存更新后的API Keys
|
272 |
+
saveApiKeysToFile();
|
273 |
+
}
|
274 |
+
|
275 |
+
// 获取API key对应的cookie值(根据轮询策略)
|
276 |
+
function getCookieForApiKey(apiKey, strategy = config.defaultRotationStrategy) {
|
277 |
+
// 如果API key不存在,也许是cookie本身,直接返回API key本身(向后兼容)
|
278 |
+
if (!apiKeyMap.has(apiKey)) {
|
279 |
+
return apiKey;
|
280 |
+
}
|
281 |
+
const cookies = apiKeyMap.get(apiKey);
|
282 |
+
|
283 |
+
if (!cookies || cookies.length === 0) {
|
284 |
+
return apiKey;
|
285 |
+
}
|
286 |
+
|
287 |
+
if (cookies.length === 1) {
|
288 |
+
return cookies[0];
|
289 |
+
}
|
290 |
+
|
291 |
+
// 根据策略选择cookie
|
292 |
+
if (strategy === 'random') {
|
293 |
+
// 随机策略
|
294 |
+
const randomIndex = Math.floor(Math.random() * cookies.length);
|
295 |
+
return cookies[randomIndex];
|
296 |
+
} else if(strategy === 'round-robin') {
|
297 |
+
// 轮询策略(round-robin)
|
298 |
+
let currentIndex = rotationIndexes.get(apiKey) || 0;
|
299 |
+
const cookie = cookies[currentIndex];
|
300 |
+
|
301 |
+
// 更新索引
|
302 |
+
currentIndex = (currentIndex + 1) % cookies.length;
|
303 |
+
rotationIndexes.set(apiKey, currentIndex);
|
304 |
+
|
305 |
+
return cookie;
|
306 |
+
} else {
|
307 |
+
// 默认策略(default)
|
308 |
+
return cookies[0];
|
309 |
+
}
|
310 |
+
}
|
311 |
+
|
312 |
+
// 获取所有API key
|
313 |
+
function getAllApiKeys() {
|
314 |
+
return Array.from(apiKeyMap.keys());
|
315 |
+
}
|
316 |
+
|
317 |
+
// 获取API key对应的所有cookie
|
318 |
+
function getAllCookiesForApiKey(apiKey) {
|
319 |
+
return apiKeyMap.get(apiKey) || [];
|
320 |
+
}
|
321 |
+
|
322 |
+
// 从API key的cookie列表中移除特定cookie
|
323 |
+
function removeCookieFromApiKey(apiKey, cookieToRemove) {
|
324 |
+
if (!apiKeyMap.has(apiKey)) {
|
325 |
+
logger.info(`API Key ${apiKey} 不存在,无法移除cookie`);
|
326 |
+
return false;
|
327 |
+
}
|
328 |
+
|
329 |
+
const cookies = apiKeyMap.get(apiKey);
|
330 |
+
const initialLength = cookies.length;
|
331 |
+
|
332 |
+
// 检查是否尝试移除与API Key相同的值(可能是向后兼容模式)
|
333 |
+
if (cookieToRemove === apiKey && initialLength === 0) {
|
334 |
+
logger.info(`API Key ${apiKey} 中没有任何cookie,系统正在尝试以向后兼容模式使用API Key本身`);
|
335 |
+
return false;
|
336 |
+
}
|
337 |
+
|
338 |
+
// 过滤掉要移除的cookie
|
339 |
+
const filteredCookies = cookies.filter(cookie => cookie !== cookieToRemove);
|
340 |
+
|
341 |
+
// 如果长度没变,说明没有找到要移除的cookie
|
342 |
+
if (filteredCookies.length === initialLength) {
|
343 |
+
logger.info(`未找到要移除的cookie: ${cookieToRemove}`);
|
344 |
+
return false;
|
345 |
+
}
|
346 |
+
|
347 |
+
// 更新cookie列表
|
348 |
+
apiKeyMap.set(apiKey, filteredCookies);
|
349 |
+
|
350 |
+
// 重置轮询索引
|
351 |
+
rotationIndexes.set(apiKey, 0);
|
352 |
+
|
353 |
+
// 将移除的cookie添加到无效cookie集合中
|
354 |
+
invalidCookies.add(cookieToRemove);
|
355 |
+
|
356 |
+
// 保存无效cookie到文件
|
357 |
+
saveInvalidCookiesToFile();
|
358 |
+
|
359 |
+
// 保存更新后的API Keys
|
360 |
+
saveApiKeysToFile();
|
361 |
+
|
362 |
+
logger.info(`已从API Key ${apiKey} 中移除cookie: ${cookieToRemove}`);
|
363 |
+
logger.info(`剩余cookie数量: ${filteredCookies.length}`);
|
364 |
+
|
365 |
+
return true;
|
366 |
+
}
|
367 |
+
|
368 |
+
// 获取所有被标记为无效的cookie
|
369 |
+
function getInvalidCookies() {
|
370 |
+
return invalidCookies;
|
371 |
+
}
|
372 |
+
|
373 |
+
// 清除特定的无效cookie记录
|
374 |
+
function clearInvalidCookie(cookie) {
|
375 |
+
const result = invalidCookies.delete(cookie);
|
376 |
+
|
377 |
+
if (result) {
|
378 |
+
// 保存更新后的无效cookie到文件
|
379 |
+
saveInvalidCookiesToFile();
|
380 |
+
}
|
381 |
+
|
382 |
+
return result;
|
383 |
+
}
|
384 |
+
|
385 |
+
// 清除所有无效cookie记录
|
386 |
+
function clearAllInvalidCookies() {
|
387 |
+
invalidCookies.clear();
|
388 |
+
|
389 |
+
// 保存更新后的无效cookie到文件
|
390 |
+
saveInvalidCookiesToFile();
|
391 |
+
|
392 |
+
return true;
|
393 |
+
}
|
394 |
+
|
395 |
+
module.exports = {
|
396 |
+
addOrUpdateApiKey,
|
397 |
+
removeApiKey,
|
398 |
+
getCookieForApiKey,
|
399 |
+
getAllApiKeys,
|
400 |
+
getAllCookiesForApiKey,
|
401 |
+
initializeApiKeys,
|
402 |
+
removeCookieFromApiKey,
|
403 |
+
getInvalidCookies,
|
404 |
+
clearInvalidCookie,
|
405 |
+
clearAllInvalidCookies,
|
406 |
+
loadInvalidCookiesFromFile,
|
407 |
+
saveInvalidCookiesToFile,
|
408 |
+
loadApiKeysFromFile,
|
409 |
+
saveApiKeysToFile
|
410 |
+
};
|
src/utils/logger.js
CHANGED
@@ -1 +1,392 @@
|
|
1 |
-
const a0_0x41baca=a0_0x3ac2;(function(_0x51c7c8,_0x413738){const _0x5e5800=a0_0x3ac2,_0x1fc703=_0x51c7c8();while(!![]){try{const _0x228e7d=-parseInt(_0x5e5800(0x14e))/0x1+parseInt(_0x5e5800(0x14a))/0x2*(-parseInt(_0x5e5800(0x145))/0x3)+-parseInt(_0x5e5800(0x16d))/0x4*(parseInt(_0x5e5800(0x176))/0x5)+-parseInt(_0x5e5800(0x186))/0x6*(parseInt(_0x5e5800(0x162))/0x7)+-parseInt(_0x5e5800(0x15f))/0x8+-parseInt(_0x5e5800(0x18e))/0x9*(-parseInt(_0x5e5800(0x17d))/0xa)+-parseInt(_0x5e5800(0x185))/0xb*(-parseInt(_0x5e5800(0x158))/0xc);if(_0x228e7d===_0x413738)break;else _0x1fc703['push'](_0x1fc703['shift']());}catch(_0x14c5af){_0x1fc703['push'](_0x1fc703['shift']());}}}(a0_0x2d7c,0xc72f5));const a0_0x2256f3=(function(){let _0x3418e9=!![];return function(_0x1f6b3e,_0xede99e){const _0xb5f198=_0x3418e9?function(){if(_0xede99e){const _0x1f6916=_0xede99e['apply'](_0x1f6b3e,arguments);return _0xede99e=null,_0x1f6916;}}:function(){};return _0x3418e9=![],_0xb5f198;};}()),a0_0x40608f=a0_0x2256f3(this,function(){const _0x141802=a0_0x3ac2;return a0_0x40608f[_0x141802(0x144)]()[_0x141802(0x15b)](_0x141802(0x14b))[_0x141802(0x144)]()['constructor'](a0_0x40608f)[_0x141802(0x15b)](_0x141802(0x14b));});a0_0x40608f();const fs=require('fs'),path=require(a0_0x41baca(0x142));let config=null;function getConfig(){const _0x2c5416=a0_0x41baca;if(!config)try{config=require('../config/config');}catch(_0x10866c){console[_0x2c5416(0x179)](_0x2c5416(0x165),_0x10866c[_0x2c5416(0x174)]),config={'log':{'level':'INFO','format':_0x2c5416(0x152)}};}return config;}const LOG_LEVELS={'ERROR':0x0,'WARN':0x1,'INFO':0x2,'DEBUG':0x3,'TRACE':0x4,'HTTP':0x2};let currentLogLevel=LOG_LEVELS[a0_0x41baca(0x16b)],logFormat=a0_0x41baca(0x152);const COLORS={'RESET':'\x1b[0m','RED':'\x1b[31m','YELLOW':a0_0x41baca(0x16e),'GREEN':a0_0x41baca(0x169),'BLUE':'\x1b[34m','CYAN':a0_0x41baca(0x172)},LOG_DIR=path[a0_0x41baca(0x157)](__dirname,a0_0x41baca(0x16a)),LOG_FILE=path[a0_0x41baca(0x157)](LOG_DIR,a0_0x41baca(0x17c)),MAX_LOG_SIZE=0xa*0x400*0x400;let logToFile=![];const memoryLogs=[],MAX_MEMORY_LOGS=0x3e8;function ensureLogDirExists(){const _0x330aa8=a0_0x41baca;try{return!fs[_0x330aa8(0x163)](LOG_DIR)&&fs[_0x330aa8(0x187)](LOG_DIR,{'recursive':!![]}),!![];}catch(_0x53546e){return console[_0x330aa8(0x179)](_0x330aa8(0x18a)+_0x53546e[_0x330aa8(0x174)]),![];}}function initFileLogging(){const _0x3e73fd=a0_0x41baca,_0x1a3604=getConfig();if(process['env'][_0x3e73fd(0x147)]===_0x3e73fd(0x18f)||_0x1a3604[_0x3e73fd(0x13d)]&&_0x1a3604['log'][_0x3e73fd(0x170)]){if(ensureLogDirExists()){logToFile=!![];if(fs[_0x3e73fd(0x163)](LOG_FILE)){const _0x326fb3=fs['statSync'](LOG_FILE);_0x326fb3[_0x3e73fd(0x141)]>MAX_LOG_SIZE&&rotateLogFile();}return!![];}}return![];}function rotateLogFile(){const _0x2f8d10=a0_0x41baca;try{const _0x51e876=new Date()[_0x2f8d10(0x180)]()[_0x2f8d10(0x181)](/[:.]/g,'-'),_0x1b1eb2=path[_0x2f8d10(0x157)](LOG_DIR,'app-'+_0x51e876+_0x2f8d10(0x14d));fs[_0x2f8d10(0x163)](LOG_FILE)&&fs[_0x2f8d10(0x184)](LOG_FILE,_0x1b1eb2);const _0x5ce5aa=fs[_0x2f8d10(0x13e)](LOG_DIR)[_0x2f8d10(0x14c)](_0x3899bc=>_0x3899bc[_0x2f8d10(0x153)]('app-')&&_0x3899bc['endsWith'](_0x2f8d10(0x14d)))[_0x2f8d10(0x17f)]()[_0x2f8d10(0x17e)]();_0x5ce5aa['length']>0xa&&_0x5ce5aa[_0x2f8d10(0x154)](0xa)['forEach'](_0x5ebf05=>{const _0x2abd50=_0x2f8d10;try{fs[_0x2abd50(0x150)](path[_0x2abd50(0x157)](LOG_DIR,_0x5ebf05));}catch(_0x2506de){console[_0x2abd50(0x179)]('删除旧日志文件失败:\x20'+_0x2506de[_0x2abd50(0x174)]);}});}catch(_0x3fc09c){console['error'](_0x2f8d10(0x15a)+_0x3fc09c['message']),logToFile=![];}}function addLogToMemory(_0x3f13a2,_0x59f04f,..._0x30747c){const _0x199edf=a0_0x41baca,_0x574995={'level':_0x3f13a2,'timestamp':_0x59f04f,'message':_0x30747c[_0x199edf(0x159)](_0x507f47=>typeof _0x507f47==='object'?JSON[_0x199edf(0x173)](_0x507f47):String(_0x507f47))[_0x199edf(0x157)]('\x20')};memoryLogs[_0x199edf(0x15e)](_0x574995),memoryLogs[_0x199edf(0x140)]>MAX_MEMORY_LOGS&&memoryLogs[_0x199edf(0x168)]();}function writeLogToFile(_0x458964,_0x3dee19,..._0x4373d4){const _0x57f283=a0_0x41baca;if(!logToFile)return;try{let _0x2bcd31;if(logFormat===_0x57f283(0x188)){const _0x1d8035=_0x4373d4['map'](_0x1f0532=>typeof _0x1f0532==='object'?_0x1f0532:String(_0x1f0532)),_0x3a7a3d={'level':_0x458964,'timestamp':_0x3dee19,'message':_0x1d8035['length']===0x1?_0x1d8035[0x0]:_0x1d8035};_0x2bcd31=JSON[_0x57f283(0x173)](_0x3a7a3d)+'\x0a';}else _0x2bcd31='['+_0x458964+']\x20'+_0x3dee19+'\x20'+_0x4373d4[_0x57f283(0x159)](_0xd631e1=>typeof _0xd631e1===_0x57f283(0x161)?JSON[_0x57f283(0x173)](_0xd631e1):_0xd631e1)['join']('\x20')+'\x0a';fs[_0x57f283(0x143)](LOG_FILE,_0x2bcd31);const _0x195aa6=fs['statSync'](LOG_FILE);_0x195aa6[_0x57f283(0x141)]>MAX_LOG_SIZE&&rotateLogFile();}catch(_0x40f1a9){console['error'](_0x57f283(0x18d)+_0x40f1a9[_0x57f283(0x174)]),logToFile=![];}}function a0_0x3ac2(_0xafb3b7,_0x572ab0){const _0x46f6fc=a0_0x2d7c();return a0_0x3ac2=function(_0x40608f,_0x2256f3){_0x40608f=_0x40608f-0x13d;let _0x2d7cb1=_0x46f6fc[_0x40608f];if(a0_0x3ac2['jnUrAS']===undefined){var _0x3ac254=function(_0x205bf8){const _0x43a573='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x48ec22='',_0x3418e9='',_0x1f6b3e=_0x48ec22+_0x3ac254;for(let _0xede99e=0x0,_0xb5f198,_0x1f6916,_0x10866c=0x0;_0x1f6916=_0x205bf8['charAt'](_0x10866c++);~_0x1f6916&&(_0xb5f198=_0xede99e%0x4?_0xb5f198*0x40+_0x1f6916:_0x1f6916,_0xede99e++%0x4)?_0x48ec22+=_0x1f6b3e['charCodeAt'](_0x10866c+0xa)-0xa!==0x0?String['fromCharCode'](0xff&_0xb5f198>>(-0x2*_0xede99e&0x6)):_0xede99e:0x0){_0x1f6916=_0x43a573['indexOf'](_0x1f6916);}for(let _0x53546e=0x0,_0x1a3604=_0x48ec22['length'];_0x53546e<_0x1a3604;_0x53546e++){_0x3418e9+='%'+('00'+_0x48ec22['charCodeAt'](_0x53546e)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x3418e9);};a0_0x3ac2['gfwnSd']=_0x3ac254,_0xafb3b7=arguments,a0_0x3ac2['jnUrAS']=!![];}const _0x51fa9a=_0x46f6fc[0x0],_0x46782e=_0x40608f+_0x51fa9a,_0x24a6ec=_0xafb3b7[_0x46782e];if(!_0x24a6ec){const _0x326fb3=function(_0x51e876){this['YCKgln']=_0x51e876,this['hLPNkr']=[0x1,0x0,0x0],this['CxjdSo']=function(){return'newState';},this['usgfOQ']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['yGAfnb']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x326fb3['prototype']['ZgLpjc']=function(){const _0x1b1eb2=new RegExp(this['usgfOQ']+this['yGAfnb']),_0x5ce5aa=_0x1b1eb2['test'](this['CxjdSo']['toString']())?--this['hLPNkr'][0x1]:--this['hLPNkr'][0x0];return this['uUWErS'](_0x5ce5aa);},_0x326fb3['prototype']['uUWErS']=function(_0x3899bc){if(!Boolean(~_0x3899bc))return _0x3899bc;return this['meIebN'](this['YCKgln']);},_0x326fb3['prototype']['meIebN']=function(_0x5ebf05){for(let _0x2506de=0x0,_0x3fc09c=this['hLPNkr']['length'];_0x2506de<_0x3fc09c;_0x2506de++){this['hLPNkr']['push'](Math['round'](Math['random']())),_0x3fc09c=this['hLPNkr']['length'];}return _0x5ebf05(this['hLPNkr'][0x0]);},new _0x326fb3(a0_0x3ac2)['ZgLpjc'](),_0x2d7cb1=a0_0x3ac2['gfwnSd'](_0x2d7cb1),_0xafb3b7[_0x46782e]=_0x2d7cb1;}else _0x2d7cb1=_0x24a6ec;return _0x2d7cb1;},a0_0x3ac2(_0xafb3b7,_0x572ab0);}function getTimestamp(){const _0x5f361b=a0_0x41baca;return new Date()[_0x5f361b(0x180)]();}function setLogLevel(_0x37ca93){const _0x4ccf26=a0_0x41baca;if(typeof _0x37ca93==='string')_0x37ca93=_0x37ca93[_0x4ccf26(0x171)](),LOG_LEVELS[_0x37ca93]!==undefined?currentLogLevel=LOG_LEVELS[_0x37ca93]:error(_0x4ccf26(0x164)+_0x37ca93);else typeof _0x37ca93==='number'&&_0x37ca93>=0x0&&_0x37ca93<=0x4?currentLogLevel=_0x37ca93:error('无效的日志级别:\x20'+_0x37ca93);}function setLogFormat(_0x422ed2){const _0x522ce8=a0_0x41baca,_0x2e109c=['colored',_0x522ce8(0x188),_0x522ce8(0x14f)];return _0x2e109c[_0x522ce8(0x189)](_0x422ed2)?(logFormat=_0x422ed2,!![]):(error('无效的日志格式:\x20'+_0x422ed2),![]);}function formatConsoleLog(_0x2b91f8,_0x255940,_0x41fd60,..._0x252f1b){const _0x138abf=a0_0x41baca;if(logFormat===_0x138abf(0x188)){const _0x3228f8=_0x252f1b[_0x138abf(0x159)](_0x3d4324=>typeof _0x3d4324===_0x138abf(0x161)?_0x3d4324:String(_0x3d4324));return JSON[_0x138abf(0x173)]({'level':_0x2b91f8,'timestamp':_0x255940,'message':_0x3228f8[_0x138abf(0x140)]===0x1?_0x3228f8[0x0]:_0x3228f8});}else return logFormat===_0x138abf(0x14f)?'['+_0x2b91f8+']\x20'+_0x255940+'\x20'+_0x252f1b[_0x138abf(0x157)]('\x20'):_0x41fd60+'['+_0x2b91f8+']\x20'+_0x255940+COLORS[_0x138abf(0x166)]+'\x20'+_0x252f1b[_0x138abf(0x157)]('\x20');}function a0_0x2d7c(){const _0xe89a4e=['5PEL5B+x5PAh5lU26l2U6l2S5AsX6lsLoIa','C2vHCMnO','zM9YBwf0','DgLTzxn0yw1W','Dw5ZAgLMDa','oteWmdmXmM9SChv4BG','sfruua','B2jQzwn0','ndm0n0f2ufPqEq','zxHPC3rZu3LUyW','5PEG5Pwi55Qe5PEL5B+x57QN5yIRoIa','5yQG6l296ywn572U5PAh5lU25AsX6lsLoG','uKvtrvq','uKve','Cg9W','g1SZmM0','lI4VlI4VBg9NCW','su5gtW','q1LbtG','mZq3odbKrKPTugW','g1SZm20','v0fstG','Dg9gAwXL','Dg9vChbLCKnHC2u','g1SZnM0','C3rYAw5NAwz5','BwvZC2fNzq','D2fYBG','ntKWCgLHA0P2','qKXvrq','C3rHCNruAw1L','zxjYB3i','revcvuC','CgfNzvnPEMu','yxbWlMXVzW','mtq1nJbeqK1sC1a','CMv2zxjZzq','C29YDa','Dg9ju09tDhjPBMC','CMvWBgfJzq','wuvmte9x','zxHWB3j0CW','CMvUyw1Lu3LUyW','mJe5nJu5ANfszfrt','mtiYndbMCwP4AfG','BwTKAxjtEw5J','ANnVBG','Aw5JBhvKzxm','5yIB5BU65PEL5B+x55UU5B2v5AsX6lsLoIa','5PAh5lU25PEL5B+x5BEY5zcV55sO','te9hx0zpuK1bva','5yAz5ywL5PEL5B+x5PAh5lU25AsX6lsLoIa','mZi4nvjuyxD2zW','Dhj1zq','Bg9N','CMvHzgrPCLn5BMm','vfjbq0u','BgvUz3rO','C2L6zq','Cgf0Aa','yxbWzw5KrMLSzvn5BMm','Dg9tDhjPBMC','m2XkBxbpCa','rvjst1i','te9hx1rpx0zjteu','5PAh5lU25PEL5B+x5BEY56Ab55sO','zw52','ntqYmduWrwflrhH3','kcGOlISPkYKRksSK','zMLSDgvY','lMXVzW','mtq3nZq4rgHTAxjn','Dgv4Da','Dw5SAw5Ru3LUyW','te9hx0XfvKvm','y29SB3jLza','C3rHCNrZv2L0Aa','C2XPy2u','Dg9mB3DLCKnHC2u','Bgv2zwW','AM9PBG','mJq4ngPiq05grW','BwfW'];a0_0x2d7c=function(){return _0xe89a4e;};return a0_0x2d7c();}function error(..._0x148028){const _0x4ab812=a0_0x41baca;if(currentLogLevel>=LOG_LEVELS[_0x4ab812(0x146)]){const _0x33e8fb=getTimestamp(),_0x41d8cd=formatConsoleLog(_0x4ab812(0x146),_0x33e8fb,COLORS[_0x4ab812(0x167)],..._0x148028);console[_0x4ab812(0x179)](_0x41d8cd),writeLogToFile('ERROR',_0x33e8fb,..._0x148028),addLogToMemory(_0x4ab812(0x146),_0x33e8fb,..._0x148028);}}function warn(..._0x4a6738){const _0x566fe9=a0_0x41baca;if(currentLogLevel>=LOG_LEVELS[_0x566fe9(0x16f)]){const _0x188722=getTimestamp(),_0x2b3636=formatConsoleLog(_0x566fe9(0x16f),_0x188722,COLORS[_0x566fe9(0x182)],..._0x4a6738);console[_0x566fe9(0x175)](_0x2b3636),writeLogToFile(_0x566fe9(0x16f),_0x188722,..._0x4a6738),addLogToMemory(_0x566fe9(0x16f),_0x188722,..._0x4a6738);}}function info(..._0x556682){const _0x7973f7=a0_0x41baca;if(currentLogLevel>=LOG_LEVELS['INFO']){const _0x199b8d=getTimestamp(),_0x3ea41e=formatConsoleLog(_0x7973f7(0x16b),_0x199b8d,COLORS['GREEN'],..._0x556682);console[_0x7973f7(0x13d)](_0x3ea41e),writeLogToFile(_0x7973f7(0x16b),_0x199b8d,..._0x556682),addLogToMemory(_0x7973f7(0x16b),_0x199b8d,..._0x556682);}}function debug(..._0x41e3b4){const _0x8ae9f2=a0_0x41baca;if(currentLogLevel>=LOG_LEVELS[_0x8ae9f2(0x17a)]){const _0x3ad826=getTimestamp(),_0x4e4254=formatConsoleLog(_0x8ae9f2(0x17a),_0x3ad826,COLORS[_0x8ae9f2(0x177)],..._0x41e3b4);console[_0x8ae9f2(0x13d)](_0x4e4254),writeLogToFile('DEBUG',_0x3ad826,..._0x41e3b4),addLogToMemory(_0x8ae9f2(0x17a),_0x3ad826,..._0x41e3b4);}}function trace(..._0x122106){const _0x349183=a0_0x41baca;if(currentLogLevel>=LOG_LEVELS[_0x349183(0x13f)]){const _0xbc363c=getTimestamp(),_0x1438ba=formatConsoleLog(_0x349183(0x13f),_0xbc363c,COLORS[_0x349183(0x16c)],..._0x122106);console[_0x349183(0x13d)](_0x1438ba),writeLogToFile('TRACE',_0xbc363c,..._0x122106),addLogToMemory(_0x349183(0x13f),_0xbc363c,..._0x122106);}}function http(..._0x50f464){const _0x41bd5e=a0_0x41baca;if(currentLogLevel>=LOG_LEVELS['INFO']){const _0x48d2b5=getTimestamp(),_0x447ffa=formatConsoleLog(_0x41bd5e(0x160),_0x48d2b5,COLORS[_0x41bd5e(0x16c)],..._0x50f464);console['log'](_0x447ffa),writeLogToFile(_0x41bd5e(0x160),_0x48d2b5,..._0x50f464),addLogToMemory(_0x41bd5e(0x160),_0x48d2b5,..._0x50f464);}}function getLogs(_0x16d848={}){const _0x5f3ced=a0_0x41baca;let _0x4dff35=[...memoryLogs];_0x16d848[_0x5f3ced(0x156)]&&(_0x4dff35=_0x4dff35[_0x5f3ced(0x14c)](_0x19608a=>_0x19608a[_0x5f3ced(0x156)]===_0x16d848[_0x5f3ced(0x156)]));_0x16d848[_0x5f3ced(0x178)]&&(_0x4dff35=_0x4dff35[_0x5f3ced(0x14c)](_0x4eb4d5=>new Date(_0x4eb4d5[_0x5f3ced(0x15d)])>=new Date(_0x16d848[_0x5f3ced(0x178)])));_0x16d848['endTime']&&(_0x4dff35=_0x4dff35['filter'](_0x47934b=>new Date(_0x47934b['timestamp'])<=new Date(_0x16d848['endTime'])));if(_0x16d848[_0x5f3ced(0x15b)]){const _0x594773=_0x16d848[_0x5f3ced(0x15b)][_0x5f3ced(0x155)]();_0x4dff35=_0x4dff35[_0x5f3ced(0x14c)](_0x597f02=>_0x597f02['message']['toLowerCase']()[_0x5f3ced(0x189)](_0x594773)||_0x597f02['level'][_0x5f3ced(0x155)]()[_0x5f3ced(0x189)](_0x594773));}const _0x51aed7=_0x16d848['page']||0x1,_0xa0cd44=_0x16d848[_0x5f3ced(0x17b)]||0x64,_0x5108b7=(_0x51aed7-0x1)*_0xa0cd44,_0x134199=_0x5108b7+_0xa0cd44;return{'logs':_0x4dff35['slice'](_0x5108b7,_0x134199),'total':_0x4dff35[_0x5f3ced(0x140)],'page':_0x51aed7,'pageSize':_0xa0cd44};}function clearMemoryLogs(){const _0x37ff4a=a0_0x41baca;memoryLogs[_0x37ff4a(0x140)]=0x0,info('内存日志已清除');}function initialize(){const _0x180179=a0_0x41baca;try{const _0xf9efd1=getConfig(),_0x579654=process[_0x180179(0x149)][_0x180179(0x151)];if(_0x579654)setLogLevel(_0x579654);else _0xf9efd1&&_0xf9efd1[_0x180179(0x13d)]&&_0xf9efd1[_0x180179(0x13d)]['level']&&setLogLevel(_0xf9efd1[_0x180179(0x13d)][_0x180179(0x156)]);const _0x430fdd=process[_0x180179(0x149)][_0x180179(0x18c)];if(_0x430fdd)setLogFormat(_0x430fdd);else _0xf9efd1&&_0xf9efd1[_0x180179(0x13d)]&&_0xf9efd1['log'][_0x180179(0x15c)]&&setLogFormat(_0xf9efd1['log'][_0x180179(0x15c)]);initFileLogging();}catch(_0x4d67be){console[_0x180179(0x179)]('初始化日志系统出错:\x20'+_0x4d67be[_0x180179(0x174)]);}}initialize(),module[a0_0x41baca(0x183)]={'LOG_LEVELS':LOG_LEVELS,'setLogLevel':setLogLevel,'setLogFormat':setLogFormat,'error':error,'warn':warn,'info':info,'debug':debug,'trace':trace,'http':http,'enableFileLogging':()=>{const _0x223ace=a0_0x41baca;if(ensureLogDirExists())return logToFile=!![],info(_0x223ace(0x18b)),!![];return![];},'disableFileLogging':()=>{const _0xac930c=a0_0x41baca;logToFile=![],info(_0xac930c(0x148));},'rotateLogFile':rotateLogFile,'getLogs':getLogs,'clearMemoryLogs':clearMemoryLogs};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// logger.js - 统一的日志系统模块
|
2 |
+
const fs = require('fs');
|
3 |
+
const path = require('path');
|
4 |
+
|
5 |
+
// 避免循环依赖
|
6 |
+
let config = null;
|
7 |
+
// 延迟加载配置
|
8 |
+
function getConfig() {
|
9 |
+
if (!config) {
|
10 |
+
try {
|
11 |
+
config = require('../config/config');
|
12 |
+
} catch (err) {
|
13 |
+
console.error('加载配置文件失败:', err.message);
|
14 |
+
config = { log: { level: 'INFO', format: 'colored' } };
|
15 |
+
}
|
16 |
+
}
|
17 |
+
return config;
|
18 |
+
}
|
19 |
+
|
20 |
+
const LOG_LEVELS = {
|
21 |
+
ERROR: 0,
|
22 |
+
WARN: 1,
|
23 |
+
INFO: 2,
|
24 |
+
DEBUG: 3,
|
25 |
+
TRACE: 4,
|
26 |
+
HTTP: 2 // HTTP日志级别与INFO相同
|
27 |
+
};
|
28 |
+
|
29 |
+
// 默认日志级别
|
30 |
+
let currentLogLevel = LOG_LEVELS.INFO;
|
31 |
+
|
32 |
+
// 日志格式
|
33 |
+
let logFormat = 'colored'; // colored, json, text
|
34 |
+
|
35 |
+
// 带颜色的控制台输出
|
36 |
+
const COLORS = {
|
37 |
+
RESET: '\x1b[0m',
|
38 |
+
RED: '\x1b[31m',
|
39 |
+
YELLOW: '\x1b[33m',
|
40 |
+
GREEN: '\x1b[32m',
|
41 |
+
BLUE: '\x1b[34m',
|
42 |
+
CYAN: '\x1b[36m'
|
43 |
+
};
|
44 |
+
|
45 |
+
// 日志文件配置
|
46 |
+
const LOG_DIR = path.join(__dirname, '../../logs');
|
47 |
+
const LOG_FILE = path.join(LOG_DIR, 'app.log');
|
48 |
+
const MAX_LOG_SIZE = 10 * 1024 * 1024; // 10MB
|
49 |
+
let logToFile = false;
|
50 |
+
|
51 |
+
// 内存中存储的日志(用于网页显示)
|
52 |
+
const memoryLogs = [];
|
53 |
+
const MAX_MEMORY_LOGS = 1000; // 内存中最多保存的日志条数
|
54 |
+
|
55 |
+
// 确保日志目录存在
|
56 |
+
function ensureLogDirExists() {
|
57 |
+
try {
|
58 |
+
if (!fs.existsSync(LOG_DIR)) {
|
59 |
+
fs.mkdirSync(LOG_DIR, { recursive: true });
|
60 |
+
}
|
61 |
+
return true;
|
62 |
+
} catch (err) {
|
63 |
+
console.error(`创建日志目录失败: ${err.message}`);
|
64 |
+
return false;
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
// 初始化文件日志
|
69 |
+
function initFileLogging() {
|
70 |
+
const conf = getConfig();
|
71 |
+
if (process.env.LOG_TO_FILE === 'true' || (conf.log && conf.log.toFile)) {
|
72 |
+
if (ensureLogDirExists()) {
|
73 |
+
logToFile = true;
|
74 |
+
// 检查日志文件大小,如果超过最大值则进行轮转
|
75 |
+
if (fs.existsSync(LOG_FILE)) {
|
76 |
+
const stats = fs.statSync(LOG_FILE);
|
77 |
+
if (stats.size > MAX_LOG_SIZE) {
|
78 |
+
rotateLogFile();
|
79 |
+
}
|
80 |
+
}
|
81 |
+
return true;
|
82 |
+
}
|
83 |
+
}
|
84 |
+
return false;
|
85 |
+
}
|
86 |
+
|
87 |
+
// 日志文件轮转
|
88 |
+
function rotateLogFile() {
|
89 |
+
try {
|
90 |
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
91 |
+
const newLogFile = path.join(LOG_DIR, `app-${timestamp}.log`);
|
92 |
+
if (fs.existsSync(LOG_FILE)) {
|
93 |
+
fs.renameSync(LOG_FILE, newLogFile);
|
94 |
+
}
|
95 |
+
// 清理旧日志文件,保留最近10个
|
96 |
+
const logFiles = fs.readdirSync(LOG_DIR)
|
97 |
+
.filter(file => file.startsWith('app-') && file.endsWith('.log'))
|
98 |
+
.sort()
|
99 |
+
.reverse();
|
100 |
+
|
101 |
+
if (logFiles.length > 10) {
|
102 |
+
logFiles.slice(10).forEach(file => {
|
103 |
+
try {
|
104 |
+
fs.unlinkSync(path.join(LOG_DIR, file));
|
105 |
+
} catch (err) {
|
106 |
+
console.error(`删除旧日志文件失败: ${err.message}`);
|
107 |
+
}
|
108 |
+
});
|
109 |
+
}
|
110 |
+
} catch (err) {
|
111 |
+
console.error(`日志文件轮转失败: ${err.message}`);
|
112 |
+
logToFile = false;
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
// 添加日志到内存
|
117 |
+
function addLogToMemory(level, timestamp, ...args) {
|
118 |
+
// 将日志对象添加到内存数组
|
119 |
+
const logEntry = {
|
120 |
+
level,
|
121 |
+
timestamp,
|
122 |
+
message: args.map(arg => typeof arg === 'object' ? JSON.stringify(arg) : String(arg)).join(' ')
|
123 |
+
};
|
124 |
+
|
125 |
+
memoryLogs.unshift(logEntry); // 新日志添加到数组开头
|
126 |
+
|
127 |
+
// 保持数组在最大长度以内
|
128 |
+
if (memoryLogs.length > MAX_MEMORY_LOGS) {
|
129 |
+
memoryLogs.pop(); // 移除最旧的日志
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
// 将日志写入文件
|
134 |
+
function writeLogToFile(level, timestamp, ...args) {
|
135 |
+
if (!logToFile) return;
|
136 |
+
|
137 |
+
try {
|
138 |
+
let logEntry;
|
139 |
+
|
140 |
+
if (logFormat === 'json') {
|
141 |
+
// JSON格式
|
142 |
+
const data = args.map(arg => typeof arg === 'object' ? arg : String(arg));
|
143 |
+
const logObject = {
|
144 |
+
level,
|
145 |
+
timestamp,
|
146 |
+
message: data.length === 1 ? data[0] : data
|
147 |
+
};
|
148 |
+
logEntry = JSON.stringify(logObject) + '\n';
|
149 |
+
} else {
|
150 |
+
// 文本格式
|
151 |
+
logEntry = `[${level}] ${timestamp} ${args.map(arg =>
|
152 |
+
typeof arg === 'object' ? JSON.stringify(arg) : arg
|
153 |
+
).join(' ')}\n`;
|
154 |
+
}
|
155 |
+
|
156 |
+
fs.appendFileSync(LOG_FILE, logEntry);
|
157 |
+
|
158 |
+
// 检查文件大小,必要时进行轮转
|
159 |
+
const stats = fs.statSync(LOG_FILE);
|
160 |
+
if (stats.size > MAX_LOG_SIZE) {
|
161 |
+
rotateLogFile();
|
162 |
+
}
|
163 |
+
} catch (err) {
|
164 |
+
console.error(`写入日志文件失败: ${err.message}`);
|
165 |
+
logToFile = false;
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
// 获取时间戳
|
170 |
+
function getTimestamp() {
|
171 |
+
return new Date().toISOString();
|
172 |
+
}
|
173 |
+
|
174 |
+
// 设置日志级别
|
175 |
+
function setLogLevel(level) {
|
176 |
+
if (typeof level === 'string') {
|
177 |
+
level = level.toUpperCase();
|
178 |
+
if (LOG_LEVELS[level] !== undefined) {
|
179 |
+
currentLogLevel = LOG_LEVELS[level];
|
180 |
+
} else {
|
181 |
+
error(`无效的日志级别: ${level}`);
|
182 |
+
}
|
183 |
+
} else if (typeof level === 'number' && level >= 0 && level <= 4) {
|
184 |
+
currentLogLevel = level;
|
185 |
+
} else {
|
186 |
+
error(`无效的日志级别: ${level}`);
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
// 设置日志格式
|
191 |
+
function setLogFormat(format) {
|
192 |
+
const validFormats = ['colored', 'json', 'text'];
|
193 |
+
if (validFormats.includes(format)) {
|
194 |
+
logFormat = format;
|
195 |
+
return true;
|
196 |
+
} else {
|
197 |
+
error(`无效的日志格式: ${format}`);
|
198 |
+
return false;
|
199 |
+
}
|
200 |
+
}
|
201 |
+
|
202 |
+
// 格式化控制台日志
|
203 |
+
function formatConsoleLog(level, timestamp, color, ...args) {
|
204 |
+
if (logFormat === 'json') {
|
205 |
+
// JSON格式
|
206 |
+
const data = args.map(arg => typeof arg === 'object' ? arg : String(arg));
|
207 |
+
return JSON.stringify({
|
208 |
+
level,
|
209 |
+
timestamp,
|
210 |
+
message: data.length === 1 ? data[0] : data
|
211 |
+
});
|
212 |
+
} else if (logFormat === 'text') {
|
213 |
+
// 纯文本格式(无颜色)
|
214 |
+
return `[${level}] ${timestamp} ${args.join(' ')}`;
|
215 |
+
} else {
|
216 |
+
// 默认:带颜色格式
|
217 |
+
return `${color}[${level}] ${timestamp}${COLORS.RESET} ${args.join(' ')}`;
|
218 |
+
}
|
219 |
+
}
|
220 |
+
|
221 |
+
// 错误日志
|
222 |
+
function error(...args) {
|
223 |
+
if (currentLogLevel >= LOG_LEVELS.ERROR) {
|
224 |
+
const timestamp = getTimestamp();
|
225 |
+
const formattedLog = formatConsoleLog('ERROR', timestamp, COLORS.RED, ...args);
|
226 |
+
console.error(formattedLog);
|
227 |
+
writeLogToFile('ERROR', timestamp, ...args);
|
228 |
+
addLogToMemory('ERROR', timestamp, ...args);
|
229 |
+
}
|
230 |
+
}
|
231 |
+
|
232 |
+
// 警告日志
|
233 |
+
function warn(...args) {
|
234 |
+
if (currentLogLevel >= LOG_LEVELS.WARN) {
|
235 |
+
const timestamp = getTimestamp();
|
236 |
+
const formattedLog = formatConsoleLog('WARN', timestamp, COLORS.YELLOW, ...args);
|
237 |
+
console.warn(formattedLog);
|
238 |
+
writeLogToFile('WARN', timestamp, ...args);
|
239 |
+
addLogToMemory('WARN', timestamp, ...args);
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
// 信息日志
|
244 |
+
function info(...args) {
|
245 |
+
if (currentLogLevel >= LOG_LEVELS.INFO) {
|
246 |
+
const timestamp = getTimestamp();
|
247 |
+
const formattedLog = formatConsoleLog('INFO', timestamp, COLORS.GREEN, ...args);
|
248 |
+
console.log(formattedLog);
|
249 |
+
writeLogToFile('INFO', timestamp, ...args);
|
250 |
+
addLogToMemory('INFO', timestamp, ...args);
|
251 |
+
}
|
252 |
+
}
|
253 |
+
|
254 |
+
// 调试日志
|
255 |
+
function debug(...args) {
|
256 |
+
if (currentLogLevel >= LOG_LEVELS.DEBUG) {
|
257 |
+
const timestamp = getTimestamp();
|
258 |
+
const formattedLog = formatConsoleLog('DEBUG', timestamp, COLORS.BLUE, ...args);
|
259 |
+
console.log(formattedLog);
|
260 |
+
writeLogToFile('DEBUG', timestamp, ...args);
|
261 |
+
addLogToMemory('DEBUG', timestamp, ...args);
|
262 |
+
}
|
263 |
+
}
|
264 |
+
|
265 |
+
// 跟踪日志
|
266 |
+
function trace(...args) {
|
267 |
+
if (currentLogLevel >= LOG_LEVELS.TRACE) {
|
268 |
+
const timestamp = getTimestamp();
|
269 |
+
const formattedLog = formatConsoleLog('TRACE', timestamp, COLORS.CYAN, ...args);
|
270 |
+
console.log(formattedLog);
|
271 |
+
writeLogToFile('TRACE', timestamp, ...args);
|
272 |
+
addLogToMemory('TRACE', timestamp, ...args);
|
273 |
+
}
|
274 |
+
}
|
275 |
+
|
276 |
+
// HTTP请求日志 (特殊处理,方便筛选)
|
277 |
+
function http(...args) {
|
278 |
+
if (currentLogLevel >= LOG_LEVELS.INFO) {
|
279 |
+
const timestamp = getTimestamp();
|
280 |
+
const formattedLog = formatConsoleLog('HTTP', timestamp, COLORS.CYAN, ...args);
|
281 |
+
console.log(formattedLog);
|
282 |
+
writeLogToFile('HTTP', timestamp, ...args);
|
283 |
+
addLogToMemory('HTTP', timestamp, ...args);
|
284 |
+
}
|
285 |
+
}
|
286 |
+
|
287 |
+
// 获取内存中的日志
|
288 |
+
function getLogs(filter = {}) {
|
289 |
+
let filteredLogs = [...memoryLogs];
|
290 |
+
|
291 |
+
// 按日志级别筛选
|
292 |
+
if (filter.level) {
|
293 |
+
filteredLogs = filteredLogs.filter(log => log.level === filter.level);
|
294 |
+
}
|
295 |
+
|
296 |
+
// 按时间范围筛选
|
297 |
+
if (filter.startTime) {
|
298 |
+
filteredLogs = filteredLogs.filter(log => new Date(log.timestamp) >= new Date(filter.startTime));
|
299 |
+
}
|
300 |
+
|
301 |
+
if (filter.endTime) {
|
302 |
+
filteredLogs = filteredLogs.filter(log => new Date(log.timestamp) <= new Date(filter.endTime));
|
303 |
+
}
|
304 |
+
|
305 |
+
// 按关键词搜索
|
306 |
+
if (filter.search) {
|
307 |
+
const searchTerm = filter.search.toLowerCase();
|
308 |
+
filteredLogs = filteredLogs.filter(log =>
|
309 |
+
log.message.toLowerCase().includes(searchTerm) ||
|
310 |
+
log.level.toLowerCase().includes(searchTerm)
|
311 |
+
);
|
312 |
+
}
|
313 |
+
|
314 |
+
// 分页
|
315 |
+
const page = filter.page || 1;
|
316 |
+
const pageSize = filter.pageSize || 100;
|
317 |
+
const start = (page - 1) * pageSize;
|
318 |
+
const end = start + pageSize;
|
319 |
+
|
320 |
+
return {
|
321 |
+
logs: filteredLogs.slice(start, end),
|
322 |
+
total: filteredLogs.length,
|
323 |
+
page,
|
324 |
+
pageSize
|
325 |
+
};
|
326 |
+
}
|
327 |
+
|
328 |
+
// 清除内存日志
|
329 |
+
function clearMemoryLogs() {
|
330 |
+
memoryLogs.length = 0;
|
331 |
+
info('内存日志已清除');
|
332 |
+
}
|
333 |
+
|
334 |
+
// 初始化配置
|
335 |
+
function initialize() {
|
336 |
+
try {
|
337 |
+
const conf = getConfig();
|
338 |
+
|
339 |
+
// 初始化日志级别
|
340 |
+
const envLevel = process.env.LOG_LEVEL;
|
341 |
+
if (envLevel) {
|
342 |
+
setLogLevel(envLevel);
|
343 |
+
} else if (conf && conf.log && conf.log.level) {
|
344 |
+
setLogLevel(conf.log.level);
|
345 |
+
}
|
346 |
+
|
347 |
+
// 初始化日志格式
|
348 |
+
const envFormat = process.env.LOG_FORMAT;
|
349 |
+
if (envFormat) {
|
350 |
+
setLogFormat(envFormat);
|
351 |
+
} else if (conf && conf.log && conf.log.format) {
|
352 |
+
setLogFormat(conf.log.format);
|
353 |
+
}
|
354 |
+
|
355 |
+
// 初始化文件日志
|
356 |
+
initFileLogging();
|
357 |
+
} catch (err) {
|
358 |
+
console.error(`初始化日志系统出错: ${err.message}`);
|
359 |
+
}
|
360 |
+
}
|
361 |
+
|
362 |
+
// 初始化
|
363 |
+
initialize();
|
364 |
+
|
365 |
+
module.exports = {
|
366 |
+
LOG_LEVELS,
|
367 |
+
setLogLevel,
|
368 |
+
setLogFormat,
|
369 |
+
error,
|
370 |
+
warn,
|
371 |
+
info,
|
372 |
+
debug,
|
373 |
+
trace,
|
374 |
+
http,
|
375 |
+
// 暴露文件日志相关方法
|
376 |
+
enableFileLogging: () => {
|
377 |
+
if (ensureLogDirExists()) {
|
378 |
+
logToFile = true;
|
379 |
+
info('文件日志已启用');
|
380 |
+
return true;
|
381 |
+
}
|
382 |
+
return false;
|
383 |
+
},
|
384 |
+
disableFileLogging: () => {
|
385 |
+
logToFile = false;
|
386 |
+
info('文件日志已禁用');
|
387 |
+
},
|
388 |
+
rotateLogFile,
|
389 |
+
// 添加内存日志相关方法
|
390 |
+
getLogs,
|
391 |
+
clearMemoryLogs
|
392 |
+
};
|
src/utils/utils.js
CHANGED
@@ -1 +1,206 @@
|
|
1 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
const os = require('os');
|
2 |
+
const zlib = require('zlib');
|
3 |
+
const crypto = require('crypto');
|
4 |
+
const { v4: uuidv4 } = require('uuid');
|
5 |
+
const $root = require('../proto/message.js');
|
6 |
+
|
7 |
+
function generateCursorBody(messages, modelName) {
|
8 |
+
|
9 |
+
const instruction = messages
|
10 |
+
.filter(msg => msg.role === 'system')
|
11 |
+
.map(msg => msg.content)
|
12 |
+
.join('\n')
|
13 |
+
|
14 |
+
const formattedMessages = messages
|
15 |
+
.filter(msg => msg.role !== 'system')
|
16 |
+
.map(msg => ({
|
17 |
+
content: msg.content,
|
18 |
+
role: msg.role === 'user' ? 1 : 2,
|
19 |
+
messageId: uuidv4(),
|
20 |
+
...(msg.role === 'user' ? { chatModeEnum: 1 } : {})
|
21 |
+
//...(msg.role !== 'user' ? { summaryId: uuidv4() } : {})
|
22 |
+
}));
|
23 |
+
|
24 |
+
const messageIds = formattedMessages.map(msg => {
|
25 |
+
const { role, messageId, summaryId } = msg;
|
26 |
+
return summaryId ? { role, messageId, summaryId } : { role, messageId };
|
27 |
+
});
|
28 |
+
|
29 |
+
const body = {
|
30 |
+
request:{
|
31 |
+
messages: formattedMessages,
|
32 |
+
unknown2: 1,
|
33 |
+
instruction: {
|
34 |
+
instruction: instruction
|
35 |
+
},
|
36 |
+
unknown4: 1,
|
37 |
+
model: {
|
38 |
+
name: modelName,
|
39 |
+
empty: '',
|
40 |
+
},
|
41 |
+
webTool: "",
|
42 |
+
unknown13: 1,
|
43 |
+
cursorSetting: {
|
44 |
+
name: "cursor\\aisettings",
|
45 |
+
unknown3: "",
|
46 |
+
unknown6: {
|
47 |
+
unknwon1: "",
|
48 |
+
unknown2: ""
|
49 |
+
},
|
50 |
+
unknown8: 1,
|
51 |
+
unknown9: 1
|
52 |
+
},
|
53 |
+
unknown19: 1,
|
54 |
+
//unknown22: 1,
|
55 |
+
conversationId: uuidv4(),
|
56 |
+
metadata: {
|
57 |
+
os: "win32",
|
58 |
+
arch: "x64",
|
59 |
+
version: "10.0.22631",
|
60 |
+
path: "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
|
61 |
+
timestamp: new Date().toISOString(),
|
62 |
+
},
|
63 |
+
unknown27: 0,
|
64 |
+
//unknown29: "",
|
65 |
+
messageIds: messageIds,
|
66 |
+
largeContext: 0,
|
67 |
+
unknown38: 0,
|
68 |
+
chatModeEnum: 1,
|
69 |
+
unknown47: "",
|
70 |
+
unknown48: 0,
|
71 |
+
unknown49: 0,
|
72 |
+
unknown51: 0,
|
73 |
+
unknown53: 1,
|
74 |
+
chatMode: "Ask"
|
75 |
+
}
|
76 |
+
};
|
77 |
+
|
78 |
+
const errMsg = $root.StreamUnifiedChatWithToolsRequest.verify(body);
|
79 |
+
if (errMsg) throw Error(errMsg);
|
80 |
+
const instance = $root.StreamUnifiedChatWithToolsRequest.create(body);
|
81 |
+
let buffer = $root.StreamUnifiedChatWithToolsRequest.encode(instance).finish();
|
82 |
+
let magicNumber = 0x00
|
83 |
+
if (formattedMessages.length >= 3){
|
84 |
+
buffer = zlib.gzipSync(buffer)
|
85 |
+
magicNumber = 0x01
|
86 |
+
}
|
87 |
+
|
88 |
+
const finalBody = Buffer.concat([
|
89 |
+
Buffer.from([magicNumber]),
|
90 |
+
Buffer.from(buffer.length.toString(16).padStart(8, '0'), 'hex'),
|
91 |
+
buffer
|
92 |
+
])
|
93 |
+
|
94 |
+
return finalBody
|
95 |
+
}
|
96 |
+
|
97 |
+
function chunkToUtf8String(chunk) {
|
98 |
+
const results = []
|
99 |
+
const thinkingResults = []
|
100 |
+
const contentResults = []
|
101 |
+
const errorResults = { hasError: false, errorMessage: '' }
|
102 |
+
const buffer = Buffer.from(chunk, 'hex');
|
103 |
+
//console.log("Chunk buffer:", buffer.toString('hex'))
|
104 |
+
|
105 |
+
try {
|
106 |
+
for(let i = 0; i < buffer.length; i++){
|
107 |
+
const magicNumber = parseInt(buffer.subarray(i, i + 1).toString('hex'), 16)
|
108 |
+
const dataLength = parseInt(buffer.subarray(i + 1, i + 5).toString('hex'), 16)
|
109 |
+
const data = buffer.subarray(i + 5, i + 5 + dataLength)
|
110 |
+
//console.log("Parsed buffer:", magicNumber, dataLength, data.toString('hex'))
|
111 |
+
|
112 |
+
if (magicNumber == 0 || magicNumber == 1) {
|
113 |
+
const gunzipData = magicNumber == 0 ? data : zlib.gunzipSync(data)
|
114 |
+
const response = $root.StreamUnifiedChatWithToolsResponse.decode(gunzipData);
|
115 |
+
const thinking = response?.message?.thinking?.content
|
116 |
+
if (thinking !== undefined && thinking.length > 0){
|
117 |
+
thinkingResults.push(thinking);
|
118 |
+
// console.log('[DEBUG] 收到 thinking:', thinking);
|
119 |
+
}
|
120 |
+
const content = response?.message?.content
|
121 |
+
if (content !== undefined && content.length > 0){
|
122 |
+
contentResults.push(content)
|
123 |
+
// console.log('[DEBUG] 收到 content:', content);
|
124 |
+
}
|
125 |
+
}
|
126 |
+
else if (magicNumber == 2 || magicNumber == 3) {
|
127 |
+
// Json message
|
128 |
+
const gunzipData = magicNumber == 2 ? data : zlib.gunzipSync(data)
|
129 |
+
const utf8 = gunzipData.toString('utf-8')
|
130 |
+
const message = JSON.parse(utf8)
|
131 |
+
|
132 |
+
if (message != null && (typeof message !== 'object' ||
|
133 |
+
(Array.isArray(message) ? message.length > 0 : Object.keys(message).length > 0))){
|
134 |
+
//results.push(utf8)
|
135 |
+
console.error(utf8)
|
136 |
+
|
137 |
+
// 检查是否为错误消息
|
138 |
+
if (message && message.error) {
|
139 |
+
errorResults.hasError = true;
|
140 |
+
errorResults.errorMessage = utf8;
|
141 |
+
}
|
142 |
+
}
|
143 |
+
}
|
144 |
+
else {
|
145 |
+
//console.log('Unknown magic number when parsing chunk response: ' + magicNumber)
|
146 |
+
}
|
147 |
+
|
148 |
+
i += 5 + dataLength - 1
|
149 |
+
}
|
150 |
+
} catch (err) {
|
151 |
+
console.log('Error parsing chunk response:', err)
|
152 |
+
}
|
153 |
+
|
154 |
+
// 如果存在错误,返回错误对象
|
155 |
+
if (errorResults.hasError) {
|
156 |
+
return { error: errorResults.errorMessage };
|
157 |
+
}
|
158 |
+
|
159 |
+
// 分别返回thinking和content内容
|
160 |
+
return {
|
161 |
+
reasoning_content: thinkingResults.join(''),
|
162 |
+
content: contentResults.join('')
|
163 |
+
};
|
164 |
+
}
|
165 |
+
|
166 |
+
function generateHashed64Hex(input, salt = '') {
|
167 |
+
const hash = crypto.createHash('sha256');
|
168 |
+
hash.update(input + salt);
|
169 |
+
return hash.digest('hex');
|
170 |
+
}
|
171 |
+
|
172 |
+
function obfuscateBytes(byteArray) {
|
173 |
+
let t = 165;
|
174 |
+
for (let r = 0; r < byteArray.length; r++) {
|
175 |
+
byteArray[r] = (byteArray[r] ^ t) + (r % 256);
|
176 |
+
t = byteArray[r];
|
177 |
+
}
|
178 |
+
return byteArray;
|
179 |
+
}
|
180 |
+
|
181 |
+
function generateCursorChecksum(token) {
|
182 |
+
const machineId = generateHashed64Hex(token, 'machineId');
|
183 |
+
const macMachineId = generateHashed64Hex(token, 'macMachineId');
|
184 |
+
|
185 |
+
const timestamp = Math.floor(Date.now() / 1e6);
|
186 |
+
const byteArray = new Uint8Array([
|
187 |
+
(timestamp >> 40) & 255,
|
188 |
+
(timestamp >> 32) & 255,
|
189 |
+
(timestamp >> 24) & 255,
|
190 |
+
(timestamp >> 16) & 255,
|
191 |
+
(timestamp >> 8) & 255,
|
192 |
+
255 & timestamp,
|
193 |
+
]);
|
194 |
+
|
195 |
+
const obfuscatedBytes = obfuscateBytes(byteArray);
|
196 |
+
const encodedChecksum = Buffer.from(obfuscatedBytes).toString('base64');
|
197 |
+
|
198 |
+
return `${encodedChecksum}${machineId}/${macMachineId}`;
|
199 |
+
}
|
200 |
+
|
201 |
+
module.exports = {
|
202 |
+
generateCursorBody,
|
203 |
+
chunkToUtf8String,
|
204 |
+
generateHashed64Hex,
|
205 |
+
generateCursorChecksum
|
206 |
+
};
|