@wireapp/core 30.1.0 → 30.4.0
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,39 @@
|
|
|
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.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)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* 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))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [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)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* 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))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# [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)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* Also create MLS device when logging in with old proteus device ([#4378](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4378)) ([31cea5a](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/31cea5a31ac69ffb269f33458896d091de6c171f))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
6
39
|
# [30.1.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@30.0.5...@wireapp/core@30.1.0) (2022-09-07)
|
|
7
40
|
|
|
8
41
|
|
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
|
|
10
|
+
"@wireapp/api-client": "20.2.0",
|
|
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.
|
|
81
|
-
"gitHead": "
|
|
80
|
+
"version": "30.4.0",
|
|
81
|
+
"gitHead": "9df4ed23ee62258dac598e16e86ef037ee143f6e"
|
|
82
82
|
}
|
package/src/main/Account.js
CHANGED
|
@@ -269,6 +269,9 @@ class Account extends events_1.EventEmitter {
|
|
|
269
269
|
return loadedClient;
|
|
270
270
|
}
|
|
271
271
|
async createMLSClient(client, context, mlsConfig, entropyData) {
|
|
272
|
+
if (!this.service) {
|
|
273
|
+
throw new Error('Services are not set.');
|
|
274
|
+
}
|
|
272
275
|
const coreCryptoKeyId = 'corecrypto-key';
|
|
273
276
|
const { CoreCrypto } = await Promise.resolve().then(() => __importStar(require('@otak/core-crypto')));
|
|
274
277
|
const dbName = this.generateSecretsDbName(context);
|
|
@@ -276,18 +279,27 @@ class Account extends events_1.EventEmitter {
|
|
|
276
279
|
? await (0, encryptedStore_1.createCustomEncryptedStore)(dbName, mlsConfig.secretsCrypto)
|
|
277
280
|
: await (0, encryptedStore_1.createEncryptedStore)(dbName);
|
|
278
281
|
let key = await secretStore.getsecretValue(coreCryptoKeyId);
|
|
282
|
+
let isNewMLSDevice = false;
|
|
279
283
|
if (!key) {
|
|
280
284
|
key = window.crypto.getRandomValues(new Uint8Array(16));
|
|
281
285
|
await secretStore.saveSecretValue(coreCryptoKeyId, key);
|
|
286
|
+
// Keeping track that this device is a new MLS device (but can be an old proteus device)
|
|
287
|
+
isNewMLSDevice = true;
|
|
282
288
|
}
|
|
283
289
|
const { userId, domain } = this.apiClient.context;
|
|
284
|
-
|
|
290
|
+
const mlsClient = await CoreCrypto.init({
|
|
285
291
|
databaseName: `corecrypto-${this.generateDbName(context)}`,
|
|
286
292
|
key: bazinga64_1.Encoder.toBase64(key).asString,
|
|
287
293
|
clientId: `${userId}:${client.id}@${domain}`,
|
|
288
294
|
wasmFilePath: mlsConfig.coreCrypoWasmFilePath,
|
|
289
295
|
entropySeed: entropyData,
|
|
290
296
|
});
|
|
297
|
+
if (isNewMLSDevice) {
|
|
298
|
+
// If the device is new, we need to upload keypackages and public key to the backend
|
|
299
|
+
await this.service.client.uploadMLSPublicKeys(await mlsClient.clientPublicKey(), client.id);
|
|
300
|
+
await this.service.client.uploadMLSKeyPackages(await mlsClient.clientKeypackages(this.nbPrekeys), client.id);
|
|
301
|
+
}
|
|
302
|
+
return mlsClient;
|
|
291
303
|
}
|
|
292
304
|
async registerClient(loginData, clientInfo = coreDefaultClient, entropyData) {
|
|
293
305
|
if (!this.service) {
|
|
@@ -297,8 +309,6 @@ class Account extends events_1.EventEmitter {
|
|
|
297
309
|
const registeredClient = await this.service.client.register(loginData, clientInfo, entropyData);
|
|
298
310
|
if (this.mlsConfig) {
|
|
299
311
|
this.coreCryptoClient = await this.createMLSClient(registeredClient, this.apiClient.context, this.mlsConfig, entropyData);
|
|
300
|
-
await this.service.client.uploadMLSPublicKeys(await this.coreCryptoClient.clientPublicKey(), registeredClient.id);
|
|
301
|
-
await this.service.client.uploadMLSKeyPackages(await this.coreCryptoClient.clientKeypackages(this.nbPrekeys), registeredClient.id);
|
|
302
312
|
}
|
|
303
313
|
this.apiClient.context.clientId = registeredClient.id;
|
|
304
314
|
this.logger.info('Client is created');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
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
|
|
66
|
+
return conversation.members.others
|
|
67
67
|
.filter(member => !!member.qualified_id)
|
|
68
68
|
.map(member => member.qualified_id)
|
|
69
|
-
|
|
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
|
|
527
|
-
const
|
|
528
|
-
const
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
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
|