homebridge-melcloud-control 4.0.0-beta.370 → 4.0.0-beta.372
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 +3 -11
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.372",
|
|
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
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import crypto from 'crypto';
|
|
3
|
-
import { wrapper } from 'axios-cookiejar-support';
|
|
4
|
-
import { CookieJar } from 'tough-cookie';
|
|
5
3
|
import { JSDOM } from 'jsdom';
|
|
6
4
|
import EventEmitter from 'events';
|
|
7
5
|
|
|
@@ -19,9 +17,7 @@ class MelCloudHomeToken extends EventEmitter {
|
|
|
19
17
|
this.passwd = config.passwd;
|
|
20
18
|
this.logWarn = config.logWarn;
|
|
21
19
|
this.logError = config.logError;
|
|
22
|
-
|
|
23
|
-
const jar = new CookieJar();
|
|
24
|
-
this.axiosInstance = wrapper(axios.create({ jar, withCredentials: true }));
|
|
20
|
+
this.axiosInstance = axios.create({ headers: { 'User-Agent': MOBILE_USER_AGENT } });
|
|
25
21
|
}
|
|
26
22
|
|
|
27
23
|
generatePKCE() {
|
|
@@ -96,7 +92,7 @@ class MelCloudHomeToken extends EventEmitter {
|
|
|
96
92
|
code_verifier: codeVerifier,
|
|
97
93
|
});
|
|
98
94
|
|
|
99
|
-
const tokenResponse = await this.axiosInstance({
|
|
95
|
+
const tokenResponse = await this.axiosInstance(tokenData.toString(), {
|
|
100
96
|
method: 'POST',
|
|
101
97
|
baseURL: TOKEN_ENDPOINT,
|
|
102
98
|
headers: {
|
|
@@ -104,7 +100,6 @@ class MelCloudHomeToken extends EventEmitter {
|
|
|
104
100
|
'Content-Length': tokenData.toString().length,
|
|
105
101
|
'Authorization': 'Basic aG9tZW1vYmlsZTo=',
|
|
106
102
|
},
|
|
107
|
-
data: tokenData.toString()
|
|
108
103
|
});
|
|
109
104
|
|
|
110
105
|
const tokens = tokenResponse.data;
|
|
@@ -122,7 +117,6 @@ class MelCloudHomeToken extends EventEmitter {
|
|
|
122
117
|
method: 'GET',
|
|
123
118
|
baseURL: url,
|
|
124
119
|
headers: {
|
|
125
|
-
'User-Agent': MOBILE_USER_AGENT,
|
|
126
120
|
'Accept': 'text/html',
|
|
127
121
|
},
|
|
128
122
|
withCredentials: true,
|
|
@@ -146,11 +140,10 @@ class MelCloudHomeToken extends EventEmitter {
|
|
|
146
140
|
if (this.logWarn) this.emit('warn', `Redirect URL: ${url}`);
|
|
147
141
|
|
|
148
142
|
// Step 3: Wyślij POST z danymi logowania
|
|
149
|
-
const response = await this.axiosInstance({
|
|
143
|
+
const response = await this.axiosInstance(formData.toString(), {
|
|
150
144
|
method: 'POST',
|
|
151
145
|
baseURL: url,
|
|
152
146
|
headers: {
|
|
153
|
-
'User-Agent': MOBILE_USER_AGENT,
|
|
154
147
|
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
|
155
148
|
'Accept-Language': 'en-US,en;q=0.9',
|
|
156
149
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
@@ -159,7 +152,6 @@ class MelCloudHomeToken extends EventEmitter {
|
|
|
159
152
|
'Origin': 'https://live-melcloudhome.auth.eu-west-1.amazoncognito.com',
|
|
160
153
|
'Referer': url,
|
|
161
154
|
},
|
|
162
|
-
data: formData.toString(),
|
|
163
155
|
maxRedirects: 0,
|
|
164
156
|
validateStatus: status => [200, 302, 400].includes(status),
|
|
165
157
|
});
|