@wireapp/core 40.5.1 → 40.5.2-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 (140) hide show
  1. package/lib/Account.d.ts +7 -9
  2. package/lib/Account.d.ts.map +1 -1
  3. package/lib/Account.js +35 -32
  4. package/lib/CoreError.js +1 -1
  5. package/lib/broadcast/BroadcastService.d.ts +11 -2
  6. package/lib/broadcast/BroadcastService.d.ts.map +1 -1
  7. package/lib/broadcast/BroadcastService.js +39 -5
  8. package/lib/client/ClientDatabaseRepository.d.ts +5 -5
  9. package/lib/client/ClientDatabaseRepository.d.ts.map +1 -1
  10. package/lib/client/ClientDatabaseRepository.js +17 -10
  11. package/lib/client/ClientService.d.ts +1 -5
  12. package/lib/client/ClientService.d.ts.map +1 -1
  13. package/lib/client/ClientService.js +9 -11
  14. package/lib/connection/ConnectionService.d.ts +2 -2
  15. package/lib/connection/ConnectionService.d.ts.map +1 -1
  16. package/lib/connection/ConnectionService.js +2 -2
  17. package/lib/conversation/AssetTransferState.js +1 -1
  18. package/lib/conversation/ConversationService/ConversationService.d.ts +5 -12
  19. package/lib/conversation/ConversationService/ConversationService.d.ts.map +1 -1
  20. package/lib/conversation/ConversationService/ConversationService.js +11 -26
  21. package/lib/conversation/ConversationService/ConversationService.test.js +1 -1
  22. package/lib/conversation/ConversationService/ConversationService.types.d.ts +11 -12
  23. package/lib/conversation/ConversationService/ConversationService.types.d.ts.map +1 -1
  24. package/lib/conversation/ConversationService/ConversationService.types.js +1 -1
  25. package/lib/conversation/ConversationService/Utility/getConversationQualifiedMembers.d.ts +1 -1
  26. package/lib/conversation/ConversationService/Utility/getConversationQualifiedMembers.d.ts.map +1 -1
  27. package/lib/conversation/GenericMessageType.js +1 -1
  28. package/lib/conversation/ReactionType.d.ts +4 -1
  29. package/lib/conversation/ReactionType.d.ts.map +1 -1
  30. package/lib/conversation/ReactionType.js +6 -0
  31. package/lib/conversation/message/Message.types.js +1 -1
  32. package/lib/conversation/message/MessageBuilder.d.ts +1 -1
  33. package/lib/conversation/message/MessageBuilder.d.ts.map +1 -1
  34. package/lib/conversation/message/MessageBuilder.js +2 -2
  35. package/lib/conversation/message/MessageService.d.ts +31 -6
  36. package/lib/conversation/message/MessageService.d.ts.map +1 -1
  37. package/lib/conversation/message/MessageService.js +162 -19
  38. package/lib/conversation/message/MessageService.test.js +141 -151
  39. package/lib/conversation/message/PayloadBundle.js +1 -1
  40. package/lib/conversation/message/UserClientsUtil.d.ts +10 -14
  41. package/lib/conversation/message/UserClientsUtil.d.ts.map +1 -1
  42. package/lib/conversation/message/UserClientsUtil.js +11 -21
  43. package/lib/conversation/message/UserClientsUtils.test.js +9 -5
  44. package/lib/messagingProtocols/mls/EventHandler/EventHandler.d.ts +1 -1
  45. package/lib/messagingProtocols/mls/EventHandler/EventHandler.d.ts.map +1 -1
  46. package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.d.ts +1 -1
  47. package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.d.ts.map +1 -1
  48. package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.js +2 -7
  49. package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.d.ts.map +1 -1
  50. package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.js +0 -2
  51. package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.test.js +1 -3
  52. package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts +8 -19
  53. package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts.map +1 -1
  54. package/lib/messagingProtocols/mls/MLSService/MLSService.js +37 -79
  55. package/lib/messagingProtocols/mls/MLSService/MLSService.test.js +0 -9
  56. package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/index.d.ts +2 -0
  57. package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/index.d.ts.map +1 -0
  58. package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/index.js +35 -0
  59. package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.d.ts +11 -0
  60. package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.d.ts.map +1 -0
  61. package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.js +50 -0
  62. package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.test.d.ts +2 -0
  63. package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.test.d.ts.map +1 -0
  64. package/lib/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.test.js +39 -0
  65. package/lib/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.d.ts +4 -0
  66. package/lib/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.d.ts.map +1 -0
  67. package/lib/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.js +35 -0
  68. package/lib/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.test.d.ts +2 -0
  69. package/lib/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.test.d.ts.map +1 -0
  70. package/lib/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.test.js +35 -0
  71. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.d.ts +5 -10
  72. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.d.ts.map +1 -1
  73. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.js +11 -33
  74. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.d.ts +3 -2
  75. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.d.ts.map +1 -1
  76. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.js +9 -8
  77. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.store.d.ts +9 -4
  78. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.store.d.ts.map +1 -1
  79. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.store.js +24 -10
  80. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/PrekeysTracker/PrekeysTracker.test.js +10 -2
  81. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.d.ts +2 -1
  82. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.d.ts.map +1 -1
  83. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.js +3 -3
  84. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.d.ts +2 -2
  85. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.d.ts.map +1 -1
  86. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoboxWrapper.d.ts +1 -1
  87. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoboxWrapper.d.ts.map +1 -1
  88. package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoboxWrapper.js +2 -2
  89. package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts +7 -14
  90. package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts.map +1 -1
  91. package/lib/messagingProtocols/proteus/ProteusService/ProteusService.js +35 -31
  92. package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts +1 -1
  93. package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts.map +1 -1
  94. package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.js +3 -2
  95. package/lib/messagingProtocols/proteus/ProteusService/ProteusService.test.js +89 -109
  96. package/lib/messagingProtocols/proteus/ProteusService/ProteusService.types.d.ts +9 -6
  97. package/lib/messagingProtocols/proteus/ProteusService/ProteusService.types.d.ts.map +1 -1
  98. package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.d.ts +25 -0
  99. package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.d.ts.map +1 -0
  100. package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.js +93 -0
  101. package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.test.d.ts +2 -0
  102. package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.test.d.ts.map +1 -0
  103. package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/PreKeyBundle.test.js +66 -0
  104. package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/index.d.ts +2 -0
  105. package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/index.d.ts.map +1 -0
  106. package/lib/messagingProtocols/proteus/Utility/PreKeyBundle/index.js +35 -0
  107. package/lib/messagingProtocols/proteus/Utility/Recipients.d.ts +10 -4
  108. package/lib/messagingProtocols/proteus/Utility/Recipients.d.ts.map +1 -1
  109. package/lib/messagingProtocols/proteus/Utility/Recipients.js +16 -16
  110. package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.d.ts +10 -15
  111. package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.d.ts.map +1 -1
  112. package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.js +92 -80
  113. package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.test.js +54 -70
  114. package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.d.ts +14 -5
  115. package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.d.ts.map +1 -1
  116. package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.js +35 -3
  117. package/lib/messagingProtocols/proteus/Utility/isClearFromMismatch.d.ts +2 -2
  118. package/lib/messagingProtocols/proteus/Utility/isClearFromMismatch.d.ts.map +1 -1
  119. package/lib/notification/NotificationDatabaseRepository.js +1 -1
  120. package/lib/notification/Notifications.types.js +1 -1
  121. package/lib/user/UserService.d.ts +17 -6
  122. package/lib/user/UserService.d.ts.map +1 -1
  123. package/lib/user/UserService.js +47 -2
  124. package/lib/util/TaskScheduler/TaskScheduler.d.ts +1 -4
  125. package/lib/util/TaskScheduler/TaskScheduler.d.ts.map +1 -1
  126. package/lib/util/TaskScheduler/TaskScheduler.js +3 -24
  127. package/lib/util/TypePredicateUtil.d.ts +1 -0
  128. package/lib/util/TypePredicateUtil.d.ts.map +1 -1
  129. package/lib/util/TypePredicateUtil.js +2 -1
  130. package/package.json +8 -8
  131. package/LICENSE +0 -674
  132. package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.d.ts +0 -13
  133. package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.d.ts.map +0 -1
  134. package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.js +0 -67
  135. package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.test.d.ts +0 -2
  136. package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.test.d.ts.map +0 -1
  137. package/lib/messagingProtocols/mls/MLSService/stores/subconversationGroupIdStore/subconversationGroupIdStore.test.js +0 -72
  138. package/lib/util/TaskScheduler/TaskScheduler.store.d.ts +0 -7
  139. package/lib/util/TaskScheduler/TaskScheduler.store.d.ts.map +0 -1
  140. package/lib/util/TaskScheduler/TaskScheduler.store.js +0 -34
