@wireapp/core 30.4.1 → 30.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/package.json +3 -3
  3. package/src/main/Account.d.ts +0 -220
  4. package/src/main/Account.js +0 -435
  5. package/src/main/CoreError.d.ts +0 -9
  6. package/src/main/CoreError.js +0 -26
  7. package/src/main/account/AccountService.d.ts +0 -7
  8. package/src/main/account/AccountService.js +0 -33
  9. package/src/main/account/AccountService.js.map +0 -1
  10. package/src/main/account/index.d.ts +0 -1
  11. package/src/main/account/index.js +0 -32
  12. package/src/main/account/index.js.map +0 -1
  13. package/src/main/auth/LoginSanitizer.d.ts +0 -5
  14. package/src/main/auth/LoginSanitizer.js +0 -41
  15. package/src/main/auth/index.d.ts +0 -1
  16. package/src/main/auth/index.js +0 -32
  17. package/src/main/broadcast/AvailabilityType.d.ts +0 -2
  18. package/src/main/broadcast/AvailabilityType.js +0 -21
  19. package/src/main/broadcast/BroadcastService.d.ts +0 -24
  20. package/src/main/broadcast/BroadcastService.js +0 -74
  21. package/src/main/broadcast/index.d.ts +0 -2
  22. package/src/main/broadcast/index.js +0 -33
  23. package/src/main/client/ClientBackendRepository.d.ts +0 -11
  24. package/src/main/client/ClientBackendRepository.js +0 -43
  25. package/src/main/client/ClientDatabaseRepository.d.ts +0 -27
  26. package/src/main/client/ClientDatabaseRepository.js +0 -85
  27. package/src/main/client/ClientInfo.d.ts +0 -8
  28. package/src/main/client/ClientInfo.js +0 -21
  29. package/src/main/client/ClientService.d.ts +0 -48
  30. package/src/main/client/ClientService.js +0 -118
  31. package/src/main/client/index.d.ts +0 -4
  32. package/src/main/client/index.js +0 -35
  33. package/src/main/connection/ConnectionService.d.ts +0 -11
  34. package/src/main/connection/ConnectionService.js +0 -45
  35. package/src/main/connection/index.d.ts +0 -1
  36. package/src/main/connection/index.js +0 -32
  37. package/src/main/conversation/AbortReason.d.ts +0 -2
  38. package/src/main/conversation/AbortReason.js +0 -21
  39. package/src/main/conversation/AssetService/AssetService.d.ts +0 -62
  40. package/src/main/conversation/AssetService/AssetService.js +0 -88
  41. package/src/main/conversation/AssetService/index.d.ts +0 -1
  42. package/src/main/conversation/AssetService/index.js +0 -32
  43. package/src/main/conversation/AssetTransferState.d.ts +0 -4
  44. package/src/main/conversation/AssetTransferState.js +0 -27
  45. package/src/main/conversation/ClientActionType.d.ts +0 -1
  46. package/src/main/conversation/ClientActionType.js +0 -24
  47. package/src/main/conversation/ConversationMapper/ConversationMapper.d.ts +0 -6
  48. package/src/main/conversation/ConversationMapper/ConversationMapper.js +0 -57
  49. package/src/main/conversation/ConversationMapper/index.d.ts +0 -1
  50. package/src/main/conversation/ConversationMapper/index.js +0 -32
  51. package/src/main/conversation/ConversationService/ConversationService.d.ts +0 -164
  52. package/src/main/conversation/ConversationService/ConversationService.js +0 -951
  53. package/src/main/conversation/ConversationService/ConversationService.types.d.ts +0 -108
  54. package/src/main/conversation/ConversationService/ConversationService.types.js +0 -28
  55. package/src/main/conversation/ConversationService/index.d.ts +0 -2
  56. package/src/main/conversation/ConversationService/index.js +0 -33
  57. package/src/main/conversation/GenericMessageType.d.ts +0 -25
  58. package/src/main/conversation/GenericMessageType.js +0 -49
  59. package/src/main/conversation/MessageTimer/MessageTimer.d.ts +0 -10
  60. package/src/main/conversation/MessageTimer/MessageTimer.js +0 -54
  61. package/src/main/conversation/MessageTimer/index.d.ts +0 -1
  62. package/src/main/conversation/MessageTimer/index.js +0 -32
  63. package/src/main/conversation/ReactionType.d.ts +0 -4
  64. package/src/main/conversation/ReactionType.js +0 -27
  65. package/src/main/conversation/content/AssetContent.d.ts +0 -42
  66. package/src/main/conversation/content/AssetContent.js +0 -21
  67. package/src/main/conversation/content/ButtonActionConfirmationContent.d.ts +0 -2
  68. package/src/main/conversation/content/ButtonActionConfirmationContent.js +0 -21
  69. package/src/main/conversation/content/ButtonActionContent.d.ts +0 -2
  70. package/src/main/conversation/content/ButtonActionContent.js +0 -21
  71. package/src/main/conversation/content/CallingContent.d.ts +0 -1
  72. package/src/main/conversation/content/CallingContent.js +0 -21
  73. package/src/main/conversation/content/ClearedContent.d.ts +0 -2
  74. package/src/main/conversation/content/ClearedContent.js +0 -21
  75. package/src/main/conversation/content/ClientActionContent.d.ts +0 -2
  76. package/src/main/conversation/content/ClientActionContent.js +0 -21
  77. package/src/main/conversation/content/ClientAddContent.d.ts +0 -4
  78. package/src/main/conversation/content/ClientAddContent.js +0 -21
  79. package/src/main/conversation/content/ClientRemoveContent.d.ts +0 -6
  80. package/src/main/conversation/content/ClientRemoveContent.js +0 -21
  81. package/src/main/conversation/content/CompositeContent.d.ts +0 -2
  82. package/src/main/conversation/content/CompositeContent.js +0 -21
  83. package/src/main/conversation/content/ConfirmationContent.d.ts +0 -2
  84. package/src/main/conversation/content/ConfirmationContent.js +0 -21
  85. package/src/main/conversation/content/ContentType.d.ts +0 -21
  86. package/src/main/conversation/content/ContentType.js +0 -94
  87. package/src/main/conversation/content/ConversationContent.d.ts +0 -3
  88. package/src/main/conversation/content/ConversationContent.js +0 -21
  89. package/src/main/conversation/content/DeletedContent.d.ts +0 -2
  90. package/src/main/conversation/content/DeletedContent.js +0 -21
  91. package/src/main/conversation/content/EditedTextContent.d.ts +0 -11
  92. package/src/main/conversation/content/EditedTextContent.js +0 -21
  93. package/src/main/conversation/content/FileContent.d.ts +0 -13
  94. package/src/main/conversation/content/FileContent.js +0 -21
  95. package/src/main/conversation/content/HiddenContent.d.ts +0 -2
  96. package/src/main/conversation/content/HiddenContent.js +0 -21
  97. package/src/main/conversation/content/ImageContent.d.ts +0 -7
  98. package/src/main/conversation/content/ImageContent.js +0 -21
  99. package/src/main/conversation/content/KnockContent.d.ts +0 -2
  100. package/src/main/conversation/content/KnockContent.js +0 -21
  101. package/src/main/conversation/content/LinkPreviewContent.d.ts +0 -10
  102. package/src/main/conversation/content/LinkPreviewContent.js +0 -21
  103. package/src/main/conversation/content/LocationContent.d.ts +0 -9
  104. package/src/main/conversation/content/LocationContent.js +0 -21
  105. package/src/main/conversation/content/MentionContent.d.ts +0 -2
  106. package/src/main/conversation/content/MentionContent.js +0 -21
  107. package/src/main/conversation/content/QuoteContent.d.ts +0 -7
  108. package/src/main/conversation/content/QuoteContent.js +0 -21
  109. package/src/main/conversation/content/ReactionContent.d.ts +0 -7
  110. package/src/main/conversation/content/ReactionContent.js +0 -21
  111. package/src/main/conversation/content/TextContent.d.ts +0 -9
  112. package/src/main/conversation/content/TextContent.js +0 -21
  113. package/src/main/conversation/content/TweetContent.d.ts +0 -2
  114. package/src/main/conversation/content/TweetContent.js +0 -21
  115. package/src/main/conversation/content/index.d.ts +0 -28
  116. package/src/main/conversation/content/index.js +0 -72
  117. package/src/main/conversation/index.d.ts +0 -9
  118. package/src/main/conversation/index.js +0 -40
  119. package/src/main/conversation/message/CompositeContentBuilder.d.ts +0 -14
  120. package/src/main/conversation/message/CompositeContentBuilder.js +0 -54
  121. package/src/main/conversation/message/Message.d.ts +0 -4
  122. package/src/main/conversation/message/Message.js +0 -21
  123. package/src/main/conversation/message/MessageBuilder.d.ts +0 -87
  124. package/src/main/conversation/message/MessageBuilder.js +0 -119
  125. package/src/main/conversation/message/MessageService.d.ts +0 -67
  126. package/src/main/conversation/message/MessageService.js +0 -293
  127. package/src/main/conversation/message/MessageToProtoMapper.d.ts +0 -7
  128. package/src/main/conversation/message/MessageToProtoMapper.js +0 -99
  129. package/src/main/conversation/message/OtrMessage.d.ts +0 -80
  130. package/src/main/conversation/message/OtrMessage.js +0 -21
  131. package/src/main/conversation/message/PayloadBundle.d.ts +0 -76
  132. package/src/main/conversation/message/PayloadBundle.js +0 -81
  133. package/src/main/conversation/message/TeamMessage.d.ts +0 -31
  134. package/src/main/conversation/message/TeamMessage.js +0 -21
  135. package/src/main/conversation/message/TextContentBuilder.d.ts +0 -13
  136. package/src/main/conversation/message/TextContentBuilder.js +0 -75
  137. package/src/main/conversation/message/UserClientsUtil.d.ts +0 -22
  138. package/src/main/conversation/message/UserClientsUtil.js +0 -38
  139. package/src/main/conversation/message/UserMessage.d.ts +0 -43
  140. package/src/main/conversation/message/UserMessage.js +0 -21
  141. package/src/main/cryptography/AssetCryptography/EncryptedAsset.d.ts +0 -11
  142. package/src/main/cryptography/AssetCryptography/EncryptedAsset.js +0 -21
  143. package/src/main/cryptography/AssetCryptography/crypto.browser.d.ts +0 -2
  144. package/src/main/cryptography/AssetCryptography/crypto.browser.js +0 -46
  145. package/src/main/cryptography/AssetCryptography/crypto.node.d.ts +0 -2
  146. package/src/main/cryptography/AssetCryptography/crypto.node.js +0 -68
  147. package/src/main/cryptography/AssetCryptography/index.d.ts +0 -8
  148. package/src/main/cryptography/AssetCryptography/index.js +0 -53
  149. package/src/main/cryptography/AssetCryptography/interfaces.d.ts +0 -9
  150. package/src/main/cryptography/AssetCryptography/interfaces.js +0 -21
  151. package/src/main/cryptography/CryptographyDatabaseRepository.d.ts +0 -16
  152. package/src/main/cryptography/CryptographyDatabaseRepository.js +0 -42
  153. package/src/main/cryptography/CryptographyService.d.ts +0 -52
  154. package/src/main/cryptography/CryptographyService.js +0 -205
  155. package/src/main/cryptography/GenericMessageMapper.d.ts +0 -6
  156. package/src/main/cryptography/GenericMessageMapper.js +0 -160
  157. package/src/main/cryptography/MessageHashService.d.ts +0 -16
  158. package/src/main/cryptography/MessageHashService.js +0 -114
  159. package/src/main/cryptography/SessionPayloadBundle.d.ts +0 -4
  160. package/src/main/cryptography/SessionPayloadBundle.js +0 -21
  161. package/src/main/cryptography/index.d.ts +0 -4
  162. package/src/main/cryptography/index.js +0 -35
  163. package/src/main/giphy/GiphyService.d.ts +0 -9
  164. package/src/main/giphy/GiphyService.js +0 -37
  165. package/src/main/giphy/index.d.ts +0 -1
  166. package/src/main/giphy/index.js +0 -32
  167. package/src/main/index.d.ts +0 -17
  168. package/src/main/index.js +0 -55
  169. package/src/main/linkPreview/LinkPreviewService.d.ts +0 -7
  170. package/src/main/linkPreview/LinkPreviewService.js +0 -52
  171. package/src/main/linkPreview/index.d.ts +0 -1
  172. package/src/main/linkPreview/index.js +0 -32
  173. package/src/main/notification/NotificationBackendRepository.d.ts +0 -11
  174. package/src/main/notification/NotificationBackendRepository.js +0 -34
  175. package/src/main/notification/NotificationDatabaseRepository.d.ts +0 -45
  176. package/src/main/notification/NotificationDatabaseRepository.js +0 -107
  177. package/src/main/notification/NotificationService.d.ts +0 -107
  178. package/src/main/notification/NotificationService.js +0 -411
  179. package/src/main/notification/index.d.ts +0 -1
  180. package/src/main/notification/index.js +0 -32
  181. package/src/main/notification/types.d.ts +0 -17
  182. package/src/main/notification/types.js +0 -21
  183. package/src/main/self/SelfService.d.ts +0 -13
  184. package/src/main/self/SelfService.js +0 -55
  185. package/src/main/self/index.d.ts +0 -1
  186. package/src/main/self/index.js +0 -32
  187. package/src/main/team/TeamService.d.ts +0 -15
  188. package/src/main/team/TeamService.js +0 -55
  189. package/src/main/team/index.d.ts +0 -1
  190. package/src/main/team/index.js +0 -32
  191. package/src/main/test/CryptographyHelper.d.ts +0 -4
  192. package/src/main/test/CryptographyHelper.js +0 -65
  193. package/src/main/test/PayloadHelper.d.ts +0 -3
  194. package/src/main/test/PayloadHelper.js +0 -66
  195. package/src/main/user/UserMapper.d.ts +0 -5
  196. package/src/main/user/UserMapper.js +0 -88
  197. package/src/main/user/UserService.d.ts +0 -25
  198. package/src/main/user/UserService.js +0 -81
  199. package/src/main/user/index.d.ts +0 -1
  200. package/src/main/user/index.js +0 -32
  201. package/src/main/util/TaskScheduler/TaskScheduler.d.ts +0 -10
  202. package/src/main/util/TaskScheduler/TaskScheduler.js +0 -70
  203. package/src/main/util/TypePredicateUtil.d.ts +0 -7
  204. package/src/main/util/TypePredicateUtil.js +0 -55
  205. package/src/main/util/encryptedStore.d.ts +0 -45
  206. package/src/main/util/encryptedStore.js +0 -116
  207. package/src/main/util/index.d.ts +0 -1
  208. package/src/main/util/index.js +0 -32
  209. package/src/main/util/mapQualifiedUserClientIdsToFullyQualifiedClientIds.d.ts +0 -8
  210. package/src/main/util/mapQualifiedUserClientIdsToFullyQualifiedClientIds.js +0 -32
