homebridge-melcloud-control 4.0.0-beta.321 → 4.0.0-beta.323

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "displayName": "MELCloud Control",
3
3
  "name": "homebridge-melcloud-control",
4
- "version": "4.0.0-beta.321",
4
+ "version": "4.0.0-beta.323",
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
@@ -297,7 +297,7 @@ class MelCloud extends EventEmitter {
297
297
 
298
298
  const data = await melCloudHomeToken.buildAuthorizeUrl();
299
299
  const code = await melCloudHomeToken.loginToMelCloudHome(data.url);
300
- const token = await melCloudHomeToken.getTokens(code);
300
+ const token = await melCloudHomeToken.getTokens(code, data.codeVerifier);
301
301
 
302
302
  return false
303
303
 
@@ -83,13 +83,14 @@ class MelCloudHomeToken extends EventEmitter {
83
83
  }
84
84
  }
85
85
 
86
- async getTokens(code) {
86
+ async getTokens(code, codeVerifier) {
87
87
  try {
88
88
  const tokenResponse = await axios.post(TOKEN_ENDPOINT, new URLSearchParams({
89
89
  grant_type: 'authorization_code',
90
90
  client_id: CLIENT_ID,
91
91
  code: code,
92
- redirect_uri: REDIRECT_URI
92
+ redirect_uri: REDIRECT_URI,
93
+ code_verifier: codeVerifier,
93
94
  }).toString(), {
94
95
  headers: {
95
96
  'Content-Type': 'application/x-www-form-urlencoded'
@@ -110,7 +111,7 @@ class MelCloudHomeToken extends EventEmitter {
110
111
  // Step 1: Pobierz stronę logowania, żeby uzyskać sesję + token _csrf
111
112
  const getResp = await axios.get(url, {
112
113
  headers: {
113
- 'User-Agent': 'Mozilla/5.0',
114
+ 'User-Agent': MOBILE_USER_AGENT,
114
115
  'Accept': 'text/html',
115
116
  },
116
117
  withCredentials: true,
@@ -157,7 +158,7 @@ class MelCloudHomeToken extends EventEmitter {
157
158
  'Cookie': cookies.join('; '),
158
159
  'Origin': 'https://auth.melcloudhome.com',
159
160
  'Referer': url,
160
- 'User-Agent': 'Mozilla/5.0',
161
+ 'User-Agent': MOBILE_USER_AGENT
161
162
  },
162
163
  maxRedirects: 0,
163
164
  validateStatus: status => [200, 302, 400].includes(status),