Initial commit: license activation server (Ed25519)

Made-with: Cursor
This commit is contained in:
Ivan Fontosh
2026-04-19 17:58:51 +08:00
commit 4a0523f309
6 changed files with 262 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
/** Детерминированная JSON-сериализация для подписи (должна совпадать с `app/shared/license/canonicalJson.ts` в клиенте DNDGamePlayer). */
export function canonicalJson(value) {
if (value === null) return 'null';
const t = typeof value;
if (t === 'number') {
if (!Number.isFinite(value)) throw new TypeError('non-finite number in license payload');
return JSON.stringify(value);
}
if (t === 'string' || t === 'boolean') return JSON.stringify(value);
if (Array.isArray(value)) {
return `[${value.map((x) => canonicalJson(x)).join(',')}]`;
}
if (t === 'object') {
const keys = Object.keys(value).sort();
return `{${keys.map((k) => `${JSON.stringify(k)}:${canonicalJson(value[k])}`).join(',')}}`;
}
throw new TypeError(`unsupported type: ${t}`);
}