CH-J Server Managergestione server su SSH
Menu
Sorgente pubblicata

CH-J Server Manager

Sfoglia directory e file per una specifica release di applicazioni.

Scarica sorgente ZIP
CH-J / Server Manager 339 file
core-20261014T184258Z-3fbed0b93fdf Aggiunto: Data non registrata · Costruito:
File
licenseAcceptance.js Aggiunto: Data non registrata 2,1 KB · 49 righe
Scarica file
1"use strict";
3const crypto = require("node:crypto");
4const fs = require("node:fs");
5const path = require("node:path");
6const { atomicWriteJson } = require("../storage/atomicFile");
7const { loadGuidanceDocuments } = require("./guidanceDocuments");
9const LICENSE_NAME = "CH-J Proprietary Software License";
10const LICENSE_VERSION = "1.14";
12class LicenseAcceptance {
13 constructor({ storageRoot, licensePath, appVersion, buildId, docsRoot = path.resolve(__dirname, "../../../docs") }) {
14 this.filePath = path.join(storageRoot, "legal", "license-acceptance.json");
15 this.text = fs.readFileSync(licensePath, "utf8");
16 if (!/^CH-J\s+Proprietary Software License\s*\n\s*Version 1\.14\b/.test(this.text) ||
17 this.text.length < 10000 || !this.text.trimEnd().endsWith("End of License.")) {
18 throw new Error("The complete CH-J application license 1.14 is required.");
19 }
20 const guidance = loadGuidanceDocuments(docsRoot);
21 this.guidance = guidance.documents;
22 this.identity = Object.freeze({
23 license: LICENSE_NAME, licenseVersion: LICENSE_VERSION,
24 sha256: crypto.createHash("sha256").update(this.text).digest("hex"),
25 appVersion, buildId, guidanceSha256: guidance.sha256
26 });
27 }
29 isAccepted() {
30 try {
31 const record = JSON.parse(fs.readFileSync(this.filePath, "utf8"));
32 return record.schemaVersion === 1 && record.accepted === true && record.guidanceDisplayed === true &&
33 typeof record.acceptedAt === "string" && Number.isFinite(Date.parse(record.acceptedAt)) &&
34 Object.entries(this.identity).every(([key, value]) => record[key] === value);
35 } catch { return false; }
36 }
38 accept(payload) {
39 if (payload?.accepted !== true || payload?.sha256 !== this.identity.sha256 ||
40 payload?.guidanceShown !== true || payload?.guidanceSha256 !== this.identity.guidanceSha256) {
41 throw new Error("Explicit acceptance of the displayed license is required.");
42 }
43 atomicWriteJson(this.filePath, {
44 schemaVersion: 1, ...this.identity, accepted: true, guidanceDisplayed: true, acceptedAt: new Date().toISOString()
45 });
46 }
49module.exports = { LicenseAcceptance, LICENSE_NAME, LICENSE_VERSION };
SHA-256c66a9c7f7d9cc06f0c35cf3a58838422523f7dd745e3a0ba24feb972ab875fe1

CH-J Proprietary Software License 1.14 · La sorgente è fornita sotto CH-J Proprietary Software License 1.14. La sua disponibilità non modifica i termini di licenza o concede diritti aggiuntivi.

Archivio SHA-2563df08cf5e899262a6ce92d7ec2caf5c42b683f1f2b57055662b845ff7dde67a8