homebridge-melcloud-control 4.0.0-beta.362 → 4.0.0-beta.364
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/melcloud.js +1 -1
- package/src/melcloudhometoken.js +10 -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.364",
|
|
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/melcloud.js
CHANGED
|
@@ -298,7 +298,7 @@ class MelCloud extends EventEmitter {
|
|
|
298
298
|
const url = data.url;
|
|
299
299
|
const codeVerifier = data.codeVerifier;
|
|
300
300
|
const code = await melCloudHomeToken.loginToMelCloudHome(url);
|
|
301
|
-
const token = await melCloudHomeToken.getTokens(code, codeVerifier);
|
|
301
|
+
//const token = await melCloudHomeToken.getTokens(code, codeVerifier);
|
|
302
302
|
|
|
303
303
|
const accountInfo = { ContextKey: code, UseFahrenheit: false };
|
|
304
304
|
this.contextKey = code;
|
package/src/melcloudhometoken.js
CHANGED
|
@@ -151,13 +151,23 @@ class MelCloudHomeToken extends EventEmitter {
|
|
|
151
151
|
validateStatus: status => [200, 302, 400].includes(status),
|
|
152
152
|
});
|
|
153
153
|
|
|
154
|
+
if (this.logWarn) this.emit('warn', `Redirect: ${cookies}`);
|
|
155
|
+
return cookies;
|
|
156
|
+
|
|
154
157
|
|
|
155
158
|
if (response.status === 302 && response.headers.location) {
|
|
156
159
|
// Login success — mamy redirect z "code="
|
|
157
160
|
const redirectUrl = response.headers.location;
|
|
158
161
|
if (this.logWarn) this.emit('warn', `Redirect URL: ${redirectUrl}`);
|
|
159
162
|
|
|
163
|
+
const getResp = await this.client.get('https://melcloudhome.com/ws/token', {
|
|
164
|
+
headers: {
|
|
165
|
+
'Accept': 'text/html',
|
|
166
|
+
},
|
|
167
|
+
withCredentials: true,
|
|
168
|
+
});
|
|
160
169
|
|
|
170
|
+
if (this.logWarn) this.emit('warn', `Redirect URL found code: ${getResp.data}, ${getResp.headers}`);
|
|
161
171
|
|
|
162
172
|
const match = redirectUrl.match(/[?&]code=([^&]+)/);
|
|
163
173
|
if (match) {
|