Published source
Download source ZIP
CH-J Server Manager
Browse directories and files for a specific application release.
Source is provided under the CH-J Proprietary Software License 1.14. Its availability does not change the license terms or grant additional rights.
1
"use strict";3
const crypto = require("node:crypto");4
const fs = require("node:fs");5
const path = require("node:path");6
const { atomicWriteJson } = require("../storage/atomicFile");7
const { loadGuidanceDocuments } = require("./guidanceDocuments");9
const LICENSE_NAME = "CH-J Proprietary Software License";10
const LICENSE_VERSION = "1.14";12
class 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.sha25626
});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
}47
}49
module.exports = { LicenseAcceptance, LICENSE_NAME, LICENSE_VERSION };SHA-256: c66a9c7f7d9cc06f0c35cf3a58838422523f7dd745e3a0ba24feb972ab875fe1
Archive SHA-256: 5ac91caf4fa32a6fdb114f2430deed486fbe7489d5eea343d1f034169fafb5e0