smart-home-engine 1.1.13 → 1.1.14

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-CLoKW1Ib.js";/*!-----------------------------------------------------------------------------
1
+ import{m as O}from"./monaco-langs-BW2J83t5.js";import{t as I}from"./index-CMM70Gp4.js";/*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
4
4
  * Released under the MIT license
@@ -172,7 +172,7 @@
172
172
  }
173
173
  })();
174
174
  </script>
175
- <script type="module" crossorigin src="/assets/index-CLoKW1Ib.js"></script>
175
+ <script type="module" crossorigin src="/assets/index-CMM70Gp4.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smart-home-engine",
3
- "version": "1.1.13",
3
+ "version": "1.1.14",
4
4
  "description": "Node.js based script runner for use in MQTT based Smart Home environments",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
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,
@@ -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
- * The caller is responsible for also clearing broker.dynsec credentials from
906
- * config.json and restarting mosquitto afterwards.
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,28 @@ 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
+
926
949
  res.json({ ok: true });
927
950
  } catch (err) {
928
951
  handleError(res, err);