@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,85 +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 {CipherOptions} from '@wireapp/api-client/src/asset';
21
- import * as crypto from 'crypto';
22
-
23
- import type {EncryptedAsset} from '../cryptography/';
24
-
25
- interface EncryptOptions extends CipherOptions {
26
- plainText: Buffer | Uint8Array;
27
- }
28
-
29
- const isEqual = (a: Buffer, b: Buffer): boolean => {
30
- const arrayA = new Uint32Array(a);
31
- const arrayB = new Uint32Array(b);
32
-
33
- const hasSameLength = arrayA.length === arrayB.length;
34
- const hasSameValues = arrayA.every((value, index) => value === arrayB[index]);
35
-
36
- return hasSameLength && hasSameValues;
37
- };
38
-
39
- export const decryptAsset = async ({
40
- cipherText,
41
- keyBytes,
42
- sha256: referenceSha256,
43
- }: EncryptedAsset): Promise<Buffer> => {
44
- const computedSha256 = crypto.createHash('SHA256').update(cipherText).digest();
45
-
46
- if (!isEqual(computedSha256, referenceSha256)) {
47
- throw new Error('Encrypted asset does not match its SHA-256 hash');
48
- }
49
-
50
- const initializationVector = cipherText.slice(0, 16);
51
- const assetCipherText = cipherText.slice(16);
52
-
53
- const decipher = crypto.createDecipheriv('AES-256-CBC', keyBytes, initializationVector);
54
- const decipherUpdated = decipher.update(assetCipherText);
55
- const decipherFinal = decipher.final();
56
-
57
- return Buffer.concat([decipherUpdated, decipherFinal]);
58
- };
59
-
60
- export const encryptAsset = async ({
61
- plainText,
62
- algorithm = 'AES-256-CBC',
63
- hash,
64
- }: EncryptOptions): Promise<EncryptedAsset> => {
65
- const initializationVector = crypto.randomBytes(16);
66
- const keyBytes = crypto.randomBytes(32);
67
-
68
- const cipher = crypto.createCipheriv(algorithm, keyBytes, initializationVector);
69
- const cipherUpdated = cipher.update(plainText);
70
- const cipherFinal = cipher.final();
71
-
72
- const cipherText = Buffer.concat([cipherUpdated, cipherFinal]);
73
-
74
- const ivCipherText = new Uint8Array(initializationVector.byteLength + cipherText.byteLength);
75
- ivCipherText.set(initializationVector, 0);
76
- ivCipherText.set(cipherText, initializationVector.byteLength);
77
-
78
- const computedHash = hash || crypto.createHash('SHA256').update(Buffer.from(ivCipherText.buffer)).digest();
79
-
80
- return {
81
- cipherText: Buffer.from(ivCipherText.buffer),
82
- keyBytes,
83
- sha256: computedHash,
84
- };
85
- };
@@ -1 +0,0 @@
1
- {"version":3,"file":"CryptographyDatabaseRepository.js","sourceRoot":"","sources":["CryptographyDatabaseRepository.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAIH,IAAY,cAMX;AAND,WAAY,cAAc;IACxB,qCAAmB,CAAA;IACnB,qCAAmB,CAAA;IACnB,+BAAa,CAAA;IACb,sCAAoB,CAAA;IACpB,uCAAqB,CAAA;AACvB,CAAC,EANW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAMzB;AAED,MAAa,8BAA8B;IAGzC,YAA6B,WAAuB;QAAvB,gBAAW,GAAX,WAAW,CAAY;IAAG,CAAC;IAEjD,YAAY;QACjB,OAAO,OAAO,CAAC,GAAG,CAAC;YACjB,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,8BAA8B,CAAC,MAAM,CAAC,OAAO,CAAC;YACzE,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,8BAA8B,CAAC,MAAM,CAAC,OAAO,CAAC;YACzE,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,8BAA8B,CAAC,MAAM,CAAC,IAAI,CAAC;YACtE,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,8BAA8B,CAAC,MAAM,CAAC,QAAQ,CAAC;YAC1E,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,8BAA8B,CAAC,MAAM,CAAC,QAAQ,CAAC;SAC3E,CAAC,CAAC;IACL,CAAC;;AAbH,wEAcC;AAbwB,qCAAM,GAAG,cAAc,CAAC"}
@@ -1,44 +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 {CRUDEngine} from '@wireapp/store-engine';
21
-
22
- export enum DatabaseStores {
23
- AMPLIFY = 'amplify',
24
- CLIENTS = 'clients',
25
- KEYS = 'keys',
26
- PRE_KEYS = 'prekeys',
27
- SESSIONS = 'sessions',
28
- }
29
-
30
- export class CryptographyDatabaseRepository {
31
- public static readonly STORES = DatabaseStores;
32
-
33
- constructor(private readonly storeEngine: CRUDEngine) {}
34
-
35
- public deleteStores(): Promise<boolean[]> {
36
- return Promise.all([
37
- this.storeEngine.deleteAll(CryptographyDatabaseRepository.STORES.AMPLIFY),
38
- this.storeEngine.deleteAll(CryptographyDatabaseRepository.STORES.CLIENTS),
39
- this.storeEngine.deleteAll(CryptographyDatabaseRepository.STORES.KEYS),
40
- this.storeEngine.deleteAll(CryptographyDatabaseRepository.STORES.SESSIONS),
41
- this.storeEngine.deleteAll(CryptographyDatabaseRepository.STORES.PRE_KEYS),
42
- ]);
43
- }
44
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"CryptographyService.js","sourceRoot":"","sources":["CryptographyService.ts"],"names":[],"mappings":";AAAA;;;;;;;;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AC;CACF;AA9LD,kDA8LC"}
@@ -1,195 +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
- /* eslint-disable no-magic-numbers */
21
- const bazinga64 = require('bazinga64');
22
- const Proteus = require('@wireapp/proteus');
23
- const {Cryptobox} = require('@wireapp/cryptobox');
24
- const {CryptographyService} = require('@wireapp/core/src/main/cryptography/');
25
- const {MemoryEngine} = require('@wireapp/store-engine');
26
- const {decryptAsset, encryptAsset} = require('@wireapp/core/src/main/cryptography/AssetCryptography.browser');
27
-
28
- async function createEngine(storeName) {
29
- const engine = new MemoryEngine();
30
- await engine.init(storeName);
31
- return engine;
32
- }
33
-
34
- describe('CryptographyService', () => {
35
- let cryptography;
36
- let aliceLastResortPreKey;
37
- let bob;
38
-
39
- beforeAll(async () => {
40
- await Proteus.init();
41
- });
42
-
43
- beforeEach(async () => {
44
- cryptography = new CryptographyService(undefined, await createEngine('wire'), undefined);
45
- const preKeys = await cryptography.cryptobox.create();
46
- aliceLastResortPreKey = preKeys.filter(preKey => preKey.key_id === Proteus.keys.PreKey.MAX_PREKEY_ID)[0];
47
- bob = new Cryptobox(await createEngine('wire'));
48
- return bob.create();
49
- });
50
-
51
- describe('"constructor"', () => {
52
- it('creates an instance.', () => {
53
- expect(cryptography.cryptobox.identity.public_key.fingerprint()).toBeDefined();
54
- expect(cryptography).toBeDefined();
55
- });
56
- });
57
-
58
- describe('"constructSessionId"', () => {
59
- it('constructs a Session ID by a given User ID and Client ID.', () => {
60
- const clientId = '1ceb9063fced26d3';
61
- const userId = 'afbb5d60-1187-4385-9c29-7361dea79647';
62
- const actual = CryptographyService.constructSessionId(userId, clientId);
63
- expect(actual).toContain(clientId);
64
- expect(actual).toContain(userId);
65
- });
66
- });
67
-
68
- describe('"decrypt"', () => {
69
- it('decrypts a Base64-encoded cipher message.', async () => {
70
- const alicePublicKey = cryptography.cryptobox.identity.public_key;
71
- const publicPreKeyBundle = new Proteus.keys.PreKeyBundle(alicePublicKey, aliceLastResortPreKey);
72
- const text = 'Hello Alice!';
73
- const encryptedPreKeyMessage = await bob.encrypt(
74
- 'alice-user-id@alice-client-id',
75
- text,
76
- publicPreKeyBundle.serialise(),
77
- );
78
- const encodedPreKeyMessage = bazinga64.Encoder.toBase64(encryptedPreKeyMessage).asString;
79
- const decryptedMessage = await cryptography.decrypt('bob-user-id@bob-client-id', encodedPreKeyMessage);
80
- const plaintext = Buffer.from(decryptedMessage).toString('utf8');
81
- expect(plaintext).toBe(text);
82
- });
83
- });
84
-
85
- describe('"encrypt"', () => {
86
- it('generates a set of encrypted data based on PreKeys from multiple clients.', async () => {
87
- const firstUserID = 'bc0c99f1-49a5-4ad2-889a-62885af37088';
88
- const secondUserID = '2bde49aa-bdb5-458f-98cf-7d3552b10916';
89
-
90
- const firstClientId = '2b83ee08d7ac550d';
91
-
92
- const preKeyBundleMap = {
93
- [firstUserID]: {
94
- '5e80ea7886680975': {
95
- id: 1337,
96
- key: 'pQABARn//wKhAFggJ1Fbpg5l6wnzKOJE+vXpRnkqUYhIvVnR5lNXEbO2o/0DoQChAFggHxZvgvtDktY/vqBcpjjo6rQnXvcNQhfwmy8AJQJKlD0E9g==',
97
- },
98
- be67218b77d02d30: {
99
- id: 72,
100
- key: 'pQABARn//wKhAFggTWwHUoppQ8aXWhbH95YWnNp6uOYMxo2y4wbarWbF+EEDoQChAFggUiFoPtsiR0WFowIvl0myD+bVnFQJBYarqieI0Gly46QE9g==',
101
- },
102
- [firstClientId]: {
103
- id: 42,
104
- key: 'pQABARn//wKhAFggWcbwny0jdqlcnnn0j4QSENIVVq/KgyQ3mmdpunfvGZQDoQChAFggrsQBkQkrVZ8sWhr8wTeaC+dmctuJ3oRqfdHsymTtKmgE9g==',
105
- },
106
- },
107
- [secondUserID]: {
108
- '5bad8cdeddc5a90f': {
109
- id: 1,
110
- key: 'pQABARn//wKhAFggEYATUNJBQ7E2tfHT7HMLxa4O3Ckd7PciUdyKiGNNWbYDoQChAFggP/s0BHmHQDNwrO4pC1dqdNHsW7bnpmF9mBadrbep4PoE9g==',
111
- },
112
- bc78eded90386d20: {
113
- id: 65535,
114
- key: 'pQABARn//wKhAFgg1xOfzMpWmpN2aBGW+0RG23L0I301pncd/HXqUm+pVyoDoQChAFggnl+dmwGW45AArcPutjUkAjYmhIbXBPrqkVrNyg0ZI08E9g==',
115
- },
116
- },
117
- };
118
-
119
- const text = new Uint8Array([72, 101, 108, 108, 111, 33]); // "Hello!"
120
- const otrBundle = await cryptography.encrypt(text, preKeyBundleMap);
121
- expect(Object.keys(otrBundle).length).toBe(2);
122
- expect(Object.keys(otrBundle[firstUserID]).length).toBe(3);
123
- expect(Object.keys(otrBundle[secondUserID]).length).toBe(2);
124
- expect(otrBundle[firstUserID][firstClientId]).toEqual(jasmine.any(Object));
125
- });
126
- });
127
-
128
- describe('"encryptAsset"', () => {
129
- it('encrypts and decrypts ArrayBuffer', async () => {
130
- const bytes = new Uint8Array(16);
131
- window.crypto.getRandomValues(bytes);
132
- const byteBuffer = Buffer.from(bytes.buffer);
133
-
134
- const encryptedAsset = await encryptAsset({plaintext: byteBuffer});
135
- const decryptedBuffer = await decryptAsset(encryptedAsset);
136
-
137
- expect(decryptedBuffer).toEqual(byteBuffer);
138
- });
139
-
140
- it('does not decrypt when the hash is missing', async () => {
141
- const bytes = new Uint8Array(16);
142
- window.crypto.getRandomValues(bytes);
143
- const byteBuffer = Buffer.from(bytes.buffer);
144
-
145
- const {cipherText, keyBytes} = await encryptAsset({plaintext: byteBuffer});
146
-
147
- try {
148
- await decryptAsset(cipherText, keyBytes, null);
149
- fail();
150
- } catch (error) {}
151
- });
152
-
153
- it('does not decrypt when hash is an empty array', async () => {
154
- const bytes = new Uint8Array(16);
155
- window.crypto.getRandomValues(bytes);
156
- const byteBuffer = Buffer.from(bytes.buffer);
157
-
158
- const {cipherText, keyBytes} = await encryptAsset({plaintext: byteBuffer});
159
-
160
- try {
161
- await decryptAsset(cipherText, keyBytes, new Uint8Array([]));
162
- fail();
163
- } catch (error) {}
164
- });
165
- });
166
-
167
- describe('"encryptPayloadForSession"', () => {
168
- it('encodes plaintext.', async () => {
169
- const sessionWithBobId = 'bob-user-id@bob-client-id';
170
- const text = new Uint8Array([72, 101, 108, 108, 111, 32, 66, 111, 98, 33]); // "Hello Bob!"
171
- const encodedPreKey =
172
- 'pQABAQACoQBYIHOFFWPnWlr4sulxUWYoP0A6rsJiBO/Ec3Y914t67CIAA6EAoQBYIPFH5CK/a0YwKEx4n/+U/IPRN+mJXVv++MCs5Z4dLmz4BPY=';
173
- const {sessionId, encryptedPayload} = await cryptography.encryptPayloadForSession(
174
- sessionWithBobId,
175
- text,
176
- encodedPreKey,
177
- );
178
- expect(new TextDecoder().decode(encryptedPayload)).not.toBe('💣');
179
- expect(sessionId).toBe(sessionWithBobId);
180
- });
181
-
182
- it('encodes invalid text as Bomb Emoji.', async () => {
183
- const sessionWithBobId = 'bob-user-id@bob-client-id';
184
- const encodedPreKey =
185
- 'pQABAQACoQBYIHOFFWPnWlr4sulxUWYoP0A6rsJiBO/Ec3Y914t67CIAA6EAoQBYIPFH5CK/a0YwKEx4n/+U/IPRN+mJXVv++MCs5Z4dLmz4BPY=';
186
- const {sessionId, encryptedPayload} = await cryptography.encryptPayloadForSession(
187
- sessionWithBobId,
188
- undefined,
189
- encodedPreKey,
190
- );
191
- expect(new TextDecoder().decode(encryptedPayload)).toBe('💣');
192
- expect(sessionId).toBe(sessionWithBobId);
193
- });
194
- });
195
- });
@@ -1,228 +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
- Object.defineProperty(exports, "__esModule", { value: true });
40
- const api_client_1 = require("@wireapp/api-client");
41
- const cryptobox_1 = require("@wireapp/cryptobox");
42
- const Proteus = __importStar(require("@wireapp/proteus"));
43
- const store_engine_1 = require("@wireapp/store-engine");
44
- const bazinga64 = __importStar(require("bazinga64"));
45
- const crypto = __importStar(require("crypto"));
46
- const util_1 = require("util");
47
- const CryptographyHelper = __importStar(require("../test/CryptographyHelper"));
48
- const AssetCryptography_node_1 = require("./AssetCryptography.node");
49
- const CryptographyService_1 = require("./CryptographyService");
50
- async function createEngine(storeName) {
51
- const engine = new store_engine_1.MemoryEngine();
52
- await engine.init(storeName);
53
- return engine;
54
- }
55
- describe('CryptographyService', () => {
56
- let cryptographyService;
57
- let aliceLastResortPreKey;
58
- let bob;
59
- beforeAll(async () => {
60
- await Proteus.init();
61
- });
62
- beforeEach(async () => {
63
- cryptographyService = new CryptographyService_1.CryptographyService(new api_client_1.APIClient(), await createEngine('wire'));
64
- const preKeys = await cryptographyService.cryptobox.create();
65
- aliceLastResortPreKey = preKeys.filter(preKey => preKey.key_id === Proteus.keys.PreKey.MAX_PREKEY_ID)[0];
66
- bob = new cryptobox_1.Cryptobox(await createEngine('wire'));
67
- await bob.create();
68
- });
69
- describe('"constructor"', () => {
70
- it('creates an instance.', () => {
71
- expect(cryptographyService.cryptobox['identity'].public_key.fingerprint()).toBeDefined();
72
- expect(cryptographyService).toBeDefined();
73
- });
74
- });
75
- describe('"constructSessionId"', () => {
76
- it('constructs a Session ID by a given User ID and Client ID.', () => {
77
- const clientId = '1ceb9063fced26d3';
78
- const userId = 'afbb5d60-1187-4385-9c29-7361dea79647';
79
- const actual = CryptographyService_1.CryptographyService.constructSessionId(userId, clientId, null);
80
- expect(actual).toContain(clientId);
81
- expect(actual).toContain(userId);
82
- });
83
- it('constructs a Session ID by a given User ID and Client ID and domain.', () => {
84
- const clientId = '1ceb9063fced26d3';
85
- const userId = 'afbb5d60-1187-4385-9c29-7361dea79647';
86
- const actual = CryptographyService_1.CryptographyService.constructSessionId(userId, clientId, 'test.wire.link');
87
- expect(actual).toContain(clientId);
88
- expect(actual).toContain(userId);
89
- expect(actual).toContain('test.wire.link');
90
- });
91
- });
92
- describe('"decrypt"', () => {
93
- it('decrypts a Base64-encoded cipher message.', async () => {
94
- const alicePublicKey = cryptographyService.cryptobox['identity'].public_key;
95
- const publicPreKeyBundle = new Proteus.keys.PreKeyBundle(alicePublicKey, aliceLastResortPreKey);
96
- const text = 'Hello Alice!';
97
- const encryptedPreKeyMessage = await bob.encrypt('alice-user-id@alice-client-id', text, publicPreKeyBundle.serialise());
98
- const encodedPreKeyMessage = bazinga64.Encoder.toBase64(encryptedPreKeyMessage).asString;
99
- const decryptedMessage = await cryptographyService.decrypt('bob-user-id@bob-client-id', encodedPreKeyMessage);
100
- const plaintext = Buffer.from(decryptedMessage).toString('utf8');
101
- expect(plaintext).toBe(text);
102
- });
103
- it('is resistant to duplicated message errors', async () => {
104
- const receiver = cryptographyService.cryptobox['identity'];
105
- const preKey = await cryptographyService.cryptobox['get_prekey']();
106
- const text = 'Hi!';
107
- const encodedPreKeyMessage = await CryptographyHelper.createEncodedCipherText(receiver, preKey, text);
108
- const sessionId = 'alice-to-bob';
109
- const plaintext = await CryptographyHelper.getPlainText(cryptographyService, encodedPreKeyMessage, sessionId);
110
- // Testing to decrypt the same message multiple times (to provoke duplicate message errors)
111
- await CryptographyHelper.getPlainText(cryptographyService, encodedPreKeyMessage, sessionId);
112
- await CryptographyHelper.getPlainText(cryptographyService, encodedPreKeyMessage, sessionId);
113
- await CryptographyHelper.getPlainText(cryptographyService, encodedPreKeyMessage, sessionId);
114
- expect(plaintext).toBe(text);
115
- });
116
- });
117
- describe('"dismantleSessionId"', () => {
118
- const clientId = '1ceb9063fced26d3';
119
- const userId = 'afbb5d60-1187-4385-9c29-7361dea79647';
120
- const domain = 'domain.wire.link';
121
- it('gets User ID and Client ID from a Session ID without domain.', () => {
122
- const sessionId = CryptographyService_1.CryptographyService.constructSessionId(userId, clientId, null);
123
- const res = CryptographyService_1.CryptographyService['dismantleSessionId'](sessionId);
124
- expect(res.clientId).toBe(clientId);
125
- expect(res.userId).toBe(userId);
126
- expect(res.domain).toBe(undefined);
127
- });
128
- it('gets User ID and Client ID from a Session ID with domain.', () => {
129
- const sessionId = CryptographyService_1.CryptographyService.constructSessionId(userId, clientId, domain);
130
- const res = CryptographyService_1.CryptographyService['dismantleSessionId'](sessionId);
131
- expect(res.clientId).toBe(clientId);
132
- expect(res.userId).toBe(userId);
133
- expect(res.domain).toBe(domain);
134
- });
135
- });
136
- describe('"encrypt"', () => {
137
- it('generates a set of encrypted data based on PreKeys from multiple clients.', async () => {
138
- const firstUserID = 'bc0c99f1-49a5-4ad2-889a-62885af37088';
139
- const secondUserID = '2bde49aa-bdb5-458f-98cf-7d3552b10916';
140
- const firstClientId = '2b83ee08d7ac550d';
141
- const preKeyBundleMap = {
142
- [firstUserID]: {
143
- '5e80ea7886680975': {
144
- id: 1337,
145
- key: 'pQABARn//wKhAFggJ1Fbpg5l6wnzKOJE+vXpRnkqUYhIvVnR5lNXEbO2o/0DoQChAFggHxZvgvtDktY/vqBcpjjo6rQnXvcNQhfwmy8AJQJKlD0E9g==',
146
- },
147
- be67218b77d02d30: {
148
- id: 72,
149
- key: 'pQABARn//wKhAFggTWwHUoppQ8aXWhbH95YWnNp6uOYMxo2y4wbarWbF+EEDoQChAFggUiFoPtsiR0WFowIvl0myD+bVnFQJBYarqieI0Gly46QE9g==',
150
- },
151
- [firstClientId]: {
152
- id: 42,
153
- key: 'pQABARn//wKhAFggWcbwny0jdqlcnnn0j4QSENIVVq/KgyQ3mmdpunfvGZQDoQChAFggrsQBkQkrVZ8sWhr8wTeaC+dmctuJ3oRqfdHsymTtKmgE9g==',
154
- },
155
- },
156
- [secondUserID]: {
157
- '5bad8cdeddc5a90f': {
158
- id: 1,
159
- key: 'pQABARn//wKhAFggEYATUNJBQ7E2tfHT7HMLxa4O3Ckd7PciUdyKiGNNWbYDoQChAFggP/s0BHmHQDNwrO4pC1dqdNHsW7bnpmF9mBadrbep4PoE9g==',
160
- },
161
- bc78eded90386d20: {
162
- id: 65535,
163
- key: 'pQABARn//wKhAFgg1xOfzMpWmpN2aBGW+0RG23L0I301pncd/HXqUm+pVyoDoQChAFggnl+dmwGW45AArcPutjUkAjYmhIbXBPrqkVrNyg0ZI08E9g==',
164
- },
165
- },
166
- };
167
- const text = new Uint8Array(Buffer.from('Hello', 'utf8'));
168
- const otrBundle = await cryptographyService.encrypt(text, preKeyBundleMap);
169
- expect(Object.keys(otrBundle).length).toBe(2);
170
- expect(Object.keys(otrBundle[firstUserID]).length).toBe(3);
171
- expect(Object.keys(otrBundle[secondUserID]).length).toBe(2);
172
- expect(otrBundle[firstUserID][firstClientId]).toEqual(jasmine.any(Uint8Array));
173
- });
174
- it('does not generate a message counter twice when ran asynchronously multiple times for the same cryptographic session', async () => {
175
- const userId = 'bc0c99f1-49a5-4ad2-889a-62885af37088';
176
- const clientId = '5e80ea7886680975';
177
- const preKeyBundleMap = {
178
- [userId]: {
179
- [clientId]: {
180
- id: 1337,
181
- key: 'pQABARn//wKhAFggJ1Fbpg5l6wnzKOJE+vXpRnkqUYhIvVnR5lNXEbO2o/0DoQChAFggHxZvgvtDktY/vqBcpjjo6rQnXvcNQhfwmy8AJQJKlD0E9g==',
182
- },
183
- },
184
- };
185
- const text = new Uint8Array([72, 101, 108, 108, 111, 33]); // "Hello!"
186
- const encryptionRuns = 100;
187
- const otrBundles = await Promise.all(Array.from(Array(encryptionRuns).keys()).map(() => cryptographyService.encrypt(text, preKeyBundleMap)));
188
- const encryptedPayloads = otrBundles.map(bundle => bundle[userId][clientId]);
189
- const messageCounters = encryptedPayloads.map(encodedCiphertext => {
190
- const messageBytes = encodedCiphertext;
191
- const messageEnvelope = Proteus.message.Envelope.deserialise(messageBytes.buffer);
192
- const preKeyMessage = messageEnvelope.message;
193
- const cipherMessage = preKeyMessage.message;
194
- return cipherMessage.counter;
195
- });
196
- const uniqueValues = messageCounters.filter((value, index, self) => self.indexOf(value) === index);
197
- expect(uniqueValues.length).toBe(encryptionRuns);
198
- });
199
- });
200
- describe('"encryptAsset"', () => {
201
- it('encrypts and decrypts ArrayBuffer', async () => {
202
- const bytes = new Uint8Array(16);
203
- await (0, util_1.promisify)(crypto.randomFill)(bytes);
204
- const byteBuffer = Buffer.from(bytes.buffer);
205
- const encryptedAsset = await (0, AssetCryptography_node_1.encryptAsset)({ plainText: byteBuffer });
206
- const decryptedBuffer = await (0, AssetCryptography_node_1.decryptAsset)(encryptedAsset);
207
- expect(decryptedBuffer).toEqual(byteBuffer);
208
- });
209
- });
210
- describe('"encryptPayloadForSession"', () => {
211
- it('encodes plaintext.', async () => {
212
- const sessionWithBobId = 'bob-user-id@bob-client-id';
213
- const text = new Uint8Array([72, 101, 108, 108, 111, 32, 66, 111, 98, 33]); // "Hello Bob!"
214
- const encodedPreKey = 'pQABAQACoQBYIHOFFWPnWlr4sulxUWYoP0A6rsJiBO/Ec3Y914t67CIAA6EAoQBYIPFH5CK/a0YwKEx4n/+U/IPRN+mJXVv++MCs5Z4dLmz4BPY=';
215
- const { sessionId, encryptedPayload } = (await cryptographyService['encryptPayloadForSession'](sessionWithBobId, text, encodedPreKey));
216
- expect(Buffer.from(encryptedPayload).toString('utf8')).not.toBe('💣');
217
- expect(sessionId).toBe(sessionWithBobId);
218
- });
219
- it('encodes invalid text as Bomb Emoji.', async () => {
220
- const sessionWithBobId = 'bob-user-id@bob-client-id';
221
- const encodedPreKey = 'pQABAQACoQBYIHOFFWPnWlr4sulxUWYoP0A6rsJiBO/Ec3Y914t67CIAA6EAoQBYIPFH5CK/a0YwKEx4n/+U/IPRN+mJXVv++MCs5Z4dLmz4BPY=';
222
- const { sessionId, encryptedPayload } = (await cryptographyService['encryptPayloadForSession'](sessionWithBobId, undefined, encodedPreKey));
223
- expect(Buffer.from(encryptedPayload).toString()).toBe('💣');
224
- expect(sessionId).toBe(sessionWithBobId);
225
- });
226
- });
227
- });
228
- //# sourceMappingURL=CryptographyService.test.node.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CryptographyService.test.node.js","sourceRoot":"","sources":["CryptographyService.test.node.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;;;;;;;;;;;;;;;;;;;AAEH,oDAA8C;AAC9C,kDAA6C;AAC7C,0DAA4C;AAC5C,wDAA+D;AAC/D,qDAAuC;AACvC,+CAAiC;AACjC,+BAA+B;AAG/B,+E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