@wireapp/core 17.27.3 → 17.28.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/package.json +3 -3
- package/src/main/conversation/ConversationService.d.ts +39 -14
- package/src/main/conversation/ConversationService.js +64 -26
- package/src/main/conversation/ConversationService.js.map +1 -1
- package/src/main/conversation/ConversationService.test.node.js +98 -51
- package/src/main/conversation/ConversationService.test.node.js.map +1 -1
- package/src/main/conversation/ConversationService.test.node.ts +137 -61
- package/src/main/conversation/ConversationService.ts +107 -32
- package/src/main/conversation/message/MessageService.d.ts +4 -2
- package/src/main/conversation/message/MessageService.js +31 -6
- package/src/main/conversation/message/MessageService.js.map +1 -1
- package/src/main/conversation/message/MessageService.test.node.js +6 -6
- package/src/main/conversation/message/MessageService.test.node.js.map +1 -1
- package/src/main/conversation/message/MessageService.test.node.ts +6 -6
- package/src/main/conversation/message/MessageService.ts +47 -16
|
@@ -41,6 +41,7 @@ import {MessageBuilder} from './MessageBuilder';
|
|
|
41
41
|
import {GenericMessage} from '@wireapp/protocol-messaging';
|
|
42
42
|
import {GenericMessageType} from '..';
|
|
43
43
|
import {flattenUserClients, flattenQualifiedUserClients} from './UserClientsUtil';
|
|
44
|
+
import {isQualifiedIdArray, isStringArray} from '../../util';
|
|
44
45
|
|
|
45
46
|
type ClientMismatchError = AxiosError<ClientMismatch | MessageSendingStatus>;
|
|
46
47
|
|
|
@@ -65,8 +66,9 @@ export class MessageService {
|
|
|
65
66
|
plainText: Uint8Array,
|
|
66
67
|
options: {
|
|
67
68
|
conversationId?: string;
|
|
68
|
-
reportMissing?: boolean;
|
|
69
|
+
reportMissing?: boolean | string[];
|
|
69
70
|
sendAsProtobuf?: boolean;
|
|
71
|
+
nativePush?: boolean;
|
|
70
72
|
onClientMismatch?: (mismatch: ClientMismatch) => void | boolean | Promise<boolean>;
|
|
71
73
|
} = {},
|
|
72
74
|
): Promise<ClientMismatch & {errored?: boolean}> {
|
|
@@ -119,7 +121,8 @@ export class MessageService {
|
|
|
119
121
|
options: {
|
|
120
122
|
assetData?: Uint8Array;
|
|
121
123
|
conversationId?: QualifiedId;
|
|
122
|
-
reportMissing?: boolean;
|
|
124
|
+
reportMissing?: boolean | QualifiedId[];
|
|
125
|
+
nativePush?: boolean;
|
|
123
126
|
onClientMismatch?: (mismatch: MessageSendingStatus) => void | boolean | Promise<boolean>;
|
|
124
127
|
},
|
|
125
128
|
): Promise<MessageSendingStatus & {errored?: boolean}> {
|
|
@@ -146,7 +149,12 @@ export class MessageService {
|
|
|
146
149
|
private async sendFederatedOtrMessage(
|
|
147
150
|
sendingClientId: string,
|
|
148
151
|
recipients: QualifiedOTRRecipients,
|
|
149
|
-
options: {
|
|
152
|
+
options: {
|
|
153
|
+
assetData?: Uint8Array;
|
|
154
|
+
conversationId?: QualifiedId;
|
|
155
|
+
reportMissing?: boolean | QualifiedId[];
|
|
156
|
+
nativePush?: boolean;
|
|
157
|
+
},
|
|
150
158
|
): Promise<MessageSendingStatus> {
|
|
151
159
|
const qualifiedUserEntries = Object.entries(recipients).map<ProtobufOTR.IQualifiedUserEntry>(
|
|
152
160
|
([domain, otrRecipients]) => {
|
|
@@ -177,6 +185,7 @@ export class MessageService {
|
|
|
177
185
|
sender: {
|
|
178
186
|
client: Long.fromString(sendingClientId, 16),
|
|
179
187
|
},
|
|
188
|
+
nativePush: options.nativePush,
|
|
180
189
|
});
|
|
181
190
|
|
|
182
191
|
if (options.assetData) {
|
|
@@ -184,9 +193,13 @@ export class MessageService {
|
|
|
184
193
|
}
|
|
185
194
|
|
|
186
195
|
if (options.reportMissing) {
|
|
187
|
-
|
|
196
|
+
if (isQualifiedIdArray(options.reportMissing)) {
|
|
197
|
+
protoMessage.reportOnly = {userIds: options.reportMissing};
|
|
198
|
+
} else {
|
|
199
|
+
protoMessage.reportAll = true;
|
|
200
|
+
}
|
|
188
201
|
} else {
|
|
189
|
-
protoMessage.ignoreAll =
|
|
202
|
+
protoMessage.ignoreAll = true;
|
|
190
203
|
}
|
|
191
204
|
|
|
192
205
|
if (!options.conversationId) {
|
|
@@ -202,22 +215,31 @@ export class MessageService {
|
|
|
202
215
|
private async sendOTRMessage(
|
|
203
216
|
sendingClientId: string,
|
|
204
217
|
recipients: OTRRecipients<Uint8Array>,
|
|
205
|
-
options: {
|
|
218
|
+
options: {
|
|
219
|
+
conversationId?: string;
|
|
220
|
+
assetData?: Uint8Array;
|
|
221
|
+
reportMissing?: boolean | string[];
|
|
222
|
+
nativePush?: boolean;
|
|
223
|
+
},
|
|
206
224
|
): Promise<ClientMismatch> {
|
|
207
225
|
const message: NewOTRMessage<string> = {
|
|
208
226
|
data: options.assetData ? Encoder.toBase64(options.assetData).asString : undefined,
|
|
209
227
|
recipients: CryptographyService.convertArrayRecipientsToBase64(recipients),
|
|
210
228
|
sender: sendingClientId,
|
|
229
|
+
native_push: options.nativePush,
|
|
211
230
|
};
|
|
212
231
|
|
|
232
|
+
let ignoreMissing;
|
|
233
|
+
if (isStringArray(options.reportMissing)) {
|
|
234
|
+
message.report_missing = options.reportMissing;
|
|
235
|
+
} else {
|
|
236
|
+
// By default we want ignore missing to be false (and have mismatch errors in case some clients are missing)
|
|
237
|
+
ignoreMissing = typeof options.reportMissing === 'boolean' ? !options.reportMissing : false;
|
|
238
|
+
}
|
|
239
|
+
|
|
213
240
|
return !options.conversationId
|
|
214
|
-
? this.apiClient.broadcast.api.postBroadcastMessage(sendingClientId, message,
|
|
215
|
-
: this.apiClient.conversation.api.postOTRMessage(
|
|
216
|
-
sendingClientId,
|
|
217
|
-
options.conversationId,
|
|
218
|
-
message,
|
|
219
|
-
!options.reportMissing,
|
|
220
|
-
);
|
|
241
|
+
? this.apiClient.broadcast.api.postBroadcastMessage(sendingClientId, message, ignoreMissing)
|
|
242
|
+
: this.apiClient.conversation.api.postOTRMessage(sendingClientId, options.conversationId, message, ignoreMissing);
|
|
221
243
|
}
|
|
222
244
|
|
|
223
245
|
private async generateExternalPayload(plainText: Uint8Array): Promise<{text: Uint8Array; cipherText: Uint8Array}> {
|
|
@@ -309,7 +331,7 @@ export class MessageService {
|
|
|
309
331
|
private async sendOTRProtobufMessage(
|
|
310
332
|
sendingClientId: string,
|
|
311
333
|
recipients: OTRRecipients<Uint8Array>,
|
|
312
|
-
options: {conversationId?: string; assetData?: Uint8Array; reportMissing?: boolean},
|
|
334
|
+
options: {conversationId?: string; assetData?: Uint8Array; reportMissing?: boolean | string[]},
|
|
313
335
|
): Promise<ClientMismatch> {
|
|
314
336
|
const userEntries: ProtobufOTR.IUserEntry[] = Object.entries(recipients).map(([userId, otrClientMap]) => {
|
|
315
337
|
const clients: ProtobufOTR.IClientEntry[] = Object.entries(otrClientMap).map(([clientId, payload]) => {
|
|
@@ -336,17 +358,26 @@ export class MessageService {
|
|
|
336
358
|
},
|
|
337
359
|
});
|
|
338
360
|
|
|
361
|
+
let ignoreMissing;
|
|
362
|
+
if (isStringArray(options.reportMissing)) {
|
|
363
|
+
const encoder = new TextEncoder();
|
|
364
|
+
protoMessage.reportMissing = options.reportMissing.map(userId => ({uuid: encoder.encode(userId)}));
|
|
365
|
+
} else {
|
|
366
|
+
// By default we want ignore missing to be false (and have mismatch errors in case some clients are missing)
|
|
367
|
+
ignoreMissing = typeof options.reportMissing === 'boolean' ? !options.reportMissing : false;
|
|
368
|
+
}
|
|
369
|
+
|
|
339
370
|
if (options.assetData) {
|
|
340
371
|
protoMessage.blob = options.assetData;
|
|
341
372
|
}
|
|
342
373
|
|
|
343
374
|
return !options.conversationId
|
|
344
|
-
? this.apiClient.broadcast.api.postBroadcastProtobufMessage(sendingClientId, protoMessage,
|
|
375
|
+
? this.apiClient.broadcast.api.postBroadcastProtobufMessage(sendingClientId, protoMessage, ignoreMissing)
|
|
345
376
|
: this.apiClient.conversation.api.postOTRProtobufMessage(
|
|
346
377
|
sendingClientId,
|
|
347
378
|
options.conversationId,
|
|
348
379
|
protoMessage,
|
|
349
|
-
|
|
380
|
+
ignoreMissing,
|
|
350
381
|
);
|
|
351
382
|
}
|
|
352
383
|
}
|