iobroker.eos-admin 9.0.29 → 9.0.30

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.
Files changed (100) hide show
  1. package/NEXOWATT_EOS_BUILD_INFO.json +12 -13
  2. package/README.md +9 -9
  3. package/adminWww/.vite/manifest.json +39 -39
  4. package/adminWww/NEXOWATT_EOS_FRONTEND_MANIFEST.json +107 -107
  5. package/adminWww/assets/{AdapterUpdateDialog-DXp4Dgkx.js → AdapterUpdateDialog-qC6MANmq.js} +1 -1
  6. package/adminWww/assets/{Adapters-1AOp__74.js → Adapters-C8quekd0.js} +1 -1
  7. package/adminWww/assets/{ConfigManager-CGGXU4Jp.js → ConfigManager-hRZCAWRy.js} +1 -1
  8. package/adminWww/assets/{Enums-Bl4EngJF.js → Enums-Dd0Z2KfV.js} +1 -1
  9. package/adminWww/assets/{Fields-zSEjRWOB.js → Fields-WfHFtdYw.js} +1 -1
  10. package/adminWww/assets/{Files-CnYmjEbu.js → Files-DyG14v5-.js} +1 -1
  11. package/adminWww/assets/{Hosts-zFJyiuvd.js → Hosts-3pSXVMxW.js} +1 -1
  12. package/adminWww/assets/{Instances-D10dnQY4.js → Instances-DT6fp_TN.js} +1 -1
  13. package/adminWww/assets/{Intro-DxLBfGZ8.js → Intro-C6pMFhbu.js} +1 -1
  14. package/adminWww/assets/{Logs-CAc6o-d_.js → Logs-suepwNkZ.js} +1 -1
  15. package/adminWww/assets/{Objects-I64lF3ZS.js → Objects-CpjVeEjv.js} +1 -1
  16. package/adminWww/assets/{Overview-BQ7HBH-7.js → Overview-CxZJgF7X.js} +1 -1
  17. package/adminWww/assets/{State-DHLL8gAc.js → State-CUsia7sz.js} +1 -1
  18. package/adminWww/assets/{UsedResources-DlQ_XqoR.js → UsedResources-C3zr7pM8.js} +1 -1
  19. package/adminWww/assets/{Users-CKHDvxG5.js → Users-BoBSUBkO.js} +1 -1
  20. package/adminWww/assets/{bootstrap-CIDT4MeX.js → bootstrap-CM9qXoc1.js} +3 -3
  21. package/adminWww/assets/{hostInit-Cvl4lPGh.js → hostInit-BQPg9kSQ.js} +1 -1
  22. package/adminWww/assets/{icons-material-ngdwOXrt.js → icons-material-CDhwkQ0o.js} +1 -1
  23. package/adminWww/assets/{index-B9Tfj1YG.js → index-BrXN_pu2.js} +2 -2
  24. package/adminWww/assets/{installSVGRenderer-COP6GC9p.js → installSVGRenderer-BEgWxsNI.js} +1 -1
  25. package/adminWww/assets/{mf-entry-bootstrap-0-31191d2e.js → mf-entry-bootstrap-0-3ef6056c.js} +2 -2
  26. package/adminWww/index.html +23 -23
  27. package/adminWww/mf-manifest.json +1 -1
  28. package/adminWww/mf-stats.json +1 -1
  29. package/adminWww/remoteEntry-eos-9.0.30.js +12 -0
  30. package/adminWww/remoteEntry.js +1 -1
  31. package/build/lib/eosRuntimeControl.js +21 -10
  32. package/build/lib/eosRuntimeControl.js.map +1 -1
  33. package/build/lib/eosRuntimeHealth.js +12 -9
  34. package/build/lib/eosRuntimeHealth.js.map +1 -1
  35. package/build/lib/eosSplitRuntime.js +61 -0
  36. package/build/lib/eosSplitRuntime.js.map +1 -0
  37. package/build/lib/eosUiProcess.js +91 -13
  38. package/build/lib/eosUiProcess.js.map +1 -1
  39. package/build/lib/eosUiProcessWorker.js +15 -8
  40. package/build/lib/eosUiProcessWorker.js.map +1 -1
  41. package/build/lib/web.js +17 -7
  42. package/build/lib/web.js.map +1 -1
  43. package/docs/README.md +2 -2
  44. package/docs/reports/unified-9.0.30/PRUEFBERICHT.md +37 -0
  45. package/docs/reports/{unified-9.0.29 → unified-9.0.30}/PRUEFERGEBNISSE.json +13 -13
  46. package/docs/reports/unified-9.0.30/raw/INDEX.json +137 -0
  47. package/docs/reports/unified-9.0.30/raw/acceptance-node22.log +30 -0
  48. package/docs/reports/unified-9.0.30/raw/acceptance-node24.log +11 -0
  49. package/docs/reports/{unified-9.0.29 → unified-9.0.30}/raw/backend.log +1 -1
  50. package/docs/reports/unified-9.0.30/raw/baseline-10000.json +1 -0
  51. package/docs/reports/unified-9.0.30/raw/baseline-50000.json +1 -0
  52. package/docs/reports/unified-9.0.30/raw/candidate-10000.json +1 -0
  53. package/docs/reports/unified-9.0.30/raw/candidate-50000.json +1 -0
  54. package/docs/reports/{unified-9.0.29 → unified-9.0.30}/raw/frontend.log +25 -25
  55. package/docs/reports/{unified-9.0.29 → unified-9.0.30}/raw/installer.log +4 -4
  56. package/docs/reports/{unified-9.0.29 → unified-9.0.30}/raw/lint.log +2 -2
  57. package/docs/reports/{unified-9.0.29 → unified-9.0.30}/raw/modules.log +1 -1
  58. package/docs/reports/unified-9.0.30/raw/node22-profile.json +611 -0
  59. package/docs/reports/{unified-9.0.29 → unified-9.0.30}/raw/node22-tests-final.log +5272 -5206
  60. package/docs/reports/unified-9.0.30/raw/node24-profile.json +611 -0
  61. package/docs/reports/{unified-9.0.29 → unified-9.0.30}/raw/node24-tests-final.log +2774 -2764
  62. package/docs/reports/unified-9.0.30/raw/profile-combined-node24.log +12 -0
  63. package/docs/reports/unified-9.0.30/raw/profile-split-node24.log +12 -0
  64. package/docs/reports/{unified-9.0.29 → unified-9.0.30}/raw/typecheck.log +1 -1
  65. package/docs/reports/{unified-9.0.29 → unified-9.0.30}/raw/ui-runtime.log +3 -2
  66. package/docs/start/START_HIER_9.0.30.md +16 -0
  67. package/docs/unified/ARCHITECTURE.md +18 -12
  68. package/io-package.json +8 -8
  69. package/modules/devices/README.md +1 -1
  70. package/modules/devices/lib/deviceRuntime.js +18 -14
  71. package/modules/devices/test/driverLoading.test.js +76 -0
  72. package/package.json +6 -6
  73. package/public/eos-runtime/index.js +7 -6
  74. package/release-manifests/unified/build-environment.cdx.json +6 -6
  75. package/release-manifests/unified/files.json +136 -96
  76. package/release-manifests/unified/frontend.cdx.json +6 -6
  77. package/release-manifests/unified/installer.cdx.json +6 -6
  78. package/release-manifests/unified/obsolete-admin-assets.json +89 -6
  79. package/release-manifests/unified/runtime.cdx.json +27 -27
  80. package/release-manifests/unified/validation.json +15 -15
  81. package/tools/eos-release-check.cjs +2 -0
  82. package/tools/eos-release-manifest.cjs +1 -1
  83. package/ui/io-package.json +2 -2
  84. package/ui/lib/datapoint-picker.js +184 -0
  85. package/ui/lib/eos-presentation-routes.js +61 -0
  86. package/ui/lib/eos-presentation.js +140 -0
  87. package/ui/lib/ephemeral-cache.js +7 -4
  88. package/ui/main.js +5 -302
  89. package/ui/package.json +1 -1
  90. package/ui/www/manifest.webmanifest +2 -2
  91. package/adminWww/remoteEntry-eos-9.0.29.js +0 -12
  92. package/docs/reports/unified-9.0.29/PRUEFBERICHT.md +0 -30
  93. package/docs/reports/unified-9.0.29/raw/INDEX.json +0 -97
  94. package/docs/reports/unified-9.0.29/raw/tls-targeted-build-node22.log +0 -139
  95. package/docs/reports/unified-9.0.29/raw/tls-targeted-node24.log +0 -132
  96. package/docs/start/START_HIER_9.0.29.md +0 -22
  97. /package/docs/reports/{unified-9.0.29 → unified-9.0.30}/raw/node22-version.log +0 -0
  98. /package/docs/reports/{unified-9.0.29 → unified-9.0.30}/raw/node24-version.log +0 -0
  99. /package/docs/reports/{unified-9.0.29 → unified-9.0.30}/raw/npm-audit-runtime.json +0 -0
  100. /package/docs/reports/{unified-9.0.29/raw/tls-lint.log → unified-9.0.30/raw/split-lint.log} +0 -0
