@wireapp/core 40.5.2 → 40.5.3-draft-20-cc.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.
Files changed (139) hide show
  1. package/lib/Account.d.ts +7 -9
  2. package/lib/Account.d.ts.map +1 -1
  3. package/lib/Account.js +35 -32
  4. package/lib/CoreError.js +1 -1
  5. package/lib/broadcast/BroadcastService.d.ts +11 -2
  6. package/lib/broadcast/BroadcastService.d.ts.map +1 -1
  7. package/lib/broadcast/BroadcastService.js +39 -5
  8. package/lib/client/ClientDatabaseRepository.d.ts +5 -5
  9. package/lib/client/ClientDatabaseRepository.d.ts.map +1 -1
  10. package/lib/client/ClientDatabaseRepository.js +17 -10
  11. package/lib/client/ClientService.d.ts +1 -5
  12. package/lib/client/ClientService.d.ts.map +1 -1
  13. package/lib/client/ClientService.js +9 -11
  14. package/lib/connection/ConnectionService.d.ts +2 -2
  15. package/lib/connection/ConnectionService.d.ts.map +1 -1
  16. package/lib/connection/ConnectionService.js +2 -2
  17. package/lib/conversation/AssetTransferState.js +1 -1
  18. package/lib/conversation/ConversationService/ConversationService.d.ts +5 -12
  19. package/lib/conversation/ConversationService/ConversationService.d.ts.map +1 -1
  20. package/lib/conversation/ConversationService/ConversationService.js +11 -26
  21. package/lib/conversation/ConversationService/ConversationService.test.js +1 -1
  22. package/lib/conversation/ConversationService/ConversationService.types.d.ts +11 -12
  23. package/lib/conversation/ConversationService/ConversationService.types.d.ts.map +1 -1
  24. package/lib/conversation/ConversationService/ConversationService.types.js +1 -1
  25. package/lib/conversation/ConversationService/Utility/getConversationQualifiedMembers.d.ts +1 -1
  26. package/lib/conversation/ConversationService/Utility/getConversationQualifiedMembers.d.ts.map +1 -1
  27. package/lib/conversation/GenericMessageType.js +1 -1
  28. package/lib/conversation/ReactionType.d.ts +4 -1
  29. package/lib/conversation/ReactionType.d.ts.map +1 -1
  30. package/lib/conversation/ReactionType.js +6 -0
  31. package/lib/conversation/message/Message.types.js +1 -1
  32. package/lib/conversation/message/MessageBuilder.d.ts +1 -1
  33. package/lib/conversation/message/MessageBuilder.d.ts.map +1 -1
  34. package/lib/conversation/message/MessageBuilder.js +2 -2
  35. package/lib/conversation/message/MessageService.d.ts +31 -6
  36. package/lib/conversation/message/MessageService.d.ts.map +1 -1
  37. package/lib/conversation/message/MessageService.js +162 -19
  38. package/lib/conversation/message/MessageService.test.js +141 -151
  39. package/lib/conversation/message/PayloadBundle.js +1 -1
  40. package/lib/conversation/message/UserClientsUtil.d.ts +10 -14
  41. package/lib/conversation/message/UserClientsUtil.d.ts.map +1 -1
  42. package/lib/conversation/message/UserClientsUtil.js +11 -21
  43. package/lib/conversation/message/UserClientsUtils.test.js +9 -5
  44. package/lib/messagingProtocols/mls/EventHandler/EventHandler.d.ts +1 -1
  45. package/lib/messagingProtocols/mls/EventHandler/EventHandler.d.ts.map +1 -1
  46. package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.d.ts +1 -1
  47. package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.d.ts.map +1 -1
  48. package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.js +2 -7
  49. package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.d.ts.map +1 -1
  50. package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.js +0 -2
  51. package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.test.js +1 -3
  52. package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts +8 -19
  53. package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts.map +1 -1
  54. package/lib/messagingProtocols/mls/MLSService/MLSService.js +37 -79
  55. package/lib/messagingProtocols/mls/MLSService/MLSService.test.js +0 -9
  56. package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/index.d.ts +2 -0
  57. package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/index.d.ts.map +1 -0
  58. package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/index.js +35 -0
  59. package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.d.ts +11 -0
  60. package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.d.ts.map +1 -0
  61. package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.js +50 -0
  62. package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.test.d.ts +2 -0
  63. package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.test.d.ts.map +1 -0
  64. package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.test.js +39 -0
  65. package/lib/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.d.ts +4 -0
  66. package/lib/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.d.ts.map +1 -0
  67. package/lib/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.js +35 -0
  68. package/lib/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.test.d.ts +2 -0
  69. package/lib/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.test.d.ts.map +1 -0
  70. package/lib/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.test.js +35 -0
  71. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.d.ts +5 -10
  72. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.d.ts.map +1 -1
  73. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.js +11 -33
  74. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.d.ts +3 -2
  75. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.d.ts.map +1 -1
  76. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.js +9 -8
  77. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.store.d.ts +9 -4
  78. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.store.d.ts.map +1 -1
  79. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.store.js +24 -10
  80. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.test.js +10 -2
  81. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.d.ts +2 -1
  82. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.d.ts.map +1 -1
  83. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.js +3 -3
  84. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.d.ts +2 -2
  85. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.d.ts.map +1 -1
  86. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoboxWrapper.d.ts +1 -1
  87. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoboxWrapper.d.ts.map +1 -1
  88. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoboxWrapper.js +2 -2
  89. package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts +7 -14
  90. package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts.map +1 -1
  91. package/lib/messagingProtocols/proteus/ProteusService/ProteusService.js +35 -31
  92. package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts +1 -1
  93. package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts.map +1 -1
  94. package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.js +3 -2
  95. package/lib/messagingProtocols/proteus/ProteusService/ProteusService.test.js +89 -109
  96. package/lib/messagingProtocols/proteus/ProteusService/ProteusService.types.d.ts +9 -6
  97. package/lib/messagingProtocols/proteus/ProteusService/ProteusService.types.d.ts.map +1 -1
  98. package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.d.ts +25 -0
  99. package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.d.ts.map +1 -0
  100. package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.js +93 -0
  101. package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.test.d.ts +2 -0
  102. package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.test.d.ts.map +1 -0
  103. package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.test.js +66 -0
  104. package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/index.d.ts +2 -0
  105. package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/index.d.ts.map +1 -0
  106. package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/index.js +35 -0
  107. package/lib/messagingProtocols/proteus/Utility/Recipients.d.ts +10 -4
  108. package/lib/messagingProtocols/proteus/Utility/Recipients.d.ts.map +1 -1
  109. package/lib/messagingProtocols/proteus/Utility/Recipients.js +16 -16
  110. package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.d.ts +10 -15
  111. package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.d.ts.map +1 -1
  112. package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.js +92 -80
  113. package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.test.js +54 -70
  114. package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.d.ts +14 -5
  115. package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.d.ts.map +1 -1
  116. package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.js +35 -3
  117. package/lib/messagingProtocols/proteus/Utility/isClearFromMismatch.d.ts +2 -2
  118. package/lib/messagingProtocols/proteus/Utility/isClearFromMismatch.d.ts.map +1 -1
  119. package/lib/notification/NotificationDatabaseRepository.js +1 -1
  120. package/lib/notification/Notifications.types.js +1 -1
  121. package/lib/user/UserService.d.ts +17 -6
  122. package/lib/user/UserService.d.ts.map +1 -1
  123. package/lib/user/UserService.js +47 -2
  124. package/lib/util/TaskScheduler/TaskScheduler.d.ts +1 -4
  125. package/lib/util/TaskScheduler/TaskScheduler.d.ts.map +1 -1
  126. package/lib/util/TaskScheduler/TaskScheduler.js +3 -24
  127. package/lib/util/TypePredicateUtil.d.ts +1 -0
  128. package/lib/util/TypePredicateUtil.d.ts.map +1 -1
  129. package/lib/util/TypePredicateUtil.js +2 -1
  130. package/package.json +3 -3
  131. package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.d.ts +0 -13
  132. package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.d.ts.map +0 -1
  133. package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.js +0 -67
  134. package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.test.d.ts +0 -2
  135. package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.test.d.ts.map +0 -1
  136. package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.test.js +0 -72
  137. package/lib/util/TaskScheduler/TaskScheduler.store.d.ts +0 -7
  138. package/lib/util/TaskScheduler/TaskScheduler.store.d.ts.map +0 -1
  139. package/lib/util/TaskScheduler/TaskScheduler.store.js +0 -34
