@wireapp/core 30.2.0 → 30.4.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,36 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [30.4.1](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@30.4.0...@wireapp/core@30.4.1) (2022-09-08)
7
+
8
+ **Note:** Version bump only for package @wireapp/core
9
+
10
+
11
+
12
+
13
+
14
+ # [30.4.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@30.3.0...@wireapp/core@30.4.0) (2022-09-07)
15
+
16
+
17
+ ### Features
18
+
19
+ * Update getAllParticipantsClients to use better endpoints without a hack ([#4379](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4379)) ([f38258d](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/f38258db39e81c4b517126792aa6c605b1ea51c5))
20
+
21
+
22
+
23
+
24
+
25
+ # [30.3.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@30.2.0...@wireapp/core@30.3.0) (2022-09-07)
26
+
27
+
28
+ ### Features
29
+
30
+ * Add ability to send external proposal (FS-689) ([#4376](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4376)) ([bf8e7dd](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/bf8e7ddd7ea4660c8a5b6eea93e27ec14485de6c))
31
+
32
+
33
+
34
+
35
+
6
36
  # [30.2.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@30.1.0...@wireapp/core@30.2.0) (2022-09-07)
7
37
 
8
38
 
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "@otak/core-crypto": "0.3.0-es2017",
8
8
  "@types/long": "4.0.1",
9
9
  "@types/node": "~14",
10
- "@wireapp/api-client": "20.0.4",
10
+ "@wireapp/api-client": "20.2.1",
11
11
  "@wireapp/commons": "4.3.0",
12
12
  "@wireapp/cryptobox": "12.8.0",
13
13
  "@wireapp/store-engine-dexie": "1.6.10",
@@ -77,6 +77,6 @@
77
77
  "test:node": "nyc jasmine --config=jasmine.json",
78
78
  "watch": "tsc ---watch"
79
79
  },
80
- "version": "30.2.0",
81
- "gitHead": "d61be6b02a9009a232f74e73a87963092ccf5a30"
80
+ "version": "30.4.1",
81
+ "gitHead": "4cc5f40299b0b8fb593f169073c5c6740a2939f1"
82
82
  }
@@ -1,4 +1,4 @@
1
- import type { CoreCrypto } from '@otak/core-crypto';
1
+ import { CoreCrypto } from '@otak/core-crypto';
2
2
  import type { APIClient } from '@wireapp/api-client';
3
3
  import { MessageSendingStatus, Conversation, DefaultConversationRoleName, MutedStatus, NewConversation, QualifiedUserClients, UserClients, ClientMismatch } from '@wireapp/api-client/src/conversation';
4
4
  import type { ConversationMemberLeaveEvent } from '@wireapp/api-client/src/event';
@@ -92,10 +92,6 @@ export declare class ConversationService {
92
92
  })>;
93
93
  /**
94
94
  * Get a fresh list from backend of clients for all the participants of the conversation.
95
- * This is a hacky way of getting all the clients for a conversation.
96
- * The idea is to send an empty message to the backend to absolutely no users and let backend reply with a mismatch error.
97
- * We then get the missing members in the mismatch, that is our fresh list of participants' clients.
98
- *
99
95
  * @param {string} conversationId
100
96
  * @param {string} conversationDomain? - If given will send the message to the new qualified endpoint
101
97
  */
@@ -157,4 +153,12 @@ export declare class ConversationService {
157
153
  addUsersToMLSConversation({ qualifiedUserIds, groupId, conversationId, }: Required<AddUsersParams>): Promise<MLSReturnType>;
158
154
  private sendCommitBundleRemovalMessages;
159
155
  removeUsersFromMLSConversation({ groupId, conversationId, qualifiedUserIds, }: RemoveUsersParams): Promise<MLSReturnType>;
156
+ /**
157
+ * Will send an external proposal for the current device to join a specific conversation.
158
+ * In order for the external proposal to be sent correctly, the underlying mls conversation needs to be in a non-established state
159
+ * @param conversationGroupId The conversation to join
160
+ * @param epoch The current epoch of the local conversation
161
+ */
162
+ sendExternalJoinProposal(conversationGroupId: string, epoch: number): Promise<void>;
163
+ isMLSConversationEstablished(conversationGroupId: string): Promise<boolean>;
160
164
  }
@@ -63,11 +63,10 @@ class ConversationService {
63
63
  * yourself in the list of users if you want to sync a message also to your
64
64
  * other clients.
65
65
  */
66
- return (conversation.members.others
66
+ return conversation.members.others
67
67
  .filter(member => !!member.qualified_id)
68
68
  .map(member => member.qualified_id)
69
- // TODO(Federation): Use 'domain' from 'conversation.members.self' when backend has it implemented
70
- .concat({ domain: this.apiClient.context.domain, id: conversation.members.self.id }));
69
+ .concat(conversation.members.self.qualified_id);
71
70
  }
72
71
  /**
73
72
  * Will generate a prekey bundle for specific users.
@@ -515,37 +514,18 @@ class ConversationService {
515
514
  }
516
515
  /**
517
516
  * Get a fresh list from backend of clients for all the participants of the conversation.
518
- * This is a hacky way of getting all the clients for a conversation.
519
- * The idea is to send an empty message to the backend to absolutely no users and let backend reply with a mismatch error.
520
- * We then get the missing members in the mismatch, that is our fresh list of participants' clients.
521
- *
522
517
  * @param {string} conversationId
523
518
  * @param {string} conversationDomain? - If given will send the message to the new qualified endpoint
524
519
  */
525
- getAllParticipantsClients(conversationId, conversationDomain) {
526
- const sendingClientId = this.apiClient.validatedClientId;
527
- const recipients = {};
528
- const text = new Uint8Array();
529
- return new Promise(async (resolve) => {
530
- const onClientMismatch = (mismatch) => {
531
- resolve(mismatch.missing);
532
- // When the mismatch happens, we ask the messageService to cancel the sending
533
- return false;
534
- };
535
- if (conversationDomain && this.config.useQualifiedIds) {
536
- await this.messageService.sendFederatedMessage(sendingClientId, recipients, text, {
537
- conversationId: { id: conversationId, domain: conversationDomain },
538
- onClientMismatch,
539
- reportMissing: true,
540
- });
541
- }
542
- else {
543
- await this.messageService.sendMessage(sendingClientId, recipients, text, {
544
- conversationId,
545
- onClientMismatch,
546
- });
547
- }
548
- });
520
+ async getAllParticipantsClients(conversationId, conversationDomain) {
521
+ const qualifiedMembers = await this.getConversationQualifiedMembers(conversationDomain ? { id: conversationId, domain: conversationDomain } : conversationId);
522
+ const allClients = await this.apiClient.api.user.postListClients({ qualified_users: qualifiedMembers });
523
+ const qualifiedUserClients = {};
524
+ Object.entries(allClients.qualified_user_map).map(([domain, userClientMap]) => Object.entries(userClientMap).map(async ([userId, clients]) => {
525
+ qualifiedUserClients[domain] || (qualifiedUserClients[domain] = {});
526
+ qualifiedUserClients[domain][userId] = clients.map(client => client.id);
527
+ }));
528
+ return qualifiedUserClients;
549
529
  }
550
530
  async deleteMessageLocal(conversationId, messageIdToHide, sendAsProtobuf, conversationDomain) {
551
531
  const messageId = MessageBuilder_1.MessageBuilder.createId();
@@ -944,6 +924,28 @@ class ConversationService {
944
924
  conversation,
945
925
  };
946
926
  }
927
+ /**
928
+ * Will send an external proposal for the current device to join a specific conversation.
929
+ * In order for the external proposal to be sent correctly, the underlying mls conversation needs to be in a non-established state
930
+ * @param conversationGroupId The conversation to join
931
+ * @param epoch The current epoch of the local conversation
932
+ */
933
+ async sendExternalJoinProposal(conversationGroupId, epoch) {
934
+ const coreCryptoClient = this.coreCryptoClientProvider();
935
+ const groupIdDecodedFromBase64 = bazinga64_1.Decoder.fromBase64(conversationGroupId).asBytes;
936
+ const externalProposal = await coreCryptoClient.newExternalProposal(0 /* Add */, {
937
+ epoch,
938
+ conversationId: groupIdDecodedFromBase64,
939
+ });
940
+ await this.apiClient.api.conversation.postMlsMessage(
941
+ //@todo: it's temporary - we wait for core-crypto fix to return the actual Uint8Array instead of regular array
942
+ optionalToUint8Array(externalProposal));
943
+ }
944
+ async isMLSConversationEstablished(conversationGroupId) {
945
+ const coreCryptoClient = this.coreCryptoClientProvider();
946
+ const groupIdDecodedFromBase64 = bazinga64_1.Decoder.fromBase64(conversationGroupId).asBytes;
947
+ return coreCryptoClient.conversationExists(groupIdDecodedFromBase64);
948
+ }
947
949
  }
948
950
  exports.ConversationService = ConversationService;
949
951
  //# sourceMappingURL=ConversationService.js.map