@wireapp/core 30.5.1 → 30.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +3 -3
  3. package/src/main/Account.d.ts +0 -204
  4. package/src/main/Account.js +0 -439
  5. package/src/main/CoreError.d.ts +0 -9
  6. package/src/main/CoreError.js +0 -26
  7. package/src/main/account/AccountService.d.ts +0 -7
  8. package/src/main/account/AccountService.js +0 -33
  9. package/src/main/account/AccountService.js.map +0 -1
  10. package/src/main/account/index.d.ts +0 -1
  11. package/src/main/account/index.js +0 -32
  12. package/src/main/account/index.js.map +0 -1
  13. package/src/main/auth/LoginSanitizer.d.ts +0 -5
  14. package/src/main/auth/LoginSanitizer.js +0 -41
  15. package/src/main/auth/index.d.ts +0 -1
  16. package/src/main/auth/index.js +0 -32
  17. package/src/main/broadcast/AvailabilityType.d.ts +0 -2
  18. package/src/main/broadcast/AvailabilityType.js +0 -21
  19. package/src/main/broadcast/BroadcastService.d.ts +0 -24
  20. package/src/main/broadcast/BroadcastService.js +0 -74
  21. package/src/main/broadcast/index.d.ts +0 -2
  22. package/src/main/broadcast/index.js +0 -33
  23. package/src/main/client/ClientBackendRepository.d.ts +0 -11
  24. package/src/main/client/ClientBackendRepository.js +0 -43
  25. package/src/main/client/ClientDatabaseRepository.d.ts +0 -27
  26. package/src/main/client/ClientDatabaseRepository.js +0 -85
  27. package/src/main/client/ClientInfo.d.ts +0 -8
  28. package/src/main/client/ClientInfo.js +0 -21
  29. package/src/main/client/ClientService.d.ts +0 -48
  30. package/src/main/client/ClientService.js +0 -118
  31. package/src/main/client/index.d.ts +0 -4
  32. package/src/main/client/index.js +0 -35
  33. package/src/main/connection/ConnectionService.d.ts +0 -11
  34. package/src/main/connection/ConnectionService.js +0 -45
  35. package/src/main/connection/index.d.ts +0 -1
  36. package/src/main/connection/index.js +0 -32
  37. package/src/main/conversation/AbortReason.d.ts +0 -2
  38. package/src/main/conversation/AbortReason.js +0 -21
  39. package/src/main/conversation/AssetService/AssetService.d.ts +0 -62
  40. package/src/main/conversation/AssetService/AssetService.js +0 -88
  41. package/src/main/conversation/AssetService/index.d.ts +0 -1
  42. package/src/main/conversation/AssetService/index.js +0 -32
  43. package/src/main/conversation/AssetTransferState.d.ts +0 -4
  44. package/src/main/conversation/AssetTransferState.js +0 -27
  45. package/src/main/conversation/ClientActionType.d.ts +0 -1
  46. package/src/main/conversation/ClientActionType.js +0 -24
  47. package/src/main/conversation/ConversationMapper/ConversationMapper.d.ts +0 -6
  48. package/src/main/conversation/ConversationMapper/ConversationMapper.js +0 -57
  49. package/src/main/conversation/ConversationMapper/index.d.ts +0 -1
  50. package/src/main/conversation/ConversationMapper/index.js +0 -32
  51. package/src/main/conversation/ConversationService/ConversationService.d.ts +0 -162
  52. package/src/main/conversation/ConversationService/ConversationService.js +0 -900
  53. package/src/main/conversation/ConversationService/ConversationService.types.d.ts +0 -108
  54. package/src/main/conversation/ConversationService/ConversationService.types.js +0 -28
  55. package/src/main/conversation/ConversationService/index.d.ts +0 -2
  56. package/src/main/conversation/ConversationService/index.js +0 -33
  57. package/src/main/conversation/GenericMessageType.d.ts +0 -25
  58. package/src/main/conversation/GenericMessageType.js +0 -49
  59. package/src/main/conversation/MessageTimer/MessageTimer.d.ts +0 -10
  60. package/src/main/conversation/MessageTimer/MessageTimer.js +0 -54
  61. package/src/main/conversation/MessageTimer/index.d.ts +0 -1
  62. package/src/main/conversation/MessageTimer/index.js +0 -32
  63. package/src/main/conversation/ReactionType.d.ts +0 -4
  64. package/src/main/conversation/ReactionType.js +0 -27
  65. package/src/main/conversation/content/AssetContent.d.ts +0 -42
  66. package/src/main/conversation/content/AssetContent.js +0 -21
  67. package/src/main/conversation/content/ButtonActionConfirmationContent.d.ts +0 -2
  68. package/src/main/conversation/content/ButtonActionConfirmationContent.js +0 -21
  69. package/src/main/conversation/content/ButtonActionContent.d.ts +0 -2
  70. package/src/main/conversation/content/ButtonActionContent.js +0 -21
  71. package/src/main/conversation/content/CallingContent.d.ts +0 -1
  72. package/src/main/conversation/content/CallingContent.js +0 -21
  73. package/src/main/conversation/content/ClearedContent.d.ts +0 -2
  74. package/src/main/conversation/content/ClearedContent.js +0 -21
  75. package/src/main/conversation/content/ClientActionContent.d.ts +0 -2
  76. package/src/main/conversation/content/ClientActionContent.js +0 -21
  77. package/src/main/conversation/content/ClientAddContent.d.ts +0 -4
  78. package/src/main/conversation/content/ClientAddContent.js +0 -21
  79. package/src/main/conversation/content/ClientRemoveContent.d.ts +0 -6
  80. package/src/main/conversation/content/ClientRemoveContent.js +0 -21
  81. package/src/main/conversation/content/CompositeContent.d.ts +0 -2
  82. package/src/main/conversation/content/CompositeContent.js +0 -21
  83. package/src/main/conversation/content/ConfirmationContent.d.ts +0 -2
  84. package/src/main/conversation/content/ConfirmationContent.js +0 -21
  85. package/src/main/conversation/content/ContentType.d.ts +0 -21
  86. package/src/main/conversation/content/ContentType.js +0 -94
  87. package/src/main/conversation/content/ConversationContent.d.ts +0 -3
  88. package/src/main/conversation/content/ConversationContent.js +0 -21
  89. package/src/main/conversation/content/DeletedContent.d.ts +0 -2
  90. package/src/main/conversation/content/DeletedContent.js +0 -21
  91. package/src/main/conversation/content/EditedTextContent.d.ts +0 -11
  92. package/src/main/conversation/content/EditedTextContent.js +0 -21
  93. package/src/main/conversation/content/FileContent.d.ts +0 -13
  94. package/src/main/conversation/content/FileContent.js +0 -21
  95. package/src/main/conversation/content/HiddenContent.d.ts +0 -2
  96. package/src/main/conversation/content/HiddenContent.js +0 -21
  97. package/src/main/conversation/content/ImageContent.d.ts +0 -7
  98. package/src/main/conversation/content/ImageContent.js +0 -21
  99. package/src/main/conversation/content/KnockContent.d.ts +0 -2
  100. package/src/main/conversation/content/KnockContent.js +0 -21
  101. package/src/main/conversation/content/LinkPreviewContent.d.ts +0 -10
  102. package/src/main/conversation/content/LinkPreviewContent.js +0 -21
  103. package/src/main/conversation/content/LocationContent.d.ts +0 -9
  104. package/src/main/conversation/content/LocationContent.js +0 -21
  105. package/src/main/conversation/content/MentionContent.d.ts +0 -2
  106. package/src/main/conversation/content/MentionContent.js +0 -21
  107. package/src/main/conversation/content/QuoteContent.d.ts +0 -7
  108. package/src/main/conversation/content/QuoteContent.js +0 -21
  109. package/src/main/conversation/content/ReactionContent.d.ts +0 -7
  110. package/src/main/conversation/content/ReactionContent.js +0 -21
  111. package/src/main/conversation/content/TextContent.d.ts +0 -9
  112. package/src/main/conversation/content/TextContent.js +0 -21
  113. package/src/main/conversation/content/TweetContent.d.ts +0 -2
  114. package/src/main/conversation/content/TweetContent.js +0 -21
  115. package/src/main/conversation/content/index.d.ts +0 -28
  116. package/src/main/conversation/content/index.js +0 -72
  117. package/src/main/conversation/index.d.ts +0 -9
  118. package/src/main/conversation/index.js +0 -40
  119. package/src/main/conversation/message/CompositeContentBuilder.d.ts +0 -14
  120. package/src/main/conversation/message/CompositeContentBuilder.js +0 -54
  121. package/src/main/conversation/message/Message.d.ts +0 -4
  122. package/src/main/conversation/message/Message.js +0 -21
  123. package/src/main/conversation/message/MessageBuilder.d.ts +0 -87
  124. package/src/main/conversation/message/MessageBuilder.js +0 -119
  125. package/src/main/conversation/message/MessageService.d.ts +0 -67
  126. package/src/main/conversation/message/MessageService.js +0 -293
  127. package/src/main/conversation/message/MessageToProtoMapper.d.ts +0 -7
  128. package/src/main/conversation/message/MessageToProtoMapper.js +0 -99
  129. package/src/main/conversation/message/OtrMessage.d.ts +0 -80
  130. package/src/main/conversation/message/OtrMessage.js +0 -21
  131. package/src/main/conversation/message/PayloadBundle.d.ts +0 -76
  132. package/src/main/conversation/message/PayloadBundle.js +0 -81
  133. package/src/main/conversation/message/TeamMessage.d.ts +0 -31
  134. package/src/main/conversation/message/TeamMessage.js +0 -21
  135. package/src/main/conversation/message/TextContentBuilder.d.ts +0 -13
  136. package/src/main/conversation/message/TextContentBuilder.js +0 -75
  137. package/src/main/conversation/message/UserClientsUtil.d.ts +0 -22
  138. package/src/main/conversation/message/UserClientsUtil.js +0 -38
  139. package/src/main/conversation/message/UserMessage.d.ts +0 -43
  140. package/src/main/conversation/message/UserMessage.js +0 -21
  141. package/src/main/cryptography/AssetCryptography/EncryptedAsset.d.ts +0 -11
  142. package/src/main/cryptography/AssetCryptography/EncryptedAsset.js +0 -21
  143. package/src/main/cryptography/AssetCryptography/crypto.browser.d.ts +0 -2
  144. package/src/main/cryptography/AssetCryptography/crypto.browser.js +0 -46
  145. package/src/main/cryptography/AssetCryptography/crypto.node.d.ts +0 -2
  146. package/src/main/cryptography/AssetCryptography/crypto.node.js +0 -68
  147. package/src/main/cryptography/AssetCryptography/index.d.ts +0 -8
  148. package/src/main/cryptography/AssetCryptography/index.js +0 -53
  149. package/src/main/cryptography/AssetCryptography/interfaces.d.ts +0 -9
  150. package/src/main/cryptography/AssetCryptography/interfaces.js +0 -21
  151. package/src/main/cryptography/CryptographyDatabaseRepository.d.ts +0 -17
  152. package/src/main/cryptography/CryptographyDatabaseRepository.js +0 -45
  153. package/src/main/cryptography/CryptographyService.d.ts +0 -52
  154. package/src/main/cryptography/CryptographyService.js +0 -205
  155. package/src/main/cryptography/GenericMessageMapper.d.ts +0 -6
  156. package/src/main/cryptography/GenericMessageMapper.js +0 -160
  157. package/src/main/cryptography/MessageHashService.d.ts +0 -16
  158. package/src/main/cryptography/MessageHashService.js +0 -114
  159. package/src/main/cryptography/SessionPayloadBundle.d.ts +0 -4
  160. package/src/main/cryptography/SessionPayloadBundle.js +0 -21
  161. package/src/main/cryptography/index.d.ts +0 -4
  162. package/src/main/cryptography/index.js +0 -35
  163. package/src/main/giphy/GiphyService.d.ts +0 -9
  164. package/src/main/giphy/GiphyService.js +0 -37
  165. package/src/main/giphy/index.d.ts +0 -1
  166. package/src/main/giphy/index.js +0 -32
  167. package/src/main/index.d.ts +0 -17
  168. package/src/main/index.js +0 -55
  169. package/src/main/linkPreview/LinkPreviewService.d.ts +0 -7
  170. package/src/main/linkPreview/LinkPreviewService.js +0 -52
  171. package/src/main/linkPreview/index.d.ts +0 -1
  172. package/src/main/linkPreview/index.js +0 -32
  173. package/src/main/mls/MLSService/MLSService.d.ts +0 -26
  174. package/src/main/mls/MLSService/MLSService.js +0 -131
  175. package/src/main/mls/index.d.ts +0 -1
  176. package/src/main/mls/index.js +0 -32
  177. package/src/main/mls/types.d.ts +0 -22
  178. package/src/main/mls/types.js +0 -21
  179. package/src/main/notification/NotificationBackendRepository.d.ts +0 -11
  180. package/src/main/notification/NotificationBackendRepository.js +0 -34
  181. package/src/main/notification/NotificationDatabaseRepository.d.ts +0 -66
  182. package/src/main/notification/NotificationDatabaseRepository.js +0 -136
  183. package/src/main/notification/NotificationService.d.ts +0 -131
  184. package/src/main/notification/NotificationService.js +0 -468
  185. package/src/main/notification/index.d.ts +0 -1
  186. package/src/main/notification/index.js +0 -32
  187. package/src/main/notification/types.d.ts +0 -20
  188. package/src/main/notification/types.js +0 -21
  189. package/src/main/self/SelfService.d.ts +0 -13
  190. package/src/main/self/SelfService.js +0 -55
  191. package/src/main/self/index.d.ts +0 -1
  192. package/src/main/self/index.js +0 -32
  193. package/src/main/team/TeamService.d.ts +0 -15
  194. package/src/main/team/TeamService.js +0 -55
  195. package/src/main/team/index.d.ts +0 -1
  196. package/src/main/team/index.js +0 -32
  197. package/src/main/test/CryptographyHelper.d.ts +0 -4
  198. package/src/main/test/CryptographyHelper.js +0 -65
  199. package/src/main/test/PayloadHelper.d.ts +0 -3
  200. package/src/main/test/PayloadHelper.js +0 -66
  201. package/src/main/user/UserMapper.d.ts +0 -5
  202. package/src/main/user/UserMapper.js +0 -88
  203. package/src/main/user/UserService.d.ts +0 -25
  204. package/src/main/user/UserService.js +0 -81
  205. package/src/main/user/index.d.ts +0 -1
  206. package/src/main/user/index.js +0 -32
  207. package/src/main/util/LowPrecisionTaskScheduler/LowPrecisionTaskScheduler.d.ts +0 -21
  208. package/src/main/util/LowPrecisionTaskScheduler/LowPrecisionTaskScheduler.js +0 -62
  209. package/src/main/util/TaskScheduler/TaskScheduler.d.ts +0 -10
  210. package/src/main/util/TaskScheduler/TaskScheduler.js +0 -70
  211. package/src/main/util/TypePredicateUtil.d.ts +0 -7
  212. package/src/main/util/TypePredicateUtil.js +0 -55
  213. package/src/main/util/encryptedStore.d.ts +0 -45
  214. package/src/main/util/encryptedStore.js +0 -116
  215. package/src/main/util/index.d.ts +0 -1
  216. package/src/main/util/index.js +0 -32
  217. package/src/main/util/mapQualifiedUserClientIdsToFullyQualifiedClientIds.d.ts +0 -8
  218. package/src/main/util/mapQualifiedUserClientIdsToFullyQualifiedClientIds.js +0 -32
