homebridge-melcloud-control 4.9.0-beta.8 → 4.9.0-beta.9

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.9.0-beta.8",
4
+ "version": "4.9.0-beta.9",
5
5
  "description": "Homebridge plugin to control Mitsubishi Air Conditioner, Heat Pump and Energy Recovery Ventilation.",
6
6
  "license": "MIT",
7
7
  "author": "grzegorz914",
@@ -34,7 +34,7 @@ class MelCloudHome extends EventEmitter {
34
34
 
35
35
  // axios auth client and token state
36
36
  this.authClient = null;
37
- this._accessToken = null;
37
+ this._accessToken = null; // podkreślnik — unika konfliktu z getterami
38
38
  this._refreshToken = null;
39
39
  this._tokenExpiry = 0; // Unix timestamp (sekundy)
40
40
  this._authenticated = false;
@@ -412,15 +412,23 @@ class MelCloudHome extends EventEmitter {
412
412
 
413
413
  if (this.logDebug) this.emit('debug', `Step 4 location: ${cognitoRedirectLocation}`);
414
414
 
415
- const signinUrl = cognitoRedirectLocation.startsWith('http')
416
- ? cognitoRedirectLocation
417
- : `https://${cognitoHostname}${cognitoRedirectLocation}`;
415
+ // signin-oidc-meu to endpoint IdentityServera obsługujący callback z Cognito.
416
+ // Cognito normalnie robi tam form_post (POST z code i state w body),
417
+ // ale my dostaliśmy 302 z parametrami w query stringu — wysyłamy więc POST
418
+ // z tymi samymi parametrami w body (tak jak zrobiłoby to Cognito).
419
+ const signinParsed = new URL(cognitoRedirectLocation);
420
+ const signinBase = `${signinParsed.protocol}//${signinParsed.host}${signinParsed.pathname}`;
421
+ const signinParams = new URLSearchParams(signinParsed.search);
422
+
423
+ if (this.logDebug) this.emit('debug', `Step 4 POST to: ${signinBase} params: ${[...signinParams.keys()].join(', ')}`);
418
424
 
419
- // GET na signin-oidc-meu — IdentityServer przetworzy i przekieruje do melcloudhome://
420
425
  const signinResp = await this.pace(() =>
421
- client.post(signinUrl, {
422
- headers: { 'User-Agent': ApiUrls.Home.UserAgent },
423
- maxRedirects: 0, // przechwytujemy redirect do melcloudhome://
426
+ client.post(signinBase, signinParams, {
427
+ headers: {
428
+ 'User-Agent': ApiUrls.Home.UserAgent,
429
+ 'Content-Type': 'application/x-www-form-urlencoded',
430
+ },
431
+ maxRedirects: 0,
424
432
  })
425
433
  );
426
434
 
@@ -458,7 +466,7 @@ class MelCloudHome extends EventEmitter {
458
466
 
459
467
  if (this.logDebug) this.emit('debug', `Got auth code: ${authCode.slice(0, 20)}...`);
460
468
 
461
- // ── Step 6: Wymień kod na tokeny ──────────────────
469
+ // ── Step 6: Wymień kod na tokeny (WAŻNE: await!) ──────────────────
462
470
  const exchangeRes = await this.exchangeCodeForTokens(client, authCode, codeVerifier);
463
471
  return this._buildConnectInfo(connectInfo, exchangeRes);
464
472