smart-home-engine 1.1.9 → 1.1.11
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-DiZlYUuT.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-DiZlYUuT.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-iTrR9H4f.css">
|
package/package.json
CHANGED
package/src/web/broker-api.js
CHANGED
|
@@ -103,16 +103,16 @@ router.get('/config', async (req, res) => {
|
|
|
103
103
|
try {
|
|
104
104
|
const bc = getBrokerConfig(req);
|
|
105
105
|
const fp = confPath(bc);
|
|
106
|
-
const backups = mosquittoConf.listBackups(fp).map((b) => path.basename(b));
|
|
107
106
|
if (bc.ssh && bc.ssh.host) {
|
|
108
107
|
_log?.debug(`broker: reading remote config from ${bc.ssh.host}:${fp}`);
|
|
109
108
|
const raw = await sshDeploy.readRemoteFile(bc.ssh, fp);
|
|
110
109
|
const parsed = mosquittoConf.parseText(raw);
|
|
111
110
|
const cs = crypto.createHash('sha256').update(raw).digest('hex');
|
|
112
|
-
return res.json({ ...parsed, checksum: cs, backups });
|
|
111
|
+
return res.json({ ...parsed, checksum: cs, backups: [] });
|
|
113
112
|
}
|
|
114
113
|
const parsed = mosquittoConf.parse(fp);
|
|
115
114
|
const cs = mosquittoConf.checksum(fp);
|
|
115
|
+
const backups = mosquittoConf.listBackups(fp).map((b) => path.basename(b));
|
|
116
116
|
res.json({ ...parsed, checksum: cs, backups });
|
|
117
117
|
} catch (err) {
|
|
118
118
|
handleError(res, err);
|
|
@@ -123,7 +123,7 @@ router.get('/config', async (req, res) => {
|
|
|
123
123
|
* PUT /she/broker/config
|
|
124
124
|
* Write structured config (body: { listeners, managed, passthrough, checksum? }).
|
|
125
125
|
* body.checksum is the client's last-known checksum for external-modify detection.
|
|
126
|
-
* In remote mode,
|
|
126
|
+
* In remote mode, uploads directly to the broker host via SCP — no local fs access.
|
|
127
127
|
*/
|
|
128
128
|
router.put('/config', async (req, res) => {
|
|
129
129
|
try {
|
|
@@ -131,17 +131,16 @@ router.put('/config', async (req, res) => {
|
|
|
131
131
|
const fp = confPath(bc);
|
|
132
132
|
const { listeners, managed, passthrough, checksum: clientChecksum } = req.body;
|
|
133
133
|
const content = mosquittoConf.serialise({ listeners, managed, passthrough });
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
134
|
+
if (bc.ssh && bc.ssh.host) {
|
|
135
|
+
_log?.info(`broker: uploading config to remote ${bc.ssh.host}:${fp}`);
|
|
136
|
+
await sshDeploy.uploadContent(bc.ssh, content, fp);
|
|
137
|
+
return res.json({ ok: true, backupPath: null });
|
|
138
|
+
}
|
|
139
|
+
_log?.info(`broker: writing config to local ${fp}`);
|
|
140
|
+
const result = mosquittoConf.write(fp, content, clientChecksum ?? null);
|
|
138
141
|
if (!result.ok) {
|
|
139
142
|
return res.status(409).json({ error: 'external_modify', message: 'mosquitto.conf was modified externally since last read' });
|
|
140
143
|
}
|
|
141
|
-
if (remote) {
|
|
142
|
-
_log?.debug(`broker: uploading config to ${bc.ssh.host}:${fp}`);
|
|
143
|
-
await sshDeploy.uploadContent(bc.ssh, content, fp);
|
|
144
|
-
}
|
|
145
144
|
_lastWriteChecksum.set(fp, mosquittoConf.checksum(fp));
|
|
146
145
|
res.json({ ok: true, backupPath: result.backupPath ? path.basename(result.backupPath) : null });
|
|
147
146
|
} catch (err) {
|
|
@@ -152,7 +151,7 @@ router.put('/config', async (req, res) => {
|
|
|
152
151
|
/**
|
|
153
152
|
* PUT /she/broker/config/raw
|
|
154
153
|
* Write raw mosquitto.conf text directly (used by the Advanced editor).
|
|
155
|
-
* In remote mode,
|
|
154
|
+
* In remote mode, uploads directly to the broker host via SCP — no local fs access.
|
|
156
155
|
*/
|
|
157
156
|
router.put('/config/raw', async (req, res) => {
|
|
158
157
|
try {
|
|
@@ -162,17 +161,16 @@ router.put('/config/raw', async (req, res) => {
|
|
|
162
161
|
if (typeof content !== 'string') {
|
|
163
162
|
return res.status(400).json({ error: 'content must be a string' });
|
|
164
163
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
if (bc.ssh && bc.ssh.host) {
|
|
165
|
+
_log?.info(`broker: uploading raw config to remote ${bc.ssh.host}:${fp}`);
|
|
166
|
+
await sshDeploy.uploadContent(bc.ssh, content, fp);
|
|
167
|
+
return res.json({ ok: true, backupPath: null });
|
|
168
|
+
}
|
|
169
|
+
_log?.info(`broker: writing raw config to local ${fp}`);
|
|
170
|
+
const result = mosquittoConf.write(fp, content, clientChecksum ?? null);
|
|
169
171
|
if (!result.ok) {
|
|
170
172
|
return res.status(409).json({ error: 'external_modify', message: 'mosquitto.conf was modified externally since last read' });
|
|
171
173
|
}
|
|
172
|
-
if (remote) {
|
|
173
|
-
_log?.debug(`broker: uploading raw config to ${bc.ssh.host}:${fp}`);
|
|
174
|
-
await sshDeploy.uploadContent(bc.ssh, content, fp);
|
|
175
|
-
}
|
|
176
174
|
_lastWriteChecksum.set(fp, mosquittoConf.checksum(fp));
|
|
177
175
|
res.json({ ok: true, backupPath: result.backupPath ? path.basename(result.backupPath) : null });
|
|
178
176
|
} catch (err) {
|