homebridge-melcloud-control 4.0.0-beta.538 → 4.0.0-beta.539
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 +14 -48
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.539",
|
|
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
|
@@ -331,7 +331,7 @@ class MelCloud extends EventEmitter {
|
|
|
331
331
|
|
|
332
332
|
this.emit('warn', `Launching Chromium...`);
|
|
333
333
|
browser = await puppeteer.launch({
|
|
334
|
-
headless: '
|
|
334
|
+
headless: 'new',
|
|
335
335
|
executablePath: chromiumPath,
|
|
336
336
|
timeout: GLOBAL_TIMEOUT,
|
|
337
337
|
args: [
|
|
@@ -344,56 +344,22 @@ class MelCloud extends EventEmitter {
|
|
|
344
344
|
]
|
|
345
345
|
});
|
|
346
346
|
|
|
347
|
-
let
|
|
348
|
-
if (typeof browser.
|
|
349
|
-
|
|
347
|
+
let context;
|
|
348
|
+
if (typeof browser.createBrowserContext === 'function') {
|
|
349
|
+
// nowoczesne API
|
|
350
|
+
context = await browser.createBrowserContext();
|
|
350
351
|
} else {
|
|
351
|
-
// fallback
|
|
352
|
-
|
|
353
|
-
page = pages && pages.length ? pages[0] : await browser.newPage();
|
|
352
|
+
// fallback do starego API (dla bezpieczeństwa)
|
|
353
|
+
context = browser.defaultBrowserContext?.() || browser;
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
if (pageContext && typeof pageContext.clearCookies === 'function') {
|
|
364
|
-
// modern API in some puppeteer versions
|
|
365
|
-
await pageContext.clearCookies();
|
|
366
|
-
} else {
|
|
367
|
-
// try CDP directly (works in most environments)
|
|
368
|
-
if (page._client && typeof page._client === 'function') {
|
|
369
|
-
const client = await page._client();
|
|
370
|
-
if (client && client.send) {
|
|
371
|
-
await client.send('Network.clearBrowserCookies');
|
|
372
|
-
} else if (page._client && page._client.send) {
|
|
373
|
-
// some versions expose _client directly as object
|
|
374
|
-
await page._client.send('Network.clearBrowserCookies');
|
|
375
|
-
} else {
|
|
376
|
-
// fallback to deleting cookies returned by page.cookies()
|
|
377
|
-
const cookies = await page.cookies();
|
|
378
|
-
if (cookies && cookies.length) {
|
|
379
|
-
await page.deleteCookie(...cookies).catch(() => { });
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
} else if (page._client && page._client.send) {
|
|
383
|
-
// older shape where _client is object
|
|
384
|
-
await page._client.send('Network.clearBrowserCookies');
|
|
385
|
-
} else {
|
|
386
|
-
// final fallback
|
|
387
|
-
const cookies = await page.cookies();
|
|
388
|
-
if (cookies && cookies.length) {
|
|
389
|
-
await page.deleteCookie(...cookies).catch(() => { });
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
} catch (clearErr) {
|
|
394
|
-
// nie przerywamy procesu logowania jeśli clear cookies nie zadziała, logujemy tylko warn
|
|
395
|
-
this.emit('warn', `Failed to clear cookies cleanly: ${clearErr.message}`);
|
|
396
|
-
}
|
|
356
|
+
const page = await context.newPage();
|
|
357
|
+
|
|
358
|
+
// --- wyczyszczenie cookies ---
|
|
359
|
+
const client = await page.createCDPSession();
|
|
360
|
+
await client.send('Network.clearBrowserCookies');
|
|
361
|
+
|
|
362
|
+
await page.goto('about:blank');
|
|
397
363
|
page.setDefaultTimeout(GLOBAL_TIMEOUT);
|
|
398
364
|
page.setDefaultNavigationTimeout(GLOBAL_TIMEOUT);
|
|
399
365
|
|