@wireapp/core 32.0.4 → 32.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/package.json +3 -3
  2. package/src/main/Account.js +1 -0
  3. package/src/main/conversation/ConversationMapper/ConversationMapper.js +1 -1
  4. package/src/main/conversation/ConversationService/ConversationService.d.ts +16 -7
  5. package/src/main/conversation/ConversationService/ConversationService.js +36 -45
  6. package/src/main/conversation/ConversationService/ConversationService.types.d.ts +5 -17
  7. package/src/main/conversation/message/CompositeContentBuilder.js +1 -1
  8. package/src/main/conversation/message/MessageBuilder.d.ts +21 -96
  9. package/src/main/conversation/message/MessageBuilder.js +238 -100
  10. package/src/main/conversation/message/MessageService.d.ts +1 -1
  11. package/src/main/conversation/message/MessageService.js +3 -3
  12. package/src/main/conversation/message/MessageToProtoMapper.d.ts +1 -1
  13. package/src/main/conversation/message/MessageToProtoMapper.js +1 -1
  14. package/src/main/conversation/message/TextContentBuilder.d.ts +10 -11
  15. package/src/main/conversation/message/TextContentBuilder.js +3 -5
  16. package/src/main/conversation/message/messageSender.d.ts +1 -0
  17. package/src/main/conversation/message/messageSender.js +5 -1
  18. package/src/main/index.d.ts +7 -17
  19. package/src/main/index.js +12 -16
  20. package/src/main/user/UserMapper.js +4 -4
  21. package/src/main/user/UserService.js +3 -1
  22. package/src/main/account/AccountService.js.map +0 -1
  23. package/src/main/account/AccountService.ts +0 -31
  24. package/src/main/account/index.js.map +0 -1
  25. package/src/main/account/index.ts +0 -20
  26. package/src/main/conversation/ConversationService/messageGenerator.d.ts +0 -9
  27. package/src/main/conversation/ConversationService/messageGenerator.js +0 -313
package/package.json CHANGED
@@ -65,7 +65,7 @@
65
65
  "!src/main/**/*test*.ts"
66
66
  ],
67
67
  "license": "GPL-3.0",
68
- "main": "src/main/Account",
68
+ "main": "src/main/index",
69
69
  "name": "@wireapp/core",
70
70
  "repository": "https://github.com/wireapp/wire-web-packages/tree/main/packages/core",
71
71
  "scripts": {
@@ -81,6 +81,6 @@
81
81
  "test": "jest",
82
82
  "watch": "tsc ---watch"
83
83
  },
84
- "version": "32.0.4",
85
- "gitHead": "98e4487ae72c0bfd8a3633bad937723b05d155c8"
84
+ "version": "32.0.5",
85
+ "gitHead": "03b66bf602b6fd57eeca4725e1a0a9218332d78d"
86
86
  }
@@ -442,6 +442,7 @@ class Account extends events_1.EventEmitter {
442
442
  this.apiClient.transport.ws.unlock();
443
443
  // We need to wait for the notification stream to be fully handled before releasing the message sending queue.
444
444
  // This is due to the nature of how message are encrypted, any change in mls epoch needs to happen before we start encrypting any kind of messages
445
+ this.logger.log(`resume message sending. ${(0, messageSender_1.getQueueLength)()} messages to be sent`);
445
446
  (0, messageSender_1.resumeMessageSending)();
446
447
  onConnectionStateChanged(ConnectionState.LIVE);
447
448
  };