@@ -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,sCA0B/B,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,EAAE,WAAW,EAAC,MAAM,sCAAsC,CAAC;AACvF,OAAO,EAAC,WAAW,EAAE,4BAA4B,EAAE,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AAE5G,OAAO,EAAC,cAAc,EAAC,MAAM,6BAA6B,CAAC;AAK3D,OAAO,EAAoB,qBAAqB,EAAC,MAAM,uBAAuB,CAAC;AAG/E,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,IAAI,CAAC;IAChB,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,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,sBAAsB,EAAE,YAAY,GAAG,SAAS,GAAG,WAAW,CAAC,GAAG;IACjG,SAAS,EAAE,KAAK,CAAC;IACjB,UAAU,EAAE,WAAW,GAAG,mBAAmB,CAAC;IAC9C,OAAO,EAAE,IAAI,CAAC,sBAAsB,CAAC,SAAS,CAAC,EAAE,eAAe,CAAC,GAAG;QAClE,aAAa,EAAE,OAAO,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;KAC/C,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,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,SAAS,CAAC;CACtB;AACD,KAAK,iCAAiC,GAAG,OAAO,CAAC,aAAa,GAAG,sBAAsB,CAAC,CAAC;AAEzF,QAAA,MAAM,uBAAuB,mIAO1B,6BAA6B,sCAyD/B,CAAC;AAEF,OAAO,EAAC,uBAAuB,EAAC,CAAC"}
@@ -24,24 +24,56 @@ const Recipients_1 = require("./Recipients");
24
24
  const UserIds_1 = require("./UserIds");
