@wireapp/core 46.0.19 → 46.1.0-hotfix-1.1

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 (122) hide show
  1. package/lib/Account.js +56 -43
  2. package/lib/account/AccountService.js +0 -1
  3. package/lib/broadcast/BroadcastService.js +0 -3
  4. package/lib/client/ClientBackendRepository.js +0 -1
  5. package/lib/client/ClientDatabaseRepository.js +7 -16
  6. package/lib/client/ClientService.d.ts.map +1 -1
  7. package/lib/client/ClientService.js +13 -14
  8. package/lib/connection/ConnectionService.js +0 -1
  9. package/lib/conversation/AssetService/AssetService.d.ts +1 -0
  10. package/lib/conversation/AssetService/AssetService.d.ts.map +1 -1
  11. package/lib/conversation/AssetService/AssetService.js +6 -13
  12. package/lib/conversation/AssetService/AssetService.test.js +1 -1
  13. package/lib/conversation/ConversationService/ConversationService.d.ts +1 -1
  14. package/lib/conversation/ConversationService/ConversationService.d.ts.map +1 -1
  15. package/lib/conversation/ConversationService/ConversationService.js +87 -91
  16. package/lib/conversation/ConversationService/ConversationService.test.js +7 -14
  17. package/lib/conversation/ConversationService/Utility/getConversationQualifiedMembers.d.ts.map +1 -1
  18. package/lib/conversation/MessageTimer/MessageTimer.js +0 -2
  19. package/lib/conversation/SubconversationService/SubconversationService.d.ts.map +1 -1
  20. package/lib/conversation/SubconversationService/SubconversationService.js +17 -23
  21. package/lib/conversation/content/AssetContent.d.ts +1 -0
  22. package/lib/conversation/content/AssetContent.d.ts.map +1 -1
  23. package/lib/conversation/content/ContentType.js +19 -18
  24. package/lib/conversation/content/FileContent.d.ts +1 -0
  25. package/lib/conversation/content/FileContent.d.ts.map +1 -1
  26. package/lib/conversation/content/ImageContent.d.ts +1 -0
  27. package/lib/conversation/content/ImageContent.d.ts.map +1 -1
  28. package/lib/conversation/message/MessageBuilder.js +23 -22
  29. package/lib/conversation/message/MessageService.js +4 -5
  30. package/lib/conversation/message/MessageService.test.js +9 -20
  31. package/lib/conversation/message/MessageToProtoMapper.js +2 -2
  32. package/lib/conversation/message/RecipientsHelper.js +2 -1
  33. package/lib/conversation/message/TextContentBuilder.js +2 -3
  34. package/lib/conversation/message/UserClientsUtil.js +3 -2
  35. package/lib/conversation/message/messageSender.js +6 -5
  36. package/lib/cryptography/AssetCryptography/AssetCryptography.d.ts.map +1 -1
  37. package/lib/cryptography/GenericMessageMapper.js +22 -74
  38. package/lib/cryptography/MessageHashService.d.ts +1 -0
  39. package/lib/cryptography/MessageHashService.d.ts.map +1 -1
  40. package/lib/cryptography/MessageHashService.js +0 -2
  41. package/lib/errors/DecryptionError.js +0 -2
  42. package/lib/errors/FederatedBackendsError.js +2 -3
  43. package/lib/giphy/GiphyService.js +0 -1
  44. package/lib/linkPreview/LinkPreviewService.js +12 -2
  45. package/lib/messagingProtocols/mls/E2EIdentityService/Connection/AcmeServer/AcmeService.d.ts +4 -4
  46. package/lib/messagingProtocols/mls/E2EIdentityService/Connection/AcmeServer/AcmeService.js +8 -9
  47. package/lib/messagingProtocols/mls/E2EIdentityService/Connection/AcmeServer/schema.d.ts +8 -8
  48. package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.js +3 -33
  49. package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.test.js +11 -11
  50. package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.js +5 -15
  51. package/lib/messagingProtocols/mls/E2EIdentityService/Helper/index.d.ts.map +1 -1
  52. package/lib/messagingProtocols/mls/E2EIdentityService/Helper/index.js +0 -1
  53. package/lib/messagingProtocols/mls/E2EIdentityService/Steps/Account.d.ts.map +1 -1
  54. package/lib/messagingProtocols/mls/E2EIdentityService/Steps/Account.js +1 -1
  55. package/lib/messagingProtocols/mls/E2EIdentityService/Steps/Authorization.d.ts +1 -1
  56. package/lib/messagingProtocols/mls/E2EIdentityService/Steps/Authorization.d.ts.map +1 -1
  57. package/lib/messagingProtocols/mls/E2EIdentityService/Steps/Authorization.js +3 -2
  58. package/lib/messagingProtocols/mls/E2EIdentityService/Steps/Certificate.js +1 -1
  59. package/lib/messagingProtocols/mls/E2EIdentityService/Steps/Order.d.ts.map +1 -1
  60. package/lib/messagingProtocols/mls/E2EIdentityService/Steps/Order.js +2 -2
  61. package/lib/messagingProtocols/mls/E2EIdentityService/Storage/E2EIStorage.d.ts.map +1 -1
  62. package/lib/messagingProtocols/mls/E2EIdentityService/Storage/E2EIStorage.js +2 -1
  63. package/lib/messagingProtocols/mls/E2EIdentityService/Storage/E2EIStorage.schema.d.ts +4 -4
  64. package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/IncomingMesssagesQueue.d.ts.map +1 -1
  65. package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.d.ts.map +1 -1
  66. package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.js +1 -1
  67. package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.d.ts.map +1 -1
  68. package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.js +1 -1
  69. package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.test.js +3 -7
  70. package/lib/messagingProtocols/mls/MLSService/ClientMLSError.js +0 -1
  71. package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.d.ts.map +1 -1
  72. package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts +3 -3
  73. package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts.map +1 -1
  74. package/lib/messagingProtocols/mls/MLSService/MLSService.js +120 -114
  75. package/lib/messagingProtocols/mls/MLSService/MLSService.test.js +9 -31
  76. package/lib/messagingProtocols/mls/MLSService/commitBundleUtil.js +2 -1
  77. package/lib/messagingProtocols/mls/conversationRejoinQueue.js +4 -3
  78. package/lib/messagingProtocols/mls/utils/MLSId.js +3 -2
  79. package/lib/messagingProtocols/proteus/EventHandler/events/otrMessageAdd/otrMessageAdd.d.ts.map +1 -1
  80. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.js +2 -6
  81. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.js +0 -3
  82. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.store.js +1 -1
  83. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoboxWrapper.js +4 -5
  84. package/lib/messagingProtocols/proteus/ProteusService/DecryptionErrorGenerator/DecryptionErrorGenerator.js +2 -1
  85. package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts.map +1 -1
  86. package/lib/messagingProtocols/proteus/ProteusService/ProteusService.js +16 -20
  87. package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts +7 -4
  88. package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts.map +1 -1
  89. package/lib/messagingProtocols/proteus/ProteusService/ProteusService.test.js +15 -15
  90. package/lib/messagingProtocols/proteus/ProteusService/cryptoMigrationStateStore.js +1 -1
  91. package/lib/messagingProtocols/proteus/ProteusService/identityClearer.js +2 -1
  92. package/lib/messagingProtocols/proteus/ProteusService/sessionIdMigrator.js +3 -2
  93. package/lib/messagingProtocols/proteus/ProteusService/userDomainFilters.js +2 -1
  94. package/lib/messagingProtocols/proteus/Utility/Recipients.d.ts.map +1 -1
  95. package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.d.ts.map +1 -1
  96. package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.js +14 -14
  97. package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.test.js +2 -5
  98. package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.d.ts.map +1 -1
  99. package/lib/notification/NotificationBackendRepository.d.ts +1 -1
  100. package/lib/notification/NotificationBackendRepository.js +0 -1
  101. package/lib/notification/NotificationDatabaseRepository.js +0 -1
  102. package/lib/notification/NotificationService.js +49 -38
  103. package/lib/secretStore/encryptedStore.js +22 -10
  104. package/lib/secretStore/secretKeyGenerator.js +2 -2
  105. package/lib/secretStore/secretKeyGenerator.test.js +1 -1
  106. package/lib/self/SelfService.js +1 -2
  107. package/lib/storage/CoreDB.js +3 -2
  108. package/lib/team/TeamService.js +0 -1
  109. package/lib/test/PayloadHelper.js +4 -3
  110. package/lib/testUtils/index.js +3 -2
  111. package/lib/user/UserService.d.ts +2 -2
  112. package/lib/user/UserService.js +0 -1
  113. package/lib/util/LocalStorageStore/index.d.ts.map +1 -1
  114. package/lib/util/LowPrecisionTaskScheduler/LowPrecisionTaskScheduler.js +6 -4
  115. package/lib/util/RecurringTaskScheduler/RecurringTaskScheduler.d.ts.map +1 -1
  116. package/lib/util/RecurringTaskScheduler/RecurringTaskScheduler.js +33 -34
  117. package/lib/util/TaskScheduler/TaskScheduler.d.ts +1 -1
  118. package/lib/util/TaskScheduler/TaskScheduler.d.ts.map +1 -1
  119. package/lib/util/TypePredicateUtil.js +10 -7
  120. package/lib/util/fullyQualifiedClientIdUtils.js +2 -1
  121. package/package.json +9 -9
  122. package/LICENSE +0 -674
