iobroker.eos-admin 9.0.33 → 9.0.35
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/NEXOWATT_EOS_BUILD_INFO.json +13 -11
- package/README.md +12 -8
- package/adminWww/.vite/manifest.json +233 -224
- package/adminWww/NEXOWATT_EOS_FRONTEND_MANIFEST.json +13897 -13887
- package/adminWww/assets/AccessTime-CuR73YC3.js +1 -0
- package/adminWww/assets/{AdapterUpdateDialog-DBUqmmyD.js → AdapterUpdateDialog-DH6S-kWX.js} +5 -5
- package/adminWww/assets/{Adapters-dDEp7o5h.js → Adapters-CIlqSF5B.js} +5 -5
- package/adminWww/assets/ConfigManager-BhVBfM-q.js +1 -0
- package/adminWww/assets/Enums-3H97czGs.js +92 -0
- package/adminWww/assets/Fields-vWLKiuvO.js +1 -0
- package/adminWww/assets/Files-wmjjMXYM.js +1 -0
- package/adminWww/assets/{Hosts-CwU1LujG.js → Hosts-Bk-xmI98.js} +6 -6
- package/adminWww/assets/Instances-Db6Vgh62.js +4 -0
- package/adminWww/assets/Intro-Dc3wAG9V.js +2 -0
- package/adminWww/assets/KeyboardArrowRight-ifvmV1ZL.js +1 -0
- package/adminWww/assets/{Logs-B5SpNqHq.js → Logs-CPbEGWNq.js} +2 -2
- package/adminWww/assets/MoreHoriz-CS7nODK8.js +1 -0
- package/adminWww/assets/{Objects-COg_cFkz.js → Objects-DJB-2468.js} +4 -4
- package/adminWww/assets/Overview-DdvghCLQ.js +3 -0
- package/adminWww/assets/Pageview-wzrLQZ-j.js +1 -0
- package/adminWww/assets/PersonOff-YtHcY0sV.js +1 -0
- package/adminWww/assets/Star-D8VNXawT.js +1 -0
- package/adminWww/assets/State-0UzpgKYj.js +1 -0
- package/adminWww/assets/UsedResources-Bcmo58YD.js +2 -0
- package/adminWww/assets/Users-BGHf3Rox.js +1 -0
- package/adminWww/assets/ViewCompact-D7bHgn99.js +1 -0
- package/adminWww/assets/ViewSidebar-CjClbCI5.js +1 -0
- package/adminWww/assets/WifiTethering-DJ9VO12W.js +1 -0
- package/adminWww/assets/{bootstrap-Dwfxhm2V.js → bootstrap-qkrk_CAn.js} +25 -25
- package/adminWww/assets/date-fns-BtR4dG_j.js +1 -0
- package/adminWww/assets/en-US-BjjaEI6N.js +1 -0
- package/adminWww/assets/{hostInit-3BbTwhaZ.js → hostInit-DlGqatlv.js} +1 -1
- package/adminWww/assets/icons-material-CUNq6tdT.js +1 -0
- package/adminWww/assets/{index-nddph2Sl.js → index-BrtKq3UN.js} +2 -2
- package/adminWww/assets/{installSVGRenderer-CPDIwFAL.js → installSVGRenderer-DujLjpXt.js} +1 -1
- package/adminWww/assets/isSameWeek-WMSJR5Qs.js +1 -0
- package/adminWww/assets/locale-DN6Bdkdt.js +1 -0
- package/adminWww/assets/{mf-entry-bootstrap-0-d1f0f40f.js → mf-entry-bootstrap-0-3e1cd85c.js} +2 -2
- package/adminWww/assets/sentry-CPzCHrwe.js +1 -0
- package/adminWww/assets/setYear-DDSuW45e.js +1 -0
- package/adminWww/index.html +23 -23
- package/adminWww/mf-manifest.json +1 -1
- package/adminWww/mf-stats.json +1 -1
- package/adminWww/{remoteEntry-eos-9.0.33.js → remoteEntry-eos-9.0.35.js} +1 -1
- package/adminWww/remoteEntry.js +1 -1
- package/build/lib/eosDashboardProcessStatus.js +191 -0
- package/build/lib/eosDashboardProcessStatus.js.map +1 -0
- package/build/lib/eosDeviceEmsPlan.js +285 -9
- package/build/lib/eosDeviceEmsPlan.js.map +1 -1
- package/build/lib/eosDeviceEmsService.js +29 -2
- package/build/lib/eosDeviceEmsService.js.map +1 -1
- package/build/lib/eosKiosk.js +1 -0
- package/build/lib/eosKiosk.js.map +1 -1
- package/build/lib/eosModuleHost.js +17 -6
- package/build/lib/eosModuleHost.js.map +1 -1
- package/build/lib/eosModuleHttp.js +18 -3
- package/build/lib/eosModuleHttp.js.map +1 -1
- package/build/lib/eosModuleProcess.js +17 -0
- package/build/lib/eosModuleProcess.js.map +1 -1
- package/build/lib/eosModuleProcessWorker.js +22 -1
- package/build/lib/eosModuleProcessWorker.js.map +1 -1
- package/build/lib/eosRuntimeControl.js +6 -0
- package/build/lib/eosRuntimeControl.js.map +1 -1
- package/build/lib/eosRuntimeHealth.js +50 -1
- package/build/lib/eosRuntimeHealth.js.map +1 -1
- package/build/lib/eosSupervisorNotifications.js +169 -0
- package/build/lib/eosSupervisorNotifications.js.map +1 -0
- package/build/lib/eosUiProcess.js +1 -0
- package/build/lib/eosUiProcess.js.map +1 -1
- package/build/lib/web.js +5 -0
- package/build/lib/web.js.map +1 -1
- package/docs/README.md +3 -2
- package/docs/reports/unified-9.0.34/PRUEFBERICHT.md +40 -0
- package/docs/reports/unified-9.0.34/PRUEFERGEBNISSE.json +112 -0
- package/docs/reports/unified-9.0.34/raw/INDEX.json +137 -0
- package/docs/reports/unified-9.0.34/raw/backend.log +5 -0
- package/docs/reports/unified-9.0.34/raw/dashboard-interval.json +108 -0
- package/docs/reports/unified-9.0.34/raw/fixtures-verification.log +44 -0
- package/docs/reports/unified-9.0.34/raw/frontend.log +152 -0
- package/docs/reports/unified-9.0.34/raw/installer.log +26 -0
- package/docs/reports/unified-9.0.34/raw/lint.log +45 -0
- package/docs/reports/unified-9.0.34/raw/mira-dashboard-browser.json +1 -0
- package/docs/reports/unified-9.0.34/raw/mira-devices-browser.log +9 -0
- package/docs/reports/unified-9.0.34/raw/mira-memory-process.json +379 -0
- package/docs/reports/unified-9.0.34/raw/modules.log +5 -0
- package/docs/reports/unified-9.0.34/raw/node22-mira.log +216 -0
- package/docs/reports/unified-9.0.34/raw/node22-protocol-to-ems.log +8 -0
- package/docs/reports/unified-9.0.34/raw/node22-tests-final.log +17850 -0
- package/docs/reports/unified-9.0.34/raw/node22-version.log +1 -0
- package/docs/reports/unified-9.0.34/raw/node24-mira.log +40 -0
- package/docs/reports/unified-9.0.34/raw/node24-protocol-to-ems.log +6 -0
- package/docs/reports/unified-9.0.34/raw/node24-tests-final.log +2973 -0
- package/docs/reports/unified-9.0.34/raw/node24-version.log +1 -0
- package/docs/reports/unified-9.0.34/raw/protocol-to-ems.cjs +364 -0
- package/docs/reports/unified-9.0.34/raw/release-metadata.log +13 -0
- package/docs/reports/unified-9.0.34/raw/sbom.log +8 -0
- package/docs/reports/unified-9.0.34/raw/typecheck.log +5 -0
- package/docs/reports/unified-9.0.34/raw/ui-runtime.log +8 -0
- package/docs/reports/unified-9.0.35/PRUEFBERICHT.md +51 -0
- package/docs/reports/unified-9.0.35/PRUEFERGEBNISSE.json +112 -0
- package/docs/reports/unified-9.0.35/raw/INDEX.json +282 -0
- package/docs/reports/unified-9.0.35/raw/backend.log +5 -0
- package/docs/reports/unified-9.0.35/raw/browser-lp-detail.log +1 -0
- package/docs/reports/unified-9.0.35/raw/browser-lp-feedback.log +1 -0
- package/docs/reports/unified-9.0.35/raw/cold-ocpp-22.log +108 -0
- package/docs/reports/unified-9.0.35/raw/cold-ocpp-24.log +24 -0
- package/docs/reports/unified-9.0.35/raw/core-final-node22.log +1439 -0
- package/docs/reports/unified-9.0.35/raw/core-final-node24.log +1381 -0
- package/docs/reports/unified-9.0.35/raw/dashboard-de-en-nl.json +716 -0
- package/docs/reports/unified-9.0.35/raw/device-chain-closed-fixed.json +98 -0
- package/docs/reports/unified-9.0.35/raw/device-chain-rst-fixed.json +98 -0
- package/docs/reports/unified-9.0.35/raw/device-chain.json +93 -0
- package/docs/reports/unified-9.0.35/raw/ee-fusion-final.log +12 -0
- package/docs/reports/unified-9.0.35/raw/eebus-monitor-browser.json +1 -0
- package/docs/reports/unified-9.0.35/raw/eebus-monitor-node22.log +206 -0
- package/docs/reports/unified-9.0.35/raw/eebus-monitor-node24.log +39 -0
- package/docs/reports/unified-9.0.35/raw/fixtures-verification.log +44 -0
- package/docs/reports/unified-9.0.35/raw/frontend.log +152 -0
- package/docs/reports/unified-9.0.35/raw/installer.log +26 -0
- package/docs/reports/unified-9.0.35/raw/legacy-mail-setup-browser.log +1 -0
- package/docs/reports/unified-9.0.35/raw/lint.log +45 -0
- package/docs/reports/unified-9.0.35/raw/live-ems-loss.log +10 -0
- package/docs/reports/unified-9.0.35/raw/modules.log +5 -0
- package/docs/reports/unified-9.0.35/raw/node22-mira-reconnect-integrity.log +452 -0
- package/docs/reports/unified-9.0.35/raw/node22-mira.log +222 -0
- package/docs/reports/unified-9.0.35/raw/node22-system-status.log +213 -0
- package/docs/reports/unified-9.0.35/raw/node22-tests-final.log +18137 -0
- package/docs/reports/unified-9.0.35/raw/node22-version.log +1 -0
- package/docs/reports/unified-9.0.35/raw/node24-mira-reconnect-integrity.log +79 -0
- package/docs/reports/unified-9.0.35/raw/node24-mira.log +41 -0
- package/docs/reports/unified-9.0.35/raw/node24-system-status.log +40 -0
- package/docs/reports/unified-9.0.35/raw/node24-tests-final.log +3019 -0
- package/docs/reports/unified-9.0.35/raw/node24-version.log +1 -0
- package/docs/reports/unified-9.0.35/raw/notifications-legacy-node22.log +1 -0
- package/docs/reports/unified-9.0.35/raw/notifications-legacy-node24.log +1 -0
- package/docs/reports/unified-9.0.35/raw/notifications-node22.log +67 -0
- package/docs/reports/unified-9.0.35/raw/notifications-node24.log +17 -0
- package/docs/reports/unified-9.0.35/raw/npm-runtime-audit.json +77 -0
- package/docs/reports/unified-9.0.35/raw/ocpp-dashboard-stations-node22.log +110 -0
- package/docs/reports/unified-9.0.35/raw/ocpp-dashboard-stations-node24.log +106 -0
- package/docs/reports/unified-9.0.35/raw/ocpp-history-node22.log +561 -0
- package/docs/reports/unified-9.0.35/raw/ocpp-history-node24.log +98 -0
- package/docs/reports/unified-9.0.35/raw/poll-life-node22.log +38 -0
- package/docs/reports/unified-9.0.35/raw/poll-life-node24.log +12 -0
- package/docs/reports/unified-9.0.35/raw/qa-source-check.log +2 -0
- package/docs/reports/unified-9.0.35/raw/release-metadata.log +13 -0
- package/docs/reports/unified-9.0.35/raw/sbom.log +8 -0
- package/docs/reports/unified-9.0.35/raw/typecheck.log +5 -0
- package/docs/reports/unified-9.0.35/raw/ui-runtime.log +8 -0
- package/docs/reports/unified-9.0.35/raw/vergleich-9.0.33.json +29 -0
- package/docs/reports/unified-9.0.35/raw/vergleich-9.0.34.json +249 -0
- package/docs/reports/unified-9.0.35/raw/vorher-9.0.33-chromium.json +286 -0
- package/docs/reports/unified-9.0.35/raw/vorher-9.0.34-chromium.json +291 -0
- package/docs/start/START_HIER_9.0.34.md +25 -0
- package/docs/start/START_HIER_9.0.35.md +27 -0
- package/io-package.json +12 -12
- package/modules/devices/admin/alias-contract-v1.json +22 -0
- package/modules/devices/admin/ems-assignment.js +6 -1
- package/modules/devices/admin/host-bridge.js +2 -0
- package/modules/devices/admin/index.html +16 -0
- package/modules/devices/admin/index_m.js +168 -9
- package/modules/devices/admin/templates.json +976 -0
- package/modules/devices/checks/emsAssignment.check.js +52 -2
- package/modules/devices/contracts.d.ts +1 -0
- package/modules/devices/index.js +25 -2
- package/modules/devices/lib/alias-contract-v1.json +22 -0
- package/modules/devices/lib/deviceRuntime.js +36 -7
- package/modules/devices/lib/drivers/modbus.js +12 -7
- package/modules/devices/lib/drivers/modbusRtuBus.js +7 -1
- package/modules/devices/lib/drivers/ovumMira.js +152 -0
- package/modules/devices/lib/ovumMiraAliases.js +61 -0
- package/modules/devices/lib/ovumMiraConnection.js +32 -0
- package/modules/devices/lib/templates.json +976 -0
- package/modules/devices/test/aliasContractV1.test.js +4 -4
- package/modules/devices/test/deviceAliasSemantics.test.js +2 -2
- package/modules/devices/test/fixtures/approved-additive-templates.json +3 -1
- package/modules/devices/test/ovumMiraPairing.test.js +76 -0
- package/modules/devices/test/ovumMiraTemplates.test.js +110 -0
- package/modules/devices/test/ovumMiraTransport.test.js +201 -0
- package/modules/eebus/README.md +8 -0
- package/modules/eebus/admin/index.js +29 -2
- package/modules/eebus/build/index.js +28 -3
- package/modules/eebus/build/lib/eebusRuntime.js +17 -2
- package/modules/eebus/build/lib/partnerMonitor.js +160 -0
- package/modules/eebus/build/lib/shipEndpoint.js +4 -0
- package/modules/eebus/build/lib/stateDefinitions.js +1 -0
- package/modules/eebus/src/index.ts +23 -3
- package/modules/eebus/src/lib/eebusRuntime.ts +20 -2
- package/modules/eebus/src/lib/partnerMonitor.ts +127 -0
- package/modules/eebus/src/lib/shipEndpoint.ts +5 -0
- package/modules/eebus/src/lib/stateDefinitions.ts +1 -0
- package/modules/eebus/test/partner-monitor.test.js +82 -0
- package/modules/eebus/test/security.test.js +17 -0
- package/modules/ocpp/README.md +9 -1
- package/modules/ocpp/build/index.js +137 -10
- package/modules/ocpp/build/stationHistory.js +113 -0
- package/modules/ocpp/ocpp/freshness.d.ts +3 -0
- package/modules/ocpp/ocpp/freshness.js +6 -0
- package/modules/ocpp/provenance.json +3 -2
- package/modules/ocpp/runtime.d.ts +1 -0
- package/modules/ocpp/runtime.js +23 -1
- package/modules/ocpp/src/index.ts +163 -12
- package/modules/ocpp/src/stationHistory.ts +119 -0
- package/modules/ocpp/test/hosted.test.cjs +161 -0
- package/package.json +9 -5
- package/release-manifests/unified/build-environment.cdx.json +6 -6
- package/release-manifests/unified/files.json +313 -190
- package/release-manifests/unified/frontend.cdx.json +6 -6
- package/release-manifests/unified/installer.cdx.json +6 -6
- package/release-manifests/unified/obsolete-admin-assets.json +166 -0
- package/release-manifests/unified/runtime.cdx.json +30 -30
- package/release-manifests/unified/validation.json +15 -15
- package/tools/eos-release-manifest.cjs +1 -1
- package/ui/ems/consumers/ovum-mira.js +164 -0
- package/ui/ems/modules/para14a.js +3 -2
- package/ui/ems/modules/stage-a-diagnostics.js +4 -2
- package/ui/ems/modules/thermal-control.js +91 -10
- package/ui/io-package.json +9 -1
- package/ui/lib/installer-lifecycle.js +11 -2
- package/ui/lib/notification-mail.js +235 -40
- package/ui/lib/notification-policy.js +41 -14
- package/ui/main.js +37 -7
- package/ui/package.json +2 -1
- package/ui/www/app.js +122 -24
- package/ui/www/dashboard-lp-status.js +4 -11
- package/ui/www/dashboard-process-status.js +202 -0
- package/ui/www/ems-apps.js +28 -9
- package/ui/www/i18n/en.json +23 -0
- package/ui/www/i18n/nl.json +20 -0
- package/ui/www/index.html +10 -5
- package/ui/www/licenses/smarthome-markdown-components.json +156 -156
- package/ui/www/live-display.js +101 -9
- package/ui/www/manifest.webmanifest +2 -2
- package/ui/www/settings.html +2 -2
- package/ui/www/styles.css +4 -0
- package/adminWww/assets/AddLink-0L0E-LsA.js +0 -1
- package/adminWww/assets/ColorLens-DA51K29x.js +0 -1
- package/adminWww/assets/ConfigManager-DbqTWi2N.js +0 -1
- package/adminWww/assets/Enums-DjldGElU.js +0 -92
- package/adminWww/assets/Fields-0GsPCJeU.js +0 -1
- package/adminWww/assets/FileCopy-B16lEuur.js +0 -1
- package/adminWww/assets/Files-COnUtEbg.js +0 -1
- package/adminWww/assets/Instances-CUX5mxMQ.js +0 -4
- package/adminWww/assets/Intro-BhQmHn3A.js +0 -2
- package/adminWww/assets/Lens-9lkeoWGk.js +0 -1
- package/adminWww/assets/LinearScale-Be5h2beh.js +0 -1
- package/adminWww/assets/North-C2whbHM-.js +0 -1
- package/adminWww/assets/Overview-CitzUjBF.js +0 -3
- package/adminWww/assets/PersonOff-DqBq0Fho.js +0 -1
- package/adminWww/assets/PlaylistAdd-O8k92YBd.js +0 -1
- package/adminWww/assets/State-D5ljzf-T.js +0 -1
- package/adminWww/assets/UsedResources-BY_NF2wB.js +0 -2
- package/adminWww/assets/Users-Cu93_-VF.js +0 -1
- package/adminWww/assets/date-fns-C1dqkno9.js +0 -1
- package/adminWww/assets/icons-material-DjqX0l_7.js +0 -1
- package/adminWww/assets/isSameWeek-Crh37s7U.js +0 -1
- package/adminWww/assets/isWithinInterval-Bo1WiDfq.js +0 -1
- package/adminWww/assets/locale-hLcz_Xh2.js +0 -1
- package/adminWww/assets/sentry-DwQQLI7N.js +0 -1
- package/adminWww/assets/startOfWeek-DJph8SIW.js +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EebusRuntime = void 0;
|
|
4
|
+
const partnerMonitor_1 = require("./partnerMonitor");
|
|
4
5
|
const discoveryService_1 = require("./discoveryService");
|
|
5
6
|
const shipEndpoint_1 = require("./shipEndpoint");
|
|
6
7
|
const spineParser_1 = require("./spineParser");
|
|
@@ -14,6 +15,7 @@ class EebusRuntime {
|
|
|
14
15
|
config;
|
|
15
16
|
identity;
|
|
16
17
|
objectFactory;
|
|
18
|
+
partnerMonitor;
|
|
17
19
|
nodes = new Map();
|
|
18
20
|
discovery;
|
|
19
21
|
endpoint;
|
|
@@ -34,9 +36,11 @@ class EebusRuntime {
|
|
|
34
36
|
this.identity = identity;
|
|
35
37
|
this.objectFactory = objectFactory;
|
|
36
38
|
this.autoAcceptNewDevices = config.autoAcceptNewDevices;
|
|
39
|
+
this.partnerMonitor = new partnerMonitor_1.PartnerMonitor(adapter, id => this.canMonitorPartner(id));
|
|
37
40
|
}
|
|
38
41
|
async start() {
|
|
39
42
|
this.stopping = false;
|
|
43
|
+
await this.partnerMonitor.load();
|
|
40
44
|
this.endpoint = new shipEndpoint_1.ShipEndpoint(this.adapter, { ...this.config, autoAcceptNewDevices: this.autoAcceptNewDevices }, this.identity, async (deviceId, message) => this.handleIncomingMessage(deviceId, message), async (node) => this.handleDiscoveredNode(node), async (deviceId, state, role, connected, error) => this.handleConnectionState(deviceId, state, role, connected, error), async (deviceId) => this.handleDataExchangeReady(deviceId), async (deviceId, request) => this.handlePairingRequest(deviceId, request), async (deviceId) => this.isTrusted(deviceId));
|
|
41
45
|
const endpointStarted = await this.endpoint.start();
|
|
42
46
|
if (this.config.shipServerEnabled && !endpointStarted)
|
|
@@ -108,11 +112,14 @@ class EebusRuntime {
|
|
|
108
112
|
async handleStateChange(id, state) {
|
|
109
113
|
if (id.endsWith('.pairing.trusted') || id.endsWith('.pairing.pinnedFingerprint')) {
|
|
110
114
|
const match = id.match(/devices\.([^.]+)\.pairing\./);
|
|
111
|
-
if (match && id.endsWith('.pinnedFingerprint'))
|
|
115
|
+
if (match && id.endsWith('.pinnedFingerprint')) {
|
|
112
116
|
this.endpoint?.invalidateCertificate(match[1], state?.val);
|
|
117
|
+
await this.partnerMonitor.pinChanged(match[1], state?.val);
|
|
118
|
+
}
|
|
113
119
|
if (match && (!state || (id.endsWith('.trusted') && state.val !== true))) {
|
|
114
120
|
this.trustCache.delete(match[1]);
|
|
115
121
|
this.endpoint?.disconnect(match[1]);
|
|
122
|
+
await this.partnerMonitor.pause(match[1]);
|
|
116
123
|
}
|
|
117
124
|
}
|
|
118
125
|
if (!state || state.ack || this.stopping || this.adapter.canOperate?.() === false)
|
|
@@ -134,8 +141,11 @@ class EebusRuntime {
|
|
|
134
141
|
return;
|
|
135
142
|
}
|
|
136
143
|
if (command.channel === 'control' && command.stateName === 'disconnect') {
|
|
137
|
-
if (Boolean(command.value))
|
|
144
|
+
if (Boolean(command.value)) {
|
|
145
|
+
const paused = this.partnerMonitor.pause(command.deviceId);
|
|
138
146
|
this.endpoint?.disconnect(command.deviceId);
|
|
147
|
+
await paused;
|
|
148
|
+
}
|
|
139
149
|
await this.adapter.setStateAsync(`devices.${command.deviceId}.control.disconnect`, { val: false, ack: true });
|
|
140
150
|
return;
|
|
141
151
|
}
|
|
@@ -166,6 +176,7 @@ class EebusRuntime {
|
|
|
166
176
|
}
|
|
167
177
|
else {
|
|
168
178
|
this.endpoint?.rejectDevice(command.deviceId);
|
|
179
|
+
await this.partnerMonitor.pause(command.deviceId);
|
|
169
180
|
}
|
|
170
181
|
await this.adapter.setStateAsync(`devices.${command.deviceId}.pairing.approve`, { val: false, ack: true });
|
|
171
182
|
await this.adapter.setStateAsync(`devices.${command.deviceId}.pairing.reject`, { val: false, ack: true });
|
|
@@ -238,6 +249,7 @@ class EebusRuntime {
|
|
|
238
249
|
await this.objectFactory.publishGlobalPairingCounts(Array.from(this.nodes.keys()));
|
|
239
250
|
}
|
|
240
251
|
async handleDataExchangeReady(deviceId) {
|
|
252
|
+
this.partnerMonitor.observed(deviceId);
|
|
241
253
|
// Prime the trust decision before the first time-critical CLS write arrives.
|
|
242
254
|
// The control path can then use the in-memory cache without an object DB read.
|
|
243
255
|
if (!this.trustCache.has(deviceId)) {
|
|
@@ -840,6 +852,9 @@ class EebusRuntime {
|
|
|
840
852
|
},
|
|
841
853
|
};
|
|
842
854
|
}
|
|
855
|
+
canMonitorPartner(id) {
|
|
856
|
+
return !this.stopping && this.adapter.canOperate?.() !== false && this.endpoint?.hasAuthorizedExchange(id) === true;
|
|
857
|
+
}
|
|
843
858
|
getNodes() { return Array.from(this.nodes.values()).map(node => ({ ...node })); }
|
|
844
859
|
periodic(key, work) {
|
|
845
860
|
if (this.stopping || this.busy.has(key))
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PartnerMonitor = void 0;
|
|
4
|
+
exports.emptyReport = emptyReport;
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
6
|
+
const objectId = 'pairing.monitoredPartners';
|
|
7
|
+
const startupGraceMs = 120_000;
|
|
8
|
+
const pinValue = (v) => typeof v === 'string' && /^[a-f0-9]{64}$/i.test(v.replace(/:/g, '')) ? v.replace(/:/g, '').toUpperCase() : '';
|
|
9
|
+
function friendlyName(value) {
|
|
10
|
+
return typeof value === 'string' && value === value.trim() && value.length <= 64 &&
|
|
11
|
+
/\p{L}/u.test(value) && /^[\p{L}\p{M}\p{N} _()-]+$/u.test(value) &&
|
|
12
|
+
!/[a-f\d]{16,}|(?:[a-f\d]{2}-){5}[a-f\d]{2}/i.test(value) && !/\d{9,}/.test(value);
|
|
13
|
+
}
|
|
14
|
+
const safeId = (v) => typeof v === 'string' && /^[a-f\d]{40}$/i.test(v);
|
|
15
|
+
const key = (id) => (0, node_crypto_1.createHash)('sha256').update('eebus:' + id.toLowerCase()).digest('hex');
|
|
16
|
+
function emptyReport(known) {
|
|
17
|
+
return { state: known ? 'ok' : 'unknown', offline: [], totalOffline: 0,
|
|
18
|
+
tracked: [], complete: known };
|
|
19
|
+
}
|
|
20
|
+
/** Names are local installer input. Discovery metadata, peer addresses and certificates never feed the customer report. */
|
|
21
|
+
class PartnerMonitor {
|
|
22
|
+
store;
|
|
23
|
+
live;
|
|
24
|
+
now;
|
|
25
|
+
partners = new Map();
|
|
26
|
+
confirmed = new Set();
|
|
27
|
+
suppressed = new Set();
|
|
28
|
+
known = false;
|
|
29
|
+
startedAt = 0;
|
|
30
|
+
pending = Promise.resolve();
|
|
31
|
+
constructor(store, live, now = () => performance.now()) {
|
|
32
|
+
this.store = store;
|
|
33
|
+
this.live = live;
|
|
34
|
+
this.now = now;
|
|
35
|
+
}
|
|
36
|
+
async load() {
|
|
37
|
+
this.startedAt = this.now();
|
|
38
|
+
try {
|
|
39
|
+
const state = await this.store.getStateAsync(objectId);
|
|
40
|
+
if (state?.ack === false)
|
|
41
|
+
throw Error();
|
|
42
|
+
const rows = state?.val == null ? [] : JSON.parse(String(state.val));
|
|
43
|
+
if (!Array.isArray(rows) || rows.length > 128)
|
|
44
|
+
throw Error();
|
|
45
|
+
const restored = new Map();
|
|
46
|
+
for (const item of rows) {
|
|
47
|
+
if (!item || !safeId(item.id) || !friendlyName(item.name) || !pinValue(item.pin) || typeof item.paused !== 'boolean' || restored.has(item.id))
|
|
48
|
+
throw Error();
|
|
49
|
+
const row = { id: item.id.toUpperCase(), key: key(item.id), name: item.name, pin: pinValue(item.pin), paused: item.paused };
|
|
50
|
+
if (restored.has(row.id))
|
|
51
|
+
throw Error();
|
|
52
|
+
restored.set(row.id, row);
|
|
53
|
+
}
|
|
54
|
+
// Verify locally approved pairing on restart even when the peer is currently absent.
|
|
55
|
+
const monitored = Array.from(restored.values()).filter(row => !row.paused);
|
|
56
|
+
let changed = false;
|
|
57
|
+
for (let start = 0; start < monitored.length; start += 8) {
|
|
58
|
+
await Promise.all(monitored.slice(start, start + 8).map(async (row) => {
|
|
59
|
+
if (await this.trustedPin(row.id) !== row.pin) {
|
|
60
|
+
row.paused = true;
|
|
61
|
+
changed = true;
|
|
62
|
+
}
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
if (changed)
|
|
66
|
+
await this.save(restored);
|
|
67
|
+
else
|
|
68
|
+
this.partners = restored;
|
|
69
|
+
this.known = true;
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
this.known = false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
async trustedPin(id) {
|
|
76
|
+
const [trust, pin] = await Promise.all(['trusted', 'pinnedFingerprint'].map(field => this.store.getStateAsync('devices.' + id + '.pairing.' + field)));
|
|
77
|
+
return trust?.val === true && trust.ack !== false && pin?.ack !== false ? pinValue(pin?.val) : '';
|
|
78
|
+
}
|
|
79
|
+
change(write) {
|
|
80
|
+
const op = this.pending.then(write);
|
|
81
|
+
this.pending = op.catch(() => { });
|
|
82
|
+
return op;
|
|
83
|
+
}
|
|
84
|
+
async save(next) {
|
|
85
|
+
await this.store.setStateAsync(objectId, { val: JSON.stringify(Array.from(next.values(), ({ id, name, pin, paused }) => ({ id, name, pin, paused }))), ack: true });
|
|
86
|
+
this.partners = next;
|
|
87
|
+
}
|
|
88
|
+
async configure(id, name, enabled) {
|
|
89
|
+
if (!safeId(id))
|
|
90
|
+
throw new Error('EEBUS_MONITOR_DEVICE');
|
|
91
|
+
id = id.toUpperCase();
|
|
92
|
+
return this.change(async () => {
|
|
93
|
+
if (!this.known)
|
|
94
|
+
throw new Error('EEBUS_MONITOR_STORAGE_UNAVAILABLE');
|
|
95
|
+
const next = new Map(this.partners);
|
|
96
|
+
if (enabled) {
|
|
97
|
+
if (!friendlyName(name))
|
|
98
|
+
throw new Error('EEBUS_MONITOR_LOCAL_NAME');
|
|
99
|
+
const pin = this.live(id) ? await this.trustedPin(id) : '';
|
|
100
|
+
if (!pin || !this.live(id))
|
|
101
|
+
throw new Error('EEBUS_MONITOR_PAIRED_SESSION_REQUIRED');
|
|
102
|
+
if (!next.has(id) && next.size >= 128)
|
|
103
|
+
throw new Error('EEBUS_MONITOR_CAPACITY');
|
|
104
|
+
next.set(id, { id, key: key(id), name, pin, paused: false });
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
next.delete(id);
|
|
108
|
+
}
|
|
109
|
+
await this.save(next);
|
|
110
|
+
if (enabled)
|
|
111
|
+
this.confirmed.add(id);
|
|
112
|
+
else
|
|
113
|
+
this.confirmed.delete(id);
|
|
114
|
+
this.suppressed.delete(id);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
pinChanged(id, value) {
|
|
118
|
+
const row = this.partners.get(id.toUpperCase());
|
|
119
|
+
return row && !row.paused && row.pin !== pinValue(value) ? this.pause(id) : Promise.resolve();
|
|
120
|
+
}
|
|
121
|
+
pause(id) {
|
|
122
|
+
id = id.toUpperCase();
|
|
123
|
+
this.suppressed.add(id);
|
|
124
|
+
return this.change(async () => {
|
|
125
|
+
const row = this.partners.get(id);
|
|
126
|
+
if (row && !row.paused) {
|
|
127
|
+
const next = new Map(this.partners);
|
|
128
|
+
next.set(id, { ...row, paused: true });
|
|
129
|
+
await this.save(next);
|
|
130
|
+
}
|
|
131
|
+
this.suppressed.delete(id);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
observed(id) { if (this.partners.has(id.toUpperCase()) && this.live(id))
|
|
135
|
+
this.confirmed.add(id.toUpperCase()); }
|
|
136
|
+
list() { return Array.from(this.partners.values(), ({ id, name, paused }) => ({ id, name, paused })); }
|
|
137
|
+
report() {
|
|
138
|
+
const report = emptyReport(this.known);
|
|
139
|
+
if (!this.known)
|
|
140
|
+
return report;
|
|
141
|
+
for (const row of this.partners.values()) {
|
|
142
|
+
const active = this.live(row.id);
|
|
143
|
+
const state = row.paused || this.suppressed.has(row.id) ? 'disabled' : active ? 'online' :
|
|
144
|
+
this.confirmed.has(row.id) || this.now() - this.startedAt >= startupGraceMs ? 'offline' : 'unknown';
|
|
145
|
+
if (state === 'online')
|
|
146
|
+
this.confirmed.add(row.id);
|
|
147
|
+
report.tracked.push({ key: row.key, name: row.name, state });
|
|
148
|
+
if (state === 'unknown' && report.state === 'ok')
|
|
149
|
+
report.state = 'unknown';
|
|
150
|
+
if (state === 'offline') {
|
|
151
|
+
report.state = 'fault';
|
|
152
|
+
report.totalOffline++;
|
|
153
|
+
if (report.offline.length < 12)
|
|
154
|
+
report.offline.push({ name: row.name });
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return report;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
exports.PartnerMonitor = PartnerMonitor;
|
|
@@ -211,6 +211,10 @@ class ShipEndpoint {
|
|
|
211
211
|
if (session && fingerprint !== session.remoteFingerprint)
|
|
212
212
|
this.disconnect(deviceId);
|
|
213
213
|
}
|
|
214
|
+
hasAuthorizedExchange(deviceId) {
|
|
215
|
+
const peer = this.sessions.get(deviceId);
|
|
216
|
+
return !!peer?.authorized && peer.dataExchangeReady && this.isSocketOpen(peer.socket) && !this.stopping;
|
|
217
|
+
}
|
|
214
218
|
hasObservedPeer(deviceId) {
|
|
215
219
|
const session = this.sessions.get(deviceId);
|
|
216
220
|
return !!session?.remoteFingerprint && this.isSocketOpen(session.socket);
|
|
@@ -27,6 +27,7 @@ exports.discoveryStates = [
|
|
|
27
27
|
{ id: 'lastDiscovery', name: 'Last discovery event', type: 'string', role: 'json', read: true, write: false },
|
|
28
28
|
];
|
|
29
29
|
exports.globalPairingStates = [
|
|
30
|
+
{ id: 'monitoredPartners', name: 'Installer-configured EEBus partner supervision', type: 'string', role: 'json', read: true, write: false, def: '[]' },
|
|
30
31
|
{
|
|
31
32
|
id: 'autoAcceptNewDevices',
|
|
32
33
|
name: 'Auto accept new devices for field testing',
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { emptyReport } from './lib/partnerMonitor';
|
|
1
2
|
import { EebusConfig, getConfig } from './lib/config';
|
|
2
3
|
import { EebusRuntime } from './lib/eebusRuntime';
|
|
3
4
|
import { IdentityManager } from './lib/identityManager';
|
|
@@ -130,17 +131,30 @@ export function createHostedModule(options: Options) {
|
|
|
130
131
|
},
|
|
131
132
|
async command(name: string, payload: unknown): Promise<{ accepted: boolean }> {
|
|
132
133
|
if (!running || !runtime || stopping || !options.canOperate()) throw new Error('EEBUS_NOT_RUNNING');
|
|
133
|
-
if (!actions
|
|
134
|
+
if ((!Object.hasOwn(actions,name) && name !== 'device.monitor') || !payload || typeof payload !== 'object' || Array.isArray(payload)) throw new Error('EEBUS_COMMAND_INVALID');
|
|
134
135
|
const deviceId = (payload as Record<string, unknown>).deviceId;
|
|
135
|
-
if (typeof deviceId !== 'string' || !/^[A-Fa-f0-9]{40}$/.test(deviceId)
|
|
136
|
+
if (typeof deviceId !== 'string' || !/^[A-Fa-f0-9]{40}$/.test(deviceId)) throw new Error('EEBUS_DEVICE_UNKNOWN');
|
|
137
|
+
const observed = runtime.getNodes().some(node => node.safeId === deviceId);
|
|
138
|
+
if (!observed && !(name === 'device.monitor' && runtime.partnerMonitor.list().some(peer => peer.id === deviceId))) throw new Error('EEBUS_DEVICE_UNKNOWN');
|
|
136
139
|
if (inFlight >= 16) throw new Error('EEBUS_COMMAND_BUSY');
|
|
137
140
|
inFlight++;
|
|
138
141
|
try {
|
|
142
|
+
if (name === 'device.monitor') {
|
|
143
|
+
const data = payload as Record<string,unknown>;
|
|
144
|
+
if (typeof data.enabled !== 'boolean') throw new Error('EEBUS_COMMAND_INVALID');
|
|
145
|
+
await runtime.partnerMonitor.configure(deviceId, data.name, data.enabled);
|
|
146
|
+
return { accepted: options.canOperate() && !stopping };
|
|
147
|
+
}
|
|
139
148
|
await runtime.handleStateChange(`${adapter.namespace}.devices.${deviceId}.${actions[name]}`, { val: true, ack: false, ts: Date.now(), lc: Date.now(), from: adapter.namespace });
|
|
140
149
|
return { accepted: options.canOperate() && !stopping };
|
|
141
150
|
} finally { inFlight--; }
|
|
142
151
|
},
|
|
152
|
+
getDashboardDeviceHealth() {
|
|
153
|
+
if (!running || stopping || !runtime || !options.canOperate()) return emptyReport(selected.enabled === false);
|
|
154
|
+
return runtime.partnerMonitor.report();
|
|
155
|
+
},
|
|
143
156
|
async getStatus() {
|
|
157
|
+
const monitored = new Map((runtime?.partnerMonitor.list() || []).map(p=>[p.id,p]));
|
|
144
158
|
const nodes = runtime?.getNodes() || [];
|
|
145
159
|
const devices = [];
|
|
146
160
|
for (const node of nodes.slice(0, 128)) {
|
|
@@ -149,9 +163,15 @@ export function createHostedModule(options: Options) {
|
|
|
149
163
|
adapter.getStateAsync(`devices.${node.safeId}.connection.shipState`),
|
|
150
164
|
adapter.getStateAsync(`devices.${node.safeId}.pairing.remoteFingerprint`),
|
|
151
165
|
]);
|
|
152
|
-
|
|
166
|
+
const entry=monitored.get(node.safeId); monitored.delete(node.safeId);
|
|
167
|
+
devices.push({ monitorName:entry?.name || '', monitorPaused:entry?.paused === true, canMonitor:runtime?.canMonitorPartner(node.safeId) === true,
|
|
168
|
+
id: node.safeId, name: node.name.slice(0, 128), ski: node.ski, fingerprint: String(fingerprint?.val || ''),
|
|
153
169
|
trusted: trust?.val === true, connected: connection?.val === 'data-exchange', state: String(connection?.val || 'discovered') });
|
|
154
170
|
}
|
|
171
|
+
// A monitored peer can be removed here even before it advertises after a restart.
|
|
172
|
+
for (const entry of monitored.values()) devices.push({ id:entry.id, name:entry.name, ski:entry.id, fingerprint:'',
|
|
173
|
+
trusted:false, connected:false, state:'Nicht verbunden', monitorName:entry.name, monitorPaused:entry.paused, canMonitor:false });
|
|
174
|
+
devices.sort((a,b)=>Number(!!b.monitorName)-Number(!!a.monitorName));
|
|
155
175
|
return { running, localSki: identity?.localSki || '', certificateFingerprint: identity?.certificateFingerprint || '',
|
|
156
176
|
shipPort: config.shipPort, commandDryRun: config.commandDryRun, devices };
|
|
157
177
|
},
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PartnerMonitor } from './partnerMonitor';
|
|
1
2
|
import { EebusConfig } from './config';
|
|
2
3
|
import { DiscoveryService } from './discoveryService';
|
|
3
4
|
import { DeviceClass, DeviceCommand, DiscoveredShipNode, EebusIdentity, ShipConnectionState } from './eebusTypes';
|
|
@@ -30,6 +31,7 @@ interface ClsSourceRuntimeState {
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
export class EebusRuntime {
|
|
34
|
+
public readonly partnerMonitor: PartnerMonitor;
|
|
33
35
|
private readonly nodes = new Map<string, DiscoveredShipNode>();
|
|
34
36
|
private discovery?: DiscoveryService;
|
|
35
37
|
private endpoint?: ShipEndpoint;
|
|
@@ -52,10 +54,12 @@ export class EebusRuntime {
|
|
|
52
54
|
private readonly objectFactory: ObjectFactory,
|
|
53
55
|
) {
|
|
54
56
|
this.autoAcceptNewDevices = config.autoAcceptNewDevices;
|
|
57
|
+
this.partnerMonitor = new PartnerMonitor(adapter, id => this.canMonitorPartner(id));
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
public async start(): Promise<void> {
|
|
58
61
|
this.stopping = false;
|
|
62
|
+
await this.partnerMonitor.load();
|
|
59
63
|
this.endpoint = new ShipEndpoint(
|
|
60
64
|
this.adapter,
|
|
61
65
|
{ ...this.config, autoAcceptNewDevices: this.autoAcceptNewDevices },
|
|
@@ -144,10 +148,14 @@ export class EebusRuntime {
|
|
|
144
148
|
public async handleStateChange(id: string, state: ioBroker.State | null | undefined): Promise<void> {
|
|
145
149
|
if (id.endsWith('.pairing.trusted') || id.endsWith('.pairing.pinnedFingerprint')) {
|
|
146
150
|
const match = id.match(/devices\.([^.]+)\.pairing\./);
|
|
147
|
-
if (match && id.endsWith('.pinnedFingerprint'))
|
|
151
|
+
if (match && id.endsWith('.pinnedFingerprint')) {
|
|
152
|
+
this.endpoint?.invalidateCertificate(match[1], state?.val);
|
|
153
|
+
await this.partnerMonitor.pinChanged(match[1], state?.val);
|
|
154
|
+
}
|
|
148
155
|
if (match && (!state || (id.endsWith('.trusted') && state.val !== true))) {
|
|
149
156
|
this.trustCache.delete(match[1]);
|
|
150
157
|
this.endpoint?.disconnect(match[1]);
|
|
158
|
+
await this.partnerMonitor.pause(match[1]);
|
|
151
159
|
}
|
|
152
160
|
}
|
|
153
161
|
if (!state || state.ack || this.stopping || this.adapter.canOperate?.() === false) return;
|
|
@@ -171,7 +179,11 @@ export class EebusRuntime {
|
|
|
171
179
|
}
|
|
172
180
|
|
|
173
181
|
if (command.channel === 'control' && command.stateName === 'disconnect') {
|
|
174
|
-
if (Boolean(command.value))
|
|
182
|
+
if (Boolean(command.value)) {
|
|
183
|
+
const paused = this.partnerMonitor.pause(command.deviceId);
|
|
184
|
+
this.endpoint?.disconnect(command.deviceId);
|
|
185
|
+
await paused;
|
|
186
|
+
}
|
|
175
187
|
await this.adapter.setStateAsync(`devices.${command.deviceId}.control.disconnect`, { val: false, ack: true });
|
|
176
188
|
return;
|
|
177
189
|
}
|
|
@@ -198,6 +210,7 @@ export class EebusRuntime {
|
|
|
198
210
|
}
|
|
199
211
|
} else {
|
|
200
212
|
this.endpoint?.rejectDevice(command.deviceId);
|
|
213
|
+
await this.partnerMonitor.pause(command.deviceId);
|
|
201
214
|
}
|
|
202
215
|
await this.adapter.setStateAsync(`devices.${command.deviceId}.pairing.approve`, { val: false, ack: true });
|
|
203
216
|
await this.adapter.setStateAsync(`devices.${command.deviceId}.pairing.reject`, { val: false, ack: true });
|
|
@@ -286,6 +299,7 @@ export class EebusRuntime {
|
|
|
286
299
|
}
|
|
287
300
|
|
|
288
301
|
private async handleDataExchangeReady(deviceId: string): Promise<void> {
|
|
302
|
+
this.partnerMonitor.observed(deviceId);
|
|
289
303
|
// Prime the trust decision before the first time-critical CLS write arrives.
|
|
290
304
|
// The control path can then use the in-memory cache without an object DB read.
|
|
291
305
|
if (!this.trustCache.has(deviceId)) {
|
|
@@ -979,6 +993,10 @@ export class EebusRuntime {
|
|
|
979
993
|
};
|
|
980
994
|
}
|
|
981
995
|
|
|
996
|
+
public canMonitorPartner(id:string): boolean {
|
|
997
|
+
return !this.stopping && this.adapter.canOperate?.() !== false && this.endpoint?.hasAuthorizedExchange(id) === true;
|
|
998
|
+
}
|
|
999
|
+
|
|
982
1000
|
public getNodes(): DiscoveredShipNode[] { return Array.from(this.nodes.values()).map(node => ({ ...node })); }
|
|
983
1001
|
|
|
984
1002
|
private periodic(key: string, work: () => Promise<void>): void {
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
|
|
3
|
+
const objectId = 'pairing.monitoredPartners';
|
|
4
|
+
const startupGraceMs = 120_000;
|
|
5
|
+
type State = 'online' | 'offline' | 'unknown' | 'disabled';
|
|
6
|
+
type Partner = { id:string; key:string; name:string; pin:string; paused:boolean };
|
|
7
|
+
const pinValue = (v:unknown):string => typeof v === 'string' && /^[a-f0-9]{64}$/i.test(v.replace(/:/g,'')) ? v.replace(/:/g,'').toUpperCase() : '';
|
|
8
|
+
interface Store {
|
|
9
|
+
getStateAsync(id:string): Promise<{val:unknown;ack?:boolean} | null | undefined>;
|
|
10
|
+
setStateAsync(id:string, value:{val:string;ack:true}): Promise<unknown>;
|
|
11
|
+
}
|
|
12
|
+
function friendlyName(value:unknown): value is string {
|
|
13
|
+
return typeof value === 'string' && value === value.trim() && value.length <= 64 &&
|
|
14
|
+
/\p{L}/u.test(value) && /^[\p{L}\p{M}\p{N} _()-]+$/u.test(value) &&
|
|
15
|
+
!/[a-f\d]{16,}|(?:[a-f\d]{2}-){5}[a-f\d]{2}/i.test(value) && !/\d{9,}/.test(value);
|
|
16
|
+
}
|
|
17
|
+
const safeId = (v:unknown):v is string => typeof v==='string' && /^[a-f\d]{40}$/i.test(v);
|
|
18
|
+
const key = (id:string) => createHash('sha256').update('eebus:'+id.toLowerCase()).digest('hex');
|
|
19
|
+
export function emptyReport(known:boolean) {
|
|
20
|
+
return {state:known?'ok':'unknown',offline:[] as {name:string}[],totalOffline:0,
|
|
21
|
+
tracked:[] as {key:string;name:string;state:State}[],complete:known};
|
|
22
|
+
}
|
|
23
|
+
/** Names are local installer input. Discovery metadata, peer addresses and certificates never feed the customer report. */
|
|
24
|
+
export class PartnerMonitor {
|
|
25
|
+
private partners = new Map<string,Partner>();
|
|
26
|
+
private confirmed = new Set<string>();
|
|
27
|
+
private suppressed = new Set<string>();
|
|
28
|
+
private known = false;
|
|
29
|
+
private startedAt = 0;
|
|
30
|
+
private pending:Promise<void> = Promise.resolve();
|
|
31
|
+
constructor(private store:Store, private live:(id:string)=>boolean, private now=()=>performance.now()) {}
|
|
32
|
+
|
|
33
|
+
async load(): Promise<void> {
|
|
34
|
+
this.startedAt = this.now();
|
|
35
|
+
try {
|
|
36
|
+
const state = await this.store.getStateAsync(objectId);
|
|
37
|
+
if (state?.ack === false) throw Error();
|
|
38
|
+
const rows:unknown = state?.val == null ? [] : JSON.parse(String(state.val));
|
|
39
|
+
if (!Array.isArray(rows) || rows.length>128) throw Error();
|
|
40
|
+
const restored = new Map<string,Partner>();
|
|
41
|
+
for (const item of rows) {
|
|
42
|
+
if (!item || !safeId(item.id) || !friendlyName(item.name) || !pinValue(item.pin) || typeof item.paused!=='boolean' || restored.has(item.id)) throw Error();
|
|
43
|
+
const row = {id:item.id.toUpperCase(), key:key(item.id), name:item.name, pin:pinValue(item.pin), paused:item.paused};
|
|
44
|
+
if (restored.has(row.id)) throw Error();
|
|
45
|
+
restored.set(row.id,row);
|
|
46
|
+
}
|
|
47
|
+
// Verify locally approved pairing on restart even when the peer is currently absent.
|
|
48
|
+
const monitored = Array.from(restored.values()).filter(row=>!row.paused);
|
|
49
|
+
let changed = false;
|
|
50
|
+
for (let start=0; start<monitored.length; start+=8) {
|
|
51
|
+
await Promise.all(monitored.slice(start,start+8).map(async row => {
|
|
52
|
+
if (await this.trustedPin(row.id) !== row.pin) { row.paused = true; changed = true; }
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
if (changed) await this.save(restored);
|
|
56
|
+
else this.partners = restored;
|
|
57
|
+
this.known = true;
|
|
58
|
+
} catch { this.known = false; }
|
|
59
|
+
}
|
|
60
|
+
private async trustedPin(id:string) {
|
|
61
|
+
const [trust,pin] = await Promise.all(['trusted','pinnedFingerprint'].map(field=>
|
|
62
|
+
this.store.getStateAsync('devices.'+id+'.pairing.'+field)));
|
|
63
|
+
return trust?.val===true && trust.ack!==false && pin?.ack!==false ? pinValue(pin?.val) : '';
|
|
64
|
+
}
|
|
65
|
+
private change(write:()=>Promise<void>):Promise<void> {
|
|
66
|
+
const op = this.pending.then(write);
|
|
67
|
+
this.pending = op.catch(()=>{});
|
|
68
|
+
return op;
|
|
69
|
+
}
|
|
70
|
+
private async save(next:Map<string,Partner>):Promise<void> {
|
|
71
|
+
await this.store.setStateAsync(objectId,{val:JSON.stringify(Array.from(next.values(), ({id,name,pin,paused})=>({id,name,pin,paused}))),ack:true});
|
|
72
|
+
this.partners = next;
|
|
73
|
+
}
|
|
74
|
+
async configure(id:string, name:unknown, enabled:boolean):Promise<void> {
|
|
75
|
+
if (!safeId(id)) throw new Error('EEBUS_MONITOR_DEVICE');
|
|
76
|
+
id=id.toUpperCase();
|
|
77
|
+
return this.change(async()=>{
|
|
78
|
+
if (!this.known) throw new Error('EEBUS_MONITOR_STORAGE_UNAVAILABLE');
|
|
79
|
+
const next = new Map(this.partners);
|
|
80
|
+
if (enabled) {
|
|
81
|
+
if (!friendlyName(name)) throw new Error('EEBUS_MONITOR_LOCAL_NAME');
|
|
82
|
+
const pin = this.live(id) ? await this.trustedPin(id) : '';
|
|
83
|
+
if (!pin || !this.live(id)) throw new Error('EEBUS_MONITOR_PAIRED_SESSION_REQUIRED');
|
|
84
|
+
if (!next.has(id) && next.size>=128) throw new Error('EEBUS_MONITOR_CAPACITY');
|
|
85
|
+
next.set(id,{id,key:key(id),name,pin,paused:false});
|
|
86
|
+
} else { next.delete(id); }
|
|
87
|
+
await this.save(next);
|
|
88
|
+
if (enabled) this.confirmed.add(id); else this.confirmed.delete(id);
|
|
89
|
+
this.suppressed.delete(id);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
pinChanged(id:string, value:unknown):Promise<void> {
|
|
93
|
+
const row=this.partners.get(id.toUpperCase());
|
|
94
|
+
return row && !row.paused && row.pin!==pinValue(value) ? this.pause(id) : Promise.resolve();
|
|
95
|
+
}
|
|
96
|
+
pause(id:string):Promise<void> {
|
|
97
|
+
id=id.toUpperCase();
|
|
98
|
+
this.suppressed.add(id);
|
|
99
|
+
return this.change(async()=>{
|
|
100
|
+
const row=this.partners.get(id);
|
|
101
|
+
if (row && !row.paused) {
|
|
102
|
+
const next=new Map(this.partners); next.set(id,{...row,paused:true});
|
|
103
|
+
await this.save(next);
|
|
104
|
+
}
|
|
105
|
+
this.suppressed.delete(id);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
observed(id:string):void { if (this.partners.has(id.toUpperCase()) && this.live(id)) this.confirmed.add(id.toUpperCase()); }
|
|
109
|
+
list() {return Array.from(this.partners.values(),({id,name,paused})=>({id,name,paused}));}
|
|
110
|
+
report() {
|
|
111
|
+
const report=emptyReport(this.known);
|
|
112
|
+
if (!this.known) return report;
|
|
113
|
+
for (const row of this.partners.values()) {
|
|
114
|
+
const active=this.live(row.id);
|
|
115
|
+
const state:State=row.paused || this.suppressed.has(row.id)?'disabled':active?'online':
|
|
116
|
+
this.confirmed.has(row.id) || this.now()-this.startedAt>=startupGraceMs?'offline':'unknown';
|
|
117
|
+
if (state==='online') this.confirmed.add(row.id);
|
|
118
|
+
report.tracked.push({key:row.key,name:row.name,state});
|
|
119
|
+
if (state==='unknown' && report.state==='ok') report.state='unknown';
|
|
120
|
+
if (state==='offline') {
|
|
121
|
+
report.state='fault'; report.totalOffline++;
|
|
122
|
+
if (report.offline.length<12) report.offline.push({name:row.name});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return report;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -246,6 +246,11 @@ export class ShipEndpoint {
|
|
|
246
246
|
if (session && fingerprint !== session.remoteFingerprint) this.disconnect(deviceId);
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
+
public hasAuthorizedExchange(deviceId: string): boolean {
|
|
250
|
+
const peer = this.sessions.get(deviceId);
|
|
251
|
+
return !!peer?.authorized && peer.dataExchangeReady && this.isSocketOpen(peer.socket) && !this.stopping;
|
|
252
|
+
}
|
|
253
|
+
|
|
249
254
|
public hasObservedPeer(deviceId: string): boolean {
|
|
250
255
|
const session = this.sessions.get(deviceId);
|
|
251
256
|
return !!session?.remoteFingerprint && this.isSocketOpen(session.socket);
|
|
@@ -41,6 +41,7 @@ export const discoveryStates: StateDefinition[] = [
|
|
|
41
41
|
];
|
|
42
42
|
|
|
43
43
|
export const globalPairingStates: StateDefinition[] = [
|
|
44
|
+
{ id: 'monitoredPartners', name: 'Installer-configured EEBus partner supervision', type: 'string', role: 'json', read: true, write: false, def: '[]' },
|
|
44
45
|
{
|
|
45
46
|
id: 'autoAcceptNewDevices',
|
|
46
47
|
name: 'Auto accept new devices for field testing',
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const test = require('node:test');
|
|
3
|
+
const assert = require('node:assert/strict');
|
|
4
|
+
const {PartnerMonitor} = require('../build/lib/partnerMonitor');
|
|
5
|
+
const {EebusRuntime} = require('../build/lib/eebusRuntime');
|
|
6
|
+
const testId='AB'.repeat(20), pin='EF'.repeat(32), name='Wärmepumpe West';
|
|
7
|
+
const roster='pairing.monitoredPartners';
|
|
8
|
+
|
|
9
|
+
function sample() {
|
|
10
|
+
let active=false, clock=0;
|
|
11
|
+
const values=new Map();
|
|
12
|
+
const store={getStateAsync:async k=>values.get(k), setStateAsync:async(k,v)=>{values.set(k,v);},
|
|
13
|
+
canOperate:()=>true, namespace:'eos-admin.0.eebus'};
|
|
14
|
+
function paired() {
|
|
15
|
+
values.set('devices.'+testId+'.pairing.trusted',{val:true,ack:true});
|
|
16
|
+
values.set('devices.'+testId+'.pairing.pinnedFingerprint',{val:pin,ack:true});
|
|
17
|
+
}
|
|
18
|
+
const open = () => new PartnerMonitor(store, id=>active && id===testId, ()=>clock);
|
|
19
|
+
return {store,values,paired,open,connected(x){active=x;},clock(x){clock=x;}};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
test('EEBus requires local intent, a trusted and pinned live data-exchange and a local display name', async()=>{
|
|
23
|
+
const f=sample(), m=f.open();await m.load();
|
|
24
|
+
assert.deepEqual(m.report(),{state:'ok',offline:[],totalOffline:0,tracked:[],complete:true});
|
|
25
|
+
f.paired(); m.observed(testId);
|
|
26
|
+
await assert.rejects(m.configure(testId,name,true),/PAIRED_SESSION/);
|
|
27
|
+
f.connected(true); f.values.delete('devices.'+testId+'.pairing.trusted');
|
|
28
|
+
await assert.rejects(m.configure(testId,name,true),/PAIRED_SESSION/);
|
|
29
|
+
f.paired(); f.values.delete('devices.'+testId+'.pairing.pinnedFingerprint');
|
|
30
|
+
await assert.rejects(m.configure(testId,name,true),/PAIRED_SESSION/); f.paired();
|
|
31
|
+
for (const label of [testId,'192.168.0.1','AA-BB-CC-DD-EE-FF','https://peer.local/','']) {
|
|
32
|
+
await assert.rejects(m.configure(testId,label,true),/LOCAL_NAME/);
|
|
33
|
+
}
|
|
34
|
+
assert.equal(f.values.has(roster),false);
|
|
35
|
+
await m.configure(testId,name,true);
|
|
36
|
+
assert.equal(m.report().tracked[0].state,'online');
|
|
37
|
+
f.connected(false);
|
|
38
|
+
const fault=m.report();
|
|
39
|
+
assert.deepEqual(fault.offline,[{name}]); assert.equal(fault.state,'fault');
|
|
40
|
+
assert.match(fault.tracked[0].key,/^[a-f0-9]{64}$/);
|
|
41
|
+
assert.ok(!JSON.stringify(fault).toLowerCase().includes(testId.toLowerCase()));
|
|
42
|
+
assert.ok(!JSON.stringify(fault).toLowerCase().includes(pin.toLowerCase()));
|
|
43
|
+
f.connected(true);
|
|
44
|
+
assert.equal(m.report().state,'ok');
|
|
45
|
+
assert.equal(m.report().tracked[0].key,fault.tracked[0].key);
|
|
46
|
+
});
|
|
47
|
+
test('EEBus opted-in partner survives reboot, allows time to reconnect, and remains paused after deliberate disconnect',async()=>{
|
|
48
|
+
const f=sample();f.paired();f.connected(true);
|
|
49
|
+
const before=f.open();await before.load();await before.configure(testId,name,true);
|
|
50
|
+
f.connected(false);const after=f.open();await after.load();
|
|
51
|
+
assert.equal(after.report().tracked[0].state,'unknown');
|
|
52
|
+
f.clock(119999);assert.equal(after.report().totalOffline,0);
|
|
53
|
+
f.clock(120000);assert.equal(after.report().tracked[0].state,'offline');
|
|
54
|
+
await after.pause(testId);assert.equal(after.report().tracked[0].state,'disabled');
|
|
55
|
+
const restart=f.open();await restart.load();f.clock(240001);assert.equal(restart.report().tracked[0].state,'disabled');
|
|
56
|
+
await restart.configure(testId,'',false); assert.equal(restart.report().tracked.length,0);
|
|
57
|
+
});
|
|
58
|
+
test('EEBus revocation and pin change disable monitoring persistently; invalid storage cannot generate an offline declaration',async()=>{
|
|
59
|
+
const f=sample();f.paired();f.connected(true);
|
|
60
|
+
const m=f.open();await m.load(); await m.configure(testId,name,true);
|
|
61
|
+
await m.pinChanged(testId,pin);assert.equal(m.report().tracked[0].state,'online');
|
|
62
|
+
await m.pinChanged(testId,'B1'.repeat(32));assert.equal(m.report().tracked[0].state,'disabled');
|
|
63
|
+
await m.configure(testId,name,true);f.values.set('devices.'+testId+'.pairing.trusted',{val:false,ack:true});
|
|
64
|
+
const next=f.open();await next.load();assert.equal(next.report().tracked[0].state,'disabled');
|
|
65
|
+
f.paired();const again=f.open();await again.load();assert.equal(again.report().tracked[0].state,'disabled');
|
|
66
|
+
f.values.set(roster,{val:'{}',ack:true});
|
|
67
|
+
const bad=f.open();await bad.load();assert.equal(bad.report().complete,false);assert.equal(bad.report().totalOffline,0);
|
|
68
|
+
await assert.rejects(bad.configure(testId,name,true),/STORAGE_UNAVAILABLE/);
|
|
69
|
+
assert.equal(f.values.get(roster).val,'{}');
|
|
70
|
+
});
|
|
71
|
+
test('the normal EEBus disconnect and trust-revocation entry points pause an active monitored partner', async()=>{
|
|
72
|
+
const f=sample();f.paired();let open=true,physicalCommands=0;
|
|
73
|
+
const runtime=new EebusRuntime(f.store,{}, {}, {});
|
|
74
|
+
runtime.endpoint={hasAuthorizedExchange:()=>open,disconnect(){physicalCommands++;open=false;}};
|
|
75
|
+
await runtime.partnerMonitor.load();
|
|
76
|
+
await runtime.partnerMonitor.configure(testId,name,true);assert.equal(physicalCommands,0);
|
|
77
|
+
await runtime.handleStateChange(f.store.namespace+'.devices.'+testId+'.control.disconnect',{val:true,ack:false});
|
|
78
|
+
assert.equal(runtime.partnerMonitor.report().tracked[0].state,'disabled');assert.equal(physicalCommands,1);
|
|
79
|
+
open=true; await runtime.partnerMonitor.configure(testId,name,true);
|
|
80
|
+
await runtime.handleStateChange(f.store.namespace+'.devices.'+testId+'.pairing.trusted',{val:false,ack:true});
|
|
81
|
+
assert.equal(runtime.partnerMonitor.report().tracked[0].state,'disabled');
|
|
82
|
+
});
|
|
@@ -339,3 +339,20 @@ test('EEBUS-SHIP-014: concurrent requests for the same peer cannot bypass the co
|
|
|
339
339
|
assert.equal(server.observed.length, 1, 'one connecting socket per peer, despite awaited diagnostics');
|
|
340
340
|
});
|
|
341
341
|
|
|
342
|
+
|
|
343
|
+
test('opted-in partner health follows a real local TLS/SHIP session; discovery and pairing alone do not create a dashboard alarm', async t=>{
|
|
344
|
+
const {PartnerMonitor}=require('../build/lib/partnerMonitor');
|
|
345
|
+
const f=await fixture(t);
|
|
346
|
+
const m=new PartnerMonitor(f.adapter,id=>f.endpoint.hasAuthorizedExchange(id));
|
|
347
|
+
await m.load(); f.trust();
|
|
348
|
+
f.states.set('devices.'+peer.ski+'.pairing.trusted',{val:true,ack:true});
|
|
349
|
+
const client=await f.connect();
|
|
350
|
+
assert.equal(m.report().tracked.length,0);
|
|
351
|
+
await assert.rejects(m.configure(peer.ski,'WP West',true),/PAIRED_SESSION/);
|
|
352
|
+
await handshake(f,client); assert.equal(m.report().tracked.length,0);
|
|
353
|
+
await m.configure(peer.ski,'WP West',true);
|
|
354
|
+
assert.equal(m.report().tracked[0].state,'online');
|
|
355
|
+
client.close(); await until(()=>m.report().state==='fault','confirmed partner goes offline on socket close');
|
|
356
|
+
assert.deepEqual(m.report().offline,[{name:'WP West'}]);
|
|
357
|
+
assert.equal(f.delivered.length,0,'enabling supervision issues no SPINE actuation');
|
|
358
|
+
});
|