homebridge-melcloud-control 4.0.0-beta.536 → 4.0.0-beta.537
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/melcloud.js +41 -4
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.537",
|
|
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/melcloud.js
CHANGED
|
@@ -344,10 +344,47 @@ class MelCloud extends EventEmitter {
|
|
|
344
344
|
]
|
|
345
345
|
});
|
|
346
346
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
347
|
+
try {
|
|
348
|
+
// go to about:blank to ensure a clean origin
|
|
349
|
+
await page.goto('about:blank');
|
|
350
|
+
|
|
351
|
+
// prefer context-based clear if available
|
|
352
|
+
const pageContext = (typeof page.browserContext === 'function') ? page.browserContext() : (page.context ? page.context() : null);
|
|
353
|
+
|
|
354
|
+
if (pageContext && typeof pageContext.clearCookies === 'function') {
|
|
355
|
+
// modern API in some puppeteer versions
|
|
356
|
+
await pageContext.clearCookies();
|
|
357
|
+
} else {
|
|
358
|
+
// try CDP directly (works in most environments)
|
|
359
|
+
if (page._client && typeof page._client === 'function') {
|
|
360
|
+
const client = await page._client();
|
|
361
|
+
if (client && client.send) {
|
|
362
|
+
await client.send('Network.clearBrowserCookies');
|
|
363
|
+
} else if (page._client && page._client.send) {
|
|
364
|
+
// some versions expose _client directly as object
|
|
365
|
+
await page._client.send('Network.clearBrowserCookies');
|
|
366
|
+
} else {
|
|
367
|
+
// fallback to deleting cookies returned by page.cookies()
|
|
368
|
+
const cookies = await page.cookies();
|
|
369
|
+
if (cookies && cookies.length) {
|
|
370
|
+
await page.deleteCookie(...cookies).catch(() => { });
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
} else if (page._client && page._client.send) {
|
|
374
|
+
// older shape where _client is object
|
|
375
|
+
await page._client.send('Network.clearBrowserCookies');
|
|
376
|
+
} else {
|
|
377
|
+
// final fallback
|
|
378
|
+
const cookies = await page.cookies();
|
|
379
|
+
if (cookies && cookies.length) {
|
|
380
|
+
await page.deleteCookie(...cookies).catch(() => { });
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
} catch (clearErr) {
|
|
385
|
+
// nie przerywamy procesu logowania jeśli clear cookies nie zadziała, logujemy tylko warn
|
|
386
|
+
this.emit('warn', `Failed to clear cookies cleanly: ${clearErr.message}`);
|
|
387
|
+
}
|
|
351
388
|
page.setDefaultTimeout(GLOBAL_TIMEOUT);
|
|
352
389
|
page.setDefaultNavigationTimeout(GLOBAL_TIMEOUT);
|
|
353
390
|
|