@tuya-sat/micro-dev-proxy 3.2.23 → 3.2.24

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.
@@ -37,6 +37,7 @@ export default class AppProxy {
37
37
  init(): Promise<void>;
38
38
  needManualLogin(): boolean;
39
39
  isLoginApi(url: string): boolean;
40
+ isApiBelongMainApp(url: string): boolean;
40
41
  getCsrf(): Promise<void>;
41
42
  getLoginCookie(): Promise<void>;
42
43
  getCookie(prevCookie?: string): string;
package/dist/appProxy.js CHANGED
@@ -70,7 +70,9 @@ class AppProxy {
70
70
  this.target = target;
71
71
  if (!isMainApp) {
72
72
  this.username = username;
73
- this.password = (0, js_sha256_1.sha256)(password);
73
+ if (password) {
74
+ this.password = (0, js_sha256_1.sha256)(password);
75
+ }
74
76
  }
75
77
  this.isMainApp = isMainApp;
76
78
  this.loginApi = loginApi;
@@ -107,7 +109,17 @@ class AppProxy {
107
109
  this.loginApi,
108
110
  '/api/login',
109
111
  '/api/login/qrcode'
110
- ].includes(url.replace(/^\/+/, ''));
112
+ ].includes(url.replace(/\/+$/, ''));
113
+ }
114
+ isApiBelongMainApp(url) {
115
+ return [
116
+ this.loginApi,
117
+ '/api/login',
118
+ '/api/login/qrcode',
119
+ '/open-api/v1.0/current/user',
120
+ '/open-api/v1.0/m/life/web/user/info',
121
+ '/open-api/v1.0/m/life/web/mqtt/connection/config',
122
+ ].includes(url.replace(/\/+$/, ''));
111
123
  }
112
124
  //获取csrf
113
125
  getCsrf() {
@@ -212,9 +224,8 @@ class AppProxy {
212
224
  this.log('----json parse responseBuffer string error-----', ((_a = err.response) === null || _a === void 0 ? void 0 : _a.data) || err.message);
213
225
  return responseBuffer;
214
226
  }
215
- const isApiBelongMainApp = [this.loginApi, '/open-api/v1.0/current/user'];
216
227
  const isMicroAppPage = (_b = req.referer) === null || _b === void 0 ? void 0 : _b.includes('/apps');
217
- if (!this.isMainApp && isMicroAppPage && !isApiBelongMainApp.includes(req.url)) {
228
+ if (!this.isMainApp && isMicroAppPage && !this.isApiBelongMainApp(req.url)) {
218
229
  const apiPathMatchReg = /\/(:[^/]+|\$?{[^/]+})/g;
219
230
  const apis = mf.apis || [];
220
231
  const microAppId = req.headers['micro-app-id'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-sat/micro-dev-proxy",
3
- "version": "3.2.23",
3
+ "version": "3.2.24",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "scripts": {