@wireapp/core 31.1.3 → 31.2.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.
Files changed (227) hide show
  1. package/package.json +10 -9
  2. package/src/main/Account.d.ts +214 -0
  3. package/src/main/Account.js +463 -0
  4. package/src/main/CoreError.d.ts +9 -0
  5. package/src/main/CoreError.js +26 -0
  6. package/src/main/account/AccountService.d.ts +7 -0
  7. package/src/main/account/AccountService.js +33 -0
  8. package/src/main/account/AccountService.js.map +1 -0
  9. package/src/main/account/index.d.ts +1 -0
  10. package/src/main/account/index.js +36 -0
  11. package/src/main/account/index.js.map +1 -0
  12. package/src/main/auth/LoginSanitizer.d.ts +5 -0
  13. package/src/main/auth/LoginSanitizer.js +41 -0
  14. package/src/main/auth/index.d.ts +1 -0
  15. package/src/main/auth/index.js +36 -0
  16. package/src/main/broadcast/AvailabilityType.d.ts +2 -0
  17. package/src/main/broadcast/AvailabilityType.js +21 -0
  18. package/src/main/broadcast/BroadcastService.d.ts +24 -0
  19. package/src/main/broadcast/BroadcastService.js +74 -0
  20. package/src/main/broadcast/index.d.ts +2 -0
  21. package/src/main/broadcast/index.js +37 -0
  22. package/src/main/client/ClientBackendRepository.d.ts +11 -0
  23. package/src/main/client/ClientBackendRepository.js +43 -0
  24. package/src/main/client/ClientDatabaseRepository.d.ts +27 -0
  25. package/src/main/client/ClientDatabaseRepository.js +85 -0
  26. package/src/main/client/ClientInfo.d.ts +8 -0
  27. package/src/main/client/ClientInfo.js +21 -0
  28. package/src/main/client/ClientService.d.ts +40 -0
  29. package/src/main/client/ClientService.js +103 -0
  30. package/src/main/client/index.d.ts +4 -0
  31. package/src/main/client/index.js +39 -0
  32. package/src/main/connection/ConnectionService.d.ts +11 -0
  33. package/src/main/connection/ConnectionService.js +45 -0
  34. package/src/main/connection/index.d.ts +1 -0
  35. package/src/main/connection/index.js +36 -0
  36. package/src/main/conversation/AbortReason.d.ts +2 -0
  37. package/src/main/conversation/AbortReason.js +21 -0
  38. package/src/main/conversation/AssetService/AssetService.d.ts +62 -0
  39. package/src/main/conversation/AssetService/AssetService.js +88 -0
  40. package/src/main/conversation/AssetService/index.d.ts +1 -0
  41. package/src/main/conversation/AssetService/index.js +36 -0
  42. package/src/main/conversation/AssetTransferState.d.ts +4 -0
  43. package/src/main/conversation/AssetTransferState.js +27 -0
  44. package/src/main/conversation/ClientActionType.d.ts +1 -0
  45. package/src/main/conversation/ClientActionType.js +24 -0
  46. package/src/main/conversation/ConversationMapper/ConversationMapper.d.ts +6 -0
  47. package/src/main/conversation/ConversationMapper/ConversationMapper.js +57 -0
  48. package/src/main/conversation/ConversationMapper/index.d.ts +1 -0
  49. package/src/main/conversation/ConversationMapper/index.js +36 -0
  50. package/src/main/conversation/ConversationService/ConversationService.d.ts +149 -0
  51. package/src/main/conversation/ConversationService/ConversationService.js +584 -0
  52. package/src/main/conversation/ConversationService/ConversationService.types.d.ts +110 -0
  53. package/src/main/conversation/ConversationService/ConversationService.types.js +28 -0
  54. package/src/main/conversation/ConversationService/index.d.ts +2 -0
  55. package/src/main/conversation/ConversationService/index.js +37 -0
  56. package/src/main/conversation/ConversationService/messageGenerator.d.ts +9 -0
  57. package/src/main/conversation/ConversationService/messageGenerator.js +313 -0
  58. package/src/main/conversation/GenericMessageType.d.ts +25 -0
  59. package/src/main/conversation/GenericMessageType.js +49 -0
  60. package/src/main/conversation/MessageTimer/MessageTimer.d.ts +10 -0
  61. package/src/main/conversation/MessageTimer/MessageTimer.js +54 -0
  62. package/src/main/conversation/MessageTimer/index.d.ts +1 -0
  63. package/src/main/conversation/MessageTimer/index.js +36 -0
  64. package/src/main/conversation/ReactionType.d.ts +4 -0
  65. package/src/main/conversation/ReactionType.js +27 -0
  66. package/src/main/conversation/content/AssetContent.d.ts +42 -0
  67. package/src/main/conversation/content/AssetContent.js +21 -0
  68. package/src/main/conversation/content/ButtonActionConfirmationContent.d.ts +2 -0
  69. package/src/main/conversation/content/ButtonActionConfirmationContent.js +21 -0
  70. package/src/main/conversation/content/ButtonActionContent.d.ts +2 -0
  71. package/src/main/conversation/content/ButtonActionContent.js +21 -0
  72. package/src/main/conversation/content/CallingContent.d.ts +1 -0
  73. package/src/main/conversation/content/CallingContent.js +21 -0
  74. package/src/main/conversation/content/ClearedContent.d.ts +2 -0
  75. package/src/main/conversation/content/ClearedContent.js +21 -0
  76. package/src/main/conversation/content/ClientActionContent.d.ts +2 -0
  77. package/src/main/conversation/content/ClientActionContent.js +21 -0
  78. package/src/main/conversation/content/ClientAddContent.d.ts +4 -0
  79. package/src/main/conversation/content/ClientAddContent.js +21 -0
  80. package/src/main/conversation/content/ClientRemoveContent.d.ts +6 -0
  81. package/src/main/conversation/content/ClientRemoveContent.js +21 -0
  82. package/src/main/conversation/content/CompositeContent.d.ts +2 -0
  83. package/src/main/conversation/content/CompositeContent.js +21 -0
  84. package/src/main/conversation/content/ConfirmationContent.d.ts +2 -0
  85. package/src/main/conversation/content/ConfirmationContent.js +21 -0
  86. package/src/main/conversation/content/ContentType.d.ts +21 -0
  87. package/src/main/conversation/content/ContentType.js +94 -0
  88. package/src/main/conversation/content/ConversationContent.d.ts +3 -0
  89. package/src/main/conversation/content/ConversationContent.js +21 -0
  90. package/src/main/conversation/content/DeletedContent.d.ts +2 -0
  91. package/src/main/conversation/content/DeletedContent.js +21 -0
  92. package/src/main/conversation/content/EditedTextContent.d.ts +11 -0
  93. package/src/main/conversation/content/EditedTextContent.js +21 -0
  94. package/src/main/conversation/content/FileContent.d.ts +13 -0
  95. package/src/main/conversation/content/FileContent.js +21 -0
  96. package/src/main/conversation/content/HiddenContent.d.ts +2 -0
  97. package/src/main/conversation/content/HiddenContent.js +21 -0
  98. package/src/main/conversation/content/ImageContent.d.ts +7 -0
  99. package/src/main/conversation/content/ImageContent.js +21 -0
  100. package/src/main/conversation/content/KnockContent.d.ts +2 -0
  101. package/src/main/conversation/content/KnockContent.js +21 -0
  102. package/src/main/conversation/content/LinkPreviewContent.d.ts +10 -0
  103. package/src/main/conversation/content/LinkPreviewContent.js +21 -0
  104. package/src/main/conversation/content/LocationContent.d.ts +9 -0
  105. package/src/main/conversation/content/LocationContent.js +21 -0
  106. package/src/main/conversation/content/MentionContent.d.ts +2 -0
  107. package/src/main/conversation/content/MentionContent.js +21 -0
  108. package/src/main/conversation/content/QuoteContent.d.ts +7 -0
  109. package/src/main/conversation/content/QuoteContent.js +21 -0
  110. package/src/main/conversation/content/ReactionContent.d.ts +7 -0
  111. package/src/main/conversation/content/ReactionContent.js +21 -0
  112. package/src/main/conversation/content/TextContent.d.ts +9 -0
  113. package/src/main/conversation/content/TextContent.js +21 -0
  114. package/src/main/conversation/content/TweetContent.d.ts +2 -0
  115. package/src/main/conversation/content/TweetContent.js +21 -0
  116. package/src/main/conversation/content/index.d.ts +28 -0
  117. package/src/main/conversation/content/index.js +76 -0
  118. package/src/main/conversation/index.d.ts +9 -0
  119. package/src/main/conversation/index.js +44 -0
  120. package/src/main/conversation/message/CompositeContentBuilder.d.ts +14 -0
  121. package/src/main/conversation/message/CompositeContentBuilder.js +54 -0
  122. package/src/main/conversation/message/Message.d.ts +4 -0
  123. package/src/main/conversation/message/Message.js +21 -0
  124. package/src/main/conversation/message/MessageBuilder.d.ts +96 -0
  125. package/src/main/conversation/message/MessageBuilder.js +125 -0
  126. package/src/main/conversation/message/MessageService.d.ts +67 -0
  127. package/src/main/conversation/message/MessageService.js +293 -0
  128. package/src/main/conversation/message/MessageToProtoMapper.d.ts +7 -0
  129. package/src/main/conversation/message/MessageToProtoMapper.js +99 -0
  130. package/src/main/conversation/message/OtrMessage.d.ts +80 -0
  131. package/src/main/conversation/message/OtrMessage.js +21 -0
  132. package/src/main/conversation/message/PayloadBundle.d.ts +76 -0
  133. package/src/main/conversation/message/PayloadBundle.js +81 -0
  134. package/src/main/conversation/message/TeamMessage.d.ts +31 -0
  135. package/src/main/conversation/message/TeamMessage.js +21 -0
  136. package/src/main/conversation/message/TextContentBuilder.d.ts +13 -0
  137. package/src/main/conversation/message/TextContentBuilder.js +75 -0
  138. package/src/main/conversation/message/UserClientsUtil.d.ts +22 -0
  139. package/src/main/conversation/message/UserClientsUtil.js +38 -0
  140. package/src/main/conversation/message/UserMessage.d.ts +43 -0
  141. package/src/main/conversation/message/UserMessage.js +21 -0
  142. package/src/main/conversation/message/messageSender.d.ts +4 -0
  143. package/src/main/conversation/message/messageSender.js +36 -0
  144. package/src/main/cryptography/AssetCryptography/EncryptedAsset.d.ts +11 -0
  145. package/src/main/cryptography/AssetCryptography/EncryptedAsset.js +21 -0
  146. package/src/main/cryptography/AssetCryptography/crypto.browser.d.ts +2 -0
  147. package/src/main/cryptography/AssetCryptography/crypto.browser.js +46 -0
  148. package/src/main/cryptography/AssetCryptography/crypto.node.d.ts +2 -0
  149. package/src/main/cryptography/AssetCryptography/crypto.node.js +72 -0
  150. package/src/main/cryptography/AssetCryptography/index.d.ts +8 -0
  151. package/src/main/cryptography/AssetCryptography/index.js +53 -0
  152. package/src/main/cryptography/AssetCryptography/interfaces.d.ts +9 -0
  153. package/src/main/cryptography/AssetCryptography/interfaces.js +21 -0
  154. package/src/main/cryptography/CryptographyDatabaseRepository.d.ts +16 -0
  155. package/src/main/cryptography/CryptographyDatabaseRepository.js +44 -0
  156. package/src/main/cryptography/CryptographyService.d.ts +52 -0
  157. package/src/main/cryptography/CryptographyService.js +205 -0
  158. package/src/main/cryptography/GenericMessageMapper.d.ts +6 -0
  159. package/src/main/cryptography/GenericMessageMapper.js +160 -0
  160. package/src/main/cryptography/MessageHashService.d.ts +16 -0
  161. package/src/main/cryptography/MessageHashService.js +118 -0
  162. package/src/main/cryptography/SessionPayloadBundle.d.ts +4 -0
  163. package/src/main/cryptography/SessionPayloadBundle.js +21 -0
  164. package/src/main/cryptography/index.d.ts +4 -0
  165. package/src/main/cryptography/index.js +39 -0
  166. package/src/main/giphy/GiphyService.d.ts +9 -0
  167. package/src/main/giphy/GiphyService.js +37 -0
  168. package/src/main/giphy/index.d.ts +1 -0
  169. package/src/main/giphy/index.js +36 -0
  170. package/src/main/index.d.ts +17 -0
  171. package/src/main/index.js +59 -0
  172. package/src/main/linkPreview/LinkPreviewService.d.ts +7 -0
  173. package/src/main/linkPreview/LinkPreviewService.js +52 -0
  174. package/src/main/linkPreview/index.d.ts +1 -0
  175. package/src/main/linkPreview/index.js +36 -0
  176. package/src/main/mls/MLSService/MLSService.d.ts +39 -0
  177. package/src/main/mls/MLSService/MLSService.js +181 -0
  178. package/src/main/mls/index.d.ts +1 -0
  179. package/src/main/mls/index.js +36 -0
  180. package/src/main/mls/keyMaterialUpdatesStore/index.d.ts +1 -0
  181. package/src/main/mls/keyMaterialUpdatesStore/index.js +36 -0
  182. package/src/main/mls/keyMaterialUpdatesStore/keyMaterialUpdatesStore.d.ts +9 -0
  183. package/src/main/mls/keyMaterialUpdatesStore/keyMaterialUpdatesStore.js +51 -0
  184. package/src/main/mls/keyPackagesStatusStore/keyPackagesStatusStore.d.ts +7 -0
  185. package/src/main/mls/keyPackagesStatusStore/keyPackagesStatusStore.js +42 -0
  186. package/src/main/mls/types.d.ts +33 -0
  187. package/src/main/mls/types.js +21 -0
  188. package/src/main/notification/NotificationBackendRepository.d.ts +11 -0
  189. package/src/main/notification/NotificationBackendRepository.js +34 -0
  190. package/src/main/notification/NotificationDatabaseRepository.d.ts +42 -0
  191. package/src/main/notification/NotificationDatabaseRepository.js +97 -0
  192. package/src/main/notification/NotificationService.d.ts +129 -0
  193. package/src/main/notification/NotificationService.js +501 -0
  194. package/src/main/notification/index.d.ts +1 -0
  195. package/src/main/notification/index.js +36 -0
  196. package/src/main/notification/types.d.ts +16 -0
  197. package/src/main/notification/types.js +21 -0
  198. package/src/main/self/SelfService.d.ts +13 -0
  199. package/src/main/self/SelfService.js +55 -0
  200. package/src/main/self/index.d.ts +1 -0
  201. package/src/main/self/index.js +36 -0
  202. package/src/main/team/TeamService.d.ts +15 -0
  203. package/src/main/team/TeamService.js +55 -0
  204. package/src/main/team/index.d.ts +1 -0
  205. package/src/main/team/index.js +36 -0
  206. package/src/main/test/CryptographyHelper.d.ts +4 -0
  207. package/src/main/test/CryptographyHelper.js +69 -0
  208. package/src/main/test/PayloadHelper.d.ts +3 -0
  209. package/src/main/test/PayloadHelper.js +66 -0
  210. package/src/main/user/UserMapper.d.ts +5 -0
  211. package/src/main/user/UserMapper.js +88 -0
  212. package/src/main/user/UserService.d.ts +25 -0
  213. package/src/main/user/UserService.js +81 -0
  214. package/src/main/user/index.d.ts +1 -0
  215. package/src/main/user/index.js +36 -0
  216. package/src/main/util/LowPrecisionTaskScheduler/LowPrecisionTaskScheduler.d.ts +21 -0
  217. package/src/main/util/LowPrecisionTaskScheduler/LowPrecisionTaskScheduler.js +62 -0
  218. package/src/main/util/TaskScheduler/TaskScheduler.d.ts +10 -0
  219. package/src/main/util/TaskScheduler/TaskScheduler.js +70 -0
  220. package/src/main/util/TypePredicateUtil.d.ts +7 -0
  221. package/src/main/util/TypePredicateUtil.js +55 -0
  222. package/src/main/util/encryptedStore.d.ts +45 -0
  223. package/src/main/util/encryptedStore.js +116 -0
  224. package/src/main/util/fullyQualifiedClientIdUtils.d.ts +13 -0
  225. package/src/main/util/fullyQualifiedClientIdUtils.js +42 -0
  226. package/src/main/util/index.d.ts +1 -0
  227. package/src/main/util/index.js +36 -0
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ /*
3
+ * Wire
4
+ * Copyright (C) 2019 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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.MessageBuilder = void 0;
25
+ const protocol_messaging_1 = require("@wireapp/protocol-messaging");
26
+ const uuidjs_1 = __importDefault(require("uuidjs"));
27
+ const __1 = require("..");
28
+ const CompositeContentBuilder_1 = require("./CompositeContentBuilder");
29
+ const TextContentBuilder_1 = require("./TextContentBuilder");
30
+ function createCommonProperties(options) {
31
+ return {
32
+ id: options.messageId || MessageBuilder.createId(),
33
+ conversation: options.conversationId,
34
+ from: options.from,
35
+ source: __1.PayloadBundleSource.LOCAL,
36
+ state: __1.PayloadBundleState.OUTGOING_UNSENT,
37
+ timestamp: Date.now(),
38
+ };
39
+ }
40
+ class MessageBuilder {
41
+ static createEditedText(payload) {
42
+ return new TextContentBuilder_1.TextContentBuilder(Object.assign(Object.assign({}, createCommonProperties(payload)), { content: {
43
+ originalMessageId: payload.originalMessageId,
44
+ text: payload.newMessageText,
45
+ }, type: __1.PayloadBundleType.MESSAGE_EDIT }));
46
+ }
47
+ static createFileData(payload) {
48
+ const { asset, expectsReadConfirmation, file, legalHoldStatus, originalMessageId } = payload;
49
+ return Object.assign(Object.assign({}, createCommonProperties(payload)), { content: {
50
+ asset,
51
+ expectsReadConfirmation,
52
+ file,
53
+ legalHoldStatus,
54
+ }, id: originalMessageId, type: __1.PayloadBundleType.ASSET });
55
+ }
56
+ static createMessageDelete(payload) {
57
+ return Object.assign(Object.assign({}, createCommonProperties(payload)), { content: { messageId: payload.messageIdToDelete }, type: __1.PayloadBundleType.MESSAGE_DELETE });
58
+ }
59
+ static createMessageHide(payload) {
60
+ return Object.assign(Object.assign({}, createCommonProperties(payload)), { content: { messageId: payload.messageIdToDelete, conversationId: payload.targetConversation }, type: __1.PayloadBundleType.MESSAGE_HIDE });
61
+ }
62
+ static createFileMetadata(payload) {
63
+ const { expectsReadConfirmation, legalHoldStatus, metaData } = payload;
64
+ return Object.assign(Object.assign({}, createCommonProperties(payload)), { content: {
65
+ expectsReadConfirmation,
66
+ legalHoldStatus,
67
+ metaData,
68
+ }, type: __1.PayloadBundleType.ASSET_META });
69
+ }
70
+ static createFileAbort(payload) {
71
+ const { expectsReadConfirmation, legalHoldStatus, reason } = payload;
72
+ return Object.assign(Object.assign({}, createCommonProperties(payload)), { content: {
73
+ expectsReadConfirmation,
74
+ legalHoldStatus,
75
+ reason,
76
+ }, id: payload.originalMessageId, type: __1.PayloadBundleType.ASSET_ABORT });
77
+ }
78
+ static createImage(payload) {
79
+ const { expectsReadConfirmation, image, asset, legalHoldStatus } = payload;
80
+ return Object.assign(Object.assign({}, createCommonProperties(payload)), { content: {
81
+ expectsReadConfirmation,
82
+ image,
83
+ asset,
84
+ legalHoldStatus,
85
+ }, type: __1.PayloadBundleType.ASSET_IMAGE });
86
+ }
87
+ static createLocation(payload) {
88
+ return Object.assign(Object.assign({}, createCommonProperties(payload)), { content: payload.location, type: __1.PayloadBundleType.LOCATION });
89
+ }
90
+ static createCall(payload) {
91
+ return Object.assign(Object.assign({}, createCommonProperties(payload)), { content: payload.content, type: __1.PayloadBundleType.CALL });
92
+ }
93
+ static createReaction(payload) {
94
+ return Object.assign(Object.assign({}, createCommonProperties(payload)), { content: payload.reaction, type: __1.PayloadBundleType.REACTION });
95
+ }
96
+ static createText(payload) {
97
+ return new TextContentBuilder_1.TextContentBuilder(Object.assign(Object.assign({}, createCommonProperties(payload)), { content: { text: payload.text }, type: __1.PayloadBundleType.TEXT }));
98
+ }
99
+ static createConfirmation(payload) {
100
+ const { firstMessageId, moreMessageIds, type } = payload;
101
+ return Object.assign(Object.assign({}, createCommonProperties(payload)), { content: { firstMessageId, moreMessageIds, type }, type: __1.PayloadBundleType.CONFIRMATION });
102
+ }
103
+ static createButtonActionMessage(payload) {
104
+ return Object.assign(Object.assign({}, createCommonProperties(payload)), { content: payload.content, type: __1.PayloadBundleType.BUTTON_ACTION });
105
+ }
106
+ static createButtonActionConfirmationMessage(payload) {
107
+ return Object.assign(Object.assign({}, createCommonProperties(payload)), { content: payload.content, type: __1.PayloadBundleType.BUTTON_ACTION_CONFIRMATION });
108
+ }
109
+ static createComposite(payload) {
110
+ return new CompositeContentBuilder_1.CompositeContentBuilder(Object.assign(Object.assign({}, createCommonProperties(payload)), { content: {}, type: __1.PayloadBundleType.COMPOSITE }));
111
+ }
112
+ static createPing(payload) {
113
+ return Object.assign(Object.assign({}, createCommonProperties(payload)), { content: payload.ping || { hotKnock: false }, type: __1.PayloadBundleType.PING });
114
+ }
115
+ static createSessionReset(payload) {
116
+ return Object.assign(Object.assign({}, createCommonProperties(payload)), { content: {
117
+ clientAction: protocol_messaging_1.ClientAction.RESET_SESSION,
118
+ }, type: __1.PayloadBundleType.CLIENT_ACTION });
119
+ }
120
+ static createId() {
121
+ return uuidjs_1.default.genV4().toString();
122
+ }
123
+ }
124
+ exports.MessageBuilder = MessageBuilder;
125
+ //# sourceMappingURL=MessageBuilder.js.map
@@ -0,0 +1,67 @@
1
+ import { APIClient } from '@wireapp/api-client';
2
+ import { ClientMismatch, MessageSendingStatus, QualifiedUserClients, UserClients } from '@wireapp/api-client/src/conversation';
3
+ import { CryptographyService } from '../../cryptography';
4
+ import { QualifiedId, QualifiedUserPreKeyBundleMap, UserPreKeyBundleMap } from '@wireapp/api-client/src/user';
5
+ export declare class MessageService {
6
+ private readonly apiClient;
7
+ private readonly cryptographyService;
8
+ constructor(apiClient: APIClient, cryptographyService: CryptographyService);
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?: string;
23
+ reportMissing?: boolean | string[];
24
+ sendAsProtobuf?: boolean;
25
+ nativePush?: boolean;
26
+ onClientMismatch?: (mismatch: ClientMismatch) => void | boolean | Promise<boolean>;
27
+ }): Promise<ClientMismatch & {
28
+ errored?: boolean;
29
+ }>;
30
+ /**
31
+ * Sends a message to a federated backend.
32
+ *
33
+ * @param sendingClientId The clientId of the current user
34
+ * @param recipients The list of recipients to send the message to
35
+ * @param plainText The plainText data to send
36
+ * @param options.conversationId? the conversation to send the message to. Will broadcast if not set
37
+ * @param options.reportMissing? trigger a mismatch error when there are missing recipients in the payload
38
+ * @param options.sendAsProtobuf?
39
+ * @param options.onClientMismatch? Called when a mismatch happens on the server
40
+ * @return the MessageSendingStatus returned by the backend
41
+ */
42
+ sendFederatedMessage(sendingClientId: string, recipients: QualifiedUserClients | QualifiedUserPreKeyBundleMap, plainText: Uint8Array, options: {
43
+ assetData?: Uint8Array;
44
+ conversationId?: QualifiedId;
45
+ reportMissing?: boolean | QualifiedId[];
46
+ nativePush?: boolean;
47
+ onClientMismatch?: (mismatch: MessageSendingStatus) => void | boolean | Promise<boolean>;
48
+ }): Promise<MessageSendingStatus & {
49
+ errored?: boolean;
50
+ }>;
51
+ private sendFederatedOtrMessage;
52
+ private sendOTRMessage;
53
+ private generateExternalPayload;
54
+ private shouldSendAsExternal;
55
+ private isClientMismatchError;
56
+ private reencryptAfterMismatch;
57
+ /**
58
+ * Will re-encrypt a message when there were some missing clients in the initial send (typically when the server replies with a client mismatch error)
59
+ *
60
+ * @param {ProtobufOTR.QualifiedNewOtrMessage} messageData The initial message that was sent
61
+ * @param {MessageSendingStatus} messageSendingStatus Info about the missing/deleted clients
62
+ * @param {Uint8Array} plainText The text that should be encrypted for the missing clients
63
+ * @return resolves with a new message payload that can be sent
64
+ */
65
+ private reencryptAfterFederatedMismatch;
66
+ private sendOTRProtobufMessage;
67
+ }
@@ -0,0 +1,293 @@
1
+ "use strict";
2
+ /*
3
+ * Wire
4
+ * Copyright (C) 2020 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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
21
+ return (mod && mod.__esModule) ? mod : { "default": mod };
22
+ };
23
+ Object.defineProperty(exports, "__esModule", { value: true });
24
+ exports.MessageService = void 0;
25
+ const http_status_codes_1 = require("http-status-codes");
26
+ const otr_1 = require("@wireapp/protocol-messaging/web/otr");
27
+ const long_1 = __importDefault(require("long"));
28
+ const StringUtil_1 = require("@wireapp/commons/src/main/util/StringUtil");
29
+ const bazinga64_1 = require("bazinga64");
30
+ const AssetCryptography_1 = require("../../cryptography/AssetCryptography");
31
+ const cryptography_1 = require("../../cryptography");
32
+ const MessageBuilder_1 = require("./MessageBuilder");
33
+ const protocol_messaging_1 = require("@wireapp/protocol-messaging");
34
+ const __1 = require("..");
35
+ const UserClientsUtil_1 = require("./UserClientsUtil");
36
+ const util_1 = require("../../util");
37
+ class MessageService {
38
+ constructor(apiClient, cryptographyService) {
39
+ this.apiClient = apiClient;
40
+ this.cryptographyService = cryptographyService;
41
+ }
42
+ /**
43
+ * Sends a message to a non-federated backend.
44
+ *
45
+ * @param sendingClientId The clientId of the current user
46
+ * @param recipients The list of recipients to send the message to
47
+ * @param plainText The plainText data to send
48
+ * @param options.conversationId? the conversation to send the message to. Will broadcast if not set
49
+ * @param options.reportMissing? trigger a mismatch error when there are missing recipients in the payload
50
+ * @param options.sendAsProtobuf?
51
+ * @param options.onClientMismatch? Called when a mismatch happens on the server
52
+ * @return the ClientMismatch status returned by the backend
53
+ */
54
+ async sendMessage(sendingClientId, recipients, plainText, options = {}) {
55
+ let plainTextPayload = plainText;
56
+ let cipherText;
57
+ if (this.shouldSendAsExternal(plainText, recipients)) {
58
+ const externalPayload = await this.generateExternalPayload(plainText);
59
+ plainTextPayload = externalPayload.text;
60
+ cipherText = externalPayload.cipherText;
61
+ }
62
+ const { encrypted, missing } = await this.cryptographyService.encrypt(plainTextPayload, recipients);
63
+ const encryptedPayload = Object.keys(missing).length
64
+ ? await this.reencryptAfterMismatch({ missing, deleted: {} }, encrypted, plainText)
65
+ : encrypted;
66
+ const send = (payload) => {
67
+ return options.sendAsProtobuf
68
+ ? this.sendOTRProtobufMessage(sendingClientId, payload, Object.assign(Object.assign({}, options), { assetData: cipherText }))
69
+ : this.sendOTRMessage(sendingClientId, payload, Object.assign(Object.assign({}, options), { assetData: cipherText }));
70
+ };
71
+ try {
72
+ return await send(encryptedPayload);
73
+ }
74
+ catch (error) {
75
+ if (!this.isClientMismatchError(error)) {
76
+ throw error;
77
+ }
78
+ const mismatch = error.response.data;
79
+ const shouldStopSending = options.onClientMismatch && (await options.onClientMismatch(mismatch)) === false;
80
+ if (shouldStopSending) {
81
+ return Object.assign(Object.assign({}, mismatch), { errored: true });
82
+ }
83
+ const reEncryptedMessage = await this.reencryptAfterMismatch(mismatch, encryptedPayload, plainText);
84
+ return send(reEncryptedMessage);
85
+ }
86
+ }
87
+ /**
88
+ * Sends a message to a federated backend.
89
+ *
90
+ * @param sendingClientId The clientId of the current user
91
+ * @param recipients The list of recipients to send the message to
92
+ * @param plainText The plainText data to send
93
+ * @param options.conversationId? the conversation to send the message to. Will broadcast if not set
94
+ * @param options.reportMissing? trigger a mismatch error when there are missing recipients in the payload
95
+ * @param options.sendAsProtobuf?
96
+ * @param options.onClientMismatch? Called when a mismatch happens on the server
97
+ * @return the MessageSendingStatus returned by the backend
98
+ */
99
+ async sendFederatedMessage(sendingClientId, recipients, plainText, options) {
100
+ const send = (payload) => {
101
+ return this.sendFederatedOtrMessage(sendingClientId, payload, options);
102
+ };
103
+ const { encrypted, missing } = await this.cryptographyService.encryptQualified(plainText, recipients);
104
+ const encryptedPayload = Object.keys(missing).length
105
+ ? await this.reencryptAfterFederatedMismatch({ missing, deleted: {} }, encrypted, plainText)
106
+ : encrypted;
107
+ try {
108
+ return await send(encryptedPayload);
109
+ }
110
+ catch (error) {
111
+ if (!this.isClientMismatchError(error)) {
112
+ throw error;
113
+ }
114
+ const mismatch = error.response.data;
115
+ const shouldStopSending = options.onClientMismatch && (await options.onClientMismatch(mismatch)) === false;
116
+ if (shouldStopSending) {
117
+ return Object.assign(Object.assign({}, mismatch), { errored: true });
118
+ }
119
+ const reEncryptedPayload = await this.reencryptAfterFederatedMismatch(mismatch, encryptedPayload, plainText);
120
+ return send(reEncryptedPayload);
121
+ }
122
+ }
123
+ async sendFederatedOtrMessage(sendingClientId, recipients, options) {
124
+ const qualifiedUserEntries = Object.entries(recipients).map(([domain, otrRecipients]) => {
125
+ const userEntries = Object.entries(otrRecipients).map(([userId, otrClientMap]) => {
126
+ const clientEntries = Object.entries(otrClientMap).map(([clientId, payload]) => {
127
+ return {
128
+ client: {
129
+ client: long_1.default.fromString(clientId, 16),
130
+ },
131
+ text: payload,
132
+ };
133
+ });
134
+ return {
135
+ user: {
136
+ uuid: (0, StringUtil_1.uuidToBytes)(userId),
137
+ },
138
+ clients: clientEntries,
139
+ };
140
+ });
141
+ return { domain, entries: userEntries };
142
+ });
143
+ const protoMessage = otr_1.proteus.QualifiedNewOtrMessage.create({
144
+ recipients: qualifiedUserEntries,
145
+ sender: {
146
+ client: long_1.default.fromString(sendingClientId, 16),
147
+ },
148
+ nativePush: options.nativePush,
149
+ });
150
+ if (options.assetData) {
151
+ protoMessage.blob = options.assetData;
152
+ }
153
+ if (options.reportMissing) {
154
+ if ((0, util_1.isQualifiedIdArray)(options.reportMissing)) {
155
+ protoMessage.reportOnly = { userIds: options.reportMissing };
156
+ }
157
+ else {
158
+ protoMessage.reportAll = true;
159
+ }
160
+ }
161
+ else {
162
+ protoMessage.ignoreAll = true;
163
+ }
164
+ if (!options.conversationId) {
165
+ return this.apiClient.api.broadcast.postBroadcastFederatedMessage(sendingClientId, protoMessage);
166
+ }
167
+ const { id, domain } = options.conversationId;
168
+ return this.apiClient.api.conversation.postOTRMessageV2(id, domain, protoMessage);
169
+ }
170
+ async sendOTRMessage(sendingClientId, recipients, options) {
171
+ const message = {
172
+ data: options.assetData ? bazinga64_1.Encoder.toBase64(options.assetData).asString : undefined,
173
+ recipients: cryptography_1.CryptographyService.convertArrayRecipientsToBase64(recipients),
174
+ sender: sendingClientId,
175
+ native_push: options.nativePush,
176
+ };
177
+ let ignoreMissing;
178
+ if ((0, util_1.isStringArray)(options.reportMissing)) {
179
+ message.report_missing = options.reportMissing;
180
+ }
181
+ else {
182
+ // By default we want ignore missing to be false (and have mismatch errors in case some clients are missing)
183
+ ignoreMissing = typeof options.reportMissing === 'boolean' ? !options.reportMissing : false;
184
+ }
185
+ return !options.conversationId
186
+ ? this.apiClient.api.broadcast.postBroadcastMessage(sendingClientId, message, ignoreMissing)
187
+ : this.apiClient.api.conversation.postOTRMessage(sendingClientId, options.conversationId, message, ignoreMissing);
188
+ }
189
+ async generateExternalPayload(plainText) {
190
+ const asset = await (0, AssetCryptography_1.encryptAsset)({ plainText });
191
+ const { cipherText, keyBytes, sha256 } = asset;
192
+ const messageId = MessageBuilder_1.MessageBuilder.createId();
193
+ const externalMessage = {
194
+ otrKey: new Uint8Array(keyBytes),
195
+ sha256: new Uint8Array(sha256),
196
+ };
197
+ const genericMessage = protocol_messaging_1.GenericMessage.create({
198
+ [__1.GenericMessageType.EXTERNAL]: externalMessage,
199
+ messageId,
200
+ });
201
+ return { text: protocol_messaging_1.GenericMessage.encode(genericMessage).finish(), cipherText };
202
+ }
203
+ shouldSendAsExternal(plainText, preKeyBundles) {
204
+ const EXTERNAL_MESSAGE_THRESHOLD_BYTES = 200 * 1024;
205
+ let clientCount = 0;
206
+ for (const user in preKeyBundles) {
207
+ clientCount += Object.keys(preKeyBundles[user]).length;
208
+ }
209
+ const messageInBytes = new Uint8Array(plainText).length;
210
+ const estimatedPayloadInBytes = clientCount * messageInBytes;
211
+ return estimatedPayloadInBytes > EXTERNAL_MESSAGE_THRESHOLD_BYTES;
212
+ }
213
+ isClientMismatchError(error) {
214
+ var _a;
215
+ return ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status) === http_status_codes_1.StatusCodes.PRECONDITION_FAILED;
216
+ }
217
+ async reencryptAfterMismatch(mismatch, recipients, plainText) {
218
+ const deleted = (0, UserClientsUtil_1.flattenUserClients)(mismatch.deleted);
219
+ const missing = (0, UserClientsUtil_1.flattenUserClients)(mismatch.missing);
220
+ // remove deleted clients to the recipients
221
+ deleted.forEach(({ userId, data }) => data.forEach(clientId => delete recipients[userId.id][clientId]));
222
+ if (missing.length) {
223
+ const missingPreKeyBundles = await this.apiClient.api.user.postMultiPreKeyBundles(mismatch.missing);
224
+ const { encrypted } = await this.cryptographyService.encrypt(plainText, missingPreKeyBundles);
225
+ const reEncryptedPayloads = (0, UserClientsUtil_1.flattenUserClients)(encrypted);
226
+ // add missing clients to the recipients
227
+ reEncryptedPayloads.forEach(({ data, userId }) => (recipients[userId.id] = Object.assign(Object.assign({}, recipients[userId.id]), data)));
228
+ }
229
+ return recipients;
230
+ }
231
+ /**
232
+ * 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)
233
+ *
234
+ * @param {ProtobufOTR.QualifiedNewOtrMessage} messageData The initial message that was sent
235
+ * @param {MessageSendingStatus} messageSendingStatus Info about the missing/deleted clients
236
+ * @param {Uint8Array} plainText The text that should be encrypted for the missing clients
237
+ * @return resolves with a new message payload that can be sent
238
+ */
239
+ async reencryptAfterFederatedMismatch(mismatch, recipients, plainText) {
240
+ const deleted = (0, UserClientsUtil_1.flattenQualifiedUserClients)(mismatch.deleted);
241
+ const missing = (0, UserClientsUtil_1.flattenQualifiedUserClients)(mismatch.missing);
242
+ // remove deleted clients to the recipients
243
+ deleted.forEach(({ userId, data }) => data.forEach(clientId => delete recipients[userId.domain][userId.id][clientId]));
244
+ if (Object.keys(missing).length) {
245
+ const missingPreKeyBundles = await this.apiClient.api.user.postQualifiedMultiPreKeyBundles(mismatch.missing);
246
+ const { encrypted } = await this.cryptographyService.encryptQualified(plainText, missingPreKeyBundles);
247
+ const reEncryptedPayloads = (0, UserClientsUtil_1.flattenQualifiedUserClients)(encrypted);
248
+ reEncryptedPayloads.forEach(({ data, userId }) => (recipients[userId.domain][userId.id] = Object.assign(Object.assign({}, recipients[userId.domain][userId.id]), data)));
249
+ }
250
+ return recipients;
251
+ }
252
+ async sendOTRProtobufMessage(sendingClientId, recipients, options) {
253
+ const userEntries = Object.entries(recipients).map(([userId, otrClientMap]) => {
254
+ const clients = Object.entries(otrClientMap).map(([clientId, payload]) => {
255
+ return {
256
+ client: {
257
+ client: long_1.default.fromString(clientId, 16),
258
+ },
259
+ text: payload,
260
+ };
261
+ });
262
+ return {
263
+ clients,
264
+ user: {
265
+ uuid: (0, StringUtil_1.uuidToBytes)(userId),
266
+ },
267
+ };
268
+ });
269
+ const protoMessage = otr_1.proteus.NewOtrMessage.create({
270
+ recipients: userEntries,
271
+ sender: {
272
+ client: long_1.default.fromString(sendingClientId, 16),
273
+ },
274
+ });
275
+ let ignoreMissing;
276
+ if ((0, util_1.isStringArray)(options.reportMissing)) {
277
+ const encoder = new TextEncoder();
278
+ protoMessage.reportMissing = options.reportMissing.map(userId => ({ uuid: encoder.encode(userId) }));
279
+ }
280
+ else {
281
+ // By default we want ignore missing to be false (and have mismatch errors in case some clients are missing)
282
+ ignoreMissing = typeof options.reportMissing === 'boolean' ? !options.reportMissing : false;
283
+ }
284
+ if (options.assetData) {
285
+ protoMessage.blob = options.assetData;
286
+ }
287
+ return !options.conversationId
288
+ ? this.apiClient.api.broadcast.postBroadcastProtobufMessage(sendingClientId, protoMessage, ignoreMissing)
289
+ : this.apiClient.api.conversation.postOTRProtobufMessage(sendingClientId, options.conversationId, protoMessage, ignoreMissing);
290
+ }
291
+ }
292
+ exports.MessageService = MessageService;
293
+ //# sourceMappingURL=MessageService.js.map
@@ -0,0 +1,7 @@
1
+ import { LinkPreview, Text } from '@wireapp/protocol-messaging';
2
+ import { LinkPreviewUploadedContent } from '../content';
3
+ import { EditedTextMessage, TextMessage } from './OtrMessage';
4
+ export declare class MessageToProtoMapper {
5
+ static mapLinkPreviews(linkPreviews: LinkPreviewUploadedContent[]): LinkPreview[];
6
+ static mapText(payloadBundle: TextMessage | EditedTextMessage): Text;
7
+ }
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ /*
3
+ * Wire
4
+ * Copyright (C) 2020 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.MessageToProtoMapper = void 0;
22
+ const protocol_messaging_1 = require("@wireapp/protocol-messaging");
23
+ const GenericMessageType_1 = require("../GenericMessageType");
24
+ class MessageToProtoMapper {
25
+ static mapLinkPreviews(linkPreviews) {
26
+ const builtLinkPreviews = [];
27
+ for (const linkPreview of linkPreviews) {
28
+ const linkPreviewMessage = protocol_messaging_1.LinkPreview.create({
29
+ permanentUrl: linkPreview.permanentUrl,
30
+ summary: linkPreview.summary,
31
+ title: linkPreview.title,
32
+ url: linkPreview.url,
33
+ urlOffset: linkPreview.urlOffset,
34
+ });
35
+ if (linkPreview.tweet) {
36
+ linkPreviewMessage.tweet = protocol_messaging_1.Tweet.create({
37
+ author: linkPreview.tweet.author,
38
+ username: linkPreview.tweet.username,
39
+ });
40
+ linkPreviewMessage.metaData = 'tweet';
41
+ }
42
+ if (linkPreview.imageUploaded) {
43
+ const { asset, image } = linkPreview.imageUploaded;
44
+ const imageMetadata = protocol_messaging_1.Asset.ImageMetaData.create({
45
+ height: image.height,
46
+ width: image.width,
47
+ });
48
+ const original = protocol_messaging_1.Asset.Original.create({
49
+ [GenericMessageType_1.GenericMessageType.IMAGE]: imageMetadata,
50
+ mimeType: image.type,
51
+ size: image.data.length,
52
+ });
53
+ const remoteData = protocol_messaging_1.Asset.RemoteData.create({
54
+ assetId: asset.key,
55
+ assetToken: asset.token,
56
+ assetDomain: asset.domain,
57
+ otrKey: asset.keyBytes,
58
+ sha256: asset.sha256,
59
+ });
60
+ const assetMessage = protocol_messaging_1.Asset.create({
61
+ original,
62
+ uploaded: remoteData,
63
+ });
64
+ linkPreviewMessage.image = assetMessage;
65
+ }
66
+ linkPreviewMessage.article = protocol_messaging_1.Article.create({
67
+ image: linkPreviewMessage.image,
68
+ permanentUrl: linkPreviewMessage.permanentUrl,
69
+ summary: linkPreviewMessage.summary,
70
+ title: linkPreviewMessage.title,
71
+ });
72
+ builtLinkPreviews.push(linkPreviewMessage);
73
+ }
74
+ return builtLinkPreviews;
75
+ }
76
+ static mapText(payloadBundle) {
77
+ const { expectsReadConfirmation, legalHoldStatus, linkPreviews, mentions, quote, text } = payloadBundle.content;
78
+ const textMessage = protocol_messaging_1.Text.create({
79
+ content: text,
80
+ expectsReadConfirmation,
81
+ legalHoldStatus,
82
+ });
83
+ if (linkPreviews === null || linkPreviews === void 0 ? void 0 : linkPreviews.length) {
84
+ textMessage.linkPreview = MessageToProtoMapper.mapLinkPreviews(linkPreviews);
85
+ }
86
+ if (mentions === null || mentions === void 0 ? void 0 : mentions.length) {
87
+ textMessage.mentions = mentions.map(mention => protocol_messaging_1.Mention.create(mention));
88
+ }
89
+ if (quote) {
90
+ textMessage.quote = protocol_messaging_1.Quote.create({
91
+ quotedMessageId: quote.quotedMessageId,
92
+ quotedMessageSha256: quote.quotedMessageSha256,
93
+ });
94
+ }
95
+ return textMessage;
96
+ }
97
+ }
98
+ exports.MessageToProtoMapper = MessageToProtoMapper;
99
+ //# sourceMappingURL=MessageToProtoMapper.js.map
@@ -0,0 +1,80 @@
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
+ export interface TextMessage extends BasePayloadBundle {
4
+ content: TextContent;
5
+ type: PayloadBundleType.TEXT;
6
+ }
7
+ export interface ButtonActionMessage extends BasePayloadBundle {
8
+ content: ButtonActionContent;
9
+ type: PayloadBundleType.BUTTON_ACTION;
10
+ }
11
+ export interface ButtonActionConfirmationMessage extends BasePayloadBundle {
12
+ content: ButtonActionConfirmationContent;
13
+ type: PayloadBundleType.BUTTON_ACTION_CONFIRMATION;
14
+ }
15
+ export interface CallMessage extends BasePayloadBundle {
16
+ content: CallingContent;
17
+ type: PayloadBundleType.CALL;
18
+ }
19
+ export interface CompositeMessage extends BasePayloadBundle {
20
+ content: CompositeContent;
21
+ type: PayloadBundleType.COMPOSITE;
22
+ }
23
+ export interface EditedTextMessage extends BasePayloadBundle {
24
+ content: EditedTextContent;
25
+ type: PayloadBundleType.MESSAGE_EDIT;
26
+ }
27
+ export interface FileAssetMessage extends BasePayloadBundle {
28
+ content: FileAssetContent;
29
+ type: PayloadBundleType.ASSET;
30
+ }
31
+ export interface FileAssetMetaDataMessage extends BasePayloadBundle {
32
+ content: FileAssetMetaDataContent;
33
+ type: PayloadBundleType.ASSET_META;
34
+ }
35
+ export interface FileAssetAbortMessage extends BasePayloadBundle {
36
+ content: FileAssetAbortContent;
37
+ type: PayloadBundleType.ASSET_ABORT;
38
+ }
39
+ export interface ImageAssetMessageOutgoing extends BasePayloadBundle {
40
+ content: ImageAssetContent;
41
+ type: PayloadBundleType.ASSET_IMAGE;
42
+ }
43
+ export interface ImageAssetMessage extends BasePayloadBundle {
44
+ content: AssetContent;
45
+ type: PayloadBundleType.ASSET_IMAGE;
46
+ }
47
+ export interface LocationMessage extends BasePayloadBundle {
48
+ content: LocationContent;
49
+ type: PayloadBundleType.LOCATION;
50
+ }
51
+ export interface ReactionMessage extends BasePayloadBundle {
52
+ content: ReactionContent;
53
+ type: PayloadBundleType.REACTION;
54
+ }
55
+ export interface ConfirmationMessage extends BasePayloadBundle {
56
+ content: ConfirmationContent;
57
+ type: PayloadBundleType.CONFIRMATION;
58
+ }
59
+ export interface PingMessage extends BasePayloadBundle {
60
+ content: KnockContent;
61
+ type: PayloadBundleType.PING;
62
+ }
63
+ export interface ResetSessionMessage extends BasePayloadBundle {
64
+ content: ClientActionContent;
65
+ type: PayloadBundleType.CLIENT_ACTION;
66
+ }
67
+ export interface ClearConversationMessage extends BasePayloadBundle {
68
+ content: ClearedContent;
69
+ type: PayloadBundleType.CONVERSATION_CLEAR;
70
+ }
71
+ export interface HideMessage extends BasePayloadBundle {
72
+ content: HiddenContent;
73
+ type: PayloadBundleType.MESSAGE_HIDE;
74
+ }
75
+ export interface DeleteMessage extends BasePayloadBundle {
76
+ content: DeletedContent;
77
+ type: PayloadBundleType.MESSAGE_DELETE;
78
+ }
79
+ export declare type OtrMessage = ButtonActionMessage | ButtonActionConfirmationMessage | CallMessage | ClearConversationMessage | CompositeMessage | ConfirmationMessage | DeleteMessage | EditedTextMessage | FileAssetAbortMessage | FileAssetMessage | FileAssetMetaDataMessage | HideMessage | ImageAssetMessage | ImageAssetMessageOutgoing | LocationMessage | PingMessage | ReactionMessage | ResetSessionMessage | TextMessage;
80
+ export declare type QuotableMessage = EditedTextMessage | ImageAssetMessage | LocationMessage | TextMessage;