@wireapp/core 40.5.0 → 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 +4 -11
  19. package/lib/conversation/ConversationService/ConversationService.d.ts.map +1 -1
  20. package/lib/conversation/ConversationService/ConversationService.js +5 -23
  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,11 +1,11 @@
1
- import { PostMlsMessageResponse, SUBCONVERSATION_ID } from '@wireapp/api-client/lib/conversation';
1
+ import { PostMlsMessageResponse } from '@wireapp/api-client/lib/conversation';
2
2
  import { Subconversation } from '@wireapp/api-client/lib/conversation/Subconversation';
3
3
  import { QualifiedId } from '@wireapp/api-client/lib/user';
4
4
  import logdown from 'logdown';
5
5
  import { APIClient } from '@wireapp/api-client';
6
- import { AddProposalArgs, ConversationId, CoreCrypto, DecryptedMessage, ExternalAddProposalArgs, ExternalProposalType, ExternalRemoveProposalArgs, Invitee, ProposalArgs, ProposalType, RemoveProposalArgs } from '@wireapp/core-crypto';
6
+ import { AddProposalArgs, ConversationId, CoreCrypto, DecryptedMessage, ExternalProposalArgs, ExternalProposalType, ExternalRemoveProposalArgs, Invitee, ProposalArgs, ProposalType, RemoveProposalArgs } from '@wireapp/core-crypto';
7
7
  import { MLSServiceConfig } from './MLSService.types';
8
- import { KeyPackageClaimUser } from '../../../conversation';
8
+ import { QualifiedUsers } from '../../../conversation';
9
9
  import { TypedEventEmitter } from '../../../util/TypedEventEmitter';
10
10
  import { EventHandlerResult } from '../../common.types';
11
11
  import { EventHandlerParams } from '../EventHandler';
