@atelieruldetehnologii/node-red-custome-solutions 0.62.22

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 (107) hide show
  1. package/NOTICE +56 -0
  2. package/PROPRIETARY-LICENSE.txt +157 -0
  3. package/README.md +105 -0
  4. package/TERMS-AND-CONDITIONS.md +311 -0
  5. package/advantech-read/advantech-read.html +775 -0
  6. package/advantech-read/advantech-read.js +449 -0
  7. package/advantech-write/advantech-write.html +413 -0
  8. package/advantech-write/advantech-write.js +338 -0
  9. package/bess-control/bess-control.html +569 -0
  10. package/bess-control/bess-control.js +541 -0
  11. package/bess-control/lib/allocation.js +149 -0
  12. package/bess-control/lib/batteries.js +86 -0
  13. package/bess-control/lib/helpers.js +157 -0
  14. package/bess-control/lib/messages.js +131 -0
  15. package/bess-control/lib/runtime.js +156 -0
  16. package/carlo-gavazzi/carlo-gavazzi.html +4327 -0
  17. package/carlo-gavazzi/carlo-gavazzi.js +3081 -0
  18. package/control-export/control-export.html +3644 -0
  19. package/control-export/control-export.js +2192 -0
  20. package/control-reactive/control-reactive.html +3136 -0
  21. package/control-reactive/control-reactive.js +2124 -0
  22. package/fronius-emulator/README.md +258 -0
  23. package/fronius-emulator/fronius-emulator.html +170 -0
  24. package/fronius-emulator/fronius-emulator.js +520 -0
  25. package/fronius-emulator/lib/binary-codec.js +65 -0
  26. package/fronius-emulator/lib/fronius-register-map.js +185 -0
  27. package/fronius-emulator/lib/modbus-parser.js +61 -0
  28. package/fronius-emulator/lib/modbus-tcp-server.js +224 -0
  29. package/fronius-emulator/lib/validation.js +206 -0
  30. package/fronius-emulator/lib/virtual-meter.js +132 -0
  31. package/fronius-read/fronius-read.html +3944 -0
  32. package/fronius-read/fronius-read.js +1466 -0
  33. package/fronius-read/lib/inverter-profiles.js +711 -0
  34. package/fronius-read/lib/sunspec-core.js +303 -0
  35. package/fronius-read/lib/sunspec-model-parsers.js +845 -0
  36. package/fronius-write/fronius-write.html +1789 -0
  37. package/fronius-write/fronius-write.js +2531 -0
  38. package/influxdb/influxdb.html +1077 -0
  39. package/influxdb/influxdb.js +1487 -0
  40. package/janitza/janitza.html +2562 -0
  41. package/janitza/janitza.js +1500 -0
  42. package/janitza/lib/janitza-profiles.js +371 -0
  43. package/lib/a3-test-server.js +199 -0
  44. package/lib/adam-6000-profiles.js +173 -0
  45. package/lib/licensing/constants.js +103 -0
  46. package/lib/licensing/device-id.js +251 -0
  47. package/lib/licensing/errors.js +21 -0
  48. package/lib/licensing/license-client.js +377 -0
  49. package/lib/licensing/license-state.js +50 -0
  50. package/lib/licensing/node-guard.js +150 -0
  51. package/lib/licensing/package-integrity.js +167 -0
  52. package/lib/licensing/package-integrity.json +513 -0
  53. package/lib/licensing/public-key.pem +3 -0
  54. package/lib/licensing/public-key.pem.example +2 -0
  55. package/lib/licensing/public-keys.js +18 -0
  56. package/lib/licensing/storage.js +63 -0
  57. package/lib/licensing/token-verifier.js +84 -0
  58. package/lib/numbers.js +26 -0
  59. package/license/atelier-license.html +88 -0
  60. package/license/atelier-license.js +170 -0
  61. package/modbus-tcp-discover/modbus-tcp-discover.html +190 -0
  62. package/modbus-tcp-discover/modbus-tcp-discover.js +706 -0
  63. package/multi-battery/multi-battery.html +649 -0
  64. package/multi-battery/multi-battery.js +668 -0
  65. package/multi-grid/multi-grid.html +745 -0
  66. package/multi-grid/multi-grid.js +1392 -0
  67. package/multi-inverter/lib/engine-core.js +237 -0
  68. package/multi-inverter/multi-inverter.html +2674 -0
  69. package/multi-inverter/multi-inverter.js +1393 -0
  70. package/package.json +109 -0
  71. package/phoenix-contact/lib/eem-ma370-advanced.js +175 -0
  72. package/phoenix-contact/lib/eem-ma370.js +138 -0
  73. package/phoenix-contact/lib/integrations.js +149 -0
  74. package/phoenix-contact/lib/phoenix-contact-profile.js +35030 -0
  75. package/phoenix-contact/phoenix-contact.html +840 -0
  76. package/phoenix-contact/phoenix-contact.js +679 -0
  77. package/pv-generator/pv-generator.html +284 -0
  78. package/pv-generator/pv-generator.js +387 -0
  79. package/pylontech-read/pylontech-read.html +763 -0
  80. package/pylontech-read/pylontech-read.js +518 -0
  81. package/pylontech-write/pylontech-write.html +405 -0
  82. package/pylontech-write/pylontech-write.js +546 -0
  83. package/scada-aggregator/lib/aggregate.js +72 -0
  84. package/scada-aggregator/lib/groups.js +39 -0
  85. package/scada-aggregator/scada-aggregator.html +108 -0
  86. package/scada-aggregator/scada-aggregator.js +117 -0
  87. package/scada-server/lib/aggregator-map.js +58 -0
  88. package/scada-server/lib/encoding.js +235 -0
  89. package/scada-server/lib/modbus-server.js +492 -0
  90. package/scada-server/lib/object-path.js +18 -0
  91. package/scada-server/lib/register-map.js +288 -0
  92. package/scada-server/scada-server.html +1419 -0
  93. package/scada-server/scada-server.js +704 -0
  94. package/scripts/check-syntax.js +66 -0
  95. package/scripts/package-integrity.js +46 -0
  96. package/scripts/package-release.js +116 -0
  97. package/scripts/run-tests.js +2178 -0
  98. package/scripts/tgz-integrity.js +74 -0
  99. package/sma-read/lib/sunspec-core.js +83 -0
  100. package/sma-read/lib/sunspec-model-parsers.js +853 -0
  101. package/sma-read/sma-read.html +659 -0
  102. package/sma-read/sma-read.js +458 -0
  103. package/sma-write/sma-write.html +105 -0
  104. package/sma-write/sma-write.js +270 -0
  105. package/victron-read/lib/mqtt-state.js +176 -0
  106. package/victron-read/victron-read.html +1074 -0
  107. package/victron-read/victron-read.js +1222 -0
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const vm = require("vm");
6
+
7
+ const rootDir = path.resolve(__dirname, "..");
8
+ const ignoredSuffixes = [".save"];
9
+ const htmlScriptPattern = /<script\b[^>]*type=["']text\/javascript["'][^>]*>([\s\S]*?)<\/script>/gi;
10
+
11
+ function walk(dir, files) {
12
+ fs.readdirSync(dir, { withFileTypes: true }).forEach(function (entry) {
13
+ const fullPath = path.join(dir, entry.name);
14
+ if (entry.isDirectory()) {
15
+ walk(fullPath, files);
16
+ return;
17
+ }
18
+
19
+ if (
20
+ entry.isFile() &&
21
+ (entry.name.endsWith(".js") || entry.name.endsWith(".html")) &&
22
+ !ignoredSuffixes.some(function (suffix) { return entry.name.endsWith(suffix); })
23
+ ) {
24
+ files.push(fullPath);
25
+ }
26
+ });
27
+ }
28
+
29
+ const files = [];
30
+ walk(rootDir, files);
31
+
32
+ const failures = [];
33
+ files.forEach(function (file) {
34
+ try {
35
+ const source = fs.readFileSync(file, "utf8");
36
+
37
+ if (file.endsWith(".html")) {
38
+ htmlScriptPattern.lastIndex = 0;
39
+ let match;
40
+ let count = 0;
41
+ while ((match = htmlScriptPattern.exec(source)) !== null) {
42
+ count += 1;
43
+ new vm.Script(match[1], {
44
+ filename: file + "#script-" + count
45
+ });
46
+ }
47
+ return;
48
+ }
49
+
50
+ new vm.Script(source, { filename: file });
51
+ } catch (error) {
52
+ failures.push({
53
+ file: path.relative(rootDir, file),
54
+ message: error.message
55
+ });
56
+ }
57
+ });
58
+
59
+ if (failures.length) {
60
+ failures.forEach(function (failure) {
61
+ console.error(failure.file + ": " + failure.message);
62
+ });
63
+ process.exit(1);
64
+ }
65
+
66
+ console.log("OK: checked " + files.length + " JS/HTML files");
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ const crypto = require("crypto");
4
+ const fs = require("fs");
5
+ const path = require("path");
6
+ const { MANIFEST_PATH, canonicalJson, listProtectedPaths, manifestPayload, protectedPath } = require("../lib/licensing/package-integrity");
7
+
8
+ function decodePrivateKey(value) {
9
+ const normalized = String(value || "").trim().replace(/\\n/g, "\n");
10
+ if (!normalized) throw new Error("PACKAGE_INTEGRITY_PRIVATE_KEY or LICENSE_PRIVATE_KEY is required");
11
+ if (normalized.includes("BEGIN")) return crypto.createPrivateKey(normalized);
12
+ const decoded = Buffer.from(normalized, "base64");
13
+ const text = decoded.toString("utf8");
14
+ return text.includes("BEGIN") ? crypto.createPrivateKey(text) : crypto.createPrivateKey({ key: decoded, format: "der", type: "pkcs8" });
15
+ }
16
+
17
+ function createIntegrityManifest(packageRoot, privateKeyValue, keyId) {
18
+ const root = path.resolve(packageRoot);
19
+ const packageJson = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8").replace(/^\uFEFF/, ""));
20
+ const files = listProtectedPaths(root).map(function (relative) {
21
+ const bytes = fs.readFileSync(path.join(root, relative.replace(/\//g, path.sep)));
22
+ return { path: relative, sha256: crypto.createHash("sha256").update(bytes).digest("hex"), size: bytes.length };
23
+ });
24
+ const manifest = {
25
+ algorithm: "sha256",
26
+ files,
27
+ keyId: keyId || "v1",
28
+ package: { name: String(packageJson.name || ""), version: String(packageJson.version || "") },
29
+ schemaVersion: 1,
30
+ signatureAlgorithm: "Ed25519"
31
+ };
32
+ const signature = crypto.sign(null, Buffer.from(canonicalJson(manifestPayload(manifest)), "utf8"), decodePrivateKey(privateKeyValue)).toString("base64url");
33
+ const complete = Object.assign({}, manifest, { signature });
34
+ const target = path.join(root, MANIFEST_PATH.replace(/\//g, path.sep));
35
+ fs.mkdirSync(path.dirname(target), { recursive: true });
36
+ fs.writeFileSync(target, JSON.stringify(complete, null, 2) + "\n", "utf8");
37
+ return complete;
38
+ }
39
+
40
+ if (require.main === module) {
41
+ const root = path.resolve(process.argv[2] || path.join(__dirname, ".."));
42
+ const manifest = createIntegrityManifest(root, process.env.PACKAGE_INTEGRITY_PRIVATE_KEY || process.env.LICENSE_PRIVATE_KEY, process.env.PACKAGE_INTEGRITY_KEY_ID || "v1");
43
+ console.log("OK: signed " + manifest.files.length + " protected files in " + root);
44
+ }
45
+
46
+ module.exports = { createIntegrityManifest, decodePrivateKey, protectedPath };
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+
3
+ const fs = require("fs");
4
+ const path = require("path");
5
+ const { spawnSync } = require("child_process");
6
+ const crypto = require("crypto");
7
+ const { createIntegrityManifest } = require("./package-integrity");
8
+ const { signTgzIntegrity } = require("./tgz-integrity");
9
+
10
+ const root = path.resolve(__dirname, "..");
11
+ const workspace = path.resolve(root, "..", "..", "..", "..");
12
+ const versionsRoot = path.join(workspace, "Versiuni");
13
+ const manifest = JSON.parse(fs.readFileSync(path.join(root, "package.json"), "utf8").replace(/^\uFEFF/, ""));
14
+ const version = manifest.version;
15
+ const nodeOutput = path.join(versionsRoot, "Versiuni Noduri", version);
16
+ const stagingRoot = path.join(root, ".release-staging", version);
17
+ const pnpm = process.argv[2] || "pnpm.cmd";
18
+ const integrityPrivateKey = process.env.PACKAGE_INTEGRITY_PRIVATE_KEY || process.env.LICENSE_PRIVATE_KEY;
19
+ if (!integrityPrivateKey) throw new Error("PACKAGE_INTEGRITY_PRIVATE_KEY or LICENSE_PRIVATE_KEY is required to build signed releases");
20
+
21
+ function decodePrivateKey(value) {
22
+ const normalized = String(value || "").trim().replace(/\\n/g, "\n");
23
+ if (normalized.includes("BEGIN")) return crypto.createPrivateKey(normalized);
24
+ const decoded = Buffer.from(normalized, "base64");
25
+ const text = decoded.toString("utf8");
26
+ return text.includes("BEGIN") ? crypto.createPrivateKey(text) : crypto.createPrivateKey({ key: decoded, format: "der", type: "pkcs8" });
27
+ }
28
+
29
+ function configureIntegrityIdentity(packageRoot, privateKeyValue) {
30
+ const publicKey = crypto.createPublicKey(decodePrivateKey(privateKeyValue));
31
+ const pem = publicKey.export({ format: "pem", type: "spki" });
32
+ const fingerprint = crypto.createHash("sha256").update(publicKey.export({ format: "der", type: "spki" })).digest("hex");
33
+ const licensingRoot = path.join(packageRoot, "lib", "licensing");
34
+ fs.writeFileSync(path.join(licensingRoot, "public-key.pem"), pem, "utf8");
35
+ const verifierPath = path.join(licensingRoot, "package-integrity.js");
36
+ const source = fs.readFileSync(verifierPath, "utf8");
37
+ const rewritten = source.replace(/(v1:\s*")[a-f0-9]{64}(")/, "$1" + fingerprint + "$2");
38
+ if (rewritten === source && !source.includes('v1: "' + fingerprint + '"')) throw new Error("Cannot update the package integrity key pin");
39
+ fs.writeFileSync(verifierPath, rewritten, "utf8");
40
+ }
41
+
42
+ function runPack(cwd, output) {
43
+ const lowerPnpm = pnpm.toLowerCase();
44
+ const isCmd = lowerPnpm.endsWith(".cmd");
45
+ const pnpmModule = lowerPnpm.endsWith(".mjs") ? path.resolve(pnpm) : null;
46
+ const executable = isCmd ? (process.env.ComSpec || "cmd.exe") : (pnpmModule ? process.execPath : pnpm);
47
+ const packArgs = (pnpmModule ? [pnpmModule] : []).concat(["pack", "--out", output]);
48
+ const args = isCmd
49
+ ? ["/d", "/s", "/c", '"' + '"' + pnpm + '" pack --out "' + output + '""']
50
+ : packArgs;
51
+ const result = spawnSync(executable, args, {
52
+ cwd,
53
+ stdio: "inherit",
54
+ shell: false,
55
+ env: {
56
+ ...process.env,
57
+ pnpm_config_pm_on_fail: "ignore",
58
+ PATH: path.dirname(process.execPath) + path.delimiter + (process.env.PATH || "")
59
+ }
60
+ });
61
+ if (result.error) throw result.error;
62
+ if (result.status !== 0) throw new Error("pnpm pack failed with exit code " + result.status);
63
+ }
64
+
65
+ function safeRemove(target) {
66
+ const resolved = path.resolve(target);
67
+ const requiredPrefix = path.resolve(root, ".release-staging") + path.sep;
68
+ if (!resolved.startsWith(requiredPrefix)) {
69
+ throw new Error("Refuz eliminarea in afara staging-ului: " + resolved);
70
+ }
71
+ fs.rmSync(resolved, { recursive: true, force: true });
72
+ }
73
+
74
+ fs.mkdirSync(versionsRoot, { recursive: true });
75
+ fs.mkdirSync(nodeOutput, { recursive: true });
76
+ fs.mkdirSync(stagingRoot, { recursive: true });
77
+
78
+ const fullArchive = path.join(versionsRoot, manifest.name + "-" + version + ".tgz");
79
+ configureIntegrityIdentity(root, integrityPrivateKey);
80
+ createIntegrityManifest(root, integrityPrivateKey, process.env.PACKAGE_INTEGRITY_KEY_ID || "v1");
81
+ runPack(root, fullArchive);
82
+ signTgzIntegrity(fullArchive, integrityPrivateKey, process.env.PACKAGE_INTEGRITY_KEY_ID || "v1");
83
+
84
+ for (const [nodeName, entryPoint] of Object.entries(manifest["node-red"].nodes)) {
85
+ if (nodeName === "atelier-license") continue;
86
+ const nodeFolder = entryPoint.split("/")[0];
87
+ const stage = path.join(stagingRoot, nodeName);
88
+ safeRemove(stage);
89
+ fs.mkdirSync(stage, { recursive: true });
90
+ fs.cpSync(path.join(root, nodeFolder), path.join(stage, nodeFolder), { recursive: true });
91
+ fs.cpSync(path.join(root, "lib"), path.join(stage, "lib"), { recursive: true });
92
+ fs.cpSync(path.join(root, "license"), path.join(stage, "license"), { recursive: true });
93
+ fs.copyFileSync(path.join(root, "README.md"), path.join(stage, "README.md"));
94
+
95
+ const nodeManifest = {
96
+ name: manifest.name + "-" + nodeName,
97
+ version,
98
+ description: manifest.description + " - " + nodeName,
99
+ private: manifest.private,
100
+ license: manifest.license,
101
+ keywords: manifest.keywords,
102
+ engines: manifest.engines,
103
+ files: [nodeFolder + "/**/*", "license/**/*", "lib/**/*", "README.md", "package.json"],
104
+ dependencies: manifest.dependencies,
105
+ "node-red": { nodes: { "atelier-license": "license/atelier-license.js", [nodeName]: entryPoint } }
106
+ };
107
+ fs.writeFileSync(path.join(stage, "package.json"), JSON.stringify(nodeManifest, null, 2) + "\n", "utf8");
108
+ configureIntegrityIdentity(stage, integrityPrivateKey);
109
+ createIntegrityManifest(stage, integrityPrivateKey, process.env.PACKAGE_INTEGRITY_KEY_ID || "v1");
110
+ const archive = path.join(nodeOutput, nodeManifest.name + "-" + version + ".tgz");
111
+ runPack(stage, archive);
112
+ signTgzIntegrity(archive, integrityPrivateKey, process.env.PACKAGE_INTEGRITY_KEY_ID || "v1");
113
+ }
114
+
115
+ safeRemove(stagingRoot);
116
+ console.log("OK: release " + version + " -> " + fullArchive + " + " + (Object.keys(manifest["node-red"].nodes).length - 1) + " node archives");