CH-J Server Managerspráva serverů přes SSH
Menu
Vydané zdroje

CH-J Server Manager

Procházejte adresáře a soubory konkrétního vydání aplikace.

Stáhnout zdroje ZIP
CH-J Proprietary Software License 1.14

Zdroje jsou zveřejněny pod CH-J Proprietary Software License 1.14. Jejich dostupnost nemění licenční podmínky ani neposkytuje další oprávnění.

2,1 KB · 49 řádkůStáhnout soubor
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-256: c66a9c7f7d9cc06f0c35cf3a58838422523f7dd745e3a0ba24feb972ab875fe1

SHA-256 archivu: 5ac91caf4fa32a6fdb114f2430deed486fbe7489d5eea343d1f034169fafb5e0