@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
@@ -18,19 +18,18 @@
18
18
  *
19
19
  */
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.CryptoboxWrapper = void 0;
22
- exports.buildClient = buildClient;
21
+ exports.CryptoboxWrapper = exports.buildClient = void 0;
23
22
  const cryptobox_1 = require("@wireapp/cryptobox");
24
23
  const proteus_1 = require("@wireapp/proteus");
25
24
  function buildClient(storeEngine, config) {
26
25
  const cryptobox = new cryptobox_1.Cryptobox(storeEngine, config.nbPrekeys);
27
26
  return new CryptoboxWrapper(cryptobox, config);
28
27
  }
28
+ exports.buildClient = buildClient;
29
29
  class CryptoboxWrapper {
30
- cryptobox;
31
- version = '1.0.0';
32
30
  constructor(cryptobox, config) {
33
31
  this.cryptobox = cryptobox;
32
+ this.version = '1.0.0';
34
33
  this.cryptobox.on(cryptobox_1.Cryptobox.TOPIC.NEW_PREKEYS, prekeys => {
35
34
  const serializedPreKeys = prekeys.map(prekey => this.cryptobox.serialize_prekey(prekey));
36
35
  config.onNewPrekeys(serializedPreKeys);
@@ -89,7 +88,7 @@ class CryptoboxWrapper {
89
88
  try {
90
89
  return !!(await this.cryptobox.session_load(sessionId));
91
90
  }
92
- catch {
91
+ catch (_a) {
93
92
  return false;
94
93
  }
95
94
  }
@@ -34,11 +34,12 @@ const isCryptoboxError = (error) => {
34
34
  return 'code' in error;
35
35
  };
36
36
  const generateDecryptionError = (senderInfo, error) => {
37
+ var _a;
37
38
  const { clientId, userId } = senderInfo;
38
39
  const sender = `${userId.id} (${clientId})`;
39
40
  const coreCryptoCode = isCoreCryptoError(error) ? error.proteusErrorCode : null;
40
41
  const cryptoboxCode = isCryptoboxError(error) ? error.code : null;
41
- const code = coreCryptoCode ?? cryptoboxCode ?? exports.ProteusErrors.Unknown;
42
+ const code = (_a = coreCryptoCode !== null && coreCryptoCode !== void 0 ? coreCryptoCode : cryptoboxCode) !== null && _a !== void 0 ? _a : exports.ProteusErrors.Unknown;
42
43
  const message = `Decryption error from ${sender} (${error.message})`;
43
44
  return new DecryptionError_1.DecryptionError(message, code);
44
45
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ProteusService.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/ProteusService/ProteusService.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AACjE,OAAO,KAAK,EAAC,MAAM,EAAE,OAAO,EAAC,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAGL,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAC,8BAA8B,EAAC,MAAM,+BAA+B,CAAC;AAClF,OAAO,KAAK,EAAC,WAAW,EAAE,4BAA4B,EAAC,MAAM,8BAA8B,CAAC;AAG5F,OAAO,EAAC,UAAU,EAAC,M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E,eAAe,GAAG,OAAO,CAAC,iCAAiC,CAAC;IAwC9G;;;OAGG;IACU,sBAAsB,CAAC,EAClC,cAAc,EACd,cAAc,GACf,EAAE,mCAAmC,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAoD5D,WAAW,CAAC,EACvB,OAAO,EACP,cAAc,EACd,UAAU,EACV,UAAU,EACV,OAAO,EACP,gBAAgB,GACjB,EAAE,wBAAwB,GAAG,OAAO,CAAC,UAAU,CAAC;IA6CpC,OAAO,CAAC,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM;IAuB9E,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM;IAQ7C,OAAO,CAClB,SAAS,EAAE,UAAU,EACrB,UAAU,EAAE,4BAA4B,GAAG,oBAAoB,GAC9D,OAAO,CAAC,gBAAgB,CAAC;IAiBtB,IAAI,CAAC,WAAW,CAAC,EAAE,UAAU;CAMpC"}
1
+ {"version":3,"file":"ProteusService.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/ProteusService/ProteusService.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AACjE,OAAO,KAAK,EAAC,MAAM,EAAE,OAAO,EAAC,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAGL,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACrB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAC,8BAA8B,EAAC,MAAM,+BAA+B,CAAC;AAClF,OAAO,KAAK,EAAC,WAAW,EAAE,4BAA4B,EAAC,MAAM,8BAA8B,CAAC;AAG5F,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAI5C,OAAO,KAAK,EACV,mCAAmC,EACnC,o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mCAAmC,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAoD5D,WAAW,CAAC,EACvB,OAAO,EACP,cAAc,EACd,UAAU,EACV,UAAU,EACV,OAAO,EACP,gBAAgB,GACjB,EAAE,wBAAwB,GAAG,OAAO,CAAC,UAAU,CAAC;IA6CpC,OAAO,CAAC,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM;IAuB9E,aAAa,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM;IAQ7C,OAAO,CAClB,SAAS,EAAE,UAAU,EACrB,UAAU,EAAE,4BAA4B,GAAG,oBAAoB,GAC9D,OAAO,CAAC,gBAAgB,CAAC;IAiBtB,IAAI,CAAC,WAAW,CAAC,EAAE,UAAU;CAMpC"}
@@ -37,15 +37,11 @@ const getGenericMessageParams_1 = require("../Utility/getGenericMessageParams");
37
37
  const isClearFromMismatch_1 = require("../Utility/isClearFromMismatch");
38
38
  const SessionHandler_1 = require("../Utility/SessionHandler");
39
39
  class ProteusService {
40
- apiClient;
41
- cryptoClient;
42
- config;
43
- messageService;
44
- logger = (0, logdown_1.default)('@wireapp/core/ProteusService');
45
40
  constructor(apiClient, cryptoClient, config) {
46
41
  this.apiClient = apiClient;
47
42
  this.cryptoClient = cryptoClient;
48
43
  this.config = config;
44
+ this.logger = (0, logdown_1.default)('@wireapp/core/ProteusService');
49
45
  this.messageService = new MessageService_1.MessageService(this.apiClient, this);
50
46
  }
51
47
  async handleOtrMessageAddEvent(event) {
@@ -55,6 +51,7 @@ class ProteusService {
55
51
  });
56
52
  }
57
53
  async initClient(storeEngine, context) {
54
+ var _a;
58
55
  const dbName = storeEngine.storeName;
59
56
  if (context.domain) {
60
57
  // We want sessions to be fully qualified from now on
@@ -66,18 +63,17 @@ class ProteusService {
66
63
  }
67
64
  }
68
65
  if (!cryptoMigrationStateStore_1.cryptoMigrationStore.coreCrypto.isReady(dbName) && this.cryptoClient.migrateFromCryptobox) {
69
- this.logger.info(`Migrating from cryptobox to corecrypto.`);
66
+ this.logger.info(`Migrating data from cryptobox store (${dbName}) to corecrypto.`);
70
67
  try {
71
- const startTime = Date.now();
72
68
  await this.cryptoClient.migrateFromCryptobox(dbName);
73
69
  cryptoMigrationStateStore_1.cryptoMigrationStore.coreCrypto.markAsReady(dbName);
74
- this.logger.info(`Successfully migrated from cryptobox to corecrypto (took ${Date.now() - startTime}ms).`);
70
+ this.logger.info(`Successfully migrated from cryptobox store (${dbName}) to corecrypto.`);
75
71
  }
76
72
  catch (error) {
77
73
  this.logger.error('Client was not able to perform DB migration: ', error);
78
74
  }
79
75
  }
80
- const backendPrekeys = await this.apiClient.api.client.getClientPreKeys(context.clientId ?? '');
76
+ const backendPrekeys = await this.apiClient.api.client.getClientPreKeys((_a = context.clientId) !== null && _a !== void 0 ? _a : '');
81
77
  const totalUsableBackedPrekeys = backendPrekeys.length - 1; // we remove the last resort prekey from the total number of available prekeys
82
78
  return this.cryptoClient.init(totalUsableBackedPrekeys);
83
79
  }
@@ -105,6 +101,7 @@ class ProteusService {
105
101
  return this.cryptoClient.getRemoteFingerprint(sessionId);
106
102
  }
107
103
  async createConversation(conversationData) {
104
+ var _a;
108
105
  try {
109
106
  const conversation = await this.apiClient.api.conversation.postConversation(conversationData);
110
107
  return { conversation };
@@ -118,8 +115,8 @@ class ProteusService {
118
115
  }
119
116
  case conversation_1.FederatedBackendsErrorLabel.UNREACHABLE_BACKENDS: {
120
117
  const { backends } = error;
121
- const { excludedUsers: unreachableUsers, includedUsers: availableUsers } = (0, userDomainFilters_1.filterUsersFromDomains)(conversationData.qualified_users ?? [], backends);
122
- conversationData = { ...conversationData, qualified_users: availableUsers };
118
+ const { excludedUsers: unreachableUsers, includedUsers: availableUsers } = (0, userDomainFilters_1.filterUsersFromDomains)((_a = conversationData.qualified_users) !== null && _a !== void 0 ? _a : [], backends);
119
+ conversationData = Object.assign(Object.assign({}, conversationData), { qualified_users: availableUsers });
123
120
  // If conversation creation returns an error because a backend is offline,
124
121
  // we try creating the conversation again with users from available backends
125
122
  const response = await this.apiClient.api.conversation.postConversation(conversationData);
@@ -191,6 +188,7 @@ class ProteusService {
191
188
  }
192
189
  }
193
190
  async sendMessage({ userIds, conversationId, nativePush, targetMode, payload, onClientMismatch, }) {
191
+ var _a;
194
192
  const messageParams = await (0, getGenericMessageParams_1.getGenericMessageParams)({
195
193
  apiClient: this.apiClient,
196
194
  sendingClientId: this.apiClient.validatedClientId,
@@ -203,19 +201,16 @@ class ProteusService {
203
201
  },
204
202
  });
205
203
  const { sendingClientId, recipients, plainText, options } = messageParams;
206
- const response = await this.messageService.sendMessage(sendingClientId, recipients, plainText, {
207
- ...options,
208
- onClientMismatch: mismatch => onClientMismatch?.(mismatch, false),
209
- });
204
+ const response = await this.messageService.sendMessage(sendingClientId, recipients, plainText, Object.assign(Object.assign({}, options), { onClientMismatch: mismatch => onClientMismatch === null || onClientMismatch === void 0 ? void 0 : onClientMismatch(mismatch, false) }));
210
205
  if (!response.canceled) {
211
206
  if (!(0, isClearFromMismatch_1.isClearFromMismatch)(response)) {
212
207
  // We warn the consumer that there is a mismatch that did not prevent message sending
213
- await onClientMismatch?.(response, true);
208
+ await (onClientMismatch === null || onClientMismatch === void 0 ? void 0 : onClientMismatch(response, true));
214
209
  }
215
210
  this.logger.log(`Successfully sent Proteus message to conversation '${conversationId.id}'`);
216
211
  }
217
212
  const sendingState = response.canceled ? conversation_2.MessageSendingState.CANCELED : conversation_2.MessageSendingState.OUTGOING_SENT;
218
- const failedToSend = response.failed || Object.keys(response.failed_to_confirm_clients ?? {}).length > 0
213
+ const failedToSend = response.failed || Object.keys((_a = response.failed_to_confirm_clients) !== null && _a !== void 0 ? _a : {}).length > 0
219
214
  ? {
220
215
  queued: response.failed_to_confirm_clients,
221
216
  failed: response.failed,
@@ -229,6 +224,7 @@ class ProteusService {
229
224
  };
230
225
  }
231
226
  async decrypt(encryptedText, userId, clientId) {
227
+ var _a, _b;
232
228
  const sessionId = this.constructSessionId(userId, clientId);
233
229
  const sessionExists = await this.cryptoClient.sessionExists(sessionId);
234
230
  try {
@@ -237,11 +233,11 @@ class ProteusService {
237
233
  : await this.cryptoClient.decrypt(sessionId, encryptedText);
238
234
  if (!sessionExists) {
239
235
  await this.cryptoClient.saveSession(sessionId);
240
- this.config.onNewClient?.({ userId, clientId });
241
- this.logger.debug(`Created a new session from message for session ID "${sessionId}" and decrypted the message`);
236
+ (_b = (_a = this.config).onNewClient) === null || _b === void 0 ? void 0 : _b.call(_a, { userId, clientId });
237
+ this.logger.info(`Created a new session from message for session ID "${sessionId}" and decrypted the message`);
242
238
  }
243
239
  else {
244
- this.logger.debug(`Decrypted message for session ID "${sessionId}"`);
240
+ this.logger.info(`Decrypted message for session ID "${sessionId}"`);
245
241
  }
246
242
  return decryptedMessage;
247
243
  }
@@ -1,8 +1,11 @@
1
1
  import { APIClient } from '@wireapp/api-client';
2
2
  import { CryptoClient } from './CryptoClient';
3
3
  import { ProteusService } from './ProteusService';
4
- export declare const buildProteusService: () => Promise<[ProteusService, {
5
- apiClient: APIClient;
6
- cryptoClient: CryptoClient;
7
- }]>;
4
+ export declare const buildProteusService: () => Promise<[
5
+ ProteusService,
6
+ {
7
+ apiClient: APIClient;
8
+ cryptoClient: CryptoClient;
9
+ }
10
+ ]>;
8
11
  //# sourceMappingURL=ProteusService.mocks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProteusService.mocks.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/ProteusService/ProteusService.mocks.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAIhD,eAAO,MAAM,mBAAmB,QAAa,OAAO,CAClD,CAAC,cAAc,EAAE;IAAC,SAAS,EAAE,SAAS,CAAC;IAAC,YAAY,EAAE,YAAY,CAAA;CAAC,CAAC,CAgBrE,CAAC"}
1
+ {"version":3,"file":"ProteusService.mocks.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/ProteusService/ProteusService.mocks.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAIhD,eAAO,MAAM,mBAAmB,QAAa,QAC3C;IAAC,cAAc;IAAE;QAAC,SAAS,EAAE,SAAS,CAAC;QAAC,YAAY,EAAE,YAAY,CAAA;KAAC;CAAC,CAgBrE,CAAC"}
@@ -63,11 +63,7 @@ jest.mock('./CryptoClient/CoreCryptoWrapper/PrekeysTracker', () => {
63
63
  }),
64
64
  };
65
65
  });
66
- jest.mock('../Utility/Recipients', () => ({
67
- ...jest.requireActual('../Utility/Recipients'),
68
- getRecipientsForConversation: jest.fn(),
69
- getQualifiedRecipientsForConversation: jest.fn(),
70
- }));
66
+ jest.mock('../Utility/Recipients', () => (Object.assign(Object.assign({}, jest.requireActual('../Utility/Recipients')), { getRecipientsForConversation: jest.fn(), getQualifiedRecipientsForConversation: jest.fn() })));
71
67
  const MockedRecipients = Recipients;
72
68
  const prepareDataForEncryption = async () => {
73
69
  const [proteusService, { cryptoClient, apiClient }] = await (0, ProteusService_mocks_1.buildProteusService)();
@@ -210,7 +206,7 @@ describe('ProteusService', () => {
210
206
  const result = await proteusService.handleOtrMessageAddEvent(eventPayload);
211
207
  expect(result).toBeDefined();
212
208
  expect(createSessionSpy).not.toHaveBeenCalled();
213
- expect(result?.decryptedData).toBe(decryptedMessage);
209
+ expect(result === null || result === void 0 ? void 0 : result.decryptedData).toBe(decryptedMessage);
214
210
  });
215
211
  it('decrypts incoming proteus encrypted and creates session if not already existing', async () => {
216
212
  const [proteusService, { cryptoClient }] = await (0, ProteusService_mocks_1.buildProteusService)();
@@ -223,7 +219,7 @@ describe('ProteusService', () => {
223
219
  expect(result).toBeDefined();
224
220
  expect(createSessionSpy).toHaveBeenCalled();
225
221
  expect(decryptSpy).not.toHaveBeenCalled();
226
- expect(result?.decryptedData).toBe(decryptedMessage);
222
+ expect(result === null || result === void 0 ? void 0 : result.decryptedData).toBe(decryptedMessage);
227
223
  });
228
224
  });
229
225
  describe('"encrypt"', () => {
@@ -459,6 +455,7 @@ describe('ProteusService', () => {
459
455
  });
460
456
  });
461
457
  it(`returns the recipients that will receive the message later`, async () => {
458
+ var _a;
462
459
  const [proteusService] = await (0, ProteusService_mocks_1.buildProteusService)();
463
460
  const recipients = {
464
461
  domain1: { user1: ['client1'], user2: ['client11', 'client12'] },
@@ -480,7 +477,7 @@ describe('ProteusService', () => {
480
477
  userIds: recipients,
481
478
  });
482
479
  expect(result.state).toBe(conversation_2.MessageSendingState.OUTGOING_SENT);
483
- expect(result.failedToSend?.queued).toEqual({ domain2: recipients.domain2 });
480
+ expect((_a = result.failedToSend) === null || _a === void 0 ? void 0 : _a.queued).toEqual({ domain2: recipients.domain2 });
484
481
  });
485
482
  });
486
483
  });
@@ -505,6 +502,7 @@ describe('ProteusService', () => {
505
502
  expect(event).toEqual(baseResponse);
506
503
  });
507
504
  it('partially add users if some backends are unreachable', async () => {
505
+ var _a, _b, _c, _d;
508
506
  const [proteusService, { apiClient }] = await (0, ProteusService_mocks_1.buildProteusService)();
509
507
  const postMembersSpy = jest
510
508
  .spyOn(apiClient.api.conversation, 'postMembers')
@@ -517,10 +515,11 @@ describe('ProteusService', () => {
517
515
  expect(postMembersSpy).toHaveBeenCalledTimes(2);
518
516
  expect(postMembersSpy).toHaveBeenCalledWith(conversationId, expect.arrayContaining([...usersDomain1, ...usersDomain2]));
519
517
  expect(postMembersSpy).toHaveBeenCalledWith(conversationId, expect.arrayContaining(usersDomain2));
520
- expect(result.failedToAdd?.[0]?.reason).toBe(conversation_2.AddUsersFailureReasons.UNREACHABLE_BACKENDS);
521
- expect(result.failedToAdd?.[0]?.users).toEqual([...usersDomain1]);
518
+ expect((_b = (_a = result.failedToAdd) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.reason).toBe(conversation_2.AddUsersFailureReasons.UNREACHABLE_BACKENDS);
519
+ expect((_d = (_c = result.failedToAdd) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.users).toEqual([...usersDomain1]);
522
520
  });
523
521
  it('completely fails to add users if some backends are unreachable', async () => {
522
+ var _a, _b, _c, _d;
524
523
  const [proteusService, { apiClient }] = await (0, ProteusService_mocks_1.buildProteusService)();
525
524
  const allUsers = [...usersDomain1, ...usersDomain2];
526
525
  const postMembersSpy = jest
@@ -533,10 +532,11 @@ describe('ProteusService', () => {
533
532
  expect(postMembersSpy).toHaveBeenCalledTimes(2);
534
533
  expect(postMembersSpy).toHaveBeenCalledWith(conversationId, expect.arrayContaining(allUsers));
535
534
  expect(postMembersSpy).toHaveBeenCalledWith(conversationId, expect.arrayContaining(usersDomain2));
536
- expect(result.failedToAdd?.[0]?.reason).toBe(conversation_2.AddUsersFailureReasons.UNREACHABLE_BACKENDS);
537
- expect(result.failedToAdd?.[0]?.users).toEqual(allUsers);
535
+ expect((_b = (_a = result.failedToAdd) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.reason).toBe(conversation_2.AddUsersFailureReasons.UNREACHABLE_BACKENDS);
536
+ expect((_d = (_c = result.failedToAdd) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.users).toEqual(allUsers);
538
537
  });
539
538
  it('partially add users if some users are part of not-connected backends', async () => {
539
+ var _a, _b, _c, _d;
540
540
  const [proteusService, { apiClient }] = await (0, ProteusService_mocks_1.buildProteusService)();
541
541
  const postMembersSpy = jest
542
542
  .spyOn(apiClient.api.conversation, 'postMembers')
@@ -549,8 +549,8 @@ describe('ProteusService', () => {
549
549
  expect(postMembersSpy).toHaveBeenCalledTimes(2);
550
550
  expect(postMembersSpy).toHaveBeenCalledWith(conversationId, expect.arrayContaining([...usersDomain1, ...usersDomain2]));
551
551
  expect(postMembersSpy).toHaveBeenCalledWith(conversationId, expect.arrayContaining(usersDomain1));
552
- expect(result.failedToAdd?.[0]?.reason).toBe(conversation_2.AddUsersFailureReasons.NON_FEDERATING_BACKENDS);
553
- expect(result.failedToAdd?.[0]?.users).toEqual([...usersDomain2, ...usersDomain3]);
552
+ expect((_b = (_a = result.failedToAdd) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.reason).toBe(conversation_2.AddUsersFailureReasons.NON_FEDERATING_BACKENDS);
553
+ expect((_d = (_c = result.failedToAdd) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.users).toEqual([...usersDomain2, ...usersDomain3]);
554
554
  });
555
555
  });
556
556
  describe('createConversation', () => {
@@ -579,7 +579,7 @@ describe('ProteusService', () => {
579
579
  };
580
580
  it('adds all requested users to a new conversation', async () => {
581
581
  const [proteusService, { apiClient }] = await (0, ProteusService_mocks_1.buildProteusService)();
582
- jest.spyOn(apiClient.api.conversation, 'postConversation').mockResolvedValueOnce({ ...newConversation });
582
+ jest.spyOn(apiClient.api.conversation, 'postConversation').mockResolvedValueOnce(Object.assign({}, newConversation));
583
583
  const result = await proteusService.createConversation({
584
584
  receipt_mode: null,
585
585
  qualified_users: [...usersDomain1, ...usersDomain2, ...usersDomain3],
@@ -23,7 +23,7 @@ function getLocalStorage() {
23
23
  try {
24
24
  return window.localStorage;
25
25
  }
26
- catch {
26
+ catch (_a) {
27
27
  return { setItem: () => { }, getItem: () => { }, removeItem: () => { } };
28
28
  }
29
29
  }
@@ -18,7 +18,7 @@
18
18
  *
19
19
  */
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.deleteIdentity = deleteIdentity;
21
+ exports.deleteIdentity = void 0;
22
22
  /** all the tables in the database that stores information relative to the client identity */
23
23
  const IDENTITY_STORES = ['amplify', 'clients', 'keys', 'prekeys', 'sessions', 'group_ids'];
24
24
  /**
@@ -30,3 +30,4 @@ function deleteIdentity(storeEngine) {
30
30
  //make sure we use enum's lowercase values, not uppercase keys
31
31
  IDENTITY_STORES.map(store => storeEngine.deleteAll(store)));
32
32
  }
33
+ exports.deleteIdentity = deleteIdentity;
@@ -18,7 +18,7 @@
18
18
  *
19
19
  */
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.migrateToQualifiedSessionIds = migrateToQualifiedSessionIds;
21
+ exports.migrateToQualifiedSessionIds = void 0;
22
22
  const sessionTableName = 'sessions';
23
23
  /**
24
24
  * Will migrate all the session ids in the database to fully qualified ids (from 'user-id@device-id` to `domain@user-id@device-id`)
@@ -34,7 +34,7 @@ async function migrateToQualifiedSessionIds(storeEngine, defaultDomain) {
34
34
  .reduce((acc, session) => {
35
35
  return acc.concat({
36
36
  oldId: session.id,
37
- newSession: { ...session, id: `${defaultDomain}@${session.id}` },
37
+ newSession: Object.assign(Object.assign({}, session), { id: `${defaultDomain}@${session.id}` }),
38
38
  });
39
39
  }, []);
40
40
  for (const { oldId, newSession } of updatedSessions) {
@@ -43,3 +43,4 @@ async function migrateToQualifiedSessionIds(storeEngine, defaultDomain) {
43
43
  await storeEngine.create(sessionTableName, newSession.id, newSession);
44
44
  }
45
45
  }
46
+ exports.migrateToQualifiedSessionIds = migrateToQualifiedSessionIds;
@@ -18,7 +18,7 @@
18
18
  *
19
19
  */
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.filterUsersFromDomains = filterUsersFromDomains;
21
+ exports.filterUsersFromDomains = void 0;
22
22
  function filterUsersFromDomains(userIds, domainsToExclude) {
23
23
  const excludedUsers = [];
24
24
  const includedUsers = [];
@@ -28,3 +28,4 @@ function filterUsersFromDomains(userIds, domainsToExclude) {
28
28
  includedUsers,
29
29
  };
30
30
  }
31
+ exports.filterUsersFromDomains = filterUsersFromDomains;
@@ -1 +1 @@
1
- {"version":3,"file":"Recipients.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/Utility/Recipients.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AAE5D,OAAO,EAAC,oBAAoB,EAAC,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAczD,UAAU,2CAA2C;IACnD,SAAS,EAAE,SAAS,CAAC;IACrB,cAAc,EAAE,WAAW,CAAC;IAC5B,OAAO,CAAC,EAAE,WAAW,EAAE,GAAG,oBAAoB,CAAC;CAChD;AAED,QAAA,MAAM,4BAA4B,4CAI/B,2CAA2C,KAAG,OAAO,CAAC,oBAAoB,CAW5E,CAAC;AAEF,OAAO,EAAC,4BAA4B,EAAC,CAAC"}
1
+ {"version":3,"file":"Recipients.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/Utility/Recipients.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AAE5D,OAAO,EAAC,oBAAoB,EAAC,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAczD,UAAU,2CAA2C;IACnD,SAAS,EAAE,SAAS,CAAC;IACrB,cAAc,EAAE,WAAW,CAAC;IAC5B,OAAO,CAAC,EAAE,WAAW,EAAE,GAAG,oBAAoB,CAAC;CAChD;AAED,QAAA,MAAM,4BAA4B,4CAI/B,2CAA2C,KAAG,QAAQ,oBAAoB,CAW5E,CAAC;AAEF,OAAO,EAAC,4BAA4B,EAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"SessionHandler.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,C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WAAW,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,YAAY,CAAC;CAC5B;AACD,iBAAe,aAAa,CAAC,MAAM,EAAE,mBAAmB,iBAGvD;AA4CD,KAAK,iBAAiB,CAAC,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9E;;GAEG;AACH,QAAA,MAAM,sBAAsB,GAAI,CAAC,YAAY,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,KAAG,iBAAiB,CAAC,CAAC,CAYhF,CAAC;AAEF,OAAO,EAAC,kBAAkB,EAAE,WAAW,EAAE,YAAY,EAAE,aAAa,EAAE,sBAAsB,EAAC,CAAC"}
1
+ {"version":3,"file":"SessionHandler.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,MAAM,EAAC,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAC,oBAAoB,EAAC,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAC,WAAW,EAAE,4BAA4B,EAAC,MAAM,8BAA8B,CAAC;AAEvF,OAAO,EAAC,MAAM,EAAC,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAK9C,OAAO,EAAC,YAAY,EAAC,MAAM,mCAAmC,CAAC;AAE/D,UAAU,wBAAwB;IAChC,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,KAAK,kBAAkB,GAAG;IACxB,8EAA8E;IAC9E,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,8GAA8G;IAC9G,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAChC,6EAA6E;IAC7E,MAAM,CAAC,EAAE,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initSession = exports.constructSessionId = void 0;
22
- exports.deleteSession = deleteSession;
21
+ exports.buildEncryptedPayloads = exports.deleteSession = exports.initSessions = exports.initSession = exports.constructSessionId = void 0;
23
22
  const bazinga64_1 = require("bazinga64");
24
23
  const UserClientsUtil_1 = require("../../../../conversation/message/UserClientsUtil");
25
24
  const constructSessionId = ({ userId, clientId }) => {
@@ -69,15 +68,13 @@ const createSessions = async ({ recipients, apiClient, cryptoClient }) => {
69
68
  recipients: prekeysBundle,
70
69
  cryptoClient,
71
70
  });
72
- return {
73
- ...result,
74
- failed: failed?.length ? failed : undefined,
75
- };
71
+ return Object.assign(Object.assign({}, result), { failed: (failed === null || failed === void 0 ? void 0 : failed.length) ? failed : undefined });
76
72
  };
77
73
  /**
78
74
  * Will make sure all the sessions need to encrypt for those user/clients pair are set
79
75
  */
80
76
  const initSessions = async ({ recipients, apiClient, cryptoClient, logger, }) => {
77
+ var _a, _b, _c;
81
78
  const missingClients = {};
82
79
  const missingClientsWithPrekeys = {};
83
80
  const existingSessions = [];
@@ -92,13 +89,13 @@ const initSessions = async ({ recipients, apiClient, cryptoClient, logger, }) =>
92
89
  continue;
93
90
  }
94
91
  if (!Array.isArray(data)) {
95
- const domainMissingWithPrekey = missingClientsWithPrekeys[userId.domain] ?? {};
96
- domainMissingWithPrekey[userId.id] = domainMissingWithPrekey[userId.id] ?? {};
92
+ const domainMissingWithPrekey = (_a = missingClientsWithPrekeys[userId.domain]) !== null && _a !== void 0 ? _a : {};
93
+ domainMissingWithPrekey[userId.id] = (_b = domainMissingWithPrekey[userId.id]) !== null && _b !== void 0 ? _b : {};
97
94
  domainMissingWithPrekey[userId.id][clientId] = data[clientId];
98
95
  missingClientsWithPrekeys[userId.domain] = domainMissingWithPrekey;
99
96
  continue;
100
97
  }
101
- const domainMissing = missingClients[userId.domain] ?? {};
98
+ const domainMissing = (_c = missingClients[userId.domain]) !== null && _c !== void 0 ? _c : {};
102
99
  domainMissing[userId.id] = domainMissing[userId.id] || [];
103
100
  domainMissing[userId.id].push(clientId);
104
101
  missingClients[userId.domain] = domainMissing;
@@ -118,7 +115,7 @@ const initSessions = async ({ recipients, apiClient, cryptoClient, logger, }) =>
118
115
  logger,
119
116
  })
120
117
  : { sessions: [], failed: undefined, unknowns: undefined };
121
- const allUnknowns = { ...prekeyUnknows, ...unknowns };
118
+ const allUnknowns = Object.assign(Object.assign({}, prekeyUnknows), unknowns);
122
119
  return {
123
120
  sessions: [...existingSessions, ...prekeyCreated, ...created],
124
121
  failed,
@@ -130,7 +127,9 @@ async function deleteSession(params) {
130
127
  const sessionId = constructSessionId(params);
131
128
  await params.cryptoClient.deleteSession(sessionId);
132
129
  }
130
+ exports.deleteSession = deleteSession;
133
131
  const createSessionsFromPreKeys = async ({ recipients, cryptoClient, }) => {
132
+ var _a, _b;
134
133
  const sessions = [];
135
134
  const unknowns = {};
136
135
  for (const domain in recipients) {
@@ -140,8 +139,8 @@ const createSessionsFromPreKeys = async ({ recipients, cryptoClient, }) => {
140
139
  const sessionId = constructSessionId({ userId: { id: userId, domain }, clientId });
141
140
  const prekey = userClients[clientId];
142
141
  if (!prekey) {
143
- const domainUnknowns = unknowns[domain] ?? {};
144
- domainUnknowns[userId] = domainUnknowns[userId] ?? [];
142
+ const domainUnknowns = (_a = unknowns[domain]) !== null && _a !== void 0 ? _a : {};
143
+ domainUnknowns[userId] = (_b = domainUnknowns[userId]) !== null && _b !== void 0 ? _b : [];
145
144
  domainUnknowns[userId].push(clientId);
146
145
  unknowns[domain] = domainUnknowns;
147
146
  continue;
@@ -160,12 +159,13 @@ const createSessionsFromPreKeys = async ({ recipients, cryptoClient, }) => {
160
159
  */
161
160
  const buildEncryptedPayloads = (payloads) => {
162
161
  return [...payloads].reduce((acc, [sessionId, payload]) => {
162
+ var _a, _b;
163
163
  const { userId, domain, clientId } = parseSessionId(sessionId);
164
164
  if (!domain) {
165
165
  throw new Error('Invalid session ID');
166
166
  }
167
- const domainPayloads = acc[domain] ?? {};
168
- domainPayloads[userId] = domainPayloads[userId] ?? {};
167
+ const domainPayloads = (_a = acc[domain]) !== null && _a !== void 0 ? _a : {};
168
+ domainPayloads[userId] = (_b = domainPayloads[userId]) !== null && _b !== void 0 ? _b : {};
169
169
  domainPayloads[userId][clientId] = payload;
170
170
  acc[domain] = domainPayloads;
171
171
  return acc;
@@ -37,10 +37,7 @@ function generatePrekeys(recipients) {
37
37
  id: index,
38
38
  key: 'pQABARn//wKhAFggJ1Fbpg5l6wnzKOJE+vXpRnkqUYhIvVnR5lNXEbO2o/0DoQChAFggHxZvgvtDktY/vqBcpjjo6rQnXvcNQhfwmy8AJQJKlD0E9g==',
39
39
  };
40
- return {
41
- ...acc,
42
- [clientId]: payload,
43
- };
40
+ return Object.assign(Object.assign({}, acc), { [clientId]: payload });
44
41
  }, {});
45
42
  prekeys[domain] = domainUsers;
46
43
  });
@@ -114,7 +111,7 @@ describe('SessionHandler', () => {
114
111
  .mockImplementation(sessionId => Promise.resolve(sessionId.includes('missing')));
115
112
  const sessionFromPrekeySpy = jest.spyOn(cryptoClient, 'sessionFromPrekey');
116
113
  const { sessions } = await (0, SessionHandler_1.initSessions)({
117
- recipients: { domain: { ...existingUserClients, ...missingUserClients } },
114
+ recipients: { domain: Object.assign(Object.assign({}, existingUserClients), missingUserClients) },
118
115
  apiClient,
119
116
  cryptoClient,
120
117
  });
@@ -1 +1 @@
1
- {"version":3,"file":"getGenericMessageParams.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/Utility/getGenericMessageParams.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAC,oBAAoB,EAAC,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAC,WAAW,EAAE,4BAA4B,EAAC,MAAM,8BAA8B,CAAC;AAEvF,OAAO,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAK3D,OAAO,EAAoB,qBAAqB,EAAC,MAAM,uBAAuB,CAAC;AAG/E,MAAM,MAAM,aAAa,GAAG;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,oBAAoB,GAAG,4BAA4B,CAAC;IAChE,SAAS,EAAE,UAAU,CAAC;IACtB,OAAO,EAAE;QACP,cAAc,EAAE,WAAW,CAAC;QAC5B,UAAU,EAAE,OAAO,GAAG,SAAS,CAAC;QAChC,aAAa,EAAE,OAAO,GAAG,WAAW,EAAE,GAAG,SAAS,CAAC;KACpD,CAAC;CACH,CAAC;AACF,UAAU,6BAA6B;IACrC,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,WAAW,CAAC;IAC5B,cAAc,EAAE,cAAc,CAAC;IAC/B,OAAO,EAAE,qBAAqB,CAAC;IAC/B,SAAS,EAAE,SAAS,CAAC;CACtB;AACD,KAAK,iCAAiC,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAEhE,QAAA,MAAM,uBAAuB,kHAM1B,6BAA6B,KAAG,iCA0BlC,CAAC;AAEF,OAAO,EAAC,uBAAuB,EAAC,CAAC"}
1
+ {"version":3,"file":"getGenericMessageParams.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/Utility/getGenericMessageParams.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAC,oBAAoB,EAAC,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAC,WAAW,EAAE,4BAA4B,EAAC,MAAM,8BAA8B,CAAC;AAEvF,OAAO,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAK3D,OAAO,EAAoB,qBAAqB,EAAC,MAAM,uBAAuB,CAAC;AAG/E,MAAM,MAAM,aAAa,GAAG;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,oBAAoB,GAAG,4BAA4B,CAAC;IAChE,SAAS,EAAE,UAAU,CAAC;IACtB,OAAO,EAAE;QACP,cAAc,EAAE,WAAW,CAAC;QAC5B,UAAU,EAAE,OAAO,GAAG,SAAS,CAAC;QAChC,aAAa,EAAE,OAAO,GAAG,WAAW,EAAE,GAAG,SAAS,CAAC;KACpD,CAAC;CACH,CAAC;AACF,UAAU,6BAA6B;IACrC,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,WAAW,CAAC;IAC5B,cAAc,EAAE,cAAc,CAAC;IAC/B,OAAO,EAAE,qBAAqB,CAAC;IAC/B,SAAS,EAAE,SAAS,CAAC;CACtB;AACD,KAAK,iCAAiC,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAEhE,QAAA,MAAM,uBAAuB,kHAM1B,6BAA6B,sCA0B/B,CAAC;AAEF,OAAO,EAAC,uBAAuB,EAAC,CAAC"}
@@ -5,7 +5,7 @@ export declare class NotificationBackendRepository {
5
5
  constructor(apiClient: APIClient);
6
6
  getAllNotifications(clientId?: string, lastNotificationId?: string): Promise<{
7
7
  notifications: Notification[];
8
- missedNotification?: string;
8
+ missedNotification?: string | undefined;
9
9
  }>;
10
10
  getLastNotification(clientId?: string): Promise<Notification>;
11
11
  }
@@ -20,7 +20,6 @@
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.NotificationBackendRepository = void 0;
22
22
  class NotificationBackendRepository {
23
- apiClient;
24
23
  constructor(apiClient) {
25
24
  this.apiClient = apiClient;
26
25
  }
@@ -32,7 +32,6 @@ const STORES = {
32
32
  AMPLIFY: 'amplify',
33
33
  };
34
34
  class NotificationDatabaseRepository {
35
- storeEngine;
36
35
  constructor(storeEngine) {
37
36
  this.storeEngine = storeEngine;
38
37
  }