@wireapp/core 41.7.1 → 41.7.3
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/Account.d.ts.map +1 -1
- package/lib/Account.js +1 -1
- package/lib/conversation/ConversationService/ConversationService.d.ts +2 -2
- package/lib/conversation/ConversationService/ConversationService.d.ts.map +1 -1
- package/lib/conversation/ConversationService/ConversationService.js +29 -11
- package/lib/conversation/ConversationService/ConversationService.test.js +82 -16
- package/package.json +2 -2
package/lib/Account.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Account.d.ts","sourceRoot":"","sources":["../src/Account.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,YAAY,EAGZ,OAAO,EACP,MAAM,EAEN,SAAS,EACV,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAuB,UAAU,EAAE,gBAAgB,EAAC,MAAM,iCAAiC,CAAC;AACnG,OAAO,KAAK,MAAM,MAAM,+BAA+B,CAAC;AAOxD,OAAO,EAAC,SAAS,EAAE,eAAe,EAAC,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAC,UAAU,EAAe,MAAM,uBAAuB,CAAC;AAE/D,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAC,UAAU,EAAE,aAAa,EAAC,MAAM,WAAW,CAAC;AACpD,OAAO,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAChD,OAAO,EAAC,YAAY,EAAE,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AAElE,OAAO,EAAC,YAAY,EAAC,MAAM,UAAU,CAAC;AACtC,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AACjD,OAAO,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAC,YAAY,EAAE,oBAAoB,EAAC,MAAM,gCA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YAAC,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAC,KAAK,IAAI,CAAC;QAEtF;;WAEG;QACH,wBAAwB,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;QAE5D;;;;;;WAMG;QACH,qBAAqB,CAAC,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;QAEzD;;WAEG;QACH,MAAM,CAAC,EAAE,OAAO,CAAC;KACb,GAAG,MAAM,IAAI;IA2FnB,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,kBAAkB;YAIZ,UAAU;CAqBzB"}
|
package/lib/Account.js
CHANGED
|
@@ -260,7 +260,7 @@ class Account extends TypedEventEmitter_1.TypedEventEmitter {
|
|
|
260
260
|
const cryptoClientDef = await this.buildCryptoClient(context, this.storeEngine, enableMLS);
|
|
261
261
|
const [clientType, cryptoClient] = cryptoClientDef;
|
|
262
262
|
const mlsService = clientType === CryptoClient_1.CryptoClientType.CORE_CRYPTO && enableMLS
|
|
263
|
-
? new mls_1.MLSService(this.apiClient, cryptoClient.getNativeClient(), Object.assign(
|
|
263
|
+
? new mls_1.MLSService(this.apiClient, cryptoClient.getNativeClient(), Object.assign({}, (_b = this.cryptoProtocolConfig) === null || _b === void 0 ? void 0 : _b.mls))
|
|
264
264
|
: undefined;
|
|
265
265
|
const proteusService = new proteus_1.ProteusService(this.apiClient, cryptoClient, {
|
|
266
266
|
onNewClient: payload => this.emit(EVENTS.NEW_SESSION, payload),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Conversation, DefaultConversationRoleName, MutedStatus, NewConversation, QualifiedUserClients, RemoteConversations, PostMlsMessageResponse } from '@wireapp/api-client/lib/conversation';
|
|
1
|
+
import { Conversation, DefaultConversationRoleName, MutedStatus, NewConversation, QualifiedUserClients, RemoteConversations, PostMlsMessageResponse, MLSConversation } from '@wireapp/api-client/lib/conversation';
|
|
2
2
|
import { BackendEvent, ConversationMemberLeaveEvent } from '@wireapp/api-client/lib/event';
|
|
3
3
|
import { QualifiedId } from '@wireapp/api-client/lib/user';
|
|
4
4
|
import { XOR } from '@wireapp/commons/lib/util/TypeUtil';
|
|
@@ -123,7 +123,7 @@ export declare class ConversationService extends TypedEventEmitter<Events> {
|
|
|
123
123
|
readonly establishMLS1to1Conversation: (groupId: string, selfUser: {
|
|
124
124
|
user: QualifiedId;
|
|
125
125
|
client: string;
|
|
126
|
-
}, otherUserId: QualifiedId) => Promise<
|
|
126
|
+
}, otherUserId: QualifiedId, shouldRetry?: boolean) => Promise<MLSConversation>;
|
|
127
127
|
private handleMLSMessageAddEvent;
|
|
128
128
|
private handleMLSWelcomeMessageEvent;
|
|
129
129
|
private handleOtrMessageAddEvent;
|
|
@@ -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,
|
|
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,EAChB,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;AAIvD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAI9C,OAAO,EAEL,cAAc,EACd,6BAA6B,EAC7B,oBAAoB,EACpB,UAAU,EACX,MAAM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,EACP,cAAc,GACf,EAAE,QAAQ,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,6BAA6B,CAAC;IAoBvD,8BAA8B,CAAC,EAC1C,OAAO,EACP,cAAc,EACd,gBAAgB,GACjB,EAAE,iBAAiB,GAAG,OAAO,CAAC,6BAA6B,CAAC;IAoBhD,oBAAoB,CAAC,cAAc,EAAE,WAAW;IAI7D;;;;;OAKG;IACU,wBAAwB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAmBpE;;;OAGG;IACU,qBAAqB,CAAC,OAAO,EAAE,MAAM;IAIlD;;;;OAIG;IACU,4BAA4B,CAAC,OAAO,EAAE,MAAM;IAI5C,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;YAIlD,YAAY;IAYb,gCAAgC;IAa7C;;;;;OAKG;YACW,+BAA+B;IA6B7C;;;;;;;OAOG;IACH,SAAgB,4BAA4B,YACjC,MAAM,YACL;QAAC,IAAI,EAAE,WAAW,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,eAChC,WAAW,4BAEvB,QAAQ,eAAe,CAAC,CAoDzB;YAEY,wBAAwB;YA8BxB,4BAA4B;YAI5B,wBAAwB;IAIzB,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC;CAYxF"}
|
|
@@ -54,23 +54,41 @@ class ConversationService extends TypedEventEmitter_1.TypedEventEmitter {
|
|
|
54
54
|
* @param selfUser - user and client ids of the self user
|
|
55
55
|
* @param otherUserId - id of the other user
|
|
56
56
|
*/
|
|
57
|
-
this.establishMLS1to1Conversation = async (groupId, selfUser, otherUserId) => {
|
|
57
|
+
this.establishMLS1to1Conversation = async (groupId, selfUser, otherUserId, shouldRetry = true) => {
|
|
58
|
+
this.logger.info(`Trying to establish a MLS 1:1 conversation with user ${otherUserId.id}...`);
|
|
59
|
+
// Before trying to register a group, check if the group is already established o backend.
|
|
60
|
+
// If remote epoch is higher than 0, it means that the group was already established.
|
|
61
|
+
// It's possible that we've already received a welcome message.
|
|
62
|
+
const mlsConversation = await this.apiClient.api.conversation.getMLS1to1Conversation(otherUserId);
|
|
63
|
+
if (mlsConversation.epoch > 0) {
|
|
64
|
+
this.logger.info(`Conversation (id ${mlsConversation.qualified_id.id}) is already established on backend, checking the local epoch...`);
|
|
65
|
+
const isMLSGroupEstablishedLocally = await this.isMLSGroupEstablishedLocally(groupId);
|
|
66
|
+
// If group is already established locally, there's nothing more to do
|
|
67
|
+
if (isMLSGroupEstablishedLocally) {
|
|
68
|
+
this.logger.info(`Conversation (id ${mlsConversation.qualified_id.id}) is already established locally.`);
|
|
69
|
+
return mlsConversation;
|
|
70
|
+
}
|
|
71
|
+
// If local epoch is 0 it means that we've not received a welcome message
|
|
72
|
+
// We try joining via external commit.
|
|
73
|
+
this.logger.info(`Conversation (id ${mlsConversation.qualified_id.id}) is not yet established locally, joining via external commit...`);
|
|
74
|
+
await this.joinByExternalCommit(mlsConversation.qualified_id);
|
|
75
|
+
return this.apiClient.api.conversation.getMLS1to1Conversation(otherUserId);
|
|
76
|
+
}
|
|
77
|
+
// If group is not established on backend,
|
|
78
|
+
// we wipe the it locally (in case it exsits in the local store) and try to register it.
|
|
79
|
+
await this.mlsService.wipeConversation(groupId);
|
|
58
80
|
try {
|
|
59
81
|
await this.mlsService.registerConversation(groupId, [otherUserId, selfUser.user], selfUser);
|
|
82
|
+
this.logger.info(`Conversation (id ${mlsConversation.qualified_id.id}) established successfully.`);
|
|
83
|
+
return this.apiClient.api.conversation.getMLS1to1Conversation(otherUserId);
|
|
60
84
|
}
|
|
61
85
|
catch (error) {
|
|
62
|
-
this.logger.info(`Could not register MLS group with id ${groupId}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
this.logger.info(`Conversation (id ${mlsConversation.qualified_id.id}) is already established, joining via external commit`);
|
|
66
|
-
// If its already established, we join with external commit
|
|
67
|
-
await this.joinByExternalCommit(mlsConversation.qualified_id);
|
|
68
|
-
return;
|
|
86
|
+
this.logger.info(`Could not register MLS group with id ${groupId}: `, error);
|
|
87
|
+
if (!shouldRetry) {
|
|
88
|
+
throw error;
|
|
69
89
|
}
|
|
70
90
|
this.logger.info(`Conversation (id ${mlsConversation.qualified_id.id}) is not established, retrying to establish it`);
|
|
71
|
-
|
|
72
|
-
await this.wipeMLSConversation(groupId);
|
|
73
|
-
return this.establishMLS1to1Conversation(groupId, selfUser, otherUserId);
|
|
91
|
+
return this.establishMLS1to1Conversation(groupId, selfUser, otherUserId, false);
|
|
74
92
|
}
|
|
75
93
|
};
|
|
76
94
|
this.messageTimer = new conversation_2.MessageTimer();
|
|
@@ -102,6 +102,7 @@ describe('ConversationService', () => {
|
|
|
102
102
|
wipeConversation: jest.fn(),
|
|
103
103
|
handleMLSMessageAddEvent: jest.fn(),
|
|
104
104
|
conversationExists: jest.fn(),
|
|
105
|
+
isConversationEstablished: jest.fn(),
|
|
105
106
|
};
|
|
106
107
|
const conversationService = new __1.ConversationService(client, mockedProteusService, mockedMLSService);
|
|
107
108
|
jest.spyOn(conversationService, 'joinByExternalCommit');
|
|
@@ -205,52 +206,117 @@ describe('ConversationService', () => {
|
|
|
205
206
|
});
|
|
206
207
|
});
|
|
207
208
|
describe('establishMLS1to1Conversation', () => {
|
|
208
|
-
it('
|
|
209
|
-
const [conversationService, { mlsService }] = buildConversationService();
|
|
209
|
+
it('only returns a conversation if a group is already established on backend and locally', async () => {
|
|
210
|
+
const [conversationService, { apiClient, mlsService }] = buildConversationService();
|
|
211
|
+
const mockConversationId = { id: 'mock-conversation-id', domain: 'staging.zinfra.io' };
|
|
210
212
|
const mockGroupId = 'mock-group-id';
|
|
211
213
|
const selfUser = { user: { id: 'self-user-id', domain: 'staging.zinfra.io' }, client: 'self-user-client-id' };
|
|
212
214
|
const otherUserId = { id: 'other-user-id', domain: 'staging.zinfra.io' };
|
|
215
|
+
const remoteEpoch = 1;
|
|
216
|
+
jest.spyOn(apiClient.api.conversation, 'getMLS1to1Conversation').mockResolvedValueOnce({
|
|
217
|
+
qualified_id: mockConversationId,
|
|
218
|
+
protocol: conversation_1.ConversationProtocol.MLS,
|
|
219
|
+
epoch: remoteEpoch,
|
|
220
|
+
group_id: mockGroupId,
|
|
221
|
+
});
|
|
222
|
+
jest.spyOn(mlsService, 'isConversationEstablished').mockResolvedValueOnce(true);
|
|
213
223
|
await conversationService.establishMLS1to1Conversation(mockGroupId, selfUser, otherUserId);
|
|
214
|
-
expect(mlsService.registerConversation).
|
|
215
|
-
expect(
|
|
216
|
-
expect(mlsService.joinByExternalCommit).not.toHaveBeenCalled();
|
|
217
|
-
expect(mlsService.wipeConversation).not.toHaveBeenCalled();
|
|
224
|
+
expect(mlsService.registerConversation).not.toHaveBeenCalled();
|
|
225
|
+
expect(conversationService.joinByExternalCommit).not.toHaveBeenCalled();
|
|
218
226
|
});
|
|
219
|
-
it('joins with external commit if
|
|
227
|
+
it('joins with an external commit if a group is already established on backend but not established locally', async () => {
|
|
220
228
|
const [conversationService, { apiClient, mlsService }] = buildConversationService();
|
|
221
229
|
const mockConversationId = { id: 'mock-conversation-id', domain: 'staging.zinfra.io' };
|
|
222
230
|
const mockGroupId = 'mock-group-id';
|
|
223
231
|
const selfUser = { user: { id: 'self-user-id', domain: 'staging.zinfra.io' }, client: 'self-user-client-id' };
|
|
224
232
|
const otherUserId = { id: 'other-user-id', domain: 'staging.zinfra.io' };
|
|
225
|
-
|
|
233
|
+
const remoteEpoch = 1;
|
|
234
|
+
const updatedEpoch = 2;
|
|
235
|
+
jest.spyOn(apiClient.api.conversation, 'getMLS1to1Conversation').mockResolvedValueOnce({
|
|
236
|
+
qualified_id: mockConversationId,
|
|
237
|
+
protocol: conversation_1.ConversationProtocol.MLS,
|
|
238
|
+
epoch: remoteEpoch,
|
|
239
|
+
group_id: mockGroupId,
|
|
240
|
+
});
|
|
241
|
+
// The 2nd request we make after joining the conversation with external commit
|
|
226
242
|
jest.spyOn(apiClient.api.conversation, 'getMLS1to1Conversation').mockResolvedValueOnce({
|
|
227
243
|
qualified_id: mockConversationId,
|
|
228
244
|
protocol: conversation_1.ConversationProtocol.MLS,
|
|
229
|
-
epoch:
|
|
245
|
+
epoch: updatedEpoch,
|
|
230
246
|
group_id: mockGroupId,
|
|
231
247
|
});
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
248
|
+
jest.spyOn(mlsService, 'isConversationEstablished').mockResolvedValueOnce(false);
|
|
249
|
+
jest.spyOn(mlsService, 'joinByExternalCommit').mockResolvedValueOnce({ events: [], time: '' });
|
|
250
|
+
const establishedConversation = await conversationService.establishMLS1to1Conversation(mockGroupId, selfUser, otherUserId);
|
|
251
|
+
expect(mlsService.registerConversation).not.toHaveBeenCalled();
|
|
235
252
|
expect(conversationService.joinByExternalCommit).toHaveBeenCalledWith(mockConversationId);
|
|
253
|
+
expect(establishedConversation.epoch).toEqual(updatedEpoch);
|
|
236
254
|
});
|
|
237
|
-
it('
|
|
255
|
+
it('wipes the conversation and registers it if a group is not yet established on backend', async () => {
|
|
238
256
|
const [conversationService, { apiClient, mlsService }] = buildConversationService();
|
|
239
257
|
const mockConversationId = { id: 'mock-conversation-id', domain: 'staging.zinfra.io' };
|
|
240
258
|
const mockGroupId = 'mock-group-id';
|
|
241
259
|
const selfUser = { user: { id: 'self-user-id', domain: 'staging.zinfra.io' }, client: 'self-user-client-id' };
|
|
242
260
|
const otherUserId = { id: 'other-user-id', domain: 'staging.zinfra.io' };
|
|
243
|
-
|
|
261
|
+
const remoteEpoch = 0;
|
|
262
|
+
const updatedEpoch = 1;
|
|
244
263
|
jest.spyOn(apiClient.api.conversation, 'getMLS1to1Conversation').mockResolvedValueOnce({
|
|
245
264
|
qualified_id: mockConversationId,
|
|
246
265
|
protocol: conversation_1.ConversationProtocol.MLS,
|
|
247
|
-
epoch:
|
|
266
|
+
epoch: remoteEpoch,
|
|
248
267
|
group_id: mockGroupId,
|
|
249
268
|
});
|
|
250
|
-
|
|
269
|
+
// The 2nd request we make after successfully registering a group
|
|
270
|
+
jest.spyOn(apiClient.api.conversation, 'getMLS1to1Conversation').mockResolvedValueOnce({
|
|
271
|
+
qualified_id: mockConversationId,
|
|
272
|
+
protocol: conversation_1.ConversationProtocol.MLS,
|
|
273
|
+
epoch: updatedEpoch,
|
|
274
|
+
group_id: mockGroupId,
|
|
275
|
+
});
|
|
276
|
+
jest.spyOn(mlsService, 'wipeConversation');
|
|
277
|
+
const establishedConversation = await conversationService.establishMLS1to1Conversation(mockGroupId, selfUser, otherUserId);
|
|
278
|
+
expect(mlsService.wipeConversation).toHaveBeenCalledWith(mockGroupId);
|
|
279
|
+
expect(mlsService.registerConversation).toHaveBeenCalledTimes(1);
|
|
251
280
|
expect(mlsService.registerConversation).toHaveBeenCalledWith(mockGroupId, [otherUserId, selfUser.user], selfUser);
|
|
281
|
+
expect(conversationService.joinByExternalCommit).not.toHaveBeenCalled();
|
|
282
|
+
expect(establishedConversation.epoch).toEqual(updatedEpoch);
|
|
283
|
+
});
|
|
284
|
+
it('retries to register the conversation after it has failed for the first time', async () => {
|
|
285
|
+
const [conversationService, { apiClient, mlsService }] = buildConversationService();
|
|
286
|
+
const mockConversationId = { id: 'mock-conversation-id', domain: 'staging.zinfra.io' };
|
|
287
|
+
const mockGroupId = 'mock-group-id';
|
|
288
|
+
const selfUser = { user: { id: 'self-user-id', domain: 'staging.zinfra.io' }, client: 'self-user-client-id' };
|
|
289
|
+
const otherUserId = { id: 'other-user-id', domain: 'staging.zinfra.io' };
|
|
290
|
+
const remoteEpoch = 0;
|
|
291
|
+
const updatedEpoch = 1;
|
|
292
|
+
jest.spyOn(apiClient.api.conversation, 'getMLS1to1Conversation').mockResolvedValueOnce({
|
|
293
|
+
qualified_id: mockConversationId,
|
|
294
|
+
protocol: conversation_1.ConversationProtocol.MLS,
|
|
295
|
+
epoch: remoteEpoch,
|
|
296
|
+
group_id: mockGroupId,
|
|
297
|
+
});
|
|
298
|
+
// The 2nd request we make when retrying to register the conversation
|
|
299
|
+
jest.spyOn(apiClient.api.conversation, 'getMLS1to1Conversation').mockResolvedValueOnce({
|
|
300
|
+
qualified_id: mockConversationId,
|
|
301
|
+
protocol: conversation_1.ConversationProtocol.MLS,
|
|
302
|
+
epoch: remoteEpoch,
|
|
303
|
+
group_id: mockGroupId,
|
|
304
|
+
});
|
|
305
|
+
// The 3rd request we make after successfully registering a group
|
|
306
|
+
jest.spyOn(apiClient.api.conversation, 'getMLS1to1Conversation').mockResolvedValueOnce({
|
|
307
|
+
qualified_id: mockConversationId,
|
|
308
|
+
protocol: conversation_1.ConversationProtocol.MLS,
|
|
309
|
+
epoch: updatedEpoch,
|
|
310
|
+
group_id: mockGroupId,
|
|
311
|
+
});
|
|
312
|
+
jest.spyOn(mlsService, 'registerConversation').mockRejectedValueOnce(undefined);
|
|
313
|
+
jest.spyOn(mlsService, 'wipeConversation');
|
|
314
|
+
const establishedConversation = await conversationService.establishMLS1to1Conversation(mockGroupId, selfUser, otherUserId);
|
|
252
315
|
expect(mlsService.wipeConversation).toHaveBeenCalledWith(mockGroupId);
|
|
253
316
|
expect(mlsService.registerConversation).toHaveBeenCalledTimes(2);
|
|
317
|
+
expect(mlsService.registerConversation).toHaveBeenCalledWith(mockGroupId, [otherUserId, selfUser.user], selfUser);
|
|
318
|
+
expect(conversationService.joinByExternalCommit).not.toHaveBeenCalled();
|
|
319
|
+
expect(establishedConversation.epoch).toEqual(updatedEpoch);
|
|
254
320
|
});
|
|
255
321
|
});
|
|
256
322
|
describe('handleEvent', () => {
|
package/package.json
CHANGED