@@ -30,7 +30,7 @@ class ConversationMapper {
30
30
  qualifiedConversation: event.qualified_conversation,
31
31
  qualifiedFrom: event.qualified_from,
32
32
  from: event.from,
33
- id: MessageBuilder_1.MessageBuilder.createId(),
33
+ id: (0, MessageBuilder_1.createId)(),
34
34
  messageTimer: 0,
35
35
  source,
36
36
  state: PayloadBundle_1.PayloadBundleState.INCOMING,
@@ -2,14 +2,22 @@ import { APIClient } from '@wireapp/api-client';
2
2
  import { MessageSendingStatus, Conversation, DefaultConversationRoleName, MutedStatus, NewConversation, QualifiedUserClients, UserClients, ClientMismatch } from '@wireapp/api-client/src/conversation';
3
3
  import { ConversationMemberLeaveEvent } from '@wireapp/api-client/src/event';
4
4
  import { QualifiedId, UserPreKeyBundleMap } from '@wireapp/api-client/src/user';
5
- import { MessageTimer, RemoveUsersParams } from '../../conversation/';
5
+ import { MessageTimer, PayloadBundleState, RemoveUsersParams } from '../../conversation/';
6
6
  import { RemoteData } from '../content';
7
7
  import { CryptographyService } from '../../cryptography/';
8
8
  import { MLSService } from '../../mls';
9
9
  import { NotificationService } from '../../notification';
10
- import { ClearConversationMessage, OtrMessage } from '../message/OtrMessage';
10
+ import { ClearConversationMessage } from '../message/OtrMessage';
11
11
  import { XOR } from '@wireapp/commons/src/main/util/TypeUtil';
12
12
  import { AddUsersParams, MessageSendingOptions, MLSReturnType, SendMlsMessageParams, SendProteusMessageParams } from './ConversationService.types';
13
+ declare type SendResult = {
14
+ /** The id of the message sent */
15
+ id: string;
16
+ /** the ISO formatted date at which the message was received by the backend */
17
+ sentAt: string;
18
+ /** The sending state of the payload (has the payload been succesfully sent or canceled) */
19
+ state: PayloadBundleState;
20
+ };
13
21
  export declare class ConversationService {
14
22
  private readonly apiClient;
15
23
  private readonly config;
@@ -31,7 +39,7 @@ export declare class ConversationService {
31
39
  * @returns {Promise<QualifiedUserPreKeyBundleMap}
32
40
  */
33
41
  private getQualifiedPreKeyBundle;
34
- getPreKeyBundleMap(conversationId: string, userIds?: string[] | UserClients): Promise<UserPreKeyBundleMap>;
42
+ getPreKeyBundleMap(conversationId: QualifiedId, userIds?: string[] | UserClients): Promise<UserPreKeyBundleMap>;
35
43
  private getSelfConversationId;
36
44
  private getQualifiedRecipientsForConversation;
37
45
  private getRecipientsForConversation;
@@ -56,7 +64,7 @@ export declare class ConversationService {
56
64
  * @param sendingOptions?
57
65
  * @return Resolves when the message has been sent
58
66
  */
59
- sendLastRead(conversationId: string, lastReadTimestamp: number, sendingOptions?: MessageSendingOptions): Promise<(MessageSendingStatus & {
67
+ sendLastRead(conversationId: QualifiedId, lastReadTimestamp: number, sendingOptions?: MessageSendingOptions): Promise<(MessageSendingStatus & {
60
68
  errored?: boolean | undefined;
61
69
  }) | (ClientMismatch & {
62
70
  errored?: boolean | undefined;
@@ -83,7 +91,7 @@ export declare class ConversationService {
83
91
  * @param {string} conversationId
84
92
  * @param {string} conversationDomain? - If given will send the message to the new qualified endpoint
85
93
  */
86
- getAllParticipantsClients(conversationId: string, conversationDomain?: string): Promise<UserClients | QualifiedUserClients>;
94
+ getAllParticipantsClients(conversationId: QualifiedId): Promise<UserClients | QualifiedUserClients>;
87
95
  /**
88
96
  * Get a fresh list from backend of clients for all the participants of the conversation.
89
97
  * @fixme there are some case where this method is not enough to detect removed devices
@@ -118,9 +126,9 @@ export declare class ConversationService {
118
126
  private sendProteusMessage;
119
127
  /**
120
128
  * Sends a message to a conversation
121
- * @return resolves with the sent message
129
+ * @return resolves with the sending status
122
130
  */
123
- send<T extends OtrMessage>(params: XOR<SendMlsMessageParams<T>, SendProteusMessageParams<T>>): Promise<T>;
131
+ send(params: XOR<SendMlsMessageParams, SendProteusMessageParams>): Promise<SendResult>;
124
132
  sendTypingStart(conversationId: string): Promise<void>;
125
133
  sendTypingStop(conversationId: string): Promise<void>;
126
134
  setConversationMutedStatus(conversationId: string, status: MutedStatus, muteTimestamp: number | Date): Promise<void>;
@@ -147,3 +155,4 @@ export declare class ConversationService {
147
155
  isMLSConversationEstablished(conversationGroupId: string): Promise<boolean>;
148
156
  wipeMLSConversation(conversationId: Uint8Array): Promise<void>;
149
157
  }
158
+ export {};
@@ -33,7 +33,6 @@ const bazinga64_1 = require("bazinga64");
33
33
  const fullyQualifiedClientIdUtils_1 = require("../../util/fullyQualifiedClientIdUtils");
34
34
  const mls_1 = require("../../mls");
35
35
  const messageSender_1 = require("../message/messageSender");
36
- const messageGenerator_1 = require("./messageGenerator");
37
36
  class ConversationService {
38
37
  constructor(apiClient, cryptographyService, config, notificationService, mlsService) {
39
38
  this.apiClient = apiClient;
@@ -155,16 +154,16 @@ class ConversationService {
155
154
  * @param genericMessage The payload of the message to send
156
155
  * @return Resolves with the message sending status from backend
157
156
  */
158
- async sendGenericMessage(sendingClientId, conversationId, genericMessage, { conversationDomain, userIds, nativePush, sendAsProtobuf, onClientMismatch, targetMode = ConversationService_types_1.MessageTargetMode.NONE, } = {}) {
157
+ async sendGenericMessage(conversationId, sendingClientId, genericMessage, { userIds, nativePush, sendAsProtobuf, onClientMismatch, targetMode = ConversationService_types_1.MessageTargetMode.NONE, } = {}) {
159
158
  const plainText = protocol_messaging_1.GenericMessage.encode(genericMessage).finish();
160
159
  if (targetMode !== ConversationService_types_1.MessageTargetMode.NONE && !userIds) {
161
160
  throw new Error('Cannot send targetted message when no userIds are given');
162
161
  }
163
- if (conversationDomain && this.config.useQualifiedIds) {
162
+ if (conversationId.domain && this.config.useQualifiedIds) {
164
163
  if ((0, TypePredicateUtil_1.isStringArray)(userIds) || (0, TypePredicateUtil_1.isUserClients)(userIds)) {
165
164
  throw new Error('Invalid userIds option for sending to federated backend');
166
165
  }
167
- const recipients = await this.getQualifiedRecipientsForConversation({ id: conversationId, domain: conversationDomain }, userIds);
166
+ const recipients = await this.getQualifiedRecipientsForConversation(conversationId, userIds);
168
167
  let reportMissing;
169
168
  if (targetMode === ConversationService_types_1.MessageTargetMode.NONE) {
170
169
  reportMissing = (0, TypePredicateUtil_1.isQualifiedUserClients)(userIds); // we want to check mismatch in case the consumer gave an exact list of users/devices
@@ -177,7 +176,7 @@ class ConversationService {
177
176
  reportMissing = false;
178
177
  }
179
178
  return this.messageService.sendFederatedMessage(sendingClientId, recipients, plainText, {
180
- conversationId: { id: conversationId, domain: conversationDomain },
179
+ conversationId,
181
180
  nativePush,
182
181
  reportMissing,
183
182
  onClientMismatch: mismatch => onClientMismatch === null || onClientMismatch === void 0 ? void 0 : onClientMismatch(mismatch, false),
@@ -220,7 +219,7 @@ class ConversationService {
220
219
  }
221
220
  return userIds;
222
221
  }
223
- async clearConversation(conversationId, timestamp = new Date(), messageId = MessageBuilder_1.MessageBuilder.createId(), sendAsProtobuf) {
222
+ async clearConversation(conversationId, timestamp = new Date(), messageId = (0, MessageBuilder_1.createId)(), sendAsProtobuf) {
224
223
  if (timestamp instanceof Date) {
225
224
  timestamp = timestamp.getTime();
226
225
  }
@@ -233,9 +232,8 @@ class ConversationService {
233
232
  [conversation_2.GenericMessageType.CLEARED]: clearedMessage,
234
233
  messageId,
235
234
  });
236
- const { id: selfConversationId, domain } = await this.getSelfConversationId();
237
- await this.sendGenericMessage(this.apiClient.validatedClientId, selfConversationId, genericMessage, {
238
- conversationDomain: domain,
235
+ const selfConversationId = await this.getSelfConversationId();
236
+ await this.sendGenericMessage(selfConversationId, this.apiClient.validatedClientId, genericMessage, {
239
237
  sendAsProtobuf,
240
238
  });
241
239
  return {
@@ -261,15 +259,15 @@ class ConversationService {
261
259
  */
262
260
  async sendLastRead(conversationId, lastReadTimestamp, sendingOptions) {
263
261
  const lastRead = new protocol_messaging_1.LastRead({
264
- conversationId,
262
+ conversationId: conversationId.id,
265
263
  lastReadTimestamp,
266
264
  });
267
265
  const genericMessage = protocol_messaging_1.GenericMessage.create({
268
266
  [conversation_2.GenericMessageType.LAST_READ]: lastRead,
269
- messageId: MessageBuilder_1.MessageBuilder.createId(),
267
+ messageId: (0, MessageBuilder_1.createId)(),
270
268
  });
271
- const { id: selfConversationId, domain: selfConversationDomain } = await this.getSelfConversationId();
272
- return this.sendGenericMessage(this.apiClient.validatedClientId, selfConversationId, genericMessage, Object.assign({ conversationDomain: selfConversationDomain }, sendingOptions));
269
+ const selfConversationId = await this.getSelfConversationId();
270
+ return this.sendGenericMessage(selfConversationId, this.apiClient.validatedClientId, genericMessage, Object.assign({}, sendingOptions));
273
271
  }
274
272
  /**
275
273
  * Syncs all self user's devices with the countly id
@@ -279,7 +277,6 @@ class ConversationService {
279
277
  * @return Resolves when the message has been sent
280
278
  */
281
279
  async sendCountlySync(countlyId, sendingOptions) {
282
- const { id: selfConversationId, domain: selfConversationDomain } = await this.getSelfConversationId();
283
280
  const dataTransfer = new protocol_messaging_1.DataTransfer({
284
281
  trackingIdentifier: {
285
282
  identifier: countlyId,
@@ -287,9 +284,10 @@ class ConversationService {
287
284
  });
288
285
  const genericMessage = new protocol_messaging_1.GenericMessage({
289
286
  [conversation_2.GenericMessageType.DATA_TRANSFER]: dataTransfer,
290
- messageId: MessageBuilder_1.MessageBuilder.createId(),
287
+ messageId: (0, MessageBuilder_1.createId)(),
291
288
  });
292
- return this.sendGenericMessage(this.apiClient.validatedClientId, selfConversationId, genericMessage, Object.assign({ conversationDomain: selfConversationDomain }, sendingOptions));
289
+ const selfConversationId = await this.getSelfConversationId();
290
+ return this.sendGenericMessage(selfConversationId, this.apiClient.validatedClientId, genericMessage, Object.assign({}, sendingOptions));
293
291
  }
294
292
  /**
295
293
  * Get a fresh list from backend of clients for all the participants of the conversation.
@@ -301,7 +299,7 @@ class ConversationService {
301
299
  * @param {string} conversationId
302
300
  * @param {string} conversationDomain? - If given will send the message to the new qualified endpoint
303
301
  */
304
- getAllParticipantsClients(conversationId, conversationDomain) {
302
+ getAllParticipantsClients(conversationId) {
305
303
  const sendingClientId = this.apiClient.validatedClientId;
306
304
  const recipients = {};
307
305
  const text = new Uint8Array();
@@ -311,9 +309,9 @@ class ConversationService {
311
309
  // When the mismatch happens, we ask the messageService to cancel the sending
312
310
  return false;
313
311
  };
314
- if (conversationDomain && this.config.useQualifiedIds) {
312
+ if (conversationId.domain && this.config.useQualifiedIds) {
315
313
  await this.messageService.sendFederatedMessage(sendingClientId, recipients, text, {
316
- conversationId: { id: conversationId, domain: conversationDomain },
314
+ conversationId,
317
315
  onClientMismatch,
318
316
  reportMissing: true,
319
317
  });
@@ -385,13 +383,10 @@ class ConversationService {
385
383
  async removeUserFromConversation(conversationId, userId) {
386
384
  return this.apiClient.api.conversation.deleteMember(conversationId, userId);
387
385
  }
388
- async sendProteusMessage(params, genericMessage, content) {
389
- var _a;
390
- const { userIds, sendAsProtobuf, conversationDomain, nativePush, targetMode, payload, onClientMismatch, onSuccess } = params;
391
- const response = await this.sendGenericMessage(this.apiClient.validatedClientId, payload.conversation, genericMessage, {
386
+ async sendProteusMessage({ userIds, sendAsProtobuf, conversationId, nativePush, targetMode, payload, onClientMismatch, }) {
387
+ const response = await this.sendGenericMessage(conversationId, this.apiClient.validatedClientId, payload, {
392
388
  userIds,
393
389
  sendAsProtobuf,
394
- conversationDomain,
395
390
  nativePush,
396
391
  targetMode,
397
392
  onClientMismatch,
@@ -401,27 +396,22 @@ class ConversationService {
401
396
  // We warn the consumer that there is a mismatch that did not prevent message sending
402
397
  await (onClientMismatch === null || onClientMismatch === void 0 ? void 0 : onClientMismatch(response, true));
403
398
  }
404
- onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(genericMessage, response.time);
405
399
  }
406
- return Object.assign(Object.assign({}, payload), { content, messageTimer: ((_a = genericMessage.ephemeral) === null || _a === void 0 ? void 0 : _a.expireAfterMillis) || 0, state: response.errored ? conversation_2.PayloadBundleState.CANCELLED : conversation_2.PayloadBundleState.OUTGOING_SENT });
400
+ return {
401
+ id: payload.messageId,
402
+ sentAt: response.time,
403
+ state: response.errored ? conversation_2.PayloadBundleState.CANCELLED : conversation_2.PayloadBundleState.OUTGOING_SENT,
404
+ };
407
405
  }
408
406
  /**
409
407
  * Sends a message to a conversation
410
- * @return resolves with the sent message
408
+ * @return resolves with the sending status
411
409
  */
412
410
  async send(params) {
413
411
  function isMLS(params) {
414
412
  return params.protocol === conversation_1.ConversationProtocol.MLS;
415
413
  }
416
- const { payload, onStart } = params;
417
- const { genericMessage, content } = (0, messageGenerator_1.generateGenericMessage)(payload, this.messageTimer);
418
- if ((await (onStart === null || onStart === void 0 ? void 0 : onStart(genericMessage))) === false) {
419
- // If the onStart call returns false, it means the consumer wants to cancel the message sending
420
- return Object.assign(Object.assign({}, payload), { state: conversation_2.PayloadBundleState.CANCELLED });
421
- }
422
- return (0, messageSender_1.sendMessage)(() => isMLS(params)
423
- ? this.sendMLSMessage(params, genericMessage, content)
424
- : this.sendProteusMessage(params, genericMessage, content));
414
+ return (0, messageSender_1.sendMessage)(() => (isMLS(params) ? this.sendMLSMessage(params) : this.sendProteusMessage(params)));
425
415
  }
426
416
  sendTypingStart(conversationId) {
427
417
  return this.apiClient.api.conversation.postTyping(conversationId, { status: data_1.CONVERSATION_TYPING.STARTED });
@@ -518,21 +508,22 @@ class ConversationService {
518
508
  conversation,
519
509
  };
520
510
  }
521
- async sendMLSMessage(params, genericMessage, content) {
522
- var _a, _b;
523
- const { groupId, onSuccess, payload } = params;
511
+ async sendMLSMessage({ payload, groupId }) {
524
512
  const groupIdBytes = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
525
513
  // immediately execute pending commits before sending the message
526
514
  await this.notificationService.commitPendingProposals({ groupId });
527
- const encrypted = await this.mlsService.encryptMessage(groupIdBytes, protocol_messaging_1.GenericMessage.encode(genericMessage).finish());
515
+ const encrypted = await this.mlsService.encryptMessage(groupIdBytes, protocol_messaging_1.GenericMessage.encode(payload).finish());
516
+ let sentAt = '';
528
517
  try {
529
518
  const { time = '' } = await this.apiClient.api.conversation.postMlsMessage(encrypted);
530
- onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(genericMessage, (time === null || time === void 0 ? void 0 : time.length) > 0 ? time : new Date().toISOString());
531
- return Object.assign(Object.assign({}, payload), { content, messageTimer: ((_a = genericMessage.ephemeral) === null || _a === void 0 ? void 0 : _a.expireAfterMillis) || 0, state: conversation_2.PayloadBundleState.OUTGOING_SENT });
532
- }
533
- catch (_c) {
534
- return Object.assign(Object.assign({}, payload), { content, messageTimer: ((_b = genericMessage.ephemeral) === null || _b === void 0 ? void 0 : _b.expireAfterMillis) || 0, state: conversation_2.PayloadBundleState.CANCELLED });
519
+ sentAt = (time === null || time === void 0 ? void 0 : time.length) > 0 ? time : new Date().toISOString();
535
520
  }
521
+ catch (_a) { }
522
+ return {
523
+ id: payload.messageId,
524
+ sentAt,
525
+ state: sentAt ? conversation_2.PayloadBundleState.OUTGOING_SENT : conversation_2.PayloadBundleState.CANCELLED,
526
+ };
536
527
  }
537
528
  async addUsersToMLSConversation({ qualifiedUserIds, groupId, conversationId, }) {
538
529
  const groupIdDecodedFromBase64 = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
@@ -8,10 +8,6 @@ export declare enum MessageTargetMode {
8
8
  USERS_CLIENTS = 2
9
9
  }
10
10
  export interface MessageSendingOptions {
11
- /**
12
- * The federated domain the server runs on. Should only be set for federation enabled envs
13
- */
14
- conversationDomain?: string;
15
11
  /**
16
12
  * can be either a QualifiedId[] or QualfiedUserClients or undefined. The type has some effect on the behavior of the method.
17
13
  * When given undefined the method will fetch both the members of the conversations and their devices. No ClientMismatch can happen in that case
@@ -37,13 +33,6 @@ export interface MessageSendingOptions {
37
33
  targetMode?: MessageTargetMode;
38
34
  }
39
35
  export interface MessageSendingCallbacks {
40
- /**
41
- * Will be called before a message is actually sent. Returning 'false' will prevent the message from being sent
42
- * @param message The message being sent
43
- * @return true or undefined if the message should be sent, false if the message sending should be cancelled
44
- */
45
- onStart?: (message: GenericMessage) => void | boolean | Promise<boolean>;
46
- onSuccess?: (message: GenericMessage, sentTime?: string) => void;
47
36
  /**
48
37
  * Called whenever there is a clientmismatch returned from the server. Will also indicate the sending status of the message (if it was already sent or not)
49
38
  *
@@ -67,12 +56,11 @@ export declare type ProtocolParam = {
67
56
  /**
68
57
  * The message to send to the conversation
69
58
  */
70
- export declare type SendCommonParams<T> = ProtocolParam & {
71
- payload: T;
72
- onStart?: (message: GenericMessage) => void | boolean | Promise<boolean>;
73
- onSuccess?: (message: GenericMessage, sentTime?: string) => void;
59
+ export declare type SendCommonParams = ProtocolParam & {
60
+ payload: GenericMessage;
74
61
  };
75
- export declare type SendProteusMessageParams<T> = SendCommonParams<T> & MessageSendingOptions & {
62
+ export declare type SendProteusMessageParams = SendCommonParams & MessageSendingOptions & {
63
+ conversationId: QualifiedId;
76
64
  /**
77
65
  * Can be either a QualifiedId[], string[], UserClients or QualfiedUserClients. The type has some effect on the behavior of the method. (Needed only for Proteus)
78
66
  * When given a QualifiedId[] or string[] 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
@@ -84,7 +72,7 @@ export declare type SendProteusMessageParams<T> = SendCommonParams<T> & MessageS
84
72
  onClientMismatch?: (status: ClientMismatch | MessageSendingStatus, wasSent: boolean) => void | boolean | Promise<boolean>;
85
73
  protocol: ConversationProtocol.PROTEUS;
86
74
  };
87
- export declare type SendMlsMessageParams<T> = SendCommonParams<T> & {
75
+ export declare type SendMlsMessageParams = SendCommonParams & {
88
76
  /**
89
77
  * The groupId of the conversation to send the message to (Needed only for MLS)
90
78
  */
@@ -45,7 +45,7 @@ class CompositeContentBuilder {
45
45
  this.items.push(protocol_messaging_1.Composite.Item.create({ text }));
46
46
  return this;
47
47
  }
48
- addButton(buttonText, id = MessageBuilder_1.MessageBuilder.createId()) {
48
+ addButton(buttonText, id = (0, MessageBuilder_1.createId)()) {
49
49
  this.items.push(protocol_messaging_1.Composite.Item.create({ button: protocol_messaging_1.Button.create({ id, text: buttonText }) }));
50
50
  return this;
51
51
  }
@@ -1,96 +1,21 @@
1
- import { Confirmation } from '@wireapp/protocol-messaging';
2
- import { AbortReason } from '..';
3
- import { EncryptedAssetUploaded } from '../../cryptography';
4
- import { ButtonActionConfirmationContent, ButtonActionContent, CallingContent, FileContent, FileMetaDataContent, ImageContent, KnockContent, LegalHoldStatus, LocationContent, ReactionContent } from '../content';
5
- import { CompositeContentBuilder } from './CompositeContentBuilder';
6
- import { ButtonActionConfirmationMessage, ButtonActionMessage, CallMessage, ConfirmationMessage, DeleteMessage, FileAssetAbortMessage, FileAssetMessage, FileAssetMetaDataMessage, HideMessage, ImageAssetMessageOutgoing, LocationMessage, PingMessage, ReactionMessage, ResetSessionMessage } from './OtrMessage';
7
- import { TextContentBuilder } from './TextContentBuilder';
8
- interface BaseOptions {
9
- conversationId: string;
10
- from: string;
11
- messageId?: string;
12
- }
13
- interface CreateMessageDeleteOption extends BaseOptions {
14
- messageIdToDelete: string;
15
- }
16
- interface CreateMessageHideOption extends BaseOptions {
17
- messageIdToDelete: string;
18
- targetConversation: string;
19
- }
20
- interface CreateImageOptions extends BaseOptions {
21
- expectsReadConfirmation?: boolean;
22
- asset: EncryptedAssetUploaded;
23
- image: ImageContent;
24
- legalHoldStatus?: LegalHoldStatus;
25
- }
26
- interface CreateFileOptions extends BaseOptions {
27
- expectsReadConfirmation?: boolean;
28
- asset: EncryptedAssetUploaded;
29
- file: FileContent;
30
- legalHoldStatus?: LegalHoldStatus;
31
- originalMessageId: string;
32
- }
33
- interface CreateEditedTextOptions extends BaseOptions {
34
- newMessageText: string;
35
- originalMessageId: string;
36
- }
37
- interface CreateFileMetadataOptions extends BaseOptions {
38
- expectsReadConfirmation?: boolean;
39
- legalHoldStatus?: LegalHoldStatus;
40
- metaData: FileMetaDataContent;
41
- }
42
- interface CreateFileAbortOptions {
43
- conversationId: string;
44
- expectsReadConfirmation?: boolean;
45
- from: string;
46
- legalHoldStatus?: LegalHoldStatus;
47
- originalMessageId: string;
48
- reason: AbortReason;
49
- }
50
- interface CreateLocationOptions extends BaseOptions {
51
- location: LocationContent;
52
- }
53
- interface CreateCallOptions extends BaseOptions {
54
- content: CallingContent;
55
- }
56
- interface CreateReactionOptions extends BaseOptions {
57
- reaction: ReactionContent;
58
- }
59
- interface CreateTextOptions extends BaseOptions {
60
- text: string;
61
- }
62
- interface CreateConfirmationOptions extends BaseOptions {
63
- firstMessageId: string;
64
- moreMessageIds?: string[];
65
- type: Confirmation.Type;
66
- }
67
- interface CreatePingOptions extends BaseOptions {
68
- ping?: KnockContent;
69
- }
70
- interface CreateButtonActionConfirmationOptions extends BaseOptions {
71
- content: ButtonActionConfirmationContent;
72
- }
73
- interface CreateActionMessageOptions extends BaseOptions {
74
- content: ButtonActionContent;
75
- }
76
- export declare class MessageBuilder {
77
- static createEditedText(payload: CreateEditedTextOptions): TextContentBuilder;
78
- static createFileData(payload: CreateFileOptions): FileAssetMessage;
79
- static createMessageDelete(payload: CreateMessageDeleteOption): DeleteMessage;
80
- static createMessageHide(payload: CreateMessageHideOption): HideMessage;
81
- static createFileMetadata(payload: CreateFileMetadataOptions): FileAssetMetaDataMessage;
82
- static createFileAbort(payload: CreateFileAbortOptions): FileAssetAbortMessage;
83
- static createImage(payload: CreateImageOptions): ImageAssetMessageOutgoing;
84
- static createLocation(payload: CreateLocationOptions): LocationMessage;
85
- static createCall(payload: CreateCallOptions): CallMessage;
86
- static createReaction(payload: CreateReactionOptions): ReactionMessage;
87
- static createText(payload: CreateTextOptions): TextContentBuilder;
88
- static createConfirmation(payload: CreateConfirmationOptions): ConfirmationMessage;
89
- static createButtonActionMessage(payload: CreateActionMessageOptions): ButtonActionMessage;
90
- static createButtonActionConfirmationMessage(payload: CreateButtonActionConfirmationOptions): ButtonActionConfirmationMessage;
91
- static createComposite(payload: BaseOptions): CompositeContentBuilder;
92
- static createPing(payload: CreatePingOptions): PingMessage;
93
- static createSessionReset(payload: BaseOptions): ResetSessionMessage;
94
- static createId(): string;
95
- }
96
- export {};
1
+ import { ButtonActionConfirmationMessage, ButtonActionMessage, CallMessage, ConfirmationMessage, DeleteMessage, EditedTextMessage, FileAssetAbortMessage, FileAssetMessage, FileAssetMetaDataMessage, HideMessage, ImageAssetMessageOutgoing, LocationMessage, PingMessage, ReactionMessage, TextMessage } from './OtrMessage';
2
+ import { IComposite, GenericMessage } from '@wireapp/protocol-messaging';
3
+ export declare function createId(): string;
4
+ export declare function buildButtonActionMessage(payloadBundle: ButtonActionMessage['content']): GenericMessage;
5
+ export declare function buildButtonActionConfirmationMessage(payloadBundle: ButtonActionConfirmationMessage['content']): GenericMessage;
6
+ export declare function buildCompositeMessage(payload: IComposite): GenericMessage;
7
+ export declare function buildConfirmationMessage(payloadBundle: ConfirmationMessage['content']): GenericMessage;
8
+ export declare function buildEditedTextMessage(payloadBundle: EditedTextMessage['content'], messageId?: string): GenericMessage;
9
+ export declare function buildFileDataMessage(payloadBundle: FileAssetMessage['content'], messageId?: string): GenericMessage;
10
+ export declare function buildFileMetaDataMessage(payloadBundle: FileAssetMetaDataMessage['content']): GenericMessage;
11
+ export declare function buildFileAbortMessage(payloadBundle: FileAssetAbortMessage['content'], messageId?: string): GenericMessage;
12
+ export declare function buildImageMessage(payloadBundle: ImageAssetMessageOutgoing['content'], messageId?: string): GenericMessage;
13
+ export declare function buildLocationMessage(payloadBundle: LocationMessage['content']): GenericMessage;
14
+ export declare function buildPingMessage(payloadBundle: PingMessage['content']): GenericMessage;
15
+ export declare function buildReactionMessage(payloadBundle: ReactionMessage['content']): GenericMessage;
16
+ export declare function buildSessionResetMessage(): GenericMessage;
17
+ export declare function buildCallMessage(payloadBundle: CallMessage['content']): GenericMessage;
18
+ export declare function buildDeleteMessage(payload: DeleteMessage['content']): GenericMessage;
19
+ export declare function buildHideMessage(payload: HideMessage['content']): GenericMessage;
20
+ export declare function buildTextMessage(payloadBundle: TextMessage['content'], messageId?: string): GenericMessage;
21
+ export declare function wrapInEphemeral(originalGenericMessage: GenericMessage, expireAfterMillis: number): GenericMessage;