iobroker.eos-admin 9.0.17 → 9.0.18
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 +12 -14
- package/README.md +5 -3
- package/START_HIER_9.0.18.md +47 -0
- package/adminWww/.vite/manifest.json +39 -39
- package/adminWww/NEXOWATT_EOS_FRONTEND_MANIFEST.json +107 -107
- package/adminWww/assets/{AdapterUpdateDialog-Cpo3dAfY.js → AdapterUpdateDialog-ByJk9Cxj.js} +1 -1
- package/adminWww/assets/{Adapters-n2ukPDdC.js → Adapters-V2JtEPZX.js} +1 -1
- package/adminWww/assets/{ConfigManager-BVZ6_Ebo.js → ConfigManager-BKcdyJnN.js} +1 -1
- package/adminWww/assets/{Enums-CQ6yHG2W.js → Enums-ChbfAWzp.js} +1 -1
- package/adminWww/assets/{Fields-CaJqzoW-.js → Fields-DzaVXEvg.js} +1 -1
- package/adminWww/assets/{Files-DfvpKGa3.js → Files-CRpIXj4X.js} +1 -1
- package/adminWww/assets/{Hosts-3xLBsdG6.js → Hosts-rOgfd2wo.js} +1 -1
- package/adminWww/assets/{Instances-B7hKEhyw.js → Instances-BxLhJ6Pb.js} +1 -1
- package/adminWww/assets/{Intro-BV4kYZdT.js → Intro-BOql527d.js} +1 -1
- package/adminWww/assets/{Logs-DpL9eY69.js → Logs-WUUDY7a4.js} +1 -1
- package/adminWww/assets/{Objects-dN06jhQk.js → Objects-DYaZkCK7.js} +1 -1
- package/adminWww/assets/{Overview-Lip63_ej.js → Overview-C6hiiPbm.js} +1 -1
- package/adminWww/assets/{State-BSO2X_xN.js → State-AH43l7fG.js} +1 -1
- package/adminWww/assets/{UsedResources-DvqzszKI.js → UsedResources-jhsRMH4X.js} +1 -1
- package/adminWww/assets/{Users-Csqd1xA-.js → Users-D9wyLyJ1.js} +1 -1
- package/adminWww/assets/{bootstrap-C3HM8kNL.js → bootstrap-gVLo1K_2.js} +3 -3
- package/adminWww/assets/{hostInit-DdxBUeXQ.js → hostInit-Dt_M-NAC.js} +1 -1
- package/adminWww/assets/{icons-material-D1Tb_725.js → icons-material-DuVW_EUA.js} +1 -1
- package/adminWww/assets/{index-BOujTMyH.js → index-B1cnPkSO.js} +2 -2
- package/adminWww/assets/{installSVGRenderer-BZyrUVAo.js → installSVGRenderer-GvgHjubR.js} +1 -1
- package/adminWww/assets/{mf-entry-bootstrap-0-3418586b.js → mf-entry-bootstrap-0-6b32b635.js} +2 -2
- 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.18.js +12 -0
- package/adminWww/remoteEntry.js +1 -1
- package/build/lib/eosDeviceEmsPlan.js +739 -0
- package/build/lib/eosDeviceEmsPlan.js.map +1 -0
- package/build/lib/eosDeviceEmsService.js +377 -0
- package/build/lib/eosDeviceEmsService.js.map +1 -0
- package/build/lib/eosModuleHost.js +53 -2
- package/build/lib/eosModuleHost.js.map +1 -1
- package/build/lib/eosModuleHttp.js +1 -1
- package/build/lib/eosModuleHttp.js.map +1 -1
- package/build/lib/web.js +15 -0
- package/build/lib/web.js.map +1 -1
- package/docs/reports/unified-9.0.18/ALIAS_V1_COVERAGE.json +5056 -0
- package/docs/reports/unified-9.0.18/ALIAS_V1_VERTRAG.md +257 -0
- package/docs/reports/unified-9.0.18/ANFORDERUNGEN.md +55 -0
- package/docs/reports/unified-9.0.18/CUSTOMER_TARIFF_REVIEW.md +33 -0
- package/docs/reports/unified-9.0.18/GERAETE_EMS_EINRICHTUNG.md +86 -0
- package/docs/reports/unified-9.0.18/INSTALLER_LIFECYCLE_REVIEW.md +29 -0
- package/docs/reports/unified-9.0.18/KUNDENTARIF_EINRICHTUNG.md +27 -0
- package/docs/reports/unified-9.0.18/PRUEFBERICHT.md +87 -0
- package/docs/reports/unified-9.0.18/UNABHAENGIGER_REVIEW.md +63 -0
- package/docs/reports/unified-9.0.18/raw/INDEX.json +331 -0
- package/docs/reports/unified-9.0.18/raw/audit-full.log +345 -0
- package/docs/reports/unified-9.0.18/raw/audit-full.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/audit-runtime.log +23 -0
- package/docs/reports/unified-9.0.18/raw/audit-runtime.result.json +15 -0
- package/docs/reports/unified-9.0.18/raw/backend-final.log +5 -0
- package/docs/reports/unified-9.0.18/raw/backend-final.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/frontend-build.log +152 -0
- package/docs/reports/unified-9.0.18/raw/frontend-build.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/installer-build.log +26 -0
- package/docs/reports/unified-9.0.18/raw/installer-build.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/keygen-source.json +6 -0
- package/docs/reports/unified-9.0.18/raw/lint-final.log +5 -0
- package/docs/reports/unified-9.0.18/raw/lint-final.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/modules-build.log +5 -0
- package/docs/reports/unified-9.0.18/raw/modules-build.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/node22-tests-final.log +9859 -0
- package/docs/reports/unified-9.0.18/raw/node22-tests-final.result.json +13 -0
- package/docs/reports/unified-9.0.18/raw/node22-typecheck-final.log +7 -0
- package/docs/reports/unified-9.0.18/raw/node22-typecheck-final.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/node22-version.log +1 -0
- package/docs/reports/unified-9.0.18/raw/node24-tests-final.log +1663 -0
- package/docs/reports/unified-9.0.18/raw/node24-tests-final.result.json +13 -0
- package/docs/reports/unified-9.0.18/raw/node24-typecheck-final.log +5 -0
- package/docs/reports/unified-9.0.18/raw/node24-typecheck-final.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/node24-version.log +1 -0
- package/docs/reports/unified-9.0.18/raw/sbom-runtime.log +7 -0
- package/docs/reports/unified-9.0.18/raw/sbom-runtime.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/sbom-vendor-check.log +1 -0
- package/docs/reports/unified-9.0.18/raw/sbom-vendor-check.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/ui-docs-check.log +6 -0
- package/docs/reports/unified-9.0.18/raw/ui-docs-check.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/ui-runtime-final.log +7 -0
- package/docs/reports/unified-9.0.18/raw/ui-runtime-final.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/ui-runtime-sync.log +6 -0
- package/docs/reports/unified-9.0.18/raw/ui-runtime-sync.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/ui-sbom-check.log +6 -0
- package/docs/reports/unified-9.0.18/raw/ui-sbom-check.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/ui-sbom-final.log +14 -0
- package/docs/reports/unified-9.0.18/raw/ui-sbom-final.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/ui-secret-final.log +6 -0
- package/docs/reports/unified-9.0.18/raw/ui-secret-final.result.json +14 -0
- package/docs/reports/unified-9.0.18/raw/ui-security-final.log +8 -0
- package/docs/reports/unified-9.0.18/raw/ui-security-final.result.json +14 -0
- package/io-package.json +8 -8
- package/modules/devices/admin/alias-contract-v1.json +189 -0
- package/modules/devices/admin/ems-assignment.d.ts +10 -0
- package/modules/devices/admin/ems-assignment.js +194 -0
- package/modules/devices/admin/host-bridge.js +47 -0
- package/modules/devices/admin/index.html +19 -1
- package/modules/devices/admin/index_m.js +73 -1
- package/modules/devices/admin/style.css +15 -0
- package/modules/devices/checks/emsAssignment.check.js +128 -0
- package/modules/devices/eslint.hosted.config.mjs +1 -1
- package/modules/devices/index.js +11 -0
- package/modules/devices/lib/alias-contract-v1.json +189 -0
- package/modules/devices/lib/aliasContract.js +7 -1
- package/modules/devices/lib/device-alias-semantics-v1.json +1605 -0
- package/modules/devices/lib/deviceAliasSemantics.js +109 -0
- package/modules/devices/lib/deviceRuntime.js +3 -0
- package/modules/devices/test/aliasContractV1.test.js +1 -1
- package/modules/devices/test/deviceAliasSemantics.test.js +163 -0
- package/modules/devices/test/emsAssignmentUi.test.js +190 -0
- package/modules/devices/tsconfig.alias-semantics.json +17 -0
- package/modules/devices/tsconfig.ems-ui.json +9 -0
- package/package.json +9 -7
- package/release-manifests/unified/build-environment.cdx.json +6 -6
- package/release-manifests/unified/files.json +194 -85
- 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 +84 -0
- package/release-manifests/unified/runtime.cdx.json +23 -23
- package/release-manifests/unified/validation.json +15 -15
- package/tools/eos-release-check.cjs +1 -1
- package/tools/eos-release-manifest.cjs +5 -5
- package/ui/docs/security/eslint-reviewed-findings.json +32 -18
- package/ui/ems/datapoints.js +22 -1
- package/ui/ems/modules/tariff-provider.js +232 -54
- package/ui/io-package.json +5 -1
- package/ui/lib/customer-tariff.js +241 -0
- package/ui/lib/installer-lifecycle.js +87 -0
- package/ui/main.js +203 -117
- package/ui/package.json +8 -4
- package/ui/www/customer-tariff.css +21 -0
- package/ui/www/customer-tariff.js +333 -0
- package/ui/www/ems-apps.js +16 -6
- package/ui/www/manifest.webmanifest +2 -2
- package/ui/www/settings.html +45 -0
- package/adminWww/remoteEntry-eos-9.0.17.js +0 -12
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 NexoWatt. All rights reserved.
|
|
3
|
+
* Confidential and Proprietary.
|
|
4
|
+
* Use, modification or distribution without express written permission is prohibited.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* AUTO-GENERATED RUNTIME FILE - NICHT MANUELL BEARBEITEN.
|
|
8
|
+
*
|
|
9
|
+
* Quelle: src-ts/runtime-executables/lib/customer-tariff.ts
|
|
10
|
+
* Quell-Hash: sha256:c67703360c97d4d9630b72d2809ab1d21c3643d5443de6db3163dfbf80cc4024
|
|
11
|
+
* Erzeugung: npm run sync:ts-runtime-executables
|
|
12
|
+
*
|
|
13
|
+
* Zweck:
|
|
14
|
+
* Diese JavaScript-Datei ist das ausführbare Build-Artefakt für lib/customer-tariff.js.
|
|
15
|
+
* Die fachliche Bearbeitung erfolgt ab 0.7.131 in der TypeScript-Quelle.
|
|
16
|
+
* Ab 0.7.132 sind doppelte Legacy-JS-Bäume wie .nwcore entfernt.
|
|
17
|
+
*
|
|
18
|
+
* Pflege-Regel:
|
|
19
|
+
* 1. Änderung zuerst in src-ts/runtime-executables/ vornehmen.
|
|
20
|
+
* 2. npm run sync:ts-runtime-executables ausführen.
|
|
21
|
+
* 3. npm run test:runtime-executables prüfen.
|
|
22
|
+
*/
|
|
23
|
+
"use strict";
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.customerTariffView = customerTariffView;
|
|
26
|
+
exports.prepareCustomerTariffChange = prepareCustomerTariffChange;
|
|
27
|
+
/**
|
|
28
|
+
* NexoWatt Quellcode-Erklärung (DE)
|
|
29
|
+
* Aufgabe: Begrenzt Kundeneinstellungen auf den gemeinsamen Anlagentarif.
|
|
30
|
+
* Daten und Wirkung: Anbieter aus fester Liste, bekannte HTTPS-Endpunkte und
|
|
31
|
+
* begrenzte Vertragswerte. Zugangsdaten werden nur angenommen, nie ausgegeben.
|
|
32
|
+
* Ein Anbieterwechsel übernimmt keine fremden Provider-Zugangsdaten; bisherige
|
|
33
|
+
* Werte bleiben ausschließlich im geschützten Konfigurationsstate erhalten.
|
|
34
|
+
* Zusammenhang: Der Aufrufer prüft Sitzung, CSRF, Lizenz und AppCenter-Revision.
|
|
35
|
+
* Bei Änderungen: Fremdfelder, URLs, alte Revisionen, geheime Daten und die
|
|
36
|
+
* ausdrückliche Zustimmung zur Zuordnung der vier Tarif-Lesepunkte prüfen.
|
|
37
|
+
*/
|
|
38
|
+
const http_error_boundary_1 = require("./http-error-boundary");
|
|
39
|
+
const PROVIDERS = ['manual-dp', 'tibber', 'energyzero', 'entsoe', 'market-profile'];
|
|
40
|
+
const ENDPOINTS = Object.freeze({
|
|
41
|
+
tibber: 'https://api.tibber.com/v1-beta/gql',
|
|
42
|
+
energyzero: 'https://public.api.energyzero.nl/public/v1/prices',
|
|
43
|
+
entsoe: 'https://web-api.tp.entsoe.eu/api',
|
|
44
|
+
});
|
|
45
|
+
const PRICE_KEYS = ['priceCurrent', 'priceAverage', 'priceTodayJson', 'priceTomorrowJson'];
|
|
46
|
+
const PRICE_SUFFIXES = new Map([['priceCurrent', 'currentPriceEurPerKwh'], ['priceAverage', 'averagePriceEurPerKwh'], ['priceTodayJson', 'pricesTodayJson'], ['priceTomorrowJson', 'pricesTomorrowJson']]);
|
|
47
|
+
const FORMULA_DEFAULTS = { marketMultiplier: 1, supplierMarkupEurPerKwh: 0, gridVariableEurPerKwh: 0, taxEurPerKwh: 0, otherVariableEurPerKwh: 0, vatPct: 0, priceIncludesVat: true };
|
|
48
|
+
const RESERVED_CREDENTIAL_INPUTS = new Set(['__KEEP__']);
|
|
49
|
+
const FIELDS = new Set(['enabled', 'providerId', 'sourceId', 'providerProfileId', 'country', 'homeId', 'priceComponent', 'formula', 'credentials', 'useForTariff']);
|
|
50
|
+
function rec(value) { return value !== null && typeof value === 'object' && !Array.isArray(value) ? value : {}; }
|
|
51
|
+
function copy(value) { return JSON.parse(JSON.stringify(value)); }
|
|
52
|
+
function invalid(message) { throw (0, http_error_boundary_1.createPublicHttpError)(422, 'EOS_TARIFF_INVALID', message); }
|
|
53
|
+
function text(value, limit) {
|
|
54
|
+
if (typeof value !== 'string' || value.length > limit || /[\u0000-\u001f\u007f]/u.test(value))
|
|
55
|
+
invalid('Ein Tariftext oder Zugangswert ist ungültig.');
|
|
56
|
+
return value.trim();
|
|
57
|
+
}
|
|
58
|
+
function own(value, key) { return Object.hasOwn(value, key); }
|
|
59
|
+
function storedText(value, fallback) { return typeof value === 'string' && value.length <= 256 ? value : fallback; }
|
|
60
|
+
function source(provider) { return provider.providerId === 'market-profile' ? storedText(provider.sourceId, provider.country === 'NL' ? 'energyzero' : 'entsoe') : storedText(provider.providerId, 'manual-dp'); }
|
|
61
|
+
function knownEndpoint(provider) { const expected = Reflect.get(ENDPOINTS, source(provider)); return typeof expected === 'string' && (!provider.endpoint || provider.endpoint === expected); }
|
|
62
|
+
function managedPoints(namespace) {
|
|
63
|
+
if (!/^(?:eos-admin|nexowatt-ui)\.\d+$/.test(namespace))
|
|
64
|
+
invalid('Der Tarifbereich ist nicht verfügbar.');
|
|
65
|
+
return Object.fromEntries([...PRICE_SUFFIXES].map(([key, suffix]) => [key, `${namespace}.tariffProvider.${suffix}`]));
|
|
66
|
+
}
|
|
67
|
+
function formulaView(value) {
|
|
68
|
+
const candidate = rec(value);
|
|
69
|
+
return Object.fromEntries(Object.entries(FORMULA_DEFAULTS).map(([key, fallback]) => {
|
|
70
|
+
const raw = Reflect.get(candidate, key);
|
|
71
|
+
return [key, typeof fallback === 'boolean' ? (typeof raw === 'boolean' ? raw : fallback) : (typeof raw === 'number' && Number.isFinite(raw) ? raw : fallback)];
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
function useForTariff(root, namespace) {
|
|
75
|
+
const points = rec(root.datapoints);
|
|
76
|
+
const expected = managedPoints(namespace);
|
|
77
|
+
return PRICE_KEYS.every(key => Reflect.get(points, key) === Reflect.get(expected, key));
|
|
78
|
+
}
|
|
79
|
+
/** Ausschließlich freigegebene Anzeige-Daten; keine internen URLs oder Geheimnisse. */
|
|
80
|
+
function customerTariffView(root, namespace, registry, snapshot) {
|
|
81
|
+
const provider = rec(root.tariffProvider);
|
|
82
|
+
const credentials = rec(provider.credentials);
|
|
83
|
+
const providerId = storedText(provider.providerId, 'manual-dp');
|
|
84
|
+
const resolved = source(provider);
|
|
85
|
+
const current = rec(snapshot);
|
|
86
|
+
const matchesCurrent = current.providerId === providerId && current.sourceId === storedText(provider.sourceId, providerId);
|
|
87
|
+
let state = 'unknown';
|
|
88
|
+
if (provider.enabled !== true || providerId === 'manual-dp')
|
|
89
|
+
state = 'disabled';
|
|
90
|
+
else if (matchesCurrent) {
|
|
91
|
+
state = current.fresh === true ? 'ready' : (current.status === 'error' || current.error ? 'error' : 'pending');
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
scope: 'system',
|
|
95
|
+
config: { enabled: provider.enabled === true, providerId, sourceId: storedText(provider.sourceId, resolved),
|
|
96
|
+
providerProfileId: storedText(provider.providerProfileId, 'local-provider'), country: provider.country === 'NL' ? 'NL' : 'DE',
|
|
97
|
+
homeId: typeof provider.homeId === 'string' ? provider.homeId.slice(0, 128) : '',
|
|
98
|
+
priceComponent: storedText(provider.priceComponent, resolved === 'energyzero' ? 'allInPriceIncludingVat' : 'total'),
|
|
99
|
+
formula: formulaView(provider.formula), useForTariff: useForTariff(root, namespace) },
|
|
100
|
+
credentialsPresent: { accessToken: resolved === 'tibber' && knownEndpoint(provider) && typeof credentials.accessToken === 'string' && credentials.accessToken.length > 0,
|
|
101
|
+
securityToken: resolved === 'entsoe' && knownEndpoint(provider) && typeof credentials.securityToken === 'string' && credentials.securityToken.length > 0 },
|
|
102
|
+
providers: (Array.isArray(registry.providers) ? registry.providers : [])
|
|
103
|
+
.filter(row => PROVIDERS.includes(rec(row).id))
|
|
104
|
+
.map(row => rec(row).id === 'market-profile' ? { ...rec(row), name: 'Anbieterprofil mit Marktpreisquelle', directApi: false,
|
|
105
|
+
description: 'ENTSO-E oder EnergyZero mit Vertragsbestandteilen; kein direkter API-Zugang zum genannten Anbieter.' } : rec(row)),
|
|
106
|
+
profiles: Array.isArray(registry.profiles) ? registry.profiles : [],
|
|
107
|
+
configuredExternally: !PROVIDERS.includes(providerId) || (providerId !== 'manual-dp' && !knownEndpoint(provider)),
|
|
108
|
+
status: { state, ...(matchesCurrent && typeof current.ts === 'number' && Number.isFinite(current.ts) ? { lastUpdate: current.ts } : {}) },
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/** Pure targeted patch: no app-enable flag, limits, arbitrary mappings, endpoint or script input. */
|
|
112
|
+
function prepareCustomerTariffChange(root, incoming, namespace, registry) {
|
|
113
|
+
if (incoming === null || typeof incoming !== 'object' || Array.isArray(incoming))
|
|
114
|
+
invalid('Die Tarifeinstellungen sind ungültig.');
|
|
115
|
+
const submitted = rec(incoming);
|
|
116
|
+
for (const key of Object.keys(submitted))
|
|
117
|
+
if (!FIELDS.has(key))
|
|
118
|
+
invalid('Die Anfrage enthält Einstellungen außerhalb des Kundentarifs.');
|
|
119
|
+
const previous = rec(root.tariffProvider);
|
|
120
|
+
const next = copy(previous);
|
|
121
|
+
const providerId = own(submitted, 'providerId') ? text(submitted.providerId, 32) : storedText(previous.providerId, 'manual-dp');
|
|
122
|
+
if (!PROVIDERS.includes(providerId))
|
|
123
|
+
invalid('Dieser Anschluss wird vom Installateur verwaltet. Bitte einen angebotenen Anbieter wählen.');
|
|
124
|
+
next.providerId = providerId;
|
|
125
|
+
if (own(submitted, 'enabled') && typeof submitted.enabled !== 'boolean')
|
|
126
|
+
invalid('Die Tarifaktivierung ist ungültig.');
|
|
127
|
+
next.enabled = own(submitted, 'enabled') ? submitted.enabled : previous.enabled === true;
|
|
128
|
+
const country = own(submitted, 'country') ? text(submitted.country, 2) : previous.country === 'NL' ? 'NL' : 'DE';
|
|
129
|
+
if (!['DE', 'NL'].includes(country))
|
|
130
|
+
invalid('Als Tarifland sind Deutschland und die Niederlande verfügbar.');
|
|
131
|
+
next.country = country;
|
|
132
|
+
next.timeZone = country === 'NL' ? 'Europe/Amsterdam' : 'Europe/Berlin';
|
|
133
|
+
const requestedSource = own(submitted, 'sourceId') ? text(submitted.sourceId, 32) : (previous.providerId === 'market-profile' ? storedText(previous.sourceId, country === 'NL' ? 'energyzero' : 'entsoe') : (country === 'NL' ? 'energyzero' : 'entsoe'));
|
|
134
|
+
if (providerId === 'market-profile' && !['entsoe', 'energyzero'].includes(requestedSource))
|
|
135
|
+
invalid('Für Anbieterprofile bitte ENTSO-E oder EnergyZero wählen.');
|
|
136
|
+
if (providerId !== 'market-profile' && own(submitted, 'sourceId') && requestedSource !== providerId)
|
|
137
|
+
invalid('Die Preisquelle passt nicht zum ausgewählten Anbieter.');
|
|
138
|
+
next.sourceId = providerId === 'market-profile' ? requestedSource : providerId;
|
|
139
|
+
const resolved = source(next);
|
|
140
|
+
if (resolved === 'energyzero' && country !== 'NL')
|
|
141
|
+
invalid('EnergyZero ist für das Tarifland Niederlande vorgesehen.');
|
|
142
|
+
if (own(submitted, 'providerProfileId')) {
|
|
143
|
+
const id = text(submitted.providerProfileId, 64);
|
|
144
|
+
if (!(Array.isArray(registry.profiles) ? registry.profiles : []).some(row => rec(row).id === id))
|
|
145
|
+
invalid('Das Anbieterprofil ist unbekannt.');
|
|
146
|
+
next.providerProfileId = id;
|
|
147
|
+
}
|
|
148
|
+
else if (!next.providerProfileId)
|
|
149
|
+
next.providerProfileId = 'local-provider';
|
|
150
|
+
if (own(submitted, 'homeId'))
|
|
151
|
+
next.homeId = text(submitted.homeId, 128);
|
|
152
|
+
if (own(submitted, 'priceComponent')) {
|
|
153
|
+
const component = text(submitted.priceComponent, 40);
|
|
154
|
+
if (!['total', 'allInPriceIncludingVat', 'basePriceIncludingVat', 'market'].includes(component))
|
|
155
|
+
invalid('Die Preiskomponente ist ungültig.');
|
|
156
|
+
next.priceComponent = component;
|
|
157
|
+
}
|
|
158
|
+
else if (source(previous) !== resolved || !next.priceComponent)
|
|
159
|
+
next.priceComponent = resolved === 'energyzero' ? 'allInPriceIncludingVat' : 'total';
|
|
160
|
+
if (own(submitted, 'formula')) {
|
|
161
|
+
if (submitted.formula === null || typeof submitted.formula !== 'object' || Array.isArray(submitted.formula))
|
|
162
|
+
invalid('Die Preisbestandteile sind ungültig.');
|
|
163
|
+
const formula = { ...rec(previous.formula) };
|
|
164
|
+
for (const [key, value] of Object.entries(rec(submitted.formula))) {
|
|
165
|
+
if (!own(FORMULA_DEFAULTS, key))
|
|
166
|
+
invalid('Ein Preisbestandteil ist unbekannt.');
|
|
167
|
+
if (key === 'priceIncludesVat') {
|
|
168
|
+
if (typeof value !== 'boolean')
|
|
169
|
+
invalid('Die Mehrwertsteuerangabe ist ungültig.');
|
|
170
|
+
}
|
|
171
|
+
else if (typeof value !== 'number' || !Number.isFinite(value) || value < (key === 'marketMultiplier' || key === 'vatPct' ? 0 : -10) || value > (key === 'vatPct' ? 100 : 10))
|
|
172
|
+
invalid('Ein Preisbestandteil liegt außerhalb des zulässigen Bereichs.');
|
|
173
|
+
Reflect.set(formula, key, value);
|
|
174
|
+
}
|
|
175
|
+
next.formula = formula;
|
|
176
|
+
}
|
|
177
|
+
const sameSource = previous.providerId === providerId && source(previous) === resolved && knownEndpoint(previous);
|
|
178
|
+
const previousCredentials = rec(previous.credentials);
|
|
179
|
+
const credentials = sameSource ? copy(previousCredentials) : {};
|
|
180
|
+
if (!sameSource && Object.keys(previousCredentials).length) {
|
|
181
|
+
// Retention only. These archived credentials are never consumed by a provider client.
|
|
182
|
+
const retained = rec(previous.retainedProviderCredentials);
|
|
183
|
+
const key = source(previous);
|
|
184
|
+
const entries = Object.entries(retained).filter(([name]) => ['manual-dp', 'tibber', 'entsoe', 'energyzero', 'custom-rest', 'ostrom'].includes(name));
|
|
185
|
+
next.retainedProviderCredentials = Object.fromEntries([...entries.filter(([name]) => name !== key), [key, { credentials: copy(previousCredentials), endpoint: typeof previous.endpoint === 'string' ? previous.endpoint : '', providerId: previous.providerId || 'manual-dp' }]].slice(-7));
|
|
186
|
+
}
|
|
187
|
+
if (own(submitted, 'credentials')) {
|
|
188
|
+
if (submitted.credentials === null || typeof submitted.credentials !== 'object' || Array.isArray(submitted.credentials))
|
|
189
|
+
invalid('Die Zugangsdaten sind ungültig.');
|
|
190
|
+
for (const [key, value] of Object.entries(rec(submitted.credentials))) {
|
|
191
|
+
if ((key !== 'accessToken' || resolved !== 'tibber') && (key !== 'securityToken' || resolved !== 'entsoe'))
|
|
192
|
+
invalid('Das Zugangsfeld passt nicht zum ausgewählten Anbieter.');
|
|
193
|
+
const secret = text(value, 4096);
|
|
194
|
+
if (RESERVED_CREDENTIAL_INPUTS.has(secret))
|
|
195
|
+
invalid('Bitte einen neuen Token eingeben oder das Feld leer lassen.');
|
|
196
|
+
if (secret)
|
|
197
|
+
Reflect.set(credentials, key, secret);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (next.enabled === true && ((resolved === 'tibber' && (typeof credentials.accessToken !== 'string' || !credentials.accessToken.trim())) || (resolved === 'entsoe' && (typeof credentials.securityToken !== 'string' || !credentials.securityToken.trim()))))
|
|
201
|
+
invalid('Für diesen Anbieterwechsel bitte den passenden Zugangstoken eingeben.');
|
|
202
|
+
next.credentials = credentials;
|
|
203
|
+
if (resolved !== 'manual-dp')
|
|
204
|
+
next.endpoint = Reflect.get(ENDPOINTS, resolved);
|
|
205
|
+
if (resolved === 'entsoe')
|
|
206
|
+
next.biddingZone = country === 'NL' ? '10YNL----------L' : '10Y1001A1001A82H';
|
|
207
|
+
if (!sameSource && resolved !== 'manual-dp')
|
|
208
|
+
next.unit = 'EUR/kWh';
|
|
209
|
+
// Existing active tariff operation is retained, never implicitly activated by a new connection.
|
|
210
|
+
next.activateTariffLogic = typeof previous.activateTariffLogic === 'boolean' ? previous.activateTariffLogic : previous.enabled === true;
|
|
211
|
+
next.automaticMode = typeof previous.automaticMode === 'boolean' ? previous.automaticMode : previous.enabled === true;
|
|
212
|
+
next.timeoutMs = 5000;
|
|
213
|
+
let wantedMapping = own(submitted, 'useForTariff') ? submitted.useForTariff : useForTariff(root, namespace);
|
|
214
|
+
if (typeof wantedMapping !== 'boolean')
|
|
215
|
+
invalid('Die Zustimmung zur Tarifzuordnung ist ungültig.');
|
|
216
|
+
if (resolved === 'manual-dp')
|
|
217
|
+
wantedMapping = false;
|
|
218
|
+
next.autoCoupleDatapoints = wantedMapping;
|
|
219
|
+
const oldPoints = rec(root.datapoints);
|
|
220
|
+
const expected = managedPoints(namespace);
|
|
221
|
+
let datapoints;
|
|
222
|
+
if (wantedMapping && resolved !== 'manual-dp') {
|
|
223
|
+
if (!useForTariff(root, namespace))
|
|
224
|
+
next.customerPreviousPriceDatapoints = Object.fromEntries(PRICE_KEYS.map(key => [key, typeof Reflect.get(oldPoints, key) === 'string' ? Reflect.get(oldPoints, key) : null]));
|
|
225
|
+
datapoints = { ...copy(oldPoints), ...expected };
|
|
226
|
+
}
|
|
227
|
+
else if ((own(submitted, 'useForTariff') || resolved === 'manual-dp') && !wantedMapping && useForTariff(root, namespace)) {
|
|
228
|
+
const saved = rec(previous.customerPreviousPriceDatapoints);
|
|
229
|
+
if (PRICE_KEYS.every(key => own(saved, key))) {
|
|
230
|
+
datapoints = copy(oldPoints);
|
|
231
|
+
for (const key of PRICE_KEYS) {
|
|
232
|
+
const value = Reflect.get(saved, key);
|
|
233
|
+
if (typeof value === 'string')
|
|
234
|
+
Reflect.set(datapoints, key, value);
|
|
235
|
+
else
|
|
236
|
+
Reflect.deleteProperty(datapoints, key);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return { tariffProvider: next, ...(datapoints ? { datapoints } : {}) };
|
|
241
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 NexoWatt. All rights reserved.
|
|
3
|
+
* Confidential and Proprietary.
|
|
4
|
+
* Use, modification or distribution without express written permission is prohibited.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* AUTO-GENERATED RUNTIME FILE - NICHT MANUELL BEARBEITEN.
|
|
8
|
+
*
|
|
9
|
+
* Quelle: src-ts/runtime-executables/lib/installer-lifecycle.ts
|
|
10
|
+
* Quell-Hash: sha256:970590230a91cc592372ca6da3f1ff8e460c5cd8143345de321bc6eb416cd083
|
|
11
|
+
* Erzeugung: npm run sync:ts-runtime-executables
|
|
12
|
+
*
|
|
13
|
+
* Zweck:
|
|
14
|
+
* Diese JavaScript-Datei ist das ausführbare Build-Artefakt für lib/installer-lifecycle.js.
|
|
15
|
+
* Die fachliche Bearbeitung erfolgt ab 0.7.131 in der TypeScript-Quelle.
|
|
16
|
+
* Ab 0.7.132 sind doppelte Legacy-JS-Bäume wie .nwcore entfernt.
|
|
17
|
+
*
|
|
18
|
+
* Pflege-Regel:
|
|
19
|
+
* 1. Änderung zuerst in src-ts/runtime-executables/ vornehmen.
|
|
20
|
+
* 2. npm run sync:ts-runtime-executables ausführen.
|
|
21
|
+
* 3. npm run test:runtime-executables prüfen.
|
|
22
|
+
*/
|
|
23
|
+
"use strict";
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.installerRevision = installerRevision;
|
|
26
|
+
exports.assertInstallerRevision = assertInstallerRevision;
|
|
27
|
+
exports.provisionInstallerObjects = provisionInstallerObjects;
|
|
28
|
+
/**
|
|
29
|
+
* NexoWatt Quellcode-Erklärung (DE)
|
|
30
|
+
* Aufgabe: Schützt AppCenter-Zuordnungen vor veralteten Speicherformularen und
|
|
31
|
+
* legt fehlende eigene Datenpunktobjekte vor der Laufzeitübernahme an.
|
|
32
|
+
* Daten und Wirkung: Eine flüchtig geschützte HMAC-Revision verlässt den Server,
|
|
33
|
+
* niemals Konfigurationswerte oder der HMAC-Schlüssel. Pro Objektgruppe gibt es
|
|
34
|
+
* höchstens zwei Versuche; fehlende Messwerte bleiben ohne künstlichen Nullwert.
|
|
35
|
+
* Zusammenhang: Automatische Gerätezuordnung und manuelles Speichern verwenden
|
|
36
|
+
* denselben AppCenter-Mutationsschutz. Keine App oder Stellfreigabe wird erteilt.
|
|
37
|
+
* Bei Änderungen: Veraltete nichtleere Listen, Ownership-Verlust, fehlgeschlagene
|
|
38
|
+
* Objektanlage und unveränderte Kundenwerte prüfen; Neustarts verwerfen alte Revisionen.
|
|
39
|
+
*/
|
|
40
|
+
const node_crypto_1 = require("node:crypto");
|
|
41
|
+
const http_error_boundary_1 = require("./http-error-boundary");
|
|
42
|
+
const revisionSecret = (0, node_crypto_1.randomBytes)(32);
|
|
43
|
+
function record(value) {
|
|
44
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value) ? value : {};
|
|
45
|
+
}
|
|
46
|
+
function canonical(value) {
|
|
47
|
+
if (Array.isArray(value))
|
|
48
|
+
return value.map(canonical);
|
|
49
|
+
if (value !== null && typeof value === 'object') {
|
|
50
|
+
return Object.fromEntries(Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([key, item]) => [key, canonical(item)]));
|
|
51
|
+
}
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
/** Stable within this runtime across key ordering; restart invalidates old forms.
|
|
55
|
+
* An ephemeral HMAC key prevents public revisions from becoming a secret-value guessing oracle. */
|
|
56
|
+
function installerRevision(patch) {
|
|
57
|
+
return (0, node_crypto_1.createHmac)('sha256', revisionSecret).update(JSON.stringify(canonical(record(patch)))).digest('hex');
|
|
58
|
+
}
|
|
59
|
+
/** Older clients remain compatible until automatic bindings need protection.
|
|
60
|
+
* Once present, a missing or stale token must never replace a newer nonempty row list. */
|
|
61
|
+
function assertInstallerRevision(expected, patch) {
|
|
62
|
+
const bindings = record(record(record(patch).eosDeviceEms).bindings);
|
|
63
|
+
const required = Object.keys(bindings).length > 0;
|
|
64
|
+
if ((expected === undefined || expected === null) && !required)
|
|
65
|
+
return;
|
|
66
|
+
if (typeof expected !== 'string' || !/^[a-f0-9]{64}$/.test(expected) || expected !== installerRevision(patch)) {
|
|
67
|
+
throw (0, http_error_boundary_1.createPublicHttpError)(409, 'EOS_INSTALLER_CONFIG_CHANGED', 'Die EMS-Zuordnung wurde inzwischen geändert. Deine Eingaben bleiben erhalten. Bitte den aktuellen Stand über „Neu laden“ laden und die Änderungen vergleichen, bevor du erneut speicherst.');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** Bounded retries tolerate a transient controller failure. No deletion, state reset or detached work. */
|
|
71
|
+
async function provisionInstallerObjects(options) {
|
|
72
|
+
for (const step of options.steps) {
|
|
73
|
+
let completed = false;
|
|
74
|
+
for (let attempt = 0; attempt < 2; attempt++) {
|
|
75
|
+
if (!options.canWrite())
|
|
76
|
+
throw (0, http_error_boundary_1.createPublicHttpError)(409, 'EOS_UI_OWNERSHIP_REQUIRED', 'Die Systemfreigabe ist nicht mehr gültig. Einstellungen wurden nicht neu übernommen.');
|
|
77
|
+
try {
|
|
78
|
+
await step();
|
|
79
|
+
completed = true;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
catch { /* Retry only idempotent object creation. */ }
|
|
83
|
+
}
|
|
84
|
+
if (!completed)
|
|
85
|
+
throw (0, http_error_boundary_1.createPublicHttpError)(503, 'EOS_EMS_OBJECT_PROVISION_FAILED', 'Die benötigten EMS-Datenpunktobjekte konnten nicht angelegt werden. Es wurde kein erfolgreicher Abschluss gemeldet; Verbindung prüfen und erneut speichern.');
|
|
86
|
+
}
|
|
87
|
+
}
|