From db05592400feb7217355c037997520c49f664beb Mon Sep 17 00:00:00 2001 From: Maxim Shishmarev Date: Tue, 28 Jul 2020 12:13:41 +1000 Subject: [PATCH] Address review comments --- js/modules/data.d.ts | 1 + ts/receiver/mediumGroups.ts | 1 - ts/session/medium_group/index.ts | 18 +++++++++++++++--- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/js/modules/data.d.ts b/js/modules/data.d.ts index 368b61f23..35a87b0f5 100644 --- a/js/modules/data.d.ts +++ b/js/modules/data.d.ts @@ -7,6 +7,7 @@ export type IdentityKey = { firstUse: boolean; verified: number; nonblockingApproval: boolean; + secretKey?: string; // found in medium groups }; export type PreKey = { diff --git a/ts/receiver/mediumGroups.ts b/ts/receiver/mediumGroups.ts index ca9f137de..021bdcb31 100644 --- a/ts/receiver/mediumGroups.ts +++ b/ts/receiver/mediumGroups.ts @@ -160,7 +160,6 @@ async function handleNewGroup( envelope: EnvelopePlus, groupUpdate: SignalService.MediumGroupUpdate ) { - window.log.error('mediumGroups.ts:hanldeNewGroup'); const { log } = window; const { diff --git a/ts/session/medium_group/index.ts b/ts/session/medium_group/index.ts index efcbfb283..1ce3d5197 100644 --- a/ts/session/medium_group/index.ts +++ b/ts/session/medium_group/index.ts @@ -296,8 +296,20 @@ async function getOrCreateSenderKeysForUpdate( } async function getGroupSecretKey(groupId: string): Promise { - const groupIdentity = await window.Signal.Data.getIdentityKeyById(groupId); - return new Uint8Array(fromHex(groupIdentity.secretKey)); + const groupIdentity = await Data.getIdentityKeyById(groupId); + if (!groupIdentity) { + throw new Error(`Could not load secret key for group ${groupId}`); + } + + const secretKey = groupIdentity.secretKey; + + if (!secretKey) { + throw new Error( + `Secret key not found in identity key record for group ${groupId}` + ); + } + + return new Uint8Array(fromHex(secretKey)); } async function syncMediumGroup(group: ConversationModel) { @@ -336,7 +348,7 @@ async function syncMediumGroup(group: ConversationModel) { }; // Note: we send this to our primary device which will in effect will send to - // our secondary devices, actually ignoring the primary + // our other devices, actually ignoring the current device await sendGroupUpdateForMedium( { joiningMembers: [ourPrimary.key] }, groupUpdate