@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,246 +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
- import {APIClient} from '@wireapp/api-client';
21
- import {Cryptobox} from '@wireapp/cryptobox';
22
- import * as Proteus from '@wireapp/proteus';
23
- import {CRUDEngine, MemoryEngine} from '@wireapp/store-engine';
24
- import * as bazinga64 from 'bazinga64';
25
- import * as crypto from 'crypto';
26
- import {promisify} from 'util';
27
- import {SessionPayloadBundle} from '.';
28
-
29
- import * as CryptographyHelper from '../test/CryptographyHelper';
30
- import {decryptAsset, encryptAsset} from './AssetCryptography.node';
31
- import {CryptographyService} from './CryptographyService';
32
-
33
- async function createEngine(storeName: string): Promise<CRUDEngine> {
34
- const engine = new MemoryEngine();
35
- await engine.init(storeName);
36
- return engine;
37
- }
38
-
39
- describe('CryptographyService', () => {
40
- let cryptographyService: CryptographyService;
41
- let aliceLastResortPreKey: Proteus.keys.PreKey;
42
- let bob: Cryptobox;
43
-
44
- beforeAll(async () => {
45
- await Proteus.init();
46
- });
47
-
48
- beforeEach(async () => {
49
- cryptographyService = new CryptographyService(new APIClient(), await createEngine('wire'));
50
- const preKeys = await cryptographyService.cryptobox.create();
51
- aliceLastResortPreKey = preKeys.filter(preKey => preKey.key_id === Proteus.keys.PreKey.MAX_PREKEY_ID)[0];
52
- bob = new Cryptobox(await createEngine('wire'));
53
- await bob.create();
54
- });
55
-
56
- describe('"constructor"', () => {
57
- it('creates an instance.', () => {
58
- expect(cryptographyService.cryptobox['identity']!.public_key.fingerprint()).toBeDefined();
59
- expect(cryptographyService).toBeDefined();
60
- });
61
- });
62
-
63
- describe('"constructSessionId"', () => {
64
- it('constructs a Session ID by a given User ID and Client ID.', () => {
65
- const clientId = '1ceb9063fced26d3';
66
- const userId = 'afbb5d60-1187-4385-9c29-7361dea79647';
67
- const actual = CryptographyService.constructSessionId(userId, clientId, null);
68
- expect(actual).toContain(clientId);
69
- expect(actual).toContain(userId);
70
- });
71
-
72
- it('constructs a Session ID by a given User ID and Client ID and domain.', () => {
73
- const clientId = '1ceb9063fced26d3';
74
- const userId = 'afbb5d60-1187-4385-9c29-7361dea79647';
75
- const actual = CryptographyService.constructSessionId(userId, clientId, 'test.wire.link');
76
- expect(actual).toContain(clientId);
77
- expect(actual).toContain(userId);
78
- expect(actual).toContain('test.wire.link');
79
- });
80
- });
81
-
82
- describe('"decrypt"', () => {
83
- it('decrypts a Base64-encoded cipher message.', async () => {
84
- const alicePublicKey = cryptographyService.cryptobox['identity']!.public_key;
85
- const publicPreKeyBundle = new Proteus.keys.PreKeyBundle(alicePublicKey, aliceLastResortPreKey);
86
- const text = 'Hello Alice!';
87
- const encryptedPreKeyMessage = await bob.encrypt(
88
- 'alice-user-id@alice-client-id',
89
- text,
90
- publicPreKeyBundle.serialise(),
91
- );
92
- const encodedPreKeyMessage = bazinga64.Encoder.toBase64(encryptedPreKeyMessage).asString;
93
- const decryptedMessage = await cryptographyService.decrypt('bob-user-id@bob-client-id', encodedPreKeyMessage);
94
- const plaintext = Buffer.from(decryptedMessage).toString('utf8');
95
- expect(plaintext).toBe(text);
96
- });
97
-
98
- it('is resistant to duplicated message errors', async () => {
99
- const receiver = cryptographyService.cryptobox['identity']!;
100
- const preKey = await cryptographyService.cryptobox['get_prekey']();
101
- const text = 'Hi!';
102
- const encodedPreKeyMessage = await CryptographyHelper.createEncodedCipherText(receiver, preKey!, text);
103
- const sessionId = 'alice-to-bob';
104
- const plaintext = await CryptographyHelper.getPlainText(cryptographyService, encodedPreKeyMessage, sessionId);
105
- // Testing to decrypt the same message multiple times (to provoke duplicate message errors)
106
- await CryptographyHelper.getPlainText(cryptographyService, encodedPreKeyMessage, sessionId);
107
- await CryptographyHelper.getPlainText(cryptographyService, encodedPreKeyMessage, sessionId);
108
- await CryptographyHelper.getPlainText(cryptographyService, encodedPreKeyMessage, sessionId);
109
- expect(plaintext).toBe(text);
110
- });
111
- });
112
-
113
- describe('"dismantleSessionId"', () => {
114
- const clientId = '1ceb9063fced26d3';
115
- const userId = 'afbb5d60-1187-4385-9c29-7361dea79647';
116
- const domain = 'domain.wire.link';
117
-
118
- it('gets User ID and Client ID from a Session ID without domain.', () => {
119
- const sessionId = CryptographyService.constructSessionId(userId, clientId, null);
120
- const res = CryptographyService['dismantleSessionId'](sessionId);
121
- expect(res.clientId).toBe(clientId);
122
- expect(res.userId).toBe(userId);
123
- expect(res.domain).toBe(undefined);
124
- });
125
-
126
- it('gets User ID and Client ID from a Session ID with domain.', () => {
127
- const sessionId = CryptographyService.constructSessionId(userId, clientId, domain);
128
- const res = CryptographyService['dismantleSessionId'](sessionId);
129
- expect(res.clientId).toBe(clientId);
130
- expect(res.userId).toBe(userId);
131
- expect(res.domain).toBe(domain);
132
- });
133
- });
134
-
135
- describe('"encrypt"', () => {
136
- it('generates a set of encrypted data based on PreKeys from multiple clients.', async () => {
137
- const firstUserID = 'bc0c99f1-49a5-4ad2-889a-62885af37088';
138
- const secondUserID = '2bde49aa-bdb5-458f-98cf-7d3552b10916';
139
-
140
- const firstClientId = '2b83ee08d7ac550d';
141
-
142
- const preKeyBundleMap = {
143
- [firstUserID]: {
144
- '5e80ea7886680975': {
145
- id: 1337,
146
- key: 'pQABARn//wKhAFggJ1Fbpg5l6wnzKOJE+vXpRnkqUYhIvVnR5lNXEbO2o/0DoQChAFggHxZvgvtDktY/vqBcpjjo6rQnXvcNQhfwmy8AJQJKlD0E9g==',
147
- },
148
- be67218b77d02d30: {
149
- id: 72,
150
- key: 'pQABARn//wKhAFggTWwHUoppQ8aXWhbH95YWnNp6uOYMxo2y4wbarWbF+EEDoQChAFggUiFoPtsiR0WFowIvl0myD+bVnFQJBYarqieI0Gly46QE9g==',
151
- },
152
- [firstClientId]: {
153
- id: 42,
154
- key: 'pQABARn//wKhAFggWcbwny0jdqlcnnn0j4QSENIVVq/KgyQ3mmdpunfvGZQDoQChAFggrsQBkQkrVZ8sWhr8wTeaC+dmctuJ3oRqfdHsymTtKmgE9g==',
155
- },
156
- },
157
- [secondUserID]: {
158
- '5bad8cdeddc5a90f': {
159
- id: 1,
160
- key: 'pQABARn//wKhAFggEYATUNJBQ7E2tfHT7HMLxa4O3Ckd7PciUdyKiGNNWbYDoQChAFggP/s0BHmHQDNwrO4pC1dqdNHsW7bnpmF9mBadrbep4PoE9g==',
161
- },
162
- bc78eded90386d20: {
163
- id: 65535,
164
- key: 'pQABARn//wKhAFgg1xOfzMpWmpN2aBGW+0RG23L0I301pncd/HXqUm+pVyoDoQChAFggnl+dmwGW45AArcPutjUkAjYmhIbXBPrqkVrNyg0ZI08E9g==',
165
- },
166
- },
167
- };
168
- const text = new Uint8Array(Buffer.from('Hello', 'utf8'));
169
- const otrBundle = await cryptographyService.encrypt(text, preKeyBundleMap);
170
- expect(Object.keys(otrBundle).length).toBe(2);
171
- expect(Object.keys(otrBundle[firstUserID]).length).toBe(3);
172
- expect(Object.keys(otrBundle[secondUserID]).length).toBe(2);
173
- expect(otrBundle[firstUserID][firstClientId]).toEqual(jasmine.any(Uint8Array));
174
- });
175
-
176
- it('does not generate a message counter twice when ran asynchronously multiple times for the same cryptographic session', async () => {
177
- const userId = 'bc0c99f1-49a5-4ad2-889a-62885af37088';
178
- const clientId = '5e80ea7886680975';
179
- const preKeyBundleMap = {
180
- [userId]: {
181
- [clientId]: {
182
- id: 1337,
183
- key: 'pQABARn//wKhAFggJ1Fbpg5l6wnzKOJE+vXpRnkqUYhIvVnR5lNXEbO2o/0DoQChAFggHxZvgvtDktY/vqBcpjjo6rQnXvcNQhfwmy8AJQJKlD0E9g==',
184
- },
185
- },
186
- };
187
- const text = new Uint8Array([72, 101, 108, 108, 111, 33]); // "Hello!"
188
- const encryptionRuns = 100;
189
- const otrBundles = await Promise.all(
190
- Array.from(Array(encryptionRuns).keys()).map(() => cryptographyService.encrypt(text, preKeyBundleMap)),
191
- );
192
- const encryptedPayloads = otrBundles.map(bundle => bundle[userId][clientId]);
193
- const messageCounters = encryptedPayloads.map(encodedCiphertext => {
194
- const messageBytes = encodedCiphertext;
195
- const messageEnvelope = Proteus.message.Envelope.deserialise(messageBytes.buffer);
196
- const preKeyMessage = messageEnvelope.message as Proteus.message.PreKeyMessage;
197
- const cipherMessage = preKeyMessage.message;
198
- return cipherMessage.counter;
199
- });
200
- const uniqueValues = messageCounters.filter((value, index, self) => self.indexOf(value) === index);
201
- expect(uniqueValues.length).toBe(encryptionRuns);
202
- });
203
- });
204
-
205
- describe('"encryptAsset"', () => {
206
- it('encrypts and decrypts ArrayBuffer', async () => {
207
- const bytes = new Uint8Array(16);
208
- await promisify(crypto.randomFill)(bytes);
209
- const byteBuffer = Buffer.from(bytes.buffer);
210
-
211
- const encryptedAsset = await encryptAsset({plainText: byteBuffer});
212
- const decryptedBuffer = await decryptAsset(encryptedAsset);
213
-
214
- expect(decryptedBuffer).toEqual(byteBuffer);
215
- });
216
- });
217
-
218
- describe('"encryptPayloadForSession"', () => {
219
- it('encodes plaintext.', async () => {
220
- const sessionWithBobId = 'bob-user-id@bob-client-id';
221
- const text = new Uint8Array([72, 101, 108, 108, 111, 32, 66, 111, 98, 33]); // "Hello Bob!"
222
- const encodedPreKey =
223
- 'pQABAQACoQBYIHOFFWPnWlr4sulxUWYoP0A6rsJiBO/Ec3Y914t67CIAA6EAoQBYIPFH5CK/a0YwKEx4n/+U/IPRN+mJXVv++MCs5Z4dLmz4BPY=';
224
- const {sessionId, encryptedPayload} = (await cryptographyService['encryptPayloadForSession'](
225
- sessionWithBobId,
226
- text,
227
- encodedPreKey,
228
- )) as SessionPayloadBundle;
229
- expect(Buffer.from(encryptedPayload).toString('utf8')).not.toBe('💣');
230
- expect(sessionId).toBe(sessionWithBobId);
231
- });
232
-
233
- it('encodes invalid text as Bomb Emoji.', async () => {
234
- const sessionWithBobId = 'bob-user-id@bob-client-id';
235
- const encodedPreKey =
236
- 'pQABAQACoQBYIHOFFWPnWlr4sulxUWYoP0A6rsJiBO/Ec3Y914t67CIAA6EAoQBYIPFH5CK/a0YwKEx4n/+U/IPRN+mJXVv++MCs5Z4dLmz4BPY=';
237
- const {sessionId, encryptedPayload} = (await cryptographyService['encryptPayloadForSession'](
238
- sessionWithBobId,
239
- undefined as any,
240
- encodedPreKey,
241
- )) as SessionPayloadBundle;
242
- expect(Buffer.from(encryptedPayload).toString()).toBe('💣');
243
- expect(sessionId).toBe(sessionWithBobId);
244
- });
245
- });
246
- });
@@ -1,246 +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
- import type {APIClient} from '@wireapp/api-client';
21
- import type {PreKey as SerializedPreKey} from '@wireapp/api-client/src/auth/';
22
- import type {RegisteredClient} from '@wireapp/api-client/src/client/';
23
- import type {
24
- OTRClientMap,
25
- OTRRecipients,
26
- QualifiedOTRRecipients,
27
- QualifiedUserClients,
28
- UserClients,
29
- } from '@wireapp/api-client/src/conversation/';
30
- import type {ConversationOtrMessageAddEvent} from '@wireapp/api-client/src/event';
31
- import type {QualifiedUserPreKeyBundleMap, UserPreKeyBundleMap} from '@wireapp/api-client/src/user/';
32
- import {Cryptobox} from '@wireapp/cryptobox';
33
- import {keys as ProteusKeys} from '@wireapp/proteus';
34
- import {GenericMessage} from '@wireapp/protocol-messaging';
35
- import type {CRUDEngine} from '@wireapp/store-engine';
36
- import {Decoder, Encoder} from 'bazinga64';
37
- import logdown from 'logdown';
38
-
39
- import {GenericMessageType, PayloadBundle, PayloadBundleSource} from '../conversation';
40
- import type {SessionPayloadBundle} from '../cryptography/';
41
- import {isUserClients} from '../util';
42
- import {CryptographyDatabaseRepository} from './CryptographyDatabaseRepository';
43
- import {GenericMessageMapper} from './GenericMessageMapper';
44
-
45
- export interface MetaClient extends RegisteredClient {
46
- meta: {
47
- is_verified?: boolean;
48
- primary_key: string;
49
- };
50
- }
51
-
52
- type CryptographyServiceOptions = {
53
- federationDomain?: string;
54
- };
55
-
56
- export class CryptographyService {
57
- private readonly logger: logdown.Logger;
58
-
59
- public cryptobox: Cryptobox;
60
- private readonly database: CryptographyDatabaseRepository;
61
-
62
- constructor(
63
- readonly apiClient: APIClient,
64
- private readonly storeEngine: CRUDEngine,
65
- private readonly options?: CryptographyServiceOptions,
66
- ) {
67
- this.cryptobox = new Cryptobox(this.storeEngine);
68
- this.database = new CryptographyDatabaseRepository(this.storeEngine);
69
- this.logger = logdown('@wireapp/core/cryptography/CryptographyService', {
70
- logger: console,
71
- markdown: false,
72
- });
73
- this.options = options;
74
- }
75
-
76
- public static constructSessionId(userId: string, clientId: string, domain: string | null): string {
77
- const baseId = `${userId}@${clientId}`;
78
- return domain ? `${domain}@${baseId}` : baseId;
79
- }
80
-
81
- public static convertArrayRecipientsToBase64(recipients: OTRRecipients<Uint8Array>): OTRRecipients<string> {
82
- return Object.fromEntries(
83
- Object.entries(recipients).map(([userId, otrClientMap]) => {
84
- const otrClientMapWithBase64: OTRClientMap<string> = Object.fromEntries(
85
- Object.entries(otrClientMap).map(([clientId, payload]) => {
86
- return [clientId, Encoder.toBase64(payload).asString];
87
- }),
88
- );
89
- return [userId, otrClientMapWithBase64];
90
- }),
91
- );
92
- }
93
-
94
- public static convertBase64RecipientsToArray(recipients: OTRRecipients<string>): OTRRecipients<Uint8Array> {
95
- return Object.fromEntries(
96
- Object.entries(recipients).map(([userId, otrClientMap]) => {
97
- const otrClientMapWithUint8Array: OTRClientMap<Uint8Array> = Object.fromEntries(
98
- Object.entries(otrClientMap).map(([clientId, payload]) => {
99
- return [clientId, Decoder.fromBase64(payload).asBytes];
100
- }),
101
- );
102
- return [userId, otrClientMapWithUint8Array];
103
- }),
104
- );
105
- }
106
-
107
- public async createCryptobox(): Promise<SerializedPreKey[]> {
108
- const initialPreKeys = await this.cryptobox.create();
109
-
110
- return initialPreKeys
111
- .map(preKey => {
112
- const preKeyJson = this.cryptobox.serialize_prekey(preKey);
113
- if (preKeyJson.id !== ProteusKeys.PreKey.MAX_PREKEY_ID) {
114
- return preKeyJson;
115
- }
116
- return {id: -1, key: ''};
117
- })
118
- .filter(serializedPreKey => serializedPreKey.key);
119
- }
120
-
121
- public decrypt(sessionId: string, encodedCiphertext: string): Promise<Uint8Array> {
122
- this.logger.log(`Decrypting message for session ID "${sessionId}"`);
123
- const messageBytes = Decoder.fromBase64(encodedCiphertext).asBytes;
124
- return this.cryptobox.decrypt(sessionId, messageBytes.buffer);
125
- }
126
-
127
- private static dismantleSessionId(sessionId: string): {clientId: string; domain?: string; userId: string} {
128
- // see https://regex101.com/r/c8FtCw/1
129
- const regex = /((?<domain>.+)@)?(?<userId>.+)@(?<clientId>.+)$/g;
130
- const match = regex.exec(sessionId);
131
- const {domain, userId, clientId} = match?.groups || {};
132
- return {clientId, domain, userId};
133
- }
134
-
135
- public async encryptQualified(
136
- plainText: Uint8Array,
137
- preKeyBundles: QualifiedUserPreKeyBundleMap | QualifiedUserClients,
138
- ): Promise<QualifiedOTRRecipients> {
139
- const qualifiedOTRRecipients: QualifiedOTRRecipients = {};
140
-
141
- for (const [domain, preKeyBundleMap] of Object.entries(preKeyBundles)) {
142
- qualifiedOTRRecipients[domain] = await this.encrypt(plainText, preKeyBundleMap, domain);
143
- }
144
-
145
- return qualifiedOTRRecipients;
146
- }
147
-
148
- public async encrypt(
149
- plainText: Uint8Array,
150
- users: UserPreKeyBundleMap | UserClients,
151
- domain?: string,
152
- ): Promise<OTRRecipients<Uint8Array>> {
153
- const bundles: Promise<SessionPayloadBundle | undefined>[] = [];
154
-
155
- for (const userId in users) {
156
- const clientIds = isUserClients(users) ? users[userId] : Object.keys(users[userId]);
157
- for (const clientId of clientIds) {
158
- const base64PreKey = isUserClients(users) ? undefined : users[userId][clientId].key;
159
- const sessionId = CryptographyService.constructSessionId(userId, clientId, domain || null);
160
- bundles.push(this.encryptPayloadForSession(sessionId, plainText, base64PreKey));
161
- }
162
- }
163
-
164
- const payloads = await Promise.all(bundles);
165
-
166
- return payloads.reduce((recipients, payload) => {
167
- if (!payload) {
168
- return recipients;
169
- }
170
- const {encryptedPayload, sessionId} = payload;
171
- const {userId, clientId} = CryptographyService.dismantleSessionId(sessionId);
172
- recipients[userId] ||= {};
173
- recipients[userId][clientId] = encryptedPayload;
174
- return recipients;
175
- }, {} as OTRRecipients<Uint8Array>);
176
- }
177
-
178
- private async encryptPayloadForSession(
179
- sessionId: string,
180
- plainText: Uint8Array,
181
- base64EncodedPreKey?: string,
182
- ): Promise<SessionPayloadBundle | undefined> {
183
- this.logger.log(`Encrypting payload for session ID "${sessionId}"`);
184
-
185
- let encryptedPayload: Uint8Array;
186
-
187
- try {
188
- const decodedPreKeyBundle = base64EncodedPreKey
189
- ? Decoder.fromBase64(base64EncodedPreKey).asBytes.buffer
190
- : undefined;
191
- const payloadAsArrayBuffer = await this.cryptobox.encrypt(sessionId, plainText, decodedPreKeyBundle);
192
- encryptedPayload = new Uint8Array(payloadAsArrayBuffer);
193
- } catch (error) {
194
- const notFoundErrorCode = 2;
195
- if ((error as any).code === notFoundErrorCode) {
196
- // 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
197
- return undefined;
198
- }
199
- this.logger.error(`Could not encrypt payload: ${(error as Error).message}`);
200
- encryptedPayload = new Uint8Array(Buffer.from('💣', 'utf-8'));
201
- }
202
-
203
- return {encryptedPayload, sessionId};
204
- }
205
-
206
- public async initCryptobox(): Promise<void> {
207
- await this.cryptobox.load();
208
- }
209
-
210
- public deleteCryptographyStores(): Promise<boolean[]> {
211
- return this.database.deleteStores();
212
- }
213
-
214
- public async resetSession(sessionId: string): Promise<void> {
215
- await this.cryptobox.session_delete(sessionId);
216
- this.logger.log(`Deleted session ID "${sessionId}".`);
217
- }
218
-
219
- public async decodeGenericMessage(
220
- otrMessage: ConversationOtrMessageAddEvent,
221
- source: PayloadBundleSource,
222
- ): Promise<PayloadBundle> {
223
- const {
224
- from,
225
- qualified_from,
226
- data: {sender, text: cipherText},
227
- } = otrMessage;
228
-
229
- const domain = this.options?.federationDomain ? qualified_from?.domain || this.options.federationDomain : null;
230
- const sessionId = CryptographyService.constructSessionId(from, sender, domain);
231
- const decryptedMessage = await this.decrypt(sessionId, cipherText);
232
- const genericMessage = GenericMessage.decode(decryptedMessage);
233
-
234
- if (genericMessage.content === GenericMessageType.EPHEMERAL) {
235
- const unwrappedMessage = GenericMessageMapper.mapGenericMessage(genericMessage.ephemeral, otrMessage, source);
236
- unwrappedMessage.id = genericMessage.messageId;
237
- if (genericMessage.ephemeral) {
238
- const expireAfterMillis = genericMessage.ephemeral.expireAfterMillis;
239
- unwrappedMessage.messageTimer =
240
- typeof expireAfterMillis === 'number' ? expireAfterMillis : expireAfterMillis.toNumber();
241
- }
242
- return unwrappedMessage;
243
- }
244
- return GenericMessageMapper.mapGenericMessage(genericMessage, otrMessage, source);
245
- }
246
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"EncryptedAsset.js","sourceRoot":"","sources":["EncryptedAsset.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG"}
@@ -1,30 +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
- export interface EncryptedAsset {
21
- cipherText: Buffer;
22
- keyBytes: Buffer;
23
- /** The SHA-256 sum of `cipherText` */
24
- sha256: Buffer;
25
- }
26
-
27
- export interface EncryptedAssetUploaded extends EncryptedAsset {
28
- key: string;
29
- token: string;
30
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"GenericMessageMapper.js","sourceRoot":"","sources":["GenericMessageMapper.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;AAIH,sDAA8B;AAC9B,kDAMyB;AAezB,MAAa,oBAAoB;IAMvB,MAAM,CAAC,sBAAsB,CACnC,cAA8B,EAC9B,KAAqC,EACrC,MAA2B;QAE3B,MAAM,EAAC,YAAY,EAAE,SAAS,EAAC,GAAG,cAAc,CAAC;QACjD,OAAO;YACL,OAAO,EAAE,YAAa;YACtB,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,YAAY,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM;YAC/B,EAAE,EAAE,SAAS;YACb,YAAY,EAAE,CAAC;YACf,MAAM;YACN,KAAK,EAAE,iCAAkB,CAAC,QAAQ;YAClC,SAAS,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE;YACzC,IAAI,EAAE,gCAAiB,CAAC,aAAa;SACtC,CAAC;IACJ,CAAC;IAED,qHAAqH;IACrH,oCAAoC;IAC7B,MAAM,CAAC,iBAAiB,CAC7B,cAAmB,EACnB,KAAqC,EACrC,MAA2B;QA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