homebridge-melcloud-control 4.0.0-beta.300 → 4.0.0-beta.302

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.300",
4
+ "version": "4.0.0-beta.302",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -1,5 +1,7 @@
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';
3
5
 
4
6
  const MOBILE_USER_AGENT = 'MonitorAndControl.App.Mobile/35 CFNetwork/3860.100.1 Darwin/25.0.0';
5
7
  const CLIENT_ID = 'homemobile';
@@ -10,6 +12,9 @@ const AUTHORIZE_ENDPOINT = 'https://auth.melcloudhome.com/connect/authorize';
10
12
 
11
13
  class MelCloudHomeToken {
12
14
  constructor() {
15
+ const jar = new CookieJar();
16
+ this.client = wrapper(axios.create({ jar, withCredentials: true }));
17
+ this.client.defaults.headers['User-Agent'] = MOBILE_USER_AGENT;
13
18
  }
14
19
 
15
20
  generatePKCE() {
@@ -91,7 +96,7 @@ class MelCloudHomeToken {
91
96
  data: tokenData,
92
97
  timeout: 10000
93
98
  });
94
-
99
+ console.log(res);
95
100
  if (res.status !== 200) {
96
101
  throw new Error(`Token exchange failed: ${res.status} ${res.statusText}`);
97
102
  }