25
25
  const conversation_1 = require("../../../conversation");
26
26
  const util_1 = require("../../../util");
27
- const getGenericMessageParams = async ({ sendingClientId, conversationId, genericMessage, options: { targetMode = conversation_1.MessageTargetMode.NONE, userIds, nativePush }, apiClient, }) => {
27
+ const getGenericMessageParams = async ({ sendingClientId, conversationId, genericMessage, options: { targetMode = conversation_1.MessageTargetMode.NONE, userIds, nativePush }, useQualifiedIds, apiClient, }) => {
28
28
  const plainText = protocol_messaging_1.GenericMessage.encode(genericMessage).finish();
29
29
  if (targetMode !== conversation_1.MessageTargetMode.NONE && !userIds) {
30
30
  throw new Error('Cannot send targetted message when no userIds are given');
31
31
  }
32
+ if (conversationId.domain && useQualifiedIds) {
33
+ if ((0, util_1.isStringArray)(userIds) || (0, util_1.isUserClients)(userIds)) {
34
+ throw new Error('Invalid userIds option for sending to federated backend');
35
+ }
36
+ const recipients = await (0, Recipients_1.getQualifiedRecipientsForConversation)({ apiClient, conversationId, userIds });
37
+ let reportMissing;
38
+ if (targetMode === conversation_1.MessageTargetMode.NONE) {
39
+ reportMissing = (0, util_1.isQualifiedUserClients)(userIds); // we want to check mismatch in case the consumer gave an exact list of users/devices
40
+ }
41
+ else if (targetMode === conversation_1.MessageTargetMode.USERS) {
42
+ reportMissing = (0, UserIds_1.extractQualifiedUserIds)({ userIds });
43
+ }
44
+ else {
45
+ // in case the message is fully targetted at user/client pairs, we do not want to report the missing clients or users at all
46
+ reportMissing = false;
47
+ }
48
+ return {
49
+ federated: true,
50
+ sendingClientId,
51
+ recipients,
52
+ plainText,
53
+ options: {
54
+ conversationId,
55
+ nativePush,
56
+ reportMissing,
57
+ },
58
+ };
59
+ }
60
+ if ((0, util_1.isQualifiedIdArray)(userIds) || (0, util_1.isQualifiedUserClients)(userIds)) {
61
+ throw new Error('Invalid userIds option for sending');
62
+ }
32
63
  const recipients = await (0, Recipients_1.getRecipientsForConversation)({ apiClient, conversationId, userIds });
33
64
  let reportMissing;
34
65
  if (targetMode === conversation_1.MessageTargetMode.NONE) {
35
- reportMissing = (0, util_1.isQualifiedUserClients)(userIds); // we want to check mismatch in case the consumer gave an exact list of users/devices
66
+ reportMissing = (0, util_1.isUserClients)(userIds); // we want to check mismatch in case the consumer gave an exact list of users/devices
36
67
  }
37
68
  else if (targetMode === conversation_1.MessageTargetMode.USERS) {
38
- reportMissing = (0, UserIds_1.extractQualifiedUserIds)({ userIds });
69
+ reportMissing = (0, UserIds_1.extractUserIds)({ userIds });
39
70
  }
40
71
  else {
41
72
  // in case the message is fully targetted at user/client pairs, we do not want to report the missing clients or users at all
42
73
  reportMissing = false;
43
74
  }
44
75
  return {
76
+ federated: false,
45
77
  sendingClientId,
46
78
  recipients,
47
79
  plainText,
@@ -1,4 +1,4 @@
1
- import { MessageSendingStatus } from '@wireapp/api-client/lib/conversation';
2
- declare const isClearFromMismatch: (mismatch: MessageSendingStatus) => boolean;
1
+ import { ClientMismatch, MessageSendingStatus } from '@wireapp/api-client/lib/conversation';
2
+ declare const isClearFromMismatch: (mismatch: ClientMismatch | MessageSendingStatus) => boolean;
3
3
  export { isClearFromMismatch };
4
4
  //# sourceMappingURL=isClearFromMismatch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"isClearFromMismatch.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/Utility/isClearFromMismatch.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,oBAAoB,EAAC,MAAM,sCAAsC,CAAC;AAE1E,QAAA,MAAM,mBAAmB,aAAc,oBAAoB,KAAG,OAM7D,CAAC;AAEF,OAAO,EAAC,mBAAmB,EAAC,CAAC"}
1
+ {"version":3,"file":"isClearFromMismatch.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/proteus/Utility/isClearFromMismatch.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,cAAc,EAAE,oBAAoB,EAAC,MAAM,sCAAsC,CAAC;AAE1F,QAAA,MAAM,mBAAmB,aAAc,cAAc,GAAG,oBAAoB,KAAG,OAM9E,CAAC;AAEF,OAAO,EAAC,mBAAmB,EAAC,CAAC"}
@@ -27,7 +27,7 @@ var DatabaseKeys;
27
27
  (function (DatabaseKeys) {
28
28
  DatabaseKeys["PRIMARY_KEY_LAST_EVENT"] = "z.storage.StorageKey.EVENT.LAST_DATE";
29
29
  DatabaseKeys["PRIMARY_KEY_LAST_NOTIFICATION"] = "z.storage.StorageKey.NOTIFICATION.LAST_ID";
30
- })(DatabaseKeys || (exports.DatabaseKeys = DatabaseKeys = {}));
30
+ })(DatabaseKeys = exports.DatabaseKeys || (exports.DatabaseKeys = {}));
31
31
  const STORES = {
32
32
  AMPLIFY: 'amplify',
33
33
  };
@@ -24,4 +24,4 @@ var NotificationSource;
24
24
  NotificationSource["LOCAL"] = "LOCAL";
25
25
  NotificationSource["NOTIFICATION_STREAM"] = "NOTIFICATION_STREAM";
26
26
  NotificationSource["WEBSOCKET"] = "WEBSOCKET";
27
- })(NotificationSource || (exports.NotificationSource = NotificationSource = {}));
27
+ })(NotificationSource = exports.NotificationSource || (exports.NotificationSource = {}));
@@ -1,13 +1,24 @@
1
1
  import { QualifiedId, User } from '@wireapp/api-client/lib/user/';
