@tuya-sat/micro-dev-proxy 3.1.1 → 3.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/appProxy.js CHANGED
@@ -93,7 +93,7 @@ class AppProxy {
93
93
  yield this.getLoginCookie();
94
94
  }
95
95
  catch (e) {
96
- throw e;
96
+ // throw e
97
97
  }
98
98
  finally {
99
99
  this.spinnies.stopAll();
@@ -143,7 +143,7 @@ class AppProxy {
143
143
  var _a, _b;
144
144
  const errMsg = ((_a = err.response) === null || _a === void 0 ? void 0 : _a.data) ? JSON.stringify((_b = err.response) === null || _b === void 0 ? void 0 : _b.data) : err.message;
145
145
  this.spinnies.fail('login', {
146
- text: `${SPIN_LABEL_NAME.login}\n\r ${errMsg}`
146
+ text: `${SPIN_LABEL_NAME.login}失败,请手动登录\n\r ${errMsg}`
147
147
  });
148
148
  return Promise.reject(errMsg);
149
149
  });
@@ -189,12 +189,19 @@ class AppProxy {
189
189
  let response;
190
190
  try {
191
191
  response = JSON.parse(responseBuffer.toString('utf8'));
192
+ if (req.url === this.loginApi) {
193
+ const token = (0, util_1.parseSetCookie)(proxyRes.headers['set-cookie']);
194
+ if (token) {
195
+ this.loginCookie.setValue(token);
196
+ }
197
+ }
192
198
  }
193
199
  catch (err) {
194
200
  this.log('----json parse responseBuffer string error-----', ((_a = err.response) === null || _a === void 0 ? void 0 : _a.data) || err.message);
195
201
  return responseBuffer;
196
202
  }
197
- if (!this.isMainApp) {
203
+ const isApiBelongMainApp = [this.loginApi, '/open-api/v1.0/current/user'];
204
+ if (!this.isMainApp && !isApiBelongMainApp.includes(req.url)) {
198
205
  const apiPathMatchReg = /\/(:[^/]+|\$?{[^/]+})/g;
199
206
  const apis = mf.apis || [];
200
207
  if (!(req === null || req === void 0 ? void 0 : req.headers['micro-app-id'].includes('main-app'))) {
package/dist/csrf.js CHANGED
@@ -14,7 +14,7 @@ function parseHtml(html) {
14
14
  }
15
15
  function getCsrf(url) {
16
16
  return globalAxios_1.default.get(url).then((res) => {
17
- const csrfCookie = res.headers['set-cookie']
17
+ const csrfCookie = (res.headers['set-cookie'] || [])
18
18
  .map((cookieInfo) => cookieInfo.split(';')[0])
19
19
  .find((cookie) => cookie.split('=')[0] === exports.COOKIE_CSRF) || '';
20
20
  let csrfToken = parseHtml(res.data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-sat/micro-dev-proxy",
3
- "version": "3.1.1",
3
+ "version": "3.1.3",
4
4
  "main": "dist/index.js",
5
5
  "license": "MIT",
6
6
  "scripts": {