@@ -34,21 +34,15 @@ export declare class MLSService extends TypedEventEmitter<Events> {
34
34
  initClient(userId: QualifiedId, clientId: string): Promise<void>;
35
35
  createClient(userId: QualifiedId, clientId: string): Promise<void>;
36
36
  private uploadCommitBundle;
37
- addUsersToExistingConversation(groupId: Uint8Array, invitee: Invitee[]): Promise<PostMlsMessageResponse | null> | null;
37
+ addUsersToExistingConversation(groupId: Uint8Array, invitee: Invitee[]): Promise<PostMlsMessageResponse | null>;
38
38
  configureMLSCallbacks({ groupIdFromConversationId, ...coreCryptoCallbacks }: MLSCallbacks): void;
39
- getKeyPackagesPayload(qualifiedUsers: KeyPackageClaimUser[]): Promise<Invitee[]>;
39
+ getKeyPackagesPayload(qualifiedUsers: QualifiedUsers[]): Promise<Invitee[]>;
40
40
  getEpoch(groupId: string | Uint8Array): Promise<number>;
41
41
  newProposal(proposalType: ProposalType, args: ProposalArgs | AddProposalArgs | RemoveProposalArgs): Promise<import("@wireapp/core-crypto").ProposalBundle>;
42
42
  joinByExternalCommit(getGroupInfo: () => Promise<Uint8Array>): Promise<PostMlsMessageResponse | null>;
43
43
  getConferenceSubconversation(conversationId: QualifiedId): Promise<Subconversation>;
44
44
  private deleteConferenceSubconversation;
45
- /**
46
- * Will leave conference subconversation if it's known by client and established.
47
- *
48
- * @param conversationId Id of the parent conversation which subconversation we want to leave
49
- */
50
45
  leaveConferenceSubconversation(conversationId: QualifiedId): Promise<void>;
51
- leaveStaleConferenceSubconversations(): Promise<void>;
52
46
  /**
53
47
  * Will join or register an mls subconversation for conference calls.
54
48
  * Will return the secret key derived from the subconversation
@@ -60,7 +54,7 @@ export declare class MLSService extends TypedEventEmitter<Events> {
60
54
  epoch: number;
61
55
  }>;
62
56
  exportSecretKey(groupId: string, keyLength: number): Promise<string>;
63
- newExternalProposal(externalProposalType: ExternalProposalType, args: ExternalAddProposalArgs | ExternalRemoveProposalArgs): Promise<Uint8Array>;
57
+ newExternalProposal(externalProposalType: ExternalProposalType, args: ExternalProposalArgs | ExternalRemoveProposalArgs): Promise<Uint8Array>;
64
58
  processWelcomeMessage(welcomeMessage: Uint8Array): Promise<ConversationId>;
65
59
  decryptMessage(conversationId: ConversationId, payload: Uint8Array): Promise<DecryptedMessage>;
66
60
  encryptMessage(conversationId: ConversationId, message: Uint8Array): Promise<Uint8Array>;
@@ -108,11 +102,6 @@ export declare class MLSService extends TypedEventEmitter<Events> {
108
102
  * @param groupId The group that should have its key material updated
109
103
  */
110
104
  resetKeyMaterialRenewal(groupId: string): void;
111
- /**
112
- * Will cancel the renewal of the key material for a given groupId
113
- * @param groupId The group that should stop having its key material updated
114
- */
115
- cancelKeyMaterialRenewal(groupId: string): void;
116
105
  /**
117
106
  * Will schedule a task to update the key material of the conversation according to the threshold given as config
118
107
  * @param groupId
@@ -122,7 +111,7 @@ export declare class MLSService extends TypedEventEmitter<Events> {
122
111
  * Get all keying material last update dates and schedule tasks for renewal
123
112
  * Function must only be called once, after application start
124
113
  */
125
- schedulePeriodicKeyMaterialRenewals(groupIds: string[]): void;
114
+ checkForKeyMaterialsUpdate(): void;
126
115
  /**
127
116
  * Get date of last key packages count query and schedule a task to sync it with backend
128
117
  * Function must only be called once, after application start
@@ -145,7 +134,7 @@ export declare class MLSService extends TypedEventEmitter<Events> {
145
134
  *
146
135
  * @param conversationQualifiedId
147
136
  */
148
- getGroupIdFromConversationId(conversationQualifiedId: QualifiedId, subconversationId?: SUBCONVERSATION_ID): Promise<string | undefined>;
137
+ getGroupIdFromConversationId(conversationQualifiedId: QualifiedId, subconversationId?: string): Promise<string>;
149
138
  /**
150
139
  * If there are pending proposals, we need to either process them,
151
140
  * or save them in the database for later processing
@@ -1 +1 @@
1
- {"version":3,"file":"MLSService.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/MLSService/MLSService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,sBAAsB,EAAE,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;AAChG,OAAO,EAAC,eAAe,EAAC,MAAM,sDAAsD,CAAC;AACrF,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAIzD,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EACL,eAAe,EAIf,cAAc,EACd,UAAU,EAEV,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAC,gBAAgB,EAAsB,MAAM,oBAAoB,CAAC;AAIzE,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAK1D,OAAO,EAAC,iBAAiB,EAAC,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAC,kBAAkB,EAAC,MAAM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B,IAAI,OAAO,CAAC,MAAM,CAAC;IAI9C,iBAAiB,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAI9E;;;;OAIG;IACU,gBAAgB,CAAC,OAAO,EAAE,MAAM;IAgB7C,OAAO,CAAC,sCAAsC;IAI9C;;;OAGG;IACI,uBAAuB,CAAC,OAAO,EAAE,MAAM;IAK9C;;;OAGG;IACI,0BAA0B,CAAC,OAAO,EAAE,MAAM;IAUjD;;;OAGG;IACI,0BAA0B;IASjC;;;OAGG;IACI,8BAA8B;YAQvB,eAAe;IAmB7B;;;;;OAKG;YACW,mBAAmB;YAMnB,oBAAoB;IAOrB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKhD,WAAW,CAAC,MAAM,EAAE,IAAI,CAAC,kBAAkB,EAAE,YAAY,CAAC,GAAG,kBAAkB;IAO5F;;;;;OAKG;IACU,4BAA4B,CACvC,uBAAuB,EAAE,WAAW,EACpC,iBAAiB,CAAC,EAAE,MAAM,GACzB,OAAO,CAAC,MAAM,CAAC;IAYlB;;;;;;;OAOG;IACU,sBAAsB,CAAC,EAAC,SAAS,EAAE,OAAO,EAAE,SAAS,EAAC,EAAE,4BAA4B;IAoBjG;;;;;OAKG;IACU,sBAAsB,CAAC,EAAC,OAAO,EAAE,UAAkB,EAAC,EAAE,4BAA4B;IAa/F;;;;OAIG;IACU,6BAA6B;IAiB1C;;;;OAIG;IACU,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,EAAE,CAAC;CAW1G"}
@@ -39,10 +39,10 @@ const axios_1 = __importDefault(require("axios"));
39
39
  const bazinga64_1 = require("bazinga64");
40
40
  const logdown_1 = __importDefault(require("logdown"));
41
41
  const commons_1 = require("@wireapp/commons");
42
- const core_crypto_1 = require("@wireapp/core-crypto");
43
42
  const commitBundleUtil_1 = require("./commitBundleUtil");
43
+ const keyMaterialUpdatesStore_1 = require("./stores/keyMaterialUpdatesStore");
44
44
  const pendingProposalsStore_1 = require("./stores/pendingProposalsStore");
45
- const subconversationGroupIdStore_1 = require("./stores/subconversationGroupIdStore/subconversationGroupIdStore");
45
+ const subconversationGroupIdMapper_1 = require("./subconversationGroupIdMapper");
46
46
  const messageSender_1 = require("../../../conversation/message/messageSender");
47
47
  const fullyQualifiedClientIdUtils_1 = require("../../../util/fullyQualifiedClientIdUtils");
48
48
  const RecurringTaskScheduler_1 = require("../../../util/RecurringTaskScheduler");
@@ -74,15 +74,13 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
74
74
  }
75
75
  async initClient(userId, clientId) {
76
76
  const qualifiedClientId = (0, fullyQualifiedClientIdUtils_1.constructFullyQualifiedClientId)(userId.id, clientId, userId.domain);
77
- await this.coreCryptoClient.mlsInit(this.textEncoder.encode(qualifiedClientId), [
78
- core_crypto_1.Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519,
79
- ]);
77
+ await this.coreCryptoClient.mlsInit(this.textEncoder.encode(qualifiedClientId));
80
78
  }
81
79
  async createClient(userId, clientId) {
82
80
  await this.initClient(userId, clientId);
83
81
  // If the device is new, we need to upload keypackages and public key to the backend
84
- const publicKey = await this.coreCryptoClient.clientPublicKey(core_crypto_1.Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519);
85
- const keyPackages = await this.coreCryptoClient.clientKeypackages(core_crypto_1.Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519, this.config.nbKeyPackages);
82
+ const publicKey = await this.coreCryptoClient.clientPublicKey();
83
+ const keyPackages = await this.coreCryptoClient.clientKeypackages(this.config.nbKeyPackages);
86
84
  await this.uploadMLSPublicKeys(publicKey, clientId);
87
85
  await this.uploadMLSKeyPackages(keyPackages, clientId);
88
86
  }
@@ -121,18 +119,16 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
121
119
  return null;
122
120
  }
123
121
  addUsersToExistingConversation(groupId, invitee) {
124
- if (invitee.length < 1) {
125
- // providing an empty invitee list to addClientsToConversation method would make core-crypto throw an error
126
- // we want to skip adding clinets in this case
127
- return null;
128
- }
129
122
  return this.processCommitAction(groupId, () => this.coreCryptoClient.addClientsToConversation(groupId, invitee));
130
123
  }
131
124
  configureMLSCallbacks(_a) {
132
125
  var { groupIdFromConversationId } = _a, coreCryptoCallbacks = __rest(_a, ["groupIdFromConversationId"]);
133
- void this.coreCryptoClient.registerCallbacks(Object.assign(Object.assign({}, coreCryptoCallbacks), { clientIsExistingGroupUser: (_groupId, _client, _otherClients) => {
134
- // All authorization/membership rules are enforced on backend
135
- return Promise.resolve(true);
126
+ void this.coreCryptoClient.registerCallbacks(Object.assign(Object.assign({}, coreCryptoCallbacks), { clientIsExistingGroupUser: (_groupId, client, otherClients) => {
127
+ const { user } = (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(this.textDecoder.decode(client));
128
+ return Promise.resolve(otherClients.some(client => {
129
+ const { user: otherUser } = (0, fullyQualifiedClientIdUtils_1.parseFullQualifiedClientId)(this.textDecoder.decode(client));
130
+ return otherUser.toLowerCase() === user.toLowerCase();
131
+ }));
136
132
  } }));
137
133
  this.groupIdFromConversationId = groupIdFromConversationId;
138
134
  }
@@ -142,7 +138,9 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
142
138
  * we want to add to the new MLS conversations,
143
139
  * includes self user too.
144
140
  */
145
- const keyPackages = await Promise.all(qualifiedUsers.map(({ id, domain, skipOwnClientId }) => this.apiClient.api.client.claimMLSKeyPackages(id, domain, skipOwnClientId)));
141
+ const keyPackages = await Promise.all([
142
+ ...qualifiedUsers.map(({ id, domain, skipOwn }) => this.apiClient.api.client.claimMLSKeyPackages(id, domain, skipOwn)),
143
+ ]);
146
144
  const coreCryptoKeyPackagesPayload = keyPackages.reduce((previousValue, currentValue) => {
147
145
  // skip users that have not uploaded their MLS key packages
148
146
  if (currentValue.key_packages.length > 0) {
@@ -168,20 +166,14 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
168
166
  async joinByExternalCommit(getGroupInfo) {
169
167
  const generateCommit = async () => {
170
168
  const groupInfo = await getGroupInfo();
171
- const _a = await this.coreCryptoClient.joinByExternalCommit(groupInfo, core_crypto_1.CredentialType.Basic), { conversationId } = _a, commitBundle = __rest(_a, ["conversationId"]);
169
+ const _a = await this.coreCryptoClient.joinByExternalCommit(groupInfo), { conversationId } = _a, commitBundle = __rest(_a, ["conversationId"]);
172
170
  return { groupId: conversationId, commitBundle };
173
171
  };
174
172
  const { commitBundle, groupId } = await generateCommit();
175
- const mlsResponse = await this.uploadCommitBundle(groupId, commitBundle, {
173
+ return this.uploadCommitBundle(groupId, commitBundle, {
176
174
  isExternalCommit: true,
177
175
  regenerateCommitBundle: async () => (await generateCommit()).commitBundle,
178
176
  });
179
- if (mlsResponse) {
180
- //after we've successfully joined via external commit, we schedule periodic key material renewal
181
- const groupIdStr = bazinga64_1.Encoder.toBase64(groupId).asString;
182
- this.scheduleKeyMaterialRenewal(groupIdStr);
183
- }
184
- return mlsResponse;
185
177
  }
186
178
  async getConferenceSubconversation(conversationId) {
187
179
  return this.apiClient.api.conversation.getSubconversation(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
@@ -189,36 +181,14 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
189
181
  async deleteConferenceSubconversation(conversationId, data) {
190
182
  return this.apiClient.api.conversation.deleteSubconversation(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE, data);
191
183
  }
192
- /**
193
- * Will leave conference subconversation if it's known by client and established.
194
- *
195
- * @param conversationId Id of the parent conversation which subconversation we want to leave
196
- */
197
184
  async leaveConferenceSubconversation(conversationId) {
198
- const subconversationGroupId = subconversationGroupIdStore_1.subconversationGroupIdStore.getGroupId(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
199
- if (!subconversationGroupId) {
200
- return;
201
- }
185
+ const subconversationGroupId = await this.getGroupIdFromConversationId(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
202
186
  const isSubconversationEstablished = await this.conversationExists(subconversationGroupId);
203
187
  if (!isSubconversationEstablished) {
204
- // if the subconversation was known by a client but is not established anymore, we can remove it from the store
205
- return subconversationGroupIdStore_1.subconversationGroupIdStore.removeGroupId(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
206
- }
207
- try {
208
- await this.apiClient.api.conversation.deleteSubconversationSelf(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
209
- }
210
- catch (error) {
211
- this.logger.error(`Failed to leave conference subconversation:`, error);
212
- }
213
- await this.wipeConversation(subconversationGroupId);
214
- // once we've left the subconversation, we can remove it from the store
215
- subconversationGroupIdStore_1.subconversationGroupIdStore.removeGroupId(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
216
- }
217
- async leaveStaleConferenceSubconversations() {
218
- const conversationIds = subconversationGroupIdStore_1.subconversationGroupIdStore.getAllGroupIdsBySubconversationId(conversation_1.SUBCONVERSATION_ID.CONFERENCE);
219
- for (const { parentConversationId } of conversationIds) {
220
- await this.leaveConferenceSubconversation(parentConversationId);
188
+ return;
221
189
  }
190
+ await this.apiClient.api.conversation.deleteSubconversationSelf(conversationId, conversation_1.SUBCONVERSATION_ID.CONFERENCE);
191
+ return this.wipeConversation(subconversationGroupId);
222
192
  }
223
193
  /**
224
194
  * Will join or register an mls subconversation for conference calls.
@@ -248,7 +218,7 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
248
218
  }
249
219
  const epoch = Number(await this.getEpoch(subconversation.group_id));
250
220
  // We store the mapping between the subconversation and the parent conversation
251
- subconversationGroupIdStore_1.subconversationGroupIdStore.storeGroupId(conversationId, subconversation.subconv_id, subconversation.group_id);
221
+ (0, subconversationGroupIdMapper_1.storeSubconversationGroupId)(conversationId, subconversation.subconv_id, subconversation.group_id);
252
222
  return { groupId: subconversation.group_id, epoch };
253
223
  }
254
224
  async exportSecretKey(groupId, keyLength) {
@@ -300,16 +270,16 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
300
270
  const mlsKeyBytes = Object.values(mlsKeys).map((key) => bazinga64_1.Decoder.fromBase64(key).asBytes);
301
271
  const configuration = {
302
272
  externalSenders: mlsKeyBytes,
303
- ciphersuite: core_crypto_1.Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519,
273
+ ciphersuite: 1, // TODO: Use the correct ciphersuite enum.
304
274
  };
305
- await this.coreCryptoClient.createConversation(groupIdBytes, core_crypto_1.CredentialType.Basic, configuration);
275
+ await this.coreCryptoClient.createConversation(groupIdBytes, configuration);
306
276
  const keyPackages = await this.getKeyPackagesPayload(users.map(user => {
307
277
  if (user.id === (creator === null || creator === void 0 ? void 0 : creator.user.id)) {
308
278
  /**
309
279
  * we should skip fetching key packages for current self client,
310
280
  * it's already added by the backend on the group creation time
311
281
  */
312
- return Object.assign(Object.assign({}, creator.user), { skipOwnClientId: creator.client });
282
+ return Object.assign(Object.assign({}, creator.user), { skipOwn: creator.client });
313
283
  }
314
284
  return user;
315
285
  }));
@@ -317,7 +287,7 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
317
287
  ? await this.addUsersToExistingConversation(groupIdBytes, keyPackages)
318
288
  : // If there are no clients to add, just update the keying material
319
289
  await this.processCommitAction(groupIdBytes, () => this.coreCryptoClient.updateKeyingMaterial(groupIdBytes));
320
- // We schedule a periodic key material renewal
290
+ // We schedule a key material renewal
321
291
  this.scheduleKeyMaterialRenewal(groupId);
322
292
  return response;
323
293
  }
@@ -339,10 +309,10 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
339
309
  return this.coreCryptoClient.conversationExists(groupIdBytes);
340
310
  }
341
311
  async clientValidKeypackagesCount() {
342
- return this.coreCryptoClient.clientValidKeypackagesCount(core_crypto_1.Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519);
312
+ return this.coreCryptoClient.clientValidKeypackagesCount();
343
313
  }
344
314
  async clientKeypackages(amountRequested) {
345
- return this.coreCryptoClient.clientKeypackages(core_crypto_1.Ciphersuite.MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519, amountRequested);
315
+ return this.coreCryptoClient.clientKeypackages(amountRequested);
346
316
  }
347
317
  /**
348
318
  * Renew key material for a given groupId
@@ -353,7 +323,7 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
353
323
  try {
354
324
  const groupConversationExists = await this.conversationExists(groupId);
355
325
  if (!groupConversationExists) {
356
- this.cancelKeyMaterialRenewal(groupId);
326
+ keyMaterialUpdatesStore_1.keyMaterialUpdatesStore.deleteLastKeyMaterialUpdateDate({ groupId });
357
327
  return;
358
328
  }
359
329
  const groupIdDecodedFromBase64 = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
@@ -371,16 +341,9 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
371
341
  * @param groupId The group that should have its key material updated
372
342
  */
373
343
  resetKeyMaterialRenewal(groupId) {
374
- this.cancelKeyMaterialRenewal(groupId);
344
+ (0, RecurringTaskScheduler_1.cancelRecurringTask)(this.createKeyMaterialUpdateTaskSchedulerId(groupId));
375
345
  this.scheduleKeyMaterialRenewal(groupId);
376
346
  }
377
- /**
378
- * Will cancel the renewal of the key material for a given groupId
379
- * @param groupId The group that should stop having its key material updated
380
- */
381
- cancelKeyMaterialRenewal(groupId) {
382
- return (0, RecurringTaskScheduler_1.cancelRecurringTask)(this.createKeyMaterialUpdateTaskSchedulerId(groupId));
383
- }
384
347
  /**
385
348
  * Will schedule a task to update the key material of the conversation according to the threshold given as config
386
349
  * @param groupId
@@ -397,9 +360,10 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
397
360
  * Get all keying material last update dates and schedule tasks for renewal
398
361
  * Function must only be called once, after application start
399
362
  */
400
- schedulePeriodicKeyMaterialRenewals(groupIds) {
363
+ checkForKeyMaterialsUpdate() {
401
364
  try {
402
- groupIds.forEach(groupId => this.scheduleKeyMaterialRenewal(groupId));
365
+ const keyMaterialUpdateDates = keyMaterialUpdatesStore_1.keyMaterialUpdatesStore.getAllUpdateDates();
366
+ keyMaterialUpdateDates.forEach(({ groupId }) => this.scheduleKeyMaterialRenewal(groupId));
403
367
  }
404
368
  catch (error) {
405
369
  this.logger.error('Could not get last key material update dates', error);
@@ -445,21 +409,11 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
445
409
  return this.apiClient.api.client.uploadMLSKeyPackages(clientId, keypackages.map(keypackage => btoa(bazinga64_1.Converter.arrayBufferViewToBaselineString(keypackage))));
446
410
  }
447
411
  async wipeConversation(groupId) {
448
- const isMLSConversationEstablished = await this.conversationExists(groupId);
449
- if (!isMLSConversationEstablished) {
450
- //if the mls group does not exist, we don't need to wipe it
451
- return;
452
- }
453
- this.cancelKeyMaterialRenewal(groupId);
454
412
  const groupIdBytes = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
455
413
  return this.coreCryptoClient.wipeConversation(groupIdBytes);
456
414
  }
457
415
  async handleEvent(params) {
458
416
  return (0, EventHandler_1.handleBackendEvent)(Object.assign(Object.assign({}, params), { mlsService: this }), async (groupId) => {
459
- const conversationExists = await this.conversationExists(groupId);
460
- if (!conversationExists) {
461
- return;
462
- }
463
417
  const newEpoch = await this.getEpoch(groupId);
464
418
  this.emit('newEpoch', { groupId, epoch: newEpoch });
465
419
  });
@@ -472,9 +426,13 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
472
426
  */
473
427
  async getGroupIdFromConversationId(conversationQualifiedId, subconversationId) {
474
428
  var _a;
429
+ const { id: conversationId, domain: conversationDomain } = conversationQualifiedId;
475
430
  const groupId = subconversationId
476
- ? subconversationGroupIdStore_1.subconversationGroupIdStore.getGroupId(conversationQualifiedId, subconversationId)
431
+ ? (0, subconversationGroupIdMapper_1.getGroupId)(conversationQualifiedId, subconversationId)
477
432
  : await ((_a = this.groupIdFromConversationId) === null || _a === void 0 ? void 0 : _a.call(this, conversationQualifiedId));
433
+ if (!groupId) {
434
+ throw new Error(`Could not find a group_id for conversation ${conversationId}@${conversationDomain}`);
435
+ }
478
436
  return groupId;
479
437
  }
480
438
  /**
@@ -29,8 +29,6 @@ describe('MLSService', () => {
29
29
  const apiClient = new api_client_1.APIClient();
30
30
  const mockCoreCrypto = {
31
31
  createConversation: jest.fn(),
32
- conversationExists: jest.fn(),
33
- wipeConversation: jest.fn(),
34
32
  };
35
33
  describe('registerConversation', () => {
36
34
  let mlsService;
@@ -42,7 +40,6 @@ describe('MLSService', () => {
42
40
  jest.spyOn(apiClient.api.client, 'claimMLSKeyPackages').mockResolvedValue({ key_packages: [] });
43
41
  jest.spyOn(mlsService, 'scheduleKeyMaterialRenewal').mockImplementation();
44
42
  jest.spyOn(mlsService, 'processCommitAction').mockImplementation();
45
- jest.spyOn(mlsService, 'cancelKeyMaterialRenewal').mockImplementation();
46
43
  });
47
44
  it('creates a new mls conversation and avoid adding the selfUser', async () => {
48
45
  const groupId = 'mXOagqRIX/RFd7QyXJA8/Ed8X+hvQgLXIiwYHm3OQFc=';
@@ -59,11 +56,5 @@ describe('MLSService', () => {
59
56
  await mlsService.registerConversation(groupId, [createUserId(), createUserId()]);
60
57
  expect(mlsService.scheduleKeyMaterialRenewal).toHaveBeenCalledWith(groupId);
61
58
  });
62
- it('cancels key material timers after group is wiped', async () => {
63
- const groupId = 'mXOagqRIX/RFd7QyXJA8/Ed8X+hvQgLXIiwYHm4OQFc=';
64
- jest.spyOn(mockCoreCrypto, 'conversationExists').mockResolvedValueOnce(true);
65
- await mlsService.wipeConversation(groupId);
66
- expect(mlsService.cancelKeyMaterialRenewal).toHaveBeenCalledWith(groupId);
67
- });
68
59
  });
69
60
  });
@@ -0,0 +1,2 @@
1
+ export * from './keyMaterialUpdatesStore';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/index.ts"],"names":[],"mappings":"AAmBA,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ /*
3
+ * Wire
4
+ * Copyright (C) 2022 Wire Swiss GmbH
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program. If not, see http://www.gnu.org/licenses/.
18
+ *
19
+ */
20
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ var desc = Object.getOwnPropertyDescriptor(m, k);
23
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
24
+ desc = { enumerable: true, get: function() { return m[k]; } };
25
+ }
26
+ Object.defineProperty(o, k2, desc);
27
+ }) : (function(o, m, k, k2) {
28
+ if (k2 === undefined) k2 = k;
29
+ o[k2] = m[k];
30
+ }));
31
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
32
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
33
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ __exportStar(require("./keyMaterialUpdatesStore"), exports);
@@ -0,0 +1,11 @@
1
+ import { CommonMLS } from '../../../types';
2
+ export type LastKeyMaterialUpdateParams = CommonMLS;
3
+ export interface KeyMaterialUpdatesStore {
4
+ [groupId: string]: LastKeyMaterialUpdateParams;
5
+ }
6
+ export declare const keyMaterialUpdatesStore: {
7
+ getAllUpdateDates: () => LastKeyMaterialUpdateParams[];
8
+ storeLastKeyMaterialUpdateDate: ({ groupId }: LastKeyMaterialUpdateParams) => void;
9
+ deleteLastKeyMaterialUpdateDate: ({ groupId }: CommonMLS) => void;
10
+ };
11
+ //# sourceMappingURL=keyMaterialUpdatesStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyMaterialUpdatesStore.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAEzC,MAAM,MAAM,2BAA2B,GAAG,SAAS,CAAC;AACpD,MAAM,WAAW,uBAAuB;IACtC,CAAC,OAAO,EAAE,MAAM,GAAG,2BAA2B,CAAC;CAChD;AA+BD,eAAO,MAAM,uBAAuB;6BAnBN,2BAA2B,EAAE;kDAKR,2BAA2B;mDAM1B,SAAS;CAY5D,CAAC"}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ /*
3
+ * Wire
4
+ * Copyright (C) 2022 Wire Swiss GmbH
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program. If not, see http://www.gnu.org/licenses/.
18
+ *
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.keyMaterialUpdatesStore = void 0;
22
+ const storageKey = 'keyMaterialUpdates';
23
+ const getUpdateDatesMap = () => {
24
+ const storedState = localStorage.getItem(storageKey);
25
+ if (!storedState) {
26
+ return {};
27
+ }
28
+ return JSON.parse(storedState);
29
+ };
30
+ const getAllUpdateDates = () => {
31
+ const storedStateMap = getUpdateDatesMap();
32
+ return Object.values(storedStateMap);
33
+ };
34
+ const storeLastKeyMaterialUpdateDate = ({ groupId }) => {
35
+ const storedState = getUpdateDatesMap();
36
+ const newStoredState = Object.assign(Object.assign({}, storedState), { [groupId]: { groupId } });
37
+ localStorage.setItem(storageKey, JSON.stringify(newStoredState));
38
+ };
39
+ const deleteLastKeyMaterialUpdateDate = ({ groupId }) => {
40
+ const storedState = getUpdateDatesMap();
41
+ if (storedState[groupId]) {
42
+ delete storedState[groupId];
43
+ }
44
+ localStorage.setItem(storageKey, JSON.stringify(storedState));
45
+ };
46
+ exports.keyMaterialUpdatesStore = {
47
+ getAllUpdateDates,
48
+ storeLastKeyMaterialUpdateDate,
49
+ deleteLastKeyMaterialUpdateDate,
50
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=keyMaterialUpdatesStore.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyMaterialUpdatesStore.test.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/MLSService/stores/keyMaterialUpdatesStore/keyMaterialUpdatesStore.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ /*
3
+ * Wire
4
+ * Copyright (C) 2022 Wire Swiss GmbH
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program. If not, see http://www.gnu.org/licenses/.
18
+ *
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const keyMaterialUpdatesStore_1 = require("./keyMaterialUpdatesStore");
22
+ const mockUpdateEntries = [{ groupId: 'group0' }, { groupId: 'group1' }];
23
+ describe('keyMaterialUpdatesStore', () => {
24
+ it('adds and retrieves items to/from dates store', () => {
25
+ keyMaterialUpdatesStore_1.keyMaterialUpdatesStore.storeLastKeyMaterialUpdateDate(mockUpdateEntries[0]);
26
+ expect(keyMaterialUpdatesStore_1.keyMaterialUpdatesStore.getAllUpdateDates()).toContainEqual(mockUpdateEntries[0]);
27
+ keyMaterialUpdatesStore_1.keyMaterialUpdatesStore.storeLastKeyMaterialUpdateDate(mockUpdateEntries[1]);
28
+ const stored = keyMaterialUpdatesStore_1.keyMaterialUpdatesStore.getAllUpdateDates();
29
+ expect(stored).toContainEqual(mockUpdateEntries[1]);
30
+ expect(stored).toContainEqual(mockUpdateEntries[0]);
31
+ expect(stored).toHaveLength(2);
32
+ });
33
+ it('removes items from dates store', () => {
34
+ keyMaterialUpdatesStore_1.keyMaterialUpdatesStore.storeLastKeyMaterialUpdateDate(mockUpdateEntries[0]);
35
+ expect(keyMaterialUpdatesStore_1.keyMaterialUpdatesStore.getAllUpdateDates()).toContainEqual(mockUpdateEntries[0]);
36
+ keyMaterialUpdatesStore_1.keyMaterialUpdatesStore.deleteLastKeyMaterialUpdateDate({ groupId: mockUpdateEntries[0].groupId });
37
+ expect(keyMaterialUpdatesStore_1.keyMaterialUpdatesStore.getAllUpdateDates()).not.toContainEqual(mockUpdateEntries[0]);
38
+ });
39
+ });
@@ -0,0 +1,4 @@
1
+ import { QualifiedId } from '@wireapp/api-client/lib/user';
2
+ export declare function storeSubconversationGroupId(parentConversation: QualifiedId, subconversation: string, subgroupId: string): void;
3
+ export declare function getGroupId(parentConversation: QualifiedId, subconversation: string): string | undefined;
4
+ //# sourceMappingURL=subconversationGroupIdMapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subconversationGroupIdMapper.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAQzD,wBAAgB,2BAA2B,CACzC,kBAAkB,EAAE,WAAW,EAC/B,eAAe,EAAE,MAAM,EACvB,UAAU,EAAE,MAAM,GACjB,IAAI,CAGN;AAED,wBAAgB,UAAU,CAAC,kBAAkB,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGvG"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ /*
3
+ * Wire
4
+ * Copyright (C) 2023 Wire Swiss GmbH
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program. If not, see http://www.gnu.org/licenses/.
18
+ *
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.getGroupId = exports.storeSubconversationGroupId = void 0;
22
+ const groupIdMap = new Map();
23
+ function generateSubconversationId(parentConversation, subconversation) {
24
+ return `${parentConversation.id}@${parentConversation.domain}:${subconversation}`;
25
+ }
26
+ function storeSubconversationGroupId(parentConversation, subconversation, subgroupId) {
27
+ const subconversationId = generateSubconversationId(parentConversation, subconversation);
28
+ groupIdMap.set(subconversationId, subgroupId);
29
+ }
30
+ exports.storeSubconversationGroupId = storeSubconversationGroupId;
31
+ function getGroupId(parentConversation, subconversation) {
32
+ const subconversationId = generateSubconversationId(parentConversation, subconversation);
33
+ return groupIdMap.get(subconversationId);
34
+ }
35
+ exports.getGroupId = getGroupId;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=subconversationGroupIdMapper.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subconversationGroupIdMapper.test.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/MLSService/subconversationGroupIdMapper.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ /*
3
+ * Wire
4
+ * Copyright (C) 2018 Wire Swiss GmbH
5
+ *
6
+ * This program is free software: you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation, either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program. If not, see http://www.gnu.org/licenses/.
18
+ *
19
+ */
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ const subconversationGroupIdMapper_1 = require("./subconversationGroupIdMapper");
22
+ describe('subconversationGroupIdMapper', () => {
23
+ it('returns empty groupId if conversation is not known', () => {
24
+ const groupId = (0, subconversationGroupIdMapper_1.getGroupId)({ domain: 'example.com', id: '123' }, 'subconversation');
25
+ expect(groupId).toBeUndefined();
26
+ });
27
+ it('returns the stored groupId', () => {
28
+ const conversationId = { domain: 'example.com', id: '123' };
29
+ const subconversation = 'subconversation';
30
+ const groupId = 'groupID';
31
+ (0, subconversationGroupIdMapper_1.storeSubconversationGroupId)(conversationId, subconversation, groupId);
32
+ const result = (0, subconversationGroupIdMapper_1.getGroupId)({ domain: 'example.com', id: '123' }, 'subconversation');
33
+ expect(result).toBe(groupId);
34
+ });
35
+ });