@@ -17,6 +17,19 @@
17
17
  * along with this program. If not, see http://www.gnu.org/licenses/.
18
18
  *
19
19
  */
20
+ var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
21
+ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
22
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
23
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
24
+ return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
25
+ function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
26
+ function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
27
+ function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
28
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
29
+ function fulfill(value) { resume("next", value); }
30
+ function reject(value) { resume("throw", value); }
31
+ function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
32
+ };
20
33
  var __importDefault = (this && this.__importDefault) || function (mod) {
21
34
  return (mod && mod.__esModule) ? mod : { "default": mod };
22
35
  };
@@ -34,18 +47,13 @@ var TOPIC;
34
47
  TOPIC["NOTIFICATION_ERROR"] = "NotificationService.TOPIC.NOTIFICATION_ERROR";
35
48
  })(TOPIC || (TOPIC = {}));
36
49
  class NotificationService extends commons_1.TypedEventEmitter {
37
- conversationService;
38
- apiClient;
39
- backend;
40
- database;
41
- logger = (0, logdown_1.default)('@wireapp/core/NotificationService', {
42
- logger: console,
43
- markdown: false,
44
- });
45
- static TOPIC = TOPIC;
46
50
  constructor(apiClient, storeEngine, conversationService) {
47
51
  super();
48
52
  this.conversationService = conversationService;
53
+ this.logger = (0, logdown_1.default)('@wireapp/core/NotificationService', {
54
+ logger: console,
55
+ markdown: false,
56
+ });
49
57
  this.apiClient = apiClient;
50
58
  this.backend = new NotificationBackendRepository_1.NotificationBackendRepository(this.apiClient);
51
59
  this.database = new NotificationDatabaseRepository_1.NotificationDatabaseRepository(storeEngine);
@@ -139,38 +147,40 @@ class NotificationService extends commons_1.TypedEventEmitter {
139
147
  }
140
148
  return false;
141
149
  }
142
- async *handleNotification(notification, source, dryRun = false) {
143
- for (const event of notification.payload) {
144
- this.logger.debug(`Handling event of type "${event.type}"`, event);
145
- let lastEventDate = undefined;
146
- try {
147
- lastEventDate = await this.database.getLastEventDate();
148
- }
149
- catch { }
150
- if ('time' in event && this.isOutdatedEvent(event, source, lastEventDate)) {
151
- this.logger.info(`Ignored outdated event type: '${event.type}'`);
152
- continue;
153
- }
154
- try {
155
- const handledEventResult = await this.handleEvent(event, dryRun);
156
- if (handledEventResult.status === 'handled' && handledEventResult.payload) {
157
- yield handledEventResult.payload;
150
+ handleNotification(notification_1, source_1) {
151
+ return __asyncGenerator(this, arguments, function* handleNotification_1(notification, source, dryRun = false) {
152
+ for (const event of notification.payload) {
153
+ this.logger.log(`Handling event of type "${event.type}" for notification with ID "${notification.id}"`, event);
154
+ let lastEventDate = undefined;
155
+ try {
156
+ lastEventDate = yield __await(this.database.getLastEventDate());
157
+ }
158
+ catch (_a) { }
159
+ if ('time' in event && this.isOutdatedEvent(event, source, lastEventDate)) {
160
+ this.logger.info(`Ignored outdated event type: '${event.type}'`);
161
+ continue;
162
+ }
163
+ try {
164
+ const handledEventResult = yield __await(this.handleEvent(event, dryRun));
165
+ if (handledEventResult.status === 'handled' && handledEventResult.payload) {
166
+ yield yield __await(handledEventResult.payload);
167
+ }
168
+ }
169
+ catch (error) {
170
+ this.logger.error(`There was an error with notification ID "${notification.id}": ${error.message}`, error);
171
+ const notificationError = {
172
+ error: error,
173
+ notification,
174
+ type: CoreError_1.CoreError.NOTIFICATION_ERROR,
175
+ };
176
+ this.emit(NotificationService.TOPIC.NOTIFICATION_ERROR, notificationError);
158
177
  }
159
178
  }
160
- catch (error) {
161
- this.logger.error(`There was an error with notification ID "${notification.id}": ${error.message}`, error);
162
- const notificationError = {
163
- error: error,
164
- notification,
165
- type: CoreError_1.CoreError.NOTIFICATION_ERROR,
166
- };
167
- this.emit(NotificationService.TOPIC.NOTIFICATION_ERROR, notificationError);
179
+ if (!dryRun && !notification.transient) {
180
+ // keep track of the last handled notification for next time we fetch the notification stream
181
+ yield __await(this.setLastNotificationId(notification));
168
182
  }
169
- }
170
- if (!dryRun && !notification.transient) {
171
- // keep track of the last handled notification for next time we fetch the notification stream
172
- await this.setLastNotificationId(notification);
173
- }
183
+ });
174
184
  }
175
185
  /**
176
186
  * Will process one event
@@ -192,3 +202,4 @@ class NotificationService extends commons_1.TypedEventEmitter {
192
202
  }
193
203
  }
194
204
  exports.NotificationService = NotificationService;
205
+ NotificationService.TOPIC = TOPIC;
@@ -17,22 +17,31 @@
17
17
  * along with this program. If not, see http://www.gnu.org/licenses/.
18
18
  *
19
19
  */
20
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
21
+ if (kind === "m") throw new TypeError("Private method is not writable");
22
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
23
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
24
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
25
+ };
26
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
27
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
28
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
29
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
30
+ };
31
+ var _EncryptedStore_decrypt, _EncryptedStore_encrypt;
20
32
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.EncryptedStore = void 0;
22
- exports.createEncryptedStore = createEncryptedStore;
23
- exports.createCustomEncryptedStore = createCustomEncryptedStore;
33
+ exports.createCustomEncryptedStore = exports.createEncryptedStore = exports.EncryptedStore = void 0;
24
34
  const idb_1 = require("idb");
25
35
  class EncryptedStore {
26
- db;
27
- #decrypt;
28
- #encrypt;
29
36
  constructor(db, { encrypt, decrypt }) {
30
37
  this.db = db;
31
- this.#encrypt = encrypt;
32
- this.#decrypt = decrypt;
38
+ _EncryptedStore_decrypt.set(this, void 0);
39
+ _EncryptedStore_encrypt.set(this, void 0);
40
+ __classPrivateFieldSet(this, _EncryptedStore_encrypt, encrypt, "f");
41
+ __classPrivateFieldSet(this, _EncryptedStore_decrypt, decrypt, "f");
33
42
  }
34
43
  async saveSecretValue(primaryKey, value) {
35
- const encrypted = await this.#encrypt(value);
44
+ const encrypted = await __classPrivateFieldGet(this, _EncryptedStore_encrypt, "f").call(this, value);
36
45
  await this.db.put('secrets', encrypted, primaryKey);
37
46
  }
38
47
  async getSecretValue(primaryKey) {
@@ -40,7 +49,7 @@ class EncryptedStore {
40
49
  if (!result) {
41
50
  return undefined;
42
51
  }
43
- return this.#decrypt(result);
52
+ return __classPrivateFieldGet(this, _EncryptedStore_decrypt, "f").call(this, result);
44
53
  }
45
54
  async deleteSecretValue(primaryKey) {
46
55
  const instance = await (0, idb_1.openDB)(this.db.name, this.db.version);
@@ -56,6 +65,7 @@ class EncryptedStore {
56
65
  }
57
66
  }
58
67
  exports.EncryptedStore = EncryptedStore;
68
+ _EncryptedStore_decrypt = new WeakMap(), _EncryptedStore_encrypt = new WeakMap();
59
69
  async function generateKey() {
60
70
  return crypto.subtle.generateKey({ name: 'AES-GCM', length: 256 }, false, //whether the key is extractable (i.e. can be used in exportKey)
61
71
  ['encrypt', 'decrypt']);
@@ -95,6 +105,7 @@ async function createEncryptedStore(dbName) {
95
105
  decrypt: payload => defaultDecrypt(payload, key),
96
106
  });
97
107
  }
108
+ exports.createEncryptedStore = createEncryptedStore;
98
109
  /**
99
110
  * Will create a database that uses a custom encryption method. It needs the encrypt and decrypt function to be able to process the values stored.
100
111
  * It's the responsability of the consumer to store the encryption key
@@ -110,3 +121,4 @@ async function createCustomEncryptedStore(dbName, config) {
110
121
  });
111
122
  return new EncryptedStore(db, config);
112
123
  }
124
+ exports.createCustomEncryptedStore = createCustomEncryptedStore;
@@ -18,8 +18,7 @@
18
18
  *
19
19
  */
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.CorruptedKeyError = void 0;
22
- exports.generateSecretKey = generateSecretKey;
21
+ exports.generateSecretKey = exports.CorruptedKeyError = void 0;
23
22
  class CorruptedKeyError extends Error {
24
23
  }
25
24
  exports.CorruptedKeyError = CorruptedKeyError;
@@ -55,3 +54,4 @@ async function generateSecretKey({ keyId, keySize = 16, secretsDb, }) {
55
54
  throw error;
56
55
  }
57
56
  }
57
+ exports.generateSecretKey = generateSecretKey;
@@ -30,7 +30,7 @@ const keyId = 'test-key';
30
30
  describe('SecretKeyGenerator', () => {
31
31
  let secretsDb;
32
32
  afterEach(async () => {
33
- await secretsDb?.wipe();
33
+ await (secretsDb === null || secretsDb === void 0 ? void 0 : secretsDb.wipe());
34
34
  });
35
35
  it('generates store and deletes a secret key stored in indexeddb', async () => {
36
36
  secretsDb = await (0, encryptedStore_1.createEncryptedStore)(dbName);
@@ -24,10 +24,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.SelfService = void 0;
25
25
  const logdown_1 = __importDefault(require("logdown"));
26
26
  class SelfService {
27
- apiClient;
28
- logger = (0, logdown_1.default)('@wireapp/core/SelfService');
29
27
  constructor(apiClient) {
30
28
  this.apiClient = apiClient;
29
+ this.logger = (0, logdown_1.default)('@wireapp/core/SelfService');
31
30
  }
32
31
  async checkUsername(username) {
33
32
  const [availableUsername] = await this.checkUsernames([username]);
@@ -18,8 +18,7 @@
18
18
  *
19
19
  */
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.openDB = openDB;
22
- exports.deleteDB = deleteDB;
21
+ exports.deleteDB = exports.openDB = void 0;
23
22
  const idb_1 = require("idb");
24
23
  const VERSION = 6;
25
24
  async function openDB(dbName) {
@@ -46,6 +45,8 @@ async function openDB(dbName) {
46
45
  });
47
46
  return db;
48
47
  }
48
+ exports.openDB = openDB;
49
49
  async function deleteDB(db) {
50
50
  return (0, idb_1.deleteDB)(db.name);
51
51
  }
52
+ exports.deleteDB = deleteDB;
@@ -20,7 +20,6 @@
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.TeamService = void 0;
22
22
  class TeamService {
23
- apiClient;
24
23
  constructor(apiClient) {
25
24
  this.apiClient = apiClient;
26
25
  }
@@ -18,20 +18,20 @@
18
18
  *
19
19
  */
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.getUUID = getUUID;
22
- exports.getUrlParameter = getUrlParameter;
23
- exports.mockUserPayload = mockUserPayload;
21
+ exports.mockUserPayload = exports.getUrlParameter = exports.getUUID = void 0;
24
22
  const faker_1 = require("@faker-js/faker");
25
23
  const uuid_1 = require("uuid");
26
24
  function getUUID() {
27
25
  return (0, uuid_1.v4)();
28
26
  }
27
+ exports.getUUID = getUUID;
29
28
  function getUrlParameter(url, parameter) {
30
29
  if (typeof window === 'undefined') {
31
30
  return require('url').parse(url, true).query[parameter];
32
31
  }
33
32
  return new URL(url).searchParams.get(parameter);
34
33
  }
34
+ exports.getUrlParameter = getUrlParameter;
35
35
  function mockUserPayload(userId) {
36
36
  return {
37
37
  accent_id: 3,
@@ -59,3 +59,4 @@ function mockUserPayload(userId) {
59
59
  ],
60
60
  };
61
61
  }
62
+ exports.mockUserPayload = mockUserPayload;
@@ -18,12 +18,12 @@
18
18
  *
19
19
  */
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.generateQualifiedId = generateQualifiedId;
22
- exports.generateQualifiedIds = generateQualifiedIds;
21
+ exports.generateQualifiedIds = exports.generateQualifiedId = void 0;
23
22
  const crypto_1 = require("crypto");
24
23
  function generateQualifiedId(domain) {
25
24
  return { id: (0, crypto_1.randomUUID)(), domain };
26
25
  }
26
+ exports.generateQualifiedId = generateQualifiedId;
27
27
  function generateQualifiedIds(nbUsers, domain) {
28
28
  const users = [];
29
29
  for (let i = 0; i < nbUsers; i++) {
@@ -31,3 +31,4 @@ function generateQualifiedIds(nbUsers, domain) {
31
31
  }
32
32
  return users;
33
33
  }
34
+ exports.generateQualifiedIds = generateQualifiedIds;
@@ -7,8 +7,8 @@ export declare class UserService {
7
7
  getUser(userId: string | QualifiedId): Promise<User>;
8
8
  getUsers(userIds: QualifiedId[]): Promise<{
9
9
  found: User[];
10
- failed?: QualifiedId[];
11
- not_found?: QualifiedId[];
10
+ failed?: QualifiedId[] | undefined;
11
+ not_found?: QualifiedId[] | undefined;
12
12
  } | never[]>;
13
13
  /**
14
14
  * Get the list of other user's supported protocols.
@@ -21,7 +21,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.UserService = void 0;
22
22
  const conversation_1 = require("@wireapp/api-client/lib/conversation");
23
23
  class UserService {
24
- apiClient;
25
24
  constructor(apiClient) {
26
25
  this.apiClient = apiClient;
27
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/util/LocalStorageStore/index.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,iBAAiB,GAAI,CAAC,iBAAiB,MAAM;eAC7C,MAAM,KAAG,CAAC,GAAG,SAAS;eAUtB,MAAM,SAAS,CAAC;kBACb,MAAM;eACT,MAAM;CACjB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/util/LocalStorageStore/index.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,iBAAiB,qBAAsB,MAAM;eAC7C,MAAM,KAAG,CAAC,GAAG,SAAS;eAUtB,MAAM,SAAS,CAAC;kBACb,MAAM;eACT,MAAM;CACjB,CAAC"}
@@ -26,15 +26,17 @@ const logdown_1 = __importDefault(require("logdown"));
26
26
  const logger = (0, logdown_1.default)('@wireapp/core/TaskScheduler');
27
27
  const intervals = {};
28
28
  const addTask = ({ key, firingDate, task, intervalDelay }) => {
29
- const existingIntervalId = intervals[intervalDelay]?.timeoutId;
29
+ var _a, _b;
30
+ const existingIntervalId = (_a = intervals[intervalDelay]) === null || _a === void 0 ? void 0 : _a.timeoutId;
30
31
  if (existingIntervalId) {
31
32
  clearInterval(existingIntervalId);
32
33
  }
33
- const tasks = intervals[intervalDelay]?.tasks || {};
34
+ const tasks = ((_b = intervals[intervalDelay]) === null || _b === void 0 ? void 0 : _b.tasks) || {};
34
35
  tasks[key] = { firingDate, task };
35
36
  const timeoutId = setInterval(async () => {
37
+ var _a;
36
38
  const nowTime = new Date().getTime();
37
- const tasks = intervals[intervalDelay]?.tasks;
39
+ const tasks = (_a = intervals[intervalDelay]) === null || _a === void 0 ? void 0 : _a.tasks;
38
40
  if (!tasks) {
39
41
  return;
40
42
  }
@@ -53,7 +55,7 @@ const addTask = ({ key, firingDate, task, intervalDelay }) => {
53
55
  const cancelTask = ({ intervalDelay, key }) => {
54
56
  if (intervals[intervalDelay]) {
55
57
  const tasks = intervals[intervalDelay].tasks || {};
56
- const newTasks = { ...tasks };
58
+ const newTasks = Object.assign({}, tasks);
57
59
  delete newTasks[key];
58
60
  intervals[intervalDelay].tasks = newTasks;
59
61
  logger.info(`Scheduled task with key "${key}" prematurely cleared`);
@@ -1 +1 @@
1
- {"version":3,"file":"RecurringTaskScheduler.d.ts","sourceRoot":"","sources":["../../../src/util/RecurringTaskScheduler/RecurringTaskScheduler.ts"],"names":[],"mappings":"AAwBA,UAAU,6BAA6B;IACrC,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAClD,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC;AAED,UAAU,UAAU;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACvC,GAAG,EAAE,MAAM,CAAC;CACb;AAED,qBAAa,sBAAsB;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,6BAA6B;IAEnE,SAAgB,YAAY,yBAA8B,UAAU,KAAG,OAAO,CAAC,IAAI,CAAC,CAwBlF;IAEF,SAAgB,UAAU,YAAmB,MAAM,KAAG,OAAO,CAAC,IAAI,CAAC,CAIjE;IAEF,SAAgB,OAAO,YAAmB,MAAM,KAAG,OAAO,CAAC,OAAO,CAAC,CAEjE;CACH"}
1
+ {"version":3,"file":"RecurringTaskScheduler.d.ts","sourceRoot":"","sources":["../../../src/util/RecurringTaskScheduler/RecurringTaskScheduler.ts"],"names":[],"mappings":"AAwBA,UAAU,6BAA6B;IACrC,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAClD,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACxC;AAED,UAAU,UAAU;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACvC,GAAG,EAAE,MAAM,CAAC;CACb;AAED,qBAAa,sBAAsB;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,6BAA6B;IAEnE,SAAgB,YAAY,yBAA8B,UAAU,KAAG,QAAQ,IAAI,CAAC,CAwBlF;IAEF,SAAgB,UAAU,YAAmB,MAAM,KAAG,QAAQ,IAAI,CAAC,CAIjE;IAEF,SAAgB,OAAO,YAAmB,MAAM,KAAG,QAAQ,OAAO,CAAC,CAEjE;CACH"}
@@ -23,42 +23,41 @@ const commons_1 = require("@wireapp/commons");
23
23
  const LowPrecisionTaskScheduler_1 = require("../LowPrecisionTaskScheduler");
24
24
  const TaskScheduler_1 = require("../TaskScheduler");
25
25
  class RecurringTaskScheduler {
26
- storage;
27
26
  constructor(storage) {
28
27
  this.storage = storage;
29
- }
30
- registerTask = async ({ every, task, key }) => {
31
- const firingDate = (await this.storage.get(key)) || Date.now() + every;
32
- await this.storage.set(key, firingDate);
33
- const taskConfig = {
34
- firingDate,
35
- key,
36
- task: async () => {
37
- await this.storage.delete(key);
38
- try {
39
- await task();
40
- }
41
- finally {
42
- await this.registerTask({ every, task, key });
43
- }
44
- },
28
+ this.registerTask = async ({ every, task, key }) => {
29
+ const firingDate = (await this.storage.get(key)) || Date.now() + every;
30
+ await this.storage.set(key, firingDate);
31
+ const taskConfig = {
32
+ firingDate,
33
+ key,
34
+ task: async () => {
35
+ await this.storage.delete(key);
36
+ try {
37
+ await task();
38
+ }
39
+ finally {
40
+ await this.registerTask({ every, task, key });
41
+ }
42
+ },
43
+ };
44
+ if (every > commons_1.TimeUtil.TimeInMillis.DAY * 20) {
45
+ // If the firing date is in more that 20 days, we could switch to a lowPrecision scheduler that will avoid hitting the limit of setTimeout
46
+ // (see https://developer.mozilla.org/en-US/docs/Web/API/setTimeout#maximum_delay_value)
47
+ LowPrecisionTaskScheduler_1.LowPrecisionTaskScheduler.addTask(Object.assign(Object.assign({}, taskConfig), { intervalDelay: commons_1.TimeUtil.TimeInMillis.MINUTE }));
48
+ }
49
+ else {
50
+ TaskScheduler_1.TaskScheduler.addTask(taskConfig);
51
+ }
52
+ };
53
+ this.cancelTask = async (taskKey) => {
54
+ await this.storage.delete(taskKey);
55
+ TaskScheduler_1.TaskScheduler.cancelTask(taskKey);
56
+ LowPrecisionTaskScheduler_1.LowPrecisionTaskScheduler.cancelTask({ intervalDelay: commons_1.TimeUtil.TimeInMillis.MINUTE, key: taskKey });
45
57
  };
46
- if (every > commons_1.TimeUtil.TimeInMillis.DAY * 20) {
47
- // If the firing date is in more that 20 days, we could switch to a lowPrecision scheduler that will avoid hitting the limit of setTimeout
48
- // (see https://developer.mozilla.org/en-US/docs/Web/API/setTimeout#maximum_delay_value)
49
- LowPrecisionTaskScheduler_1.LowPrecisionTaskScheduler.addTask({ ...taskConfig, intervalDelay: commons_1.TimeUtil.TimeInMillis.MINUTE });
50
- }
51
- else {
52
- TaskScheduler_1.TaskScheduler.addTask(taskConfig);
53
- }
54
- };
55
- cancelTask = async (taskKey) => {
56
- await this.storage.delete(taskKey);
57
- TaskScheduler_1.TaskScheduler.cancelTask(taskKey);
58
- LowPrecisionTaskScheduler_1.LowPrecisionTaskScheduler.cancelTask({ intervalDelay: commons_1.TimeUtil.TimeInMillis.MINUTE, key: taskKey });
59
- };
60
- hasTask = async (taskKey) => {
61
- return !!(await this.storage.get(taskKey));
62
- };
58
+ this.hasTask = async (taskKey) => {
59
+ return !!(await this.storage.get(taskKey));
60
+ };
61
+ }
63
62
  }
64
63
  exports.RecurringTaskScheduler = RecurringTaskScheduler;
@@ -7,7 +7,7 @@ type ScheduleTaskParams = {
7
7
  export declare const TaskScheduler: {
8
8
  addTask: ({ task, firingDate, key, persist }: ScheduleTaskParams) => void;
9
9
  cancelTask: (key: string) => void;
10
- continueTask: ({ key, task }: Omit<ScheduleTaskParams, "firingDate" | "persist">) => void;
10
+ continueTask: ({ key, task }: Omit<ScheduleTaskParams, 'firingDate' | 'persist'>) => void;
11
11
  hasActiveTask: (key: string) => boolean;
12
12
  };
13
13
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"TaskScheduler.d.ts","sourceRoot":"","sources":["../../../src/util/TaskScheduler/TaskScheduler.ts"],"names":[],"mappings":"AA4BA,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAsEF,eAAO,MAAM,aAAa;kDA3DiC,kBAAkB;sBAoCpD,MAAM;kCAcI,IAAI,CAAC,kBAAkB,EAAE,YAAY,GAAG,SAAS,CAAC;yBAOzD,MAAM;CAOjC,CAAC"}
1
+ {"version":3,"file":"TaskScheduler.d.ts","sourceRoot":"","sources":["../../../src/util/TaskScheduler/TaskScheduler.ts"],"names":[],"mappings":"AA4BA,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAsEF,eAAO,MAAM,aAAa;kDA3DiC,kBAAkB;sBAoCpD,MAAM;kCAcI,KAAK,kBAAkB,EAAE,YAAY,GAAG,SAAS,CAAC;yBAOzD,MAAM;CAOjC,CAAC"}
@@ -18,24 +18,23 @@
18
18
  *
19
19
  */
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.isStringArray = isStringArray;
22
- exports.isQualifiedIdArray = isQualifiedIdArray;
23
- exports.isQualifiedUserClients = isQualifiedUserClients;
24
- exports.isUserClients = isUserClients;
25
- exports.isMLSConversation = isMLSConversation;
21
+ exports.isMLSConversation = exports.isUserClients = exports.isQualifiedUserClients = exports.isQualifiedIdArray = exports.isStringArray = void 0;
26
22
  const conversation_1 = require("@wireapp/api-client/lib/conversation/");
27
23
  function isStringArray(obj) {
28
24
  return Array.isArray(obj) && (obj.length === 0 || typeof obj[0] === 'string');
29
25
  }
26
+ exports.isStringArray = isStringArray;
30
27
  function isQualifiedId(obj) {
31
28
  return typeof obj === 'object' && typeof obj['domain'] === 'string';
32
29
  }
33
30
  function isQualifiedIdArray(obj) {
34
31
  return Array.isArray(obj) && isQualifiedId(obj[0]);
35
32
  }
33
+ exports.isQualifiedIdArray = isQualifiedIdArray;
36
34
  function isQualifiedUserClients(obj) {
35
+ var _a;
37
36
  if (typeof obj === 'object') {
38
- const firstUserClientObject = Object.values(obj)?.[0];
37
+ const firstUserClientObject = (_a = Object.values(obj)) === null || _a === void 0 ? void 0 : _a[0];
39
38
  if (typeof firstUserClientObject === 'object') {
40
39
  const firstClientIdArray = Object.values(firstUserClientObject)[0];
41
40
  return isStringArray(firstClientIdArray);
@@ -43,14 +42,18 @@ function isQualifiedUserClients(obj) {
43
42
  }
44
43
  return false;
45
44
  }
45
+ exports.isQualifiedUserClients = isQualifiedUserClients;
46
46
  function isUserClients(obj) {
47
+ var _a;
47
48
  if (typeof obj === 'object') {
48
- const firstUserClientArray = Object.values(obj)?.[0];
49
+ const firstUserClientArray = (_a = Object.values(obj)) === null || _a === void 0 ? void 0 : _a[0];
49
50
  return isStringArray(firstUserClientArray);
50
51
  }
51
52
  return false;
52
53
  }
54
+ exports.isUserClients = isUserClients;
53
55
  function isMLSConversation(conversation) {
54
56
  const { protocol, epoch, group_id } = conversation;
55
57
  return protocol === conversation_1.ConversationProtocol.MLS && epoch !== undefined && group_id !== undefined;
56
58
  }
59
+ exports.isMLSConversation = isMLSConversation;
@@ -22,8 +22,9 @@ exports.mapQualifiedUserClientIdsToFullyQualifiedClientIds = exports.parseFullQu
22
22
  const constructFullyQualifiedClientId = (userId, clientId, domain) => `${userId}:${clientId}@${domain}`;
23
23
  exports.constructFullyQualifiedClientId = constructFullyQualifiedClientId;
24
24
  const parseFullQualifiedClientId = (qualifiedId) => {
25
+ var _a;
25
26
  const regexp = /([a-zA-Z0-9\-]+):([a-zA-Z0-9\-]+)@([a-zA-Z0-9\-.]+)/;
26
- const [, user, client, domain] = qualifiedId.match(regexp) ?? [];
27
+ const [, user, client, domain] = (_a = qualifiedId.match(regexp)) !== null && _a !== void 0 ? _a : [];
27
28
  if (!user || !client || !domain) {
28
29
  throw new Error(`given client fully qualified ID is corrupted (${qualifiedId})`);
29
30
  }
package/package.json CHANGED
@@ -11,16 +11,16 @@
11
11
  "./lib/cryptography/AssetCryptography/crypto.node": "./lib/cryptography/AssetCryptography/crypto.browser.js"
12
12
  },
13
13
  "dependencies": {
14
- "@wireapp/api-client": "^27.0.11",
15
- "@wireapp/commons": "^5.2.9",
16
- "@wireapp/core-crypto": "1.0.0-rc.60",
14
+ "@wireapp/api-client": "workspace:^",
15
+ "@wireapp/commons": "workspace:^",
16
+ "@wireapp/core-crypto": "1.0.2",
17
17
  "@wireapp/cryptobox": "12.8.0",
18
- "@wireapp/priority-queue": "^2.1.6",
19
- "@wireapp/promise-queue": "^2.3.4",
18
+ "@wireapp/priority-queue": "workspace:^",
19
+ "@wireapp/promise-queue": "workspace:^",
20
20
  "@wireapp/protocol-messaging": "1.48.0",
21
- "@wireapp/store-engine": "5.1.6",
21
+ "@wireapp/store-engine": "workspace:*",
22
22
  "axios": "1.7.2",
23
- "bazinga64": "^6.3.5",
23
+ "bazinga64": "workspace:^",
24
24
  "deepmerge-ts": "6.0.0",
25
25
  "hash.js": "1.1.7",
26
26
  "http-status-codes": "2.3.0",
@@ -62,6 +62,6 @@
62
62
  "test:coverage": "jest --coverage",
63
63
  "watch": "tsc --watch"
64
64
  },
65
- "version": "46.0.19",
66
- "gitHead": "6dd7c585f42be7424b9f0d09cd62167880d74818"
65
+ "version": "46.1.0-hotfix-1.1",
66
+ "gitHead": "5339f01fe01ef0871da8c8bc8662fbe9e604754a"
67
67
  }