@@ -155,9 +155,12 @@ class ConversationService {
155
155
  * Will create a conversation on backend and register it to CoreCrypto once created
156
156
  * @param conversationData
157
157
  */
158
- async createMLSConversation(conversationData, selfUserId, selfClientId) {
158
+ async createMLSConversation(conversationData) {
159
159
  var _a;
160
- const { qualified_users: qualifiedUsers = [] } = conversationData;
160
+ const { selfUserId, qualified_users: qualifiedUsers = [] } = conversationData;
161
+ if (!selfUserId) {
162
+ throw new Error('You need to pass self user qualified id in order to create an MLS conversation');
163
+ }
161
164
  /**
162
165
  * @note For creating MLS conversations the users & qualified_users
163
166
  * field must be empty as backend is not aware which users
@@ -170,7 +173,7 @@ class ConversationService {
170
173
  }
171
174
  const response = await this.mlsService.registerConversation(groupId, qualifiedUsers.concat(selfUserId), {
172
175
  user: selfUserId,
173
- client: selfClientId,
176
+ client: conversationData.creator_client,
174
177
  });
175
178
  // We fetch the fresh version of the conversation created on backend with the newly added users
176
179
  const conversation = await this.apiClient.api.conversation.getConversation(qualifiedId);
@@ -180,41 +183,25 @@ class ConversationService {
180
183
  };
181
184
  }
182
185
  async sendMLSMessage({ payload, groupId }) {
183
- var _a, _b;
184
186
  const groupIdBytes = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
185
187
  // immediately execute pending commits before sending the message
186
188
  await this.mlsService.commitPendingProposals({ groupId });
187
189
  const encrypted = await this.mlsService.encryptMessage(groupIdBytes, protocol_messaging_1.GenericMessage.encode(payload).finish());
188
- let response = null;
189
190
  let sentAt = '';
190
191
  try {
191
- response = await this.apiClient.api.conversation.postMlsMessage(encrypted);
192
- sentAt = ((_a = response.time) === null || _a === void 0 ? void 0 : _a.length) > 0 ? response.time : new Date().toISOString();
192
+ const { time = '' } = await this.apiClient.api.conversation.postMlsMessage(encrypted);
193
+ sentAt = (time === null || time === void 0 ? void 0 : time.length) > 0 ? time : new Date().toISOString();
193
194
  }
194
- catch (_c) { }
195
- const failedToSend = (response === null || response === void 0 ? void 0 : response.failed) || ((_b = response === null || response === void 0 ? void 0 : response.failed_to_send) !== null && _b !== void 0 ? _b : []).length > 0
196
- ? {
197
- queued: response === null || response === void 0 ? void 0 : response.failed_to_send,
198
- failed: response === null || response === void 0 ? void 0 : response.failed,
199
- }
200
- : undefined;
195
+ catch (_a) { }
201
196
  return {
202
197
  id: payload.messageId,
203
198
  sentAt,
204
- failedToSend,
205
199
  state: sentAt ? conversation_2.MessageSendingState.OUTGOING_SENT : conversation_2.MessageSendingState.CANCELED,
206
200
  };
207
201
  }
208
- /**
209
- * Will add users to existing MLS group by claiming their key packages and passing them to CoreCrypto.addClientsToConversation
210
- *
211
- * @param qualifiedUsers List of qualified user ids (with optional skipOwnClientId field - if provided we will not claim key package for this self client)
212
- * @param groupId Id of the group to which we want to add users
213
- * @param conversationId Id of the conversation to which we want to add users
214
- */
215
- async addUsersToMLSConversation({ qualifiedUsers, groupId, conversationId, }) {
202
+ async addUsersToMLSConversation({ qualifiedUserIds, groupId, conversationId, }) {
216
203
  const groupIdBytes = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
217
- const coreCryptoKeyPackagesPayload = await this.mlsService.getKeyPackagesPayload(qualifiedUsers);
204
+ const coreCryptoKeyPackagesPayload = await this.mlsService.getKeyPackagesPayload([...qualifiedUserIds]);
218
205
  const response = await this.mlsService.addUsersToExistingConversation(groupIdBytes, coreCryptoKeyPackagesPayload);
219
206
  const conversation = await this.getConversation(conversationId);
220
207
  //We store the info when user was added (and key material was created), so we will know when to renew it
@@ -251,8 +238,6 @@ class ConversationService {
251
238
  const externalProposal = await this.mlsService.newExternalProposal(core_crypto_1.ExternalProposalType.Add, {
252
239
  epoch,
253
240
  conversationId: groupIdBytes,
254
- ciphersuite: core_crypto_1.Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519,
255
- credentialType: core_crypto_1.CredentialType.Basic,
256
241
  });
257
242
  await this.apiClient.api.conversation.postMlsMessage(
258
243
  //@todo: it's temporary - we wait for core-crypto fix to return the actual Uint8Array instead of regular array
@@ -208,7 +208,7 @@ describe('ConversationService', () => {
208
208
  { domain: 'test-domain', id: 'test-id-1' },
209
209
  { domain: 'test-domain', id: 'test-id-2' },
210
210
  ]);
211
- const fetchedMembers = await conversationService.fetchAllParticipantsClients({ id: 'convid', domain: '' });
211
+ const fetchedMembers = await conversationService.fetchAllParticipantsClients('convid');
212
212
  expect(fetchedMembers).toEqual(members);
213
213
  });
214
214
  });
@@ -1,4 +1,4 @@
1
- import { QualifiedUserClients, ConversationProtocol, MessageSendingStatus, Conversation } from '@wireapp/api-client/lib/conversation';
1
+ import { QualifiedUserClients, ClientMismatch, ConversationProtocol, MessageSendingStatus, UserClients, Conversation } from '@wireapp/api-client/lib/conversation';
2
2
  import { ConversationEvent } from '@wireapp/api-client/lib/event';
3
3
  import { QualifiedId } from '@wireapp/api-client/lib/user';
4
4
  import { GenericMessage } from '@wireapp/protocol-messaging';
@@ -15,7 +15,11 @@ export interface MessageSendingOptions {
15
15
  * When given a QualifiedId[] the method will fetch the freshest list of devices for those users (since they are not given by the consumer). As a consequence no ClientMismatch error will trigger and we will ignore missing clients when sending
16
16
  * When given a QualifiedUserClients the method will only send to the clients listed in the userIds. This could lead to ClientMismatch (since the given list of devices might not be the freshest one and new clients could have been created)
17
17
  */
18
- userIds?: QualifiedId[] | QualifiedUserClients;
18
+ userIds?: string[] | QualifiedId[] | UserClients | QualifiedUserClients;
19
+ /**
20
+ * Will send the message as a protobuf payload
21
+ */
22
+ sendAsProtobuf?: boolean;
19
23
  nativePush?: boolean;
20
24
  /**
21
25
  * Will be called whenever there is a clientmismatch returned from the server. Needs to be combined with a userIds of type QualifiedUserClients
@@ -37,7 +41,7 @@ export interface MessageSendingCallbacks {
37
41
  * @param wasSent Indicate whether the message was already sent or if it can still be canceled
38
42
  * @return
39
43
  */
40
- onClientMismatch?: (status: MessageSendingStatus, wasSent: boolean) => void | boolean | Promise<boolean>;
44
+ onClientMismatch?: (status: ClientMismatch | MessageSendingStatus, wasSent: boolean) => void | boolean | Promise<boolean>;
41
45
  }
42
46
  /**
43
47
  * ######################################################################
@@ -63,12 +67,12 @@ export type SendMlsMessageParams = SendCommonParams & {
63
67
  groupId: string;
64
68
  protocol: ConversationProtocol.MLS;
65
69
  };
66
- export type KeyPackageClaimUser = QualifiedId & {
67
- skipOwnClientId?: string;
70
+ export type QualifiedUsers = QualifiedId & {
71
+ skipOwn?: string;
68
72
  };
69
73
  export type AddUsersParams = {
70
74
  conversationId: QualifiedId;
71
- qualifiedUsers: KeyPackageClaimUser[];
75
+ qualifiedUserIds: QualifiedId[];
72
76
  groupId?: string;
73
77
  };
74
78
  export type RemoveUsersParams = {
@@ -88,11 +92,6 @@ export type SendResult = {
88
92
  /** The sending state of the payload (has the payload been succesfully sent or canceled) */
89
93
  state: MessageSendingState;
90
94
  /** In case the message was sent to some federated backend, if the backend was down at the moment of sending the `failedToSend` property will contain all the users/devices that couldn't get the message */
91
- failedToSend?: {
92
- /** the message was encrypted for those recipients but will reach them later (a session existed but their backend is offline) */
93
- queued?: QualifiedUserClients | QualifiedId[];
94
- /** the message could not be encrypted for those recipients and thus will never reach them (a session did not exist and their backend if offline) */
95
- failed?: QualifiedId[];
96
- };
95
+ failedToSend?: QualifiedUserClients;
97
96
  };
98
97
  //# sourceMappingURL=ConversationService.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ConversationService.types.d.ts","sourceRoot":"","sources":["../../../src/conversation/ConversationService/ConversationService.types.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACb,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAC,iBAAiB,EAAC,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAC,mBAAmB,EAAC,MAAM,IAAI,CAAC;AAEvC,oBAAY,iBAAiB;IAC3B,IAAI,IAAA;IACJ,KAAK,IAAA;IACL,aAAa,IAAA;CACd;AAED,MAAM,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iBAAiB,EAAE,CAAC;IAAC,YAAY,EAAE,YAAY,CAAA;CAAC,CAAC;AAEtF,MAAM,MAAM,UAAU,GAAG;IACvB,iCAAiC;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,8EAA8E;IAC9E,MAAM,EAAE,MAAM,CAAC;IACf,2FAA2F;IAC3F,KAAK,EAAE,mBAAmB,CAAC;IAC3B,4MAA4M;IAC5M,YAAY,CAAC,EAAE;QACb,gIAAgI;QAChI,MAAM,CAAC,EAAE,oBAAoB,GAAG,WAAW,EAAE,CAAC;QAC9C,oJAAoJ;QACpJ,MAAM,CAAC,EAAE,WAAW,EAAE,CAAC;KACxB,CAAC;CACH,CAAC"}
1
+ {"version":3,"file":"ConversationService.types.d.ts","sourceRoot":"","sources":["../../../src/conversation/ConversationService/ConversationService.types.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,WAAW,EACX,YAAY,EACb,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAC,iBAAiB,EAAC,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAE3D,OAAO,EAAC,mBAAmB,EAAC,MAAM,IAAI,CAAC;AAEvC,oBAAY,iBAAiB;IAC3B,IAAI,IAAA;IACJ,KAAK,IAAA;IACL,aAAa,IAAA;CACd;AAED,MAAM,WAAW,qBAAqB;IACpC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,GAAG,WAAW,GAAG,oBAAoB,CAAC;IAExE;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,gBAAgB,CAAC,EAAE,uBAAuB,CAAC,kBAAkB,CAAC,CAAC;IAE/D;;;;;OAKG;IACH,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AE,mBAAmB,CAAC;IAC3B,4MAA4M;IAC5M,YAAY,CAAC,EAAE,oBAAoB,CAAC;CACrC,CAAC"}
@@ -24,4 +24,4 @@ var MessageTargetMode;
24
24
  MessageTargetMode[MessageTargetMode["NONE"] = 0] = "NONE";
25
25
  MessageTargetMode[MessageTargetMode["USERS"] = 1] = "USERS";
26
26
  MessageTargetMode[MessageTargetMode["USERS_CLIENTS"] = 2] = "USERS_CLIENTS";
27
- })(MessageTargetMode || (exports.MessageTargetMode = MessageTargetMode = {}));
27
+ })(MessageTargetMode = exports.MessageTargetMode || (exports.MessageTargetMode = {}));
@@ -2,7 +2,7 @@ import { APIClient } from '@wireapp/api-client/lib/APIClient';
2
2
  import { QualifiedId } from '@wireapp/api-client/lib/user';
