@wireapp/core 17.30.0 → 17.31.3

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 (239) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/package.json +8 -8
  3. package/src/main/cryptography/GenericMessageMapper.d.ts +0 -1
  4. package/src/main/cryptography/GenericMessageMapper.js +23 -158
  5. package/src/main/Account.js.map +0 -1
  6. package/src/main/Account.test.browser.js +0 -114
  7. package/src/main/Account.test.node.d.ts +0 -1
  8. package/src/main/Account.test.node.js +0 -214
  9. package/src/main/Account.test.node.js.map +0 -1
  10. package/src/main/Account.test.node.ts +0 -236
  11. package/src/main/Account.ts +0 -401
  12. package/src/main/CoreError.js.map +0 -1
  13. package/src/main/CoreError.ts +0 -30
  14. package/src/main/auth/LoginSanitizer.js.map +0 -1
  15. package/src/main/auth/LoginSanitizer.test.node.d.ts +0 -1
  16. package/src/main/auth/LoginSanitizer.test.node.js +0 -56
  17. package/src/main/auth/LoginSanitizer.test.node.js.map +0 -1
  18. package/src/main/auth/LoginSanitizer.test.node.ts +0 -68
  19. package/src/main/auth/LoginSanitizer.ts +0 -44
  20. package/src/main/auth/index.js.map +0 -1
  21. package/src/main/auth/index.ts +0 -20
  22. package/src/main/broadcast/AvailabilityType.js.map +0 -1
  23. package/src/main/broadcast/AvailabilityType.ts +0 -22
  24. package/src/main/broadcast/BroadcastService.js.map +0 -1
  25. package/src/main/broadcast/BroadcastService.ts +0 -66
  26. package/src/main/broadcast/index.js.map +0 -1
  27. package/src/main/broadcast/index.ts +0 -21
  28. package/src/main/client/ClientBackendRepository.js.map +0 -1
  29. package/src/main/client/ClientBackendRepository.ts +0 -33
  30. package/src/main/client/ClientDatabaseRepository.js.map +0 -1
  31. package/src/main/client/ClientDatabaseRepository.ts +0 -130
  32. package/src/main/client/ClientInfo.js.map +0 -1
  33. package/src/main/client/ClientInfo.ts +0 -28
  34. package/src/main/client/ClientService.js.map +0 -1
  35. package/src/main/client/ClientService.ts +0 -116
  36. package/src/main/client/index.js.map +0 -1
  37. package/src/main/client/index.ts +0 -23
  38. package/src/main/connection/ConnectionService.js.map +0 -1
  39. package/src/main/connection/ConnectionService.ts +0 -49
  40. package/src/main/connection/index.js.map +0 -1
  41. package/src/main/connection/index.ts +0 -20
  42. package/src/main/conversation/AbortReason.js.map +0 -1
  43. package/src/main/conversation/AbortReason.ts +0 -22
  44. package/src/main/conversation/AssetService.js.map +0 -1
  45. package/src/main/conversation/AssetService.test.node.d.ts +0 -1
  46. package/src/main/conversation/AssetService.test.node.js +0 -61
  47. package/src/main/conversation/AssetService.test.node.js.map +0 -1
  48. package/src/main/conversation/AssetService.test.node.ts +0 -65
  49. package/src/main/conversation/AssetService.ts +0 -60
  50. package/src/main/conversation/AssetTransferState.js.map +0 -1
  51. package/src/main/conversation/AssetTransferState.ts +0 -23
  52. package/src/main/conversation/ClientActionType.js.map +0 -1
  53. package/src/main/conversation/ClientActionType.ts +0 -20
  54. package/src/main/conversation/ConversationMapper.js.map +0 -1
  55. package/src/main/conversation/ConversationMapper.test.node.d.ts +0 -1
  56. package/src/main/conversation/ConversationMapper.test.node.js +0 -111
  57. package/src/main/conversation/ConversationMapper.test.node.js.map +0 -1
  58. package/src/main/conversation/ConversationMapper.test.node.ts +0 -154
  59. package/src/main/conversation/ConversationMapper.ts +0 -56
  60. package/src/main/conversation/ConversationService.js.map +0 -1
  61. package/src/main/conversation/ConversationService.test.node.d.ts +0 -1
  62. package/src/main/conversation/ConversationService.test.node.js +0 -344
  63. package/src/main/conversation/ConversationService.test.node.js.map +0 -1
  64. package/src/main/conversation/ConversationService.test.node.ts +0 -416
  65. package/src/main/conversation/ConversationService.ts +0 -1024
  66. package/src/main/conversation/GenericMessageType.js.map +0 -1
  67. package/src/main/conversation/GenericMessageType.ts +0 -44
  68. package/src/main/conversation/MessageTimer.js.map +0 -1
  69. package/src/main/conversation/MessageTimer.test.node.d.ts +0 -1
  70. package/src/main/conversation/MessageTimer.test.node.js +0 -88
  71. package/src/main/conversation/MessageTimer.test.node.js.map +0 -1
  72. package/src/main/conversation/MessageTimer.test.node.ts +0 -103
  73. package/src/main/conversation/MessageTimer.ts +0 -56
  74. package/src/main/conversation/ReactionType.js.map +0 -1
  75. package/src/main/conversation/ReactionType.ts +0 -23
  76. package/src/main/conversation/content/AssetContent.js.map +0 -1
  77. package/src/main/conversation/content/AssetContent.ts +0 -71
  78. package/src/main/conversation/content/ButtonActionConfirmationContent.js.map +0 -1
  79. package/src/main/conversation/content/ButtonActionConfirmationContent.ts +0 -21
  80. package/src/main/conversation/content/ButtonActionContent.js.map +0 -1
  81. package/src/main/conversation/content/ButtonActionContent.ts +0 -21
  82. package/src/main/conversation/content/CallingContent.js.map +0 -1
  83. package/src/main/conversation/content/CallingContent.ts +0 -20
  84. package/src/main/conversation/content/ClearedContent.js.map +0 -1
  85. package/src/main/conversation/content/ClearedContent.ts +0 -21
  86. package/src/main/conversation/content/ClientActionContent.js.map +0 -1
  87. package/src/main/conversation/content/ClientActionContent.ts +0 -22
  88. package/src/main/conversation/content/ClientAddContent.js.map +0 -1
  89. package/src/main/conversation/content/ClientAddContent.ts +0 -24
  90. package/src/main/conversation/content/ClientRemoveContent.js.map +0 -1
  91. package/src/main/conversation/content/ClientRemoveContent.ts +0 -25
  92. package/src/main/conversation/content/CompositeContent.js.map +0 -1
  93. package/src/main/conversation/content/CompositeContent.ts +0 -21
  94. package/src/main/conversation/content/ConfirmationContent.js.map +0 -1
  95. package/src/main/conversation/content/ConfirmationContent.ts +0 -21
  96. package/src/main/conversation/content/ContentType.js.map +0 -1
  97. package/src/main/conversation/content/ContentType.ts +0 -112
  98. package/src/main/conversation/content/ConversationContent.js.map +0 -1
  99. package/src/main/conversation/content/ConversationContent.ts +0 -71
  100. package/src/main/conversation/content/DeletedContent.js.map +0 -1
  101. package/src/main/conversation/content/DeletedContent.ts +0 -21
  102. package/src/main/conversation/content/EditedTextContent.js.map +0 -1
  103. package/src/main/conversation/content/EditedTextContent.ts +0 -31
  104. package/src/main/conversation/content/FileContent.js.map +0 -1
  105. package/src/main/conversation/content/FileContent.ts +0 -32
  106. package/src/main/conversation/content/HiddenContent.js.map +0 -1
  107. package/src/main/conversation/content/HiddenContent.ts +0 -21
  108. package/src/main/conversation/content/ImageContent.js.map +0 -1
  109. package/src/main/conversation/content/ImageContent.ts +0 -25
  110. package/src/main/conversation/content/KnockContent.js.map +0 -1
  111. package/src/main/conversation/content/KnockContent.ts +0 -21
  112. package/src/main/conversation/content/LinkPreviewContent.js.map +0 -1
  113. package/src/main/conversation/content/LinkPreviewContent.ts +0 -32
  114. package/src/main/conversation/content/LocationContent.js.map +0 -1
  115. package/src/main/conversation/content/LocationContent.ts +0 -29
  116. package/src/main/conversation/content/MentionContent.js.map +0 -1
  117. package/src/main/conversation/content/MentionContent.ts +0 -21
  118. package/src/main/conversation/content/QuoteContent.js.map +0 -1
  119. package/src/main/conversation/content/QuoteContent.ts +0 -29
  120. package/src/main/conversation/content/ReactionContent.js.map +0 -1
  121. package/src/main/conversation/content/ReactionContent.ts +0 -27
  122. package/src/main/conversation/content/TextContent.js.map +0 -1
  123. package/src/main/conversation/content/TextContent.ts +0 -29
  124. package/src/main/conversation/content/TweetContent.js.map +0 -1
  125. package/src/main/conversation/content/TweetContent.ts +0 -21
  126. package/src/main/conversation/content/index.js.map +0 -1
  127. package/src/main/conversation/content/index.ts +0 -49
  128. package/src/main/conversation/index.js.map +0 -1
  129. package/src/main/conversation/index.ts +0 -28
  130. package/src/main/conversation/message/CompositeContentBuilder.js.map +0 -1
  131. package/src/main/conversation/message/CompositeContentBuilder.ts +0 -60
  132. package/src/main/conversation/message/Message.js.map +0 -1
  133. package/src/main/conversation/message/Message.ts +0 -24
  134. package/src/main/conversation/message/MessageBuilder.js.map +0 -1
  135. package/src/main/conversation/message/MessageBuilder.test.browser.js +0 -27
  136. package/src/main/conversation/message/MessageBuilder.ts +0 -488
  137. package/src/main/conversation/message/MessageService.js.map +0 -1
  138. package/src/main/conversation/message/MessageService.test.node.d.ts +0 -1
  139. package/src/main/conversation/message/MessageService.test.node.js +0 -308
  140. package/src/main/conversation/message/MessageService.test.node.js.map +0 -1
  141. package/src/main/conversation/message/MessageService.test.node.ts +0 -398
  142. package/src/main/conversation/message/MessageService.ts +0 -383
  143. package/src/main/conversation/message/MessageToProtoMapper.js.map +0 -1
  144. package/src/main/conversation/message/MessageToProtoMapper.ts +0 -114
  145. package/src/main/conversation/message/OtrMessage.js.map +0 -1
  146. package/src/main/conversation/message/OtrMessage.ts +0 -160
  147. package/src/main/conversation/message/PayloadBundle.js.map +0 -1
  148. package/src/main/conversation/message/PayloadBundle.ts +0 -101
  149. package/src/main/conversation/message/TeamMessage.js.map +0 -1
  150. package/src/main/conversation/message/TeamMessage.ts +0 -72
  151. package/src/main/conversation/message/TextContentBuilder.js.map +0 -1
  152. package/src/main/conversation/message/TextContentBuilder.ts +0 -88
  153. package/src/main/conversation/message/UserClientsUtil.js.map +0 -1
  154. package/src/main/conversation/message/UserClientsUtil.ts +0 -44
  155. package/src/main/conversation/message/UserClientsUtils.test.node.d.ts +0 -1
  156. package/src/main/conversation/message/UserClientsUtils.test.node.js +0 -42
  157. package/src/main/conversation/message/UserClientsUtils.test.node.js.map +0 -1
  158. package/src/main/conversation/message/UserClientsUtils.test.node.ts +0 -44
  159. package/src/main/conversation/message/UserMessage.js.map +0 -1
  160. package/src/main/conversation/message/UserMessage.ts +0 -95
  161. package/src/main/cryptography/AssetCryptography.browser.js.map +0 -1
  162. package/src/main/cryptography/AssetCryptography.browser.ts +0 -76
  163. package/src/main/cryptography/AssetCryptography.node.js.map +0 -1
  164. package/src/main/cryptography/AssetCryptography.node.ts +0 -85
  165. package/src/main/cryptography/CryptographyDatabaseRepository.js.map +0 -1
  166. package/src/main/cryptography/CryptographyDatabaseRepository.ts +0 -44
  167. package/src/main/cryptography/CryptographyService.js.map +0 -1
  168. package/src/main/cryptography/CryptographyService.test.browser.js +0 -195
  169. package/src/main/cryptography/CryptographyService.test.node.d.ts +0 -1
  170. package/src/main/cryptography/CryptographyService.test.node.js +0 -228
  171. package/src/main/cryptography/CryptographyService.test.node.js.map +0 -1
  172. package/src/main/cryptography/CryptographyService.test.node.ts +0 -246
  173. package/src/main/cryptography/CryptographyService.ts +0 -246
  174. package/src/main/cryptography/EncryptedAsset.js.map +0 -1
  175. package/src/main/cryptography/EncryptedAsset.ts +0 -30
  176. package/src/main/cryptography/GenericMessageMapper.js.map +0 -1
  177. package/src/main/cryptography/GenericMessageMapper.ts +0 -364
  178. package/src/main/cryptography/MessageHashService.js.map +0 -1
  179. package/src/main/cryptography/MessageHashService.test.browser.js +0 -176
  180. package/src/main/cryptography/MessageHashService.test.node.d.ts +0 -1
  181. package/src/main/cryptography/MessageHashService.test.node.js +0 -138
  182. package/src/main/cryptography/MessageHashService.test.node.js.map +0 -1
  183. package/src/main/cryptography/MessageHashService.test.node.ts +0 -176
  184. package/src/main/cryptography/MessageHashService.ts +0 -109
  185. package/src/main/cryptography/SessionPayloadBundle.js.map +0 -1
  186. package/src/main/cryptography/SessionPayloadBundle.ts +0 -23
  187. package/src/main/cryptography/index.js.map +0 -1
  188. package/src/main/cryptography/index.ts +0 -23
  189. package/src/main/giphy/GiphyService.js.map +0 -1
  190. package/src/main/giphy/GiphyService.ts +0 -37
  191. package/src/main/giphy/index.js.map +0 -1
  192. package/src/main/giphy/index.ts +0 -20
  193. package/src/main/index.js.map +0 -1
  194. package/src/main/index.test.browser.js +0 -22
  195. package/src/main/index.ts +0 -34
  196. package/src/main/notification/NotificationBackendRepository.js.map +0 -1
  197. package/src/main/notification/NotificationBackendRepository.ts +0 -33
  198. package/src/main/notification/NotificationDatabaseRepository.js.map +0 -1
  199. package/src/main/notification/NotificationDatabaseRepository.ts +0 -74
  200. package/src/main/notification/NotificationService.js.map +0 -1
  201. package/src/main/notification/NotificationService.test.browser.js +0 -179
  202. package/src/main/notification/NotificationService.test.node.d.ts +0 -1
  203. package/src/main/notification/NotificationService.test.node.js +0 -99
  204. package/src/main/notification/NotificationService.test.node.js.map +0 -1
  205. package/src/main/notification/NotificationService.test.node.ts +0 -124
  206. package/src/main/notification/NotificationService.ts +0 -260
  207. package/src/main/notification/index.js.map +0 -1
  208. package/src/main/notification/index.ts +0 -20
  209. package/src/main/self/SelfService.js.map +0 -1
  210. package/src/main/self/SelfService.ts +0 -59
  211. package/src/main/self/index.js.map +0 -1
  212. package/src/main/self/index.ts +0 -20
  213. package/src/main/team/TeamService.js.map +0 -1
  214. package/src/main/team/TeamService.ts +0 -68
  215. package/src/main/team/index.js.map +0 -1
  216. package/src/main/team/index.ts +0 -20
  217. package/src/main/test/CryptographyHelper.js.map +0 -1
  218. package/src/main/test/CryptographyHelper.ts +0 -57
  219. package/src/main/test/PayloadHelper.js.map +0 -1
  220. package/src/main/test/PayloadHelper.ts +0 -60
  221. package/src/main/user/UserMapper.js.map +0 -1
  222. package/src/main/user/UserMapper.test.node.d.ts +0 -1
  223. package/src/main/user/UserMapper.test.node.js +0 -55
  224. package/src/main/user/UserMapper.test.node.js.map +0 -1
  225. package/src/main/user/UserMapper.test.node.ts +0 -63
  226. package/src/main/user/UserMapper.ts +0 -92
  227. package/src/main/user/UserService.js.map +0 -1
  228. package/src/main/user/UserService.test.node.js +0 -141
  229. package/src/main/user/UserService.ts +0 -98
  230. package/src/main/user/index.js.map +0 -1
  231. package/src/main/user/index.ts +0 -20
  232. package/src/main/util/TypePredicateUtil.js.map +0 -1
  233. package/src/main/util/TypePredicateUtil.test.node.d.ts +0 -1
  234. package/src/main/util/TypePredicateUtil.test.node.js +0 -42
  235. package/src/main/util/TypePredicateUtil.test.node.js.map +0 -1
  236. package/src/main/util/TypePredicateUtil.test.node.ts +0 -44
  237. package/src/main/util/TypePredicateUtil.ts +0 -52
  238. package/src/main/util/index.js.map +0 -1
  239. package/src/main/util/index.ts +0 -20
