@wireapp/core 31.1.3 → 31.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. package/package.json +10 -9
  2. package/src/main/Account.d.ts +214 -0
  3. package/src/main/Account.js +463 -0
  4. package/src/main/CoreError.d.ts +9 -0
  5. package/src/main/CoreError.js +26 -0
  6. package/src/main/account/AccountService.d.ts +7 -0
  7. package/src/main/account/AccountService.js +33 -0
  8. package/src/main/account/AccountService.js.map +1 -0
  9. package/src/main/account/index.d.ts +1 -0
  10. package/src/main/account/index.js +36 -0
  11. package/src/main/account/index.js.map +1 -0
  12. package/src/main/auth/LoginSanitizer.d.ts +5 -0
  13. package/src/main/auth/LoginSanitizer.js +41 -0
  14. package/src/main/auth/index.d.ts +1 -0
  15. package/src/main/auth/index.js +36 -0
  16. package/src/main/broadcast/AvailabilityType.d.ts +2 -0
  17. package/src/main/broadcast/AvailabilityType.js +21 -0
  18. package/src/main/broadcast/BroadcastService.d.ts +24 -0
  19. package/src/main/broadcast/BroadcastService.js +74 -0
  20. package/src/main/broadcast/index.d.ts +2 -0
  21. package/src/main/broadcast/index.js +37 -0
  22. package/src/main/client/ClientBackendRepository.d.ts +11 -0
  23. package/src/main/client/ClientBackendRepository.js +43 -0
  24. package/src/main/client/ClientDatabaseRepository.d.ts +27 -0
  25. package/src/main/client/ClientDatabaseRepository.js +85 -0
  26. package/src/main/client/ClientInfo.d.ts +8 -0
  27. package/src/main/client/ClientInfo.js +21 -0
  28. package/src/main/client/ClientService.d.ts +40 -0
  29. package/src/main/client/ClientService.js +103 -0
  30. package/src/main/client/index.d.ts +4 -0
  31. package/src/main/client/index.js +39 -0
  32. package/src/main/connection/ConnectionService.d.ts +11 -0
  33. package/src/main/connection/ConnectionService.js +45 -0
  34. package/src/main/connection/index.d.ts +1 -0
  35. package/src/main/connection/index.js +36 -0
  36. package/src/main/conversation/AbortReason.d.ts +2 -0
  37. package/src/main/conversation/AbortReason.js +21 -0
  38. package/src/main/conversation/AssetService/AssetService.d.ts +62 -0
  39. package/src/main/conversation/AssetService/AssetService.js +88 -0
  40. package/src/main/conversation/AssetService/index.d.ts +1 -0
  41. package/src/main/conversation/AssetService/index.js +36 -0
  42. package/src/main/conversation/AssetTransferState.d.ts +4 -0
  43. package/src/main/conversation/AssetTransferState.js +27 -0
  44. package/src/main/conversation/ClientActionType.d.ts +1 -0
  45. package/src/main/conversation/ClientActionType.js +24 -0
  46. package/src/main/conversation/ConversationMapper/ConversationMapper.d.ts +6 -0
  47. package/src/main/conversation/ConversationMapper/ConversationMapper.js +57 -0
  48. package/src/main/conversation/ConversationMapper/index.d.ts +1 -0
  49. package/src/main/conversation/ConversationMapper/index.js +36 -0
  50. package/src/main/conversation/ConversationService/ConversationService.d.ts +149 -0
  51. package/src/main/conversation/ConversationService/ConversationService.js +584 -0
  52. package/src/main/conversation/ConversationService/ConversationService.types.d.ts +110 -0
  53. package/src/main/conversation/ConversationService/ConversationService.types.js +28 -0
  54. package/src/main/conversation/ConversationService/index.d.ts +2 -0
  55. package/src/main/conversation/ConversationService/index.js +37 -0
  56. package/src/main/conversation/ConversationService/messageGenerator.d.ts +9 -0
  57. package/src/main/conversation/ConversationService/messageGenerator.js +313 -0
  58. package/src/main/conversation/GenericMessageType.d.ts +25 -0
  59. package/src/main/conversation/GenericMessageType.js +49 -0
  60. package/src/main/conversation/MessageTimer/MessageTimer.d.ts +10 -0
  61. package/src/main/conversation/MessageTimer/MessageTimer.js +54 -0
  62. package/src/main/conversation/MessageTimer/index.d.ts +1 -0
  63. package/src/main/conversation/MessageTimer/index.js +36 -0
  64. package/src/main/conversation/ReactionType.d.ts +4 -0
  65. package/src/main/conversation/ReactionType.js +27 -0
  66. package/src/main/conversation/content/AssetContent.d.ts +42 -0
  67. package/src/main/conversation/content/AssetContent.js +21 -0
  68. package/src/main/conversation/content/ButtonActionConfirmationContent.d.ts +2 -0
  69. package/src/main/conversation/content/ButtonActionConfirmationContent.js +21 -0
  70. package/src/main/conversation/content/ButtonActionContent.d.ts +2 -0
  71. package/src/main/conversation/content/ButtonActionContent.js +21 -0
  72. package/src/main/conversation/content/CallingContent.d.ts +1 -0
  73. package/src/main/conversation/content/CallingContent.js +21 -0
  74. package/src/main/conversation/content/ClearedContent.d.ts +2 -0
  75. package/src/main/conversation/content/ClearedContent.js +21 -0
  76. package/src/main/conversation/content/ClientActionContent.d.ts +2 -0
  77. package/src/main/conversation/content/ClientActionContent.js +21 -0
  78. package/src/main/conversation/content/ClientAddContent.d.ts +4 -0
  79. package/src/main/conversation/content/ClientAddContent.js +21 -0
  80. package/src/main/conversation/content/ClientRemoveContent.d.ts +6 -0
  81. package/src/main/conversation/content/ClientRemoveContent.js +21 -0
  82. package/src/main/conversation/content/CompositeContent.d.ts +2 -0
  83. package/src/main/conversation/content/CompositeContent.js +21 -0
  84. package/src/main/conversation/content/ConfirmationContent.d.ts +2 -0
  85. package/src/main/conversation/content/ConfirmationContent.js +21 -0
  86. package/src/main/conversation/content/ContentType.d.ts +21 -0
  87. package/src/main/conversation/content/ContentType.js +94 -0
  88. package/src/main/conversation/content/ConversationContent.d.ts +3 -0
  89. package/src/main/conversation/content/ConversationContent.js +21 -0
  90. package/src/main/conversation/content/DeletedContent.d.ts +2 -0
  91. package/src/main/conversation/content/DeletedContent.js +21 -0
  92. package/src/main/conversation/content/EditedTextContent.d.ts +11 -0
  93. package/src/main/conversation/content/EditedTextContent.js +21 -0
  94. package/src/main/conversation/content/FileContent.d.ts +13 -0
  95. package/src/main/conversation/content/FileContent.js +21 -0
  96. package/src/main/conversation/content/HiddenContent.d.ts +2 -0
  97. package/src/main/conversation/content/HiddenContent.js +21 -0
  98. package/src/main/conversation/content/ImageContent.d.ts +7 -0
  99. package/src/main/conversation/content/ImageContent.js +21 -0
  100. package/src/main/conversation/content/KnockContent.d.ts +2 -0
  101. package/src/main/conversation/content/KnockContent.js +21 -0
  102. package/src/main/conversation/content/LinkPreviewContent.d.ts +10 -0
  103. package/src/main/conversation/content/LinkPreviewContent.js +21 -0
  104. package/src/main/conversation/content/LocationContent.d.ts +9 -0
  105. package/src/main/conversation/content/LocationContent.js +21 -0
  106. package/src/main/conversation/content/MentionContent.d.ts +2 -0
  107. package/src/main/conversation/content/MentionContent.js +21 -0
  108. package/src/main/conversation/content/QuoteContent.d.ts +7 -0
  109. package/src/main/conversation/content/QuoteContent.js +21 -0
  110. package/src/main/conversation/content/ReactionContent.d.ts +7 -0
  111. package/src/main/conversation/content/ReactionContent.js +21 -0
  112. package/src/main/conversation/content/TextContent.d.ts +9 -0
  113. package/src/main/conversation/content/TextContent.js +21 -0
  114. package/src/main/conversation/content/TweetContent.d.ts +2 -0
  115. package/src/main/conversation/content/TweetContent.js +21 -0
  116. package/src/main/conversation/content/index.d.ts +28 -0
  117. package/src/main/conversation/content/index.js +76 -0
  118. package/src/main/conversation/index.d.ts +9 -0
  119. package/src/main/conversation/index.js +44 -0
  120. package/src/main/conversation/message/CompositeContentBuilder.d.ts +14 -0
  121. package/src/main/conversation/message/CompositeContentBuilder.js +54 -0
  122. package/src/main/conversation/message/Message.d.ts +4 -0
  123. package/src/main/conversation/message/Message.js +21 -0
  124. package/src/main/conversation/message/MessageBuilder.d.ts +96 -0
  125. package/src/main/conversation/message/MessageBuilder.js +125 -0
  126. package/src/main/conversation/message/MessageService.d.ts +67 -0
  127. package/src/main/conversation/message/MessageService.js +293 -0
  128. package/src/main/conversation/message/MessageToProtoMapper.d.ts +7 -0
  129. package/src/main/conversation/message/MessageToProtoMapper.js +99 -0
  130. package/src/main/conversation/message/OtrMessage.d.ts +80 -0
  131. package/src/main/conversation/message/OtrMessage.js +21 -0
  132. package/src/main/conversation/message/PayloadBundle.d.ts +76 -0
  133. package/src/main/conversation/message/PayloadBundle.js +81 -0
  134. package/src/main/conversation/message/TeamMessage.d.ts +31 -0
  135. package/src/main/conversation/message/TeamMessage.js +21 -0
  136. package/src/main/conversation/message/TextContentBuilder.d.ts +13 -0
  137. package/src/main/conversation/message/TextContentBuilder.js +75 -0
  138. package/src/main/conversation/message/UserClientsUtil.d.ts +22 -0
  139. package/src/main/conversation/message/UserClientsUtil.js +38 -0
  140. package/src/main/conversation/message/UserMessage.d.ts +43 -0
  141. package/src/main/conversation/message/UserMessage.js +21 -0
  142. package/src/main/conversation/message/messageSender.d.ts +4 -0
  143. package/src/main/conversation/message/messageSender.js +36 -0
  144. package/src/main/cryptography/AssetCryptography/EncryptedAsset.d.ts +11 -0
  145. package/src/main/cryptography/AssetCryptography/EncryptedAsset.js +21 -0
  146. package/src/main/cryptography/AssetCryptography/crypto.browser.d.ts +2 -0
  147. package/src/main/cryptography/AssetCryptography/crypto.browser.js +46 -0
  148. package/src/main/cryptography/AssetCryptography/crypto.node.d.ts +2 -0
  149. package/src/main/cryptography/AssetCryptography/crypto.node.js +72 -0
  150. package/src/main/cryptography/AssetCryptography/index.d.ts +8 -0
  151. package/src/main/cryptography/AssetCryptography/index.js +53 -0
  152. package/src/main/cryptography/AssetCryptography/interfaces.d.ts +9 -0
  153. package/src/main/cryptography/AssetCryptography/interfaces.js +21 -0
  154. package/src/main/cryptography/CryptographyDatabaseRepository.d.ts +16 -0
  155. package/src/main/cryptography/CryptographyDatabaseRepository.js +44 -0
  156. package/src/main/cryptography/CryptographyService.d.ts +52 -0
  157. package/src/main/cryptography/CryptographyService.js +205 -0
  158. package/src/main/cryptography/GenericMessageMapper.d.ts +6 -0
  159. package/src/main/cryptography/GenericMessageMapper.js +160 -0
  160. package/src/main/cryptography/MessageHashService.d.ts +16 -0
  161. package/src/main/cryptography/MessageHashService.js +118 -0
  162. package/src/main/cryptography/SessionPayloadBundle.d.ts +4 -0
  163. package/src/main/cryptography/SessionPayloadBundle.js +21 -0
  164. package/src/main/cryptography/index.d.ts +4 -0
  165. package/src/main/cryptography/index.js +39 -0
  166. package/src/main/giphy/GiphyService.d.ts +9 -0
  167. package/src/main/giphy/GiphyService.js +37 -0
  168. package/src/main/giphy/index.d.ts +1 -0
  169. package/src/main/giphy/index.js +36 -0
  170. package/src/main/index.d.ts +17 -0
  171. package/src/main/index.js +59 -0
  172. package/src/main/linkPreview/LinkPreviewService.d.ts +7 -0
  173. package/src/main/linkPreview/LinkPreviewService.js +52 -0
  174. package/src/main/linkPreview/index.d.ts +1 -0
  175. package/src/main/linkPreview/index.js +36 -0
  176. package/src/main/mls/MLSService/MLSService.d.ts +39 -0
  177. package/src/main/mls/MLSService/MLSService.js +181 -0
  178. package/src/main/mls/index.d.ts +1 -0
  179. package/src/main/mls/index.js +36 -0
  180. package/src/main/mls/keyMaterialUpdatesStore/index.d.ts +1 -0
  181. package/src/main/mls/keyMaterialUpdatesStore/index.js +36 -0
  182. package/src/main/mls/keyMaterialUpdatesStore/keyMaterialUpdatesStore.d.ts +9 -0
  183. package/src/main/mls/keyMaterialUpdatesStore/keyMaterialUpdatesStore.js +51 -0
  184. package/src/main/mls/keyPackagesStatusStore/keyPackagesStatusStore.d.ts +7 -0
  185. package/src/main/mls/keyPackagesStatusStore/keyPackagesStatusStore.js +42 -0
  186. package/src/main/mls/types.d.ts +33 -0
  187. package/src/main/mls/types.js +21 -0
  188. package/src/main/notification/NotificationBackendRepository.d.ts +11 -0
  189. package/src/main/notification/NotificationBackendRepository.js +34 -0
  190. package/src/main/notification/NotificationDatabaseRepository.d.ts +42 -0
  191. package/src/main/notification/NotificationDatabaseRepository.js +97 -0
  192. package/src/main/notification/NotificationService.d.ts +129 -0
  193. package/src/main/notification/NotificationService.js +501 -0
  194. package/src/main/notification/index.d.ts +1 -0
  195. package/src/main/notification/index.js +36 -0
  196. package/src/main/notification/types.d.ts +16 -0
  197. package/src/main/notification/types.js +21 -0
  198. package/src/main/self/SelfService.d.ts +13 -0
  199. package/src/main/self/SelfService.js +55 -0
  200. package/src/main/self/index.d.ts +1 -0
  201. package/src/main/self/index.js +36 -0
  202. package/src/main/team/TeamService.d.ts +15 -0
  203. package/src/main/team/TeamService.js +55 -0
  204. package/src/main/team/index.d.ts +1 -0
  205. package/src/main/team/index.js +36 -0
  206. package/src/main/test/CryptographyHelper.d.ts +4 -0
  207. package/src/main/test/CryptographyHelper.js +69 -0
  208. package/src/main/test/PayloadHelper.d.ts +3 -0
  209. package/src/main/test/PayloadHelper.js +66 -0
  210. package/src/main/user/UserMapper.d.ts +5 -0
  211. package/src/main/user/UserMapper.js +88 -0
  212. package/src/main/user/UserService.d.ts +25 -0
  213. package/src/main/user/UserService.js +81 -0
  214. package/src/main/user/index.d.ts +1 -0
  215. package/src/main/user/index.js +36 -0
  216. package/src/main/util/LowPrecisionTaskScheduler/LowPrecisionTaskScheduler.d.ts +21 -0
  217. package/src/main/util/LowPrecisionTaskScheduler/LowPrecisionTaskScheduler.js +62 -0
  218. package/src/main/util/TaskScheduler/TaskScheduler.d.ts +10 -0
  219. package/src/main/util/TaskScheduler/TaskScheduler.js +70 -0
  220. package/src/main/util/TypePredicateUtil.d.ts +7 -0
  221. package/src/main/util/TypePredicateUtil.js +55 -0
  222. package/src/main/util/encryptedStore.d.ts +45 -0
  223. package/src/main/util/encryptedStore.js +116 -0
  224. package/src/main/util/fullyQualifiedClientIdUtils.d.ts +13 -0
  225. package/src/main/util/fullyQualifiedClientIdUtils.js +42 -0
  226. package/src/main/util/index.d.ts +1 -0
  227. package/src/main/util/index.js +36 -0
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+ /*
3
+ * Wire
4
+ * Copyright (C) 2022 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 __rest = (this && this.__rest) || function (s, e) {
21
+ var t = {};
22
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
23
+ t[p] = s[p];
24
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
25
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
26
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
27
+ t[p[i]] = s[p[i]];
28
+ }
29
+ return t;
30
+ };
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.MLSService = exports.optionalToUint8Array = void 0;
33
+ const bazinga64_1 = require("bazinga64");
34
+ const messageSender_1 = require("../../conversation/message/messageSender");
35
+ const fullyQualifiedClientIdUtils_1 = require("../../util/fullyQualifiedClientIdUtils");
36
+ //@todo: this function is temporary, we wait for the update from core-crypto side
37
+ //they are returning regular array instead of Uint8Array for commit and welcome messages
38
+ const optionalToUint8Array = (array) => {
39
+ return Array.isArray(array) ? Uint8Array.from(array) : array;
40
+ };
41
+ exports.optionalToUint8Array = optionalToUint8Array;
42
+ class MLSService {
43
+ constructor(config, apiClient, coreCryptoClientProvider) {
44
+ this.config = config;
45
+ this.apiClient = apiClient;
46
+ this.coreCryptoClientProvider = coreCryptoClientProvider;
47
+ }
48
+ getCoreCryptoClient() {
49
+ const client = this.coreCryptoClientProvider();
50
+ if (!client) {
51
+ throw new Error('Could not get coreCryptoClient');
52
+ }
53
+ return client;
54
+ }
55
+ async uploadCommitBundle(groupId, { commit, welcome }) {
56
+ const coreCryptoClient = this.getCoreCryptoClient();
57
+ if (commit) {
58
+ try {
59
+ const messageResponse = await this.apiClient.api.conversation.postMlsMessage(
60
+ //@todo: it's temporary - we wait for core-crypto fix to return the actual Uint8Array instead of regular array
61
+ (0, exports.optionalToUint8Array)(commit));
62
+ await coreCryptoClient.commitAccepted(groupId);
63
+ if (welcome) {
64
+ // If the commit went well, we can send the Welcome
65
+ //@todo: it's temporary - we wait for core-crypto fix to return the actual Uint8Array instead of regular array
66
+ await this.apiClient.api.conversation.postMlsWelcomeMessage((0, exports.optionalToUint8Array)(welcome));
67
+ }
68
+ return messageResponse;
69
+ }
70
+ catch (error) {
71
+ await coreCryptoClient.clearPendingCommit(groupId);
72
+ }
73
+ }
74
+ return null;
75
+ }
76
+ addUsersToExistingConversation(groupId, invitee) {
77
+ return (0, messageSender_1.sendMessage)(async () => {
78
+ const coreCryptoClient = this.getCoreCryptoClient();
79
+ const memberAddedMessages = await coreCryptoClient.addClientsToConversation(groupId, invitee);
80
+ return this.uploadCommitBundle(groupId, memberAddedMessages);
81
+ });
82
+ }
83
+ configureMLSCallbacks(_a) {
84
+ var { groupIdFromConversationId } = _a, coreCryptoCallbacks = __rest(_a, ["groupIdFromConversationId"]);
85
+ this.getCoreCryptoClient().registerCallbacks(Object.assign(Object.assign({}, coreCryptoCallbacks), { clientIdBelongsToOneOf: (client, otherClients) => {
86
+ const decoder = new TextDecoder();
87
+ const { user } = (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(decoder.decode(client));
88
+ return otherClients.some(client => {
89
+ const { user: otherUser } = (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(decoder.decode(client));
90
+ return otherUser === user;
91
+ });
92
+ } }));
93
+ this.groupIdFromConversationId = groupIdFromConversationId;
94
+ }
95
+ async getKeyPackagesPayload(qualifiedUsers) {
96
+ /**
97
+ * @note We need to fetch key packages for all the users
98
+ * we want to add to the new MLS conversations,
99
+ * includes self user too.
100
+ */
101
+ const keyPackages = await Promise.all([
102
+ ...qualifiedUsers.map(({ id, domain, skipOwn }) => this.apiClient.api.client.claimMLSKeyPackages(id, domain, skipOwn)),
103
+ ]);
104
+ const coreCryptoKeyPackagesPayload = keyPackages.reduce((previousValue, currentValue) => {
105
+ // skip users that have not uploaded their MLS key packages
106
+ if (currentValue.key_packages.length > 0) {
107
+ return [
108
+ ...previousValue,
109
+ ...currentValue.key_packages.map(keyPackage => ({
110
+ id: bazinga64_1.Encoder.toBase64(keyPackage.client).asBytes,
111
+ kp: bazinga64_1.Decoder.fromBase64(keyPackage.key_package).asBytes,
112
+ })),
113
+ ];
114
+ }
115
+ return previousValue;
116
+ }, []);
117
+ return coreCryptoKeyPackagesPayload;
118
+ }
119
+ async newProposal(proposalType, args) {
120
+ return this.getCoreCryptoClient().newProposal(proposalType, args);
121
+ }
122
+ async newExternalProposal(externalProposalType, args) {
123
+ return this.getCoreCryptoClient().newExternalProposal(externalProposalType, args);
124
+ }
125
+ async processWelcomeMessage(welcomeMessage) {
126
+ return this.getCoreCryptoClient().processWelcomeMessage(welcomeMessage);
127
+ }
128
+ async decryptMessage(conversationId, payload) {
129
+ return this.getCoreCryptoClient().decryptMessage(conversationId, payload);
130
+ }
131
+ async encryptMessage(conversationId, message) {
132
+ return this.getCoreCryptoClient().encryptMessage(conversationId, message);
133
+ }
134
+ updateKeyingMaterial(conversationId) {
135
+ return (0, messageSender_1.sendMessage)(async () => {
136
+ const commitBundle = await this.getCoreCryptoClient().updateKeyingMaterial(conversationId);
137
+ return this.uploadCommitBundle(conversationId, commitBundle);
138
+ });
139
+ }
140
+ async createConversation(conversationId, configuration) {
141
+ return this.getCoreCryptoClient().createConversation(conversationId, configuration);
142
+ }
143
+ removeClientsFromConversation(conversationId, clientIds) {
144
+ return (0, messageSender_1.sendMessage)(async () => {
145
+ const commitBundle = await this.getCoreCryptoClient().removeClientsFromConversation(conversationId, clientIds);
146
+ return this.uploadCommitBundle(conversationId, commitBundle);
147
+ });
148
+ }
149
+ async commitPendingProposals(groupId) {
150
+ const commitBundle = await this.getCoreCryptoClient().commitPendingProposals(groupId);
151
+ return commitBundle ? void this.uploadCommitBundle(groupId, commitBundle) : undefined;
152
+ }
153
+ async conversationExists(conversationId) {
154
+ return this.getCoreCryptoClient().conversationExists(conversationId);
155
+ }
156
+ async clientValidKeypackagesCount() {
157
+ return this.getCoreCryptoClient().clientValidKeypackagesCount();
158
+ }
159
+ async clientKeypackages(amountRequested) {
160
+ return this.getCoreCryptoClient().clientKeypackages(amountRequested);
161
+ }
162
+ /**
163
+ * Will make the given client mls capable (generate and upload key packages)
164
+ *
165
+ * @param mlsClient Intance of the coreCrypto that represents the mls client
166
+ * @param clientId The id of the client
167
+ */
168
+ async uploadMLSPublicKeys(publicKey, clientId) {
169
+ return this.apiClient.api.client.putClient(clientId, {
170
+ mls_public_keys: { ed25519: btoa(bazinga64_1.Converter.arrayBufferViewToBaselineString(publicKey)) },
171
+ });
172
+ }
173
+ async uploadMLSKeyPackages(keypackages, clientId) {
174
+ return this.apiClient.api.client.uploadMLSKeyPackages(clientId, keypackages.map(keypackage => btoa(bazinga64_1.Converter.arrayBufferViewToBaselineString(keypackage))));
175
+ }
176
+ async wipeConversation(conversationId) {
177
+ return this.getCoreCryptoClient().wipeConversation(conversationId);
178
+ }
179
+ }
180
+ exports.MLSService = MLSService;
181
+ //# sourceMappingURL=MLSService.js.map
@@ -0,0 +1 @@
1
+ export * from './MLSService/MLSService';
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ /*
3
+ * Wire
4
+ * Copyright (C) 2022 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
+ var desc = Object.getOwnPropertyDescriptor(m, k);
23
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
24
+ desc = { enumerable: true, get: function() { return m[k]; } };
25
+ }
26
+ Object.defineProperty(o, k2, desc);
27
+ }) : (function(o, m, k, k2) {
28
+ if (k2 === undefined) k2 = k;
29
+ o[k2] = m[k];
30
+ }));
31
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
32
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
33
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ __exportStar(require("./MLSService/MLSService"), exports);
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ export * from './keyMaterialUpdatesStore';
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ /*
3
+ * Wire
4
+ * Copyright (C) 2022 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
+ var desc = Object.getOwnPropertyDescriptor(m, k);
23
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
24
+ desc = { enumerable: true, get: function() { return m[k]; } };
25
+ }
26
+ Object.defineProperty(o, k2, desc);
27
+ }) : (function(o, m, k, k2) {
28
+ if (k2 === undefined) k2 = k;
29
+ o[k2] = m[k];
30
+ }));
31
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
32
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
33
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ __exportStar(require("./keyMaterialUpdatesStore"), exports);
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,9 @@
1
+ import { CommonMLS, LastKeyMaterialUpdateParams } from '../../notification/types';
2
+ export interface KeyMaterialUpdatesStore {
3
+ [groupId: string]: LastKeyMaterialUpdateParams;
4
+ }
5
+ export declare const keyMaterialUpdatesStore: {
6
+ getAllUpdateDates: () => LastKeyMaterialUpdateParams[];
7
+ storeLastKeyMaterialUpdateDate: ({ groupId, previousUpdateDate }: LastKeyMaterialUpdateParams) => void;
8
+ deleteLastKeyMaterialUpdateDate: ({ groupId }: CommonMLS) => void;
9
+ };
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ /*
3
+ * Wire
4
+ * Copyright (C) 2022 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.keyMaterialUpdatesStore = void 0;
22
+ const storageKey = 'keyMaterialUpdates';
23
+ const getUpdateDatesMap = () => {
24
+ const storedState = localStorage.getItem(storageKey);
25
+ if (!storedState) {
26
+ return {};
27
+ }
28
+ return JSON.parse(storedState);
29
+ };
30
+ const getAllUpdateDates = () => {
31
+ const storedStateMap = getUpdateDatesMap();
32
+ return Object.values(storedStateMap);
33
+ };
34
+ const storeLastKeyMaterialUpdateDate = ({ groupId, previousUpdateDate }) => {
35
+ const storedState = getUpdateDatesMap();
36
+ const newStoredState = Object.assign(Object.assign({}, storedState), { [groupId]: { groupId, previousUpdateDate } });
37
+ localStorage.setItem(storageKey, JSON.stringify(newStoredState));
38
+ };
39
+ const deleteLastKeyMaterialUpdateDate = ({ groupId }) => {
40
+ const storedState = getUpdateDatesMap();
41
+ if (storedState[groupId]) {
42
+ delete storedState[groupId];
43
+ }
44
+ localStorage.setItem(storageKey, JSON.stringify(storedState));
45
+ };
46
+ exports.keyMaterialUpdatesStore = {
47
+ getAllUpdateDates,
48
+ storeLastKeyMaterialUpdateDate,
49
+ deleteLastKeyMaterialUpdateDate,
50
+ };
51
+ //# sourceMappingURL=keyMaterialUpdatesStore.js.map
@@ -0,0 +1,7 @@
1
+ export interface KeyPackagesStatusStore {
2
+ lastQueryDate: number;
3
+ }
4
+ export declare const keyPackagesStatusStore: {
5
+ getState: () => KeyPackagesStatusStore;
6
+ saveState: ({ lastQueryDate }: KeyPackagesStatusStore) => void;
7
+ };
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ /*
3
+ * Wire
4
+ * Copyright (C) 2022 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.keyPackagesStatusStore = void 0;
22
+ const storageKey = 'keyPackagesStatus';
23
+ const getState = () => {
24
+ const storedState = localStorage.getItem(storageKey);
25
+ if (!storedState) {
26
+ return {
27
+ lastQueryDate: 0,
28
+ };
29
+ }
30
+ const parsedState = JSON.parse(storedState);
31
+ return {
32
+ lastQueryDate: Number(parsedState.lastQueryDate),
33
+ };
34
+ };
35
+ const saveState = ({ lastQueryDate }) => {
36
+ localStorage.setItem(storageKey, JSON.stringify({ lastQueryDate }));
37
+ };
38
+ exports.keyPackagesStatusStore = {
39
+ getState,
40
+ saveState,
41
+ };
42
+ //# sourceMappingURL=keyPackagesStatusStore.js.map
@@ -0,0 +1,33 @@
1
+ import { QualifiedId } from '@wireapp/api-client/src/user';
2
+ import { CoreCryptoCallbacks } from '@wireapp/core-crypto';
3
+ declare type SecretCrypto<T> = {
4
+ encrypt: (value: Uint8Array) => Promise<T>;
5
+ decrypt: (payload: T) => Promise<Uint8Array>;
6
+ };
7
+ export interface MLSCallbacks extends Pick<CoreCryptoCallbacks, 'authorize'> {
8
+ /**
9
+ * Should return a groupId corresponding to the conversation ID given
10
+ * Used for the core to know what core-crypto conversation we are dealing with when receiving events
11
+ * @param conversationId
12
+ * @returns the bytes of the groupId corresponding to the conversation ID
13
+ */
14
+ groupIdFromConversationId: (conversationId: QualifiedId) => Promise<string | undefined>;
15
+ }
16
+ export interface MLSConfig<T = any> {
17
+ /**
18
+ * encrypt/decrypt function pair that will be called before storing/fetching secrets in the secrets database.
19
+ * If not provided will use the built in encryption mechanism
20
+ */
21
+ secretsCrypto?: SecretCrypto<T>;
22
+ /**
23
+ * path on the public server to the core crypto wasm file.
24
+ * This file will be downloaded lazily when corecrypto is needed.
25
+ * It, thus, needs to know where, on the server, the file can be found
26
+ */
27
+ coreCrypoWasmFilePath: string;
28
+ /**
29
+ * (milliseconds) period of time between automatic updates of the keying material (30 days by default)
30
+ */
31
+ keyingMaterialUpdateThreshold?: number;
32
+ }
33
+ export {};
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ /*
3
+ * Wire
4
+ * Copyright (C) 2022 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=types.js.map
@@ -0,0 +1,11 @@
1
+ import { APIClient } from '@wireapp/api-client';
2
+ import { Notification } from '@wireapp/api-client/src/notification/';
3
+ export declare class NotificationBackendRepository {
4
+ private readonly apiClient;
5
+ constructor(apiClient: APIClient);
6
+ getAllNotifications(clientId?: string, lastNotificationId?: string): Promise<{
7
+ notifications: Notification[];
8
+ missedNotification?: string | undefined;
9
+ }>;
10
+ getLastNotification(clientId?: string): Promise<Notification>;
11
+ }
@@ -0,0 +1,34 @@
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.NotificationBackendRepository = void 0;
22
+ class NotificationBackendRepository {
23
+ constructor(apiClient) {
24
+ this.apiClient = apiClient;
25
+ }
26
+ async getAllNotifications(clientId, lastNotificationId) {
27
+ return this.apiClient.api.notification.getAllNotifications(clientId, lastNotificationId);
28
+ }
29
+ getLastNotification(clientId) {
30
+ return this.apiClient.api.notification.getLastNotification(clientId);
31
+ }
32
+ }
33
+ exports.NotificationBackendRepository = NotificationBackendRepository;
34
+ //# sourceMappingURL=NotificationBackendRepository.js.map
@@ -0,0 +1,42 @@
1
+ import { BackendEvent } from '@wireapp/api-client/src/event';
2
+ import { Notification } from '@wireapp/api-client/src/notification/';
3
+ import { CRUDEngine } from '@wireapp/store-engine';
4
+ import { CommonMLS, StorePendingProposalsParams } from './types';
5
+ export declare enum DatabaseStores {
6
+ EVENTS = "events"
7
+ }
8
+ export declare enum DatabaseKeys {
9
+ PRIMARY_KEY_LAST_EVENT = "z.storage.StorageKey.EVENT.LAST_DATE",
10
+ PRIMARY_KEY_LAST_NOTIFICATION = "z.storage.StorageKey.NOTIFICATION.LAST_ID"
11
+ }
12
+ export declare class NotificationDatabaseRepository {
13
+ private readonly storeEngine;
14
+ constructor(storeEngine: CRUDEngine);
15
+ getNotificationEventList(): Promise<BackendEvent[]>;
16
+ getLastEventDate(): Promise<Date>;
17
+ updateLastEventDate(eventDate: Date): Promise<Date>;
18
+ createLastEventDate(eventDate: Date): Promise<Date>;
19
+ getLastNotificationId(): Promise<string>;
20
+ updateLastNotificationId(lastNotification: Notification): Promise<string>;
21
+ /**
22
+ * ## MLS only ##
23
+ * Store groupIds with pending proposals and a delay in the DB until the proposals get committed.
24
+ *
25
+ * @param groupId groupId of the mls conversation
26
+ * @param firingDate date when the pending proposals should be committed
27
+ */
28
+ storePendingProposal(params: StorePendingProposalsParams): Promise<boolean>;
29
+ /**
30
+ * ## MLS only ##
31
+ * Delete stored entries for pending proposals that have been committed.
32
+ *
33
+ * @param groupId groupId of the mls conversation
34
+ */
35
+ deletePendingProposal({ groupId }: CommonMLS): Promise<boolean>;
36
+ /**
37
+ * ## MLS only ##
38
+ * Get all stored entries for pending proposals.
39
+ *
40
+ */
41
+ getStoredPendingProposals(): Promise<StorePendingProposalsParams[]>;
42
+ }
@@ -0,0 +1,97 @@
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.NotificationDatabaseRepository = exports.DatabaseKeys = exports.DatabaseStores = void 0;
22
+ const CryptographyDatabaseRepository_1 = require("../cryptography/CryptographyDatabaseRepository");
23
+ var DatabaseStores;
24
+ (function (DatabaseStores) {
25
+ DatabaseStores["EVENTS"] = "events";
26
+ })(DatabaseStores = exports.DatabaseStores || (exports.DatabaseStores = {}));
27
+ var DatabaseKeys;
28
+ (function (DatabaseKeys) {
29
+ DatabaseKeys["PRIMARY_KEY_LAST_EVENT"] = "z.storage.StorageKey.EVENT.LAST_DATE";
30
+ DatabaseKeys["PRIMARY_KEY_LAST_NOTIFICATION"] = "z.storage.StorageKey.NOTIFICATION.LAST_ID";
31
+ })(DatabaseKeys = exports.DatabaseKeys || (exports.DatabaseKeys = {}));
32
+ const STORES = Object.assign({}, CryptographyDatabaseRepository_1.CryptographyDatabaseRepository.STORES);
33
+ class NotificationDatabaseRepository {
34
+ constructor(storeEngine) {
35
+ this.storeEngine = storeEngine;
36
+ }
37
+ getNotificationEventList() {
38
+ return this.storeEngine.readAll(DatabaseStores.EVENTS);
39
+ }
40
+ async getLastEventDate() {
41
+ const { value } = await this.storeEngine.read(STORES.AMPLIFY, DatabaseKeys.PRIMARY_KEY_LAST_EVENT);
42
+ return new Date(value);
43
+ }
44
+ async updateLastEventDate(eventDate) {
45
+ await this.storeEngine.update(STORES.AMPLIFY, DatabaseKeys.PRIMARY_KEY_LAST_EVENT, {
46
+ value: eventDate.toISOString(),
47
+ });
48
+ return eventDate;
49
+ }
50
+ async createLastEventDate(eventDate) {
51
+ await this.storeEngine.create(STORES.AMPLIFY, DatabaseKeys.PRIMARY_KEY_LAST_EVENT, {
52
+ value: eventDate.toISOString(),
53
+ });
54
+ return eventDate;
55
+ }
56
+ async getLastNotificationId() {
57
+ const { value } = await this.storeEngine.read(STORES.AMPLIFY, DatabaseKeys.PRIMARY_KEY_LAST_NOTIFICATION);
58
+ return value;
59
+ }
60
+ async updateLastNotificationId(lastNotification) {
61
+ await this.storeEngine.updateOrCreate(STORES.AMPLIFY, DatabaseKeys.PRIMARY_KEY_LAST_NOTIFICATION, {
62
+ value: lastNotification.id,
63
+ });
64
+ return lastNotification.id;
65
+ }
66
+ /**
67
+ * ## MLS only ##
68
+ * Store groupIds with pending proposals and a delay in the DB until the proposals get committed.
69
+ *
70
+ * @param groupId groupId of the mls conversation
71
+ * @param firingDate date when the pending proposals should be committed
72
+ */
73
+ async storePendingProposal(params) {
74
+ await this.storeEngine.updateOrCreate(STORES.PENDING_PROPOSALS, `${params.groupId}`, params);
75
+ return true;
76
+ }
77
+ /**
78
+ * ## MLS only ##
79
+ * Delete stored entries for pending proposals that have been committed.
80
+ *
81
+ * @param groupId groupId of the mls conversation
82
+ */
83
+ async deletePendingProposal({ groupId }) {
84
+ await this.storeEngine.delete(STORES.PENDING_PROPOSALS, `${groupId}`);
85
+ return true;
86
+ }
87
+ /**
88
+ * ## MLS only ##
89
+ * Get all stored entries for pending proposals.
90
+ *
91
+ */
92
+ async getStoredPendingProposals() {
93
+ return this.storeEngine.readAll(STORES.PENDING_PROPOSALS);
94
+ }
95
+ }
96
+ exports.NotificationDatabaseRepository = NotificationDatabaseRepository;
97
+ //# sourceMappingURL=NotificationDatabaseRepository.js.map