2
2
  import { APIClient } from '@wireapp/api-client';
3
+ import { AvailabilityType, BroadcastService } from '../broadcast/';
4
+ import { ConnectionService } from '../connection';
3
5
  export declare class UserService {
4
6
  private readonly apiClient;
5
- constructor(apiClient: APIClient);
7
+ private readonly broadcastService;
8
+ private readonly connectionService;
9
+ constructor(apiClient: APIClient, broadcastService: BroadcastService, connectionService: ConnectionService);
6
10
  getUser(userId: string | QualifiedId): Promise<User>;
7
- getUsers(userIds: QualifiedId[]): Promise<{
8
- found: User[];
9
- failed?: QualifiedId[] | undefined;
10
- not_found?: QualifiedId[] | undefined;
11
- } | never[]>;
11
+ getUsers(userIds: string[] | QualifiedId[]): Promise<User[]>;
12
+ /**
13
+ * Sends a availability update to members of the same team
14
+ * @param teamId
15
+ * @param type
16
+ * @param options.sendAll=false will broadcast the message to all the members of the team (instead of just direct connections). Should be avoided in a big team
17
+ * @param options.sendAsProtobuf=false
18
+ */
19
+ setAvailability(teamId: string, type: AvailabilityType, { sendAll, sendAsProtobuf }?: {
20
+ sendAll?: boolean | undefined;
21
+ sendAsProtobuf?: boolean | undefined;
22
+ }): Promise<void>;
12
23
  }
