homebridge-viessmann-vicare 2.0.4 → 2.0.6
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/dist/auth-manager.d.ts +79 -0
- package/dist/auth-manager.d.ts.map +1 -1
- package/dist/auth-manager.js +262 -73
- package/package.json +1 -1
package/dist/auth-manager.d.ts
CHANGED
|
@@ -113,6 +113,85 @@ export declare class AuthManager {
|
|
|
113
113
|
this.log.warn('⚠️ Error opening browser:', error);
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
+
|
|
117
|
+
private openBrowser(url: string): void {
|
|
118
|
+
const { execFile, exec } = require('child_process');
|
|
119
|
+
|
|
120
|
+
const tryExecFile = (cmd: string, args: string[], env: NodeJS.ProcessEnv) =>
|
|
121
|
+
new Promise<void>((resolve, reject) => {
|
|
122
|
+
execFile(cmd, args, { env }, (err: any) => err ? reject(err) : resolve());
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
const tryExec = (command: string, env: NodeJS.ProcessEnv) =>
|
|
126
|
+
new Promise<void>((resolve, reject) => {
|
|
127
|
+
exec(command, { env }, (err: any) => err ? reject(err) : resolve());
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// Copia pulita dell'ambiente
|
|
131
|
+
const env: NodeJS.ProcessEnv = { ...process.env };
|
|
132
|
+
|
|
133
|
+
// Migliora compatibilità Linux (X/Wayland) senza toccare il servizio
|
|
134
|
+
if (process.platform === 'linux') {
|
|
135
|
+
if (!env.DISPLAY) {
|
|
136
|
+
// fallback tipico X11
|
|
137
|
+
env.DISPLAY = ':0';
|
|
138
|
+
}
|
|
139
|
+
if (!env.XDG_RUNTIME_DIR && typeof process.getuid === 'function') {
|
|
140
|
+
env.XDG_RUNTIME_DIR = `/run/user/${process.getuid()}`;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
const tryLinux = async () => {
|
|
146
|
+
// 1) Standard freedesktop
|
|
147
|
+
try { await tryExecFile('xdg-open', [url], env); this.log.debug('🌐 xdg-open OK'); return; } catch {}
|
|
148
|
+
|
|
149
|
+
// 2) Gio / GVFS
|
|
150
|
+
try { await tryExec(`gio open "${url}"`, env); this.log.debug('🌐 gio open OK'); return; } catch {}
|
|
151
|
+
|
|
152
|
+
// 3) Debian-like helpers
|
|
153
|
+
try { await tryExecFile('sensible-browser', [url], env); this.log.debug('🌐 sensible-browser OK'); return; } catch {}
|
|
154
|
+
try { await tryExecFile('x-www-browser', [url], env); this.log.debug('🌐 x-www-browser OK'); return; } catch {}
|
|
155
|
+
|
|
156
|
+
// 4) xdg-desktop-portal (DBus OpenURI) — compatibile Wayland/X
|
|
157
|
+
try {
|
|
158
|
+
await tryExec(
|
|
159
|
+
`gdbus call --session ` +
|
|
160
|
+
`--dest org.freedesktop.portal.Desktop ` +
|
|
161
|
+
`--object-path /org/freedesktop/portal/desktop ` +
|
|
162
|
+
`--method org.freedesktop.portal.OpenURI.OpenURI "" "${url}" "{}"`,
|
|
163
|
+
env
|
|
164
|
+
);
|
|
165
|
+
this.log.debug('🌐 xdg-desktop-portal OpenURI OK');
|
|
166
|
+
return;
|
|
167
|
+
} catch {}
|
|
168
|
+
|
|
169
|
+
// 5) backend specifici (best-effort, non bloccanti)
|
|
170
|
+
try { await tryExecFile('kde-open5', [url], env); this.log.debug('🌐 kde-open5 OK'); return; } catch {}
|
|
171
|
+
try { await tryExecFile('gnome-open', [url], env); this.log.debug('🌐 gnome-open OK'); return; } catch {}
|
|
172
|
+
|
|
173
|
+
// Nessun metodo disponibile/riuscito
|
|
174
|
+
throw new Error('No Linux opener succeeded');
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
(async () => {
|
|
178
|
+
try {
|
|
179
|
+
switch (process.platform) {
|
|
180
|
+
case 'darwin':
|
|
181
|
+
await tryExec(`open "${url}"`, env);
|
|
182
|
+
break;
|
|
183
|
+
case 'win32':
|
|
184
|
+
await tryExec(`start "" "${url}"`, env);
|
|
185
|
+
break;
|
|
186
|
+
default:
|
|
187
|
+
await tryLinux();
|
|
188
|
+
}
|
|
189
|
+
this.log.info('✅ Tentativo di apertura browser completato');
|
|
190
|
+
} catch (e: any) {
|
|
191
|
+
this.log.warn(`⚠️ Impossibile aprire automaticamente il browser (${e?.message || e}). Apri l’URL manualmente.`);
|
|
192
|
+
}
|
|
193
|
+
})();
|
|
194
|
+
}
|
|
116
195
|
**/
|
|
117
196
|
private openBrowser;
|
|
118
197
|
private exchangeCodeForTokens;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-manager.d.ts","sourceRoot":"","sources":["../src/auth-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,aAAa,EAAiB,MAAM,OAAO,CAAC;AAOrD,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAkBD,qBAAa,WAAW;IAuBpB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM;IAzBzB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuD;IAC/E,OAAO,CAAC,QAA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C;QAC7B,yBAAyB,CAAC,EAAE,MAAM,CAAC;QACnC,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,IAAI,CAAC;KACjB;IAeH,OAAO,CAAC,iBAAiB;IAgBhB,OAAO,IAAI,IAAI;CAiBvB"}
|
package/dist/auth-manager.js
CHANGED
|
@@ -474,6 +474,8 @@ class AuthManager {
|
|
|
474
474
|
startAuthServer(callback) {
|
|
475
475
|
this.authServer = http.createServer((req, res) => {
|
|
476
476
|
const url = new URL(req.url, `http://localhost:${this.config.redirectPort || 4200}`);
|
|
477
|
+
this.log.warn(`🟢 Auth server listening on http://${this.hostIp}:${this.config.redirectPort || 4200}/`);
|
|
478
|
+
this.log.warn(`👉 If the browser does not open automatically, open this URL manually from another device:\nhttp://${this.hostIp}:${this.config.redirectPort || 4200}/login`);
|
|
477
479
|
if (url.pathname === '/') {
|
|
478
480
|
const code = url.searchParams.get('code');
|
|
479
481
|
const error = url.searchParams.get('error');
|
|
@@ -491,7 +493,7 @@ class AuthManager {
|
|
|
491
493
|
</html>
|
|
492
494
|
`);
|
|
493
495
|
callback(undefined, new Error(`OAuth error: ${errorDescription}`));
|
|
494
|
-
this.stopAuthServer();
|
|
496
|
+
//this.stopAuthServer();
|
|
495
497
|
return;
|
|
496
498
|
}
|
|
497
499
|
if (code) {
|
|
@@ -507,7 +509,7 @@ class AuthManager {
|
|
|
507
509
|
</html>
|
|
508
510
|
`);
|
|
509
511
|
callback(code);
|
|
510
|
-
this.stopAuthServer();
|
|
512
|
+
//this.stopAuthServer();
|
|
511
513
|
return;
|
|
512
514
|
}
|
|
513
515
|
}
|
|
@@ -515,7 +517,7 @@ class AuthManager {
|
|
|
515
517
|
res.writeHead(404, { 'Content-Type': 'text/plain' });
|
|
516
518
|
res.end('Not found');
|
|
517
519
|
});
|
|
518
|
-
this.authServer.listen(this.config.redirectPort || 4200, () => {
|
|
520
|
+
this.authServer.listen(this.config.redirectPort || 4200, '0.0.0.0', () => {
|
|
519
521
|
this.log.debug(`🌐 Auth server listening on ${this.hostIp}:${this.config.redirectPort || 4200}`);
|
|
520
522
|
});
|
|
521
523
|
this.authServer.on('error', (error) => {
|
|
@@ -568,97 +570,284 @@ class AuthManager {
|
|
|
568
570
|
this.log.warn('⚠️ Error opening browser:', error);
|
|
569
571
|
}
|
|
570
572
|
}
|
|
573
|
+
|
|
574
|
+
private openBrowser(url: string): void {
|
|
575
|
+
const { execFile, exec } = require('child_process');
|
|
576
|
+
|
|
577
|
+
const tryExecFile = (cmd: string, args: string[], env: NodeJS.ProcessEnv) =>
|
|
578
|
+
new Promise<void>((resolve, reject) => {
|
|
579
|
+
execFile(cmd, args, { env }, (err: any) => err ? reject(err) : resolve());
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
const tryExec = (command: string, env: NodeJS.ProcessEnv) =>
|
|
583
|
+
new Promise<void>((resolve, reject) => {
|
|
584
|
+
exec(command, { env }, (err: any) => err ? reject(err) : resolve());
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
// Copia pulita dell'ambiente
|
|
588
|
+
const env: NodeJS.ProcessEnv = { ...process.env };
|
|
589
|
+
|
|
590
|
+
// Migliora compatibilità Linux (X/Wayland) senza toccare il servizio
|
|
591
|
+
if (process.platform === 'linux') {
|
|
592
|
+
if (!env.DISPLAY) {
|
|
593
|
+
// fallback tipico X11
|
|
594
|
+
env.DISPLAY = ':0';
|
|
595
|
+
}
|
|
596
|
+
if (!env.XDG_RUNTIME_DIR && typeof process.getuid === 'function') {
|
|
597
|
+
env.XDG_RUNTIME_DIR = `/run/user/${process.getuid()}`;
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
const tryLinux = async () => {
|
|
603
|
+
// 1) Standard freedesktop
|
|
604
|
+
try { await tryExecFile('xdg-open', [url], env); this.log.debug('🌐 xdg-open OK'); return; } catch {}
|
|
605
|
+
|
|
606
|
+
// 2) Gio / GVFS
|
|
607
|
+
try { await tryExec(`gio open "${url}"`, env); this.log.debug('🌐 gio open OK'); return; } catch {}
|
|
608
|
+
|
|
609
|
+
// 3) Debian-like helpers
|
|
610
|
+
try { await tryExecFile('sensible-browser', [url], env); this.log.debug('🌐 sensible-browser OK'); return; } catch {}
|
|
611
|
+
try { await tryExecFile('x-www-browser', [url], env); this.log.debug('🌐 x-www-browser OK'); return; } catch {}
|
|
612
|
+
|
|
613
|
+
// 4) xdg-desktop-portal (DBus OpenURI) — compatibile Wayland/X
|
|
614
|
+
try {
|
|
615
|
+
await tryExec(
|
|
616
|
+
`gdbus call --session ` +
|
|
617
|
+
`--dest org.freedesktop.portal.Desktop ` +
|
|
618
|
+
`--object-path /org/freedesktop/portal/desktop ` +
|
|
619
|
+
`--method org.freedesktop.portal.OpenURI.OpenURI "" "${url}" "{}"`,
|
|
620
|
+
env
|
|
621
|
+
);
|
|
622
|
+
this.log.debug('🌐 xdg-desktop-portal OpenURI OK');
|
|
623
|
+
return;
|
|
624
|
+
} catch {}
|
|
625
|
+
|
|
626
|
+
// 5) backend specifici (best-effort, non bloccanti)
|
|
627
|
+
try { await tryExecFile('kde-open5', [url], env); this.log.debug('🌐 kde-open5 OK'); return; } catch {}
|
|
628
|
+
try { await tryExecFile('gnome-open', [url], env); this.log.debug('🌐 gnome-open OK'); return; } catch {}
|
|
629
|
+
|
|
630
|
+
// Nessun metodo disponibile/riuscito
|
|
631
|
+
throw new Error('No Linux opener succeeded');
|
|
632
|
+
};
|
|
633
|
+
|
|
634
|
+
(async () => {
|
|
635
|
+
try {
|
|
636
|
+
switch (process.platform) {
|
|
637
|
+
case 'darwin':
|
|
638
|
+
await tryExec(`open "${url}"`, env);
|
|
639
|
+
break;
|
|
640
|
+
case 'win32':
|
|
641
|
+
await tryExec(`start "" "${url}"`, env);
|
|
642
|
+
break;
|
|
643
|
+
default:
|
|
644
|
+
await tryLinux();
|
|
645
|
+
}
|
|
646
|
+
this.log.info('✅ Tentativo di apertura browser completato');
|
|
647
|
+
} catch (e: any) {
|
|
648
|
+
this.log.warn(`⚠️ Impossibile aprire automaticamente il browser (${e?.message || e}). Apri l’URL manualmente.`);
|
|
649
|
+
}
|
|
650
|
+
})();
|
|
651
|
+
}
|
|
571
652
|
**/
|
|
572
653
|
openBrowser(url) {
|
|
573
654
|
const { execFile, exec } = require('child_process');
|
|
574
|
-
|
|
575
|
-
execFile(cmd, args, { env }, (err) => err ? reject(err) : resolve());
|
|
576
|
-
});
|
|
577
|
-
const tryExec = (command, env) => new Promise((resolve, reject) => {
|
|
578
|
-
exec(command, { env }, (err) => err ? reject(err) : resolve());
|
|
579
|
-
});
|
|
580
|
-
// Copia pulita dell'ambiente
|
|
655
|
+
// Ambiente pulito senza toccare DISPLAY
|
|
581
656
|
const env = { ...process.env };
|
|
582
|
-
//
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
return;
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
657
|
+
// Helper per eseguire comandi con timeout
|
|
658
|
+
const execWithTimeout = (command, args = [], timeout = 5000) => {
|
|
659
|
+
return new Promise((resolve, reject) => {
|
|
660
|
+
const child = args.length > 0
|
|
661
|
+
? execFile(command, args, { env, timeout })
|
|
662
|
+
: exec(command, { env, timeout });
|
|
663
|
+
child.on('error', reject);
|
|
664
|
+
child.on('exit', (code) => {
|
|
665
|
+
if (code === 0)
|
|
666
|
+
resolve();
|
|
667
|
+
else
|
|
668
|
+
reject(new Error(`Exit code ${code}`));
|
|
669
|
+
});
|
|
670
|
+
});
|
|
671
|
+
};
|
|
672
|
+
const detectDesktopEnvironment = () => {
|
|
673
|
+
const xdg = env.XDG_CURRENT_DESKTOP?.toLowerCase() || '';
|
|
674
|
+
const session = env.DESKTOP_SESSION?.toLowerCase() || '';
|
|
675
|
+
const gdmsession = env.GDMSESSION?.toLowerCase() || '';
|
|
676
|
+
// Controlla tutti i possibili indicatori
|
|
677
|
+
const indicators = [xdg, session, gdmsession].join(':');
|
|
678
|
+
if (indicators.includes('gnome'))
|
|
679
|
+
return 'gnome';
|
|
680
|
+
if (indicators.includes('kde') || indicators.includes('plasma'))
|
|
681
|
+
return 'kde';
|
|
682
|
+
if (indicators.includes('xfce'))
|
|
683
|
+
return 'xfce';
|
|
684
|
+
if (indicators.includes('lxde') || indicators.includes('lxqt'))
|
|
685
|
+
return 'lxde';
|
|
686
|
+
if (indicators.includes('mate'))
|
|
687
|
+
return 'mate';
|
|
688
|
+
if (indicators.includes('cinnamon'))
|
|
689
|
+
return 'cinnamon';
|
|
690
|
+
if (indicators.includes('labwc') || indicators.includes('wlroots'))
|
|
691
|
+
return 'wayland';
|
|
692
|
+
if (indicators.includes('wayfire') || indicators.includes('sway'))
|
|
693
|
+
return 'wayland';
|
|
694
|
+
return 'unknown';
|
|
695
|
+
};
|
|
696
|
+
const tryLinuxMethods = async () => {
|
|
697
|
+
const desktop = detectDesktopEnvironment();
|
|
698
|
+
this.log.debug(`🖥️ Desktop environment detected: ${desktop} (XDG_CURRENT_DESKTOP=${env.XDG_CURRENT_DESKTOP})`);
|
|
699
|
+
// 1. Metodo universale - xdg-open (funziona con tutti i DE moderni)
|
|
614
700
|
try {
|
|
615
|
-
await
|
|
616
|
-
this.log.
|
|
617
|
-
return;
|
|
701
|
+
await execWithTimeout('xdg-open', [url]);
|
|
702
|
+
this.log.info('✅ Browser aperto con xdg-open');
|
|
703
|
+
return true;
|
|
618
704
|
}
|
|
619
705
|
catch { }
|
|
620
|
-
//
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
706
|
+
// 2. Metodi specifici per desktop environment
|
|
707
|
+
switch (desktop) {
|
|
708
|
+
case 'gnome':
|
|
709
|
+
try {
|
|
710
|
+
await execWithTimeout('gnome-open', [url]);
|
|
711
|
+
this.log.info('✅ Browser aperto con gnome-open');
|
|
712
|
+
return true;
|
|
713
|
+
}
|
|
714
|
+
catch { }
|
|
715
|
+
try {
|
|
716
|
+
await execWithTimeout('gio', ['open', url]);
|
|
717
|
+
this.log.info('✅ Browser aperto con gio open');
|
|
718
|
+
return true;
|
|
719
|
+
}
|
|
720
|
+
catch { }
|
|
721
|
+
break;
|
|
722
|
+
case 'kde':
|
|
723
|
+
try {
|
|
724
|
+
await execWithTimeout('kde-open5', [url]);
|
|
725
|
+
this.log.info('✅ Browser aperto con kde-open5');
|
|
726
|
+
return true;
|
|
727
|
+
}
|
|
728
|
+
catch { }
|
|
729
|
+
try {
|
|
730
|
+
await execWithTimeout('kde-open', [url]);
|
|
731
|
+
this.log.info('✅ Browser aperto con kde-open');
|
|
732
|
+
return true;
|
|
733
|
+
}
|
|
734
|
+
catch { }
|
|
735
|
+
break;
|
|
736
|
+
case 'xfce':
|
|
737
|
+
try {
|
|
738
|
+
await execWithTimeout('exo-open', [url]);
|
|
739
|
+
this.log.info('✅ Browser aperto con exo-open');
|
|
740
|
+
return true;
|
|
741
|
+
}
|
|
742
|
+
catch { }
|
|
743
|
+
break;
|
|
744
|
+
case 'lxde':
|
|
745
|
+
try {
|
|
746
|
+
await execWithTimeout('pcmanfm', [url]);
|
|
747
|
+
this.log.info('✅ Browser aperto con pcmanfm');
|
|
748
|
+
return true;
|
|
749
|
+
}
|
|
750
|
+
catch { }
|
|
751
|
+
break;
|
|
752
|
+
case 'mate':
|
|
753
|
+
try {
|
|
754
|
+
await execWithTimeout('mate-open', [url]);
|
|
755
|
+
this.log.info('✅ Browser aperto con mate-open');
|
|
756
|
+
return true;
|
|
757
|
+
}
|
|
758
|
+
catch { }
|
|
759
|
+
break;
|
|
760
|
+
case 'cinnamon':
|
|
761
|
+
try {
|
|
762
|
+
await execWithTimeout('cinnamon-open', [url]);
|
|
763
|
+
this.log.info('✅ Browser aperto con cinnamon-open');
|
|
764
|
+
return true;
|
|
765
|
+
}
|
|
766
|
+
catch { }
|
|
767
|
+
break;
|
|
768
|
+
case 'wayland':
|
|
769
|
+
// Portal DBus (metodo nativo Wayland - funziona con labwc)
|
|
770
|
+
try {
|
|
771
|
+
const escapedUrl = url.replace(/"/g, '\\"');
|
|
772
|
+
await execWithTimeout('gdbus', [
|
|
773
|
+
'call', '--session',
|
|
774
|
+
'--dest', 'org.freedesktop.portal.Desktop',
|
|
775
|
+
'--object-path', '/org/freedesktop/portal/desktop',
|
|
776
|
+
'--method', 'org.freedesktop.portal.OpenURI.OpenURI',
|
|
777
|
+
'', escapedUrl, '{}'
|
|
778
|
+
]);
|
|
779
|
+
this.log.info('✅ Browser aperto con xdg-desktop-portal (Wayland)');
|
|
780
|
+
return true;
|
|
781
|
+
}
|
|
782
|
+
catch { }
|
|
783
|
+
break;
|
|
628
784
|
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
785
|
+
// 3. Fallback: Helper generici Debian/Ubuntu/Raspberry Pi OS
|
|
786
|
+
const helpers = ['sensible-browser', 'x-www-browser', 'www-browser'];
|
|
787
|
+
for (const helper of helpers) {
|
|
788
|
+
try {
|
|
789
|
+
await execWithTimeout(helper, [url]);
|
|
790
|
+
this.log.info(`✅ Browser aperto con ${helper}`);
|
|
791
|
+
return true;
|
|
792
|
+
}
|
|
793
|
+
catch { }
|
|
635
794
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
795
|
+
// 4. Ultimo tentativo: Browser diretti
|
|
796
|
+
const browsers = [
|
|
797
|
+
'chromium-browser', // Raspberry Pi OS default
|
|
798
|
+
'chromium',
|
|
799
|
+
'firefox',
|
|
800
|
+
'firefox-esr', // Debian/Raspberry Pi OS
|
|
801
|
+
'google-chrome',
|
|
802
|
+
'microsoft-edge',
|
|
803
|
+
'brave-browser',
|
|
804
|
+
'opera'
|
|
805
|
+
];
|
|
806
|
+
for (const browser of browsers) {
|
|
807
|
+
try {
|
|
808
|
+
await execWithTimeout(browser, [url]);
|
|
809
|
+
this.log.info(`✅ Browser aperto con ${browser}`);
|
|
810
|
+
return true;
|
|
811
|
+
}
|
|
812
|
+
catch { }
|
|
641
813
|
}
|
|
642
|
-
|
|
643
|
-
// Nessun metodo disponibile/riuscito
|
|
644
|
-
throw new Error('No Linux opener succeeded');
|
|
814
|
+
return false;
|
|
645
815
|
};
|
|
646
816
|
(async () => {
|
|
647
817
|
try {
|
|
818
|
+
let success = false;
|
|
648
819
|
switch (process.platform) {
|
|
649
820
|
case 'darwin':
|
|
650
|
-
await
|
|
821
|
+
await execWithTimeout('open', [url]);
|
|
822
|
+
success = true;
|
|
651
823
|
break;
|
|
652
824
|
case 'win32':
|
|
653
|
-
await
|
|
825
|
+
await execWithTimeout(`start "" "${url}"`);
|
|
826
|
+
success = true;
|
|
654
827
|
break;
|
|
655
|
-
default:
|
|
656
|
-
await
|
|
828
|
+
default: // Linux
|
|
829
|
+
success = await tryLinuxMethods();
|
|
830
|
+
}
|
|
831
|
+
if (success) {
|
|
832
|
+
this.log.info('🌐 Browser aperto con successo');
|
|
833
|
+
}
|
|
834
|
+
else {
|
|
835
|
+
throw new Error('Tutti i metodi di apertura browser falliti');
|
|
657
836
|
}
|
|
658
|
-
this.log.info('✅ Tentativo di apertura browser completato');
|
|
659
837
|
}
|
|
660
838
|
catch (e) {
|
|
661
|
-
this.log.warn(
|
|
839
|
+
this.log.warn('='.repeat(80));
|
|
840
|
+
this.log.warn('⚠️ IMPOSSIBILE APRIRE IL BROWSER AUTOMATICAMENTE');
|
|
841
|
+
this.log.warn('='.repeat(80));
|
|
842
|
+
this.log.warn('📱 Apri manualmente questo URL da QUALSIASI dispositivo nella tua rete:');
|
|
843
|
+
this.log.warn('');
|
|
844
|
+
this.log.warn(` ${url}`);
|
|
845
|
+
this.log.warn('');
|
|
846
|
+
this.log.warn('💡 Puoi usare:');
|
|
847
|
+
this.log.warn(' • Computer/laptop sulla stessa rete');
|
|
848
|
+
this.log.warn(' • Smartphone/tablet');
|
|
849
|
+
this.log.warn(' • Qualsiasi browser moderno');
|
|
850
|
+
this.log.warn('='.repeat(80));
|
|
662
851
|
}
|
|
663
852
|
})();
|
|
664
853
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-viessmann-vicare",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"description": "Complete Homebridge plugin for Viessmann ViCare heating systems with full control capabilities, advanced rate limiting protection, and intelligent cache management",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|