@wireapp/core 44.0.7 → 44.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/conversation/ConversationService/ConversationService.d.ts.map +1 -1
- package/lib/conversation/ConversationService/ConversationService.js +12 -6
- package/lib/conversation/ConversationService/ConversationService.test.js +8 -4
- package/lib/conversation/SubconversationService/SubconversationService.d.ts +2 -1
- package/lib/conversation/SubconversationService/SubconversationService.d.ts.map +1 -1
- package/lib/conversation/SubconversationService/SubconversationService.js +6 -5
- package/lib/conversation/SubconversationService/SubconversationService.test.js +16 -10
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts +11 -6
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.js +17 -7
- package/lib/messagingProtocols/mls/MLSService/MLSService.test.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConversationService.d.ts","sourceRoot":"","sources":["../../../src/conversation/ConversationService/ConversationService.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,YAAY,EACZ,2BAA2B,EAC3B,WAAW,EACX,eAAe,EACf,oBAAoB,EAEpB,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAEnB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACL,YAAY,EAIZ,4BAA4B,EAE7B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAC,GAAG,EAAC,MAAM,oCAAoC,CAAC;AAIvD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAEL,cAAc,EAEd,6BAA6B,EAC7B,oBAAoB,EACpB,UAAU,EACX,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAA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CAC9B,cAAc,EAAE,WAAW,EAC3B,QAAQ,EAAE,OAAO,EACjB,gBAAgB,GAAE,MAAM,GAAG,IAAiB,GAC3C,OAAO,CAAC,IAAI,CAAC;IAaT,yBAAyB,CAC9B,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,2BAA2B,GAAG,MAAM,GACrD,OAAO,CAAC,IAAI,CAAC;IAMhB;;;;OAIG;IAEH;;;OAGG;IACU,qBAAqB,CAChC,gBAAgB,EAAE,eAAe,EACjC,UAAU,EAAE,WAAW,EACvB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"ConversationService.d.ts","sourceRoot":"","sources":["../../../src/conversation/ConversationService/ConversationService.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,YAAY,EACZ,2BAA2B,EAC3B,WAAW,EACX,eAAe,EACf,oBAAoB,EAEpB,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAEnB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACL,YAAY,EAIZ,4BAA4B,EAE7B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAC,GAAG,EAAC,MAAM,oCAAoC,CAAC;AAIvD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAGnD,OAAO,EAEL,cAAc,EAEd,6BAA6B,EAC7B,oBAAoB,EACpB,UAAU,EACX,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAC,YAAY,EAAuB,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAEzF,OAAO,EAAC,UAAU,EAAC,MAAM,8BAA8B,CAAC;AAGxD,OAAO,EAAkC,cAAc,EAAC,MAAM,kCAAkC,CAAC;AACjG,OAAO,EACL,mCAAmC,EACn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WAAW,CAAC;QACxB,cAAc,EAAE,WAAW,EAAE,CAAC;KAC/B,GAAG,OAAO,CAAC,IAAI,CAAC;YA4BH,wBAAwB;YAsBxB,gCAAgC;YAyBhC,4BAA4B;YAI5B,wBAAwB;YAIxB,yBAAyB;IAKvC;;;;OAIG;IACU,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAoB3E"}
|
|
@@ -96,7 +96,7 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
96
96
|
// we wipe the it locally (in case it exsits in the local store) and try to register it.
|
|
97
97
|
await this.mlsService.wipeConversation(groupId);
|
|
98
98
|
try {
|
|
99
|
-
await this.mlsService.registerConversation(groupId, [otherUserId, selfUser.user], selfUser);
|
|
99
|
+
await this.mlsService.registerConversation(groupId, [otherUserId, selfUser.user], { creator: selfUser });
|
|
100
100
|
this.logger.info(`Conversation (id ${mlsConversation.qualified_id.id}) established successfully.`);
|
|
101
101
|
return this.getMLS1to1Conversation(otherUserId);
|
|
102
102
|
}
|
|
@@ -248,8 +248,10 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
248
248
|
throw new Error('No group_id found in response which is required for creating MLS conversations.');
|
|
249
249
|
}
|
|
250
250
|
const response = await this.mlsService.registerConversation(groupId, qualifiedUsers.concat(selfUserId), {
|
|
251
|
-
|
|
252
|
-
|
|
251
|
+
creator: {
|
|
252
|
+
user: selfUserId,
|
|
253
|
+
client: selfClientId,
|
|
254
|
+
},
|
|
253
255
|
});
|
|
254
256
|
// We fetch the fresh version of the conversation created on backend with the newly added users
|
|
255
257
|
const conversation = await this.apiClient.api.conversation.getConversation(qualifiedId);
|
|
@@ -374,7 +376,7 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
374
376
|
* Handles epoch mismatch in a subconversation.
|
|
375
377
|
* @param subconversation - subconversation
|
|
376
378
|
*/
|
|
377
|
-
async handleSubconversationEpochMismatch(subconversation) {
|
|
379
|
+
async handleSubconversationEpochMismatch(subconversation, parentGroupId) {
|
|
378
380
|
const { parent_qualified_id: parentConversationId, group_id: groupId, epoch, subconv_id: subconversationId, } = subconversation;
|
|
379
381
|
if (await this.hasEpochMismatch(groupId, epoch)) {
|
|
380
382
|
this.logger.log(`Subconversation "${subconversationId}" (parent id: ${parentConversationId.id}) was not established or its epoch number was out of date, joining via external commit`);
|
|
@@ -383,7 +385,7 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
383
385
|
throw new Error('Unexpected subconversation id');
|
|
384
386
|
}
|
|
385
387
|
try {
|
|
386
|
-
await this.subconversationService.joinConferenceSubconversation(parentConversationId);
|
|
388
|
+
await this.subconversationService.joinConferenceSubconversation(parentConversationId, parentGroupId);
|
|
387
389
|
}
|
|
388
390
|
catch (error) {
|
|
389
391
|
const message = `There was an error while handling epoch mismatch in MLS subconversation (id: ${parentConversationId.id}, subconv: ${subconversationId}):`;
|
|
@@ -482,8 +484,12 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
482
484
|
}
|
|
483
485
|
async recoverMLSGroupFromEpochMismatch(conversationId, subconversationId) {
|
|
484
486
|
if (subconversationId) {
|
|
487
|
+
const parentGroupId = await this.groupIdFromConversationId(conversationId);
|
|
485
488
|
const subconversation = await this.apiClient.api.conversation.getSubconversation(conversationId, subconversationId);
|
|
486
|
-
|
|
489
|
+
if (!parentGroupId) {
|
|
490
|
+
throw new Error('Could not find parent group id for the subconversation');
|
|
491
|
+
}
|
|
492
|
+
return this.handleSubconversationEpochMismatch(subconversation, parentGroupId);
|
|
487
493
|
}
|
|
488
494
|
const mlsConversation = await this.apiClient.api.conversation.getConversation(conversationId);
|
|
489
495
|
if (!(0, util_1.isMLSConversation)(mlsConversation)) {
|
|
@@ -109,7 +109,7 @@ describe('ConversationService', () => {
|
|
|
109
109
|
resetKeyMaterialRenewal: jest.fn(),
|
|
110
110
|
};
|
|
111
111
|
const mockedDb = await (0, CoreDB_1.openDB)('core-test-db');
|
|
112
|
-
const groupIdFromConversationId = jest.fn();
|
|
112
|
+
const groupIdFromConversationId = jest.fn(async () => 'groupId');
|
|
113
113
|
const mockedSubconversationService = {
|
|
114
114
|
joinConferenceSubconversation: jest.fn(),
|
|
115
115
|
};
|
|
@@ -320,7 +320,9 @@ describe('ConversationService', () => {
|
|
|
320
320
|
const establishedConversation = await conversationService.establishMLS1to1Conversation(mockGroupId, selfUser, otherUserId);
|
|
321
321
|
expect(mlsService.wipeConversation).toHaveBeenCalledWith(mockGroupId);
|
|
322
322
|
expect(mlsService.registerConversation).toHaveBeenCalledTimes(1);
|
|
323
|
-
expect(mlsService.registerConversation).toHaveBeenCalledWith(mockGroupId, [otherUserId, selfUser.user],
|
|
323
|
+
expect(mlsService.registerConversation).toHaveBeenCalledWith(mockGroupId, [otherUserId, selfUser.user], {
|
|
324
|
+
creator: selfUser,
|
|
325
|
+
});
|
|
324
326
|
expect(conversationService.joinByExternalCommit).not.toHaveBeenCalled();
|
|
325
327
|
expect(establishedConversation.epoch).toEqual(updatedEpoch);
|
|
326
328
|
});
|
|
@@ -357,7 +359,9 @@ describe('ConversationService', () => {
|
|
|
357
359
|
const establishedConversation = await conversationService.establishMLS1to1Conversation(mockGroupId, selfUser, otherUserId);
|
|
358
360
|
expect(mlsService.wipeConversation).toHaveBeenCalledWith(mockGroupId);
|
|
359
361
|
expect(mlsService.registerConversation).toHaveBeenCalledTimes(2);
|
|
360
|
-
expect(mlsService.registerConversation).toHaveBeenCalledWith(mockGroupId, [otherUserId, selfUser.user],
|
|
362
|
+
expect(mlsService.registerConversation).toHaveBeenCalledWith(mockGroupId, [otherUserId, selfUser.user], {
|
|
363
|
+
creator: selfUser,
|
|
364
|
+
});
|
|
361
365
|
expect(conversationService.joinByExternalCommit).not.toHaveBeenCalled();
|
|
362
366
|
expect(establishedConversation.epoch).toEqual(updatedEpoch);
|
|
363
367
|
});
|
|
@@ -408,7 +412,7 @@ describe('ConversationService', () => {
|
|
|
408
412
|
await conversationService.handleEvent(mockMLSMessageAddEvent);
|
|
409
413
|
await new Promise(resolve => setImmediate(resolve));
|
|
410
414
|
expect(conversationService.joinByExternalCommit).not.toHaveBeenCalled();
|
|
411
|
-
expect(subconversationService.joinConferenceSubconversation).toHaveBeenCalledWith(conversationId);
|
|
415
|
+
expect(subconversationService.joinConferenceSubconversation).toHaveBeenCalledWith(conversationId, 'groupId');
|
|
412
416
|
});
|
|
413
417
|
});
|
|
414
418
|
describe('getConversations', () => {
|
|
@@ -26,8 +26,9 @@ export declare class SubconversationService extends TypedEventEmitter<Events> {
|
|
|
26
26
|
* Will return the secret key derived from the subconversation
|
|
27
27
|
*
|
|
28
28
|
* @param conversationId Id of the parent conversation in which the call should happen
|
|
29
|
+
* @param groupId groupId of the parent conversation in which the call should happen
|
|
29
30
|
*/
|
|
30
|
-
joinConferenceSubconversation(conversationId: QualifiedId, shouldRetry?: boolean): Promise<{
|
|
31
|
+
joinConferenceSubconversation(conversationId: QualifiedId, groupId: string, shouldRetry?: boolean): Promise<{
|
|
31
32
|
groupId: string;
|
|
32
33
|
epoch: number;
|
|
33
34
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubconversationService.d.ts","sourceRoot":"","sources":["../../../src/conversation/SubconversationService/SubconversationService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,kBAAkB,EAAkB,MAAM,sCAAsC,CAAC;AACzF,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAIzD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAInD,OAAO,EAAC,UAAU,EAAC,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAGlD,KAAK,MAAM,GAAG;IACZ,wBAAwB,EAAE;QAAC,cAAc,EAAE,WAAW,CAAA;KAAC,CAAC;CACzD,CAAC;AAEF,MAAM,WAAW,8BAA8B;IAC7C,MAAM,EAAE,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;CACrB;AAID,qBAAa,sBAAuB,SAAQ,iBAAiB,CAAC,MAAM,CAAC;IAIjE,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;IAL/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAmD;gBAGvD,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,WAAW,CAAC,wBAAY;IAK3C,IAAI,UAAU,IAAI,UAAU,CAK3B;IAED
|
|
1
|
+
{"version":3,"file":"SubconversationService.d.ts","sourceRoot":"","sources":["../../../src/conversation/SubconversationService/SubconversationService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,kBAAkB,EAAkB,MAAM,sCAAsC,CAAC;AACzF,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAIzD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAInD,OAAO,EAAC,UAAU,EAAC,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAGlD,KAAK,MAAM,GAAG;IACZ,wBAAwB,EAAE;QAAC,cAAc,EAAE,WAAW,CAAA;KAAC,CAAC;CACzD,CAAC;AAEF,MAAM,WAAW,8BAA8B;IAC7C,MAAM,EAAE,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;CACrB;AAID,qBAAa,sBAAuB,SAAQ,iBAAiB,CAAC,MAAM,CAAC;IAIjE,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,C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I,EAAE,WAAW,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC,GACpD,OAAO,CAAC,IAAI,CAAC;YAgCF,mCAAmC;YAMnC,4BAA4B;YAI5B,+BAA+B;YAO/B,8BAA8B;IAsBrC,yBAAyB,yBACR,WAAW,qBACd,kBAAkB,KACpC,QAAQ,MAAM,GAAG,SAAS,CAAC,CAO5B;IAEK,iCAAiC,sBACnB,kBAAkB;8BAGb,WAAW;2BACd,kBAAkB;iBAC5B,MAAM;SASjB;IAEK,0BAA0B,yBACT,WAAW,qBACd,kBAAkB,WAC5B,MAAM,qBAOf;IAEK,2BAA2B,yBACV,WAAW,qBACd,kBAAkB,mBAMrC;CACH"}
|
|
@@ -63,8 +63,9 @@ class SubconversationService extends commons_1.TypedEventEmitter {
|
|
|
63
63
|
* Will return the secret key derived from the subconversation
|
|
64
64
|
*
|
|
65
65
|
* @param conversationId Id of the parent conversation in which the call should happen
|
|
66
|
+
* @param groupId groupId of the parent conversation in which the call should happen
|
|
66
67
|
*/
|
|
67
|
-
async joinConferenceSubconversation(conversationId, shouldRetry = true) {
|
|
68
|
+
async joinConferenceSubconversation(conversationId, groupId, shouldRetry = true) {
|
|
68
69
|
try {
|
|
69
70
|
const { group_id: subconversationGroupId, epoch: subconversationEpoch, epoch_timestamp: subconversationEpochTimestamp, subconv_id: subconversationId, } = await this.getConferenceSubconversation(conversationId);
|
|
70
71
|
if (subconversationEpoch === 0) {
|
|
@@ -73,7 +74,7 @@ class SubconversationService extends commons_1.TypedEventEmitter {
|
|
|
73
74
|
await this.mlsService.wipeConversation(subconversationGroupId);
|
|
74
75
|
}
|
|
75
76
|
// If subconversation is not yet established, create it and upload the commit bundle.
|
|
76
|
-
await this.mlsService.registerConversation(subconversationGroupId, []);
|
|
77
|
+
await this.mlsService.registerConversation(subconversationGroupId, [], { parentGroupId: groupId });
|
|
77
78
|
}
|
|
78
79
|
else {
|
|
79
80
|
const epochUpdateTime = new Date(subconversationEpochTimestamp).getTime();
|
|
@@ -85,7 +86,7 @@ class SubconversationService extends commons_1.TypedEventEmitter {
|
|
|
85
86
|
epoch: subconversationEpoch,
|
|
86
87
|
});
|
|
87
88
|
await this.mlsService.wipeConversation(subconversationGroupId);
|
|
88
|
-
return this.joinConferenceSubconversation(conversationId);
|
|
89
|
+
return this.joinConferenceSubconversation(conversationId, groupId);
|
|
89
90
|
}
|
|
90
91
|
await this.joinSubconversationByExternalCommit(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
|
|
91
92
|
}
|
|
@@ -96,7 +97,7 @@ class SubconversationService extends commons_1.TypedEventEmitter {
|
|
|
96
97
|
}
|
|
97
98
|
catch (error) {
|
|
98
99
|
if (shouldRetry) {
|
|
99
|
-
return this.joinConferenceSubconversation(conversationId, false);
|
|
100
|
+
return this.joinConferenceSubconversation(conversationId, groupId, false);
|
|
100
101
|
}
|
|
101
102
|
throw error;
|
|
102
103
|
}
|
|
@@ -153,7 +154,7 @@ class SubconversationService extends commons_1.TypedEventEmitter {
|
|
|
153
154
|
return { members, epoch, keyLength: MLS_CONVERSATION_KEY_LENGTH, secretKey };
|
|
154
155
|
}
|
|
155
156
|
async subscribeToEpochUpdates(parentConversationId, parentConversationGroupId, findConversationByGroupId, onEpochUpdate) {
|
|
156
|
-
const { epoch: initialEpoch, groupId: subconversationGroupId } = await this.joinConferenceSubconversation(parentConversationId);
|
|
157
|
+
const { epoch: initialEpoch, groupId: subconversationGroupId } = await this.joinConferenceSubconversation(parentConversationId, parentConversationGroupId);
|
|
157
158
|
const forwardNewEpoch = async ({ groupId }) => {
|
|
158
159
|
if (groupId !== subconversationGroupId) {
|
|
159
160
|
// if the epoch update did not happen in the subconversation directly, check if it happened in the parent conversation
|
|
@@ -64,6 +64,7 @@ describe('SubconversationService', () => {
|
|
|
64
64
|
it('wipes group locally (if it exists) before registering a group if remote epoch is equal 0', async () => {
|
|
65
65
|
const [subconversationService, { apiClient, mlsService }] = await buildSubconversationService();
|
|
66
66
|
const parentConversationId = { id: 'parentConversationId', domain: 'domain' };
|
|
67
|
+
const parentGroupId = 'parentGroupId';
|
|
67
68
|
const subconversationGroupId = 'subconversationGroupId';
|
|
68
69
|
const subconversationResponse = getSubconversationResponse({
|
|
69
70
|
epoch: 0,
|
|
@@ -74,13 +75,14 @@ describe('SubconversationService', () => {
|
|
|
74
75
|
});
|
|
75
76
|
jest.spyOn(apiClient.api.conversation, 'getSubconversation').mockResolvedValueOnce(subconversationResponse);
|
|
76
77
|
jest.spyOn(mlsService, 'conversationExists').mockResolvedValueOnce(true);
|
|
77
|
-
await subconversationService.joinConferenceSubconversation(parentConversationId);
|
|
78
|
+
await subconversationService.joinConferenceSubconversation(parentConversationId, parentGroupId);
|
|
78
79
|
expect(mlsService.wipeConversation).toHaveBeenCalledWith(subconversationGroupId);
|
|
79
|
-
expect(mlsService.registerConversation).toHaveBeenCalledWith(subconversationGroupId, []);
|
|
80
|
+
expect(mlsService.registerConversation).toHaveBeenCalledWith(subconversationGroupId, [], { parentGroupId });
|
|
80
81
|
});
|
|
81
82
|
it('registers a group if remote epoch is 0 and group does not exist locally', async () => {
|
|
82
83
|
const [subconversationService, { apiClient, mlsService }] = await buildSubconversationService();
|
|
83
84
|
const parentConversationId = { id: 'parentConversationId', domain: 'domain' };
|
|
85
|
+
const parentGroupId = 'parentGroupId';
|
|
84
86
|
const subconversationGroupId = 'subconversationGroupId';
|
|
85
87
|
const subconversationResponse = getSubconversationResponse({
|
|
86
88
|
epoch: 0,
|
|
@@ -91,14 +93,15 @@ describe('SubconversationService', () => {
|
|
|
91
93
|
});
|
|
92
94
|
jest.spyOn(apiClient.api.conversation, 'getSubconversation').mockResolvedValueOnce(subconversationResponse);
|
|
93
95
|
jest.spyOn(mlsService, 'conversationExists').mockResolvedValueOnce(false);
|
|
94
|
-
await subconversationService.joinConferenceSubconversation(parentConversationId);
|
|
96
|
+
await subconversationService.joinConferenceSubconversation(parentConversationId, parentGroupId);
|
|
95
97
|
expect(mlsService.wipeConversation).not.toHaveBeenCalled();
|
|
96
|
-
expect(mlsService.registerConversation).toHaveBeenCalledWith(subconversationGroupId, []);
|
|
98
|
+
expect(mlsService.registerConversation).toHaveBeenCalledWith(subconversationGroupId, [], { parentGroupId });
|
|
97
99
|
});
|
|
98
100
|
it('deletes conference subconversation from backend if group is already established and epoch is older than one day, then rejoins', async () => {
|
|
99
101
|
jest.useFakeTimers();
|
|
100
102
|
const [subconversationService, { apiClient, mlsService }] = await buildSubconversationService();
|
|
101
103
|
const parentConversationId = { id: 'parentConversationId', domain: 'domain' };
|
|
104
|
+
const parentGroupId = 'parentGroupId';
|
|
102
105
|
const subconversationGroupId = 'subconversationGroupId';
|
|
103
106
|
const initialSubconversationEpoch = 1;
|
|
104
107
|
const currentTimeISO = '2023-10-24T12:00:00.000Z';
|
|
@@ -124,7 +127,7 @@ describe('SubconversationService', () => {
|
|
|
124
127
|
subconversationId: conversation_1.SUBCONVERSATION_ID.CONFERENCE,
|
|
125
128
|
});
|
|
126
129
|
jest.spyOn(apiClient.api.conversation, 'getSubconversation').mockResolvedValueOnce(subconversationResponse2);
|
|
127
|
-
await subconversationService.joinConferenceSubconversation(parentConversationId);
|
|
130
|
+
await subconversationService.joinConferenceSubconversation(parentConversationId, parentGroupId);
|
|
128
131
|
expect(apiClient.api.conversation.deleteSubconversation).toHaveBeenCalledWith(parentConversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE, {
|
|
129
132
|
groupId: subconversationGroupId,
|
|
130
133
|
epoch: initialSubconversationEpoch,
|
|
@@ -137,6 +140,7 @@ describe('SubconversationService', () => {
|
|
|
137
140
|
const [subconversationService, { apiClient, mlsService }] = await buildSubconversationService();
|
|
138
141
|
const parentConversationId = { id: 'parentConversationId', domain: 'domain' };
|
|
139
142
|
const subconversationGroupId = 'subconversationGroupId';
|
|
143
|
+
const parentGroupId = 'parentGroupId';
|
|
140
144
|
const subconversationEpoch = 1;
|
|
141
145
|
const currentTimeISO = '2023-10-24T12:00:00.000Z';
|
|
142
146
|
jest.setSystemTime(new Date(currentTimeISO));
|
|
@@ -151,7 +155,7 @@ describe('SubconversationService', () => {
|
|
|
151
155
|
subconversationId: conversation_1.SUBCONVERSATION_ID.CONFERENCE,
|
|
152
156
|
});
|
|
153
157
|
jest.spyOn(apiClient.api.conversation, 'getSubconversation').mockResolvedValueOnce(subconversationResponse);
|
|
154
|
-
await subconversationService.joinConferenceSubconversation(parentConversationId);
|
|
158
|
+
await subconversationService.joinConferenceSubconversation(parentConversationId, parentGroupId);
|
|
155
159
|
expect(apiClient.api.conversation.deleteSubconversation).not.toHaveBeenCalled();
|
|
156
160
|
expect(mlsService.registerConversation).not.toHaveBeenCalled();
|
|
157
161
|
expect(mlsService.wipeConversation).not.toHaveBeenCalled();
|
|
@@ -160,6 +164,7 @@ describe('SubconversationService', () => {
|
|
|
160
164
|
it('retries to join if registering a conversations throws an error', async () => {
|
|
161
165
|
const [subconversationService, { apiClient, mlsService }] = await buildSubconversationService();
|
|
162
166
|
const parentConversationId = { id: 'parentConversationId', domain: 'domain' };
|
|
167
|
+
const parentGroupId = 'parentGroupId';
|
|
163
168
|
const subconversationGroupId = 'subconversationGroupId';
|
|
164
169
|
const subconversationResponse = getSubconversationResponse({
|
|
165
170
|
epoch: 0,
|
|
@@ -173,14 +178,15 @@ describe('SubconversationService', () => {
|
|
|
173
178
|
jest
|
|
174
179
|
.spyOn(mlsService, 'registerConversation')
|
|
175
180
|
.mockRejectedValueOnce(new http_1.BackendError('', http_1.BackendErrorLabel.MLS_STALE_MESSAGE, http_1.StatusCode.CONFLICT));
|
|
176
|
-
await subconversationService.joinConferenceSubconversation(parentConversationId);
|
|
181
|
+
await subconversationService.joinConferenceSubconversation(parentConversationId, parentGroupId);
|
|
177
182
|
expect(mlsService.wipeConversation).not.toHaveBeenCalled();
|
|
178
|
-
expect(mlsService.registerConversation).toHaveBeenCalledWith(subconversationGroupId, []);
|
|
183
|
+
expect(mlsService.registerConversation).toHaveBeenCalledWith(subconversationGroupId, [], { parentGroupId });
|
|
179
184
|
expect(mlsService.registerConversation).toHaveBeenCalledTimes(2);
|
|
180
185
|
});
|
|
181
186
|
it('returns fresh epoch number after joining the group', async () => {
|
|
182
187
|
const [subconversationService, { apiClient, mlsService }] = await buildSubconversationService();
|
|
183
188
|
const parentConversationId = { id: 'parentConversationId', domain: 'domain' };
|
|
189
|
+
const parentGroupId = 'parentGroupId';
|
|
184
190
|
const subconversationGroupId = 'subconversationGroupId';
|
|
185
191
|
const subconversationResponse = getSubconversationResponse({
|
|
186
192
|
epoch: 0,
|
|
@@ -193,9 +199,9 @@ describe('SubconversationService', () => {
|
|
|
193
199
|
jest.spyOn(mlsService, 'conversationExists').mockResolvedValueOnce(false);
|
|
194
200
|
const updatedEpoch = 1;
|
|
195
201
|
jest.spyOn(mlsService, 'getEpoch').mockResolvedValueOnce(updatedEpoch);
|
|
196
|
-
const response = await subconversationService.joinConferenceSubconversation(parentConversationId);
|
|
202
|
+
const response = await subconversationService.joinConferenceSubconversation(parentConversationId, parentGroupId);
|
|
197
203
|
expect(mlsService.wipeConversation).not.toHaveBeenCalled();
|
|
198
|
-
expect(mlsService.registerConversation).toHaveBeenCalledWith(subconversationGroupId, []);
|
|
204
|
+
expect(mlsService.registerConversation).toHaveBeenCalledWith(subconversationGroupId, [], { parentGroupId });
|
|
199
205
|
expect(response).toEqual({ epoch: updatedEpoch, groupId: subconversationGroupId });
|
|
200
206
|
});
|
|
201
207
|
});
|
|
@@ -89,17 +89,22 @@ export declare class MLSService extends TypedEventEmitter<Events> {
|
|
|
89
89
|
/**
|
|
90
90
|
* Will create an empty conversation inside of coreCrypto.
|
|
91
91
|
* @param groupId the id of the group to create inside of coreCrypto
|
|
92
|
+
* @param parentGroupId in case the conversation is a subconversation, the id of the parent conversation
|
|
92
93
|
*/
|
|
93
|
-
registerEmptyConversation(groupId: string): Promise<void>;
|
|
94
|
+
registerEmptyConversation(groupId: string, parentGroupId?: string): Promise<void>;
|
|
94
95
|
/**
|
|
95
96
|
* Will create a conversation inside of coreCrypto, add users to it or update the keying material if empty key packages list is provided.
|
|
96
97
|
* @param groupId the id of the group to create inside of coreCrypto
|
|
97
98
|
* @param users the list of users that will be members of the conversation (including the self user)
|
|
98
|
-
* @param creator the creator of the list. Most of the time will be the self user (or empty if the conversation was created by backend first)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
* @param options.creator the creator of the list. Most of the time will be the self user (or empty if the conversation was created by backend first)
|
|
100
|
+
* @param options.parentGroupId in case the conversation is a subconversation, the id of the parent conversation
|
|
101
|
+
*/
|
|
102
|
+
registerConversation(groupId: string, users: QualifiedId[], options?: {
|
|
103
|
+
creator?: {
|
|
104
|
+
user: QualifiedId;
|
|
105
|
+
client?: string;
|
|
106
|
+
};
|
|
107
|
+
parentGroupId?: string;
|
|
103
108
|
}): Promise<PostMlsMessageResponse>;
|
|
104
109
|
/**
|
|
105
110
|
* Will try to register mls group and send an empty commit to establish it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MLSService.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/MLSService/MLSService.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAqB,gBAAgB,EAAC,MAAM,gCAAgC,CAAC;AACzF,OAAO,EAAC,sBAAsB,EAAE,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;AAChG,OAAO,EAAC,8BAA8B,EAAE,2BAA2B,EAAC,MAAM,+BAA+B,CAAC;AAE1G,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAIzD,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAW,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EACL,eAAe,EAIf,cAAc,EACd,UAAU,EAEV,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,kBAAkB,EACnB,MAAM,sBAAsB,CAAC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gBrB,4BAA4B,CAAC,KAAK,EAAE,2BAA2B,EAAE,QAAQ,EAAE,MAAM;IAcjF,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE;IASjF;;;;;;;;OAQG;IACU,UAAU,CACrB,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,gBAAgB,EACxB,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,MAAM,EACtB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,sBAAsB,CAAC;CAqDnC"}
|
|
@@ -335,13 +335,21 @@ class MLSService extends commons_1.TypedEventEmitter {
|
|
|
335
335
|
/**
|
|
336
336
|
* Will create an empty conversation inside of coreCrypto.
|
|
337
337
|
* @param groupId the id of the group to create inside of coreCrypto
|
|
338
|
+
* @param parentGroupId in case the conversation is a subconversation, the id of the parent conversation
|
|
338
339
|
*/
|
|
339
|
-
async registerEmptyConversation(groupId) {
|
|
340
|
+
async registerEmptyConversation(groupId, parentGroupId) {
|
|
340
341
|
const groupIdBytes = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
|
|
341
|
-
|
|
342
|
-
|
|
342
|
+
let externalSenders = [];
|
|
343
|
+
if (parentGroupId) {
|
|
344
|
+
const parentGroupIdBytes = bazinga64_1.Decoder.fromBase64(parentGroupId).asBytes;
|
|
345
|
+
externalSenders = [await this.coreCryptoClient.getExternalSender(parentGroupIdBytes)];
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
const mlsKeys = (await this.apiClient.api.client.getPublicKeys()).removal;
|
|
349
|
+
externalSenders = Object.values(mlsKeys).map((key) => bazinga64_1.Decoder.fromBase64(key).asBytes);
|
|
350
|
+
}
|
|
343
351
|
const configuration = {
|
|
344
|
-
externalSenders
|
|
352
|
+
externalSenders,
|
|
345
353
|
ciphersuite: this.config.cipherSuite,
|
|
346
354
|
};
|
|
347
355
|
const credentialType = await this.getCredentialType();
|
|
@@ -351,10 +359,12 @@ class MLSService extends commons_1.TypedEventEmitter {
|
|
|
351
359
|
* Will create a conversation inside of coreCrypto, add users to it or update the keying material if empty key packages list is provided.
|
|
352
360
|
* @param groupId the id of the group to create inside of coreCrypto
|
|
353
361
|
* @param users the list of users that will be members of the conversation (including the self user)
|
|
354
|
-
* @param creator the creator of the list. Most of the time will be the self user (or empty if the conversation was created by backend first)
|
|
362
|
+
* @param options.creator the creator of the list. Most of the time will be the self user (or empty if the conversation was created by backend first)
|
|
363
|
+
* @param options.parentGroupId in case the conversation is a subconversation, the id of the parent conversation
|
|
355
364
|
*/
|
|
356
|
-
async registerConversation(groupId, users,
|
|
357
|
-
await this.registerEmptyConversation(groupId);
|
|
365
|
+
async registerConversation(groupId, users, options) {
|
|
366
|
+
await this.registerEmptyConversation(groupId, options === null || options === void 0 ? void 0 : options.parentGroupId);
|
|
367
|
+
const creator = options === null || options === void 0 ? void 0 : options.creator;
|
|
358
368
|
const { coreCryptoKeyPackagesPayload: keyPackages, failedToFetchKeyPackages } = await this.getKeyPackagesPayload(users.map(user => {
|
|
359
369
|
if (user.id === (creator === null || creator === void 0 ? void 0 : creator.user.id)) {
|
|
360
370
|
/**
|
|
@@ -89,7 +89,7 @@ describe('MLSService', () => {
|
|
|
89
89
|
const selfUser = createUserId();
|
|
90
90
|
const creator = { user: selfUser, client: 'client-1' };
|
|
91
91
|
const users = [createUserId(), createUserId()];
|
|
92
|
-
await mlsService.registerConversation(groupId, [...users, selfUser], creator);
|
|
92
|
+
await mlsService.registerConversation(groupId, [...users, selfUser], { creator });
|
|
93
93
|
expect(apiClient.api.client.claimMLSKeyPackages).toHaveBeenCalledTimes(3);
|
|
94
94
|
expect(apiClient.api.client.claimMLSKeyPackages).toHaveBeenCalledWith(selfUser.id, selfUser.domain, '0x1', creator.client);
|
|
95
95
|
expect(mlsService.scheduleKeyMaterialRenewal).toHaveBeenCalledWith(groupId);
|
package/package.json
CHANGED