13
24
  //# sourceMappingURL=UserService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"UserService.d.ts","sourceRoot":"","sources":["../../src/user/UserService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAE,IAAI,EAAC,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;gBAE1B,SAAS,EAAE,SAAS;IAIzB,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C,QAAQ,CAAC,OAAO,EAAE,WAAW,EAAE;;;;;CAM7C"}
1
+ {"version":3,"file":"UserService.d.ts","sourceRoot":"","sources":["../../src/user/UserService.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAC,WAAW,EAAE,IAAI,EAAsB,MAAM,+BAA+B,CAAC;AAErF,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAG9C,OAAO,EAAC,gBAAgB,EAAE,gBAAgB,EAAC,MAAM,eAAe,CAAC;AACjE,OAAO,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAKhD,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAmB;IACpD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAoB;gBAE1C,SAAS,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,iBAAiB;IAMnG,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IASzE;;;;;;OAMG;IACU,eAAe,CAC1B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,gBAAgB,EACtB,EAAC,OAAe,EAAE,cAAsB,EAAC;;;KAAK,GAC7C,OAAO,CAAC,IAAI,CAAC;CAuCjB"}
@@ -19,9 +19,16 @@
19
19
  */
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.UserService = void 0;
22
+ const connection_1 = require("@wireapp/api-client/lib/connection");
23
+ const protocol_messaging_1 = require("@wireapp/protocol-messaging");
24
+ const MessageBuilder_1 = require("../conversation/message/MessageBuilder");
25
+ const PreKeyBundle_1 = require("../messagingProtocols/proteus/Utility/PreKeyBundle");
26
+ const TypePredicateUtil_1 = require("../util/TypePredicateUtil");
22
27
  class UserService {
23
- constructor(apiClient) {
28
+ constructor(apiClient, broadcastService, connectionService) {
24
29
  this.apiClient = apiClient;
30
+ this.broadcastService = broadcastService;
31
+ this.connectionService = connectionService;
25
32
  }
26
33
  getUser(userId) {
27
34
  return this.apiClient.api.user.getUser(userId);
@@ -30,7 +37,45 @@ class UserService {
30
37
  if (!userIds.length) {
31
38
  return [];
32
39
  }
33
- return this.apiClient.api.user.postListUsers({ qualified_ids: userIds });
40
+ return (0, TypePredicateUtil_1.isQualifiedIdArray)(userIds)
41
+ ? this.apiClient.api.user.postListUsers({ qualified_ids: userIds })
42
+ : this.apiClient.api.user.getUsers({ ids: userIds });
43
+ }
44
+ /**
45
+ * Sends a availability update to members of the same team
46
+ * @param teamId
47
+ * @param type
48
+ * @param options.sendAll=false will broadcast the message to all the members of the team (instead of just direct connections). Should be avoided in a big team
49
+ * @param options.sendAsProtobuf=false
50
+ */
51
+ async setAvailability(teamId, type, { sendAll = false, sendAsProtobuf = false } = {}) {
52
+ // Get pre-key bundles for members of your own team
53
+ const preKeyBundlesFromTeam = await this.broadcastService.getPreKeyBundlesFromTeam(teamId, false, !sendAll);
54
+ // Get pre-key bundles for all of your other 1:1 connections
55
+ const connections = await this.connectionService.getConnections();
56
+ const acceptedConnections = connections.filter(connection => connection.status === connection_1.ConnectionStatus.ACCEPTED);
57
+ const preKeyBundlePromises = acceptedConnections.map(connection => {
58
+ const mappedConnection = {
59
+ userId: connection.to,
60
+ conversationId: connection.conversation,
61
+ };
62
+ return (0, PreKeyBundle_1.getPreKeyBundleMap)({
63
+ apiClient: this.apiClient,
64
+ conversationId: { id: mappedConnection.conversationId, domain: '' },
65
+ userIds: [mappedConnection.userId],
66
+ });
67
+ });
68
+ const preKeyBundlesFromConnections = await Promise.all(preKeyBundlePromises);
69
+ // Merge pre-key bundles
70
+ const allPreKeyBundles = preKeyBundlesFromConnections.reduce((accumulator, preKeyBundleMap) => {
71
+ return Object.assign(Object.assign({}, accumulator), preKeyBundleMap);
72
+ }, preKeyBundlesFromTeam);
73
+ const genericMessage = protocol_messaging_1.GenericMessage.create({
74
+ availability: new protocol_messaging_1.Availability({ type }),
75
+ messageId: (0, MessageBuilder_1.createId)(),
76
+ });
77
+ // Broadcast availability status to your team members & external 1:1 connections
78
+ await this.broadcastService.broadcastGenericMessage(genericMessage, allPreKeyBundles, sendAsProtobuf);
34
79
  }
35
80
  }
36
81
  exports.UserService = UserService;
@@ -2,13 +2,10 @@ type ScheduleTaskParams = {
2
2
  task: () => void;
3
3
  firingDate: number;
4
4
  key: string;
5
- persist?: boolean;
6
5
  };
7
6
  export declare const TaskScheduler: {
8
- addTask: ({ task, firingDate, key, persist }: ScheduleTaskParams) => void;
7
+ addTask: ({ task, firingDate, key }: ScheduleTaskParams) => void;
9
8
  cancelTask: (key: string) => void;
10
- continueTask: ({ key, task }: Omit<ScheduleTaskParams, 'firingDate' | 'persist'>) => void;
11
- hasActiveTask: (key: string) => boolean;
12
9
  };
13
10
  export {};
14
11
  //# sourceMappingURL=TaskScheduler.d.ts.map
@@ -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,IAAI,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAoEF,eAAO,MAAM,aAAa;kDAzDiC,kBAAkB;sBAoCpD,MAAM;kCAcI,KAAK,kBAAkB,EAAE,YAAY,GAAG,SAAS,CAAC;;CAYpF,CAAC"}
1
+ {"version":3,"file":"TaskScheduler.d.ts","sourceRoot":"","sources":["../../../src/util/TaskScheduler/TaskScheduler.ts"],"names":[],"mappings":"AA0BA,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAiDF,eAAO,MAAM,aAAa;yCAtCgB,kBAAkB;sBA6BnC,MAAM;CAY9B,CAAC"}
@@ -23,7 +23,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.TaskScheduler = void 0;
25
25
  const logdown_1 = __importDefault(require("logdown"));
26
- const TaskScheduler_store_1 = require("./TaskScheduler.store");
27
26
  const logger = (0, logdown_1.default)('@wireapp/core/TaskScheduler', {
28
27
  logger: console,
29
28
  markdown: false,
@@ -36,27 +35,20 @@ const activeTimeouts = {};
36
35
  * @param firingDate execution date
37
36
  * @param key unique key for the task
38
37
  */
39
- const addTask = ({ task, firingDate, key, persist = false }) => {
40
- const now = Date.now();
38
+ const addTask = ({ task, firingDate, key }) => {
39
+ const now = new Date();
41
40
  const execute = new Date(firingDate);
42
- const delay = execute.getTime() - now;
43
- if (TaskScheduler_store_1.TaskSchedulerStore.has(key)) {
44
- TaskScheduler_store_1.TaskSchedulerStore.remove(key);
45
- }
41
+ const delay = execute.getTime() - now.getTime();
46
42
  if (activeTimeouts[key]) {
47
43
  cancelTask(key);
48
44
  }
49
45
  const timeout = setTimeout(async () => {
50
46
  logger.info(`Executing task with key "${key}"`);
51
47
  delete activeTimeouts[key];
52
- TaskScheduler_store_1.TaskSchedulerStore.remove(key);
53
48
  await task();
54
49
  }, delay > 0 ? delay : 0);
55
50
  // add the task to the list of active tasks
56
51
  activeTimeouts[key] = timeout;
57
- if (persist) {
58
- TaskScheduler_store_1.TaskSchedulerStore.add(key, firingDate);
59
- }
60
52
  logger.info(`New scheduled task to be executed at "${execute}" with key "${key}"`);
61
53
  };
62
54
  /**
@@ -72,20 +64,7 @@ const cancelTask = (key) => {
72
64
  logger.info(`Scheduled task with key "${key}" prematurely cleared`);
73
65
  }
74
66
  };
75
- /**
76
- * Checks if a task has been scheduled in the past and reschedules it
77
- * @param task function to be executed
78
- * @param key unique key for the task
79
- */
80
- const continueTask = ({ key, task }) => {
81
- const activeTaskEndTime = TaskScheduler_store_1.TaskSchedulerStore.get(key);
82
- if (activeTaskEndTime) {
83
- addTask({ task, firingDate: activeTaskEndTime, key, persist: true });
84
- }
85
- };
86
67
  exports.TaskScheduler = {
87
68
  addTask,
88
69
  cancelTask,
89
- continueTask,
90
- hasActiveTask: TaskScheduler_store_1.TaskSchedulerStore.has,
91
70
  };
@@ -2,6 +2,7 @@ import { Conversation, QualifiedUserClients, UserClients } from '@wireapp/api-cl
2
2
  import { QualifiedId } from '@wireapp/api-client/lib/user/';
3
3
  import { MLSConversation } from '../messagingProtocols/mls/types';
4
4
  export declare function isStringArray(obj: any): obj is string[];
5
+ export declare function isQualifiedId(obj: any): obj is QualifiedId;
5
6
  export declare function isQualifiedIdArray(obj: any): obj is QualifiedId[];
6
7
  export declare function isQualifiedUserClients(obj: any): obj is QualifiedUserClients;
7
8
  export declare function isUserClients(obj: any): obj is UserClients;
@@ -1 +1 @@
1
- {"version":3,"file":"TypePredicateUtil.d.ts","sourceRoot":"","sources":["../../src/util/TypePredicateUtil.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,YAAY,EAEZ,oBAAoB,EACpB,WAAW,EACZ,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAC,WAAW,EAAC,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAEhE,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,MAAM,EAAE,CAEvD;AAMD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,WAAW,EAAE,CAEjE;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,oBAAoB,CAS5E;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,WAAW,CAM1D;AAED,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,YAAY,GAAG,YAAY,IAAI,eAAe,CAG7F"}
1
+ {"version":3,"file":"TypePredicateUtil.d.ts","sourceRoot":"","sources":["../../src/util/TypePredicateUtil.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,YAAY,EAEZ,oBAAoB,EACpB,WAAW,EACZ,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAC,WAAW,EAAC,MAAM,+BAA+B,CAAC;AAE1D,OAAO,EAAC,eAAe,EAAC,MAAM,iCAAiC,CAAC;AAEhE,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,MAAM,EAAE,CAEvD;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,WAAW,CAE1D;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,WAAW,EAAE,CAEjE;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,oBAAoB,CAS5E;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,WAAW,CAM1D;AAED,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,YAAY,GAAG,YAAY,IAAI,eAAe,CAG7F"}
@@ -18,7 +18,7 @@
18
18
  *
19
19
  */
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.isMLSConversation = exports.isUserClients = exports.isQualifiedUserClients = exports.isQualifiedIdArray = exports.isStringArray = void 0;
21
+ exports.isMLSConversation = exports.isUserClients = exports.isQualifiedUserClients = exports.isQualifiedIdArray = exports.isQualifiedId = exports.isStringArray = void 0;
22
22
  const conversation_1 = require("@wireapp/api-client/lib/conversation/");
23
23
  function isStringArray(obj) {
24
24
  return Array.isArray(obj) && (obj.length === 0 || typeof obj[0] === 'string');
@@ -27,6 +27,7 @@ exports.isStringArray = isStringArray;
27
27
  function isQualifiedId(obj) {
28
28
  return typeof obj === 'object' && typeof obj['domain'] === 'string';
29
29
  }
30
+ exports.isQualifiedId = isQualifiedId;
30
31
  function isQualifiedIdArray(obj) {
31
32
  return Array.isArray(obj) && isQualifiedId(obj[0]);
32
33
  }
package/package.json CHANGED
@@ -11,14 +11,14 @@
11
11
  "./lib/cryptography/AssetCryptography/crypto.node": "./lib/cryptography/AssetCryptography/crypto.browser.js"
12
12
  },
13
13
  "dependencies": {
14
- "@wireapp/api-client": "^24.15.4",
15
- "@wireapp/commons": "^5.1.0",
16
- "@wireapp/core-crypto": "0.11.0",
14
+ "@wireapp/api-client": "workspace:^",
15
+ "@wireapp/commons": "workspace:^",
16
+ "@wireapp/core-crypto": "1.0.0-pre.5",
17
17
  "@wireapp/cryptobox": "12.8.0",
18
- "@wireapp/promise-queue": "^2.2.0",
18
+ "@wireapp/promise-queue": "workspace:^",
19
19
  "@wireapp/protocol-messaging": "1.44.0",
20
- "@wireapp/store-engine": "5.1.1",
21
- "@wireapp/store-engine-dexie": "^2.1.2",
20
+ "@wireapp/store-engine": "workspace:*",
21
+ "@wireapp/store-engine-dexie": "workspace:^",
22
22
  "axios": "1.4.0",
23
23
  "bazinga64": "6.1.1",
24
24
  "deepmerge-ts": "4.3.0",
@@ -60,6 +60,6 @@
60
60
  "test:coverage": "jest --coverage",
61
61
  "watch": "tsc --watch"
62
62
  },
63
- "version": "40.5.1",
64
- "gitHead": "7096977539106206a58c7f0e391b4873457eab86"
63
+ "version": "40.5.2-1",
64
+ "gitHead": "5339f01fe01ef0871da8c8bc8662fbe9e604754a"
65
65
  }