@wireapp/core 41.3.2 → 41.4.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.
package/lib/Account.js CHANGED
@@ -382,7 +382,7 @@ class Account extends TypedEventEmitter_1.TypedEventEmitter {
382
382
  const handleMissedNotifications = async (notificationId) => {
383
383
  var _a, _b;
384
384
  if (((_a = this.cryptoProtocolConfig) === null || _a === void 0 ? void 0 : _a.mls) && this.backendFeatures.supportsMLS) {
385
- await ((_b = this.service) === null || _b === void 0 ? void 0 : _b.conversation.handleEpochMismatch());
385
+ await ((_b = this.service) === null || _b === void 0 ? void 0 : _b.conversation.handleConversationsEpochMismatch());
386
386
  }
387
387
  return onMissedNotifications(notificationId);
388
388
  };
@@ -9,8 +9,14 @@ import { MLSService } from '../../messagingProtocols/mls';
9
9
  import { ProteusService } from '../../messagingProtocols/proteus';
10
10
  import { AddUsersToProteusConversationParams, SendProteusMessageParams } from '../../messagingProtocols/proteus/ProteusService/ProteusService.types';
11
11
  import { HandledEventPayload } from '../../notification';
12
+ import { TypedEventEmitter } from '../../util/TypedEventEmitter';
12
13
  import { RemoteData } from '../content';
13
- export declare class ConversationService {
14
+ type Events = {
15
+ MLSConversationRecovered: {
16
+ conversationId: QualifiedId;
17
+ };
18
+ };
19
+ export declare class ConversationService extends TypedEventEmitter<Events> {
14
20
  private readonly apiClient;
15
21
  private readonly proteusService;
16
22
  private readonly _mlsService?;
@@ -88,7 +94,14 @@ export declare class ConversationService {
88
94
  isMLSConversationEstablished(groupId: string): Promise<boolean>;
89
95
  wipeMLSConversation(groupId: string): Promise<void>;
90
96
  private matchesEpoch;
91
- handleEpochMismatch(): Promise<void>;
97
+ handleConversationsEpochMismatch(): Promise<void>;
98
+ /**
99
+ * Handles epoch mismatch in a single MLS conversation.
100
+ * Compares the epoch of the local conversation with the epoch of the remote conversation.
101
+ * If the epochs do not match, it will try to rejoin the conversation via external commit.
102
+ * @param mlsConversation - mls conversation
103
+ */
104
+ private handleConversationEpochMismatch;
92
105
  /**
93
106
  * Will try registering mls 1:1 conversation adding the other user.
94
107
  * If it fails and the conversation is already established, it will try joining via external commit instead.
@@ -106,4 +119,5 @@ export declare class ConversationService {
106
119
  private handleOtrMessageAddEvent;
107
120
  handleEvent(event: BackendEvent): Promise<HandledEventPayload | undefined>;
108
121
  }
122
+ export {};
109
123
  //# sourceMappingURL=ConversationService.d.ts.map
@@ -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,EACvB,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,6BAA6B,CAAC;AAErC,OAAO,EAAC,YAAY,EAAuB,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAEzF,OAAO,EAAC,UAAU,EAAuB,MAAM,8BAA8B,CAAC;AAE9E,OAAO,EAAkC,cAAc,EAAC,MAAM,kCAAkC,CAAC;AACjG,OAAO,EACL,mCAAmC,EACnC,wBAAwB,EACzB,MAAM,sEAAsE,CAAC;AAC9E,OAAO,EAAC,mBAAmB,EAAC,MAAM,oBAAoB,CAAC;AAGvD,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AAGtC,qBAAa,mBAAmB;IAK5B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,Q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EY,wBAAwB;YAIxB,4BAA4B;YAI5B,wBAAwB;IAIzB,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC;CAYxF"}
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,EAEvB,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,6BAA6B,CAAC;AAErC,OAAO,EAAC,YAAY,EAAuB,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAEzF,OAAO,EAAC,UAAU,EAAuB,MAAM,8BAA8B,CAAC;AAE9E,OAAO,EAAkC,cAAc,EAAC,MAAM,kCAAkC,CAAC;AACjG,OAAO,EACL,mCAAmC,EACnC,wBAAwB,EACzB,MAAM,sEAAsE,CAAC;AAC9E,OAAO,EAAC,mBAAmB,EAAC,MAAM,oBAAoB,CAAC;AAGvD,OAAO,EAAC,iBAAiB,EAAC,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AAGtC,KAAK,MAAM,GAAG;IACZ,wBAAwB,EAAE;QAAC,cAAc,EAAE,WAAW,CAAA;KAAC,CAAC;CACzD,CAAC;AAEF,qBAAa,mBAAoB,SAAQ,iBAAiB,CAAC,MAAM,CAAC;IAK9D,OAAO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MAAM,EAAE,MAAM,CAAA;KAAC,eAChC,WAAW,KACvB,QAAQ,IAAI,CAAC,CA0Bd;YAEY,wBAAwB;YA8BxB,4BAA4B;YAI5B,wBAAwB;IAIzB,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC;CAYxF"}
@@ -33,13 +33,15 @@ const ConversationService_types_1 = require("./ConversationService.types");
33
33
  const conversation_2 = require("../../conversation/");
34
34
  const AssetCryptography_1 = require("../../cryptography/AssetCryptography");
35
35
  const mls_1 = require("../../messagingProtocols/mls");
36
- const events_1 = require("../../messagingProtocols/mls/EventHandler/events");
36
+ const CoreCryptoMLSErrors_1 = require("../../messagingProtocols/mls/MLSService/CoreCryptoMLSErrors");
37
37
  const proteus_1 = require("../../messagingProtocols/proteus");
38
38
  const util_1 = require("../../util");
39
39
  const fullyQualifiedClientIdUtils_1 = require("../../util/fullyQualifiedClientIdUtils");
40
+ const TypedEventEmitter_1 = require("../../util/TypedEventEmitter");
40
41
  const messageSender_1 = require("../message/messageSender");
41
- class ConversationService {
42
+ class ConversationService extends TypedEventEmitter_1.TypedEventEmitter {
42
43
  constructor(apiClient, proteusService, _mlsService) {
44
+ super();
43
45
  this.apiClient = apiClient;
44
46
  this.proteusService = proteusService;
45
47
  this._mlsService = _mlsService;
@@ -320,31 +322,62 @@ class ConversationService {
320
322
  //corecrypto stores epoch number as BigInt, we're mapping both values to be sure comparison is valid
321
323
  return BigInt(localEpoch) === BigInt(backendEpoch);
322
324
  }
323
- async handleEpochMismatch() {
325
+ async handleConversationsEpochMismatch() {
324
326
  this.logger.info(`There were some missed messages, handling possible epoch mismatch in MLS conversations.`);
325
327
  //fetch all the mls conversations from backend
326
328
  const conversations = await this.apiClient.api.conversation.getConversationList();
327
329
  const foundConversations = conversations.found || [];
328
330
  const mlsConversations = foundConversations.filter(util_1.isMLSConversation);
329
331
  //check all the established conversations' epoch with the core-crypto epoch
330
- for (const { qualified_id: qualifiedId, group_id: groupId, epoch } of mlsConversations) {
331
- try {
332
- //if conversation is not established or epoch does not match -> try to rejoin
333
- if (!(await this.isMLSConversationEstablished(groupId)) || !(await this.matchesEpoch(groupId, epoch))) {
334
- this.logger.log(`Conversation (id ${qualifiedId.id}) was not established or it's epoch number was out of date, joining via external commit`);
335
- await this.joinByExternalCommit(qualifiedId);
332
+ await Promise.all(mlsConversations.map(mlsConversation => this.handleConversationEpochMismatch(mlsConversation)));
333
+ }
334
+ /**
335
+ * Handles epoch mismatch in a single MLS conversation.
336
+ * Compares the epoch of the local conversation with the epoch of the remote conversation.
337
+ * If the epochs do not match, it will try to rejoin the conversation via external commit.
338
+ * @param mlsConversation - mls conversation
339
+ */
340
+ async handleConversationEpochMismatch(remoteMlsConversation, onSuccessfulRejoin) {
341
+ const { qualified_id: qualifiedId, group_id: groupId, epoch } = remoteMlsConversation;
342
+ try {
343
+ const isEstablished = await this.isMLSConversationEstablished(groupId);
344
+ const doesEpochMatch = await this.matchesEpoch(groupId, epoch);
345
+ //if conversation is not established or epoch does not match -> try to rejoin
346
+ if (!isEstablished || !doesEpochMatch) {
347
+ this.logger.log(`Conversation (id ${qualifiedId.id}) was not established or it's epoch number was out of date, joining via external commit`);
348
+ await this.joinByExternalCommit(qualifiedId);
349
+ if (onSuccessfulRejoin) {
350
+ onSuccessfulRejoin();
336
351
  }
337
352
  }
338
- catch (error) {
339
- this.logger.error(`There was an error while handling epoch mismatch in MLS conversation (id: ${qualifiedId.id}):`, error);
340
- }
353
+ }
354
+ catch (error) {
355
+ this.logger.error(`There was an error while handling epoch mismatch in MLS conversation (id: ${qualifiedId.id}):`, error);
341
356
  }
342
357
  }
343
358
  async handleMLSMessageAddEvent(event) {
344
- return (0, events_1.handleMLSMessageAdd)({ event, mlsService: this.mlsService });
359
+ try {
360
+ return await this.mlsService.handleMLSMessageAddEvent(event);
361
+ }
362
+ catch (error) {
363
+ if ((0, CoreCryptoMLSErrors_1.isCoreCryptoMLSWrongEpochError)(error)) {
364
+ this.logger.info(`Received message for the wrong epoch in conversation ${event.conversation}, handling epoch mismatch...`);
365
+ const conversationId = event.qualified_conversation;
366
+ if (!conversationId) {
367
+ throw new Error('Qualified conversation id is missing in the event');
368
+ }
369
+ const mlsConversation = await this.apiClient.api.conversation.getConversation(conversationId);
370
+ if (!(0, util_1.isMLSConversation)(mlsConversation)) {
371
+ throw new Error('Conversation is not an MLS conversation');
372
+ }
373
+ await this.handleConversationEpochMismatch(mlsConversation, () => this.emit('MLSConversationRecovered', { conversationId }));
374
+ return;
375
+ }
376
+ throw error;
377
+ }
345
378
  }
346
379
  async handleMLSWelcomeMessageEvent(event) {
347
- return (0, events_1.handleMLSWelcomeMessage)({ event, mlsService: this.mlsService });
380
+ return this.mlsService.handleMLSWelcomeMessageEvent(event);
348
381
  }
349
382
  async handleOtrMessageAddEvent(event) {
350
383
  return this.proteusService.handleOtrMessageAddEvent(event);
@@ -43,22 +43,25 @@ var __importStar = (this && this.__importStar) || function (mod) {
43
43
  Object.defineProperty(exports, "__esModule", { value: true });
44
44
  const client_1 = require("@wireapp/api-client/lib/client");
45
45
  const conversation_1 = require("@wireapp/api-client/lib/conversation");
46
+ const event_1 = require("@wireapp/api-client/lib/event");
46
47
  const api_client_1 = require("@wireapp/api-client");
47
48
  const __1 = require("..");
49
+ const CoreCryptoMLSErrors_1 = require("../../messagingProtocols/mls/MLSService/CoreCryptoMLSErrors");
48
50
  const MessagingProtocols = __importStar(require("../../messagingProtocols/proteus"));
49
51
  const PayloadHelper = __importStar(require("../../test/PayloadHelper"));
50
52
  const MessageBuilder = __importStar(require("../message/MessageBuilder"));
53
+ const createMLSMessageAddEventMock = (conversationId) => ({
54
+ data: '',
55
+ conversation: conversationId.id,
56
+ qualified_conversation: conversationId,
57
+ from: '',
58
+ senderClientId: '',
59
+ type: event_1.CONVERSATION_EVENT.MLS_MESSAGE_ADD,
60
+ time: '2023-08-21T06:47:43.387Z',
61
+ });
51
62
  jest.mock('../../messagingProtocols/proteus', () => (Object.assign(Object.assign({}, jest.requireActual('../../messagingProtocols/proteus')), { getGenericMessageParams: jest.fn(), getRecipientsForConversation: jest.fn(), getConversationQualifiedMembers: jest.fn() })));
52
63
  const MockedMessagingProtocols = MessagingProtocols;
53
64
  jest.mock('../message/messageSender', () => (Object.assign(Object.assign({}, jest.requireActual('../message/messageSender')), { sendMessage: jest.fn().mockImplementation(fn => fn()) })));
54
- const mockedMLSService = {
55
- encryptMessage: () => { },
56
- commitPendingProposals: () => Promise.resolve(),
57
- getEpoch: () => Promise.resolve(),
58
- joinByExternalCommit: jest.fn(),
59
- registerConversation: jest.fn(),
60
- wipeConversation: jest.fn(),
61
- };
62
65
  const mockedProteusService = {
63
66
  encryptGenericMessage: () => Promise.resolve(),
64
67
  sendProteusMessage: () => Promise.resolve({ sentAt: new Date() }),
@@ -90,8 +93,19 @@ describe('ConversationService', () => {
90
93
  userId: PayloadHelper.getUUID(),
91
94
  clientId: PayloadHelper.getUUID(),
92
95
  };
96
+ const mockedMLSService = {
97
+ encryptMessage: () => { },
98
+ commitPendingProposals: () => Promise.resolve(),
99
+ getEpoch: () => Promise.resolve(),
100
+ joinByExternalCommit: jest.fn(),
101
+ registerConversation: jest.fn(),
102
+ wipeConversation: jest.fn(),
103
+ handleMLSMessageAddEvent: jest.fn(),
104
+ conversationExists: jest.fn(),
105
+ };
93
106
  const conversationService = new __1.ConversationService(client, mockedProteusService, mockedMLSService);
94
107
  jest.spyOn(conversationService, 'joinByExternalCommit');
108
+ jest.spyOn(conversationService, 'emit');
95
109
  return [conversationService, { apiClient: client, mlsService: mockedMLSService }];
96
110
  }
97
111
  describe('"send PROTEUS"', () => {
@@ -155,13 +169,16 @@ describe('ConversationService', () => {
155
169
  };
156
170
  };
157
171
  it('re-joins multiple not-established conversations', async () => {
158
- const [conversationService, { apiClient }] = buildConversationService();
159
- const mlsConversation1 = createConversation(1, 'conversation1');
160
- const mlsConversation2 = createConversation(1, 'conversation2');
172
+ const [conversationService, { apiClient, mlsService }] = buildConversationService();
173
+ const remoteEpoch = 1;
174
+ const localEpoch = 0;
175
+ const mlsConversation1 = createConversation(remoteEpoch, 'conversation1');
176
+ const mlsConversation2 = createConversation(remoteEpoch, 'conversation2');
161
177
  const mockedDBResponse = [mlsConversation1, mlsConversation2];
162
178
  jest.spyOn(apiClient.api.conversation, 'getConversationList').mockResolvedValueOnce({ found: mockedDBResponse });
163
179
  jest.spyOn(conversationService, 'isMLSConversationEstablished').mockResolvedValue(false);
164
- await conversationService.handleEpochMismatch();
180
+ jest.spyOn(mlsService, 'getEpoch').mockResolvedValue(localEpoch);
181
+ await conversationService.handleConversationsEpochMismatch();
165
182
  expect(conversationService.joinByExternalCommit).toHaveBeenCalledWith(mlsConversation1.qualified_id);
166
183
  expect(conversationService.joinByExternalCommit).toHaveBeenCalledWith(mlsConversation2.qualified_id);
167
184
  });
@@ -173,7 +190,7 @@ describe('ConversationService', () => {
173
190
  jest.spyOn(apiClient.api.conversation, 'getConversationList').mockResolvedValueOnce({ found: mockedDBResponse });
174
191
  jest.spyOn(conversationService, 'isMLSConversationEstablished').mockResolvedValue(true);
175
192
  jest.spyOn(mlsService, 'getEpoch').mockResolvedValue(2);
176
- await conversationService.handleEpochMismatch();
193
+ await conversationService.handleConversationsEpochMismatch();
177
194
  expect(conversationService.joinByExternalCommit).toHaveBeenCalledWith(mlsConversation1.qualified_id);
178
195
  expect(conversationService.joinByExternalCommit).toHaveBeenCalledWith(mlsConversation2.qualified_id);
179
196
  });
@@ -184,7 +201,8 @@ describe('ConversationService', () => {
184
201
  jest.spyOn(apiClient.api.conversation, 'getConversationList').mockResolvedValueOnce({ found: mockedDBResponse });
185
202
  jest.spyOn(conversationService, 'isMLSConversationEstablished').mockResolvedValueOnce(true);
186
203
  jest.spyOn(mlsService, 'getEpoch').mockResolvedValueOnce(1);
187
- await conversationService.handleEpochMismatch();
204
+ jest.spyOn(mlsService, 'conversationExists').mockResolvedValueOnce(true);
205
+ await conversationService.handleConversationsEpochMismatch();
188
206
  expect(conversationService.joinByExternalCommit).not.toHaveBeenCalled();
189
207
  });
190
208
  });
@@ -237,6 +255,30 @@ describe('ConversationService', () => {
237
255
  expect(mlsService.registerConversation).toHaveBeenCalledTimes(2);
238
256
  });
239
257
  });
258
+ describe('handleEvent', () => {
259
+ it('rejoins a MLS conversation if epoch mismatch detected when decrypting mls message', async () => {
260
+ const [conversationService, { apiClient, mlsService }] = buildConversationService();
261
+ const conversationId = { id: 'conversationId', domain: 'staging.zinfra.io' };
262
+ const mockGroupId = 'mock-group-id';
263
+ const mockMLSMessageAddEvent = createMLSMessageAddEventMock(conversationId);
264
+ jest
265
+ .spyOn(mlsService, 'handleMLSMessageAddEvent')
266
+ .mockRejectedValueOnce(new Error(CoreCryptoMLSErrors_1.CoreCryptoMLSErrors.WRONG_EPOCH));
267
+ const remoteEpoch = 5;
268
+ const localEpoch = 4;
269
+ jest.spyOn(mlsService, 'conversationExists').mockResolvedValueOnce(true);
270
+ jest.spyOn(mlsService, 'getEpoch').mockResolvedValueOnce(localEpoch);
271
+ jest.spyOn(apiClient.api.conversation, 'getConversation').mockResolvedValueOnce({
272
+ qualified_id: conversationId,
273
+ protocol: conversation_1.ConversationProtocol.MLS,
274
+ epoch: remoteEpoch,
275
+ group_id: mockGroupId,
276
+ });
277
+ await conversationService.handleEvent(mockMLSMessageAddEvent);
278
+ expect(conversationService.joinByExternalCommit).toHaveBeenCalledWith(conversationId);
279
+ expect(conversationService.emit).toHaveBeenCalledWith('MLSConversationRecovered', { conversationId });
280
+ });
281
+ });
240
282
  describe('fetchAllParticipantsClients', () => {
241
283
  it('gives the members and clients of a federated conversation', async () => {
242
284
  const [conversationService, { apiClient }] = buildConversationService();
@@ -0,0 +1,5 @@
1
+ export declare enum CoreCryptoMLSErrors {
2
+ WRONG_EPOCH = "Incoming message is for the wrong epoch"
3
+ }
4
+ export declare const isCoreCryptoMLSWrongEpochError: (error: unknown) => boolean;
5
+ //# sourceMappingURL=CoreCryptoMLSErrors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CoreCryptoMLSErrors.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/MLSService/CoreCryptoMLSErrors.ts"],"names":[],"mappings":"AAmBA,oBAAY,mBAAmB;IAC7B,WAAW,4CAA4C;CACxD;AAED,eAAO,MAAM,8BAA8B,UAAW,OAAO,KAAG,OAE/D,CAAC"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ /*
3
+ * Wire
4
+ * Copyright (C) 2023 Wire Swiss GmbH
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program. If not, see http://www.gnu.org/licenses/.
18
+ *
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.isCoreCryptoMLSWrongEpochError = exports.CoreCryptoMLSErrors = void 0;
22
+ var CoreCryptoMLSErrors;
23
+ (function (CoreCryptoMLSErrors) {
24
+ CoreCryptoMLSErrors["WRONG_EPOCH"] = "Incoming message is for the wrong epoch";
25
+ })(CoreCryptoMLSErrors || (exports.CoreCryptoMLSErrors = CoreCryptoMLSErrors = {}));
26
+ const isCoreCryptoMLSWrongEpochError = (error) => {
27
+ return error instanceof Error && error.message === CoreCryptoMLSErrors.WRONG_EPOCH;
28
+ };
29
+ exports.isCoreCryptoMLSWrongEpochError = isCoreCryptoMLSWrongEpochError;
@@ -1,5 +1,6 @@
1
1
  import { PostMlsMessageResponse, SUBCONVERSATION_ID } from '@wireapp/api-client/lib/conversation';
2
2
  import { Subconversation } from '@wireapp/api-client/lib/conversation/Subconversation';
3
+ import { ConversationMLSMessageAddEvent, ConversationMLSWelcomeEvent } from '@wireapp/api-client/lib/event';
3
4
  import { QualifiedId } from '@wireapp/api-client/lib/user';
4
5
  import logdown from 'logdown';
5
6
  import { APIClient } from '@wireapp/api-client';
@@ -192,6 +193,8 @@ export declare class MLSService extends TypedEventEmitter<Events> {
192
193
  clientId: string;
193
194
  domain: string;
194
195
  }[]>;
196
+ handleMLSMessageAddEvent(event: ConversationMLSMessageAddEvent): Promise<import("../../../notification").HandledEventPayload | undefined>;
197
+ handleMLSWelcomeMessageEvent(event: ConversationMLSWelcomeEvent): Promise<import("../../../notification").HandledEventPayload>;
195
198
  }
196
199
  export {};
197
200
  //# sourceMappingURL=MLSService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MLSService.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/MLSService/MLSService.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAC,sBAAsB,EAAE,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;AAChG,OAAO,EAAC,eAAe,EAAC,MAAM,sDAAsD,CAAC;AAErF,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAGzD,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EACL,eAAe,EAIf,cAAc,EACd,UAAU,EAEV,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAC,gBAAgB,EAAsB,MAAM,oBAAoB,CAAC;AAIzE,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAK1D,OAAO,EAAC,iBAAiB,EAAC,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAC,4BAA4B,EAAE,4BAA4B,EAAE,YAAY,EAAC,MAAM,UAAU,CAAC;AAIlG,eAAO,MAAM,oBAAoB,U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2B;CAG7E"}
@@ -47,6 +47,7 @@ const fullyQualifiedClientIdUtils_1 = require("../../../util/fullyQualifiedClien
47
47
  const RecurringTaskScheduler_1 = require("../../../util/RecurringTaskScheduler");
48
48
  const TaskScheduler_1 = require("../../../util/TaskScheduler");
49
49
  const TypedEventEmitter_1 = require("../../../util/TypedEventEmitter");
50
+ const events_1 = require("../EventHandler/events");
50
51
  //@todo: this function is temporary, we wait for the update from core-crypto side
51
52
  //they are returning regular array instead of Uint8Array for commit and welcome messages
52
53
  const optionalToUint8Array = (array) => {
@@ -575,5 +576,11 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
575
576
  });
576
577
  return clientIds;
577
578
  }
579
+ async handleMLSMessageAddEvent(event) {
580
+ return (0, events_1.handleMLSMessageAdd)({ event, mlsService: this });
581
+ }
582
+ async handleMLSWelcomeMessageEvent(event) {
583
+ return (0, events_1.handleMLSWelcomeMessage)({ event, mlsService: this });
584
+ }
578
585
  }
579
586
  exports.MLSService = MLSService;
@@ -1,4 +1,3 @@
1
- import { Conversation, ConversationProtocol } from '@wireapp/api-client/lib/conversation';
2
1
  import { QualifiedId } from '@wireapp/api-client/lib/user';
3
2
  import { CoreCryptoCallbacks } from '@wireapp/core-crypto';
4
3
  export type SecretCrypto = {
@@ -52,9 +51,4 @@ export interface CryptoProtocolConfig {
52
51
  /** if set to true, will use experimental proteus encryption/decryption library (core-crypto). If not set will fallback to the legacy proteus library (cryptobox) */
53
52
  proteus?: boolean;
54
53
  }
55
- export type MLSConversation = Conversation & {
56
- protocol: ConversationProtocol.MLS;
57
- epoch: number;
58
- group_id: string;
59
- };
60
54
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/messagingProtocols/mls/types.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,YAAY,EAAE,oBAAoB,EAAC,MAAM,sCAAsC,CAAC;AACxF,OAAO,EAAC,WAAW,EAAC,MAAM,8B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4BAA4B,GAAG;IACzC,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,SAAS,CAAC;AAEd,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAE5B,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;;OAIG;IACH,qBAAqB,EAAE,MAAM,CAAC;IAE9B,uEAAuE;IACvE,GAAG,CAAC,EAAE;QACJ;;WAEG;QACH,6BAA6B,CAAC,EAAE,MAAM,CAAC;KACxC,CAAC;IAEF,oKAAoK;IACpK,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
@@ -1,6 +1,5 @@
1
- import { Conversation, QualifiedUserClients, UserClients } from '@wireapp/api-client/lib/conversation/';
1
+ import { Conversation, MLSConversation, QualifiedUserClients, UserClients } from '@wireapp/api-client/lib/conversation/';
2
2
  import { QualifiedId } from '@wireapp/api-client/lib/user/';
3
- import { MLSConversation } from '../messagingProtocols/mls/types';
4
3
  export declare function isStringArray(obj: any): obj is string[];
5
4
  export declare function isQualifiedIdArray(obj: any): obj is QualifiedId[];
6
5
  export declare function isQualifiedUserClients(obj: any): obj is QualifiedUserClients;
@@ -1 +1 @@
1
- {"version":3,"file":"TypePredicateUtil.d.ts","sourceRoot":"","sources":["../../src/util/TypePredicateUtil.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,YAAY,EAEZ,oBAAoB,EACpB,WAAW,EACZ,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAC,WAAW,EAAC,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAEhE,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,MAAM,EAAE,CAEvD;AAMD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,WAAW,EAAE,CAEjE;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,oBAAoB,CAS5E;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,WAAW,CAM1D;AAED,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,YAAY,GAAG,YAAY,IAAI,eAAe,CAG7F"}
1
+ {"version":3,"file":"TypePredicateUtil.d.ts","sourceRoot":"","sources":["../../src/util/TypePredicateUtil.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,YAAY,EAEZ,eAAe,EACf,oBAAoB,EACpB,WAAW,EACZ,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAC,WAAW,EAAC,MAAM,+BAA+B,CAAC;AAE1D,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,MAAM,EAAE,CAEvD;AAMD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,WAAW,EAAE,CAEjE;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,oBAAoB,CAS5E;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,WAAW,CAM1D;AAED,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,YAAY,GAAG,YAAY,IAAI,eAAe,CAG7F"}
package/package.json CHANGED
@@ -60,6 +60,6 @@
60
60
  "test:coverage": "jest --coverage",
61
61
  "watch": "tsc --watch"
62
62
  },
63
- "version": "41.3.2",
64
- "gitHead": "25cda76a8722c6ea34b364f5b79c96dfdc519022"
63
+ "version": "41.4.0",
64
+ "gitHead": "658953da9d1983bcab668f5d9454cd5660f8c80e"
65
65
  }