@wireapp/core 30.9.0 → 30.11.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/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [30.11.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@30.10.0...@wireapp/core@30.11.0) (2022-09-19)
7
+
8
+
9
+ ### Features
10
+
11
+ * leave mls conversation (FS-683) ([#4399](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4399)) ([4e5087a](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/4e5087a8c224d95e1685376fedee202b2b4cb039))
12
+
13
+
14
+
15
+
16
+
17
+ # [30.10.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@30.9.0...@wireapp/core@30.10.0) (2022-09-15)
18
+
19
+
20
+ ### Features
21
+
22
+ * Queue message sending [FS-882] ([#4392](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4392)) ([3b29dd0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/3b29dd012ebd41debcea3460c6e0fffa2da3646e))
23
+
24
+
25
+
26
+
27
+
6
28
  # [30.9.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@30.8.0...@wireapp/core@30.9.0) (2022-09-15)
7
29
 
8
30
 
package/package.json CHANGED
@@ -10,6 +10,7 @@
10
10
  "@wireapp/commons": "4.3.0",
11
11
  "@wireapp/core-crypto": "0.4.0",
12
12
  "@wireapp/cryptobox": "12.8.0",
13
+ "@wireapp/promise-queue": "1.1.1",
13
14
  "@wireapp/store-engine-dexie": "1.6.10",
14
15
  "bazinga64": "5.10.0",
15
16
  "hash.js": "1.1.7",
@@ -77,6 +78,6 @@
77
78
  "test:node": "nyc jasmine --config=jasmine.json",
78
79
  "watch": "tsc ---watch"
79
80
  },
80
- "version": "30.9.0",
81
- "gitHead": "72d73664ce7afadd6bb3aba146a5102ce2938f48"
81
+ "version": "30.11.0",
82
+ "gitHead": "3f0c9ee9078ae7bbebc53e6e881b69857488ac16"
82
83
  }
@@ -73,6 +73,7 @@ const linkPreview_1 = require("./linkPreview");
73
73
  const encryptedStore_1 = require("./util/encryptedStore");
74
74
  const bazinga64_1 = require("bazinga64");
75
75
  const mls_1 = require("./mls");
76
+ const messageSender_1 = require("./conversation/message/messageSender");
76
77
  var TOPIC;
77
78
  (function (TOPIC) {
78
79
  TOPIC["ERROR"] = "Account.TOPIC.ERROR";
@@ -402,6 +403,9 @@ class Account extends events_1.EventEmitter {
402
403
  }, onMissedNotifications, abortHandler);
403
404
  // We can now unlock the websocket and let the new messages being handled and decrypted
404
405
  this.apiClient.transport.ws.unlock();
406
+ // We need to wait for the notification stream to be fully handled before releasing the message sending queue.
407
+ // This is due to the nature of how message are encrypted, any change in mls epoch needs to happen before we start encrypting any kind of messages
408
+ (0, messageSender_1.resumeMessageSending)();
405
409
  onConnected();
406
410
  };
407
411
  await this.apiClient.connect(onBeforeConnect);
@@ -111,7 +111,6 @@ export declare class ConversationService {
111
111
  deleteMessageLocal(conversationId: string, messageIdToHide: string, sendAsProtobuf?: boolean, conversationDomain?: string): Promise<HideMessage>;
112
112
  deleteMessageEveryone(conversationId: string, messageIdToDelete: string, userIds?: string[] | QualifiedId[] | UserClients | QualifiedUserClients, sendAsProtobuf?: boolean, conversationDomain?: string, callbacks?: MessageSendingCallbacks): Promise<DeleteMessage>;
113
113
  leaveConversation(conversationId: QualifiedId): Promise<ConversationMemberLeaveEvent>;
114
- leaveMLSConversation(conversationId: QualifiedId): Promise<ConversationMemberLeaveEvent>;
115
114
  /**
116
115
  * @depricated seems not to be used and is outdated. use leaveConversation instead
117
116
  */
@@ -171,4 +170,5 @@ export declare class ConversationService {
171
170
  */
172
171
  sendExternalJoinProposal(conversationGroupId: string, epoch: number): Promise<void>;
173
172
  isMLSConversationEstablished(conversationGroupId: string): Promise<boolean>;
173
+ wipeMLSConversation(conversationId: Uint8Array): Promise<void>;
174
174
  }
@@ -32,6 +32,7 @@ const ConversationService_types_1 = require("./ConversationService.types");
32
32
  const bazinga64_1 = require("bazinga64");
33
33
  const mapQualifiedUserClientIdsToFullyQualifiedClientIds_1 = require("../../util/mapQualifiedUserClientIdsToFullyQualifiedClientIds");
34
34
  const mls_1 = require("../../mls");
35
+ const messageSender_1 = require("../message/messageSender");
35
36
  class ConversationService {
36
37
  constructor(apiClient, cryptographyService, config, notificationService, mlsService) {
37
38
  this.apiClient = apiClient;
@@ -624,9 +625,6 @@ class ConversationService {
624
625
  id: this.apiClient.context.userId,
625
626
  });
626
627
  }
627
- leaveMLSConversation(conversationId) {
628
- return this.leaveConversation(conversationId);
629
- }
630
628
  /**
631
629
  * @depricated seems not to be used and is outdated. use leaveConversation instead
632
630
  */
@@ -716,9 +714,9 @@ class ConversationService {
716
714
  // If the onStart call returns false, it means the consumer wants to cancel the message sending
717
715
  return Object.assign(Object.assign({}, payload), { state: conversation_2.PayloadBundleState.CANCELLED });
718
716
  }
719
- return isMLS(params)
717
+ return (0, messageSender_1.sendMessage)(() => isMLS(params)
720
718
  ? this.sendMLSMessage(params, genericMessage, content)
721
- : this.sendProteusMessage(params, genericMessage, content);
719
+ : this.sendProteusMessage(params, genericMessage, content));
722
720
  }
723
721
  sendTypingStart(conversationId) {
724
722
  return this.apiClient.api.conversation.postTyping(conversationId, { status: data_1.CONVERSATION_TYPING.STARTED });
@@ -916,21 +914,26 @@ class ConversationService {
916
914
  * @param epoch The current epoch of the local conversation
917
915
  */
918
916
  async sendExternalJoinProposal(conversationGroupId, epoch) {
919
- const groupIdDecodedFromBase64 = bazinga64_1.Decoder.fromBase64(conversationGroupId).asBytes;
920
- const externalProposal = await this.mlsService.newExternalProposal(0 /* Add */, {
921
- epoch,
922
- conversationId: groupIdDecodedFromBase64,
917
+ return (0, messageSender_1.sendMessage)(async () => {
918
+ const groupIdDecodedFromBase64 = bazinga64_1.Decoder.fromBase64(conversationGroupId).asBytes;
919
+ const externalProposal = await this.mlsService.newExternalProposal(0 /* Add */, {
920
+ epoch,
921
+ conversationId: groupIdDecodedFromBase64,
922
+ });
923
+ await this.apiClient.api.conversation.postMlsMessage(
924
+ //@todo: it's temporary - we wait for core-crypto fix to return the actual Uint8Array instead of regular array
925
+ (0, mls_1.optionalToUint8Array)(externalProposal));
926
+ //We store the info when user was added (and key material was created), so we will know when to renew it
927
+ await this.storeLastKeyMaterialUpdateDateWithCurrentTime(conversationGroupId);
923
928
  });
924
- await this.apiClient.api.conversation.postMlsMessage(
925
- //@todo: it's temporary - we wait for core-crypto fix to return the actual Uint8Array instead of regular array
926
- (0, mls_1.optionalToUint8Array)(externalProposal));
927
- //We store the info when user was added (and key material was created), so we will know when to renew it
928
- await this.storeLastKeyMaterialUpdateDateWithCurrentTime(conversationGroupId);
929
929
  }
930
930
  async isMLSConversationEstablished(conversationGroupId) {
931
931
  const groupIdDecodedFromBase64 = bazinga64_1.Decoder.fromBase64(conversationGroupId).asBytes;
932
932
  return this.mlsService.conversationExists(groupIdDecodedFromBase64);
933
933
  }
934
+ async wipeMLSConversation(conversationId) {
935
+ return this.mlsService.wipeConversation(conversationId);
936
+ }
934
937
  }
935
938
  exports.ConversationService = ConversationService;
936
939
  //# sourceMappingURL=ConversationService.js.map
@@ -0,0 +1,4 @@
1
+ import { Task } from '@wireapp/promise-queue';
2
+ export declare function sendMessage<T>(sendingFunction: Task<T>): Promise<T>;
3
+ export declare function resumeMessageSending(): void;
4
+ export declare function pauseMessageSending(): void;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ /*
3
+ * Wire
4
+ * Copyright (C) 2022 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.pauseMessageSending = exports.resumeMessageSending = exports.sendMessage = void 0;
22
+ const promise_queue_1 = require("@wireapp/promise-queue");
23
+ const sendingQueue = new promise_queue_1.PromiseQueue({ name: 'message-sender', paused: true });
24
+ function sendMessage(sendingFunction) {
25
+ return sendingQueue.push(sendingFunction);
26
+ }
27
+ exports.sendMessage = sendMessage;
28
+ function resumeMessageSending() {
29
+ sendingQueue.pause(false);
30
+ }
31
+ exports.resumeMessageSending = resumeMessageSending;
32
+ function pauseMessageSending() {
33
+ sendingQueue.pause(true);
34
+ }
35
+ exports.pauseMessageSending = pauseMessageSending;
36
+ //# sourceMappingURL=messageSender.js.map
@@ -33,4 +33,5 @@ export declare class MLSService {
33
33
  */
34
34
  uploadMLSPublicKeys(publicKey: Uint8Array, clientId: string): Promise<void>;
35
35
  uploadMLSKeyPackages(keypackages: Uint8Array[], clientId: string): Promise<void>;
36
+ wipeConversation(conversationId: ConversationId): Promise<void>;
36
37
  }
@@ -20,6 +20,7 @@
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.MLSService = exports.optionalToUint8Array = void 0;
22
22
  const bazinga64_1 = require("bazinga64");
23
+ const messageSender_1 = require("../../conversation/message/messageSender");
23
24
  //@todo: this function is temporary, we wait for the update from core-crypto side
24
25
  //they are returning regular array instead of Uint8Array for commit and welcome messages
25
26
  const optionalToUint8Array = (array) => {
@@ -60,10 +61,12 @@ class MLSService {
60
61
  }
61
62
  return null;
62
63
  }
63
- async addUsersToExistingConversation(groupId, invitee) {
64
- const coreCryptoClient = this.getCoreCryptoClient();
65
- const memberAddedMessages = await coreCryptoClient.addClientsToConversation(groupId, invitee);
66
- return this.uploadCommitBundle(groupId, memberAddedMessages);
64
+ addUsersToExistingConversation(groupId, invitee) {
65
+ return (0, messageSender_1.sendMessage)(async () => {
66
+ const coreCryptoClient = this.getCoreCryptoClient();
67
+ const memberAddedMessages = await coreCryptoClient.addClientsToConversation(groupId, invitee);
68
+ return this.uploadCommitBundle(groupId, memberAddedMessages);
69
+ });
67
70
  }
68
71
  async getKeyPackagesPayload(qualifiedUsers) {
69
72
  /**
@@ -104,16 +107,20 @@ class MLSService {
104
107
  async encryptMessage(conversationId, message) {
105
108
  return this.getCoreCryptoClient().encryptMessage(conversationId, message);
106
109
  }
107
- async updateKeyingMaterial(conversationId) {
108
- const commitBundle = await this.getCoreCryptoClient().updateKeyingMaterial(conversationId);
109
- return this.uploadCommitBundle(conversationId, commitBundle);
110
+ updateKeyingMaterial(conversationId) {
111
+ return (0, messageSender_1.sendMessage)(async () => {
112
+ const commitBundle = await this.getCoreCryptoClient().updateKeyingMaterial(conversationId);
113
+ return this.uploadCommitBundle(conversationId, commitBundle);
114
+ });
110
115
  }
111
116
  async createConversation(conversationId, configuration) {
112
117
  return this.getCoreCryptoClient().createConversation(conversationId, configuration);
113
118
  }
114
- async removeClientsFromConversation(conversationId, clientIds) {
115
- const commitBundle = await this.getCoreCryptoClient().removeClientsFromConversation(conversationId, clientIds);
116
- return this.uploadCommitBundle(conversationId, commitBundle);
119
+ removeClientsFromConversation(conversationId, clientIds) {
120
+ return (0, messageSender_1.sendMessage)(async () => {
121
+ const commitBundle = await this.getCoreCryptoClient().removeClientsFromConversation(conversationId, clientIds);
122
+ return this.uploadCommitBundle(conversationId, commitBundle);
123
+ });
117
124
  }
118
125
  async commitPendingProposals(conversationId) {
119
126
  return this.getCoreCryptoClient().commitPendingProposals(conversationId);
@@ -141,6 +148,9 @@ class MLSService {
141
148
  async uploadMLSKeyPackages(keypackages, clientId) {
142
149
  return this.apiClient.api.client.uploadMLSKeyPackages(clientId, keypackages.map(keypackage => btoa(bazinga64_1.Converter.arrayBufferViewToBaselineString(keypackage))));
143
150
  }
151
+ async wipeConversation(conversationId) {
152
+ return this.getCoreCryptoClient().wipeConversation(conversationId);
153
+ }
144
154
  }
145
155
  exports.MLSService = MLSService;
146
156
  //# sourceMappingURL=MLSService.js.map