@@ -1,411 +0,0 @@
1
- "use strict";
2
- /*
3
- * Wire
4
- * Copyright (C) 2018 Wire Swiss GmbH
5
- *
6
- * This program is free software: you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation, either version 3 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program. If not, see http://www.gnu.org/licenses/.
18
- *
19
- */
20
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
21
- if (k2 === undefined) k2 = k;
22
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
23
- }) : (function(o, m, k, k2) {
24
- if (k2 === undefined) k2 = k;
25
- o[k2] = m[k];
26
- }));
27
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
28
- Object.defineProperty(o, "default", { enumerable: true, value: v });
29
- }) : function(o, v) {
30
- o["default"] = v;
31
- });
32
- var __importStar = (this && this.__importStar) || function (mod) {
33
- if (mod && mod.__esModule) return mod;
34
- var result = {};
35
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
36
- __setModuleDefault(result, mod);
37
- return result;
38
- };
39
- var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
40
- var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
41
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
42
- var g = generator.apply(thisArg, _arguments || []), i, q = [];
43
- return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
44
- function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
45
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
46
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
47
- function fulfill(value) { resume("next", value); }
48
- function reject(value) { resume("throw", value); }
49
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
50
- };
51
- var __importDefault = (this && this.__importDefault) || function (mod) {
52
- return (mod && mod.__esModule) ? mod : { "default": mod };
53
- };
54
- Object.defineProperty(exports, "__esModule", { value: true });
55
- exports.NotificationService = void 0;
56
- const Events = __importStar(require("@wireapp/api-client/src/event"));
57
- const store_engine_1 = require("@wireapp/store-engine");
58
- const events_1 = require("events");
59
- const logdown_1 = __importDefault(require("logdown"));
60
- const conversation_1 = require("../conversation");
61
- const ConversationMapper_1 = require("../conversation/ConversationMapper");
62
- const CoreError_1 = require("../CoreError");
63
- const UserMapper_1 = require("../user/UserMapper");
64
- const NotificationBackendRepository_1 = require("./NotificationBackendRepository");
65
- const NotificationDatabaseRepository_1 = require("./NotificationDatabaseRepository");
66
- const protocol_messaging_1 = require("@wireapp/protocol-messaging");
67
- const bazinga64_1 = require("bazinga64");
68
- const TaskScheduler_1 = require("../util/TaskScheduler/TaskScheduler");
69
- var TOPIC;
70
- (function (TOPIC) {
71
- TOPIC["NOTIFICATION_ERROR"] = "NotificationService.TOPIC.NOTIFICATION_ERROR";
72
- })(TOPIC || (TOPIC = {}));
73
- class NotificationService extends events_1.EventEmitter {
74
- constructor(apiClient, cryptographyService, storeEngine, coreCryptoClientProvider) {
75
- super();
76
- this.coreCryptoClientProvider = coreCryptoClientProvider;
77
- this.logger = (0, logdown_1.default)('@wireapp/core/notification/NotificationService', {
78
- logger: console,
79
- markdown: false,
80
- });
81
- this.apiClient = apiClient;
82
- this.cryptographyService = cryptographyService;
83
- this.backend = new NotificationBackendRepository_1.NotificationBackendRepository(this.apiClient);
84
- this.database = new NotificationDatabaseRepository_1.NotificationDatabaseRepository(storeEngine);
85
- }
86
- async getAllNotifications() {
87
- const clientId = this.apiClient.clientId;
88
- const lastNotificationId = await this.database.getLastNotificationId();
89
- return this.backend.getAllNotifications(clientId, lastNotificationId);
90
- }
91
- /** Should only be called with a completely new client. */
92
- async initializeNotificationStream() {
93
- const clientId = this.apiClient.clientId;
94
- await this.setLastEventDate(new Date(0));
95
- const latestNotification = await this.backend.getLastNotification(clientId);
96
- return this.setLastNotificationId(latestNotification);
97
- }
98
- async hasHistory() {
99
- const notificationEvents = await this.getNotificationEventList();
100
- return !!notificationEvents.length;
101
- }
102
- getNotificationEventList() {
103
- return this.database.getNotificationEventList();
104
- }
105
- async setLastEventDate(eventDate) {
106
- let databaseLastEventDate;
107
- try {
108
- databaseLastEventDate = await this.database.getLastEventDate();
109
- }
110
- catch (error) {
111
- if (error instanceof store_engine_1.error.RecordNotFoundError ||
112
- error.constructor.name === store_engine_1.error.RecordNotFoundError.name) {
113
- return this.database.createLastEventDate(eventDate);
114
- }
115
- throw error;
116
- }
117
- if (databaseLastEventDate && eventDate > databaseLastEventDate) {
118
- return this.database.updateLastEventDate(eventDate);
119
- }
120
- return databaseLastEventDate;
121
- }
122
- async setLastNotificationId(lastNotification) {
123
- return this.database.updateLastNotificationId(lastNotification);
124
- }
125
- async handleNotificationStream(notificationHandler, onMissedNotifications, abortHandler) {
126
- const { notifications, missedNotification } = await this.getAllNotifications();
127
- if (missedNotification) {
128
- onMissedNotifications(missedNotification);
129
- }
130
- for (const [index, notification] of notifications.entries()) {
131
- if (abortHandler.isAborted()) {
132
- /* Stop handling notifications if the websocket has been disconnected.
133
- * Upon reconnecting we are going to restart handling the notification stream for where we left of
134
- */
135
- return;
136
- }
137
- await notificationHandler(notification, conversation_1.PayloadBundleSource.NOTIFICATION_STREAM, {
138
- done: index + 1,
139
- total: notifications.length,
140
- }).catch(error => this.logger.error(error));
141
- }
142
- }
143
- /**
144
- * Checks if an event should be ignored.
145
- * An event that has a date prior to that last event that we have parsed should be ignored
146
- *
147
- * @param event
148
- * @param source
149
- * @param lastEventDate?
150
- */
151
- isOutdatedEvent(event, source, lastEventDate) {
152
- const isFromNotificationStream = source === conversation_1.PayloadBundleSource.NOTIFICATION_STREAM;
153
- const shouldCheckEventDate = !!event.time && isFromNotificationStream && lastEventDate;
154
- if (shouldCheckEventDate) {
155
- /** This check prevents duplicated "You joined" system messages. */
156
- const isOutdated = lastEventDate.getTime() >= new Date(event.time).getTime();
157
- return isOutdated;
158
- }
159
- return false;
160
- }
161
- handleNotification(notification, source, dryRun = false) {
162
- return __asyncGenerator(this, arguments, function* handleNotification_1() {
163
- for (const event of notification.payload) {
164
- this.logger.log(`Handling event of type "${event.type}" for notification with ID "${notification.id}"`, event);
165
- let lastEventDate = undefined;
166
- try {
167
- lastEventDate = yield __await(this.database.getLastEventDate());
168
- }
169
- catch (_a) { }
170
- if ('time' in event && this.isOutdatedEvent(event, source, lastEventDate)) {
171
- this.logger.info(`Ignored outdated event type: '${event.type}'`);
172
- continue;
173
- }
174
- try {
175
- const data = yield __await(this.handleEvent(event, source, dryRun));
176
- yield yield __await(Object.assign(Object.assign({}, data), { mappedEvent: data.mappedEvent ? this.cleanupPayloadBundle(data.mappedEvent) : undefined }));
177
- }
178
- catch (error) {
179
- this.logger.error(`There was an error with notification ID "${notification.id}": ${error.message}`, error);
180
- const notificationError = {
181
- error: error,
182
- notification,
183
- type: CoreError_1.CoreError.NOTIFICATION_ERROR,
184
- };
185
- this.emit(NotificationService.TOPIC.NOTIFICATION_ERROR, notificationError);
186
- }
187
- }
188
- if (!dryRun && !notification.transient) {
189
- // keep track of the last handled notification for next time we fetch the notification stream
190
- yield __await(this.setLastNotificationId(notification));
191
- }
192
- });
193
- }
194
- cleanupPayloadBundle(payload) {
195
- switch (payload.type) {
196
- case conversation_1.PayloadBundleType.ASSET: {
197
- const assetContent = payload.content;
198
- const isMetaData = !!(assetContent === null || assetContent === void 0 ? void 0 : assetContent.original) && !(assetContent === null || assetContent === void 0 ? void 0 : assetContent.uploaded);
199
- const isAbort = !!assetContent.abortReason || (!assetContent.original && !assetContent.uploaded);
200
- if (isMetaData) {
201
- payload.type = conversation_1.PayloadBundleType.ASSET_META;
202
- }
203
- else if (isAbort) {
204
- payload.type = conversation_1.PayloadBundleType.ASSET_ABORT;
205
- }
206
- return payload;
207
- }
208
- default:
209
- return payload;
210
- }
211
- }
212
- async handleEvent(event, source, dryRun = false) {
213
- var _a, _b;
214
- const coreCryptoClient = this.coreCryptoClientProvider();
215
- switch (event.type) {
216
- case Events.CONVERSATION_EVENT.MLS_WELCOME_MESSAGE:
217
- if (!coreCryptoClient) {
218
- throw new Error('Unable to access core crypto client');
219
- }
220
- const data = bazinga64_1.Decoder.fromBase64(event.data).asBytes;
221
- // We extract the groupId from the welcome message and let coreCrypto store this group
222
- const newGroupId = await coreCryptoClient.processWelcomeMessage(data);
223
- const groupIdStr = bazinga64_1.Encoder.toBase64(newGroupId).asString;
224
- // The groupId can then be sent back to the consumer
225
- return {
226
- event,
227
- mappedEvent: ConversationMapper_1.ConversationMapper.mapConversationEvent(Object.assign(Object.assign({}, event), { data: groupIdStr }), source),
228
- };
229
- case Events.CONVERSATION_EVENT.MLS_MESSAGE_ADD:
230
- if (!coreCryptoClient) {
231
- throw new Error('Unable to access core crypto client');
232
- }
233
- const encryptedData = bazinga64_1.Decoder.fromBase64(event.data).asBytes;
234
- const groupId = await this.getUint8ArrayFromConversationGroupId((_a = event.qualified_conversation) !== null && _a !== void 0 ? _a : { id: event.conversation, domain: '' });
235
- // Check if the message includes proposals
236
- const { proposals, commitDelay, message } = await coreCryptoClient.decryptMessage(groupId, encryptedData);
237
- if (proposals.length > 0) {
238
- await this.handlePendingProposals({
239
- groupId: groupId.toString(),
240
- delayInMs: commitDelay !== null && commitDelay !== void 0 ? commitDelay : 0,
241
- eventTime: event.time,
242
- });
243
- }
244
- if (!message) {
245
- throw new Error(`MLS message received from ${source} was empty`);
246
- }
247
- const decryptedData = protocol_messaging_1.GenericMessage.decode(message);
248
- /**
249
- * @todo Find a proper solution to add mappedEvent to this return
250
- * otherwise event.data will be base64 raw data of the received event
251
- */
252
- return { event, decryptedData };
253
- // Encrypted Proteus events
254
- case Events.CONVERSATION_EVENT.OTR_MESSAGE_ADD: {
255
- if (dryRun) {
256
- // In case of a dry run, we do not want to decrypt messages
257
- // We just return the raw event to the caller
258
- return { event };
259
- }
260
- try {
261
- const decryptedData = await this.cryptographyService.decryptMessage(event);
262
- return {
263
- mappedEvent: this.cryptographyService.mapGenericMessage(event, decryptedData, source),
264
- event,
265
- decryptedData,
266
- };
267
- }
268
- catch (error) {
269
- return { event, decryptionError: error };
270
- }
271
- }
272
- // Meta events
273
- case Events.CONVERSATION_EVENT.MEMBER_JOIN:
274
- // As of today (07/07/2022) the backend sends `WELCOME` message to the user's own conversation (not the actual conversation that the welcome should be part of)
275
- // So in order to map conversation Ids and groupId together, we need to first fetch the conversation and get the groupId linked to it.
276
- const conversation = await this.apiClient.api.conversation.getConversation((_b = event.qualified_conversation) !== null && _b !== void 0 ? _b : { id: event.conversation, domain: '' });
277
- if (!conversation) {
278
- throw new Error('no conv');
279
- }
280
- await this.saveConversationGroupId(conversation);
281
- case Events.CONVERSATION_EVENT.MESSAGE_TIMER_UPDATE:
282
- case Events.CONVERSATION_EVENT.RENAME:
283
- case Events.CONVERSATION_EVENT.TYPING: {
284
- const { conversation, from } = event;
285
- const metaEvent = Object.assign(Object.assign({}, event), { conversation, from });
286
- return { mappedEvent: ConversationMapper_1.ConversationMapper.mapConversationEvent(metaEvent, source), event };
287
- }
288
- // User events
289
- case Events.USER_EVENT.CONNECTION:
290
- case Events.USER_EVENT.CLIENT_ADD:
291
- case Events.USER_EVENT.UPDATE:
292
- case Events.USER_EVENT.CLIENT_REMOVE: {
293
- return { mappedEvent: UserMapper_1.UserMapper.mapUserEvent(event, this.apiClient.context.userId, source), event };
294
- }
295
- }
296
- return { event };
297
- }
298
- /**
299
- * ## MLS only ##
300
- * If there is a groupId in the conversation, we need to store the conversationId => groupId pair
301
- * in order to find the groupId when decrypting messages
302
- * This is a bit hacky but since mls messages do not embed the groupId we need to keep a mapping of those
303
- *
304
- * @param conversation conversation with group_id
305
- */
306
- async saveConversationGroupId(conversation) {
307
- if (conversation.group_id) {
308
- const { group_id: groupId, qualified_id: { id: conversationId, domain: conversationDomain }, } = conversation;
309
- await this.database.addCompoundGroupId({ conversationDomain, conversationId, groupId });
310
- }
311
- }
312
- /**
313
- * ## MLS only ##
314
- * If there is a matching conversationId => groupId pair in the database,
315
- * we can find the groupId and return it as a Uint8Array
316
- *
317
- * @param conversationQualifiedId
318
- */
319
- async getUint8ArrayFromConversationGroupId(conversationQualifiedId) {
320
- const { id: conversationId, domain: conversationDomain } = conversationQualifiedId;
321
- const groupId = await this.database.getCompoundGroupId({
322
- conversationId,
323
- conversationDomain,
324
- });
325
- if (!groupId) {
326
- throw new Error(`Could not find a group_id for conversation ${conversationId}@${conversationDomain}`);
327
- }
328
- return bazinga64_1.Decoder.fromBase64(groupId).asBytes;
329
- }
330
- /**
331
- * ## MLS only ##
332
- * If there are pending proposals, we need to either process them,
333
- * or save them in the database for later processing
334
- *
335
- * @param groupId groupId of the mls conversation
336
- * @param delayInMs delay in ms before processing proposals
337
- * @param eventTime time of the event that had the proposals
338
- */
339
- async handlePendingProposals({ delayInMs, groupId, eventTime }) {
340
- if (delayInMs > 0) {
341
- const eventDate = new Date(eventTime);
342
- const firingDate = eventDate.setTime(eventDate.getTime() + delayInMs);
343
- try {
344
- await this.database.storePendingProposal({
345
- groupId,
346
- firingDate,
347
- });
348
- }
349
- catch (error) {
350
- this.logger.error('Could not store pending proposal', error);
351
- }
352
- finally {
353
- TaskScheduler_1.TaskScheduler.addTask({
354
- task: () => this.commitPendingProposals({ groupId }),
355
- firingDate,
356
- key: groupId,
357
- });
358
- }
359
- }
360
- else {
361
- await this.commitPendingProposals({ groupId, skipDelete: true });
362
- }
363
- }
364
- /**
365
- * ## MLS only ##
366
- * Commit all pending proposals for a given groupId
367
- *
368
- * @param groupId groupId of the conversation
369
- * @param skipDelete if true, do not delete the pending proposals from the database
370
- */
371
- async commitPendingProposals({ groupId, skipDelete = false }) {
372
- const coreCryptoClient = this.coreCryptoClientProvider();
373
- if (!coreCryptoClient) {
374
- throw new Error('Could not get coreCryptoClient');
375
- }
376
- try {
377
- await coreCryptoClient.commitPendingProposals(bazinga64_1.Decoder.fromBase64(groupId).asBytes);
378
- if (!skipDelete) {
379
- TaskScheduler_1.TaskScheduler.cancelTask(groupId);
380
- await this.database.deletePendingProposal({ groupId });
381
- }
382
- }
383
- catch (error) {
384
- this.logger.error(`Error while committing pending proposals for groupId ${groupId}`, error);
385
- }
386
- }
387
- /**
388
- * ## MLS only ##
389
- * Get all pending proposals from the database and schedule them
390
- * Function must only be called once, after application start
391
- *
392
- */
393
- async checkExistingPendingProposals() {
394
- try {
395
- const pendingProposals = await this.database.getStoredPendingProposals();
396
- if (pendingProposals.length > 0) {
397
- pendingProposals.forEach(({ groupId, firingDate }) => TaskScheduler_1.TaskScheduler.addTask({
398
- task: () => this.commitPendingProposals({ groupId }),
399
- firingDate,
400
- key: groupId,
401
- }));
402
- }
403
- }
404
- catch (error) {
405
- this.logger.error('Could not get pending proposals', error);
406
- }
407
- }
408
- }
409
- exports.NotificationService = NotificationService;
410
- NotificationService.TOPIC = TOPIC;
411
- //# sourceMappingURL=NotificationService.js.map
@@ -1 +0,0 @@
1
- export * from './NotificationService';
@@ -1,32 +0,0 @@
1
- "use strict";
2
- /*
3
- * Wire
4
- * Copyright (C) 2018 Wire Swiss GmbH
5
- *
6
- * This program is free software: you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation, either version 3 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program. If not, see http://www.gnu.org/licenses/.
18
- *
19
- */
20
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
21
- if (k2 === undefined) k2 = k;
22
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
23
- }) : (function(o, m, k, k2) {
24
- if (k2 === undefined) k2 = k;
25
- o[k2] = m[k];
26
- }));
27
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
28
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
29
- };
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- __exportStar(require("./NotificationService"), exports);
32
- //# sourceMappingURL=index.js.map
@@ -1,17 +0,0 @@
1
- export declare type CommonMLS = {
2
- groupId: string;
3
- };
4
- export declare type CompoundGroupIdParams = {
5
- conversationId: string;
6
- conversationDomain: string;
7
- } & CommonMLS;
8
- export declare type HandlePendingProposalsParams = {
9
- delayInMs: number;
10
- eventTime: string;
11
- } & CommonMLS;
12
- export declare type CommitPendingProposalsParams = {
13
- skipDelete?: boolean;
14
- } & CommonMLS;
15
- export declare type StorePendingProposalsParams = {
16
- firingDate: number;
17
- } & CommonMLS;
@@ -1,21 +0,0 @@
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
@@ -1,13 +0,0 @@
1
- import type { APIClient } from '@wireapp/api-client';
2
- import type { Self } from '@wireapp/api-client/src/self/';
3
- export declare class SelfService {
4
- private readonly apiClient;
5
- constructor(apiClient: APIClient);
6
- checkUsername(username: string): Promise<boolean>;
7
- checkUsernames(usernames: string[]): Promise<string[]>;
8
- getName(): Promise<string>;
9
- getSelf(): Promise<Self>;
10
- getUsername(): Promise<string | undefined>;
11
- setName(name: string): Promise<void>;
12
- setUsername(username: string): Promise<void>;
13
- }
@@ -1,55 +0,0 @@
1
- "use strict";
2
- /*
3
- * Wire
4
- * Copyright (C) 2018 Wire Swiss GmbH
5
- *
6
- * This program is free software: you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation, either version 3 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program. If not, see http://www.gnu.org/licenses/.
18
- *
19
- */
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.SelfService = void 0;
22
- class SelfService {
23
- constructor(apiClient) {
24
- this.apiClient = apiClient;
25
- }
26
- async checkUsername(username) {
27
- const [availableUsername] = await this.checkUsernames([username]);
28
- return !!availableUsername;
29
- }
30
- checkUsernames(usernames) {
31
- return this.apiClient.api.user.postHandles({
32
- handles: usernames,
33
- });
34
- }
35
- async getName() {
36
- const { name } = await this.apiClient.api.self.getName();
37
- return name;
38
- }
39
- async getSelf() {
40
- const selfData = await this.apiClient.api.self.getSelf();
41
- return selfData;
42
- }
43
- async getUsername() {
44
- const { handle } = await this.getSelf();
45
- return handle;
46
- }
47
- setName(name) {
48
- return this.apiClient.api.self.putSelf({ name });
49
- }
50
- setUsername(username) {
51
- return this.apiClient.api.self.putHandle({ handle: username });
52
- }
53
- }
54
- exports.SelfService = SelfService;
55
- //# sourceMappingURL=SelfService.js.map
@@ -1 +0,0 @@
1
- export * from './SelfService';
@@ -1,32 +0,0 @@
1
- "use strict";
2
- /*
3
- * Wire
4
- * Copyright (C) 2018 Wire Swiss GmbH
5
- *
6
- * This program is free software: you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation, either version 3 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program. If not, see http://www.gnu.org/licenses/.
18
- *
19
- */
20
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
21
- if (k2 === undefined) k2 = k;
22
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
23
- }) : (function(o, m, k, k2) {
24
- if (k2 === undefined) k2 = k;
25
- o[k2] = m[k];
26
- }));
27
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
28
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
29
- };
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- __exportStar(require("./SelfService"), exports);
32
- //# sourceMappingURL=index.js.map
@@ -1,15 +0,0 @@
1
- import type { APIClient } from '@wireapp/api-client';
2
- import type { MemberData, Members, NewTeamData, TeamChunkData, TeamData, UpdateTeamData } from '@wireapp/api-client/src/team/';
3
- export declare class TeamService {
4
- private readonly apiClient;
5
- constructor(apiClient: APIClient);
6
- addMember(teamId: string, memberData: MemberData): Promise<void>;
7
- createTeam(teamData: NewTeamData): Promise<void>;
8
- deleteTeam(teamId: string, password: string): Promise<void>;
9
- getAllMembers(teamId: string): Promise<Members>;
10
- getTeam(teamId: string): Promise<TeamData>;
11
- getTeams(): Promise<TeamChunkData>;
12
- removeMember(teamId: string, userId: string, password: string): Promise<void>;
13
- updateMember(teamId: string, memberData: MemberData): Promise<void>;
14
- updateTeam(teamId: string, teamData: UpdateTeamData): Promise<void>;
15
- }
@@ -1,55 +0,0 @@
1
- "use strict";
2
- /*
3
- * Wire
4
- * Copyright (C) 2018 Wire Swiss GmbH
5
- *
6
- * This program is free software: you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation, either version 3 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program. If not, see http://www.gnu.org/licenses/.
18
- *
19
- */
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.TeamService = void 0;
22
- class TeamService {
23
- constructor(apiClient) {
24
- this.apiClient = apiClient;
25
- }
26
- addMember(teamId, memberData) {
27
- return this.apiClient.api.teams.member.postMembers(teamId, memberData);
28
- }
29
- createTeam(teamData) {
30
- return this.apiClient.api.teams.team.postTeam(teamData);
31
- }
32
- deleteTeam(teamId, password) {
33
- return this.apiClient.api.teams.team.deleteTeam(teamId, password);
34
- }
35
- getAllMembers(teamId) {
36
- return this.apiClient.api.teams.member.getAllMembers(teamId);
37
- }
38
- getTeam(teamId) {
39
- return this.apiClient.api.teams.team.getTeam(teamId);
40
- }
41
- getTeams() {
42
- return this.apiClient.api.teams.team.getTeams();
43
- }
44
- removeMember(teamId, userId, password) {
45
- return this.apiClient.api.teams.member.deleteMember(teamId, userId, password);
46
- }
47
- updateMember(teamId, memberData) {
48
- return this.apiClient.api.teams.member.putMembers(teamId, memberData);
49
- }
50
- updateTeam(teamId, teamData) {
51
- return this.apiClient.api.teams.team.putTeam(teamId, teamData);
52
- }
53
- }
54
- exports.TeamService = TeamService;
55
- //# sourceMappingURL=TeamService.js.map
@@ -1 +0,0 @@
1
- export * from './TeamService';