homebridge-melcloud-control 4.9.0-beta.6 β 4.9.0-beta.8
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/melcloudhome.js +15 -18
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"displayName": "MELCloud Control",
|
|
3
3
|
"name": "homebridge-melcloud-control",
|
|
4
|
-
"version": "4.9.0-beta.
|
|
4
|
+
"version": "4.9.0-beta.8",
|
|
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/melcloudhome.js
CHANGED
|
@@ -408,30 +408,27 @@ class MelCloudHome extends EventEmitter {
|
|
|
408
408
|
if (this.logDebug) this.emit('debug', 'Step 4: Follow Cognito β IdentityServer redirect');
|
|
409
409
|
|
|
410
410
|
const cognitoRedirectLocation = credResp.headers?.location ?? '';
|
|
411
|
-
|
|
412
|
-
if (!cognitoRedirectLocation) {
|
|
413
|
-
throw new Error('No Location header in Cognito response');
|
|
414
|
-
}
|
|
411
|
+
if (!cognitoRedirectLocation) throw new Error('No Location header in Cognito response');
|
|
415
412
|
|
|
416
413
|
if (this.logDebug) this.emit('debug', `Step 4 location: ${cognitoRedirectLocation}`);
|
|
417
414
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
const codeMatch = /code=([^&]+)/.exec(cognitoRedirectLocation);
|
|
423
|
-
if (!codeMatch) throw new Error('No code in signin-oidc-meu redirect');
|
|
415
|
+
const signinUrl = cognitoRedirectLocation.startsWith('http')
|
|
416
|
+
? cognitoRedirectLocation
|
|
417
|
+
: `https://${cognitoHostname}${cognitoRedirectLocation}`;
|
|
424
418
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
419
|
+
// GET na signin-oidc-meu β IdentityServer przetworzy i przekieruje do melcloudhome://
|
|
420
|
+
const signinResp = await this.pace(() =>
|
|
421
|
+
client.post(signinUrl, {
|
|
422
|
+
headers: { 'User-Agent': ApiUrls.Home.UserAgent },
|
|
423
|
+
maxRedirects: 0, // przechwytujemy redirect do melcloudhome://
|
|
424
|
+
})
|
|
425
|
+
);
|
|
428
426
|
|
|
429
|
-
|
|
430
|
-
|
|
427
|
+
if (this.logDebug) {
|
|
428
|
+
this.emit('debug', `Step 4 signin status: ${signinResp.status}`);
|
|
429
|
+
this.emit('debug', `Step 4 signin location: ${signinResp.headers?.location ?? '(none)'}`);
|
|
431
430
|
}
|
|
432
431
|
|
|
433
|
-
|
|
434
|
-
|
|
435
432
|
// ββ Step 5: WyciΔ
gnij auth code z redirectu melcloudhome:// βββββββββββ
|
|
436
433
|
if (this.logDebug) this.emit('debug', 'Step 5: Extract auth code from redirect');
|
|
437
434
|
|
|
@@ -461,7 +458,7 @@ class MelCloudHome extends EventEmitter {
|
|
|
461
458
|
|
|
462
459
|
if (this.logDebug) this.emit('debug', `Got auth code: ${authCode.slice(0, 20)}...`);
|
|
463
460
|
|
|
464
|
-
// ββ Step 6: WymieΕ kod na tokeny
|
|
461
|
+
// ββ Step 6: WymieΕ kod na tokeny ββββββββββββββββββ
|
|
465
462
|
const exchangeRes = await this.exchangeCodeForTokens(client, authCode, codeVerifier);
|
|
466
463
|
return this._buildConnectInfo(connectInfo, exchangeRes);
|
|
467
464
|
|