homebridge-melcloud-control 4.0.0-beta.387 → 4.0.0-beta.388

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.387",
4
+ "version": "4.0.0-beta.388",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -9,7 +9,7 @@ const MOBILE_USER_AGENT = 'MonitorAndControl.App.Mobile/35 CFNetwork/3860.100.1
9
9
  const CLIENT_ID = 'homemobile';
10
10
  const REDIRECT_URI = 'melcloudhome://';
11
11
  const SCOPE = 'openid profile email offline_access IdentityServerApi';
12
- const TOKEN_ENDPOINT = 'https://app.melcloudhome.com/connect/token';
12
+ const TOKEN_ENDPOINT = 'https://auth.melcloudhome.com/connect/token';
13
13
  const AUTHORIZE_ENDPOINT = 'https://auth.melcloudhome.com/connect/authorize';
14
14
 
15
15
  class MelCloudHomeToken extends EventEmitter {
@@ -98,6 +98,7 @@ class MelCloudHomeToken extends EventEmitter {
98
98
  // Step 3: Wyślij POST z danymi logowania
99
99
  const response = await this.client.post(url, formData.toString(), {
100
100
  headers: {
101
+ 'User-Agent': MOBILE_USER_AGENT,
101
102
  'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
102
103
  'Accept-Language': 'en-US,en;q=0.9',
103
104
  'Content-Type': 'application/x-www-form-urlencoded',
@@ -111,7 +112,7 @@ class MelCloudHomeToken extends EventEmitter {
111
112
  });
112
113
 
113
114
  if (response.status === 400) if (this.logWarn) this.emit('warn', `Login failed (bad request or invalid credentials: ${response.data}`);
114
- if (response.status === 302 && response.headers.location) {
115
+ if (response.status === 302 && response.headers.location.startsWith('melcloudhome://')) {
115
116
  // Login success — mamy redirect z "code="
116
117
  const redirectUrl = response.headers.location;
117
118
  if (this.logWarn) this.emit('warn', `Redirect URL: ${getResp}`);