remove all reference to closed group update v2

pull/1465/head
Audric Ackermann 4 years ago
parent 999e6fc712
commit 6e11c6db2e
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -168,7 +168,7 @@ module.exports = {
removeAllClosedGroupRatchets,
getAllEncryptionKeyPairsForGroupV2,
getAllEncryptionKeyPairsForGroup,
getLatestClosedGroupEncryptionKeyPair,
addClosedGroupEncryptionKeyPair,
removeAllClosedGroupEncryptionKeyPairs,
@ -1091,7 +1091,7 @@ async function updateToLokiSchemaVersion10(currentVersion, instance) {
console.log('updateToLokiSchemaVersion10: starting...');
await instance.run('BEGIN TRANSACTION;');
await createEncryptionKeyPairsForClosedGroupV2(instance);
await createEncryptionKeyPairsForClosedGroup(instance);
await instance.run(
`INSERT INTO loki_schema (
@ -1111,7 +1111,7 @@ async function updateToLokiSchemaVersion11(currentVersion, instance) {
console.log('updateToLokiSchemaVersion11: starting...');
await instance.run('BEGIN TRANSACTION;');
await updateExistingClosedGroupToClosedGroupV2(instance);
await updateExistingClosedGroupToClosedGroup(instance);
await instance.run(
`INSERT INTO loki_schema (
@ -3142,7 +3142,7 @@ async function removePrefixFromGroupConversations(instance) {
const CLOSED_GROUP_V2_KEY_PAIRS_TABLE = 'encryptionKeyPairsForClosedGroupV2';
async function createEncryptionKeyPairsForClosedGroupV2(instance) {
async function createEncryptionKeyPairsForClosedGroup(instance) {
await instance.run(
`CREATE TABLE ${CLOSED_GROUP_V2_KEY_PAIRS_TABLE} (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
@ -3171,7 +3171,7 @@ function remove05PrefixFromStringIfNeeded(str) {
return str;
}
async function updateExistingClosedGroupToClosedGroupV2(instance) {
async function updateExistingClosedGroupToClosedGroup(instance) {
// the migration is called only once, so all current groups not being open groups are v1 closed group.
const allClosedGroupV1 =
(await getAllClosedGroupConversations(instance)) || [];
@ -3214,7 +3214,7 @@ async function updateExistingClosedGroupToClosedGroupV2(instance) {
* The returned array is ordered based on the timestamp, the latest is at the end.
* @param {*} groupPublicKey string | PubKey
*/
async function getAllEncryptionKeyPairsForGroupV2(groupPublicKey) {
async function getAllEncryptionKeyPairsForGroup(groupPublicKey) {
const pubkeyAsString = groupPublicKey.key
? groupPublicKey.key
: groupPublicKey;
@ -3229,7 +3229,7 @@ async function getAllEncryptionKeyPairsForGroupV2(groupPublicKey) {
}
async function getLatestClosedGroupEncryptionKeyPair(groupPublicKey) {
const rows = await getAllEncryptionKeyPairsForGroupV2(groupPublicKey);
const rows = await getAllEncryptionKeyPairsForGroup(groupPublicKey);
if (!rows || rows.length === 0) {
return undefined;
}

@ -12,7 +12,7 @@ interface ConversationAttributes {
unreadCount: number;
active_at: number;
timestamp: number; // timestamp of what?
lastJoinedTimestamp: number; // ClosedGroupV2: last time we were added to this group
lastJoinedTimestamp: number; // ClosedGroup: last time we were added to this group
groupAdmins?: Array<string>;
isKickedFromGroup?: boolean;
avatarPath?: string;

@ -673,7 +673,7 @@
}
if (this.isMediumGroup()) {
const closedGroupV2ChatMessage = new libsession.Messages.Outgoing.ClosedGroupV2ChatMessage(
const closedGroupChatMessage = new libsession.Messages.Outgoing.ClosedGroupChatMessage(
{
chatMessage,
groupId: destination,
@ -683,7 +683,7 @@
// we need the return await so that errors are caught in the catch {}
return await libsession
.getMessageQueue()
.sendToGroup(closedGroupV2ChatMessage);
.sendToGroup(closedGroupChatMessage);
}
if (this.isClosedGroup()) {
@ -997,7 +997,7 @@
}
if (this.isMediumGroup()) {
await window.libsession.ClosedGroupV2.leaveClosedGroupV2(this.id);
await window.libsession.ClosedGroup.leaveClosedGroup(this.id);
} else {
throw new Error(
'Legacy group are not supported anymore. You need to create this group again.'

@ -930,7 +930,7 @@
// TODO should we handle medium groups message here too?
// Not sure there is the concept of retrySend for those
const closedGroupChatMessage = new libsession.Messages.Outgoing.ClosedGroupV2ChatMessage(
const closedGroupChatMessage = new libsession.Messages.Outgoing.ClosedGroupChatMessage(
{
identifier: this.id,
chatMessage,
@ -988,7 +988,7 @@
.sendToPubKey(recipientPubKey, chatMessage);
}
const closedGroupChatMessage = new libsession.Messages.Outgoing.ClosedGroupV2ChatMessage(
const closedGroupChatMessage = new libsession.Messages.Outgoing.ClosedGroupChatMessage(
{
chatMessage,
groupId: this.get('conversationId'),

@ -1,5 +1,5 @@
import { KeyPair } from '../../libtextsecure/libsignal-protocol';
import { HexKeyPair } from '../../ts/receiver/closedGroupsV2';
import { HexKeyPair } from '../../ts/receiver/closedGroups';
import { PubKey } from '../../ts/session/types';
import { ConversationType } from '../../ts/state/ducks/conversations';
import { Message } from '../../ts/types/Message';
@ -398,7 +398,7 @@ export function getMessagesWithFileAttachments(
// Sender Keys
export function removeAllClosedGroupRatchets(groupId: string): Promise<void>;
export function getAllEncryptionKeyPairsForGroupV2(
export function getAllEncryptionKeyPairsForGroup(
groupPublicKey: string | PubKey
): Promise<Array<HexKeyPair> | undefined>;
export function getLatestClosedGroupEncryptionKeyPair(

@ -193,7 +193,7 @@ module.exports = {
removeAllClosedGroupRatchets,
getAllEncryptionKeyPairsForGroupV2,
getAllEncryptionKeyPairsForGroup,
getLatestClosedGroupEncryptionKeyPair,
addClosedGroupEncryptionKeyPair,
removeAllClosedGroupEncryptionKeyPairs,
@ -705,14 +705,14 @@ async function updateSwarmNodesForPubkey(pubkey, snodeEdKeys) {
await channels.updateSwarmNodesForPubkey(pubkey, snodeEdKeys);
}
// Closed group v2
// Closed group
/**
* The returned array is ordered based on the timestamp, the latest is at the end.
* @param {*} groupPublicKey
*/
async function getAllEncryptionKeyPairsForGroupV2(groupPublicKey) {
return channels.getAllEncryptionKeyPairsForGroupV2(groupPublicKey);
async function getAllEncryptionKeyPairsForGroup(groupPublicKey) {
return channels.getAllEncryptionKeyPairsForGroup(groupPublicKey);
}
async function getLatestClosedGroupEncryptionKeyPair(groupPublicKey) {

@ -101,7 +101,7 @@
const groupId = this.convo.get('id');
const groupName = this.convo.get('name');
window.libsession.ClosedGroupV2.initiateGroupUpdate(
window.libsession.ClosedGroup.initiateGroupUpdate(
groupId,
groupName,
uniqMembers

@ -64,7 +64,7 @@
},
onSubmit(groupName, avatar) {
if (groupName !== this.groupName || avatar !== this.avatarPath) {
window.libsession.ClosedGroupV2.initiateGroupUpdate(
window.libsession.ClosedGroup.initiateGroupUpdate(
this.groupId,
groupName,
this.members,
@ -182,7 +182,7 @@
return;
}
window.libsession.ClosedGroupV2.initiateGroupUpdate(
window.libsession.ClosedGroup.initiateGroupUpdate(
this.groupId,
this.groupName,
filteredMemberes,

@ -2,7 +2,7 @@ import React from 'react';
import { ContactType } from './session/SessionMemberListItem';
import { ToastUtils } from '../session/utils';
import { createClosedGroupV2 } from '../receiver/closedGroupsV2';
import { createClosedGroup as createClosedGroupV2 } from '../receiver/closedGroups';
export class MessageView extends React.Component {
public render() {

@ -19,7 +19,7 @@ interface Props {
contactList: Array<any>;
isAdmin: boolean;
existingMembers: Array<String>;
admins: Array<String>; // used for closed group v2
admins: Array<String>; // used for closed group
i18n: any;
onSubmit: any;
@ -179,7 +179,7 @@ export class UpdateGroupMembersDialog extends React.Component<Props, State> {
if (selected.existingMember && admins.includes(selected.id)) {
window.log.warn(
`User ${selected.id} cannot be removed as they are the creator of the closed group v2.`
`User ${selected.id} cannot be removed as they are the creator of the closed group.`
);
ToastUtils.pushCannotRemoveCreatorFromGroup();
return;

@ -4,25 +4,25 @@ import { EnvelopePlus } from './types';
import { PubKey } from '../session/types';
import { toHex } from '../session/utils/String';
import { ConversationController } from '../session/conversations';
import * as ClosedGroupV2 from '../session/groupv2';
import * as ClosedGroup from '../session/group';
import { BlockedNumberController } from '../util';
import {
generateClosedGroupV2PublicKey,
generateClosedGroupPublicKey,
generateCurve25519KeyPairWithoutPrefix,
} from '../session/crypto';
import { getMessageQueue } from '../session';
import { decryptWithSessionProtocol } from './contentMessage';
import * as Data from '../../js/modules/data';
import {
ClosedGroupV2NewMessage,
ClosedGroupV2NewMessageParams,
} from '../session/messages/outgoing/content/data/groupv2/ClosedGroupV2NewMessage';
ClosedGroupNewMessage,
ClosedGroupNewMessageParams,
} from '../session/messages/outgoing/content/data/group/ClosedGroupNewMessage';
import { ECKeyPair } from './keypairs';
import { getOurNumber } from '../session/utils/User';
import { UserUtils } from '../session/utils';
export async function handleClosedGroupV2(
export async function handleClosedGroup(
envelope: EnvelopePlus,
groupUpdate: any
) {
@ -36,17 +36,17 @@ export async function handleClosedGroupV2(
}
if (type === Type.ENCRYPTION_KEY_PAIR) {
await handleKeyPairClosedGroupV2(envelope, groupUpdate);
await handleKeyPairClosedGroup(envelope, groupUpdate);
} else if (type === Type.NEW) {
await handleNewClosedGroupV2(envelope, groupUpdate);
await handleNewClosedGroup(envelope, groupUpdate);
} else if (type === Type.UPDATE) {
await handleUpdateClosedGroupV2(envelope, groupUpdate);
await handleUpdateClosedGroup(envelope, groupUpdate);
} else {
window.log.error('Unknown group update type v2: ', type);
window.log.error('Unknown group update type: ', type);
}
}
function sanityCheckNewGroupV2(
function sanityCheckNewGroup(
groupUpdate: SignalService.DataMessage.ClosedGroupControlMessage
): boolean {
// for a new group message, we need everything to be set
@ -54,74 +54,75 @@ function sanityCheckNewGroupV2(
const { log } = window;
if (!name?.length) {
log.warn('groupUpdateV2: name is empty');
log.warn('groupUpdate: name is empty');
return false;
}
if (!name?.length) {
log.warn('groupUpdateV2: name is empty');
log.warn('groupUpdate: name is empty');
return false;
}
if (!publicKey?.length) {
log.warn('groupUpdateV2: publicKey is empty');
log.warn('groupUpdate: publicKey is empty');
return false;
}
const hexGroupPublicKey = toHex(publicKey);
if (!PubKey.from(hexGroupPublicKey)) {
log.warn(
'groupUpdateV2: publicKey is not recognized as a valid pubkey',
'groupUpdate: publicKey is not recognized as a valid pubkey',
hexGroupPublicKey
);
return false;
}
if (!members?.length) {
log.warn('groupUpdateV2: members is empty');
log.warn('groupUpdate: members is empty');
return false;
}
if (members.some(m => m.length === 0)) {
log.warn('groupUpdateV2: one of the member pubkey is empty');
log.warn('groupUpdate: one of the member pubkey is empty');
return false;
}
if (!admins?.length) {
log.warn('groupUpdateV2: admins is empty');
log.warn('groupUpdate: admins is empty');
return false;
}
if (admins.some(a => a.length === 0)) {
log.warn('groupUpdateV2: one of the admins pubkey is empty');
log.warn('groupUpdate: one of the admins pubkey is empty');
return false;
}
if (!encryptionKeyPair?.publicKey?.length) {
log.warn('groupUpdateV2: keypair publicKey is empty');
log.warn('groupUpdate: keypair publicKey is empty');
return false;
}
if (!encryptionKeyPair?.privateKey?.length) {
log.warn('groupUpdateV2: keypair privateKey is empty');
log.warn('groupUpdate: keypair privateKey is empty');
return false;
}
return true;
}
async function handleNewClosedGroupV2(
async function handleNewClosedGroup(
envelope: EnvelopePlus,
groupUpdate: SignalService.DataMessage.ClosedGroupControlMessage
) {
const { log } = window;
if (
groupUpdate.type !== SignalService.DataMessage.ClosedGroupControlMessage.Type.NEW
groupUpdate.type !==
SignalService.DataMessage.ClosedGroupControlMessage.Type.NEW
) {
return;
}
if (!sanityCheckNewGroupV2(groupUpdate)) {
log.warn('Sanity check for newGroupV2 failed, dropping the message...');
if (!sanityCheckNewGroup(groupUpdate)) {
log.warn('Sanity check for newGroup failed, dropping the message...');
await removeFromCache(envelope);
return;
}
@ -146,7 +147,7 @@ async function handleNewClosedGroupV2(
await removeFromCache(envelope);
return;
}
// FIXME maybe we should handle an expiretimer here too? And on ClosedGroupV2 updates?
// FIXME maybe we should handle an expiretimer here too? And on ClosedGroup updates?
const maybeConvo = ConversationController.getInstance().get(groupId);
@ -166,7 +167,7 @@ async function handleNewClosedGroupV2(
maybeConvo.set('lastJoinedTimestamp', Date.now());
} else {
log.warn(
'Ignoring a closed group v2 message of type NEW: the conversation already exists'
'Ignoring a closed group message of type NEW: the conversation already exists'
);
await removeFromCache(envelope);
return;
@ -180,9 +181,9 @@ async function handleNewClosedGroupV2(
'group'
));
// ***** Creating a new group *****
log.info('Received a new ClosedGroupV2 of id:', groupId);
log.info('Received a new ClosedGroup of id:', groupId);
await ClosedGroupV2.addUpdateMessage(
await ClosedGroup.addUpdateMessage(
convo,
{ newName: name, joiningMembers: members },
'incoming'
@ -190,7 +191,7 @@ async function handleNewClosedGroupV2(
convo.set('name', name);
convo.set('members', members);
// mark a closed group v2 as a medium group.
// mark a closed group as a medium group.
// this field is used to poll for this groupPubKey on the swarm nodes, among other things
convo.set('is_medium_group', true);
convo.set('active_at', Date.now());
@ -215,7 +216,7 @@ async function handleNewClosedGroupV2(
await removeFromCache(envelope);
}
async function handleUpdateClosedGroupV2(
async function handleUpdateClosedGroup(
envelope: EnvelopePlus,
groupUpdate: SignalService.DataMessage.ClosedGroupControlMessage
) {
@ -228,14 +229,14 @@ async function handleUpdateClosedGroupV2(
const { name, members: membersBinary } = groupUpdate;
const { log } = window;
// for a closed group v2 update message, the envelope.source is the groupPublicKey
// for a closed group update message, the envelope.source is the groupPublicKey
const groupPublicKey = envelope.source;
const convo = ConversationController.getInstance().get(groupPublicKey);
if (!convo) {
log.warn(
'Ignoring a closed group v2 update message (INFO) for a non-existing group'
'Ignoring a closed group update message (INFO) for a non-existing group'
);
await removeFromCache(envelope);
return;
@ -265,15 +266,15 @@ async function handleUpdateClosedGroupV2(
const oldMembers = convo.get('members') || [];
if (!oldMembers.includes(envelope.senderIdentity)) {
log.error(
`Error: closed group v2: ignoring closed group update message from non-member. ${envelope.senderIdentity} is not a current member.`
`Error: closed group: ignoring closed group update message from non-member. ${envelope.senderIdentity} is not a current member.`
);
await removeFromCache(envelope);
return;
}
// NOTE: admins cannot change with closed groups v2
// NOTE: admins cannot change with closed groups
const members = membersBinary.map(toHex);
const diff = ClosedGroupV2.buildGroupDiff(convo, { name, members });
const diff = ClosedGroup.buildGroupDiff(convo, { name, members });
// Check whether we are still in the group
const ourNumber = await UserUtils.getOurNumber();
@ -282,9 +283,9 @@ async function handleUpdateClosedGroupV2(
if (wasCurrentUserRemoved) {
if (isCurrentUserAdmin) {
// cannot remove the admin from a v2 closed group
// cannot remove the admin from a closed group
log.info(
'Dropping message trying to remove the admin (us) from a v2 closed group'
'Dropping message trying to remove the admin (us) from a closed group'
);
await removeFromCache(envelope);
return;
@ -312,7 +313,7 @@ async function handleUpdateClosedGroupV2(
window.log.info(
'Handling group update: A user was removed and we are the admin. Generating and sending a new ECKeyPair'
);
await ClosedGroupV2.generateAndSendNewEncryptionKeyPair(
await ClosedGroup.generateAndSendNewEncryptionKeyPair(
groupPublicKey,
members
);
@ -324,7 +325,7 @@ async function handleUpdateClosedGroupV2(
diff.leavingMembers?.length ||
diff.newName
) {
await ClosedGroupV2.addUpdateMessage(convo, diff, 'incoming');
await ClosedGroup.addUpdateMessage(convo, diff, 'incoming');
}
convo.set('name', name);
@ -336,11 +337,11 @@ async function handleUpdateClosedGroupV2(
}
/**
* This function is called when we get a message with the new encryption keypair for a closed group v2.
* This function is called when we get a message with the new encryption keypair for a closed group.
* In this message, we have n-times the same keypair encoded with n being the number of current members.
* One of that encoded keypair is the one for us. We need to find it, decode it, and save it for use with this group.
*/
async function handleKeyPairClosedGroupV2(
async function handleKeyPairClosedGroup(
envelope: EnvelopePlus,
groupUpdate: SignalService.DataMessage.ClosedGroupControlMessage
) {
@ -450,7 +451,7 @@ async function handleKeyPairClosedGroupV2(
await removeFromCache(envelope);
}
export async function createClosedGroupV2(
export async function createClosedGroup(
groupName: string,
members: Array<string>
) {
@ -460,12 +461,10 @@ export async function createClosedGroupV2(
// Create Group Identity
// Generate the key pair that'll be used for encryption and decryption
// Generate the group's public key
const groupPublicKey = await generateClosedGroupV2PublicKey();
const groupPublicKey = await generateClosedGroupPublicKey();
const encryptionKeyPair = await generateCurve25519KeyPairWithoutPrefix();
if (!encryptionKeyPair) {
throw new Error(
'Could not create encryption keypair for new closed group v2'
);
throw new Error('Could not create encryption keypair for new closed group');
}
// Ensure the current uses' primary device is included in the member list
setOfMembers.add(ourNumber.key);
@ -489,12 +488,12 @@ export async function createClosedGroupV2(
};
// used for UI only, adding of a message to remind who is in the group and the name of the group
const groupDiff: ClosedGroupV2.GroupDiff = {
const groupDiff: ClosedGroup.GroupDiff = {
newName: groupName,
joiningMembers: listOfMembers,
};
const dbMessage = await ClosedGroupV2.addUpdateMessage(
const dbMessage = await ClosedGroup.addUpdateMessage(
convo,
groupDiff,
'outgoing'
@ -503,12 +502,12 @@ export async function createClosedGroupV2(
// be sure to call this before sending the message.
// the sending pipeline needs to know from GroupUtils when a message is for a medium group
await ClosedGroupV2.updateOrCreateClosedGroupV2(groupDetails);
await ClosedGroup.updateOrCreateClosedGroup(groupDetails);
convo.set('lastJoinedTimestamp', Date.now());
// Send a closed group update message to all members individually
const promises = listOfMembers.map(async m => {
const messageParams: ClosedGroupV2NewMessageParams = {
const messageParams: ClosedGroupNewMessageParams = {
groupId: groupPublicKey,
name: groupName,
members: listOfMembers,
@ -518,7 +517,7 @@ export async function createClosedGroupV2(
identifier: dbMessage.id,
expireTimer: 0,
};
const message = new ClosedGroupV2NewMessage(messageParams);
const message = new ClosedGroupNewMessage(messageParams);
window.log.info(
`Creating a new group and an encryptionKeyPair for group ${groupPublicKey}`
);

@ -31,12 +31,12 @@ export async function handleContentMessage(envelope: EnvelopePlus) {
}
}
async function decryptForClosedGroupV2(
async function decryptForClosedGroup(
envelope: EnvelopePlus,
ciphertext: ArrayBuffer
) {
// case .closedGroupCiphertext: for ios
window.log.info('received closed group v2 message');
window.log.info('received closed group message');
try {
const hexEncodedGroupPublicKey = envelope.source;
if (!GroupUtils.isMediumGroup(PubKey.cast(hexEncodedGroupPublicKey))) {
@ -45,7 +45,7 @@ async function decryptForClosedGroupV2(
);
throw new Error('Invalid group public key'); // invalidGroupPublicKey
}
const encryptionKeyPairs = await Data.getAllEncryptionKeyPairsForGroupV2(
const encryptionKeyPairs = await Data.getAllEncryptionKeyPairsForGroup(
hexEncodedGroupPublicKey
);
const encryptionKeyPairsCount = encryptionKeyPairs?.length;
@ -78,7 +78,7 @@ async function decryptForClosedGroupV2(
keyIndex++;
} catch (e) {
window.log.info(
`Failed to decrypt closed group v2 with key index ${keyIndex}. We have ${encryptionKeyPairs.length} keys to try left.`
`Failed to decrypt closed group with key index ${keyIndex}. We have ${encryptionKeyPairs.length} keys to try left.`
);
}
} while (encryptionKeyPairs.length > 0);
@ -86,10 +86,10 @@ async function decryptForClosedGroupV2(
if (!decryptedContent) {
await removeFromCache(envelope);
throw new Error(
`Could not decrypt message for closed group v2 with any of the ${encryptionKeyPairsCount} keypairs.`
`Could not decrypt message for closed group with any of the ${encryptionKeyPairsCount} keypairs.`
);
}
window.log.info('ClosedGroupV2 Message decrypted successfully.');
window.log.info('ClosedGroup Message decrypted successfully.');
const ourDevicePubKey = await UserUtils.getCurrentDevicePubKey();
if (
@ -98,7 +98,7 @@ async function decryptForClosedGroupV2(
) {
await removeFromCache(envelope);
window.log.info(
'Dropping message from our current device after decrypt for closed group v2'
'Dropping message from our current device after decrypt for closed group'
);
return null;
}
@ -115,8 +115,8 @@ async function decryptForClosedGroupV2(
}
/**
* This function can be called to decrypt a keypair wrapper for a closed group update v2
* or a message sent to a closed group v2.
* This function can be called to decrypt a keypair wrapper for a closed group update
* or a message sent to a closed group.
*
* We do not unpad the result here, as in the case of the keypair wrapper, there is not padding.
* Instead, it is the called who needs to unpad() the content.
@ -125,7 +125,7 @@ export async function decryptWithSessionProtocol(
envelope: EnvelopePlus,
ciphertextObj: ArrayBuffer,
x25519KeyPair: ECKeyPair,
isClosedGroupV2?: boolean
isClosedGroup?: boolean
): Promise<ArrayBuffer> {
const recipientX25519PrivateKey = x25519KeyPair.privateKeyData;
const hex = toHex(new Uint8Array(x25519KeyPair.publicKeyData));
@ -186,7 +186,7 @@ export async function decryptWithSessionProtocol(
}
// set the sender identity on the envelope itself.
if (isClosedGroupV2) {
if (isClosedGroup) {
envelope.senderIdentity = `05${toHex(senderX25519PublicKey)}`;
} else {
envelope.source = `05${toHex(senderX25519PublicKey)}`;
@ -255,7 +255,7 @@ async function doDecrypt(
switch (envelope.type) {
// Only UNIDENTIFIED_SENDER and CLOSED_GROUP_CIPHERTEXT are supported
case SignalService.Envelope.Type.CLOSED_GROUP_CIPHERTEXT:
return decryptForClosedGroupV2(envelope, ciphertext);
return decryptForClosedGroup(envelope, ciphertext);
case SignalService.Envelope.Type.UNIDENTIFIED_SENDER: {
return decryptUnidentifiedSender(envelope, ciphertext);
}

@ -12,7 +12,7 @@ import { StringUtils, UserUtils } from '../session/utils';
import { DeliveryReceiptMessage } from '../session/messages/outgoing';
import { getMessageQueue } from '../session';
import { ConversationController } from '../session/conversations';
import { handleClosedGroupV2 } from './closedGroupsV2';
import { handleClosedGroup } from './closedGroups';
import { isUs } from '../session/utils/User';
export async function updateProfile(
@ -244,7 +244,6 @@ function isBodyEmpty(body: string) {
return _.isEmpty(body);
}
export async function handleDataMessage(
envelope: EnvelopePlus,
dataMessage: SignalService.IDataMessage
@ -252,7 +251,7 @@ export async function handleDataMessage(
window.log.info('data message from', getEnvelopeId(envelope));
if (dataMessage.closedGroupControlMessage) {
await handleClosedGroupV2(envelope, dataMessage.closedGroupControlMessage);
await handleClosedGroup(envelope, dataMessage.closedGroupControlMessage);
return;
}

@ -6,7 +6,7 @@ export const TTL_DEFAULT = {
DEVICE_UNPAIRING: 4 * DAYS,
TYPING_MESSAGE: 20 * SECONDS,
REGULAR_MESSAGE: 2 * DAYS,
ENCRYPTION_PAIR_V2_GROUP: 4 * DAYS,
ENCRYPTION_PAIR_GROUP: 4 * DAYS,
};
// User Interface

@ -60,10 +60,10 @@ export async function encrypt(
) {
throw new Error(`Invalid encryption type:${encryptionType}`);
}
const encryptForClosedGroupV2 = encryptionType === EncryptionType.ClosedGroup;
const encryptForClosedGroup = encryptionType === EncryptionType.ClosedGroup;
const plainText = padPlainTextBuffer(plainTextBuffer);
if (encryptForClosedGroupV2) {
if (encryptForClosedGroup) {
window?.log?.info(
'Encrypting message with SessionProtocol and envelope type is CLOSED_GROUP_CIPHERTEXT'
);
@ -80,14 +80,14 @@ export async function encrypt(
// the exports is to reference the exported function, so when we stub it during test, we stub the one called here
const cipherTextClosedGroupV2 = await exports.encryptUsingSessionProtocol(
const cipherTextClosedGroup = await exports.encryptUsingSessionProtocol(
hexPubFromECKeyPair,
plainText
);
return {
envelopeType: CLOSED_GROUP_CIPHERTEXT,
cipherText: cipherTextClosedGroupV2,
cipherText: cipherTextClosedGroup,
};
}

@ -28,10 +28,10 @@ export const concatUInt8Array = (...args: Array<Uint8Array>): Uint8Array => {
/**
* Returns a generated curve25519 hex public key being of length 66 and starting with 05.
* For a closed group v2, we have one publicKey (with prefix) used for polling (this function),
* For a closed group, we have one publicKey (with prefix) used for polling (this function),
* and one keypair without prefix used for encoding of the messages (function generateCurve25519KeyPairWithoutPrefix).
*/
export async function generateClosedGroupV2PublicKey() {
export async function generateClosedGroupPublicKey() {
const sodium = await getSodium();
const ed25519KeyPair = sodium.crypto_sign_keypair();

@ -10,11 +10,11 @@ import { ConversationController } from '../conversations';
import { updateOpenGroup } from '../../receiver/openGroups';
import { getMessageQueue } from '../instance';
import {
ClosedGroupV2EncryptionPairMessage,
ClosedGroupV2NewMessage,
ClosedGroupV2UpdateMessage,
ClosedGroupEncryptionPairMessage,
ClosedGroupNewMessage,
ClosedGroupUpdateMessage,
ExpirationTimerUpdateMessage,
} from '../messages/outgoing/';
} from '../messages/outgoing';
import uuid from 'uuid';
import { SignalService } from '../../protobuf';
import { generateCurve25519KeyPairWithoutPrefix } from '../crypto';
@ -104,7 +104,7 @@ export async function initiateGroupUpdate(
const diff = buildGroupDiff(convo, groupDetails);
await updateOrCreateClosedGroupV2(groupDetails);
await updateOrCreateClosedGroup(groupDetails);
if (avatar) {
// would get to download this file on each client in the group
@ -122,7 +122,7 @@ export async function initiateGroupUpdate(
const dbMessage = await addUpdateMessage(convo, diff, 'outgoing');
window.getMessageController().register(dbMessage.id, dbMessage);
await sendGroupUpdateForClosedV2(convo, diff, updateObj, dbMessage.id);
await sendGroupUpdateForClosed(convo, diff, updateObj, dbMessage.id);
}
export async function addUpdateMessage(
@ -194,7 +194,7 @@ export function buildGroupDiff(
return groupDiff;
}
export async function updateOrCreateClosedGroupV2(details: GroupInfo) {
export async function updateOrCreateClosedGroup(details: GroupInfo) {
const { id } = details;
const conversation = await ConversationController.getInstance().getOrCreateAndWait(
@ -261,13 +261,13 @@ export async function updateOrCreateClosedGroupV2(details: GroupInfo) {
});
}
export async function leaveClosedGroupV2(groupId: string) {
export async function leaveClosedGroup(groupId: string) {
window.SwarmPolling.removePubkey(groupId);
const convo = ConversationController.getInstance().get(groupId);
if (!convo) {
window.log.error('Cannot leave non-existing v2 group');
window.log.error('Cannot leave non-existing group');
return;
}
const ourNumber = await UserUtils.getOurNumber();
@ -279,7 +279,7 @@ export async function leaveClosedGroupV2(groupId: string) {
// for now, a destroyed group is one with those 2 flags set to true.
// FIXME audric, add a flag to conversation model when a group is destroyed
if (isCurrentUserAdmin) {
window.log.info('Admin left a closed group v2. We need to destroy it');
window.log.info('Admin left a closed group. We need to destroy it');
convo.set({ left: true });
members = [];
} else {
@ -305,7 +305,7 @@ export async function leaveClosedGroupV2(groupId: string) {
admins: convo.get('groupAdmins'),
};
await sendGroupUpdateForClosedV2(
await sendGroupUpdateForClosed(
convo,
{ leavingMembers: [ourNumber.key] },
groupUpdate,
@ -313,7 +313,7 @@ export async function leaveClosedGroupV2(groupId: string) {
);
}
export async function sendGroupUpdateForClosedV2(
export async function sendGroupUpdateForClosed(
convo: ConversationModel,
diff: MemberChanges,
groupUpdate: GroupInfo,
@ -356,7 +356,7 @@ export async function sendGroupUpdateForClosedV2(
}
// Send the update to the group
const mainClosedGroupUpdate = new ClosedGroupV2UpdateMessage({
const mainClosedGroupUpdate = new ClosedGroupUpdateMessage({
timestamp: Date.now(),
groupId,
name: groupName,
@ -393,7 +393,7 @@ export async function sendGroupUpdateForClosedV2(
if (newMembers.length) {
// Send closed group update messages to any new members individually
const newClosedGroupUpdate = new ClosedGroupV2NewMessage({
const newClosedGroupUpdate = new ClosedGroupNewMessage({
timestamp: Date.now(),
name: groupName,
groupId,
@ -404,7 +404,7 @@ export async function sendGroupUpdateForClosedV2(
expireTimer: expireTimerToShare,
});
// if an expiretimer in this ClosedGroupV2 already, send it in another message
// if an expiretimer in this ClosedGroup already, send it in another message
// if an expire timer is set, we have to send it to the joining members
let expirationTimerMessage: ExpirationTimerUpdateMessage | undefined;
if (expireTimer && expireTimer > 0) {
@ -455,7 +455,7 @@ export async function generateAndSendNewEncryptionKeyPair(
}
if (!groupConvo.isMediumGroup()) {
window.log.warn(
'generateAndSendNewEncryptionKeyPair: conversation not a closed group v2',
'generateAndSendNewEncryptionKeyPair: conversation not a closed group',
groupPublicKey
);
return;
@ -478,10 +478,12 @@ export async function generateAndSendNewEncryptionKeyPair(
);
return;
}
const proto = new SignalService.DataMessage.ClosedGroupControlMessage.KeyPair({
privateKey: newKeyPair?.privateKeyData,
publicKey: newKeyPair?.publicKeyData,
});
const proto = new SignalService.DataMessage.ClosedGroupControlMessage.KeyPair(
{
privateKey: newKeyPair?.privateKeyData,
publicKey: newKeyPair?.publicKeyData,
}
);
const plaintext = SignalService.DataMessage.ClosedGroupControlMessage.KeyPair.encode(
proto
).finish();
@ -493,16 +495,18 @@ export async function generateAndSendNewEncryptionKeyPair(
PubKey.cast(pubkey),
plaintext
);
return new SignalService.DataMessage.ClosedGroupControlMessage.KeyPairWrapper({
encryptedKeyPair: ciphertext,
publicKey: fromHexToArray(pubkey),
});
return new SignalService.DataMessage.ClosedGroupControlMessage.KeyPairWrapper(
{
encryptedKeyPair: ciphertext,
publicKey: fromHexToArray(pubkey),
}
);
})
);
const expireTimerToShare = groupConvo.get('expireTimer') || 0;
const keypairsMessage = new ClosedGroupV2EncryptionPairMessage({
const keypairsMessage = new ClosedGroupEncryptionPairMessage({
groupId: toHex(groupId),
timestamp: Date.now(),
encryptedKeyPairs: wrappers,
@ -511,7 +515,7 @@ export async function generateAndSendNewEncryptionKeyPair(
const messageSentCallback = async () => {
window.log.info(
`KeyPairMessage for ClosedGroupV2 ${groupPublicKey} is sent. Saving the new encryptionKeyPair.`
`KeyPairMessage for ClosedGroup ${groupPublicKey} is sent. Saving the new encryptionKeyPair.`
);
// tslint:disable-next-line: no-non-null-assertion

@ -4,7 +4,7 @@ import * as Types from './types';
import * as Utils from './utils';
import * as Sending from './sending';
import * as Constants from './constants';
import * as ClosedGroupV2 from './groupv2';
import * as ClosedGroup from './group';
export * from './instance';
@ -15,5 +15,5 @@ export {
Types,
Sending,
Constants,
ClosedGroupV2,
ClosedGroup,
};

@ -35,7 +35,7 @@ export class ExpirationTimerUpdateMessage extends DataMessage {
data.flags = SignalService.DataMessage.Flags.EXPIRATION_TIMER_UPDATE;
// FIXME we shouldn't need this once android recieving refactor is done.
// the envelope stores the groupId for a closed group v2 already.
// the envelope stores the groupId for a closed group already.
if (this.groupId) {
const groupMessage = new SignalService.GroupContext();
const groupIdWithPrefix = PubKey.addTextSecurePrefixIfNeeded(

@ -1,20 +1,20 @@
import { SignalService } from '../../../../../../protobuf';
import { ChatMessage } from '../ChatMessage';
import { ClosedGroupV2Message } from './ClosedGroupV2Message';
import { ClosedGroupMessage } from './ClosedGroupMessage';
import { PubKey } from '../../../../../types';
import { Constants } from '../../../../..';
import { StringUtils } from '../../../../../utils';
interface ClosedGroupV2ChatMessageParams {
interface ClosedGroupChatMessageParams {
identifier?: string;
groupId: string | PubKey;
chatMessage: ChatMessage;
}
export class ClosedGroupV2ChatMessage extends ClosedGroupV2Message {
export class ClosedGroupChatMessage extends ClosedGroupMessage {
private readonly chatMessage: ChatMessage;
constructor(params: ClosedGroupV2ChatMessageParams) {
constructor(params: ClosedGroupChatMessageParams) {
super({
timestamp: params.chatMessage.timestamp,
identifier: params.identifier ?? params.chatMessage.identifier,

@ -1,23 +1,23 @@
import { Constants } from '../../../../..';
import { SignalService } from '../../../../../../protobuf';
import {
ClosedGroupV2Message,
ClosedGroupV2MessageParams,
} from './ClosedGroupV2Message';
ClosedGroupMessage,
ClosedGroupMessageParams,
} from './ClosedGroupMessage';
interface ClosedGroupV2EncryptionPairMessageParams
extends ClosedGroupV2MessageParams {
interface ClosedGroupEncryptionPairMessageParams
extends ClosedGroupMessageParams {
encryptedKeyPairs: Array<
SignalService.DataMessage.ClosedGroupControlMessage.KeyPairWrapper
>;
}
export class ClosedGroupV2EncryptionPairMessage extends ClosedGroupV2Message {
export class ClosedGroupEncryptionPairMessage extends ClosedGroupMessage {
private readonly encryptedKeyPairs: Array<
SignalService.DataMessage.ClosedGroupControlMessage.KeyPairWrapper
>;
constructor(params: ClosedGroupV2EncryptionPairMessageParams) {
constructor(params: ClosedGroupEncryptionPairMessageParams) {
super({
timestamp: params.timestamp,
identifier: params.identifier,
@ -50,6 +50,6 @@ export class ClosedGroupV2EncryptionPairMessage extends ClosedGroupV2Message {
}
public ttl(): number {
return Constants.TTL_DEFAULT.ENCRYPTION_PAIR_V2_GROUP;
return Constants.TTL_DEFAULT.ENCRYPTION_PAIR_GROUP;
}
}

@ -3,16 +3,16 @@ import { MessageParams } from '../../../Message';
import { SignalService } from '../../../../../../protobuf';
import { PubKey } from '../../../../../types/PubKey';
export interface ClosedGroupV2MessageParams extends MessageParams {
export interface ClosedGroupMessageParams extends MessageParams {
groupId: string | PubKey;
expireTimer: number;
}
export abstract class ClosedGroupV2Message extends DataMessage {
export abstract class ClosedGroupMessage extends DataMessage {
public readonly groupId: PubKey;
public readonly expireTimer: number;
constructor(params: ClosedGroupV2MessageParams) {
constructor(params: ClosedGroupMessageParams) {
super({
timestamp: params.timestamp,
identifier: params.identifier,

@ -1,26 +1,25 @@
import { SignalService } from '../../../../../../protobuf';
import {
ClosedGroupV2Message,
ClosedGroupV2MessageParams,
} from './ClosedGroupV2Message';
ClosedGroupMessage,
ClosedGroupMessageParams,
} from './ClosedGroupMessage';
import { fromHexToArray } from '../../../../../utils/String';
import { ECKeyPair } from '../../../../../../receiver/keypairs';
export interface ClosedGroupV2NewMessageParams
extends ClosedGroupV2MessageParams {
export interface ClosedGroupNewMessageParams extends ClosedGroupMessageParams {
name: string;
members: Array<string>;
admins: Array<string>;
keypair: ECKeyPair;
}
export class ClosedGroupV2NewMessage extends ClosedGroupV2Message {
export class ClosedGroupNewMessage extends ClosedGroupMessage {
private readonly name: string;
private readonly members: Array<string>;
private readonly admins: Array<string>;
private readonly keypair: ECKeyPair;
constructor(params: ClosedGroupV2NewMessageParams) {
constructor(params: ClosedGroupNewMessageParams) {
super({
timestamp: params.timestamp,
identifier: params.identifier,
@ -39,7 +38,7 @@ export class ClosedGroupV2NewMessage extends ClosedGroupV2Message {
throw new Error('Members must be set');
}
// Assert that every admins is a member
if (!ClosedGroupV2Message.areAdminsMembers(params.admins, params.members)) {
if (!ClosedGroupMessage.areAdminsMembers(params.admins, params.members)) {
throw new Error('Admins must all be members of the group');
}
if (!params.name || params.name.length === 0) {
@ -67,8 +66,12 @@ export class ClosedGroupV2NewMessage extends ClosedGroupV2Message {
);
dataMessage.closedGroupControlMessage.name = this.name;
dataMessage.closedGroupControlMessage.admins = this.admins.map(fromHexToArray);
dataMessage.closedGroupControlMessage.members = this.members.map(fromHexToArray);
dataMessage.closedGroupControlMessage.admins = this.admins.map(
fromHexToArray
);
dataMessage.closedGroupControlMessage.members = this.members.map(
fromHexToArray
);
try {
dataMessage.closedGroupControlMessage.encryptionKeyPair = new SignalService.DataMessage.ClosedGroupControlMessage.KeyPair();
dataMessage.closedGroupControlMessage.encryptionKeyPair.privateKey = new Uint8Array(
@ -78,8 +81,8 @@ export class ClosedGroupV2NewMessage extends ClosedGroupV2Message {
this.keypair.publicKeyData
);
} catch (e) {
window.log.error('Failed to add encryptionKeyPair to v2 group:', e);
throw new Error('Failed to add encryptionKeyPair to v2 group:');
window.log.error('Failed to add encryptionKeyPair to group:', e);
throw new Error('Failed to add encryptionKeyPair to group:');
}
return dataMessage;

@ -1,22 +1,22 @@
import { SignalService } from '../../../../../../protobuf';
import {
ClosedGroupV2Message,
ClosedGroupV2MessageParams,
} from './ClosedGroupV2Message';
ClosedGroupMessage,
ClosedGroupMessageParams,
} from './ClosedGroupMessage';
import { fromHexToArray } from '../../../../../utils/String';
export interface ClosedGroupV2UpdateMessageParams
extends ClosedGroupV2MessageParams {
export interface ClosedGroupUpdateMessageParams
extends ClosedGroupMessageParams {
name: string;
members: Array<string>;
expireTimer: number;
}
export class ClosedGroupV2UpdateMessage extends ClosedGroupV2Message {
export class ClosedGroupUpdateMessage extends ClosedGroupMessage {
private readonly name: string;
private readonly members: Array<string>;
constructor(params: ClosedGroupV2UpdateMessageParams) {
constructor(params: ClosedGroupUpdateMessageParams) {
super({
timestamp: params.timestamp,
identifier: params.identifier,
@ -42,7 +42,9 @@ export class ClosedGroupV2UpdateMessage extends ClosedGroupV2Message {
dataMessage.closedGroupControlMessage.type =
SignalService.DataMessage.ClosedGroupControlMessage.Type.UPDATE;
dataMessage.closedGroupControlMessage.name = this.name;
dataMessage.closedGroupControlMessage.members = this.members.map(fromHexToArray);
dataMessage.closedGroupControlMessage.members = this.members.map(
fromHexToArray
);
return dataMessage;
}

@ -0,0 +1,4 @@
export * from './ClosedGroupChatMessage';
export * from './ClosedGroupEncryptionPairMessage';
export * from './ClosedGroupNewMessage';
export * from './ClosedGroupUpdateMessage';

@ -1,4 +0,0 @@
export * from './ClosedGroupV2ChatMessage';
export * from './ClosedGroupV2EncryptionPairMessage';
export * from './ClosedGroupV2NewMessage';
export * from './ClosedGroupV2UpdateMessage';

@ -1,10 +1,10 @@
export * from './DataMessage';
export * from './GroupInvitationMessage';
export * from './ChatMessage';
export * from './groupv2/ClosedGroupV2Message';
export * from './groupv2/ClosedGroupV2ChatMessage';
export * from './groupv2/ClosedGroupV2EncryptionPairMessage';
export * from './groupv2/ClosedGroupV2NewMessage';
export * from './groupv2/ClosedGroupV2UpdateMessage';
export * from './groupv2/ClosedGroupV2Message';
export * from './group/ClosedGroupMessage';
export * from './group/ClosedGroupChatMessage';
export * from './group/ClosedGroupEncryptionPairMessage';
export * from './group/ClosedGroupNewMessage';
export * from './group/ClosedGroupUpdateMessage';
export * from './group/ClosedGroupMessage';
export * from './ExpirationTimerUpdateMessage';

@ -13,7 +13,7 @@ import { PendingMessageCache } from './PendingMessageCache';
import { JobQueue, TypedEventEmitter, UserUtils } from '../utils';
import { PubKey, RawMessage } from '../types';
import { MessageSender } from '.';
import { ClosedGroupV2Message } from '../messages/outgoing/content/data/groupv2/ClosedGroupV2Message';
import { ClosedGroupMessage } from '../messages/outgoing/content/data/group/ClosedGroupMessage';
export class MessageQueue implements MessageQueueInterface {
public readonly events: TypedEventEmitter<MessageQueueInterfaceEvents>;
@ -94,7 +94,7 @@ export class MessageQueue implements MessageQueueInterface {
let groupId: PubKey | undefined;
if (
message instanceof ExpirationTimerUpdateMessage ||
message instanceof ClosedGroupV2Message
message instanceof ClosedGroupMessage
) {
groupId = message.groupId;
}

@ -2,13 +2,13 @@ import { ContentMessage, OpenGroupMessage } from '../messages/outgoing';
import { RawMessage } from '../types/RawMessage';
import { TypedEventEmitter } from '../utils';
import { PubKey } from '../types';
import { ClosedGroupV2Message } from '../messages/outgoing/content/data/groupv2/ClosedGroupV2Message';
import { ClosedGroupV2ChatMessage } from '../messages/outgoing/content/data/groupv2/ClosedGroupV2ChatMessage';
import { ClosedGroupMessage } from '../messages/outgoing/content/data/group/ClosedGroupMessage';
import { ClosedGroupChatMessage } from '../messages/outgoing/content/data/group/ClosedGroupChatMessage';
export type GroupMessageType =
| OpenGroupMessage
| ClosedGroupV2ChatMessage
| ClosedGroupV2Message;
| ClosedGroupChatMessage
| ClosedGroupMessage;
export interface MessageQueueInterfaceEvents {
sendSuccess: (
message: RawMessage | OpenGroupMessage,

@ -5,21 +5,21 @@ import {
TypingMessage,
} from '../messages/outgoing';
import { EncryptionType, PubKey } from '../types';
import { ClosedGroupV2Message } from '../messages/outgoing/content/data/groupv2/ClosedGroupV2Message';
import { ClosedGroupV2NewMessage } from '../messages/outgoing/content/data/groupv2/ClosedGroupV2NewMessage';
import { ClosedGroupMessage } from '../messages/outgoing/content/data/group/ClosedGroupMessage';
import { ClosedGroupNewMessage } from '../messages/outgoing/content/data/group/ClosedGroupNewMessage';
export function getEncryptionTypeFromMessageType(
message: ContentMessage
): EncryptionType {
// ClosedGroupV2NewMessage is sent using established channels, so using fallback
if (message instanceof ClosedGroupV2NewMessage) {
// ClosedGroupNewMessage is sent using established channels, so using fallback
if (message instanceof ClosedGroupNewMessage) {
return EncryptionType.Fallback;
}
// 1. any ClosedGroupV2Message which is not a ClosedGroupV2NewMessage must be encoded with ClosedGroup
// 1. any ClosedGroupMessage which is not a ClosedGroupNewMessage must be encoded with ClosedGroup
// 2. if TypingMessage or ExpirationTimer and groupId is set => must be encoded with ClosedGroup too
if (
message instanceof ClosedGroupV2Message ||
message instanceof ClosedGroupMessage ||
(message instanceof ExpirationTimerUpdateMessage && message.groupId)
) {
return EncryptionType.ClosedGroup;

@ -129,7 +129,7 @@ describe('MessageEncrypter', () => {
});
describe('EncryptionType', () => {
describe('ClosedGroupV2', () => {
describe('ClosedGroup', () => {
it('should return a CLOSED_GROUP_CIPHERTEXT envelope type for ClosedGroup', async () => {
const hexKeyPair = {
publicHex: `05${ourUserEd25516Keypair.pubKey}`,

@ -2,7 +2,7 @@ import { expect } from 'chai';
import {
ChatMessage,
ClosedGroupV2ChatMessage,
ClosedGroupChatMessage,
} from '../../../../session/messages/outgoing';
import { SignalService } from '../../../../protobuf';
import { TestUtils } from '../../../test-utils';
@ -10,7 +10,7 @@ import { StringUtils } from '../../../../session/utils';
import { PubKey } from '../../../../session/types';
import { Constants } from '../../../../session';
describe('ClosedGroupV2ChatMessage', () => {
describe('ClosedGroupChatMessage', () => {
let groupId: PubKey;
beforeEach(() => {
groupId = TestUtils.generateFakePubKey();
@ -20,7 +20,7 @@ describe('ClosedGroupV2ChatMessage', () => {
timestamp: Date.now(),
body: 'body',
});
const message = new ClosedGroupV2ChatMessage({
const message = new ClosedGroupChatMessage({
groupId,
chatMessage,
});
@ -53,7 +53,7 @@ describe('ClosedGroupV2ChatMessage', () => {
const chatMessage = new ChatMessage({
timestamp: Date.now(),
});
const message = new ClosedGroupV2ChatMessage({
const message = new ClosedGroupChatMessage({
groupId,
chatMessage,
});
@ -64,7 +64,7 @@ describe('ClosedGroupV2ChatMessage', () => {
const chatMessage = new ChatMessage({
timestamp: Date.now(),
});
const message = new ClosedGroupV2ChatMessage({
const message = new ClosedGroupChatMessage({
groupId,
chatMessage,
});
@ -81,7 +81,7 @@ describe('ClosedGroupV2ChatMessage', () => {
body: 'body',
identifier: 'chatMessage',
});
const message = new ClosedGroupV2ChatMessage({
const message = new ClosedGroupChatMessage({
groupId,
chatMessage,
identifier: 'closedGroupMessage',
@ -95,7 +95,7 @@ describe('ClosedGroupV2ChatMessage', () => {
body: 'body',
identifier: 'chatMessage',
});
const message = new ClosedGroupV2ChatMessage({
const message = new ClosedGroupChatMessage({
groupId,
chatMessage,
});

@ -13,7 +13,7 @@ import {
import { PubKey, RawMessage } from '../../../../session/types';
import { MessageSender } from '../../../../session/sending';
import { PendingMessageCacheStub } from '../../../test-utils/stubs';
import { ClosedGroupV2Message } from '../../../../session/messages/outgoing/content/data/groupv2/ClosedGroupV2Message';
import { ClosedGroupMessage } from '../../../../session/messages/outgoing/content/data/group/ClosedGroupMessage';
// tslint:disable-next-line: no-require-imports no-var-requires
const chaiAsPromised = require('chai-as-promised');
@ -188,9 +188,9 @@ describe('MessageQueue', () => {
expect(send.callCount).to.equal(1);
const arg = send.getCall(0).args;
expect(arg[1] instanceof ClosedGroupV2Message).to.equal(
expect(arg[1] instanceof ClosedGroupMessage).to.equal(
true,
'message sent to group member was not a ClosedGroupV2Message'
'message sent to group member was not a ClosedGroupMessage'
);
});

@ -3,11 +3,11 @@ import * as sinon from 'sinon';
import { TestUtils } from '../../../test-utils';
import { MessageUtils } from '../../../../session/utils';
import { EncryptionType, PubKey } from '../../../../session/types';
import { ClosedGroupV2ChatMessage } from '../../../../session/messages/outgoing/content/data/groupv2/ClosedGroupV2ChatMessage';
import { ClosedGroupChatMessage } from '../../../../session/messages/outgoing/content/data/group/ClosedGroupChatMessage';
import {
ClosedGroupV2EncryptionPairMessage,
ClosedGroupV2NewMessage,
ClosedGroupV2UpdateMessage,
ClosedGroupEncryptionPairMessage,
ClosedGroupNewMessage,
ClosedGroupUpdateMessage,
} from '../../../../session/messages/outgoing';
import { SignalService } from '../../../../protobuf';
// tslint:disable-next-line: no-require-imports no-var-requires
@ -23,6 +23,7 @@ describe('Message Utils', () => {
sandbox.restore();
});
// tslint:disable-next-line: max-func-body-length
describe('toRawMessage', () => {
it('can convert to raw message', async () => {
const device = TestUtils.generateFakePubKey();
@ -81,11 +82,11 @@ describe('Message Utils', () => {
);
});
it('should set encryption to ClosedGroup if a ClosedGroupV2ChatMessage is passed in', async () => {
it('should set encryption to ClosedGroup if a ClosedGroupChatMessage is passed in', async () => {
const device = TestUtils.generateFakePubKey();
const groupId = TestUtils.generateFakePubKey();
const chatMessage = TestUtils.generateChatMessage();
const message = new ClosedGroupV2ChatMessage({ chatMessage, groupId });
const message = new ClosedGroupChatMessage({ chatMessage, groupId });
const rawMessage = await MessageUtils.toRawMessage(device, message);
expect(rawMessage.encryption).to.equal(EncryptionType.ClosedGroup);
@ -99,11 +100,11 @@ describe('Message Utils', () => {
expect(rawMessage.encryption).to.equal(EncryptionType.Fallback);
});
it('passing ClosedGroupV2NewMessage returns Fallback', async () => {
it('passing ClosedGroupNewMessage returns Fallback', async () => {
const device = TestUtils.generateFakePubKey();
const member = TestUtils.generateFakePubKey().key;
const msg = new ClosedGroupV2NewMessage({
const msg = new ClosedGroupNewMessage({
timestamp: Date.now(),
name: 'df',
members: [member],
@ -116,10 +117,10 @@ describe('Message Utils', () => {
expect(rawMessage.encryption).to.equal(EncryptionType.Fallback);
});
it('passing ClosedGroupV2UpdateMessage returns ClosedGroup', async () => {
it('passing ClosedGroupUpdateMessage returns ClosedGroup', async () => {
const device = TestUtils.generateFakePubKey();
const msg = new ClosedGroupV2UpdateMessage({
const msg = new ClosedGroupUpdateMessage({
timestamp: Date.now(),
name: 'df',
members: [TestUtils.generateFakePubKey().key],
@ -130,7 +131,7 @@ describe('Message Utils', () => {
expect(rawMessage.encryption).to.equal(EncryptionType.ClosedGroup);
});
it('passing ClosedGroupV2EncryptionPairMessage returns ClosedGroup', async () => {
it('passing ClosedGroupEncryptionPairMessage returns ClosedGroup', async () => {
const device = TestUtils.generateFakePubKey();
const fakeWrappers = new Array<
@ -142,7 +143,7 @@ describe('Message Utils', () => {
encryptedKeyPair: new Uint8Array(8),
})
);
const msg = new ClosedGroupV2EncryptionPairMessage({
const msg = new ClosedGroupEncryptionPairMessage({
timestamp: Date.now(),
groupId: TestUtils.generateFakePubKey().key,
encryptedKeyPairs: fakeWrappers,
@ -152,7 +153,7 @@ describe('Message Utils', () => {
expect(rawMessage.encryption).to.equal(EncryptionType.ClosedGroup);
});
it('passing ClosedGroupV2EncryptionPairMessage returns ClosedGroup', async () => {
it('passing ClosedGroupEncryptionPairMessage returns ClosedGroup', async () => {
const device = TestUtils.generateFakePubKey();
const fakeWrappers = new Array<
@ -164,7 +165,7 @@ describe('Message Utils', () => {
encryptedKeyPair: new Uint8Array(8),
})
);
const msg = new ClosedGroupV2EncryptionPairMessage({
const msg = new ClosedGroupEncryptionPairMessage({
timestamp: Date.now(),
groupId: TestUtils.generateFakePubKey().key,
encryptedKeyPairs: fakeWrappers,

@ -1,6 +1,6 @@
import {
ChatMessage,
ClosedGroupV2ChatMessage,
ClosedGroupChatMessage,
OpenGroupMessage,
} from '../../../session/messages/outgoing';
import { v4 as uuid } from 'uuid';
@ -40,8 +40,8 @@ export function generateOpenGroupMessage(): OpenGroupMessage {
export function generateClosedGroupMessage(
groupId?: string
): ClosedGroupV2ChatMessage {
return new ClosedGroupV2ChatMessage({
): ClosedGroupChatMessage {
return new ClosedGroupChatMessage({
identifier: uuid(),
groupId: groupId ?? generateFakePubKey().key,
chatMessage: generateChatMessage(),

Loading…
Cancel
Save