3
3
  interface Params {
4
4
  apiClient: APIClient;
5
- conversationId: QualifiedId;
5
+ conversationId: string | QualifiedId;
6
6
  }
7
7
  declare const getConversationQualifiedMembers: ({ apiClient, conversationId }: Params) => Promise<QualifiedId[]>;
8
8
  export { getConversationQualifiedMembers };
@@ -1 +1 @@
1
- {"version":3,"file":"getConversationQualifiedMembers.d.ts","sourceRoot":"","sources":["../../../../src/conversation/ConversationService/Utility/getConversationQualifiedMembers.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAEzD,UAAU,MAAM;IACd,SAAS,EAAE,SAAS,CAAC;IACrB,cAAc,EAAE,WAAW,CAAC;CAC7B;AACD,QAAA,MAAM,+BAA+B,kCAAuC,MAAM,KAAG,QAAQ,WAAW,EAAE,CAWzG,CAAC;AAEF,OAAO,EAAC,+BAA+B,EAAC,CAAC"}
1
+ {"version":3,"file":"getConversationQualifiedMembers.d.ts","sourceRoot":"","sources":["../../../../src/conversation/ConversationService/Utility/getConversationQualifiedMembers.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAEzD,UAAU,MAAM;IACd,SAAS,EAAE,SAAS,CAAC;IACrB,cAAc,EAAE,MAAM,GAAG,WAAW,CAAC;CACtC;AACD,QAAA,MAAM,+BAA+B,kCAAuC,MAAM,KAAG,QAAQ,WAAW,EAAE,CAWzG,CAAC;AAEF,OAAO,EAAC,+BAA+B,EAAC,CAAC"}
@@ -45,4 +45,4 @@ var GenericMessageType;
45
45
  GenericMessageType["LOCATION"] = "location";
46
46
  GenericMessageType["REACTION"] = "reaction";
47
47
  GenericMessageType["TEXT"] = "text";
48
- })(GenericMessageType || (exports.GenericMessageType = GenericMessageType = {}));
48
+ })(GenericMessageType = exports.GenericMessageType || (exports.GenericMessageType = {}));
@@ -1,2 +1,5 @@
1
- export type ReactionType = string;
1
+ export declare enum ReactionType {
2
+ LIKE = "\u2764\uFE0F",
3
+ NONE = ""
4
+ }
2
5
  //# sourceMappingURL=ReactionType.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ReactionType.d.ts","sourceRoot":"","sources":["../../src/conversation/ReactionType.ts"],"names":[],"mappings":"AAmBA,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC"}
1
+ {"version":3,"file":"ReactionType.d.ts","sourceRoot":"","sources":["../../src/conversation/ReactionType.ts"],"names":[],"mappings":"AAmBA,oBAAY,YAAY;IACtB,IAAI,iBAAO;IACX,IAAI,KAAK;CACV"}
@@ -18,3 +18,9 @@
18
18
  *
19
19
  */
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.ReactionType = void 0;
22
+ var ReactionType;
23
+ (function (ReactionType) {
24
+ ReactionType["LIKE"] = "\u2764\uFE0F";
25
+ ReactionType["NONE"] = "";
26
+ })(ReactionType = exports.ReactionType || (exports.ReactionType = {}));
@@ -24,4 +24,4 @@ var MessageSendingState;
24
24
  MessageSendingState["INCOMING"] = "INCOMING";
25
25
  MessageSendingState["OUTGOING_SENT"] = "OUTGOING_SENT";
26
26
  MessageSendingState["CANCELED"] = "CANCELED";
27
- })(MessageSendingState || (exports.MessageSendingState = MessageSendingState = {}));
27
+ })(MessageSendingState = exports.MessageSendingState || (exports.MessageSendingState = {}));
@@ -8,7 +8,7 @@ export declare function buildCompositeMessage(payload: IComposite): GenericMessa
8
8
  export declare function buildConfirmationMessage(payloadBundle: ConfirmationMessage['content']): GenericMessage;
