smart-home-engine 1.1.13 → 1.1.15
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-DZuKCHly.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-DZuKCHly.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-Cek-ldk8.css">
|
package/package.json
CHANGED
package/src/lib/dynsec.js
CHANGED
|
@@ -183,6 +183,31 @@ function getStatus() {
|
|
|
183
183
|
return { connected: _connected, configured: _configured, dynsecReady: _dynsecReady };
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
+
/**
|
|
187
|
+
* Permanently stop the dynsec client (called when dynsec is deactivated).
|
|
188
|
+
* Ends the MQTT connection without reconnect, rejects all pending requests,
|
|
189
|
+
* and marks the client as unconfigured so it will not try to reconnect.
|
|
190
|
+
*/
|
|
191
|
+
function stop() {
|
|
192
|
+
_configured = false;
|
|
193
|
+
_connected = false;
|
|
194
|
+
_dynsecReady = false;
|
|
195
|
+
// Reject any in-flight / queued requests
|
|
196
|
+
if (_inflight && _inflightResolve) {
|
|
197
|
+
_inflightResolve = null;
|
|
198
|
+
_inflight = false;
|
|
199
|
+
}
|
|
200
|
+
while (_queue.length > 0) {
|
|
201
|
+
const { reject } = _queue.shift();
|
|
202
|
+
reject(new Error('dynsec stopped'));
|
|
203
|
+
}
|
|
204
|
+
if (_client) {
|
|
205
|
+
_client.end(true); // force=true — skip DISCONNECT, prevent auto-reconnect
|
|
206
|
+
_client = null;
|
|
207
|
+
}
|
|
208
|
+
if (_log) _log.info('dynsec: stopped');
|
|
209
|
+
}
|
|
210
|
+
|
|
186
211
|
// ── User management ────────────────────────────────────────────────────────────
|
|
187
212
|
|
|
188
213
|
function createClient(username, password, options = {}) {
|
|
@@ -297,6 +322,7 @@ function setDefaultACLAccess(acls) {
|
|
|
297
322
|
module.exports = {
|
|
298
323
|
init,
|
|
299
324
|
getStatus,
|
|
325
|
+
stop,
|
|
300
326
|
// Users
|
|
301
327
|
createClient,
|
|
302
328
|
deleteClient,
|
package/src/web/broker-api.js
CHANGED
|
@@ -901,9 +901,10 @@ router.post('/wizard/bootstrap', async (req, res) => {
|
|
|
901
901
|
|
|
902
902
|
/**
|
|
903
903
|
* POST /she/broker/wizard/deactivate
|
|
904
|
-
* Remove dynsec plugin lines from mosquitto.conf (remote or local)
|
|
905
|
-
*
|
|
906
|
-
* config.json
|
|
904
|
+
* Remove dynsec plugin lines from mosquitto.conf (remote or local),
|
|
905
|
+
* stop the dynsec MQTT client immediately, and clear broker.dynsec credentials
|
|
906
|
+
* from config.json so she does not try to reconnect on next restart.
|
|
907
|
+
* Caller must still restart mosquitto to fully remove the plugin.
|
|
907
908
|
*/
|
|
908
909
|
router.post('/wizard/deactivate', async (req, res) => {
|
|
909
910
|
try {
|
|
@@ -923,6 +924,56 @@ router.post('/wizard/deactivate', async (req, res) => {
|
|
|
923
924
|
const content = mosquittoConf.serialise(parsed);
|
|
924
925
|
mosquittoConf.write(fp, content);
|
|
925
926
|
}
|
|
927
|
+
|
|
928
|
+
// Stop the dynsec client immediately — prevents log flooding from
|
|
929
|
+
// repeated reconnect attempts against a broker that no longer has
|
|
930
|
+
// the dynamic-security plugin loaded.
|
|
931
|
+
dynsec.stop();
|
|
932
|
+
|
|
933
|
+
// Clear broker.dynsec credentials from config.json so the dynsec
|
|
934
|
+
// client is not re-initialised if she is restarted.
|
|
935
|
+
const configPath = req.app.locals.configPath;
|
|
936
|
+
if (configPath) {
|
|
937
|
+
try {
|
|
938
|
+
const cfg = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
939
|
+
if (cfg.broker && cfg.broker.dynsec) {
|
|
940
|
+
delete cfg.broker.dynsec;
|
|
941
|
+
fs.writeFileSync(configPath, JSON.stringify(cfg, null, 4) + '\n', 'utf8');
|
|
942
|
+
_log?.info('broker: cleared broker.dynsec credentials from config.json');
|
|
943
|
+
}
|
|
944
|
+
} catch (e) {
|
|
945
|
+
_log?.warn(`broker: failed to clear dynsec credentials from config.json: ${e.message}`);
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
res.json({ ok: true });
|
|
950
|
+
} catch (err) {
|
|
951
|
+
handleError(res, err);
|
|
952
|
+
}
|
|
953
|
+
});
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* POST /she/broker/wizard/reinit
|
|
957
|
+
* Re-initialise the dynsec MQTT client with the credentials that were just
|
|
958
|
+
* saved to config.json by the wizard. Called immediately after saving
|
|
959
|
+
* credentials so the daemon picks them up without requiring a full she restart.
|
|
960
|
+
*
|
|
961
|
+
* Uses the startup config (URL, TLS, etc.) merged with the fresh broker
|
|
962
|
+
* section from config.json.
|
|
963
|
+
*/
|
|
964
|
+
router.post('/wizard/reinit', (req, res) => {
|
|
965
|
+
try {
|
|
966
|
+
const configPath = req.app.locals.configPath;
|
|
967
|
+
if (!configPath) return res.status(500).json({ error: 'no configPath in app.locals' });
|
|
968
|
+
const freshCfg = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
969
|
+
if (!freshCfg.broker?.dynsec?.adminUsername || !freshCfg.broker?.dynsec?.adminPassword) {
|
|
970
|
+
return res.status(400).json({ error: 'broker.dynsec credentials not set in config.json' });
|
|
971
|
+
}
|
|
972
|
+
// Merge startup config (URL, TLS, etc.) with fresh broker section from config.json
|
|
973
|
+
const reInitConfig = { ...sheConfig, broker: freshCfg.broker };
|
|
974
|
+
dynsec.stop(); // clean up any existing client first
|
|
975
|
+
dynsec.init(reInitConfig, _log);
|
|
976
|
+
_log?.info('broker: dynsec client re-initialised with updated credentials');
|
|
926
977
|
res.json({ ok: true });
|
|
927
978
|
} catch (err) {
|
|
928
979
|
handleError(res, err);
|