homebridge-melcloud-control 4.0.0-beta.270 → 4.0.0-beta.272
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 +2 -3
- package/src/melcloud.js +2 -1
- package/src/melcloudhometoken.js +2 -6
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.272",
|
|
5
5
|
"description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "grzegorz914",
|
|
@@ -42,8 +42,7 @@
|
|
|
42
42
|
"puppeteer": "^24.26.1",
|
|
43
43
|
"axios-cookiejar-support": "^6.0.4",
|
|
44
44
|
"tough-cookie": "^6.0.0",
|
|
45
|
-
"cheerio": "^1.1.2"
|
|
46
|
-
"node-fetch": "^3.3.2"
|
|
45
|
+
"cheerio": "^1.1.2"
|
|
47
46
|
},
|
|
48
47
|
"keywords": [
|
|
49
48
|
"homebridge",
|
package/src/melcloud.js
CHANGED
|
@@ -7,7 +7,6 @@ import MelCloudHomeToken from './melcloudhometoken.js';
|
|
|
7
7
|
import ImpulseGenerator from './impulsegenerator.js';
|
|
8
8
|
import Functions from './functions.js';
|
|
9
9
|
import { ApiUrls, ApiUrlsHome } from './constants.js';
|
|
10
|
-
import fetch from 'node-fetch';
|
|
11
10
|
import { URLSearchParams } from 'url';
|
|
12
11
|
const TOKEN_ENDPOINT = 'https://auth.melcloudhome.com/connect/token';
|
|
13
12
|
|
|
@@ -292,6 +291,8 @@ class MelCloud extends EventEmitter {
|
|
|
292
291
|
const melCloudHomeToken = new MelCloudHomeToken();
|
|
293
292
|
const url = await melCloudHomeToken.getUrl();
|
|
294
293
|
|
|
294
|
+
this.emit('warn', url);
|
|
295
|
+
|
|
295
296
|
const page = await browser.newPage();
|
|
296
297
|
await page.goto(url, { waitUntil: 'networkidle2' });
|
|
297
298
|
|
package/src/melcloudhometoken.js
CHANGED
|
@@ -32,11 +32,7 @@ class MelCloudHomeToken {
|
|
|
32
32
|
async getLoginPage(authUrl) {
|
|
33
33
|
console.log('Getting login page...');
|
|
34
34
|
const res = await this.client.get(authUrl, { maxRedirects: 10 });
|
|
35
|
-
|
|
36
|
-
const csrf = $('input[name="_csrf"]').attr('value');
|
|
37
|
-
if (!csrf) throw new Error('Could not extract CSRF token from login page');
|
|
38
|
-
console.log('CSRF token found:', csrf);
|
|
39
|
-
return { csrf, url: res.request.res.responseUrl };
|
|
35
|
+
return { url: res.request.res.responseUrl };
|
|
40
36
|
}
|
|
41
37
|
|
|
42
38
|
async getUrl() {
|
|
@@ -56,7 +52,7 @@ class MelCloudHomeToken {
|
|
|
56
52
|
|
|
57
53
|
const loginPage = await this.getLoginPage(authUrl.toString());
|
|
58
54
|
|
|
59
|
-
return loginPage;
|
|
55
|
+
return loginPage.url;
|
|
60
56
|
} catch (error) {
|
|
61
57
|
console.error('Failed to obtain OAuth tokens:', error);
|
|
62
58
|
throw error;
|