wx2tg-puppet 3.0.3 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -126,6 +126,8 @@ declare class LoginApi {
126
126
  LoginGetQRWinUwp(body: LoginGetQRReq): Promise<AxiosResponse<ApiResponse>>;
127
127
  /** 获取二维码(iPad-绕过验证码) */
128
128
  LoginGetQRx(body: LoginGetQRReq): Promise<AxiosResponse<ApiResponse>>;
129
+ /** 获取二维码(绕过验证码-推送确认) */
130
+ LoginGetQRNotCodePush(body: LoginGetQRReq): Promise<AxiosResponse<ApiResponse>>;
129
131
  /** 二次登录 */
130
132
  LoginTwiceAutoAuth(wxid: string): Promise<AxiosResponse<ApiResponse>>;
131
133
  /** 初始化 */
@@ -163,6 +163,10 @@ class LoginApi {
163
163
  LoginGetQRx(body) {
164
164
  return axiosInstance_1.axiosInstance.post('/Login/LoginGetQRx', body);
165
165
  }
166
+ /** 获取二维码(绕过验证码-推送确认) */
167
+ LoginGetQRNotCodePush(body) {
168
+ return axiosInstance_1.axiosInstance.post('/Login/LoginGetQRNotCodePush', body);
169
+ }
166
170
  /** 二次登录 */
167
171
  LoginTwiceAutoAuth(wxid) {
168
172
  return axiosInstance_1.axiosInstance.post('/Login/LoginTwiceAutoAuth', null, { params: { wxid } });
package/dist/index.js CHANGED
@@ -167,15 +167,25 @@ class WxBot extends events_1.EventEmitter {
167
167
  });
168
168
  break;
169
169
  case 'ipadX':
170
- response = yield LoginApi_1.loginApi.LoginGetQRx({
171
- "DeviceID": (config === null || config === void 0 ? void 0 : config.deviceId) || "",
172
- "DeviceName": (config === null || config === void 0 ? void 0 : config.DeviceName) || "",
173
- "Proxy": {
174
- "ProxyIp": this.ProxyIp || "",
175
- "ProxyPassword": this.ProxyPassword || "",
176
- "ProxyUser": this.ProxyUser || ""
177
- }
178
- });
170
+ response = (0, axiosInstance_1.isNewProtocol)()
171
+ ? yield LoginApi_1.loginApi.LoginGetQRNotCodePush({
172
+ "DeviceID": (config === null || config === void 0 ? void 0 : config.deviceId) || "",
173
+ "DeviceName": (config === null || config === void 0 ? void 0 : config.DeviceName) || "",
174
+ "Proxy": {
175
+ "ProxyIp": this.ProxyIp || "",
176
+ "ProxyPassword": this.ProxyPassword || "",
177
+ "ProxyUser": this.ProxyUser || ""
178
+ }
179
+ })
180
+ : yield LoginApi_1.loginApi.LoginGetQRx({
181
+ "DeviceID": (config === null || config === void 0 ? void 0 : config.deviceId) || "",
182
+ "DeviceName": (config === null || config === void 0 ? void 0 : config.DeviceName) || "",
183
+ "Proxy": {
184
+ "ProxyIp": this.ProxyIp || "",
185
+ "ProxyPassword": this.ProxyPassword || "",
186
+ "ProxyUser": this.ProxyUser || ""
187
+ }
188
+ });
179
189
  break;
180
190
  case 'ipad':
181
191
  default:
@@ -650,11 +660,12 @@ class WxBot extends events_1.EventEmitter {
650
660
  login() {
651
661
  return __awaiter(this, void 0, void 0, function* () {
652
662
  if (this.loggingIn) {
653
- return; // Already logging in, prevent concurrent execution
663
+ return;
654
664
  }
655
665
  try {
656
666
  this.loggingIn = true;
657
- this.clearAllIntervals(); // 确保清理所有定时器
667
+ yield (0, axiosInstance_1.detectProtocolVersion)();
668
+ this.clearAllIntervals();
658
669
  yield this.fetchAndShowQRCode();
659
670
  this.interval = setInterval(() => {
660
671
  this.checkLoginStatus();
@@ -671,7 +682,8 @@ class WxBot extends events_1.EventEmitter {
671
682
  try {
672
683
  yield exports.AppDataSource.initialize();
673
684
  console.log('Data Source has been initialized!');
674
- this.clearAllIntervals(); // 确保清理所有定时器
685
+ yield (0, axiosInstance_1.detectProtocolVersion)();
686
+ this.clearAllIntervals();
675
687
  const config = yield config_service_1.configService.get();
676
688
  if (config && config.wxid) {
677
689
  const resp = yield MsgApi_1.msgApi.Sync({
@@ -1,2 +1,8 @@
1
1
  export declare const axiosInstance: import("axios").AxiosInstance;
2
2
  export declare function setBaseUrl(baseUrl: string): void;
3
+ /**
4
+ * 检测服务端协议版本
5
+ * @returns 是否为新协议
6
+ */
7
+ export declare function detectProtocolVersion(): Promise<boolean>;
8
+ export declare function isNewProtocol(): boolean;
@@ -1,10 +1,21 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
13
  };
5
14
  Object.defineProperty(exports, "__esModule", { value: true });
6
15
  exports.axiosInstance = void 0;
7
16
  exports.setBaseUrl = setBaseUrl;
17
+ exports.detectProtocolVersion = detectProtocolVersion;
18
+ exports.isNewProtocol = isNewProtocol;
8
19
  const axios_1 = __importDefault(require("axios"));
9
20
  const json_bigint_1 = __importDefault(require("json-bigint"));
10
21
  const JSONbigString = (0, json_bigint_1.default)({
@@ -23,6 +34,37 @@ exports.axiosInstance = axios_1.default.create({
23
34
  }
24
35
  }
25
36
  });
37
+ let protocolDetected = false;
38
+ let newProtocol = false;
26
39
  function setBaseUrl(baseUrl) {
27
40
  exports.axiosInstance.defaults.baseURL = baseUrl;
41
+ protocolDetected = false;
42
+ newProtocol = false;
43
+ }
44
+ /**
45
+ * 检测服务端协议版本
46
+ * @returns 是否为新协议
47
+ */
48
+ function detectProtocolVersion() {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ var _a, _b, _c;
51
+ if (protocolDetected)
52
+ return newProtocol;
53
+ protocolDetected = true;
54
+ try {
55
+ const resp = yield exports.axiosInstance.get('/Tools/Version');
56
+ if (((_a = resp.data) === null || _a === void 0 ? void 0 : _a.Code) === 0 && ((_b = resp.data) === null || _b === void 0 ? void 0 : _b.Success) && ((_c = resp.data) === null || _c === void 0 ? void 0 : _c.Data)) {
57
+ newProtocol = true;
58
+ console.log(`检测到新协议版本: ${resp.data.Data}`);
59
+ return true;
60
+ }
61
+ }
62
+ catch (_d) {
63
+ // Version 接口不可用,使用旧协议
64
+ }
65
+ return false;
66
+ });
67
+ }
68
+ function isNewProtocol() {
69
+ return newProtocol;
28
70
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wx2tg-puppet",
3
- "version": "3.0.3",
3
+ "version": "3.0.4",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [