@wireapp/core 40.5.3-draft-20-cc.3 → 40.5.3-draft-20-cc.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.d.ts +9 -7
- package/lib/Account.d.ts.map +1 -1
- package/lib/Account.js +32 -35
- package/lib/CoreError.js +1 -1
- package/lib/broadcast/BroadcastService.d.ts +2 -11
- package/lib/broadcast/BroadcastService.d.ts.map +1 -1
- package/lib/broadcast/BroadcastService.js +5 -39
- package/lib/client/ClientDatabaseRepository.d.ts +5 -5
- package/lib/client/ClientDatabaseRepository.d.ts.map +1 -1
- package/lib/client/ClientDatabaseRepository.js +10 -17
- package/lib/client/ClientService.d.ts +5 -1
- package/lib/client/ClientService.d.ts.map +1 -1
- package/lib/client/ClientService.js +11 -9
- package/lib/connection/ConnectionService.d.ts +2 -2
- package/lib/connection/ConnectionService.d.ts.map +1 -1
- package/lib/connection/ConnectionService.js +2 -2
- package/lib/conversation/AssetTransferState.js +1 -1
- package/lib/conversation/ConversationService/ConversationService.d.ts +12 -5
- package/lib/conversation/ConversationService/ConversationService.d.ts.map +1 -1
- package/lib/conversation/ConversationService/ConversationService.js +26 -11
- package/lib/conversation/ConversationService/ConversationService.test.js +1 -1
- package/lib/conversation/ConversationService/ConversationService.types.d.ts +12 -11
- package/lib/conversation/ConversationService/ConversationService.types.d.ts.map +1 -1
- package/lib/conversation/ConversationService/ConversationService.types.js +1 -1
- package/lib/conversation/ConversationService/Utility/getConversationQualifiedMembers.d.ts +1 -1
- package/lib/conversation/ConversationService/Utility/getConversationQualifiedMembers.d.ts.map +1 -1
- package/lib/conversation/GenericMessageType.js +1 -1
- package/lib/conversation/ReactionType.d.ts +1 -4
- package/lib/conversation/ReactionType.d.ts.map +1 -1
- package/lib/conversation/ReactionType.js +0 -6
- package/lib/conversation/message/Message.types.js +1 -1
- package/lib/conversation/message/MessageBuilder.d.ts +1 -1
- package/lib/conversation/message/MessageBuilder.d.ts.map +1 -1
- package/lib/conversation/message/MessageBuilder.js +2 -2
- package/lib/conversation/message/MessageService.d.ts +6 -31
- package/lib/conversation/message/MessageService.d.ts.map +1 -1
- package/lib/conversation/message/MessageService.js +19 -162
- package/lib/conversation/message/MessageService.test.js +151 -141
- package/lib/conversation/message/PayloadBundle.js +1 -1
- package/lib/conversation/message/UserClientsUtil.d.ts +14 -10
- package/lib/conversation/message/UserClientsUtil.d.ts.map +1 -1
- package/lib/conversation/message/UserClientsUtil.js +21 -11
- package/lib/conversation/message/UserClientsUtils.test.js +5 -9
- package/lib/messagingProtocols/mls/EventHandler/EventHandler.d.ts +1 -1
- package/lib/messagingProtocols/mls/EventHandler/EventHandler.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.d.ts +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.js +7 -2
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.js +2 -0
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.test.js +3 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts +20 -8
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.js +81 -40
- package/lib/messagingProtocols/mls/MLSService/MLSService.test.js +9 -0
- package/lib/messagingProtocols/mls/MLSService/commitBundleUtil.d.ts +1 -1
- package/lib/messagingProtocols/mls/MLSService/commitBundleUtil.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/commitBundleUtil.js +5 -5
- package/lib/messagingProtocols/mls/MLSService/commitBundleUtil.test.js +3 -3
- package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.d.ts +13 -0
- package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.js +67 -0
- package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.test.d.ts +2 -0
- package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.test.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.test.js +72 -0
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.d.ts +10 -5
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.js +33 -11
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.d.ts +2 -3
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.js +8 -9
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.store.d.ts +4 -9
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.store.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.store.js +10 -24
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.test.js +2 -10
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.d.ts +1 -2
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.js +3 -3
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.d.ts +2 -2
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoboxWrapper.d.ts +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoboxWrapper.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoboxWrapper.js +2 -2
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts +14 -7
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.js +31 -35
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.js +2 -3
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.test.js +109 -89
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.types.d.ts +6 -9
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.types.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/Utility/Recipients.d.ts +4 -10
- package/lib/messagingProtocols/proteus/Utility/Recipients.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/Utility/Recipients.js +16 -16
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.d.ts +15 -10
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.js +80 -92
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.test.js +70 -54
- package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.d.ts +5 -14
- package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.js +3 -35
- package/lib/messagingProtocols/proteus/Utility/isClearFromMismatch.d.ts +2 -2
- package/lib/messagingProtocols/proteus/Utility/isClearFromMismatch.d.ts.map +1 -1
- package/lib/notification/NotificationDatabaseRepository.js +1 -1
- package/lib/notification/Notifications.types.js +1 -1
- package/lib/user/UserService.d.ts +6 -17
- package/lib/user/UserService.d.ts.map +1 -1
- package/lib/user/UserService.js +2 -47
- package/lib/util/TaskScheduler/TaskScheduler.d.ts +4 -1
- package/lib/util/TaskScheduler/TaskScheduler.d.ts.map +1 -1
- package/lib/util/TaskScheduler/TaskScheduler.js +24 -3
- package/lib/util/TaskScheduler/TaskScheduler.store.d.ts +7 -0
- package/lib/util/TaskScheduler/TaskScheduler.store.d.ts.map +1 -0
- package/lib/util/TaskScheduler/TaskScheduler.store.js +34 -0
- package/lib/util/TypePredicateUtil.d.ts +0 -1
- package/lib/util/TypePredicateUtil.d.ts.map +1 -1
- package/lib/util/TypePredicateUtil.js +1 -2
- package/package.json +3 -3
- package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/index.d.ts +0 -2
- package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/index.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/index.js +0 -35
- package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.d.ts +0 -11
- package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.js +0 -50
- package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.test.d.ts +0 -2
- package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.test.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.test.js +0 -39
- package/lib/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.d.ts +0 -4
- package/lib/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.js +0 -35
- package/lib/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.test.d.ts +0 -2
- package/lib/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.test.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.test.js +0 -35
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.d.ts +0 -25
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.d.ts.map +0 -1
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.js +0 -93
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.test.d.ts +0 -2
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.test.d.ts.map +0 -1
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.test.js +0 -66
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/index.d.ts +0 -2
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/index.d.ts.map +0 -1
- package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/index.js +0 -35
|
@@ -155,12 +155,9 @@ 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) {
|
|
158
|
+
async createMLSConversation(conversationData, selfUserId, selfClientId) {
|
|
159
159
|
var _a;
|
|
160
|
-
const {
|
|
161
|
-
if (!selfUserId) {
|
|
162
|
-
throw new Error('You need to pass self user qualified id in order to create an MLS conversation');
|
|
163
|
-
}
|
|
160
|
+
const { qualified_users: qualifiedUsers = [] } = conversationData;
|
|
164
161
|
/**
|
|
165
162
|
* @note For creating MLS conversations the users & qualified_users
|
|
166
163
|
* field must be empty as backend is not aware which users
|
|
@@ -173,7 +170,7 @@ class ConversationService {
|
|
|
173
170
|
}
|
|
174
171
|
const response = await this.mlsService.registerConversation(groupId, qualifiedUsers.concat(selfUserId), {
|
|
175
172
|
user: selfUserId,
|
|
176
|
-
client:
|
|
173
|
+
client: selfClientId,
|
|
177
174
|
});
|
|
178
175
|
// We fetch the fresh version of the conversation created on backend with the newly added users
|
|
179
176
|
const conversation = await this.apiClient.api.conversation.getConversation(qualifiedId);
|
|
@@ -183,25 +180,41 @@ class ConversationService {
|
|
|
183
180
|
};
|
|
184
181
|
}
|
|
185
182
|
async sendMLSMessage({ payload, groupId }) {
|
|
183
|
+
var _a, _b;
|
|
186
184
|
const groupIdBytes = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
|
|
187
185
|
// immediately execute pending commits before sending the message
|
|
188
186
|
await this.mlsService.commitPendingProposals({ groupId });
|
|
189
187
|
const encrypted = await this.mlsService.encryptMessage(groupIdBytes, protocol_messaging_1.GenericMessage.encode(payload).finish());
|
|
188
|
+
let response = null;
|
|
190
189
|
let sentAt = '';
|
|
191
190
|
try {
|
|
192
|
-
|
|
193
|
-
sentAt = (time === null ||
|
|
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();
|
|
194
193
|
}
|
|
195
|
-
catch (
|
|
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;
|
|
196
201
|
return {
|
|
197
202
|
id: payload.messageId,
|
|
198
203
|
sentAt,
|
|
204
|
+
failedToSend,
|
|
199
205
|
state: sentAt ? conversation_2.MessageSendingState.OUTGOING_SENT : conversation_2.MessageSendingState.CANCELED,
|
|
200
206
|
};
|
|
201
207
|
}
|
|
202
|
-
|
|
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, }) {
|
|
203
216
|
const groupIdBytes = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
|
|
204
|
-
const coreCryptoKeyPackagesPayload = await this.mlsService.getKeyPackagesPayload(
|
|
217
|
+
const coreCryptoKeyPackagesPayload = await this.mlsService.getKeyPackagesPayload(qualifiedUsers);
|
|
205
218
|
const response = await this.mlsService.addUsersToExistingConversation(groupIdBytes, coreCryptoKeyPackagesPayload);
|
|
206
219
|
const conversation = await this.getConversation(conversationId);
|
|
207
220
|
//We store the info when user was added (and key material was created), so we will know when to renew it
|
|
@@ -238,6 +251,8 @@ class ConversationService {
|
|
|
238
251
|
const externalProposal = await this.mlsService.newExternalProposal(core_crypto_1.ExternalProposalType.Add, {
|
|
239
252
|
epoch,
|
|
240
253
|
conversationId: groupIdBytes,
|
|
254
|
+
ciphersuite: core_crypto_1.Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519,
|
|
255
|
+
credentialType: core_crypto_1.CredentialType.Basic,
|
|
241
256
|
});
|
|
242
257
|
await this.apiClient.api.conversation.postMlsMessage(
|
|
243
258
|
//@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('convid');
|
|
211
|
+
const fetchedMembers = await conversationService.fetchAllParticipantsClients({ id: 'convid', domain: '' });
|
|
212
212
|
expect(fetchedMembers).toEqual(members);
|
|
213
213
|
});
|
|
214
214
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { QualifiedUserClients,
|
|
1
|
+
import { QualifiedUserClients, ConversationProtocol, MessageSendingStatus, 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,11 +15,7 @@ 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?:
|
|
19
|
-
/**
|
|
20
|
-
* Will send the message as a protobuf payload
|
|
21
|
-
*/
|
|
22
|
-
sendAsProtobuf?: boolean;
|
|
18
|
+
userIds?: QualifiedId[] | QualifiedUserClients;
|
|
23
19
|
nativePush?: boolean;
|
|
24
20
|
/**
|
|
25
21
|
* Will be called whenever there is a clientmismatch returned from the server. Needs to be combined with a userIds of type QualifiedUserClients
|
|
@@ -41,7 +37,7 @@ export interface MessageSendingCallbacks {
|
|
|
41
37
|
* @param wasSent Indicate whether the message was already sent or if it can still be canceled
|
|
42
38
|
* @return
|
|
43
39
|
*/
|
|
44
|
-
onClientMismatch?: (status:
|
|
40
|
+
onClientMismatch?: (status: MessageSendingStatus, wasSent: boolean) => void | boolean | Promise<boolean>;
|
|
45
41
|
}
|
|
46
42
|
/**
|
|
47
43
|
* ######################################################################
|
|
@@ -67,12 +63,12 @@ export type SendMlsMessageParams = SendCommonParams & {
|
|
|
67
63
|
groupId: string;
|
|
68
64
|
protocol: ConversationProtocol.MLS;
|
|
69
65
|
};
|
|
70
|
-
export type
|
|
71
|
-
|
|
66
|
+
export type KeyPackageClaimUser = QualifiedId & {
|
|
67
|
+
skipOwnClientId?: string;
|
|
72
68
|
};
|
|
73
69
|
export type AddUsersParams = {
|
|
74
70
|
conversationId: QualifiedId;
|
|
75
|
-
|
|
71
|
+
qualifiedUsers: KeyPackageClaimUser[];
|
|
76
72
|
groupId?: string;
|
|
77
73
|
};
|
|
78
74
|
export type RemoveUsersParams = {
|
|
@@ -92,6 +88,11 @@ export type SendResult = {
|
|
|
92
88
|
/** The sending state of the payload (has the payload been succesfully sent or canceled) */
|
|
93
89
|
state: MessageSendingState;
|
|
94
90
|
/** 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 */
|
|
95
|
-
failedToSend?:
|
|
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
|
+
};
|
|
96
97
|
};
|
|
97
98
|
//# 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,
|
|
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,WAAW,qBAAqB;IACpC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,WAAW,EAAE,GAAG,oBAAoB,CAAC;IAE/C,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,gBAAgB,CAAC,EAAE,uBAAuB,CAAC,kBAAkB,CAAC,CAAC;IAE/D;;;;;OAKG;IACH,UAAU,CAAC,EAAE,iBAAiB,CAAC;CAChC;AAED,MAAM,WAAW,uBAAuB;IACtC;;;;;;OAMG;IACH,gBAAgB,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1G;AAED;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,EAAE,oBAAoB,CAAC;CAChC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC7C,OAAO,EAAE,cAAc,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,gBAAgB,GAAG;IACpD;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,oBAAoB,CAAC,GAAG,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG;IAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC;AAE3E,MAAM,MAAM,cAAc,GAAG;IAC3B,cAAc,EAAE,WAAW,CAAC;IAC5B,cAAc,EAAE,mBAAmB,EAAE,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,cAAc,EAAE,WAAW,CAAC;IAC5B,gBAAgB,EAAE,WAAW,EAAE,CAAC;IAChC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAAC,MAAM,EAAE,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"}
|
|
@@ -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
|
|
27
|
+
})(MessageTargetMode || (exports.MessageTargetMode = 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:
|
|
5
|
+
conversationId: QualifiedId;
|
|
6
6
|
}
|
|
7
7
|
declare const getConversationQualifiedMembers: ({ apiClient, conversationId }: Params) => Promise<QualifiedId[]>;
|
|
8
8
|
export { getConversationQualifiedMembers };
|
package/lib/conversation/ConversationService/Utility/getConversationQualifiedMembers.d.ts.map
CHANGED
|
@@ -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,
|
|
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"}
|
|
@@ -45,4 +45,4 @@ var GenericMessageType;
|
|
|
45
45
|
GenericMessageType["LOCATION"] = "location";
|
|
46
46
|
GenericMessageType["REACTION"] = "reaction";
|
|
47
47
|
GenericMessageType["TEXT"] = "text";
|
|
48
|
-
})(GenericMessageType
|
|
48
|
+
})(GenericMessageType || (exports.GenericMessageType = GenericMessageType = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactionType.d.ts","sourceRoot":"","sources":["../../src/conversation/ReactionType.ts"],"names":[],"mappings":"AAmBA,
|
|
1
|
+
{"version":3,"file":"ReactionType.d.ts","sourceRoot":"","sources":["../../src/conversation/ReactionType.ts"],"names":[],"mappings":"AAmBA,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC"}
|
|
@@ -18,9 +18,3 @@
|
|
|
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
|
|
27
|
+
})(MessageSendingState || (exports.MessageSendingState = 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']): GenericMessage;
|
|
11
|
+
export declare function buildFileMetaDataMessage(payloadBundle: FileAssetMetaDataMessage['content'], messageId?: string): 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,CAAC,GAAG,cAAc,CAKtG;AAED,wBAAgB,oCAAoC,CAClD,aAAa,EAAE,+BAA+B,CAAC,SAAS,CAAC,GACxD,cAAc,CAKhB;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,UAAU,GAAG,cAAc,CAKzE;AAED,wBAAgB,wBAAwB,CAAC,aAAa,EAAE,mBAAmB,CAAC,SAAS,CAAC,GAAG,cAAc,CAOtG;AAED,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,iBAAiB,CAAC,SAAS,CAAC,EAC3C,SAAS,GAAE,MAAmB,GAC7B,cAAc,CAUhB;AAED,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,gBAAgB,CAAC,SAAS,CAAC,EAC1C,SAAS,GAAE,MAAmB,GAC7B,cAAc,CAyBhB;AAED,wBAAgB,wBAAwB,
|
|
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,CAAC,GAAG,cAAc,CAKtG;AAED,wBAAgB,oCAAoC,CAClD,aAAa,EAAE,+BAA+B,CAAC,SAAS,CAAC,GACxD,cAAc,CAKhB;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,UAAU,GAAG,cAAc,CAKzE;AAED,wBAAgB,wBAAwB,CAAC,aAAa,EAAE,mBAAmB,CAAC,SAAS,CAAC,GAAG,cAAc,CAOtG;AAED,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,iBAAiB,CAAC,SAAS,CAAC,EAC3C,SAAS,GAAE,MAAmB,GAC7B,cAAc,CAUhB;AAED,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,gBAAgB,CAAC,SAAS,CAAC,EAC1C,SAAS,GAAE,MAAmB,GAC7B,cAAc,CAyBhB;AAED,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,wBAAwB,CAAC,SAAS,CAAC,EAClD,SAAS,GAAE,MAAmB,GAC7B,cAAc,CAwBhB;AAED,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,qBAAqB,CAAC,SAAS,CAAC,EAC/C,SAAS,GAAE,MAAmB,GAC7B,cAAc,CAiBhB;AAED,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,kBAU1F;AAED,wBAAgB,wBAAwB,CAAC,UAAU,EAAE,MAAM,kBAW1D;AAED,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,WAAW,EAAE,SAAS,GAAE,MAAmB,kBAU9F;AAED,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,yBAAyB,CAAC,SAAS,CAAC,EACnD,SAAS,GAAE,MAAmB,GAC7B,cAAc,CAShB;AACD,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,eAAe,CAAC,SAAS,CAAC,GAAG,cAAc,CAkB9F;AACD,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,WAAW,CAAC,SAAS,CAAC,GAAG,cAAc,CAStF;AAED,wBAAgB,oBAAoB,CAAC,aAAa,EAAE,eAAe,CAAC,SAAS,CAAC,GAAG,cAAc,CAc9F;AAED,wBAAgB,wBAAwB,IAAI,cAAc,CAKzD;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,QAAQ,GAAG,cAAc,CAOlE;AAED,wBAAgB,kBAAkB,CAAC,OAAO,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) {
|
|
93
|
+
function buildFileMetaDataMessage(payloadBundle, messageId = createId()) {
|
|
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) {
|
|
|
107
107
|
});
|
|
108
108
|
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
109
109
|
[GenericMessageType_1.GenericMessageType.ASSET]: assetMessage,
|
|
110
|
-
messageId
|
|
110
|
+
messageId,
|
|
111
111
|
});
|
|
112
112
|
return genericMessage;
|
|
113
113
|
}
|
|
@@ -1,32 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { QualifiedId, QualifiedUserPreKeyBundleMap
|
|
1
|
+
import { MessageSendingStatus, QualifiedUserClients } from '@wireapp/api-client/lib/conversation';
|
|
2
|
+
import { QualifiedId, QualifiedUserPreKeyBundleMap } 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
|
-
}>;
|
|
30
9
|
/**
|
|
31
10
|
* Sends a message to a federated backend.
|
|
32
11
|
*
|
|
@@ -39,7 +18,7 @@ export declare class MessageService {
|
|
|
39
18
|
* @param options.onClientMismatch? Called when a mismatch happens on the server
|
|
40
19
|
* @return the MessageSendingStatus returned by the backend
|
|
41
20
|
*/
|
|
42
|
-
|
|
21
|
+
sendMessage(sendingClientId: string, recipients: QualifiedUserClients | QualifiedUserPreKeyBundleMap, plainText: Uint8Array, options?: {
|
|
43
22
|
assetData?: Uint8Array;
|
|
44
23
|
conversationId?: QualifiedId;
|
|
45
24
|
reportMissing?: boolean | QualifiedId[];
|
|
@@ -47,13 +26,10 @@ export declare class MessageService {
|
|
|
47
26
|
onClientMismatch?: (mismatch: MessageSendingStatus) => void | boolean | Promise<boolean>;
|
|
48
27
|
}): Promise<MessageSendingStatus & {
|
|
49
28
|
canceled?: boolean;
|
|
29
|
+
failed?: QualifiedId[];
|
|
50
30
|
}>;
|
|
51
|
-
private
|
|
52
|
-
private sendOTRMessage;
|
|
53
|
-
private generateExternalPayload;
|
|
54
|
-
private shouldSendAsExternal;
|
|
31
|
+
private sendOtrMessage;
|
|
55
32
|
private isClientMismatchError;
|
|
56
|
-
private reencryptAfterMismatch;
|
|
57
33
|
/**
|
|
58
34
|
* 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)
|
|
59
35
|
*
|
|
@@ -62,7 +38,6 @@ export declare class MessageService {
|
|
|
62
38
|
* @param {Uint8Array} plainText The text that should be encrypted for the missing clients
|
|
63
39
|
* @return resolves with a new message payload that can be sent
|
|
64
40
|
*/
|
|
65
|
-
private
|
|
66
|
-
private sendOTRProtobufMessage;
|
|
41
|
+
private reencryptAfterMismatch;
|
|
67
42
|
}
|
|
68
43
|
//# 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,
|
|
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,OAAO,CAAC,CAAC;KACrF,GACL,OAAO,CAAC,oBAAoB,GAAG;QAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,EAAE,CAAA;KAAC,CAAC;YAyBjE,cAAc;IAiE5B,OAAO,CAAC,qBAAqB;IAI7B;;;;;;;OAOG;YACW,sBAAsB;CAiBrC"}
|
|
@@ -24,63 +24,16 @@ 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
|
|
27
|
+
const deepmerge_ts_1 = require("deepmerge-ts");
|
|
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");
|
|
33
30
|
const UserClientsUtil_1 = require("./UserClientsUtil");
|
|
34
|
-
const __1 = require("..");
|
|
35
|
-
const AssetCryptography_1 = require("../../cryptography/AssetCryptography");
|
|
36
31
|
const util_1 = require("../../util");
|
|
37
32
|
class MessageService {
|
|
38
33
|
constructor(apiClient, proteusService) {
|
|
39
34
|
this.apiClient = apiClient;
|
|
40
35
|
this.proteusService = proteusService;
|
|
41
36
|
}
|
|
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
|
-
}
|
|
84
37
|
/**
|
|
85
38
|
* Sends a message to a federated backend.
|
|
86
39
|
*
|
|
@@ -93,13 +46,15 @@ class MessageService {
|
|
|
93
46
|
* @param options.onClientMismatch? Called when a mismatch happens on the server
|
|
94
47
|
* @return the MessageSendingStatus returned by the backend
|
|
95
48
|
*/
|
|
96
|
-
async
|
|
97
|
-
const
|
|
98
|
-
|
|
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);
|
|
99
55
|
};
|
|
100
|
-
const encryptedPayload = await this.proteusService.encryptQualified(plainText, recipients);
|
|
101
56
|
try {
|
|
102
|
-
return await send(
|
|
57
|
+
return await send(encryptionResults);
|
|
103
58
|
}
|
|
104
59
|
catch (error) {
|
|
105
60
|
if (!this.isClientMismatchError(error)) {
|
|
@@ -110,11 +65,11 @@ class MessageService {
|
|
|
110
65
|
if (shouldStopSending) {
|
|
111
66
|
return Object.assign(Object.assign({}, mismatch), { canceled: true });
|
|
112
67
|
}
|
|
113
|
-
const reEncryptedPayload = await this.
|
|
68
|
+
const reEncryptedPayload = await this.reencryptAfterMismatch(mismatch, encryptionResults, plainText);
|
|
114
69
|
return send(reEncryptedPayload);
|
|
115
70
|
}
|
|
116
71
|
}
|
|
117
|
-
async
|
|
72
|
+
async sendOtrMessage(sendingClientId, recipients, options) {
|
|
118
73
|
const qualifiedUserEntries = Object.entries(recipients).map(([domain, otrRecipients]) => {
|
|
119
74
|
const userEntries = Object.entries(otrRecipients).map(([userId, otrClientMap]) => {
|
|
120
75
|
const clientEntries = Object.entries(otrClientMap).map(([clientId, payload]) => {
|
|
@@ -156,71 +111,15 @@ class MessageService {
|
|
|
156
111
|
protoMessage.ignoreAll = true;
|
|
157
112
|
}
|
|
158
113
|
if (!options.conversationId) {
|
|
159
|
-
return this.apiClient.api.broadcast.
|
|
114
|
+
return this.apiClient.api.broadcast.postBroadcastMessage(sendingClientId, protoMessage);
|
|
160
115
|
}
|
|
161
116
|
const { id, domain } = options.conversationId;
|
|
162
|
-
return this.apiClient.api.conversation.
|
|
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;
|
|
117
|
+
return this.apiClient.api.conversation.postOTRMessage(id, domain, protoMessage);
|
|
205
118
|
}
|
|
206
119
|
isClientMismatchError(error) {
|
|
207
120
|
var _a;
|
|
208
121
|
return ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === http_status_codes_1.StatusCodes.PRECONDITION_FAILED;
|
|
209
122
|
}
|
|
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
|
-
}
|
|
224
123
|
/**
|
|
225
124
|
* 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)
|
|
226
125
|
*
|
|
@@ -229,57 +128,15 @@ class MessageService {
|
|
|
229
128
|
* @param {Uint8Array} plainText The text that should be encrypted for the missing clients
|
|
230
129
|
* @return resolves with a new message payload that can be sent
|
|
231
130
|
*/
|
|
232
|
-
async
|
|
233
|
-
const deleted = (0, UserClientsUtil_1.
|
|
234
|
-
const missing = (0, UserClientsUtil_1.flattenQualifiedUserClients)(mismatch.missing);
|
|
131
|
+
async reencryptAfterMismatch(mismatch, initialPayloads, plainText) {
|
|
132
|
+
const deleted = (0, UserClientsUtil_1.flattenUserMap)(mismatch.deleted);
|
|
235
133
|
// remove deleted clients to the recipients
|
|
236
|
-
deleted.forEach(({ userId, data }) => data.forEach(clientId => delete
|
|
237
|
-
if (Object.keys(missing).length) {
|
|
238
|
-
|
|
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;
|
|
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;
|
|
279
137
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
: this.apiClient.api.conversation.postOTRProtobufMessage(sendingClientId, options.conversationId.id, protoMessage, ignoreMissing);
|
|
138
|
+
const reencryptedResults = await this.proteusService.encrypt(plainText, mismatch.missing);
|
|
139
|
+
return (0, deepmerge_ts_1.deepmerge)(initialPayloads, reencryptedResults);
|
|
283
140
|
}
|
|
284
141
|
}
|
|
285
142
|
exports.MessageService = MessageService;
|