@wireapp/core 46.39.11 → 46.40.0
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.
|
@@ -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,eAAe,EACf,kBAAkB,
|
|
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,eAAe,EACf,kBAAkB,EAKnB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACL,YAAY,EAIZ,4BAA4B,EAE7B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAC,GAAG,EAAC,MAAM,oCAAoC,CAAC;AAGvD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAa,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAY/D,OAAO,EACL,cAAc,EACd,8BAA8B,EAE9B,oBAAoB,EACpB,UAAU,EACX,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAC,YAAY,EAAuB,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACzF,OAAO,EAAC,UAAU,EAAE,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAG1E,OAAO,EAAkC,cAAc,EAAC,MAAM,kCAAkC,CAAC;AACjG,OAAO,EACL,mCAAmC,EACnC,wBAAwB,EACzB,MAAM,sEAAsE,CAAC;AAC9E,OAAO,EAAsB,kBAAkB,EAAC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AAW;IAShD;;;;;;;OAOG;IACH,SAAgB,4BAA4B,YACjC,MAAM,YACL;QAAC,IAAI,EAAE,WAAW,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,eAChC,WAAW,4BAEvB,OAAO,CAAC,eAAe,CAAC,CAwDzB;IAEF;;;;;;;;OAQG;IACU,uBAAuB,CAAC,EACnC,OAAO,EACP,cAAc,EACd,UAAU,EACV,cAAc,GACf,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,cAAc,EAAE,WAAW,CAAC;QAC5B,UAAU,EAAE,WAAW,CAAC;QACxB,cAAc,EAAE,WAAW,EAAE,CAAC;KAC/B,GAAG,OAAO,CAAC,IAAI,CAAC;YAkCH,wBAAwB;YAsBxB,gCAAgC;YA0BhC,4BAA4B;IA2B1C,OAAO,CAAC,2BAA2B;IAmBnC;;;OAGG;YACW,uCAAuC;YA4BvC,wBAAwB;YAIxB,yBAAyB;IAKvC;;;;OAIG;IACU,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAoB3E"}
|
|
@@ -263,9 +263,9 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
263
263
|
};
|
|
264
264
|
}
|
|
265
265
|
catch (error) {
|
|
266
|
-
this.logger.
|
|
266
|
+
this.logger.warn('Failed to send MLS message', { error, groupId });
|
|
267
267
|
if (!shouldRetry) {
|
|
268
|
-
this.logger.
|
|
268
|
+
this.logger.error("Tried to send MLS message but it's still failing after recovery", {
|
|
269
269
|
error,
|
|
270
270
|
groupId,
|
|
271
271
|
});
|
|
@@ -280,7 +280,6 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
280
280
|
groupId,
|
|
281
281
|
});
|
|
282
282
|
await this.handleBrokenMLSConversation(conversationId);
|
|
283
|
-
return this.sendMLSMessage(params, false);
|
|
284
283
|
}
|
|
285
284
|
/**
|
|
286
285
|
* We may have the same error from core-crypto or from the backend error mapper
|
|
@@ -293,13 +292,19 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
293
292
|
groupId,
|
|
294
293
|
});
|
|
295
294
|
await this.recoverMLSGroupFromEpochMismatch(conversationId);
|
|
296
|
-
return this.sendMLSMessage(params, false);
|
|
297
295
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
296
|
+
if (error instanceof conversation_1.MLSGroupOutOfSyncError) {
|
|
297
|
+
this.logger.info('Failed to send MLS message because of group out of sync, recovering by adding missing users', {
|
|
298
|
+
error,
|
|
299
|
+
groupId,
|
|
300
|
+
});
|
|
301
|
+
await this.addUsersToMLSConversation({
|
|
302
|
+
groupId,
|
|
303
|
+
conversationId,
|
|
304
|
+
qualifiedUsers: error.missing_users,
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
return this.sendMLSMessage(params, false);
|
|
303
308
|
}
|
|
304
309
|
}
|
|
305
310
|
/**
|
|
@@ -311,6 +316,7 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
311
316
|
*/
|
|
312
317
|
async addUsersToMLSConversation({ qualifiedUsers, groupId, conversationId, shouldRetry = true, }) {
|
|
313
318
|
try {
|
|
319
|
+
this.logger.info(`Adding users to MLS conversation`, { groupId, conversationId, qualifiedUsers });
|
|
314
320
|
const exisitingClientIdsInGroup = await this.mlsService.getClientIdsInGroup(groupId);
|
|
315
321
|
const conversation = await this.getConversation(conversationId);
|
|
316
322
|
const { keyPackages, failures: keysClaimingFailures } = await this.mlsService.getKeyPackagesPayload(qualifiedUsers, exisitingClientIdsInGroup);
|
|
@@ -326,6 +332,7 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
326
332
|
};
|
|
327
333
|
}
|
|
328
334
|
catch (error) {
|
|
335
|
+
this.logger.warn('Failed to add users to MLS conversation', { error, groupId, conversationId });
|
|
329
336
|
if (mls_1.MLSService.isBrokenMLSConversationError(error)) {
|
|
330
337
|
if (!shouldRetry) {
|
|
331
338
|
this.logger.warn("Tried to add users to MLS conversation but it's still broken after reset", error);
|
|
@@ -510,8 +517,14 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
510
517
|
async hasEpochMismatch(groupId, epoch) {
|
|
511
518
|
const isEstablished = await this.mlsGroupExistsLocally(groupId);
|
|
512
519
|
const doesEpochMatch = isEstablished && (await this.matchesEpoch(groupId, epoch));
|
|
513
|
-
//if conversation is not established or epoch does not match -> try to rejoin
|
|
514
|
-
|
|
520
|
+
// if conversation is not established or epoch does not match -> try to rejoin
|
|
521
|
+
const hasEpochMismatch = !isEstablished || !doesEpochMatch;
|
|
522
|
+
this.logger.info(`Conversation (group_id: ${groupId}) epoch mismatch check result: ${hasEpochMismatch}`, {
|
|
523
|
+
isEstablished,
|
|
524
|
+
doesEpochMatch,
|
|
525
|
+
epoch,
|
|
526
|
+
});
|
|
527
|
+
return hasEpochMismatch;
|
|
515
528
|
}
|
|
516
529
|
/**
|
|
517
530
|
* Get a MLS 1:1-conversation with a given user.
|
|
@@ -628,6 +641,7 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
628
641
|
}
|
|
629
642
|
}
|
|
630
643
|
async recoverMLSGroupFromEpochMismatch(conversationId, subconversationId) {
|
|
644
|
+
this.logger.info(`Recovering MLS group from epoch mismatch`, { conversationId, subconversationId });
|
|
631
645
|
if (subconversationId) {
|
|
632
646
|
const parentGroupId = await this.groupIdFromConversationId(conversationId);
|
|
633
647
|
const subconversation = await this.apiClient.api.conversation.getSubconversation(conversationId, subconversationId);
|
|
@@ -222,6 +222,34 @@ describe('ConversationService', () => {
|
|
|
222
222
|
});
|
|
223
223
|
expect(apiClient.api.conversation.postMlsMessage).toHaveBeenCalledTimes(2);
|
|
224
224
|
});
|
|
225
|
+
it('adds missing users to MLS group and retries when group is out of sync during send', async () => {
|
|
226
|
+
const [conversationService, { apiClient }] = await buildConversationService();
|
|
227
|
+
const mockGroupId = 'AAEAAH87aajaQ011i+rNLmwpy0sAZGl5YS53aXJlamxpbms=';
|
|
228
|
+
const mockConversationId = { id: 'mockConversationId', domain: 'staging.zinfra.io' };
|
|
229
|
+
const mockedMessage = MessageBuilder.buildTextMessage({ text: 'test' });
|
|
230
|
+
const missingUsers = [
|
|
231
|
+
{ id: 'user-1', domain: 'staging.zinfra.io' },
|
|
232
|
+
{ id: 'user-2', domain: 'staging.zinfra.io' },
|
|
233
|
+
];
|
|
234
|
+
const outOfSyncError = new conversation_1.MLSGroupOutOfSyncError(http_status_codes_1.StatusCodes.CONFLICT, missingUsers, http_1.BackendErrorLabel.MLS_GROUP_OUT_OF_SYNC);
|
|
235
|
+
// First send fails with out-of-sync, second succeeds via default mock
|
|
236
|
+
jest.spyOn(apiClient.api.conversation, 'postMlsMessage').mockRejectedValueOnce(outOfSyncError);
|
|
237
|
+
const addUsersSpy = jest
|
|
238
|
+
.spyOn(conversationService, 'addUsersToMLSConversation')
|
|
239
|
+
.mockResolvedValueOnce({ conversation: { members: { others: [] } } });
|
|
240
|
+
await conversationService.send({
|
|
241
|
+
protocol: conversation_1.ConversationProtocol.MLS,
|
|
242
|
+
groupId: mockGroupId,
|
|
243
|
+
payload: mockedMessage,
|
|
244
|
+
conversationId: mockConversationId,
|
|
245
|
+
});
|
|
246
|
+
expect(addUsersSpy).toHaveBeenCalledWith({
|
|
247
|
+
groupId: mockGroupId,
|
|
248
|
+
conversationId: mockConversationId,
|
|
249
|
+
qualifiedUsers: missingUsers,
|
|
250
|
+
});
|
|
251
|
+
expect(apiClient.api.conversation.postMlsMessage).toHaveBeenCalledTimes(2);
|
|
252
|
+
});
|
|
225
253
|
});
|
|
226
254
|
describe('handleConversationsEpochMismatch', () => {
|
|
227
255
|
beforeEach(() => {
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"./lib/cryptography/AssetCryptography/crypto.node": "./lib/cryptography/AssetCryptography/crypto.browser.js"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@wireapp/api-client": "^27.
|
|
14
|
+
"@wireapp/api-client": "^27.82.0",
|
|
15
15
|
"@wireapp/commons": "^5.4.5",
|
|
16
16
|
"@wireapp/core-crypto": "9.1.0",
|
|
17
17
|
"@wireapp/cryptobox": "12.8.0",
|
|
@@ -61,6 +61,6 @@
|
|
|
61
61
|
"test:coverage": "jest --coverage",
|
|
62
62
|
"watch": "tsc --watch"
|
|
63
63
|
},
|
|
64
|
-
"version": "46.
|
|
65
|
-
"gitHead": "
|
|
64
|
+
"version": "46.40.0",
|
|
65
|
+
"gitHead": "28ddfb822c9e80262e718a5c1d89dc2878f72dd4"
|
|
66
66
|
}
|