homebridge-melcloud-control 4.0.0-beta.350 → 4.0.0-beta.352
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 +12 -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.352",
|
|
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
|
@@ -301,7 +301,7 @@ class MelCloud extends EventEmitter {
|
|
|
301
301
|
//const token = await melCloudHomeToken.getTokens(code, codeVerifier);
|
|
302
302
|
|
|
303
303
|
const accountInfo = { ContextKey: code, UseFahrenheit: false };
|
|
304
|
-
this.contextKey =
|
|
304
|
+
this.contextKey = code;
|
|
305
305
|
|
|
306
306
|
return accountInfo
|
|
307
307
|
} catch (error) {
|
package/src/melcloudhometoken.js
CHANGED
|
@@ -153,11 +153,23 @@ class MelCloudHomeToken extends EventEmitter {
|
|
|
153
153
|
validateStatus: status => [200, 302, 400].includes(status),
|
|
154
154
|
});
|
|
155
155
|
|
|
156
|
+
if (this.logWarn) this.emit('warn', `Response: ${response}`);
|
|
157
|
+
|
|
156
158
|
if (response.status === 302 && response.headers.location) {
|
|
157
159
|
// Login success — mamy redirect z "code="
|
|
158
160
|
const redirectUrl = response.headers.location;
|
|
159
161
|
if (this.logWarn) this.emit('warn', `Redirect URL: ${redirectUrl}`);
|
|
160
162
|
|
|
163
|
+
const getResp = await axios.get('https://melcloudhome.com/dashboard', {
|
|
164
|
+
headers: {
|
|
165
|
+
'User-Agent': MOBILE_USER_AGENT,
|
|
166
|
+
'Accept': 'text/html',
|
|
167
|
+
},
|
|
168
|
+
withCredentials: true,
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
if (this.logWarn) this.emit('warn', `ResponseL: ${getResp}`);
|
|
172
|
+
|
|
161
173
|
const match = redirectUrl.match(/[?&]code=([^&]+)/);
|
|
162
174
|
if (match) {
|
|
163
175
|
const code = match[1];
|