homebridge-melcloud-control 4.0.0-beta.402 → 4.0.0-beta.403
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/package.json +1 -1
- package/src/melcloudhometoken.js +5 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.403",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|
package/src/melcloudhometoken.js
CHANGED
|
@@ -116,6 +116,7 @@ class MelCloudHomeToken extends EventEmitter {
|
|
|
116
116
|
validateStatus: () => true,
|
|
117
117
|
maxRedirects: 0,
|
|
118
118
|
responseType: 'text',
|
|
119
|
+
transformResponse: [(data) => data], // <— force raw string
|
|
119
120
|
});
|
|
120
121
|
if (resp.headers['set-cookie']) {
|
|
121
122
|
await this.cookieJar.setCookie(resp.headers['set-cookie'].join('; '), url);
|
|
@@ -136,6 +137,7 @@ class MelCloudHomeToken extends EventEmitter {
|
|
|
136
137
|
validateStatus: () => true,
|
|
137
138
|
maxRedirects: 0,
|
|
138
139
|
responseType: 'text',
|
|
140
|
+
transformResponse: [(data) => data], // <— force raw string
|
|
139
141
|
});
|
|
140
142
|
if (resp.headers['set-cookie']) {
|
|
141
143
|
await this.cookieJar.setCookie(resp.headers['set-cookie'].join('; '), url);
|
|
@@ -143,12 +145,15 @@ class MelCloudHomeToken extends EventEmitter {
|
|
|
143
145
|
return resp;
|
|
144
146
|
}
|
|
145
147
|
|
|
148
|
+
|
|
146
149
|
_extractCsrf(html) {
|
|
150
|
+
if (typeof html !== 'string') return null;
|
|
147
151
|
const match = html.match(/name="_csrf" value="([^"]+)"/);
|
|
148
152
|
return match ? match[1] : null;
|
|
149
153
|
}
|
|
150
154
|
|
|
151
155
|
_extractAuthCode(html) {
|
|
156
|
+
if (typeof html !== 'string') return null;
|
|
152
157
|
const urlMatch = html.match(/[?&]code=([^&]+)/);
|
|
153
158
|
if (urlMatch) return urlMatch[1];
|
|
154
159
|
const formMatch = html.match(/name="code"\s+value="([^"]+)"/);
|