Обновить HEADER, теги CORE и конфигурацию основного сервера

This commit is contained in:
AidarKC
2026-12-04 00:12:50 +03:00
parent cc010a8eea
commit 3c91014469
40 changed files with 526 additions and 103 deletions
+5 -6
View File
@@ -544,15 +544,14 @@ function extractContactsFromDialogs(dialogs) {
return out;
}
export const HEADER_VERSION = 1;
// Временное значение до утверждения лицензии проекта.
export const HEADER_DEFAULT_LICENSE = '';
export const HEADER_VERSION = 2;
export const HEADER_DEFAULT_LICENSE = 'CC0-1.0';
function makeHeaderBodyBytes({ login, initialBlockchainKey32, license = '', accountType = 1, previousAccounts = [] }) {
function makeHeaderBodyBytes({ login, initialBlockchainKey32, license = 'CC0-1.0', accountType = 1, previousAccounts = [] }) {
const cleanLogin = String(login || '').trim();
const loginBytes = utf8Bytes(cleanLogin);
const licenseBytes = utf8Bytes(license);
if (licenseBytes.length > 255) throw new Error('HEADER license must be 0..255 UTF-8 bytes');
if (licenseBytes.length > 65535) throw new Error('HEADER license must be 0..65535 UTF-8 bytes');
const keyBytes = initialBlockchainKey32 instanceof Uint8Array
? initialBlockchainKey32
: new Uint8Array(initialBlockchainKey32 || []);
@@ -574,7 +573,7 @@ function makeHeaderBodyBytes({ login, initialBlockchainKey32, license = '', acco
int8Byte(loginBytes.length),
loginBytes,
identityBytes,
int8Byte(licenseBytes.length),
Uint8Array.of(licenseBytes.length >> 8, licenseBytes.length & 255),
licenseBytes,
keyBytes,
);
@@ -137,7 +137,7 @@ function parseTechBody(subType, body, frame) {
seen.add(previous.toLowerCase());
}
}
const license = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(reader.raw(reader.u8('HEADER license length'), 'HEADER license'));
const license = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(reader.raw(frame.version === 2 ? reader.u16('HEADER license length') : reader.u8('HEADER license length'), 'HEADER license'));
const initialBlockchainKey = bytesToBase64Url(reader.raw(32, 'initialBlockchainKey32'));
if (reader.remaining() !== 0) throw new Error('Неожиданные данные после HEADER');
return { kind: 'header', magic, login, license, accountType, previousAccounts, initialBlockchainKey };
@@ -247,7 +247,7 @@ function parseStatusBody(subType, body) {
}
function parseBody(type, subType, version, body, frame) {
if (version !== 1) {
if (version !== 1 && !(type === 0 && subType === 0 && version === 2)) {
return { kind: 'unsupported_version', rawBodyLength: body.length };
}
if (type === 0) return parseTechBody(subType, body, frame);
+2 -2
View File
@@ -80,7 +80,7 @@ export function coreTags(core) {
function checkEventLine(content, core) {
const { type, subType, version } = content;
const header = type === 0 && subType === 0;
if (version !== 1) throw new Error('Unsupported CONTENT version for creation');
if (version !== 1 && !(header && version === 2)) throw new Error('Unsupported CONTENT version for creation');
if (header !== (core.blockNumber === 0)) throw new Error('HEADER must be CORE #0');
const code = core.line?.lineCode;
if (type === 0 && !header) { if (code !== SHINE_CORE_LINE_TECH) throw new Error('Wrong TECH line'); }
@@ -128,7 +128,7 @@ export async function verifyCoreContentPair(coreItem, contentItem, expectedOwner
if (!c.signatureValid || !p.signatureValid || !equal(c.owner32, expectedOwner32) || !equal(p.owner32, expectedOwner32)) throw new Error('Invalid pair signature or owner');
const core = decodeCore(c.data), content = decodeContent(p.data);
// This is the canonical encoding produced by the UI. General Arweave import validation is D.
if (c.target.length || c.anchor.length || p.target.length || p.anchor.length || c.tagsCount !== coreTags(core).length || p.tagsCount !== 0 || !equal(c.rawTags, serializeAns104Tags(coreTags(core))) || !equal(p.rawTags, serializeAns104Tags([]))) throw new Error('Invalid pair tags');
if (c.target.length || c.anchor.length || p.target.length || p.anchor.length || c.tagsCount !== coreTags(core).length || p.tagsCount !== 0 || !(equal(c.rawTags, serializeAns104Tags(coreTags(core))) || equal(c.rawTags, serializeAns104Tags(coreTags(core).map(t => t.name === 'App' ? { ...t, value: 'test5599' } : t)))) || !equal(p.rawTags, serializeAns104Tags([]))) throw new Error('Invalid pair tags');
if (!equal(core.contentHash32, p.frameHashBytes) || !equal(core.contentDataItemId32, p.dataItemIdBytes)) throw new Error('CONTENT does not match CORE');
return { core, content, coreHash32: c.frameHashBytes, coreDataItemId32: c.dataItemIdBytes };
}
+1 -1
View File
@@ -7,7 +7,7 @@ export const SHINE_CHANNEL_TAG_NAME = 'c';
export const SHINE_TYPE_TAG_NAME = 't';
// Активная эпоха CORE/CONTENT.
export const SHINE_CORE_NAMESPACE = 'test5599';
export const SHINE_CORE_NAMESPACE = 'SHiNE';
export const SHINE_CORE_NUMBER_TAG_NAME = 'n';
export const SHINE_CORE_LINE_TAG_NAME = 'l';
export const SHINE_CORE_LINE_PROFILE = 2147483645;