smart-home-engine 1.1.1 → 1.1.3
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{m as O}from"./monaco-langs-BW2J83t5.js";import{t as I}from"./index-
|
|
1
|
+
import{m as O}from"./monaco-langs-BW2J83t5.js";import{t as I}from"./index-S8U43ruI.js";/*!-----------------------------------------------------------------------------
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
3
|
* Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
|
|
4
4
|
* Released under the MIT license
|
package/dist/web/index.html
CHANGED
|
@@ -172,7 +172,7 @@
|
|
|
172
172
|
}
|
|
173
173
|
})();
|
|
174
174
|
</script>
|
|
175
|
-
<script type="module" crossorigin src="/assets/index-
|
|
175
|
+
<script type="module" crossorigin src="/assets/index-S8U43ruI.js"></script>
|
|
176
176
|
<link rel="modulepreload" crossorigin href="/assets/monaco-langs-BW2J83t5.js">
|
|
177
177
|
<link rel="stylesheet" crossorigin href="/assets/monaco-langs-DyX1CsEw.css">
|
|
178
178
|
<link rel="stylesheet" crossorigin href="/assets/index-DKIgEFlE.css">
|
package/package.json
CHANGED
package/src/lib/ssh-deploy.js
CHANGED
|
@@ -50,7 +50,8 @@ function scpArgs(sshConfig) {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
function sshTarget(sshConfig) {
|
|
53
|
-
|
|
53
|
+
const user = sshConfig.user || os.userInfo().username;
|
|
54
|
+
return `${user}@${sshConfig.host}`;
|
|
54
55
|
}
|
|
55
56
|
|
|
56
57
|
/**
|
|
@@ -159,4 +160,4 @@ async function generateKeypair(identityFile) {
|
|
|
159
160
|
return fs.readFileSync(expandedPath + '.pub', 'utf8').trim();
|
|
160
161
|
}
|
|
161
162
|
|
|
162
|
-
module.exports = { runCommand, readRemoteFile, uploadFile, uploadContent, testConnection, generateKeypair };
|
|
163
|
+
module.exports = { expandHome, runCommand, readRemoteFile, uploadFile, uploadContent, testConnection, generateKeypair };
|
package/src/web/broker-api.js
CHANGED
|
@@ -190,8 +190,7 @@ router.post('/config/restore', (req, res) => {
|
|
|
190
190
|
router.post('/reload', async (req, res) => {
|
|
191
191
|
try {
|
|
192
192
|
const bc = getBrokerConfig(req);
|
|
193
|
-
if (bc.
|
|
194
|
-
const cmd = bc.reloadCmd || 'sudo systemctl reload mosquitto';
|
|
193
|
+
if (bc.ssh && bc.ssh.host) {
|
|
195
194
|
const result = await sshDeploy.runCommand(bc.ssh, cmd);
|
|
196
195
|
return res.json({ ok: true, ...result });
|
|
197
196
|
}
|
|
@@ -210,8 +209,7 @@ router.post('/reload', async (req, res) => {
|
|
|
210
209
|
router.post('/restart', async (req, res) => {
|
|
211
210
|
try {
|
|
212
211
|
const bc = getBrokerConfig(req);
|
|
213
|
-
if (bc.
|
|
214
|
-
const cmd = bc.restartCmd || 'sudo systemctl restart mosquitto';
|
|
212
|
+
if (bc.ssh && bc.ssh.host) {
|
|
215
213
|
const result = await sshDeploy.runCommand(bc.ssh, cmd);
|
|
216
214
|
return res.json({ ok: true, ...result });
|
|
217
215
|
}
|
|
@@ -662,6 +660,20 @@ module.exports = { router };
|
|
|
662
660
|
// Note: these routes are mounted on the same router but defined after module.exports
|
|
663
661
|
// because they add to `router` (which is already exported by reference).
|
|
664
662
|
|
|
663
|
+
/** GET /she/broker/ssh/pubkey — Read existing public key (if any) */
|
|
664
|
+
router.get('/ssh/pubkey', (req, res) => {
|
|
665
|
+
try {
|
|
666
|
+
const bc = getBrokerConfig(req);
|
|
667
|
+
const identityFile = sshDeploy.expandHome((bc.ssh && bc.ssh.identityFile) || DEFAULT_SSH_KEY);
|
|
668
|
+
const pubPath = identityFile + '.pub';
|
|
669
|
+
if (!fs.existsSync(pubPath)) return res.json({ publicKey: null });
|
|
670
|
+
const publicKey = fs.readFileSync(pubPath, 'utf8').trim();
|
|
671
|
+
res.json({ publicKey });
|
|
672
|
+
} catch (err) {
|
|
673
|
+
handleError(res, err);
|
|
674
|
+
}
|
|
675
|
+
});
|
|
676
|
+
|
|
665
677
|
/** POST /she/broker/ssh/keygen — Generate SSH keypair */
|
|
666
678
|
router.post('/ssh/keygen', async (req, res) => {
|
|
667
679
|
try {
|
|
@@ -723,7 +735,7 @@ router.post('/wizard/bootstrap', async (req, res) => {
|
|
|
723
735
|
const username = req.body.adminUsername || 'she-admin';
|
|
724
736
|
const password = req.body.adminPassword || crypto.randomBytes(18).toString('base64url');
|
|
725
737
|
const configDir = (req.body.configDir || bc.configDir || '/etc/mosquitto').replace(/\\/g, '/');
|
|
726
|
-
const isRemote = bc.
|
|
738
|
+
const isRemote = !!(bc.ssh && bc.ssh.host);
|
|
727
739
|
|
|
728
740
|
const dynSecPath = `${configDir}/dynamic-security.json`;
|
|
729
741
|
const confFilePath = `${configDir}/mosquitto.conf`;
|