9
9
  export declare function buildEditedTextMessage(payloadBundle: EditedTextMessage['content'], messageId?: string): GenericMessage;
10
10
  export declare function buildFileDataMessage(payloadBundle: FileAssetMessage['content'], messageId?: string): GenericMessage;
11
- export declare function buildFileMetaDataMessage(payloadBundle: FileAssetMetaDataMessage['content'], messageId?: string): GenericMessage;
11
+ export declare function buildFileMetaDataMessage(payloadBundle: FileAssetMetaDataMessage['content']): GenericMessage;
12
12
  export declare function buildFileAbortMessage(payloadBundle: FileAssetAbortMessage['content'], messageId?: string): GenericMessage;
13
13
  export declare function buildLastReadMessage(conversationId: QualifiedId, lastReadTimestamp: number): GenericMessage;
14
14
  export declare function buildDataTransferMessage(identifier: string): GenericMessage;
@@ -1 +1 @@
1
- {"version":3,"file":"MessageBuilder.d.ts","sourceRoot":"","sources":["../../../src/conversation/message/MessageBuilder.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAGzD,OAAO,EACL,UAAU,EAUV,cAAc,EASd,QAAQ,EACT,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,+BAA+B,EAC/B,mBAAmB,EACnB,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,EAChB,wBAAwB,EACxB,WAAW,EACX,yBAAyB,EACzB,eAAe,EACf,WAAW,EACX,eAAe,EACf,WAAW,EACZ,MAAM,cAAc,CAAC;AAMtB,wBAAgB,QAAQ,WAEvB;AAED,wBAAgB,wBAAwB,CAAC,aAAa,EAAE,mBAAmB,CAAC,SAAS,CA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EAAE,aAAa,CAAC,SAAS,CAAC,GAAG,cAAc,CAOpF;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,GAAG,cAAc,CAOhF;AAED,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,WAAW,CAAC,SAAS,CAAC,EACrC,SAAS,GAAE,MAAmB,GAC7B,cAAc,CAOhB;AAqCD,wBAAgB,eAAe,CAAC,sBAAsB,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,GAAG,cAAc,CAYjH"}
@@ -90,7 +90,7 @@ function buildFileDataMessage(payloadBundle, messageId = createId()) {
90
90
  return genericMessage;
91
91
  }
92
92
  exports.buildFileDataMessage = buildFileDataMessage;
93
- function buildFileMetaDataMessage(payloadBundle, messageId = createId()) {
93
+ function buildFileMetaDataMessage(payloadBundle) {
94
94
  const { expectsReadConfirmation, legalHoldStatus, metaData } = payloadBundle;
95
95
  const original = protocol_messaging_1.Asset.Original.create({
96
96
  audio: metaData.audio,
@@ -107,7 +107,7 @@ function buildFileMetaDataMessage(payloadBundle, messageId = createId()) {
107
107
  });
108
108
  const genericMessage = protocol_messaging_1.GenericMessage.create({
109
109
  [GenericMessageType_1.GenericMessageType.ASSET]: assetMessage,
110
- messageId,
110
+ messageId: createId(),
111
111
  });
112
112
  return genericMessage;
113
113
  }
@@ -1,11 +1,32 @@
1
- import { MessageSendingStatus, QualifiedUserClients } from '@wireapp/api-client/lib/conversation';
2
- import { QualifiedId, QualifiedUserPreKeyBundleMap } from '@wireapp/api-client/lib/user';
1
+ import { ClientMismatch, MessageSendingStatus, QualifiedUserClients, UserClients } from '@wireapp/api-client/lib/conversation';
2
+ import { QualifiedId, QualifiedUserPreKeyBundleMap, UserPreKeyBundleMap } from '@wireapp/api-client/lib/user';
3
3
  import { APIClient } from '@wireapp/api-client';
4
4
  import type { ProteusService } from '../../messagingProtocols/proteus';
5
5
  export declare class MessageService {
6
6
  private readonly apiClient;
7
7
  private readonly proteusService;
8
8
  constructor(apiClient: APIClient, proteusService: ProteusService);
9
+ /**
10
+ * Sends a message to a non-federated backend.
11
+ *
12
+ * @param sendingClientId The clientId of the current user
13
+ * @param recipients The list of recipients to send the message to
14
+ * @param plainText The plainText data to send
15
+ * @param options.conversationId? the conversation to send the message to. Will broadcast if not set
16
+ * @param options.reportMissing? trigger a mismatch error when there are missing recipients in the payload
17
+ * @param options.sendAsProtobuf?
18
+ * @param options.onClientMismatch? Called when a mismatch happens on the server
19
+ * @return the ClientMismatch status returned by the backend
20
+ */
21
+ sendMessage(sendingClientId: string, recipients: UserClients | UserPreKeyBundleMap, plainText: Uint8Array, options?: {
22
+ conversationId?: QualifiedId;
23
+ reportMissing?: boolean | string[];
24
+ sendAsProtobuf?: boolean;
25
+ nativePush?: boolean;
26
+ onClientMismatch?: (mismatch: ClientMismatch) => void | boolean | Promise<boolean>;
27
+ }): Promise<ClientMismatch & {
28
+ canceled?: boolean;
29
+ }>;
9
30
  /**
10
31
  * Sends a message to a federated backend.
11
32
  *
@@ -18,7 +39,7 @@ export declare class MessageService {
18
39
  * @param options.onClientMismatch? Called when a mismatch happens on the server
19
40
  * @return the MessageSendingStatus returned by the backend
20
41
  */
21
- sendMessage(sendingClientId: string, recipients: QualifiedUserClients | QualifiedUserPreKeyBundleMap, plainText: Uint8Array, options?: {
42
+ sendFederatedMessage(sendingClientId: string, recipients: QualifiedUserClients | QualifiedUserPreKeyBundleMap, plainText: Uint8Array, options: {
22
43
  assetData?: Uint8Array;
23
44
  conversationId?: QualifiedId;
24
45
  reportMissing?: boolean | QualifiedId[];
@@ -26,10 +47,13 @@ export declare class MessageService {
26
47
  onClientMismatch?: (mismatch: MessageSendingStatus) => void | boolean | Promise<boolean>;
27
48
  }): Promise<MessageSendingStatus & {
28
49
  canceled?: boolean;
29
- failed?: QualifiedId[];
30
50
  }>;
31
- private sendOtrMessage;
51
+ private sendFederatedOtrMessage;
52
+ private sendOTRMessage;
53
+ private generateExternalPayload;
54
+ private shouldSendAsExternal;
32
55
  private isClientMismatchError;
56
+ private reencryptAfterMismatch;
33
57
  /**
34
58
  * Will re-encrypt a message when there were some missing clients in the initial send (typically when the server replies with a client mismatch error)
35
59
  *
@@ -38,6 +62,7 @@ export declare class MessageService {
38
62
  * @param {Uint8Array} plainText The text that should be encrypted for the missing clients
39
63
  * @return resolves with a new message payload that can be sent
40
64
  */
41
- private reencryptAfterMismatch;
65
+ private reencryptAfterFederatedMismatch;
66
+ private sendOTRProtobufMessage;
42
67
  }
43
68
  //# sourceMappingURL=MessageService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MessageService.d.ts","sourceRoot":"","sources":["../../../src/conversation/message/MessageService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,oBAAoB,EAA0B,oBAAoB,EAAC,MAAM,sCAAsC,CAAC;AACxH,OAAO,EAAC,WAAW,EAAE,4BAA4B,EAAC,MAAM,8BAA8B,CAAC;AAQvF,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAI9C,OAAO,KAAK,EAAmB,cAAc,EAAC,MAAM,kCAAkC,CAAC;AAKvF,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,SAAS;IAAa,OAAO,CAAC,QAAQ,CAAC,cAAc;gBAArD,SAAS,EAAE,SAAS,EAAmB,cAAc,EAAE,cAAc;IAElG;;;;;;;;;;;OAWG;IACU,WAAW,CACtB,eAAe,EAAE,MAAM,EACvB,UAAU,EAAE,oBAAoB,GAAG,4BAA4B,EAC/D,SAAS,EAAE,UAAU,EACrB,OAAO,GAAE;QACP,SAAS,CAAC,EAAE,UAAU,CAAC;QACvB,cAAc,CAAC,EAAE,WAAW,CAAC;QAC7B,aAAa,CAAC,EAAE,OAAO,GAAG,WAAW,EAAE,CAAC;QACxC,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,oBAAoB,KAAK,IAAI,GAAG,OAAO,GAAG,OAAO,CAAC,OAA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C,CAAC;IAgCjD;;;;;;;;;;;OAWG;IACU,oBAAoB,CAC/B,eAAe,EAAE,MAAM,EACvB,UAAU,EAAE,oBAAoB,GAAG,4BAA4B,EAC/D,SAAS,EAAE,UAAU,EACrB,OAAO,EAAE;QACP,SAAS,CAAC,EAAE,UAAU,CAAC;QACvB,cAAc,CAAC,EAAE,WAAW,CAAC;QAC7B,aAAa,CAAC,EAAE,OAAO,GAAG,WAAW,EAAE,CAAC;QACxC,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,oBAAoB,KAAK,IAAI,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;KAC1F,GACA,OAAO,CAAC,oBAAoB,GAAG;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAC,CAAC;YAsBzC,uBAAuB;YAiEvB,cAAc;YAmCd,uBAAuB;IAiBrC,OAAO,CAAC,oBAAoB;IAc5B,OAAO,CAAC,qBAAqB;YAIf,sBAAsB;IAmBpC;;;;;;;OAOG;YACW,+BAA+B;YAuB/B,sBAAsB;CAoDrC"}
@@ -24,16 +24,63 @@ Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.MessageService = void 0;
25
25
  const StringUtil_1 = require("@wireapp/commons/lib/util/StringUtil");
26
26
  const otr_1 = require("@wireapp/protocol-messaging/web/otr");
27
- const deepmerge_ts_1 = require("deepmerge-ts");
27
+ const bazinga64_1 = require("bazinga64");
28
28
  const http_status_codes_1 = require("http-status-codes");
29
29
  const long_1 = __importDefault(require("long"));
30
+ const protocol_messaging_1 = require("@wireapp/protocol-messaging");
31
+ const MessageBuilder_1 = require("./MessageBuilder");
32
+ const RecipientsHelper_1 = require("./RecipientsHelper");
30
33
  const UserClientsUtil_1 = require("./UserClientsUtil");
34
+ const __1 = require("..");
35
+ const AssetCryptography_1 = require("../../cryptography/AssetCryptography");
31
36
  const util_1 = require("../../util");
32
37
  class MessageService {
33
38
  constructor(apiClient, proteusService) {
34
39
  this.apiClient = apiClient;
35
40
  this.proteusService = proteusService;
36
41
  }
42
+ /**
43
+ * Sends a message to a non-federated backend.
44
+ *
45
+ * @param sendingClientId The clientId of the current user
46
+ * @param recipients The list of recipients to send the message to
47
+ * @param plainText The plainText data to send
48
+ * @param options.conversationId? the conversation to send the message to. Will broadcast if not set
49
+ * @param options.reportMissing? trigger a mismatch error when there are missing recipients in the payload
50
+ * @param options.sendAsProtobuf?
51
+ * @param options.onClientMismatch? Called when a mismatch happens on the server
52
+ * @return the ClientMismatch status returned by the backend
53
+ */
54
+ async sendMessage(sendingClientId, recipients, plainText, options = {}) {
55
+ let plainTextPayload = plainText;
56
+ let cipherText;
57
+ if (this.shouldSendAsExternal(plainText, recipients)) {
58
+ const externalPayload = await this.generateExternalPayload(plainText);
59
+ plainTextPayload = externalPayload.text;
60
+ cipherText = externalPayload.cipherText;
61
+ }
62
+ const encryptedPayload = await this.proteusService.encrypt(plainTextPayload, recipients);
63
+ const send = (payload) => {
64
+ return options.sendAsProtobuf
65
+ ? this.sendOTRProtobufMessage(sendingClientId, payload, Object.assign(Object.assign({}, options), { assetData: cipherText }))
66
+ : this.sendOTRMessage(sendingClientId, payload, Object.assign(Object.assign({}, options), { assetData: cipherText }));
67
+ };
68
+ try {
69
+ return await send(encryptedPayload);
70
+ }
71
+ catch (error) {
72
+ if (!this.isClientMismatchError(error)) {
73
+ throw error;
74
+ }
75
+ const mismatch = error.response.data;
76
+ const shouldStopSending = options.onClientMismatch && (await options.onClientMismatch(mismatch)) === false;
77
+ if (shouldStopSending) {
78
+ return Object.assign(Object.assign({}, mismatch), { canceled: true });
79
+ }
80
+ const reEncryptedMessage = await this.reencryptAfterMismatch(mismatch, encryptedPayload, plainText);
81
+ return send(reEncryptedMessage);
82
+ }
83
+ }
37
84
  /**
38
85
  * Sends a message to a federated backend.
39
86
  *
@@ -46,15 +93,13 @@ class MessageService {
46
93
  * @param options.onClientMismatch? Called when a mismatch happens on the server
47
94
  * @return the MessageSendingStatus returned by the backend
48
95
  */
49
- async sendMessage(sendingClientId, recipients, plainText, options = {}) {
50
- const encryptionResults = await this.proteusService.encrypt(plainText, recipients);
51
- const send = async ({ payloads, unknowns, failed }) => {
52
- const result = await this.sendOtrMessage(sendingClientId, payloads, options);
53
- const extras = { failed, deleted: unknowns !== null && unknowns !== void 0 ? unknowns : {} };
54
- return (0, deepmerge_ts_1.deepmerge)(result, extras);
96
+ async sendFederatedMessage(sendingClientId, recipients, plainText, options) {
97
+ const send = (payload) => {
98
+ return this.sendFederatedOtrMessage(sendingClientId, payload, options);
55
99
  };
100
+ const encryptedPayload = await this.proteusService.encryptQualified(plainText, recipients);
56
101
  try {
57
- return await send(encryptionResults);
102
+ return await send(encryptedPayload);
58
103
  }
59
104
  catch (error) {
60
105
  if (!this.isClientMismatchError(error)) {
@@ -65,11 +110,11 @@ class MessageService {
65
110
  if (shouldStopSending) {
66
111
  return Object.assign(Object.assign({}, mismatch), { canceled: true });
67
112
  }
68
- const reEncryptedPayload = await this.reencryptAfterMismatch(mismatch, encryptionResults, plainText);
113
+ const reEncryptedPayload = await this.reencryptAfterFederatedMismatch(mismatch, encryptedPayload, plainText);
69
114
  return send(reEncryptedPayload);
70
115
  }
71
116
  }
72
- async sendOtrMessage(sendingClientId, recipients, options) {
117
+ async sendFederatedOtrMessage(sendingClientId, recipients, options) {
73
118
  const qualifiedUserEntries = Object.entries(recipients).map(([domain, otrRecipients]) => {
74
119
  const userEntries = Object.entries(otrRecipients).map(([userId, otrClientMap]) => {
75
120
  const clientEntries = Object.entries(otrClientMap).map(([clientId, payload]) => {
@@ -111,15 +156,71 @@ class MessageService {
111
156
  protoMessage.ignoreAll = true;
112
157
  }
113
158
  if (!options.conversationId) {
114
- return this.apiClient.api.broadcast.postBroadcastMessage(sendingClientId, protoMessage);
159
+ return this.apiClient.api.broadcast.postBroadcastFederatedMessage(sendingClientId, protoMessage);
115
160
  }
116
161
  const { id, domain } = options.conversationId;
117
- return this.apiClient.api.conversation.postOTRMessage(id, domain, protoMessage);
162
+ return this.apiClient.api.conversation.postOTRMessageV2(id, domain, protoMessage);
163
+ }
164
+ async sendOTRMessage(sendingClientId, recipients, options) {
165
+ const message = {
166
+ data: options.assetData ? bazinga64_1.Encoder.toBase64(options.assetData).asString : undefined,
167
+ recipients: (0, RecipientsHelper_1.recipientsToBase64)(recipients),
168
+ sender: sendingClientId,
169
+ native_push: options.nativePush,
170
+ };
171
+ let ignoreMissing;
172
+ if ((0, util_1.isStringArray)(options.reportMissing)) {
173
+ message.report_missing = options.reportMissing;
174
+ }
175
+ else {
176
+ // By default we want ignore missing to be false (and have mismatch errors in case some clients are missing)
177
+ ignoreMissing = typeof options.reportMissing === 'boolean' ? !options.reportMissing : false;
178
+ }
179
+ return !options.conversationId
180
+ ? this.apiClient.api.broadcast.postBroadcastMessage(sendingClientId, message, ignoreMissing)
181
+ : this.apiClient.api.conversation.postOTRMessage(sendingClientId, options.conversationId.id, message, ignoreMissing);
182
+ }
183
+ async generateExternalPayload(plainText) {
184
+ const asset = await (0, AssetCryptography_1.encryptAsset)({ plainText });
185
+ const { cipherText, keyBytes, sha256 } = asset;
186
+ const externalMessage = {
187
+ otrKey: new Uint8Array(keyBytes),
188
+ sha256: new Uint8Array(sha256),
189
+ };
190
+ const genericMessage = protocol_messaging_1.GenericMessage.create({
191
+ [__1.GenericMessageType.EXTERNAL]: externalMessage,
192
+ messageId: (0, MessageBuilder_1.createId)(),
193
+ });
194
+ return { text: protocol_messaging_1.GenericMessage.encode(genericMessage).finish(), cipherText };
195
+ }
196
+ shouldSendAsExternal(plainText, preKeyBundles) {
197
+ const EXTERNAL_MESSAGE_THRESHOLD_BYTES = 200 * 1024;
198
+ let clientCount = 0;
199
+ for (const user in preKeyBundles) {
200
+ clientCount += Object.keys(preKeyBundles[user]).length;
201
+ }
202
+ const messageInBytes = new Uint8Array(plainText).length;
203
+ const estimatedPayloadInBytes = clientCount * messageInBytes;
204
+ return estimatedPayloadInBytes > EXTERNAL_MESSAGE_THRESHOLD_BYTES;
118
205
  }
119
206
  isClientMismatchError(error) {
120
207
  var _a;
121
208
  return ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === http_status_codes_1.StatusCodes.PRECONDITION_FAILED;
122
209
  }
210
+ async reencryptAfterMismatch(mismatch, recipients, plainText) {
211
+ const deleted = (0, UserClientsUtil_1.flattenUserClients)(mismatch.deleted);
212
+ const missing = (0, UserClientsUtil_1.flattenUserClients)(mismatch.missing);
213
+ // remove deleted clients to the recipients
214
+ deleted.forEach(({ userId, data }) => data.forEach(clientId => delete recipients[userId.id][clientId]));
215
+ if (missing.length) {
216
+ const missingPreKeyBundles = await this.apiClient.api.user.postMultiPreKeyBundles(mismatch.missing);
217
+ const encrypted = await this.proteusService.encrypt(plainText, missingPreKeyBundles);
218
+ const reEncryptedPayloads = (0, UserClientsUtil_1.flattenUserClients)(encrypted);
219
+ // add missing clients to the recipients
220
+ reEncryptedPayloads.forEach(({ data, userId }) => (recipients[userId.id] = Object.assign(Object.assign({}, recipients[userId.id]), data)));
221
+ }
222
+ return recipients;
223
+ }
123
224
  /**
124
225
  * Will re-encrypt a message when there were some missing clients in the initial send (typically when the server replies with a client mismatch error)
125
226
  *
@@ -128,15 +229,57 @@ class MessageService {
128
229
  * @param {Uint8Array} plainText The text that should be encrypted for the missing clients
129
230
  * @return resolves with a new message payload that can be sent
130
231
  */
131
- async reencryptAfterMismatch(mismatch, initialPayloads, plainText) {
132
- const deleted = (0, UserClientsUtil_1.flattenUserMap)(mismatch.deleted);
232
+ async reencryptAfterFederatedMismatch(mismatch, recipients, plainText) {
233
+ const deleted = (0, UserClientsUtil_1.flattenQualifiedUserClients)(mismatch.deleted);
234
+ const missing = (0, UserClientsUtil_1.flattenQualifiedUserClients)(mismatch.missing);
133
235
  // remove deleted clients to the recipients
134
- deleted.forEach(({ userId, data }) => data.forEach(clientId => delete initialPayloads.payloads[userId.domain][userId.id][clientId]));
135
- if (Object.keys(mismatch.missing).length === 0) {
136
- return initialPayloads;
236
+ deleted.forEach(({ userId, data }) => data.forEach(clientId => delete recipients[userId.domain][userId.id][clientId]));
237
+ if (Object.keys(missing).length) {
238
+ const missingPreKeyBundles = await this.apiClient.api.user.postQualifiedMultiPreKeyBundles(mismatch.missing);
239
+ const encrypted = await this.proteusService.encryptQualified(plainText, missingPreKeyBundles);
240
+ const reEncryptedPayloads = (0, UserClientsUtil_1.flattenQualifiedUserClients)(encrypted);
241
+ reEncryptedPayloads.forEach(({ data, userId }) => (recipients[userId.domain][userId.id] = Object.assign(Object.assign({}, recipients[userId.domain][userId.id]), data)));
242
+ }
243
+ return recipients;
244
+ }
245
+ async sendOTRProtobufMessage(sendingClientId, recipients, options) {
246
+ const userEntries = Object.entries(recipients).map(([userId, otrClientMap]) => {
247
+ const clients = Object.entries(otrClientMap).map(([clientId, payload]) => {
248
+ return {
249
+ client: {
250
+ client: long_1.default.fromString(clientId, 16),
251
+ },
252
+ text: payload,
253
+ };
254
+ });
255
+ return {
256
+ clients,
257
+ user: {
258
+ uuid: (0, StringUtil_1.uuidToBytes)(userId),
259
+ },
260
+ };
261
+ });
262
+ const protoMessage = otr_1.proteus.NewOtrMessage.create({
263
+ recipients: userEntries,
264
+ sender: {
265
+ client: long_1.default.fromString(sendingClientId, 16),
266
+ },
267
+ });
268
+ let ignoreMissing;
269
+ if ((0, util_1.isStringArray)(options.reportMissing)) {
270
+ const encoder = new TextEncoder();
271
+ protoMessage.reportMissing = options.reportMissing.map(userId => ({ uuid: encoder.encode(userId) }));
272
+ }
273
+ else {
274
+ // By default we want ignore missing to be false (and have mismatch errors in case some clients are missing)
275
+ ignoreMissing = typeof options.reportMissing === 'boolean' ? !options.reportMissing : false;
276
+ }
277
+ if (options.assetData) {
278
+ protoMessage.blob = options.assetData;
137
279
  }
138
- const reencryptedResults = await this.proteusService.encrypt(plainText, mismatch.missing);
139
- return (0, deepmerge_ts_1.deepmerge)(initialPayloads, reencryptedResults);
280
+ return !options.conversationId
281
+ ? this.apiClient.api.broadcast.postBroadcastProtobufMessage(sendingClientId, protoMessage, ignoreMissing)
282
+ : this.apiClient.api.conversation.postOTRProtobufMessage(sendingClientId, options.conversationId.id, protoMessage, ignoreMissing);
140
283
  }
141
284
  }
142
285
  exports.MessageService = MessageService;