@@ -0,0 +1,184 @@
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/datapoint-picker.ts
10
+ * Quell-Hash: sha256:83c6734102e2a8d5ceb5c347e5e1077da84c74b1207f9a744abf3a8158feb51e
11
+ * Erzeugung: npm run sync:ts-runtime-executables
12
+ *
13
+ * Zweck:
14
+ * Diese JavaScript-Datei ist das ausführbare Build-Artefakt für lib/datapoint-picker.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.registerDatapointPicker = registerDatapointPicker;
26
+ const ephemeral_cache_1 = require("./ephemeral-cache");
27
+ const SEARCH_MAX_AGE_MS = 15000;
28
+ const TREE_MAX_AGE_MS = 30000;
29
+ const ALLOWED_TYPES = new Set(['boolean', 'number', 'string']);
30
+ const PREFERRED_PREFIXES = ['0_userdata.0.', 'alias.0.', 'javascript.0.'];
31
+ function csvFilter(value, maxItems, validator) {
32
+ if (value === undefined)
33
+ return new Set();
34
+ if (typeof value !== 'string' || !value || value.length > 1024)
35
+ return null;
36
+ const entries = value.split(',');
37
+ return entries.length <= maxItems && entries.every(validator) ? new Set(entries) : null;
38
+ }
39
+ /** Shares one idle-expiring state metadata index between the two installer views. */
40
+ function registerDatapointPicker(app, owner, requireDpDiscovery, time) {
41
+ let closed = false;
42
+ const snapshot = new ephemeral_cache_1.ExpiringSnapshot(async () => {
43
+ var _a;
44
+ if (closed)
45
+ throw new Error('EOS_UI_STOPPING');
46
+ const objects = (await owner.getForeignObjectsAsync?.('*', 'state')) || {};
47
+ if (closed)
48
+ throw new Error('EOS_UI_STOPPING');
49
+ const items = [];
50
+ for (const id of Object.keys(objects)) {
51
+ const common = objects[id]?.common;
52
+ if (!common)
53
+ continue;
54
+ const nameRaw = common.name || '';
55
+ const name = typeof nameRaw === 'string' ? nameRaw : JSON.stringify(nameRaw);
56
+ items.push({
57
+ id,
58
+ name,
59
+ role: common.role || '',
60
+ type: common.type || '',
61
+ unit: common.unit || '',
62
+ read: common.read === true,
63
+ write: common.write === true,
64
+ idLower: id.toLowerCase(),
65
+ nameLower: String(name).toLowerCase(),
66
+ });
67
+ }
68
+ items.sort((a, b) => a.idLower.localeCompare(b.idLower));
69
+ const makeNode = () => ({ children: Object.create(null), item: null });
70
+ const trie = makeNode();
71
+ for (const item of items) {
72
+ if (!item.id)
73
+ continue;
74
+ let node = trie;
75
+ for (const segment of item.id.split('.').filter(Boolean)) {
76
+ node = (_a = node.children)[segment] ?? (_a[segment] = makeNode());
77
+ }
78
+ node.item = item;
79
+ }
80
+ return { items, trie };
81
+ }, TREE_MAX_AGE_MS, time);
82
+ app.get('/api/smarthome/dpsearch', requireDpDiscovery, async (req, res) => {
83
+ try {
84
+ const qLower = String(req.query?.q || '').trim().toLowerCase();
85
+ const direction = req.query?.direction;
86
+ const types = csvFilter(req.query?.types, 3, value => ALLOWED_TYPES.has(value));
87
+ const roles = csvFilter(req.query?.roles, 16, value => /^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/.test(value));
88
+ if ((direction !== undefined && direction !== 'read' && direction !== 'write') || !types || !roles) {
89
+ return void res.status(400).json({ ok: false, error: 'EOS_DP_FILTER_INVALID' });
90
+ }
91
+ const requestedLimit = Number.parseInt(String(req.query?.limit || ''), 10);
92
+ const limit = Number.isFinite(requestedLimit) && requestedLimit > 0 ? Math.min(requestedLimit, 5000) : 200;
93
+ if (typeof owner.getForeignObjectsAsync !== 'function') {
94
+ owner.log.warn('SmartHomeConfig dpsearch: getForeignObjectsAsync not available');
95
+ return void res.json({ ok: false, error: 'datapoint search not supported' });
96
+ }
97
+ const { items } = await snapshot.get(false, SEARCH_MAX_AGE_MS);
98
+ const results = [];
99
+ const seen = new Set();
100
+ const matchesQuery = (item) => !qLower || item.idLower.includes(qLower) || item.nameLower.includes(qLower)
101
+ || (direction && typeof item.role === 'string' && item.role.toLowerCase().includes(qLower));
102
+ const pushItem = (item) => {
103
+ const { id, name, role, type, unit, read, write } = item;
104
+ if (!id || seen.has(id) || (direction && item[direction] !== true) || (types.size && !types.has(type)))
105
+ return;
106
+ seen.add(id);
107
+ results.push({ id, name, role, type, unit, read, write });
108
+ };
109
+ // Reserving the first matches by role keeps a useful result near the top of a large tree.
110
+ if (roles.size) {
111
+ for (const item of items) {
112
+ if (roles.has(item.role) && matchesQuery(item))
113
+ pushItem(item);
114
+ if (results.length >= limit)
115
+ return void res.json({ ok: true, results });
116
+ }
117
+ }
118
+ if (!qLower) {
119
+ for (const prefix of PREFERRED_PREFIXES) {
120
+ for (const item of items) {
121
+ if (!item.idLower.startsWith(prefix))
122
+ continue;
123
+ pushItem(item);
124
+ if (results.length >= limit)
125
+ return void res.json({ ok: true, results });
126
+ }
127
+ }
128
+ }
129
+ for (const item of items) {
130
+ if (matchesQuery(item))
131
+ pushItem(item);
132
+ if (results.length >= limit)
133
+ break;
134
+ }
135
+ res.json({ ok: true, results });
136
+ }
137
+ catch (error) {
138
+ owner.log.warn('SmartHomeConfig dpsearch error: ' + (error instanceof Error ? error.message : String(error)));
139
+ res.status(500).json({ ok: false, error: 'internal error' });
140
+ }
141
+ });
142
+ app.get(['/api/object/tree', '/api/smarthome/object/tree'], requireDpDiscovery, async (req, res) => {
143
+ try {
144
+ const prefix = String(req.query?.prefix || '').trim();
145
+ if (typeof owner.getForeignObjectsAsync !== 'function') {
146
+ return void res.status(500).json({ ok: false, error: 'getForeignObjectsAsync not available' });
147
+ }
148
+ const { trie } = await snapshot.get(false, TREE_MAX_AGE_MS);
149
+ const parts = prefix ? prefix.split('.').filter(Boolean) : [];
150
+ let node = trie;
151
+ for (const segment of parts) {
152
+ const child = node.children[segment];
153
+ if (!child)
154
+ return void res.json({ ok: true, prefix, children: [] });
155
+ node = child;
156
+ }
157
+ const labels = Object.keys(node.children).sort((a, b) => a.localeCompare(b));
158
+ const children = labels.map(label => {
159
+ const child = node.children[label];
160
+ const item = child?.item;
161
+ return {
162
+ id: prefix ? `${prefix}.${label}` : label,
163
+ label,
164
+ hasChildren: !!(child && Object.keys(child.children).length),
165
+ isState: !!item,
166
+ name: item ? item.name : '',
167
+ role: item ? item.role : '',
168
+ type: item ? item.type : '',
169
+ unit: item ? item.unit : '',
170
+ ...(item ? { read: item.read, write: item.write } : {}),
171
+ };
172
+ });
173
+ res.json({ ok: true, prefix, children });
174
+ }
175
+ catch (error) {
176
+ try {
177
+ owner.log.warn('object tree API error: ' + (error instanceof Error ? error.message : String(error)));
178
+ }
179
+ catch { /* response still required */ }
180
+ res.status(500).json({ ok: false, error: 'internal error' });
181
+ }
182
+ });
183
+ return { close() { closed = true; snapshot.close(); } };
184
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * AUTO-GENERATED RUNTIME FILE - NICHT MANUELL BEARBEITEN.
3
+ *
4
+ * Quelle: src-ts/runtime-executables/lib/eos-presentation-routes.ts
5
+ * Quell-Hash: sha256:ca555781f4f4e528219676909063058131cd7c6a90399408e5876e6e159b7020
6
+ * Erzeugung: npm run sync:ts-runtime-executables
7
+ *
8
+ * Zweck:
9
+ * Diese JavaScript-Datei ist das ausführbare Build-Artefakt für lib/eos-presentation-routes.js.
10
+ * Die fachliche Bearbeitung erfolgt ab 0.7.131 in der TypeScript-Quelle.
11
+ * Ab 0.7.132 sind doppelte Legacy-JS-Bäume wie .nwcore entfernt.
12
+ *
13
+ * Pflege-Regel:
14
+ * 1. Änderung zuerst in src-ts/runtime-executables/ vornehmen.
15
+ * 2. npm run sync:ts-runtime-executables ausführen.
16
+ * 3. npm run test:runtime-executables prüfen.
17
+ */
18
+ "use strict";
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.PRESENTATION_FILES = void 0;
21
+ exports.presentationRoute = presentationRoute;
22
+ exports.isPresentationRequest = isPresentationRequest;
23
+ /** Copyright (c) 2026 NexoWatt. Confidential and proprietary. */
24
+ const ui_access_policy_1 = require("./ui-access-policy");
25
+ const DATAPOINT_PICKER_ROUTES = new Set([
26
+ '/api/smarthome/dpsearch', '/api/smarthome/object/tree', '/api/object/tree',
27
+ ]);
28
+ exports.PRESENTATION_FILES = new Map([
29
+ ['/manifest.webmanifest', ['www/manifest.webmanifest', 'application/manifest+json']],
30
+ ['/sw.js', ['www/sw.js', 'application/javascript']],
31
+ ['/apple-touch-icon.png', ['www/apple-touch-icon.png', 'image/png']],
32
+ ['/apple-touch-icon-precomposed.png', ['www/assets/icons/nexowatt-180.png', 'image/png']],
33
+ ['/apple-touch-icon-180x180.png', ['www/assets/icons/nexowatt-180.png', 'image/png']],
34
+ ['/apple-touch-icon-180x180-precomposed.png', ['www/assets/icons/nexowatt-180.png', 'image/png']],
35
+ ['/favicon.ico', ['www/assets/icons/nexowatt-32.png', 'image/x-icon']],
36
+ ]);
37
+ /** A raw HTTP path must match this allowlist before crossing into the read-only process. */
38
+ function presentationRoute(method, url) {
39
+ if ((method !== 'GET' && method !== 'HEAD') || typeof url !== 'string')
40
+ return null;
41
+ const pathname = url.split(/[?#]/, 1)[0];
42
+ if (!pathname)
43
+ return null;
44
+ const canonical = (0, ui_access_policy_1.uiRequestPath)({ path: pathname });
45
+ // The three existing Express 4 picker routes also accept case variants and
46
+ // one trailing slash. Never pass percent/decode or traversal aliases here.
47
+ if ((canonical === pathname || canonical + '/' === pathname) && DATAPOINT_PICKER_ROUTES.has(canonical.toLowerCase()))
48
+ return 'picker';
49
+ if (canonical !== pathname)
50
+ return null;
51
+ if (pathname === '/')
52
+ return 'dashboard';
53
+ if (exports.PRESENTATION_FILES.has(pathname))
54
+ return 'file';
55
+ if (/^\/(?:assets|static)\//.test(pathname) && (0, ui_access_policy_1.isPublicUiRequest)({ method, path: pathname }))
56
+ return 'asset';
57
+ return null;
58
+ }
59
+ function isPresentationRequest(method, url) {
60
+ return presentationRoute(method, url) !== null;
61
+ }
@@ -0,0 +1,140 @@
1
+ /**
2
+ * AUTO-GENERATED RUNTIME FILE - NICHT MANUELL BEARBEITEN.
3
+ *
4
+ * Quelle: src-ts/runtime-executables/lib/eos-presentation.ts
5
+ * Quell-Hash: sha256:e93e16ad5cb445fc484dc6eefcad7022020e05b6fa0af7f426c74b3282f5653c
6
+ * Erzeugung: npm run sync:ts-runtime-executables
7
+ *
8
+ * Zweck:
9
+ * Diese JavaScript-Datei ist das ausführbare Build-Artefakt für lib/eos-presentation.js.
10
+ * Die fachliche Bearbeitung erfolgt ab 0.7.131 in der TypeScript-Quelle.
11
+ * Ab 0.7.132 sind doppelte Legacy-JS-Bäume wie .nwcore entfernt.
12
+ *
13
+ * Pflege-Regel:
14
+ * 1. Änderung zuerst in src-ts/runtime-executables/ vornehmen.
15
+ * 2. npm run sync:ts-runtime-executables ausführen.
16
+ * 3. npm run test:runtime-executables prüfen.
17
+ */
18
+ "use strict";
19
+ var __importDefault = (this && this.__importDefault) || function (mod) {
20
+ return (mod && mod.__esModule) ? mod : { "default": mod };
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ exports.createHostedRuntime = createHostedRuntime;
24
+ /** Copyright (c) 2026 NexoWatt. Confidential and proprietary. */
25
+ const node_path_1 = __importDefault(require("node:path"));
26
+ const datapoint_picker_1 = require("./datapoint-picker");
27
+ const eos_presentation_routes_1 = require("./eos-presentation-routes");
28
+ const hosted_http_boundary_1 = require("./hosted-http-boundary");
29
+ const runtime_proxy_html_1 = require("./runtime-proxy-html");
30
+ const express = require('express4');
31
+ const { centralAccess, centralLicenseSnapshot } = require('./hosted-adapter');
32
+ function canUse(access, capability) {
33
+ return access.authenticated === true && Array.isArray(access.capabilities) &&
34
+ (access.capabilities.includes('*') || access.capabilities.includes(capability));
35
+ }
36
+ function noStore(res) {
37
+ res.set({
38
+ 'Cache-Control': 'no-store, no-cache, must-revalidate, proxy-revalidate',
39
+ Pragma: 'no-cache',
40
+ Expires: '0',
41
+ });
42
+ }
43
+ /** Read-only UI. Browser input cannot invoke an operational or state-write handler here. */
44
+ function createHostedRuntime(owner, bridge) {
45
+ const root = node_path_1.default.resolve(__dirname, '..');
46
+ const migration = owner.config?.eosUiMigration;
47
+ const namespace = migration?.preserveNamespace === true && typeof migration.source === 'string' &&
48
+ /^nexowatt-ui\.\d+$/.test(migration.source) ? migration.source : owner.namespace;
49
+ const sendHtml = (0, runtime_proxy_html_1.createRuntimeFileSender)(root, namespace);
50
+ const app = express();
51
+ app.disable('x-powered-by');
52
+ app.use(async (req, res, next) => {
53
+ const route = (0, eos_presentation_routes_1.presentationRoute)(req.method, req.url);
54
+ if (!route)
55
+ return next();
56
+ res.set({
57
+ 'X-Content-Type-Options': 'nosniff',
58
+ 'X-Frame-Options': 'SAMEORIGIN',
59
+ 'Referrer-Policy': 'no-referrer',
60
+ 'Permissions-Policy': 'camera=(), microphone=(), geolocation=(), payment=(), usb=()',
61
+ 'Content-Security-Policy': "base-uri 'self'; object-src 'none'; frame-ancestors 'self'",
62
+ });
63
+ if (bridge.originAllowed(req) !== true) {
64
+ res.status(403).json({ ok: false, error: 'origin_forbidden', message: 'Zugriff von fremder Origin blockiert.' });
65
+ return;
66
+ }
67
+ if (route === 'asset' || route === 'file')
68
+ return next();
69
+ noStore(res);
70
+ try {
71
+ const access = await centralAccess(bridge, req);
72
+ if (access.role === 'none' || access.authenticated !== true) {
73
+ if (route === 'dashboard') {
74
+ const prefix = (0, runtime_proxy_html_1.runtimeProxyPrefix)(req, namespace) || '';
75
+ res.redirect(303, prefix + '/login.html?returnTo=' + encodeURIComponent(prefix + '/'));
76
+ }
77
+ else
78
+ res.status(401).json({ ok: false, error: 'authentication_required', mode: 'eos' });
79
+ return;
80
+ }
81
+ if (!canUse(access, 'frontend.open')) {
82
+ res.status(403).json({ ok: false, error: 'forbidden' });
83
+ return;
84
+ }
85
+ const license = centralLicenseSnapshot(bridge);
86
+ if (req.path.toLowerCase().startsWith('/api/smarthome/') && !license.grants.includes('smartHome')) {
87
+ res.status(403).json({ ok: false, error: 'EOS_FEATURE_LICENSE_REQUIRED' });
88
+ return;
89
+ }
90
+ if (!license.ok) {
91
+ res.status(403).type('html').send('<!doctype html><html lang="de"><meta charset="utf-8"><title>NexoWatt EOS – Lizenz</title><h1>EOS-Lizenz erforderlich</h1><p><a href="/nexowatt/license">Lizenz aktivieren</a></p></html>');
92
+ return;
93
+ }
94
+ next();
95
+ }
96
+ catch {
97
+ res.status(503).json({ ok: false, error: 'authentication_unavailable' });
98
+ }
99
+ });
100
+ const requireMapping = async (req, res, next) => {
101
+ const access = await centralAccess(bridge, req);
102
+ if (access.role === 'none' || access.authenticated !== true) {
103
+ res.status(401).json({ ok: false, error: 'unauthorized', message: 'Installer-/Admin-Anmeldung erforderlich.' });
104
+ return;
105
+ }
106
+ if (!canUse(access, 'mapping.edit')) {
107
+ res.status(403).json({ ok: false, error: 'forbidden', message: 'Diese Funktion ist für diese Rolle nicht freigegeben.' });
108
+ return;
109
+ }
110
+ next();
111
+ };
112
+ const picker = (0, datapoint_picker_1.registerDatapointPicker)(app, owner, requireMapping);
113
+ app.get('/', (req, res) => sendHtml(req, res, node_path_1.default.join(root, 'www', 'index.html')));
114
+ for (const [url, [file, type]] of eos_presentation_routes_1.PRESENTATION_FILES) {
115
+ app.get(url, (_req, res) => { res.type(type).sendFile(node_path_1.default.join(root, file)); });
116
+ }
117
+ app.get('/static/evcs-electrical-limits.js', (_req, res) => {
118
+ res.sendFile(node_path_1.default.join(root, 'lib', 'evcs-electrical-limits.js'));
119
+ });
120
+ const staticOptions = { index: false, redirect: false, dotfiles: 'deny' };
121
+ app.use('/static', express.static(node_path_1.default.join(root, 'www'), staticOptions));
122
+ app.use('/assets', express.static(node_path_1.default.join(root, 'www', 'assets'), staticOptions));
123
+ app.use((_error, _req, res, next) => {
124
+ if (res.headersSent)
125
+ return next(_error);
126
+ res.status(503).json({ ok: false, error: 'EOS_UI_UNAVAILABLE' });
127
+ });
128
+ const handle = (0, hosted_http_boundary_1.createHostedHttpHandler)(app);
129
+ let running = false;
130
+ return {
131
+ async start() { running = true; },
132
+ async stop() { running = false; picker.close(); },
133
+ handle(req, res, next) {
134
+ if (!running || !(0, eos_presentation_routes_1.presentationRoute)(req.method, req.url))
135
+ return next();
136
+ return handle(req, res, next);
137
+ },
138
+ status() { return { state: running ? 'ready' : 'stopped', active: running, canWrite: false, emsReady: false }; },
139
+ };
140
+ }
@@ -7,7 +7,7 @@
7
7
  * AUTO-GENERATED RUNTIME FILE - NICHT MANUELL BEARBEITEN.
8
8
  *
9
9
  * Quelle: src-ts/runtime-executables/lib/ephemeral-cache.ts
10
- * Quell-Hash: sha256:8836aeca081c6bfc69ef5afb57d1f392c51881d50958a2718febef6122a0acac
10
+ * Quell-Hash: sha256:726b8b689a45fd0422ce656823bf117ea83097c7fb136cf955953f82d90e4887
11
11
  * Erzeugung: npm run sync:ts-runtime-executables
12
12
  *
13
13
  * Zweck:
@@ -88,26 +88,29 @@ exports.EphemeralMap = EphemeralMap;
88
88
  class ExpiringSnapshot {
89
89
  constructor(load, ttlMs, time = clock) {
90
90
  this.load = load;
91
+ this.time = time;
91
92
  this.pending = null;
92
93
  this.closed = false;
93
94
  this.cache = new EphemeralMap(ttlMs, 1, time);
94
95
  }
95
96
  get retained() { return this.cache.has('snapshot'); }
96
97
  get loading() { return this.pending !== null; }
97
- get(force = false) {
98
+ get(force = false, maxAgeMs) {
98
99
  if (this.closed)
99
100
  return Promise.reject(new Error('EOS_UI_STOPPING'));
100
101
  // A refresh already in progress is newer than the previously cached snapshot.
101
102
  if (this.pending)
102
103
  return this.pending;
103
104
  const cached = !force ? this.cache.get('snapshot') : undefined;
104
- if (cached)
105
+ if (cached && (maxAgeMs === undefined || this.time.now() - cached.startedAt <= maxAgeMs)) {
105
106
  return Promise.resolve(cached.value);
107
+ }
106
108
  this.cache.clear();
109
+ const startedAt = this.time.now();
107
110
  const request = Promise.resolve().then(this.load).then(value => {
108
111
  if (this.closed)
109
112
  throw new Error('EOS_UI_STOPPING');
110
- this.cache.set('snapshot', { value });
113
+ this.cache.set('snapshot', { value, startedAt });
111
114
  return value;
112
115
  });
113
116
  this.pending = request;