@tuya-sat/micro-dev-proxy 3.1.2 → 3.1.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.
- package/dist/appProxy.js +8 -1
- package/dist/csrf.js +1 -1
- package/package.json +1 -1
package/dist/appProxy.js
CHANGED
|
@@ -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
|
-
|
|
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);
|