@@ -1,364 +0,0 @@
1
- /*
2
- * Wire
3
- * Copyright (C) 2019 Wire Swiss GmbH
4
- *
5
- * This program is free software: you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation, either version 3 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program. If not, see http://www.gnu.org/licenses/.
17
- *
18
- */
19
-
20
- import type {ConversationOtrMessageAddEvent} from '@wireapp/api-client/src/event/';
21
- import type {GenericMessage} from '@wireapp/protocol-messaging';
22
- import logdown from 'logdown';
23
- import {
24
- GenericMessageType,
25
- PayloadBundle,
26
- PayloadBundleSource,
27
- PayloadBundleState,
28
- PayloadBundleType,
29
- } from '../conversation';
30
- import type {
31
- AssetContent,
32
- ClearedContent,
33
- ConfirmationContent,
34
- DeletedContent,
35
- EditedTextContent,
36
- HiddenContent,
37
- KnockContent,
38
- LocationContent,
39
- ReactionContent,
40
- TextContent,
41
- } from '../conversation/content';
42
- import type {ButtonActionMessage} from '../conversation/message/OtrMessage';
43
-
44
- export class GenericMessageMapper {
45
- private static readonly logger = logdown('@wireapp/core/cryptography/GenericMessageMapper', {
46
- logger: console,
47
- markdown: false,
48
- });
49
-
50
- private static mapButtonActionMessage(
51
- genericMessage: GenericMessage,
52
- event: ConversationOtrMessageAddEvent,
53
- source: PayloadBundleSource,
54
- ): ButtonActionMessage {
55
- const {buttonAction, messageId} = genericMessage;
56
- return {
57
- content: buttonAction!,
58
- conversation: event.conversation,
59
- from: event.from,
60
- fromClientId: event.data.sender,
61
- id: messageId,
62
- messageTimer: 0,
63
- source,
64
- state: PayloadBundleState.INCOMING,
65
- timestamp: new Date(event.time).getTime(),
66
- type: PayloadBundleType.BUTTON_ACTION,
67
- };
68
- }
69
-
70
- // TODO: Turn "any" into a specific type (or collection of types) and make the return type more specific based on the
71
- // "genericMessage" input parameter.
72
- public static mapGenericMessage(
73
- genericMessage: any,
74
- event: ConversationOtrMessageAddEvent,
75
- source: PayloadBundleSource,
76
- ): PayloadBundle {
77
- switch (genericMessage.content) {
78
- case GenericMessageType.TEXT: {
79
- const {
80
- content: text,
81
- expectsReadConfirmation,
82
- legalHoldStatus,
83
- linkPreview: linkPreviews,
84
- mentions,
85
- quote,
86
- } = genericMessage[GenericMessageType.TEXT];
87
-
88
- const content: TextContent = {expectsReadConfirmation, legalHoldStatus, text};
89
-
90
- if (linkPreviews?.length) {
91
- content.linkPreviews = linkPreviews;
92
- }
93
-
94
- if (mentions?.length) {
95
- content.mentions = mentions;
96
- }
97
-
98
- if (quote) {
99
- content.quote = quote;
100
- }
101
-
102
- if (typeof legalHoldStatus !== 'undefined') {
103
- content.legalHoldStatus = legalHoldStatus;
104
- }
105
-
106
- return {
107
- content,
108
- conversation: event.conversation,
109
- from: event.from,
110
- fromClientId: event.data.sender,
111
- id: genericMessage.messageId,
112
- messageTimer: 0,
113
- source,
114
- state: PayloadBundleState.INCOMING,
115
- timestamp: new Date(event.time).getTime(),
116
- type: PayloadBundleType.TEXT,
117
- };
118
- }
119
- case GenericMessageType.BUTTON_ACTION: {
120
- return GenericMessageMapper.mapButtonActionMessage(genericMessage, event, source);
121
- }
122
- case GenericMessageType.CALLING: {
123
- return {
124
- content: genericMessage.calling.content,
125
- conversation: event.conversation,
126
- from: event.from,
127
- fromClientId: event.data.sender,
128
- id: genericMessage.messageId,
129
- messageTimer: 0,
130
- source,
131
- state: PayloadBundleState.INCOMING,
132
- timestamp: new Date(event.time).getTime(),
133
- type: PayloadBundleType.CALL,
134
- };
135
- }
136
- case GenericMessageType.CONFIRMATION: {
137
- const {firstMessageId, moreMessageIds, type} = genericMessage[GenericMessageType.CONFIRMATION];
138
-
139
- const content: ConfirmationContent = {firstMessageId, moreMessageIds, type};
140
-
141
- return {
142
- content,
143
- conversation: event.conversation,
144
- from: event.from,
145
- fromClientId: event.data.sender,
146
- id: genericMessage.messageId,
147
- messageTimer: 0,
148
- source,
149
- state: PayloadBundleState.INCOMING,
150
- timestamp: new Date(event.time).getTime(),
151
- type: PayloadBundleType.CONFIRMATION,
152
- };
153
- }
154
- case GenericMessageType.CLEARED: {
155
- const content: ClearedContent = genericMessage[GenericMessageType.CLEARED];
156
-
157
- return {
158
- content,
159
- conversation: event.conversation,
160
- from: event.from,
161
- fromClientId: event.data.sender,
162
- id: genericMessage.messageId,
163
- messageTimer: 0,
164
- source,
165
- state: PayloadBundleState.INCOMING,
166
- timestamp: new Date(event.time).getTime(),
167
- type: PayloadBundleType.CONVERSATION_CLEAR,
168
- };
169
- }
170
- case GenericMessageType.DELETED: {
171
- const originalMessageId = genericMessage[GenericMessageType.DELETED].messageId;
172
-
173
- const content: DeletedContent = {messageId: originalMessageId};
174
-
175
- return {
176
- content,
177
- conversation: event.conversation,
178
- from: event.from,
179
- fromClientId: event.data.sender,
180
- id: genericMessage.messageId,
181
- messageTimer: 0,
182
- source,
183
- state: PayloadBundleState.INCOMING,
184
- timestamp: new Date(event.time).getTime(),
185
- type: PayloadBundleType.MESSAGE_DELETE,
186
- };
187
- }
188
- case GenericMessageType.EDITED: {
189
- const {
190
- expectsReadConfirmation,
191
- text: {
192
- content: editedText,
193
- legalHoldStatus,
194
- linkPreview: editedLinkPreviews,
195
- mentions: editedMentions,
196
- quote: editedQuote,
197
- },
198
- replacingMessageId,
199
- } = genericMessage[GenericMessageType.EDITED];
200
-
201
- const content: EditedTextContent = {
202
- expectsReadConfirmation,
203
- legalHoldStatus,
204
- originalMessageId: replacingMessageId,
205
- text: editedText,
206
- };
207
-
208
- if (editedLinkPreviews?.length) {
209
- content.linkPreviews = editedLinkPreviews;
210
- }
211
-
212
- if (editedMentions?.length) {
213
- content.mentions = editedMentions;
214
- }
215
-
216
- if (editedQuote) {
217
- content.quote = editedQuote;
218
- }
219
-
220
- return {
221
- content,
222
- conversation: event.conversation,
223
- from: event.from,
224
- fromClientId: event.data.sender,
225
- id: genericMessage.messageId,
226
- messageTimer: 0,
227
- source,
228
- state: PayloadBundleState.INCOMING,
229
- timestamp: new Date(event.time).getTime(),
230
- type: PayloadBundleType.MESSAGE_EDIT,
231
- };
232
- }
233
- case GenericMessageType.HIDDEN: {
234
- const {conversationId, messageId} = genericMessage[GenericMessageType.HIDDEN];
235
-
236
- const content: HiddenContent = {
237
- conversationId,
238
- messageId,
239
- };
240
-
241
- return {
242
- content,
243
- conversation: event.conversation,
244
- from: event.from,
245
- fromClientId: event.data.sender,
246
- id: genericMessage.messageId,
247
- messageTimer: 0,
248
- source,
249
- state: PayloadBundleState.INCOMING,
250
- timestamp: new Date(event.time).getTime(),
251
- type: PayloadBundleType.MESSAGE_HIDE,
252
- };
253
- }
254
- case GenericMessageType.KNOCK: {
255
- const {expectsReadConfirmation, legalHoldStatus} = genericMessage[GenericMessageType.KNOCK];
256
- const content: KnockContent = {expectsReadConfirmation, hotKnock: false, legalHoldStatus};
257
-
258
- return {
259
- content,
260
- conversation: event.conversation,
261
- from: event.from,
262
- fromClientId: event.data.sender,
263
- id: genericMessage.messageId,
264
- messageTimer: 0,
265
- source,
266
- state: PayloadBundleState.INCOMING,
267
- timestamp: new Date(event.time).getTime(),
268
- type: PayloadBundleType.PING,
269
- };
270
- }
271
- case GenericMessageType.LOCATION: {
272
- const {expectsReadConfirmation, latitude, legalHoldStatus, longitude, name, zoom} =
273
- genericMessage[GenericMessageType.LOCATION];
274
-
275
- const content: LocationContent = {
276
- expectsReadConfirmation,
277
- latitude,
278
- legalHoldStatus,
279
- longitude,
280
- name,
281
- zoom,
282
- };
283
-
284
- return {
285
- content,
286
- conversation: event.conversation,
287
- from: event.from,
288
- fromClientId: event.data.sender,
289
- id: genericMessage.messageId,
290
- messageTimer: 0,
291
- source,
292
- state: PayloadBundleState.INCOMING,
293
- timestamp: new Date(event.time).getTime(),
294
- type: PayloadBundleType.LOCATION,
295
- };
296
- }
297
- case GenericMessageType.ASSET: {
298
- const {expectsReadConfirmation, legalHoldStatus, notUploaded, original, preview, status, uploaded} =
299
- genericMessage[GenericMessageType.ASSET];
300
- const isImage = !!uploaded?.assetId && !!original?.image;
301
-
302
- const content: AssetContent = {
303
- abortReason: notUploaded,
304
- expectsReadConfirmation,
305
- legalHoldStatus,
306
- original,
307
- preview,
308
- status,
309
- uploaded,
310
- };
311
-
312
- return {
313
- content,
314
- conversation: event.conversation,
315
- from: event.from,
316
- fromClientId: event.data.sender,
317
- id: genericMessage.messageId,
318
- messageTimer: 0,
319
- source,
320
- state: PayloadBundleState.INCOMING,
321
- timestamp: new Date(event.time).getTime(),
322
- type: isImage ? PayloadBundleType.ASSET_IMAGE : PayloadBundleType.ASSET,
323
- };
324
- }
325
- case GenericMessageType.REACTION: {
326
- const {emoji, legalHoldStatus, messageId} = genericMessage[GenericMessageType.REACTION];
327
-
328
- const content: ReactionContent = {
329
- legalHoldStatus,
330
- originalMessageId: messageId,
331
- type: emoji,
332
- };
333
-
334
- return {
335
- content,
336
- conversation: event.conversation,
337
- from: event.from,
338
- fromClientId: event.data.sender,
339
- id: genericMessage.messageId,
340
- messageTimer: 0,
341
- source,
342
- state: PayloadBundleState.INCOMING,
343
- timestamp: new Date(event.time).getTime(),
344
- type: PayloadBundleType.REACTION,
345
- };
346
- }
347
- default: {
348
- this.logger.warn(`Unhandled event type "${genericMessage.content}": ${JSON.stringify(genericMessage)}`);
349
- return {
350
- content: genericMessage.content,
351
- conversation: event.conversation,
352
- from: event.from,
353
- fromClientId: event.data.sender,
354
- id: genericMessage.messageId,
355
- messageTimer: 0,
356
- source,
357
- state: PayloadBundleState.INCOMING,
358
- timestamp: new Date(event.time).getTime(),
359
- type: PayloadBundleType.UNKNOWN,
360
- };
361
- }
362
- }
363
- }
364
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"MessageHashService.js","sourceRoot":"","sources":["MessageHashService.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8CAAgC;AAChC,gDAAwB;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,CAAC,OAAO,CAAC,CAAC;SACpC;aAAM,IAAI,qBAAW,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE;YAC9C,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;SACrC;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,yBAAyB,OAAO,EAAE,CAAC,CAAC;SACrD;QAED,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAChE,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,OAAO;QACL,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;CACF;AAlFD,gDAkFC"}
@@ -1,176 +0,0 @@
1
- /*
2
- * Wire
3
- * Copyright (C) 2018 Wire Swiss GmbH
4
- *
5
- * This program is free software: you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation, either version 3 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program. If not, see http://www.gnu.org/licenses/.
17
- *
18
- */
19
-
20
- //@ts-check
21
-
22
- /* eslint-disable no-magic-numbers */
23
-
24
- const {MessageHashService} = require('@wireapp/core/src/main/cryptography/');
25
-
26
- describe('MessageHashService', () => {
27
- describe('"getHash"', () => {
28
- it('correctly identifies the message type.', () => {
29
- const content = {
30
- text: 'Hello!',
31
- };
32
-
33
- const messageHashService = new MessageHashService(content);
34
-
35
- spyOn(messageHashService, 'getTextBytes').and.callThrough();
36
- spyOn(messageHashService, 'getLocationBytes').and.callThrough();
37
-
38
- messageHashService.getHash();
39
-
40
- expect(messageHashService.getTextBytes).toHaveBeenCalled();
41
- expect(messageHashService.getLocationBytes).not.toHaveBeenCalled();
42
- });
43
-
44
- it('correctly creates a timestamp bytes buffer.', () => {
45
- const expectedHexValue = '000000005bcdcc09';
46
- const content = {
47
- text: 'Hello!',
48
- };
49
- const timestamp = 1540213769;
50
-
51
- const messageHashService = new MessageHashService(content, timestamp);
52
- const buffer = messageHashService.getTimestampBuffer(timestamp);
53
-
54
- const hexValue = buffer.toString('hex');
55
- expect(hexValue).toBe(expectedHexValue);
56
- });
57
-
58
- it('correctly creates a markdown text bytes buffer.', () => {
59
- const expectedHashValue = 'f25a925d55116800e66872d2a82d8292adf1d4177195703f976bc884d32b5c94';
60
-
61
- const content = {
62
- text: 'This has **markdown**',
63
- };
64
- const timestamp = 1540213965000;
65
-
66
- const messageHashService = new MessageHashService(content, timestamp);
67
-
68
- const hashValue = messageHashService.getHash().toString('hex');
69
- expect(hashValue).toBe(expectedHashValue);
70
- });
71
-
72
- it('correctly creates an arabic text bytes buffer.', () => {
73
- const expectedHashValue = '5830012f6f14c031bf21aded5b07af6e2d02d01074f137d106d4645e4dc539ca';
74
-
75
- const content = {
76
- text: 'بغداد',
77
- };
78
- const timestamp = 1540213965000;
79
-
80
- const messageHashService = new MessageHashService(content, timestamp);
81
-
82
- const hashValue = messageHashService.getHash().toString('hex');
83
- expect(hashValue).toBe(expectedHashValue);
84
- });
85
-
86
- it('correctly creates an emoji text bytes buffer.', () => {
87
- const expectedHashValue = '4f8ee55a8b71a7eb7447301d1bd0c8429971583b15a91594b45dee16f208afd5';
88
-
89
- const content = {
90
- text: 'Hello 👩‍💻👨‍👩‍👧!',
91
- };
92
- const timestamp = 1540213769000;
93
-
94
- const messageHashService = new MessageHashService(content, timestamp);
95
-
96
- const hashValue = messageHashService.getHash().toString('hex');
97
- expect(hashValue).toBe(expectedHashValue);
98
- });
99
-
100
- it('correctly creates a link text bytes buffer.', () => {
101
- const expectedHashValue = 'ef39934807203191c404ebb3acba0d33ec9dce669f9acec49710d520c365b657';
102
-
103
- const content = {
104
- text: 'https://www.youtube.com/watch?v=DLzxrzFCyOs',
105
- };
106
- const timestamp = 1540213769000;
107
-
108
- const messageHashService = new MessageHashService(content, timestamp);
109
-
110
- const hashValue = messageHashService.getHash().toString('hex');
111
- expect(hashValue).toBe(expectedHashValue);
112
- });
113
-
114
- it('correctly creates a location bytes buffer.', () => {
115
- const expectedHashValue = '56a5fa30081bc16688574fdfbbe96c2eee004d1fb37dc714eec6efb340192816';
116
-
117
- const content = {
118
- latitude: 52.5166667,
119
- longitude: 13.4,
120
- };
121
- const timestamp = 1540213769000;
122
-
123
- const messageHashService = new MessageHashService(content, timestamp);
124
-
125
- const hashValue = messageHashService.getHash().toString('hex');
126
- expect(hashValue).toBe(expectedHashValue);
127
- });
128
-
129
- it('correctly creates another location bytes buffer.', () => {
130
- const expectedHashValue = '803b2698104f58772dbd715ec6ee5853d835df98a4736742b2a676b2217c9499';
131
-
132
- const content = {
133
- latitude: 51.509143,
134
- longitude: -0.117277,
135
- };
136
- const timestamp = 1540213769000;
137
-
138
- const messageHashService = new MessageHashService(content, timestamp);
139
-
140
- const hashValue = messageHashService.getHash().toString('hex');
141
- expect(hashValue).toBe(expectedHashValue);
142
- });
143
-
144
- it('correctly creates an asset bytes buffer.', () => {
145
- const expectedHashValue = 'bf20de149847ae999775b3cc88e5ff0c0382e9fa67b9d382b1702920b8afa1de';
146
-
147
- const content = {
148
- uploaded: {
149
- assetId: '3-2-1-38d4f5b9',
150
- },
151
- };
152
- const timestamp = 1540213769000;
153
-
154
- const messageHashService = new MessageHashService(content, timestamp);
155
-
156
- const hashValue = messageHashService.getHash().toString('hex');
157
- expect(hashValue).toBe(expectedHashValue);
158
- });
159
-
160
- it('correctly creates another asset bytes buffer.', () => {
161
- const expectedHashValue = '2235f5b6c00d9b0917675399d0314c8401f0525457b00aa54a38998ab93b90d6';
162
-
163
- const content = {
164
- uploaded: {
165
- assetId: '3-3-3-82a62735',
166
- },
167
- };
168
- const timestamp = 1540213965000;
169
-
170
- const messageHashService = new MessageHashService(content, timestamp);
171
-
172
- const hashValue = messageHashService.getHash().toString('hex');
173
- expect(hashValue).toBe(expectedHashValue);
174
- });
175
- });
176
- });
@@ -1,138 +0,0 @@
1
- "use strict";
2
- /*
3
- * Wire
4
- * Copyright (C) 2018 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
- const MessageHashService_1 = require("./MessageHashService");
22
- describe('MessageHashService', () => {
23
- describe('"getHash"', () => {
24
- it('correctly identifies the message type.', () => {
25
- const content = {
26
- text: 'Hello!',
27
- };
28
- const messageHashService = new MessageHashService_1.MessageHashService(content);
29
- spyOn(messageHashService, 'getTextBytes').and.callThrough();
30
- spyOn(messageHashService, 'getLocationBytes').and.callThrough();
31
- messageHashService.getHash();
32
- expect(messageHashService['getTextBytes']).toHaveBeenCalled();
33
- expect(messageHashService['getLocationBytes']).not.toHaveBeenCalled();
34
- });
35
- it('correctly creates a timestamp bytes buffer.', () => {
36
- const expectedHexValue = '000000005bcdcc09';
37
- const content = {
38
- text: 'Hello!',
39
- };
40
- const timestamp = 1540213769;
41
- const messageHashService = new MessageHashService_1.MessageHashService(content, timestamp);
42
- const buffer = messageHashService['getTimestampBuffer'](timestamp);
43
- const hexValue = buffer.toString('hex');
44
- expect(hexValue).toBe(expectedHexValue);
45
- });
46
- it('correctly creates a markdown text bytes buffer.', () => {
47
- const expectedHashValue = 'f25a925d55116800e66872d2a82d8292adf1d4177195703f976bc884d32b5c94';
48
- const content = {
49
- text: 'This has **markdown**',
50
- };
51
- const timestamp = 1540213965000;
52
- const messageHashService = new MessageHashService_1.MessageHashService(content, timestamp);
53
- const hashValue = messageHashService.getHash().toString('hex');
54
- expect(hashValue).toBe(expectedHashValue);
55
- });
56
- it('correctly creates an arabic text bytes buffer.', () => {
57
- const expectedHashValue = '5830012f6f14c031bf21aded5b07af6e2d02d01074f137d106d4645e4dc539ca';
58
- const content = {
59
- text: 'بغداد',
60
- };
61
- const timestamp = 1540213965000;
62
- const messageHashService = new MessageHashService_1.MessageHashService(content, timestamp);
63
- const hashValue = messageHashService.getHash().toString('hex');
64
- expect(hashValue).toBe(expectedHashValue);
65
- });
66
- it('correctly creates an emoji text bytes buffer.', () => {
67
- const expectedHashValue = '4f8ee55a8b71a7eb7447301d1bd0c8429971583b15a91594b45dee16f208afd5';
68
- const content = {
69
- text: 'Hello 👩‍💻👨‍👩‍👧!',
70
- };
71
- const timestamp = 1540213769000;
72
- const messageHashService = new MessageHashService_1.MessageHashService(content, timestamp);
73
- const hashValue = messageHashService.getHash().toString('hex');
74
- expect(hashValue).toBe(expectedHashValue);
75
- });
76
- it('correctly creates a link text bytes buffer.', () => {
77
- const expectedHashValue = 'ef39934807203191c404ebb3acba0d33ec9dce669f9acec49710d520c365b657';
78
- const content = {
79
- text: 'https://www.youtube.com/watch?v=DLzxrzFCyOs',
80
- };
81
- const timestamp = 1540213769000;
82
- const messageHashService = new MessageHashService_1.MessageHashService(content, timestamp);
83
- const hashValue = messageHashService.getHash().toString('hex');
84
- expect(hashValue).toBe(expectedHashValue);
85
- });
86
- it('correctly creates a location bytes buffer.', () => {
87
- const expectedHashValue = '56a5fa30081bc16688574fdfbbe96c2eee004d1fb37dc714eec6efb340192816';
88
- const content = {
89
- latitude: 52.5166667,
90
- longitude: 13.4,
91
- };
92
- const timestamp = 1540213769000;
93
- const messageHashService = new MessageHashService_1.MessageHashService(content, timestamp);
94
- const hashValue = messageHashService.getHash().toString('hex');
95
- expect(hashValue).toBe(expectedHashValue);
96
- });
97
- it('correctly creates another location bytes buffer.', () => {
98
- const expectedHashValue = '803b2698104f58772dbd715ec6ee5853d835df98a4736742b2a676b2217c9499';
99
- const content = {
100
- latitude: 51.509143,
101
- longitude: -0.117277,
102
- };
103
- const timestamp = 1540213769000;
104
- const messageHashService = new MessageHashService_1.MessageHashService(content, timestamp);
105
- const hashValue = messageHashService.getHash().toString('hex');
106
- expect(hashValue).toBe(expectedHashValue);
107
- });
108
- it('correctly creates an asset bytes buffer.', () => {
109
- const expectedHashValue = 'bf20de149847ae999775b3cc88e5ff0c0382e9fa67b9d382b1702920b8afa1de';
110
- const content = {
111
- uploaded: {
112
- assetId: '3-2-1-38d4f5b9',
113
- otrKey: new Uint8Array(),
114
- sha256: new Uint8Array(),
115
- },
116
- };
117
- const timestamp = 1540213769000;
118
- const messageHashService = new MessageHashService_1.MessageHashService(content, timestamp);
119
- const hashValue = messageHashService.getHash().toString('hex');
120
- expect(hashValue).toBe(expectedHashValue);
121
- });
122
- it('correctly creates another asset bytes buffer.', () => {
123
- const expectedHashValue = '2235f5b6c00d9b0917675399d0314c8401f0525457b00aa54a38998ab93b90d6';
124
- const content = {
125
- uploaded: {
126
- assetId: '3-3-3-82a62735',
127
- otrKey: new Uint8Array(),
128
- sha256: new Uint8Array(),
129
- },
130
- };
131
- const timestamp = 1540213965000;
132
- const messageHashService = new MessageHashService_1.MessageHashService(content, timestamp);
133
- const hashValue = messageHashService.getHash().toString('hex');
134
- expect(hashValue).toBe(expectedHashValue);
135
- });
136
- });
137
- });
138
- //# sourceMappingURL=MessageHashService.test.node.js.map