Защищенная синхронизация ключей и мета-данных групп

This commit is contained in:
RoyceDa
2026-02-24 14:33:47 +02:00
parent 8952fe43e8
commit bf057c14f4
4 changed files with 77 additions and 24 deletions

View File

@@ -162,26 +162,10 @@ export function useGroups() : {
const groupId = packet.getGroupId();
info(`Creating group with id ${groupId}`);
const encryptKey = generateRandomKey(64);
const secureKey = await encodeWithPassword(privatePlain, encryptKey);
let content = await encodeWithPassword(encryptKey, `$a=Group created`);
let plainMessage = await encodeWithPassword(privatePlain, `$a=Group created`);
await runQuery(`
INSERT INTO groups (account, group_id, title, description, key) VALUES (?, ?, ?, ?, ?)
`, [publicKey, groupId, title, description, secureKey]);
await runQuery(`
INSERT INTO messages
(from_public_key, to_public_key, content, timestamp, read, chacha_key, from_me, plain_message, account, message_id, delivered, attachments) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
`, [publicKey, "#group:" + groupId, content, Date.now(), 1, "", 1, plainMessage, publicKey, generateRandomKey(16),
DeliveredMessageState.DELIVERED
, '[]']);
updateDialog("#group:" + groupId);
updateGroupInformation({
groupId: groupId,
title: title,
description: description
});
setLoading(false);
navigate(`/main/chat/${prepareForRoute(groupId)}`);
/**
* После создания группы в нее необходимо зайти, в соотвествии с новым протоколом
*/
joinGroup(await constructGroupString(groupId, title, encryptKey, description));
});
}
@@ -201,9 +185,11 @@ export function useGroups() : {
const groupId = parsed.groupId;
const title = parsed.title;
const description = parsed.description;
const encodedGroupString = await encodeWithPassword(privatePlain, groupString);
const packet = new PacketGroupJoin();
packet.setGroupId(parsed.groupId);
packet.setGroupString(encodedGroupString);
send(packet);
setLoading(true);