homebridge-melcloud-control 4.0.0-beta.330 → 4.0.0-beta.332
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 -6
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.332",
|
|
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
|
@@ -132,6 +132,8 @@ class MelCloudHomeToken extends EventEmitter {
|
|
|
132
132
|
form.append('cognitoAsfData', '');
|
|
133
133
|
form.append('_csrf', csrf);
|
|
134
134
|
|
|
135
|
+
if (this.logWarn) this.emit('warn', `Redirect URL: ${url}`);
|
|
136
|
+
|
|
135
137
|
// Step 3: Wyślij POST z danymi logowania
|
|
136
138
|
const response = await axios.post(url, form.toString(), {
|
|
137
139
|
headers: {
|
|
@@ -148,6 +150,7 @@ class MelCloudHomeToken extends EventEmitter {
|
|
|
148
150
|
if (response.status === 302 && response.headers.location) {
|
|
149
151
|
// Login success — mamy redirect z "code="
|
|
150
152
|
const redirectUrl = response.headers.location;
|
|
153
|
+
if (this.logWarn) this.emit('warn', `Redirect URL: ${redirectUrl}`);
|
|
151
154
|
|
|
152
155
|
// 🔹 wykonaj GET na redirect URL (tam ustawiane są C1/C2)
|
|
153
156
|
const finalResp = await axios.get(redirectUrl, {
|
|
@@ -158,18 +161,14 @@ class MelCloudHomeToken extends EventEmitter {
|
|
|
158
161
|
validateStatus: s => [200, 302].includes(s),
|
|
159
162
|
});
|
|
160
163
|
|
|
161
|
-
if (this.logWarn) this.emit('warn', `Redirect URL: ${
|
|
164
|
+
if (this.logWarn) this.emit('warn', `Redirect URL: ${finalResp}`);
|
|
162
165
|
|
|
163
166
|
const finalCookies = finalResp.headers['set-cookie'] || [];
|
|
164
167
|
const c1 = finalCookies.find(c => c.startsWith('__Secure-monitorandcontrolC1='))?.split(';')[0];
|
|
165
168
|
const c2 = finalCookies.find(c => c.startsWith('__Secure-monitorandcontrolC2='))?.split(';')[0];
|
|
166
169
|
|
|
167
170
|
if (c1 && c2) {
|
|
168
|
-
const cookieHeader = [
|
|
169
|
-
'__Secure-monitorandcontrol=chunks-2',
|
|
170
|
-
c1,
|
|
171
|
-
c2
|
|
172
|
-
].join('; ');
|
|
171
|
+
const cookieHeader = ['__Secure-monitorandcontrol=chunks-2', c1, c2].join('; ');
|
|
173
172
|
if (this.logWarn) this.emit('warn', `Cookie returned: ${cookieHeader}`);
|
|
174
173
|
|
|
175
174
|
return cookieHeader;
|