Добавить лицензию CC0 1.0

This commit is contained in:
AidarKC
2026-11-16 23:50:28 +03:00
parent 548160f7f8
commit c477560632
39 changed files with 901 additions and 138 deletions
@@ -121,9 +121,17 @@ function parseTechBody(subType, body, frame) {
const reader = new Reader(body);
if (subType === 0) {
const magic = reader.text(5, 'HEADER magic');
if (magic !== 'SHiNE') throw new Error('Неправильная сигнатура HEADER');
const login = reader.textU8('HEADER login');
let license = null;
if (frame.version === 2) {
const marker = reader.text(15, 'HEADER license');
if (marker !== 'license:CC0-1.0') throw new Error('Неподдерживаемая лицензия HEADER');
license = 'CC0-1.0';
}
const initialBlockchainKey = bytesToBase64Url(reader.raw(32, 'initialBlockchainKey32'));
return { kind: 'header', magic, login, initialBlockchainKey };
if (reader.remaining() !== 0) throw new Error('Неожиданные данные после HEADER');
return { kind: 'header', magic, login, license, initialBlockchainKey };
}
if (subType === 1) {
const line = parseLinePrefix(reader);
@@ -230,7 +238,10 @@ function parseStatusBody(subType, body) {
}
function parseBody(type, subType, version, body, frame) {
if (version !== 1) return { kind: 'unsupported_version', rawBodyLength: body.length };
// Only TECH HEADER subtype 0 has a second version; all other records stay v1.
if (version !== 1 && !(type === 0 && subType === 0 && version === 2)) {
return { kind: 'unsupported_version', rawBodyLength: body.length };
}
if (type === 0) return parseTechBody(subType, body, frame);
if (type === 1) return parseTextBody(subType, body);
if (type === 2) return parseReactionBody(subType, body);