@wireapp/core 30.12.0 → 31.0.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/package.json +28 -22
- package/src/main/Account.d.ts +11 -3
- package/src/main/Account.js +11 -0
- package/src/main/CoreError.d.ts +1 -1
- package/src/main/account/AccountService.d.ts +2 -2
- package/src/main/account/AccountService.ts +2 -2
- package/src/main/auth/LoginSanitizer.d.ts +1 -1
- package/src/main/broadcast/AvailabilityType.d.ts +1 -1
- package/src/main/broadcast/BroadcastService.d.ts +3 -3
- package/src/main/client/ClientBackendRepository.d.ts +2 -2
- package/src/main/client/ClientDatabaseRepository.d.ts +3 -3
- package/src/main/client/ClientInfo.d.ts +1 -1
- package/src/main/client/ClientService.d.ts +4 -4
- package/src/main/connection/ConnectionService.d.ts +1 -1
- package/src/main/conversation/AbortReason.d.ts +1 -1
- package/src/main/conversation/AssetService/AssetService.d.ts +4 -4
- package/src/main/conversation/ConversationService/ConversationService.d.ts +9 -28
- package/src/main/conversation/ConversationService/ConversationService.js +4 -312
- package/src/main/conversation/ConversationService/ConversationService.types.d.ts +2 -0
- package/src/main/conversation/ConversationService/messageGenerator.d.ts +9 -0
- package/src/main/conversation/ConversationService/messageGenerator.js +301 -0
- package/src/main/conversation/message/CompositeContentBuilder.d.ts +1 -1
- package/src/main/conversation/message/Message.d.ts +3 -3
- package/src/main/conversation/message/MessageBuilder.d.ts +6 -2
- package/src/main/conversation/message/MessageBuilder.js +3 -0
- package/src/main/conversation/message/MessageToProtoMapper.d.ts +2 -2
- package/src/main/conversation/message/OtrMessage.d.ts +2 -2
- package/src/main/conversation/message/PayloadBundle.d.ts +3 -3
- package/src/main/conversation/message/TeamMessage.d.ts +2 -2
- package/src/main/conversation/message/TextContentBuilder.d.ts +1 -1
- package/src/main/conversation/message/UserMessage.d.ts +2 -2
- package/src/main/cryptography/AssetCryptography/index.d.ts +1 -1
- package/src/main/cryptography/CryptographyDatabaseRepository.d.ts +1 -1
- package/src/main/cryptography/CryptographyService.d.ts +7 -7
- package/src/main/cryptography/GenericMessageMapper.d.ts +1 -1
- package/src/main/giphy/GiphyService.d.ts +2 -2
- package/src/main/mls/MLSService/MLSService.d.ts +5 -3
- package/src/main/mls/MLSService/MLSService.js +35 -10
- package/src/main/mls/types.d.ts +11 -0
- package/src/main/notification/NotificationBackendRepository.d.ts +2 -2
- package/src/main/notification/NotificationDatabaseRepository.d.ts +4 -7
- package/src/main/notification/NotificationDatabaseRepository.js +0 -10
- package/src/main/notification/NotificationService.d.ts +6 -17
- package/src/main/notification/NotificationService.js +15 -27
- package/src/main/notification/types.d.ts +0 -4
- package/src/main/self/SelfService.d.ts +2 -2
- package/src/main/team/TeamService.d.ts +2 -2
- package/src/main/test/CryptographyHelper.d.ts +1 -1
- package/src/main/user/UserService.d.ts +3 -3
- package/src/main/util/TypePredicateUtil.d.ts +2 -2
- package/src/main/util/{mapQualifiedUserClientIdsToFullyQualifiedClientIds.d.ts → fullyQualifiedClientIdUtils.d.ts} +5 -0
- package/src/main/util/{mapQualifiedUserClientIdsToFullyQualifiedClientIds.js → fullyQualifiedClientIdUtils.js} +12 -2
- package/CHANGELOG.md +0 -12408
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Wire
|
|
4
|
+
* Copyright (C) 2022 Wire Swiss GmbH
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
9
|
+
* (at your option) any later version.
|
|
10
|
+
*
|
|
11
|
+
* This program is distributed in the hope that it will be useful,
|
|
12
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
* GNU General Public License for more details.
|
|
15
|
+
*
|
|
16
|
+
* You should have received a copy of the GNU General Public License
|
|
17
|
+
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.generateGenericMessage = void 0;
|
|
22
|
+
const protocol_messaging_1 = require("@wireapp/protocol-messaging");
|
|
23
|
+
const PayloadBundle_1 = require("../message/PayloadBundle");
|
|
24
|
+
const MessageToProtoMapper_1 = require("../message/MessageToProtoMapper");
|
|
25
|
+
const GenericMessageType_1 = require("../GenericMessageType");
|
|
26
|
+
const AssetTransferState_1 = require("../AssetTransferState");
|
|
27
|
+
function generateGenericMessage(payload, messageTimer) {
|
|
28
|
+
const content = payload.content;
|
|
29
|
+
switch (payload.type) {
|
|
30
|
+
case PayloadBundle_1.PayloadBundleType.ASSET:
|
|
31
|
+
return { genericMessage: generateFileDataGenericMessage(payload, messageTimer), content };
|
|
32
|
+
case PayloadBundle_1.PayloadBundleType.ASSET_ABORT:
|
|
33
|
+
return { genericMessage: generateFileAbortGenericMessage(payload, messageTimer), content };
|
|
34
|
+
case PayloadBundle_1.PayloadBundleType.ASSET_META:
|
|
35
|
+
return { genericMessage: generateFileMetaDataGenericMessage(payload, messageTimer), content };
|
|
36
|
+
case PayloadBundle_1.PayloadBundleType.ASSET_IMAGE:
|
|
37
|
+
return generateImageGenericMessage(payload, messageTimer);
|
|
38
|
+
case PayloadBundle_1.PayloadBundleType.BUTTON_ACTION:
|
|
39
|
+
return { genericMessage: generateButtonActionGenericMessage(payload), content };
|
|
40
|
+
case PayloadBundle_1.PayloadBundleType.BUTTON_ACTION_CONFIRMATION:
|
|
41
|
+
return { genericMessage: generateButtonActionConfirmationGenericMessage(payload), content };
|
|
42
|
+
case PayloadBundle_1.PayloadBundleType.CALL:
|
|
43
|
+
return { genericMessage: generateCallGenericMessage(payload), content };
|
|
44
|
+
case PayloadBundle_1.PayloadBundleType.CLIENT_ACTION:
|
|
45
|
+
return { genericMessage: generateSessionResetGenericMessage(payload), content };
|
|
46
|
+
case PayloadBundle_1.PayloadBundleType.COMPOSITE:
|
|
47
|
+
return { genericMessage: generateCompositeGenericMessage(payload), content };
|
|
48
|
+
case PayloadBundle_1.PayloadBundleType.CONFIRMATION:
|
|
49
|
+
return { genericMessage: generateConfirmationGenericMessage(payload), content };
|
|
50
|
+
case PayloadBundle_1.PayloadBundleType.LOCATION:
|
|
51
|
+
return { genericMessage: generateLocationGenericMessage(payload, messageTimer), content };
|
|
52
|
+
case PayloadBundle_1.PayloadBundleType.MESSAGE_EDIT:
|
|
53
|
+
return { genericMessage: generateEditedTextGenericMessage(payload), content };
|
|
54
|
+
case PayloadBundle_1.PayloadBundleType.PING:
|
|
55
|
+
return { genericMessage: generatePingGenericMessage(payload, messageTimer), content };
|
|
56
|
+
case PayloadBundle_1.PayloadBundleType.REACTION:
|
|
57
|
+
return { genericMessage: generateReactionGenericMessage(payload), content };
|
|
58
|
+
case PayloadBundle_1.PayloadBundleType.TEXT:
|
|
59
|
+
return { genericMessage: generateTextGenericMessage(payload, messageTimer), content };
|
|
60
|
+
case PayloadBundle_1.PayloadBundleType.MESSAGE_DELETE:
|
|
61
|
+
return { genericMessage: generateDeleteMessage(payload), content };
|
|
62
|
+
/**
|
|
63
|
+
* ToDo: Create Generic implementation for everything else
|
|
64
|
+
*/
|
|
65
|
+
default:
|
|
66
|
+
throw new Error(`No send method implemented for "${payload['type']}".`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.generateGenericMessage = generateGenericMessage;
|
|
70
|
+
function generateButtonActionGenericMessage(payloadBundle) {
|
|
71
|
+
return protocol_messaging_1.GenericMessage.create({
|
|
72
|
+
[GenericMessageType_1.GenericMessageType.BUTTON_ACTION]: protocol_messaging_1.ButtonAction.create(payloadBundle.content),
|
|
73
|
+
messageId: payloadBundle.id,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function generateButtonActionConfirmationGenericMessage(payloadBundle) {
|
|
77
|
+
return protocol_messaging_1.GenericMessage.create({
|
|
78
|
+
[GenericMessageType_1.GenericMessageType.BUTTON_ACTION_CONFIRMATION]: protocol_messaging_1.ButtonActionConfirmation.create(payloadBundle.content),
|
|
79
|
+
messageId: payloadBundle.id,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function generateCompositeGenericMessage(payloadBundle) {
|
|
83
|
+
return protocol_messaging_1.GenericMessage.create({
|
|
84
|
+
[GenericMessageType_1.GenericMessageType.COMPOSITE]: protocol_messaging_1.Composite.create(payloadBundle.content),
|
|
85
|
+
messageId: payloadBundle.id,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function generateConfirmationGenericMessage(payloadBundle) {
|
|
89
|
+
const content = protocol_messaging_1.Confirmation.create(payloadBundle.content);
|
|
90
|
+
return protocol_messaging_1.GenericMessage.create({
|
|
91
|
+
[GenericMessageType_1.GenericMessageType.CONFIRMATION]: content,
|
|
92
|
+
messageId: payloadBundle.id,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function generateEditedTextGenericMessage(payloadBundle) {
|
|
96
|
+
const editedMessage = protocol_messaging_1.MessageEdit.create({
|
|
97
|
+
replacingMessageId: payloadBundle.content.originalMessageId,
|
|
98
|
+
text: MessageToProtoMapper_1.MessageToProtoMapper.mapText(payloadBundle),
|
|
99
|
+
});
|
|
100
|
+
return protocol_messaging_1.GenericMessage.create({
|
|
101
|
+
[GenericMessageType_1.GenericMessageType.EDITED]: editedMessage,
|
|
102
|
+
messageId: payloadBundle.id,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function generateFileDataGenericMessage(payloadBundle, messageTimer) {
|
|
106
|
+
if (!payloadBundle.content) {
|
|
107
|
+
throw new Error('No content for sendFileData provided.');
|
|
108
|
+
}
|
|
109
|
+
const { asset, expectsReadConfirmation, legalHoldStatus } = payloadBundle.content;
|
|
110
|
+
const remoteData = protocol_messaging_1.Asset.RemoteData.create({
|
|
111
|
+
assetId: asset.key,
|
|
112
|
+
assetToken: asset.token,
|
|
113
|
+
otrKey: asset.keyBytes,
|
|
114
|
+
sha256: asset.sha256,
|
|
115
|
+
assetDomain: asset.domain,
|
|
116
|
+
});
|
|
117
|
+
const assetMessage = protocol_messaging_1.Asset.create({
|
|
118
|
+
expectsReadConfirmation,
|
|
119
|
+
legalHoldStatus,
|
|
120
|
+
uploaded: remoteData,
|
|
121
|
+
});
|
|
122
|
+
assetMessage.status = AssetTransferState_1.AssetTransferState.UPLOADED;
|
|
123
|
+
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
124
|
+
[GenericMessageType_1.GenericMessageType.ASSET]: assetMessage,
|
|
125
|
+
messageId: payloadBundle.id,
|
|
126
|
+
});
|
|
127
|
+
const expireAfterMillis = messageTimer.getMessageTimer(payloadBundle.conversation);
|
|
128
|
+
return expireAfterMillis > 0 ? createEphemeral(genericMessage, expireAfterMillis) : genericMessage;
|
|
129
|
+
}
|
|
130
|
+
function generateFileMetaDataGenericMessage(payloadBundle, messageTimer) {
|
|
131
|
+
if (!payloadBundle.content) {
|
|
132
|
+
throw new Error('No content for sendFileMetaData provided.');
|
|
133
|
+
}
|
|
134
|
+
const { expectsReadConfirmation, legalHoldStatus, metaData } = payloadBundle.content;
|
|
135
|
+
const original = protocol_messaging_1.Asset.Original.create({
|
|
136
|
+
audio: metaData.audio,
|
|
137
|
+
mimeType: metaData.type,
|
|
138
|
+
name: metaData.name,
|
|
139
|
+
size: metaData.length,
|
|
140
|
+
video: metaData.video,
|
|
141
|
+
image: metaData.image,
|
|
142
|
+
});
|
|
143
|
+
const assetMessage = protocol_messaging_1.Asset.create({
|
|
144
|
+
expectsReadConfirmation,
|
|
145
|
+
legalHoldStatus,
|
|
146
|
+
original,
|
|
147
|
+
});
|
|
148
|
+
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
149
|
+
[GenericMessageType_1.GenericMessageType.ASSET]: assetMessage,
|
|
150
|
+
messageId: payloadBundle.id,
|
|
151
|
+
});
|
|
152
|
+
const expireAfterMillis = messageTimer.getMessageTimer(payloadBundle.conversation);
|
|
153
|
+
return expireAfterMillis > 0 ? createEphemeral(genericMessage, expireAfterMillis) : genericMessage;
|
|
154
|
+
}
|
|
155
|
+
function generateFileAbortGenericMessage(payloadBundle, messageTimer) {
|
|
156
|
+
if (!payloadBundle.content) {
|
|
157
|
+
throw new Error('No content for sendFileAbort provided.');
|
|
158
|
+
}
|
|
159
|
+
const { expectsReadConfirmation, legalHoldStatus, reason } = payloadBundle.content;
|
|
160
|
+
const assetMessage = protocol_messaging_1.Asset.create({
|
|
161
|
+
expectsReadConfirmation,
|
|
162
|
+
legalHoldStatus,
|
|
163
|
+
notUploaded: reason,
|
|
164
|
+
});
|
|
165
|
+
assetMessage.status = AssetTransferState_1.AssetTransferState.NOT_UPLOADED;
|
|
166
|
+
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
167
|
+
[GenericMessageType_1.GenericMessageType.ASSET]: assetMessage,
|
|
168
|
+
messageId: payloadBundle.id,
|
|
169
|
+
});
|
|
170
|
+
const expireAfterMillis = messageTimer.getMessageTimer(payloadBundle.conversation);
|
|
171
|
+
return expireAfterMillis > 0 ? createEphemeral(genericMessage, expireAfterMillis) : genericMessage;
|
|
172
|
+
}
|
|
173
|
+
function generateImageGenericMessage(payloadBundle, messageTimer) {
|
|
174
|
+
const imageAsset = generateAsset(payloadBundle);
|
|
175
|
+
let genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
176
|
+
[GenericMessageType_1.GenericMessageType.ASSET]: imageAsset,
|
|
177
|
+
messageId: payloadBundle.id,
|
|
178
|
+
});
|
|
179
|
+
const expireAfterMillis = messageTimer.getMessageTimer(payloadBundle.conversation);
|
|
180
|
+
if (expireAfterMillis) {
|
|
181
|
+
genericMessage = createEphemeral(genericMessage, expireAfterMillis);
|
|
182
|
+
}
|
|
183
|
+
return { genericMessage, content: imageAsset };
|
|
184
|
+
}
|
|
185
|
+
function generateLocationGenericMessage(payloadBundle, messageTimer) {
|
|
186
|
+
const { expectsReadConfirmation, latitude, legalHoldStatus, longitude, name, zoom } = payloadBundle.content;
|
|
187
|
+
const locationMessage = protocol_messaging_1.Location.create({
|
|
188
|
+
expectsReadConfirmation,
|
|
189
|
+
latitude,
|
|
190
|
+
legalHoldStatus,
|
|
191
|
+
longitude,
|
|
192
|
+
name,
|
|
193
|
+
zoom,
|
|
194
|
+
});
|
|
195
|
+
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
196
|
+
[GenericMessageType_1.GenericMessageType.LOCATION]: locationMessage,
|
|
197
|
+
messageId: payloadBundle.id,
|
|
198
|
+
});
|
|
199
|
+
const expireAfterMillis = messageTimer.getMessageTimer(payloadBundle.conversation);
|
|
200
|
+
return expireAfterMillis > 0 ? createEphemeral(genericMessage, expireAfterMillis) : genericMessage;
|
|
201
|
+
}
|
|
202
|
+
function generatePingGenericMessage(payloadBundle, messageTimer) {
|
|
203
|
+
const content = protocol_messaging_1.Knock.create(payloadBundle.content);
|
|
204
|
+
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
205
|
+
[GenericMessageType_1.GenericMessageType.KNOCK]: content,
|
|
206
|
+
messageId: payloadBundle.id,
|
|
207
|
+
});
|
|
208
|
+
const expireAfterMillis = messageTimer.getMessageTimer(payloadBundle.conversation);
|
|
209
|
+
return expireAfterMillis > 0 ? createEphemeral(genericMessage, expireAfterMillis) : genericMessage;
|
|
210
|
+
}
|
|
211
|
+
function generateReactionGenericMessage(payloadBundle) {
|
|
212
|
+
const { legalHoldStatus, originalMessageId, type } = payloadBundle.content;
|
|
213
|
+
const reaction = protocol_messaging_1.Reaction.create({
|
|
214
|
+
emoji: type,
|
|
215
|
+
legalHoldStatus,
|
|
216
|
+
messageId: originalMessageId,
|
|
217
|
+
});
|
|
218
|
+
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
219
|
+
[GenericMessageType_1.GenericMessageType.REACTION]: reaction,
|
|
220
|
+
messageId: payloadBundle.id,
|
|
221
|
+
});
|
|
222
|
+
return genericMessage;
|
|
223
|
+
}
|
|
224
|
+
function generateSessionResetGenericMessage(payload) {
|
|
225
|
+
if (payload.content.clientAction !== protocol_messaging_1.ClientAction.RESET_SESSION) {
|
|
226
|
+
throw new Error(`No send method implemented for "${payload.type}" and ClientAction "${payload.content}".`);
|
|
227
|
+
}
|
|
228
|
+
return protocol_messaging_1.GenericMessage.create({
|
|
229
|
+
[GenericMessageType_1.GenericMessageType.CLIENT_ACTION]: protocol_messaging_1.ClientAction.RESET_SESSION,
|
|
230
|
+
messageId: payload.id,
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
function generateCallGenericMessage(payloadBundle) {
|
|
234
|
+
const callMessage = protocol_messaging_1.Calling.create({
|
|
235
|
+
content: payloadBundle.content,
|
|
236
|
+
});
|
|
237
|
+
return protocol_messaging_1.GenericMessage.create({
|
|
238
|
+
[GenericMessageType_1.GenericMessageType.CALLING]: callMessage,
|
|
239
|
+
messageId: payloadBundle.id,
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
function generateDeleteMessage(payload) {
|
|
243
|
+
const content = protocol_messaging_1.MessageDelete.create({
|
|
244
|
+
messageId: payload.content.messageId,
|
|
245
|
+
});
|
|
246
|
+
return protocol_messaging_1.GenericMessage.create({
|
|
247
|
+
[GenericMessageType_1.GenericMessageType.DELETED]: content,
|
|
248
|
+
messageId: payload.id,
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
function generateTextGenericMessage(payloadBundle, messageTimer) {
|
|
252
|
+
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
253
|
+
messageId: payloadBundle.id,
|
|
254
|
+
[GenericMessageType_1.GenericMessageType.TEXT]: MessageToProtoMapper_1.MessageToProtoMapper.mapText(payloadBundle),
|
|
255
|
+
});
|
|
256
|
+
const expireAfterMillis = messageTimer.getMessageTimer(payloadBundle.conversation);
|
|
257
|
+
return expireAfterMillis > 0 ? createEphemeral(genericMessage, expireAfterMillis) : genericMessage;
|
|
258
|
+
}
|
|
259
|
+
function generateAsset(payloadBundle) {
|
|
260
|
+
if (!payloadBundle.content) {
|
|
261
|
+
throw new Error('No content for sendImage provided.');
|
|
262
|
+
}
|
|
263
|
+
const { asset, expectsReadConfirmation, image, legalHoldStatus } = payloadBundle.content;
|
|
264
|
+
const imageMetadata = protocol_messaging_1.Asset.ImageMetaData.create({
|
|
265
|
+
height: image.height,
|
|
266
|
+
width: image.width,
|
|
267
|
+
});
|
|
268
|
+
const original = protocol_messaging_1.Asset.Original.create({
|
|
269
|
+
[GenericMessageType_1.GenericMessageType.IMAGE]: imageMetadata,
|
|
270
|
+
mimeType: image.type,
|
|
271
|
+
name: null,
|
|
272
|
+
size: image.data.length,
|
|
273
|
+
});
|
|
274
|
+
const remoteData = protocol_messaging_1.Asset.RemoteData.create({
|
|
275
|
+
assetId: asset.key,
|
|
276
|
+
assetToken: asset.token,
|
|
277
|
+
assetDomain: asset.domain,
|
|
278
|
+
otrKey: asset.keyBytes,
|
|
279
|
+
sha256: asset.sha256,
|
|
280
|
+
});
|
|
281
|
+
const assetMessage = protocol_messaging_1.Asset.create({
|
|
282
|
+
expectsReadConfirmation,
|
|
283
|
+
legalHoldStatus,
|
|
284
|
+
original,
|
|
285
|
+
uploaded: remoteData,
|
|
286
|
+
});
|
|
287
|
+
assetMessage.status = AssetTransferState_1.AssetTransferState.UPLOADED;
|
|
288
|
+
return assetMessage;
|
|
289
|
+
}
|
|
290
|
+
function createEphemeral(originalGenericMessage, expireAfterMillis) {
|
|
291
|
+
const ephemeralMessage = protocol_messaging_1.Ephemeral.create({
|
|
292
|
+
expireAfterMillis,
|
|
293
|
+
[originalGenericMessage.content]: originalGenericMessage[originalGenericMessage.content],
|
|
294
|
+
});
|
|
295
|
+
const genericMessage = protocol_messaging_1.GenericMessage.create({
|
|
296
|
+
[GenericMessageType_1.GenericMessageType.EPHEMERAL]: ephemeralMessage,
|
|
297
|
+
messageId: originalGenericMessage.messageId,
|
|
298
|
+
});
|
|
299
|
+
return genericMessage;
|
|
300
|
+
}
|
|
301
|
+
//# sourceMappingURL=messageGenerator.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Text } from '@wireapp/protocol-messaging';
|
|
2
2
|
import { LegalHoldStatus } from '../content';
|
|
3
|
-
import
|
|
3
|
+
import { CompositeMessage } from './OtrMessage';
|
|
4
4
|
export declare class CompositeContentBuilder {
|
|
5
5
|
private readonly content;
|
|
6
6
|
private readonly payloadBundle;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { OtrMessage } from './OtrMessage';
|
|
2
|
+
import { TeamMessage } from './TeamMessage';
|
|
3
|
+
import { UserMessage } from './UserMessage';
|
|
4
4
|
export declare type Message = OtrMessage | TeamMessage | UserMessage;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { Confirmation } from '@wireapp/protocol-messaging';
|
|
2
2
|
import { AbortReason } from '..';
|
|
3
3
|
import { EncryptedAssetUploaded } from '../../cryptography';
|
|
4
|
-
import
|
|
4
|
+
import { ButtonActionConfirmationContent, ButtonActionContent, CallingContent, FileContent, FileMetaDataContent, ImageContent, KnockContent, LegalHoldStatus, LocationContent, ReactionContent } from '../content';
|
|
5
5
|
import { CompositeContentBuilder } from './CompositeContentBuilder';
|
|
6
|
-
import
|
|
6
|
+
import { ButtonActionConfirmationMessage, ButtonActionMessage, CallMessage, ConfirmationMessage, DeleteMessage, FileAssetAbortMessage, FileAssetMessage, FileAssetMetaDataMessage, ImageAssetMessageOutgoing, LocationMessage, PingMessage, ReactionMessage, ResetSessionMessage } from './OtrMessage';
|
|
7
7
|
import { TextContentBuilder } from './TextContentBuilder';
|
|
8
8
|
interface BaseOptions {
|
|
9
9
|
conversationId: string;
|
|
10
10
|
from: string;
|
|
11
11
|
messageId?: string;
|
|
12
12
|
}
|
|
13
|
+
interface CreateDeleteOption extends BaseOptions {
|
|
14
|
+
messageIdToDelete: string;
|
|
15
|
+
}
|
|
13
16
|
interface CreateImageOptions extends BaseOptions {
|
|
14
17
|
expectsReadConfirmation?: boolean;
|
|
15
18
|
asset: EncryptedAssetUploaded;
|
|
@@ -69,6 +72,7 @@ interface CreateActionMessageOptions extends BaseOptions {
|
|
|
69
72
|
export declare class MessageBuilder {
|
|
70
73
|
static createEditedText(payload: CreateEditedTextOptions): TextContentBuilder;
|
|
71
74
|
static createFileData(payload: CreateFileOptions): FileAssetMessage;
|
|
75
|
+
static createDelete(payload: CreateDeleteOption): DeleteMessage;
|
|
72
76
|
static createFileMetadata(payload: CreateFileMetadataOptions): FileAssetMetaDataMessage;
|
|
73
77
|
static createFileAbort(payload: CreateFileAbortOptions): FileAssetAbortMessage;
|
|
74
78
|
static createImage(payload: CreateImageOptions): ImageAssetMessageOutgoing;
|
|
@@ -53,6 +53,9 @@ class MessageBuilder {
|
|
|
53
53
|
legalHoldStatus,
|
|
54
54
|
}, id: originalMessageId, type: __1.PayloadBundleType.ASSET });
|
|
55
55
|
}
|
|
56
|
+
static createDelete(payload) {
|
|
57
|
+
return Object.assign(Object.assign({}, createCommonProperties(payload)), { content: { messageId: payload.messageIdToDelete }, type: __1.PayloadBundleType.MESSAGE_DELETE });
|
|
58
|
+
}
|
|
56
59
|
static createFileMetadata(payload) {
|
|
57
60
|
const { expectsReadConfirmation, legalHoldStatus, metaData } = payload;
|
|
58
61
|
return Object.assign(Object.assign({}, createCommonProperties(payload)), { content: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LinkPreview, Text } from '@wireapp/protocol-messaging';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import { LinkPreviewUploadedContent } from '../content';
|
|
3
|
+
import { EditedTextMessage, TextMessage } from './OtrMessage';
|
|
4
4
|
export declare class MessageToProtoMapper {
|
|
5
5
|
static mapLinkPreviews(linkPreviews: LinkPreviewUploadedContent[]): LinkPreview[];
|
|
6
6
|
static mapText(payloadBundle: TextMessage | EditedTextMessage): Text;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { AssetContent, ButtonActionContent, ButtonActionConfirmationContent, CallingContent, ClearedContent, ClientActionContent, CompositeContent, ConfirmationContent, DeletedContent, EditedTextContent, FileAssetAbortContent, FileAssetContent, FileAssetMetaDataContent, HiddenContent, ImageAssetContent, KnockContent, LocationContent, ReactionContent, TextContent } from '../content';
|
|
2
|
+
import { BasePayloadBundle, PayloadBundleType } from './PayloadBundle';
|
|
3
3
|
export interface TextMessage extends BasePayloadBundle {
|
|
4
4
|
content: TextContent;
|
|
5
5
|
type: PayloadBundleType.TEXT;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ConversationEventData, TeamEventData, UserEventData } from '@wireapp/api-client/src/event/';
|
|
2
2
|
import { QualifiedId } from '@wireapp/api-client/src/user';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import { ConversationContent } from '../content';
|
|
4
|
+
import { Message } from './Message';
|
|
5
5
|
export declare type PayloadBundleContent = ConversationContent | ConversationEventData | TeamEventData | UserEventData;
|
|
6
6
|
export declare enum PayloadBundleSource {
|
|
7
7
|
LOCAL = "PayloadBundleSource.LOCAL",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { TeamConversationCreateData, TeamConversationDeleteData, TeamMemberJoinData, TeamMemberLeaveData, TeamUpdateData } from '@wireapp/api-client/src/team/data';
|
|
2
|
+
import { BasePayloadBundle, PayloadBundleType } from './PayloadBundle';
|
|
3
3
|
export interface TeamConversationCreateMessage extends BasePayloadBundle {
|
|
4
4
|
content: TeamConversationCreateData;
|
|
5
5
|
type: PayloadBundleType.TEAM_CONVERSATION_CREATE;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LegalHoldStatus, LinkPreviewUploadedContent, MentionContent, QuoteContent } from '../content';
|
|
2
|
-
import
|
|
2
|
+
import { EditedTextMessage, TextMessage, QuotableMessage } from './OtrMessage';
|
|
3
3
|
export declare class TextContentBuilder {
|
|
4
4
|
private readonly content;
|
|
5
5
|
private readonly payloadBundle;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { UserActivateData, UserClientAddData, UserClientRemoveData, UserConnectionData, UserDeleteData, UserLegalHoldDisableData, UserLegalHoldEnableData, UserLegalHoldRequestData, UserPropertiesSetData, UserUpdateData } from '@wireapp/api-client/src/user/data';
|
|
2
|
+
import { BasePayloadBundle, PayloadBundleType } from './PayloadBundle';
|
|
3
3
|
export interface UserActivateMessage extends BasePayloadBundle {
|
|
4
4
|
content: UserActivateData;
|
|
5
5
|
type: PayloadBundleType.USER_ACTIVATE;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import { APIClient } from '@wireapp/api-client';
|
|
2
|
+
import { PreKey as SerializedPreKey } from '@wireapp/api-client/src/auth/';
|
|
3
|
+
import { RegisteredClient } from '@wireapp/api-client/src/client/';
|
|
4
|
+
import { OTRRecipients, QualifiedOTRRecipients, QualifiedUserClients, UserClients } from '@wireapp/api-client/src/conversation/';
|
|
5
|
+
import { ConversationOtrMessageAddEvent } from '@wireapp/api-client/src/event';
|
|
6
|
+
import { QualifiedId, QualifiedUserPreKeyBundleMap, UserPreKeyBundleMap } from '@wireapp/api-client/src/user/';
|
|
7
7
|
import { Cryptobox } from '@wireapp/cryptobox';
|
|
8
8
|
import { GenericMessage } from '@wireapp/protocol-messaging';
|
|
9
|
-
import
|
|
9
|
+
import { CRUDEngine } from '@wireapp/store-engine';
|
|
10
10
|
import { PayloadBundle, PayloadBundleSource } from '../conversation';
|
|
11
11
|
export declare type DecryptionError = {
|
|
12
12
|
code: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ConversationOtrMessageAddEvent } from '@wireapp/api-client/src/event/';
|
|
2
2
|
import { PayloadBundle, PayloadBundleSource } from '../conversation';
|
|
3
3
|
export declare class GenericMessageMapper {
|
|
4
4
|
private static readonly logger;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { APIClient } from '@wireapp/api-client';
|
|
2
|
+
import { GiphySearchOptions, GiphyMultipleResult, GiphyResult, GIPHY_RATING } from '@wireapp/api-client/src/giphy/';
|
|
3
3
|
export declare class GiphyService {
|
|
4
4
|
private readonly apiClient;
|
|
5
5
|
constructor(apiClient: APIClient);
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { AddProposalArgs,
|
|
1
|
+
import { AddProposalArgs, ConversationConfiguration, ConversationId, CoreCrypto, DecryptedMessage, ExternalProposalArgs, ExternalProposalType, ExternalRemoveProposalArgs, Invitee, ProposalArgs, ProposalType, RemoveProposalArgs } from '@wireapp/core-crypto';
|
|
2
2
|
import { APIClient } from '@wireapp/api-client';
|
|
3
3
|
import { QualifiedUsers } from '../../conversation';
|
|
4
|
-
import
|
|
4
|
+
import { MLSCallbacks, MLSConfig } from '../types';
|
|
5
5
|
import { PostMlsMessageResponse } from '@wireapp/api-client/src/conversation';
|
|
6
6
|
export declare const optionalToUint8Array: (array: Uint8Array | []) => Uint8Array;
|
|
7
7
|
export declare class MLSService {
|
|
8
8
|
readonly config: MLSConfig | undefined;
|
|
9
9
|
private readonly apiClient;
|
|
10
10
|
private readonly coreCryptoClientProvider;
|
|
11
|
+
groupIdFromConversationId?: MLSCallbacks['groupIdFromConversationId'];
|
|
11
12
|
constructor(config: MLSConfig | undefined, apiClient: APIClient, coreCryptoClientProvider: () => CoreCrypto | undefined);
|
|
12
13
|
private getCoreCryptoClient;
|
|
13
14
|
private uploadCommitBundle;
|
|
14
15
|
addUsersToExistingConversation(groupId: Uint8Array, invitee: Invitee[]): Promise<PostMlsMessageResponse | null>;
|
|
16
|
+
configureMLSCallbacks({ groupIdFromConversationId, ...coreCryptoCallbacks }: MLSCallbacks): void;
|
|
15
17
|
getKeyPackagesPayload(qualifiedUsers: QualifiedUsers[]): Promise<Invitee[]>;
|
|
16
18
|
newProposal(proposalType: ProposalType, args: ProposalArgs | AddProposalArgs | RemoveProposalArgs): Promise<import("@wireapp/core-crypto").ProposalBundle>;
|
|
17
19
|
newExternalProposal(externalProposalType: ExternalProposalType, args: ExternalProposalArgs | ExternalRemoveProposalArgs): Promise<Uint8Array>;
|
|
@@ -21,7 +23,7 @@ export declare class MLSService {
|
|
|
21
23
|
updateKeyingMaterial(conversationId: ConversationId): Promise<PostMlsMessageResponse | null>;
|
|
22
24
|
createConversation(conversationId: ConversationId, configuration?: ConversationConfiguration): Promise<any>;
|
|
23
25
|
removeClientsFromConversation(conversationId: ConversationId, clientIds: Uint8Array[]): Promise<PostMlsMessageResponse | null>;
|
|
24
|
-
commitPendingProposals(
|
|
26
|
+
commitPendingProposals(groupId: ConversationId): Promise<void>;
|
|
25
27
|
conversationExists(conversationId: ConversationId): Promise<boolean>;
|
|
26
28
|
clientValidKeypackagesCount(): Promise<number>;
|
|
27
29
|
clientKeypackages(amountRequested: number): Promise<Uint8Array[]>;
|
|
@@ -17,10 +17,22 @@
|
|
|
17
17
|
* along with this program. If not, see http://www.gnu.org/licenses/.
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
21
|
+
var t = {};
|
|
22
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
23
|
+
t[p] = s[p];
|
|
24
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
25
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
26
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
27
|
+
t[p[i]] = s[p[i]];
|
|
28
|
+
}
|
|
29
|
+
return t;
|
|
30
|
+
};
|
|
20
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
32
|
exports.MLSService = exports.optionalToUint8Array = void 0;
|
|
22
33
|
const bazinga64_1 = require("bazinga64");
|
|
23
34
|
const messageSender_1 = require("../../conversation/message/messageSender");
|
|
35
|
+
const fullyQualifiedClientIdUtils_1 = require("../../util/fullyQualifiedClientIdUtils");
|
|
24
36
|
//@todo: this function is temporary, we wait for the update from core-crypto side
|
|
25
37
|
//they are returning regular array instead of Uint8Array for commit and welcome messages
|
|
26
38
|
const optionalToUint8Array = (array) => {
|
|
@@ -40,23 +52,23 @@ class MLSService {
|
|
|
40
52
|
}
|
|
41
53
|
return client;
|
|
42
54
|
}
|
|
43
|
-
async uploadCommitBundle(groupId,
|
|
55
|
+
async uploadCommitBundle(groupId, { commit, welcome }) {
|
|
44
56
|
const coreCryptoClient = this.getCoreCryptoClient();
|
|
45
|
-
if (
|
|
46
|
-
//@todo: it's temporary - we wait for core-crypto fix to return the actual Uint8Array instead of regular array
|
|
47
|
-
await this.apiClient.api.conversation.postMlsWelcomeMessage((0, exports.optionalToUint8Array)(commitBundle.welcome));
|
|
48
|
-
}
|
|
49
|
-
if (commitBundle.commit) {
|
|
57
|
+
if (commit) {
|
|
50
58
|
try {
|
|
51
59
|
const messageResponse = await this.apiClient.api.conversation.postMlsMessage(
|
|
52
60
|
//@todo: it's temporary - we wait for core-crypto fix to return the actual Uint8Array instead of regular array
|
|
53
|
-
(0, exports.optionalToUint8Array)(
|
|
61
|
+
(0, exports.optionalToUint8Array)(commit));
|
|
54
62
|
await coreCryptoClient.commitAccepted(groupId);
|
|
63
|
+
if (welcome) {
|
|
64
|
+
// If the commit went well, we can send the Welcome
|
|
65
|
+
//@todo: it's temporary - we wait for core-crypto fix to return the actual Uint8Array instead of regular array
|
|
66
|
+
await this.apiClient.api.conversation.postMlsWelcomeMessage((0, exports.optionalToUint8Array)(welcome));
|
|
67
|
+
}
|
|
55
68
|
return messageResponse;
|
|
56
69
|
}
|
|
57
70
|
catch (error) {
|
|
58
71
|
await coreCryptoClient.clearPendingCommit(groupId);
|
|
59
|
-
return null;
|
|
60
72
|
}
|
|
61
73
|
}
|
|
62
74
|
return null;
|
|
@@ -68,6 +80,18 @@ class MLSService {
|
|
|
68
80
|
return this.uploadCommitBundle(groupId, memberAddedMessages);
|
|
69
81
|
});
|
|
70
82
|
}
|
|
83
|
+
configureMLSCallbacks(_a) {
|
|
84
|
+
var { groupIdFromConversationId } = _a, coreCryptoCallbacks = __rest(_a, ["groupIdFromConversationId"]);
|
|
85
|
+
this.getCoreCryptoClient().registerCallbacks(Object.assign(Object.assign({}, coreCryptoCallbacks), { clientIdBelongsToOneOf: (client, otherClients) => {
|
|
86
|
+
const decoder = new TextDecoder();
|
|
87
|
+
const { user } = (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(decoder.decode(client));
|
|
88
|
+
return otherClients.some(client => {
|
|
89
|
+
const { user: otherUser } = (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(decoder.decode(client));
|
|
90
|
+
return otherUser === user;
|
|
91
|
+
});
|
|
92
|
+
} }));
|
|
93
|
+
this.groupIdFromConversationId = groupIdFromConversationId;
|
|
94
|
+
}
|
|
71
95
|
async getKeyPackagesPayload(qualifiedUsers) {
|
|
72
96
|
/**
|
|
73
97
|
* @note We need to fetch key packages for all the users
|
|
@@ -122,8 +146,9 @@ class MLSService {
|
|
|
122
146
|
return this.uploadCommitBundle(conversationId, commitBundle);
|
|
123
147
|
});
|
|
124
148
|
}
|
|
125
|
-
async commitPendingProposals(
|
|
126
|
-
|
|
149
|
+
async commitPendingProposals(groupId) {
|
|
150
|
+
const commitBundle = await this.getCoreCryptoClient().commitPendingProposals(groupId);
|
|
151
|
+
return commitBundle ? void this.uploadCommitBundle(groupId, commitBundle) : undefined;
|
|
127
152
|
}
|
|
128
153
|
async conversationExists(conversationId) {
|
|
129
154
|
return this.getCoreCryptoClient().conversationExists(conversationId);
|
package/src/main/mls/types.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
+
import { QualifiedId } from '@wireapp/api-client/src/user';
|
|
2
|
+
import { CoreCryptoCallbacks } from '@wireapp/core-crypto';
|
|
1
3
|
declare type SecretCrypto<T> = {
|
|
2
4
|
encrypt: (value: Uint8Array) => Promise<T>;
|
|
3
5
|
decrypt: (payload: T) => Promise<Uint8Array>;
|
|
4
6
|
};
|
|
7
|
+
export interface MLSCallbacks extends Pick<CoreCryptoCallbacks, 'authorize'> {
|
|
8
|
+
/**
|
|
9
|
+
* Should return a groupId corresponding to the conversation ID given
|
|
10
|
+
* Used for the core to know what core-crypto conversation we are dealing with when receiving events
|
|
11
|
+
* @param conversationId
|
|
12
|
+
* @returns the bytes of the groupId corresponding to the conversation ID
|
|
13
|
+
*/
|
|
14
|
+
groupIdFromConversationId: (conversationId: QualifiedId) => Promise<string | undefined>;
|
|
15
|
+
}
|
|
5
16
|
export interface MLSConfig<T = any> {
|
|
6
17
|
/**
|
|
7
18
|
* encrypt/decrypt function pair that will be called before storing/fetching secrets in the secrets database.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { APIClient } from '@wireapp/api-client';
|
|
2
|
+
import { Notification } from '@wireapp/api-client/src/notification/';
|
|
3
3
|
export declare class NotificationBackendRepository {
|
|
4
4
|
private readonly apiClient;
|
|
5
5
|
constructor(apiClient: APIClient);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { CommonMLS,
|
|
1
|
+
import { BackendEvent } from '@wireapp/api-client/src/event';
|
|
2
|
+
import { Notification } from '@wireapp/api-client/src/notification/';
|
|
3
|
+
import { CRUDEngine } from '@wireapp/store-engine';
|
|
4
|
+
import { CommonMLS, StorePendingProposalsParams } from './types';
|
|
5
5
|
export declare enum DatabaseStores {
|
|
6
6
|
EVENTS = "events"
|
|
7
7
|
}
|
|
@@ -18,9 +18,6 @@ export declare class NotificationDatabaseRepository {
|
|
|
18
18
|
createLastEventDate(eventDate: Date): Promise<Date>;
|
|
19
19
|
getLastNotificationId(): Promise<string>;
|
|
20
20
|
updateLastNotificationId(lastNotification: Notification): Promise<string>;
|
|
21
|
-
private generateCompoundGroupIdPrimaryKey;
|
|
22
|
-
addCompoundGroupId(params: CompoundGroupIdParams): Promise<CompoundGroupIdParams>;
|
|
23
|
-
getCompoundGroupId(params: Omit<CompoundGroupIdParams, 'groupId'>): Promise<string>;
|
|
24
21
|
/**
|
|
25
22
|
* ## MLS only ##
|
|
26
23
|
* Store groupIds with pending proposals and a delay in the DB until the proposals get committed.
|