@tuya-sat/micro-dev-proxy 3.0.27-beta.27 → 3.0.27-beta.29
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/csrf.js +3 -2
- package/package.json +1 -1
package/dist/csrf.js
CHANGED
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.HEADERS_CSRF = exports.COOKIE_CSRF = void 0;
|
|
7
7
|
const globalAxios_1 = __importDefault(require("./globalAxios"));
|
|
8
|
-
const util_1 = require("./util");
|
|
9
8
|
exports.COOKIE_CSRF = '_csrf';
|
|
10
9
|
exports.HEADERS_CSRF = 'csrf-token';
|
|
11
10
|
function parseHtml(html) {
|
|
@@ -15,7 +14,9 @@ function parseHtml(html) {
|
|
|
15
14
|
}
|
|
16
15
|
function getCsrf(url) {
|
|
17
16
|
return globalAxios_1.default.get(url).then((res) => {
|
|
18
|
-
|
|
17
|
+
const csrfCookie = res.headers['set-cookie']
|
|
18
|
+
.map((cookieInfo) => cookieInfo.split(';')[0])
|
|
19
|
+
.find((cookie) => cookie.split('=')[0] === exports.COOKIE_CSRF) || '';
|
|
19
20
|
let csrfToken = parseHtml(res.data);
|
|
20
21
|
return [csrfCookie, csrfToken];
|
|
21
22
|
});
|