@@ -1,205 +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
- 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.CryptographyService = void 0;
25
- const cryptobox_1 = require("@wireapp/cryptobox");
26
- const proteus_1 = require("@wireapp/proteus");
27
- const protocol_messaging_1 = require("@wireapp/protocol-messaging");
28
- const bazinga64_1 = require("bazinga64");
29
- const logdown_1 = __importDefault(require("logdown"));
30
- const conversation_1 = require("../conversation");
31
- const util_1 = require("../util");
32
- const CryptographyDatabaseRepository_1 = require("./CryptographyDatabaseRepository");
33
- const GenericMessageMapper_1 = require("./GenericMessageMapper");
34
- class CryptographyService {
35
- constructor(apiClient, storeEngine, config) {
36
- this.apiClient = apiClient;
37
- this.storeEngine = storeEngine;
38
- this.config = config;
39
- this.cryptobox = new cryptobox_1.Cryptobox(this.storeEngine, config.nbPrekeys);
40
- this.database = new CryptographyDatabaseRepository_1.CryptographyDatabaseRepository(this.storeEngine);
41
- this.logger = (0, logdown_1.default)('@wireapp/core/cryptography/CryptographyService', {
42
- logger: console,
43
- markdown: false,
44
- });
45
- }
46
- constructSessionId(userId, clientId, domain) {
47
- const { id, domain: baseDomain } = typeof userId === 'string' ? { id: userId, domain } : userId;
48
- const baseId = `${id}@${clientId}`;
49
- return baseDomain && this.config.useQualifiedIds ? `${baseDomain}@${baseId}` : baseId;
50
- }
51
- static convertArrayRecipientsToBase64(recipients) {
52
- return Object.fromEntries(Object.entries(recipients).map(([userId, otrClientMap]) => {
53
- const otrClientMapWithBase64 = Object.fromEntries(Object.entries(otrClientMap).map(([clientId, payload]) => {
54
- return [clientId, bazinga64_1.Encoder.toBase64(payload).asString];
55
- }));
56
- return [userId, otrClientMapWithBase64];
57
- }));
58
- }
59
- static convertBase64RecipientsToArray(recipients) {
60
- return Object.fromEntries(Object.entries(recipients).map(([userId, otrClientMap]) => {
61
- const otrClientMapWithUint8Array = Object.fromEntries(Object.entries(otrClientMap).map(([clientId, payload]) => {
62
- return [clientId, bazinga64_1.Decoder.fromBase64(payload).asBytes];
63
- }));
64
- return [userId, otrClientMapWithUint8Array];
65
- }));
66
- }
67
- async createCryptobox(entropyData) {
68
- const initialPreKeys = await this.cryptobox.create(entropyData);
69
- return initialPreKeys
70
- .map(preKey => {
71
- const preKeyJson = this.cryptobox.serialize_prekey(preKey);
72
- if (preKeyJson.id !== proteus_1.keys.PreKey.MAX_PREKEY_ID) {
73
- return preKeyJson;
74
- }
75
- return { id: -1, key: '' };
76
- })
77
- .filter(serializedPreKey => serializedPreKey.key);
78
- }
79
- decrypt(sessionId, encodedCiphertext) {
80
- this.logger.log(`Decrypting message for session ID "${sessionId}"`);
81
- const messageBytes = bazinga64_1.Decoder.fromBase64(encodedCiphertext).asBytes;
82
- return this.cryptobox.decrypt(sessionId, messageBytes.buffer);
83
- }
84
- async encryptQualified(plainText, preKeyBundles) {
85
- const qualifiedOTRRecipients = {};
86
- const missing = {};
87
- for (const [domain, preKeyBundleMap] of Object.entries(preKeyBundles)) {
88
- const result = await this.encrypt(plainText, preKeyBundleMap, domain);
89
- qualifiedOTRRecipients[domain] = result.encrypted;
90
- missing[domain] = result.missing;
91
- }
92
- return {
93
- encrypted: qualifiedOTRRecipients,
94
- missing,
95
- };
96
- }
97
- async encrypt(plainText, users, domain) {
98
- var _a;
99
- const encrypted = {};
100
- const missing = {};
101
- for (const userId in users) {
102
- const clientIds = (0, util_1.isUserClients)(users)
103
- ? users[userId]
104
- : Object.keys(users[userId])
105
- // We filter out clients that have `null` prekey
106
- .filter(clientId => !!users[userId][clientId]);
107
- for (const clientId of clientIds) {
108
- const base64PreKey = (0, util_1.isUserClients)(users) ? undefined : (_a = users[userId][clientId]) === null || _a === void 0 ? void 0 : _a.key;
109
- const sessionId = this.constructSessionId(userId, clientId, domain);
110
- const result = await this.encryptPayloadForSession(sessionId, plainText, base64PreKey);
111
- if (result) {
112
- encrypted[userId] || (encrypted[userId] = {});
113
- encrypted[userId][clientId] = result.encryptedPayload;
114
- }
115
- else {
116
- missing[userId] || (missing[userId] = []);
117
- missing[userId].push(clientId);
118
- }
119
- }
120
- }
121
- return { encrypted, missing };
122
- }
123
- async encryptPayloadForSession(sessionId, plainText, base64EncodedPreKey) {
124
- this.logger.log(`Encrypting payload for session ID "${sessionId}"`);
125
- let encryptedPayload;
126
- try {
127
- const decodedPreKeyBundle = base64EncodedPreKey
128
- ? bazinga64_1.Decoder.fromBase64(base64EncodedPreKey).asBytes.buffer
129
- : undefined;
130
- const payloadAsArrayBuffer = await this.cryptobox.encrypt(sessionId, plainText, decodedPreKeyBundle);
131
- encryptedPayload = new Uint8Array(payloadAsArrayBuffer);
132
- }
133
- catch (error) {
134
- const notFoundErrorCode = 2;
135
- if (error.code === notFoundErrorCode) {
136
- // If the session is not in the database, we just return undefined. Later on there will be a mismatch and the session will be created
137
- return undefined;
138
- }
139
- this.logger.error(`Could not encrypt payload: ${error.message}`);
140
- encryptedPayload = new Uint8Array(Buffer.from('💣', 'utf-8'));
141
- }
142
- return { encryptedPayload, sessionId };
143
- }
144
- async initCryptobox() {
145
- await this.cryptobox.load();
146
- }
147
- deleteCryptographyStores() {
148
- return this.database.deleteStores();
149
- }
150
- async resetSession(sessionId) {
151
- await this.cryptobox.session_delete(sessionId);
152
- this.logger.log(`Deleted session ID "${sessionId}".`);
153
- }
154
- async decryptMessage(otrMessage) {
155
- const { from, qualified_from, data: { sender, text: cipherText }, } = otrMessage;
156
- const sessionId = this.constructSessionId(from, sender, qualified_from === null || qualified_from === void 0 ? void 0 : qualified_from.domain);
157
- try {
158
- const decryptedMessage = await this.decrypt(sessionId, cipherText);
159
- return protocol_messaging_1.GenericMessage.decode(decryptedMessage);
160
- }
161
- catch (error) {
162
- throw this.generateDecryptionError(otrMessage, error);
163
- }
164
- }
165
- mapGenericMessage(otrMessage, genericMessage, source) {
166
- if (genericMessage.content === conversation_1.GenericMessageType.EPHEMERAL) {
167
- const unwrappedMessage = GenericMessageMapper_1.GenericMessageMapper.mapGenericMessage(genericMessage.ephemeral, otrMessage, source);
168
- unwrappedMessage.id = genericMessage.messageId;
169
- if (genericMessage.ephemeral) {
170
- const expireAfterMillis = genericMessage.ephemeral.expireAfterMillis;
171
- unwrappedMessage.messageTimer =
172
- typeof expireAfterMillis === 'number' ? expireAfterMillis : expireAfterMillis.toNumber();
173
- }
174
- return unwrappedMessage;
175
- }
176
- return GenericMessageMapper_1.GenericMessageMapper.mapGenericMessage(genericMessage, otrMessage, source);
177
- }
178
- generateDecryptionError(event, error) {
179
- var _a;
180
- const errorCode = (_a = error.code) !== null && _a !== void 0 ? _a : 999;
181
- let message = 'Unknown decryption error';
182
- const { data: eventData, from: remoteUserId, time: formattedTime } = event;
183
- const remoteClientId = eventData.sender;
184
- const isDuplicateMessage = error instanceof proteus_1.errors.DecryptError.DuplicateMessage;
185
- const isOutdatedMessage = error instanceof proteus_1.errors.DecryptError.OutdatedMessage;
186
- // We don't need to show these message errors to the user
187
- if (isDuplicateMessage || isOutdatedMessage) {
188
- message = `Message from user ID "${remoteUserId}" at "${formattedTime}" will not be handled because it is outdated or a duplicate.`;
189
- }
190
- const isInvalidMessage = error instanceof proteus_1.errors.DecryptError.InvalidMessage;
191
- const isInvalidSignature = error instanceof proteus_1.errors.DecryptError.InvalidSignature;
192
- const isRemoteIdentityChanged = error instanceof proteus_1.errors.DecryptError.RemoteIdentityChanged;
193
- // Session is broken, let's see what's really causing it...
194
- if (isInvalidMessage || isInvalidSignature) {
195
- message = `Session with user '${remoteUserId}' (${remoteClientId}) is broken.\nReset the session for possible fix.`;
196
- }
197
- else if (isRemoteIdentityChanged) {
198
- message = `Remote identity of client '${remoteClientId}' from user '${remoteUserId}' changed`;
199
- }
200
- this.logger.warn(`Failed to decrypt event from client '${remoteClientId}' of user '${remoteUserId}' (${formattedTime}).\nError Code: '${errorCode}'\nError Message: ${error.message}`, error);
201
- return { code: errorCode, message };
202
- }
203
- }
204
- exports.CryptographyService = CryptographyService;
205
- //# sourceMappingURL=CryptographyService.js.map
@@ -1,6 +0,0 @@
1
- import type { ConversationOtrMessageAddEvent } from '@wireapp/api-client/src/event/';
2
- import { PayloadBundle, PayloadBundleSource } from '../conversation';
3
- export declare class GenericMessageMapper {
4
- private static readonly logger;
5
- static mapGenericMessage(genericMessage: any, event: ConversationOtrMessageAddEvent, source: PayloadBundleSource): PayloadBundle;
6
- }
@@ -1,160 +0,0 @@
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.GenericMessageMapper = void 0;
25
- const logdown_1 = __importDefault(require("logdown"));
26
- const conversation_1 = require("../conversation");
27
- class GenericMessageMapper {
28
- // TODO: Turn "any" into a specific type (or collection of types) and make the return type more specific based on the
29
- // "genericMessage" input parameter.
30
- static mapGenericMessage(genericMessage, event, source) {
31
- const baseMessage = {
32
- conversation: event.conversation,
33
- qualifiedConversation: event.qualified_conversation,
34
- qualifiedFrom: event.qualified_from,
35
- fromClientId: event.data.sender,
36
- from: event.from,
37
- state: conversation_1.PayloadBundleState.INCOMING,
38
- timestamp: new Date(event.time).getTime(),
39
- id: genericMessage.messageId,
40
- messageTimer: 0,
41
- source,
42
- };
43
- switch (genericMessage.content) {
44
- case conversation_1.GenericMessageType.TEXT: {
45
- const { content: text, expectsReadConfirmation, legalHoldStatus, linkPreview: linkPreviews, mentions, quote, } = genericMessage[conversation_1.GenericMessageType.TEXT];
46
- const content = { expectsReadConfirmation, legalHoldStatus, text };
47
- if (linkPreviews === null || linkPreviews === void 0 ? void 0 : linkPreviews.length) {
48
- content.linkPreviews = linkPreviews;
49
- }
50
- if (mentions === null || mentions === void 0 ? void 0 : mentions.length) {
51
- content.mentions = mentions;
52
- }
53
- if (quote) {
54
- content.quote = quote;
55
- }
56
- if (typeof legalHoldStatus !== 'undefined') {
57
- content.legalHoldStatus = legalHoldStatus;
58
- }
59
- return Object.assign(Object.assign({}, baseMessage), { content, type: conversation_1.PayloadBundleType.TEXT });
60
- }
61
- case conversation_1.GenericMessageType.BUTTON_ACTION: {
62
- return Object.assign(Object.assign({}, baseMessage), { content: genericMessage.buttonAction, type: conversation_1.PayloadBundleType.BUTTON_ACTION });
63
- }
64
- case conversation_1.GenericMessageType.CALLING: {
65
- return Object.assign(Object.assign({}, baseMessage), { content: genericMessage.calling.content, type: conversation_1.PayloadBundleType.CALL });
66
- }
67
- case conversation_1.GenericMessageType.CONFIRMATION: {
68
- const { firstMessageId, moreMessageIds, type } = genericMessage[conversation_1.GenericMessageType.CONFIRMATION];
69
- const content = { firstMessageId, moreMessageIds, type };
70
- return Object.assign(Object.assign({}, baseMessage), { content, type: conversation_1.PayloadBundleType.CONFIRMATION });
71
- }
72
- case conversation_1.GenericMessageType.CLEARED: {
73
- const content = genericMessage[conversation_1.GenericMessageType.CLEARED];
74
- return Object.assign(Object.assign({}, baseMessage), { content, type: conversation_1.PayloadBundleType.CONVERSATION_CLEAR });
75
- }
76
- case conversation_1.GenericMessageType.DELETED: {
77
- const originalMessageId = genericMessage[conversation_1.GenericMessageType.DELETED].messageId;
78
- const content = { messageId: originalMessageId };
79
- return Object.assign(Object.assign({}, baseMessage), { content, type: conversation_1.PayloadBundleType.MESSAGE_DELETE });
80
- }
81
- case conversation_1.GenericMessageType.EDITED: {
82
- const { expectsReadConfirmation, text: { content: editedText, legalHoldStatus, linkPreview: editedLinkPreviews, mentions: editedMentions, quote: editedQuote, }, replacingMessageId, } = genericMessage[conversation_1.GenericMessageType.EDITED];
83
- const content = {
84
- expectsReadConfirmation,
85
- legalHoldStatus,
86
- originalMessageId: replacingMessageId,
87
- text: editedText,
88
- };
89
- if (editedLinkPreviews === null || editedLinkPreviews === void 0 ? void 0 : editedLinkPreviews.length) {
90
- content.linkPreviews = editedLinkPreviews;
91
- }
92
- if (editedMentions === null || editedMentions === void 0 ? void 0 : editedMentions.length) {
93
- content.mentions = editedMentions;
94
- }
95
- if (editedQuote) {
96
- content.quote = editedQuote;
97
- }
98
- return Object.assign(Object.assign({}, baseMessage), { content, type: conversation_1.PayloadBundleType.MESSAGE_EDIT });
99
- }
100
- case conversation_1.GenericMessageType.HIDDEN: {
101
- const { conversationId, messageId } = genericMessage[conversation_1.GenericMessageType.HIDDEN];
102
- const content = {
103
- conversationId,
104
- messageId,
105
- };
106
- return Object.assign(Object.assign({}, baseMessage), { content, type: conversation_1.PayloadBundleType.MESSAGE_HIDE });
107
- }
108
- case conversation_1.GenericMessageType.KNOCK: {
109
- const { expectsReadConfirmation, legalHoldStatus } = genericMessage[conversation_1.GenericMessageType.KNOCK];
110
- const content = { expectsReadConfirmation, hotKnock: false, legalHoldStatus };
111
- return Object.assign(Object.assign({}, baseMessage), { content, type: conversation_1.PayloadBundleType.PING });
112
- }
113
- case conversation_1.GenericMessageType.LOCATION: {
114
- const { expectsReadConfirmation, latitude, legalHoldStatus, longitude, name, zoom } = genericMessage[conversation_1.GenericMessageType.LOCATION];
115
- const content = {
116
- expectsReadConfirmation,
117
- latitude,
118
- legalHoldStatus,
119
- longitude,
120
- name,
121
- zoom,
122
- };
123
- return Object.assign(Object.assign({}, baseMessage), { content, type: conversation_1.PayloadBundleType.LOCATION });
124
- }
125
- case conversation_1.GenericMessageType.ASSET: {
126
- const { expectsReadConfirmation, legalHoldStatus, notUploaded, original, preview, status, uploaded } = genericMessage[conversation_1.GenericMessageType.ASSET];
127
- const isImage = !!(uploaded === null || uploaded === void 0 ? void 0 : uploaded.assetId) && !!(original === null || original === void 0 ? void 0 : original.image);
128
- const content = {
129
- abortReason: notUploaded,
130
- expectsReadConfirmation,
131
- legalHoldStatus,
132
- original,
133
- preview,
134
- status,
135
- uploaded,
136
- };
137
- return Object.assign(Object.assign({}, baseMessage), { content, type: isImage ? conversation_1.PayloadBundleType.ASSET_IMAGE : conversation_1.PayloadBundleType.ASSET });
138
- }
139
- case conversation_1.GenericMessageType.REACTION: {
140
- const { emoji, legalHoldStatus, messageId } = genericMessage[conversation_1.GenericMessageType.REACTION];
141
- const content = {
142
- legalHoldStatus,
143
- originalMessageId: messageId,
144
- type: emoji,
145
- };
146
- return Object.assign(Object.assign({}, baseMessage), { content, type: conversation_1.PayloadBundleType.REACTION });
147
- }
148
- default: {
149
- this.logger.warn(`Unhandled event type "${genericMessage.content}": ${JSON.stringify(genericMessage)}`);
150
- return Object.assign(Object.assign({}, baseMessage), { content: genericMessage.content, type: conversation_1.PayloadBundleType.UNKNOWN });
151
- }
152
- }
153
- }
154
- }
155
- exports.GenericMessageMapper = GenericMessageMapper;
156
- GenericMessageMapper.logger = (0, logdown_1.default)('@wireapp/core/cryptography/GenericMessageMapper', {
157
- logger: console,
158
- markdown: false,
159
- });
160
- //# sourceMappingURL=GenericMessageMapper.js.map
@@ -1,16 +0,0 @@
1
- /// <reference types="node" />
2
- import { AssetContent, LocationContent, TextContent } from '../conversation/content';
3
- export declare type AvailableMessageContent = AssetContent | LocationContent | TextContent;
4
- export declare class MessageHashService {
5
- private readonly messageContent;
6
- private readonly timestamp;
7
- constructor(messageContent: AvailableMessageContent, timestamp?: number);
8
- private createSha256Hash;
9
- private convertToUtf16BE;
10
- private getAssetBytes;
11
- private getTimestampBuffer;
12
- private getLocationBytes;
13
- private getTextBytes;
14
- private getBytes;
15
- getHash(): Buffer;
16
- }
@@ -1,114 +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
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
21
- if (k2 === undefined) k2 = k;
22
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
23
- }) : (function(o, m, k, k2) {
24
- if (k2 === undefined) k2 = k;
25
- o[k2] = m[k];
26
- }));
27
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
28
- Object.defineProperty(o, "default", { enumerable: true, value: v });
29
- }) : function(o, v) {
30
- o["default"] = v;
31
- });
32
- var __importStar = (this && this.__importStar) || function (mod) {
33
- if (mod && mod.__esModule) return mod;
34
- var result = {};
35
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
36
- __setModuleDefault(result, mod);
37
- return result;
38
- };
39
- var __importDefault = (this && this.__importDefault) || function (mod) {
40
- return (mod && mod.__esModule) ? mod : { "default": mod };
41
- };
42
- Object.defineProperty(exports, "__esModule", { value: true });
43
- exports.MessageHashService = void 0;
44
- const hash = __importStar(require("hash.js"));
45
- const long_1 = __importDefault(require("long"));
46
- const content_1 = require("../conversation/content");
47
- class MessageHashService {
48
- constructor(messageContent, timestamp = Date.now()) {
49
- this.messageContent = messageContent;
50
- const unixTimestamp = new Date(timestamp).getTime();
51
- this.timestamp = Math.floor(unixTimestamp / 1e3);
52
- }
53
- createSha256Hash(buffer) {
54
- const hashArray = hash.sha256().update(buffer).digest();
55
- return Buffer.from(hashArray);
56
- }
57
- convertToUtf16BE(str) {
58
- const BOMChar = '\uFEFF';
59
- str = `${BOMChar}${str}`;
60
- const buffer = Buffer.from(str, 'ucs2');
61
- for (let index = 0; index < buffer.length; index += 2) {
62
- const tempValue = buffer[index];
63
- buffer[index] = buffer[index + 1];
64
- buffer[index + 1] = tempValue;
65
- }
66
- return buffer;
67
- }
68
- getAssetBytes(content) {
69
- if (content.uploaded) {
70
- const assetId = content.uploaded.assetId;
71
- return this.convertToUtf16BE(assetId);
72
- }
73
- return Buffer.from([]);
74
- }
75
- getTimestampBuffer(timestamp) {
76
- const timestampBytes = long_1.default.fromInt(timestamp).toBytesBE();
77
- return Buffer.from(timestampBytes);
78
- }
79
- getLocationBytes(content) {
80
- const latitudeApproximate = Math.round(content.latitude * 1000);
81
- const longitudeApproximate = Math.round(content.longitude * 1000);
82
- const latitudeLong = long_1.default.fromInt(latitudeApproximate).toBytesBE();
83
- const longitudeLong = long_1.default.fromInt(longitudeApproximate).toBytesBE();
84
- const latitudeBuffer = Buffer.from(latitudeLong);
85
- const longitudeBuffer = Buffer.from(longitudeLong);
86
- return Buffer.concat([latitudeBuffer, longitudeBuffer]);
87
- }
88
- getTextBytes(content) {
89
- return this.convertToUtf16BE(content.text);
90
- }
91
- getBytes(content) {
92
- let bytes;
93
- if (content_1.ContentType.isLocationContent(content)) {
94
- bytes = this.getLocationBytes(content);
95
- }
96
- else if (content_1.ContentType.isTextContent(content)) {
97
- bytes = this.getTextBytes(content);
98
- }
99
- else if (content_1.ContentType.isAssetContent(content)) {
100
- bytes = this.getAssetBytes(content);
101
- }
102
- else {
103
- throw new Error(`Unknown message type. ${content}`);
104
- }
105
- const timestampBuffer = this.getTimestampBuffer(this.timestamp);
106
- return Buffer.concat([bytes, timestampBuffer]);
107
- }
108
- getHash() {
109
- const buffer = this.getBytes(this.messageContent);
110
- return this.createSha256Hash(buffer);
111
- }
112
- }
113
- exports.MessageHashService = MessageHashService;
114
- //# sourceMappingURL=MessageHashService.js.map
@@ -1,4 +0,0 @@
1
- export interface SessionPayloadBundle {
2
- encryptedPayload: Uint8Array;
3
- sessionId: string;
4
- }
@@ -1,21 +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
- //# sourceMappingURL=SessionPayloadBundle.js.map
@@ -1,4 +0,0 @@
1
- export * from './CryptographyService';
2
- export * from './AssetCryptography/EncryptedAsset';
3
- export * from './SessionPayloadBundle';
4
- export * from './MessageHashService';
@@ -1,35 +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
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
21
- if (k2 === undefined) k2 = k;
22
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
23
- }) : (function(o, m, k, k2) {
24
- if (k2 === undefined) k2 = k;
25
- o[k2] = m[k];
26
- }));
27
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
28
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
29
- };
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- __exportStar(require("./CryptographyService"), exports);
32
- __exportStar(require("./AssetCryptography/EncryptedAsset"), exports);
33
- __exportStar(require("./SessionPayloadBundle"), exports);
34
- __exportStar(require("./MessageHashService"), exports);
35
- //# sourceMappingURL=index.js.map
@@ -1,9 +0,0 @@
1
- import type { APIClient } from '@wireapp/api-client';
2
- import type { GiphySearchOptions, GiphyMultipleResult, GiphyResult, GIPHY_RATING } from '@wireapp/api-client/src/giphy/';
3
- export declare class GiphyService {
4
- private readonly apiClient;
5
- constructor(apiClient: APIClient);
6
- getRandomGif(tag?: string, rating?: GIPHY_RATING): Promise<GiphyResult>;
7
- getTrendingGif(rating?: GIPHY_RATING): Promise<GiphyMultipleResult>;
8
- searchGif(options: GiphySearchOptions): Promise<GiphyMultipleResult>;
9
- }
@@ -1,37 +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
- exports.GiphyService = void 0;
22
- class GiphyService {
23
- constructor(apiClient) {
24
- this.apiClient = apiClient;
25
- }
26
- getRandomGif(tag, rating) {
27
- return this.apiClient.api.giphy.getGiphyRandom({ rating, tag });
28
- }
29
- getTrendingGif(rating) {
30
- return this.apiClient.api.giphy.getGiphyTrending({ rating });
31
- }
32
- searchGif(options) {
33
- return this.apiClient.api.giphy.getGiphySearch(options);
34
- }
35
- }
36
- exports.GiphyService = GiphyService;
37
- //# sourceMappingURL=GiphyService.js.map
@@ -1 +0,0 @@
1
- export * from './GiphyService';
@@ -1,32 +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
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
21
- if (k2 === undefined) k2 = k;
22
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
23
- }) : (function(o, m, k, k2) {
24
- if (k2 === undefined) k2 = k;
25
- o[k2] = m[k];
26
- }));
27
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
28
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
29
- };
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- __exportStar(require("./GiphyService"), exports);
32
- //# sourceMappingURL=index.js.map