@wireapp/core 46.37.1 → 46.38.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/lib/conversation/AssetService/AssetService.d.ts +28 -10
- package/lib/conversation/AssetService/AssetService.d.ts.map +1 -1
- package/lib/conversation/AssetService/AssetService.js +11 -1
- package/lib/conversation/ConversationService/ConversationService.d.ts +19 -3
- package/lib/conversation/ConversationService/ConversationService.d.ts.map +1 -1
- package/lib/conversation/ConversationService/ConversationService.js +158 -43
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.d.ts +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts +6 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.js +61 -21
- package/lib/messagingProtocols/proteus/ProteusService/DecryptionErrorGenerator/DecryptionErrorGenerator.d.ts +1 -6
- package/lib/messagingProtocols/proteus/ProteusService/DecryptionErrorGenerator/DecryptionErrorGenerator.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/DecryptionErrorGenerator/DecryptionErrorGenerator.js +19 -22
- package/package.json +4 -4
|
@@ -2,13 +2,33 @@ import { AssetOptions, AssetResponse } from '@wireapp/api-client/lib/asset';
|
|
|
2
2
|
import { ProgressCallback, RequestCancelable } from '@wireapp/api-client/lib/http';
|
|
3
3
|
import { APIClient } from '@wireapp/api-client';
|
|
4
4
|
import { EncryptedAsset, EncryptedAssetUploaded } from '../../cryptography';
|
|
5
|
-
|
|
6
|
-
export type AssetUrlData = {
|
|
5
|
+
interface AssetDataV4 {
|
|
7
6
|
assetKey: string;
|
|
8
7
|
assetToken: string;
|
|
9
8
|
assetDomain: string;
|
|
10
9
|
forceCaching: boolean;
|
|
11
|
-
|
|
10
|
+
version: 4;
|
|
11
|
+
}
|
|
12
|
+
interface AssetDataV3 {
|
|
13
|
+
assetKey: string;
|
|
14
|
+
assetToken: string;
|
|
15
|
+
forceCaching: boolean;
|
|
16
|
+
version: 3;
|
|
17
|
+
}
|
|
18
|
+
interface AssetDataV2 {
|
|
19
|
+
assetId: string;
|
|
20
|
+
conversationId: string;
|
|
21
|
+
forceCaching: boolean;
|
|
22
|
+
version: 2;
|
|
23
|
+
}
|
|
24
|
+
interface AssetDataV1 {
|
|
25
|
+
assetId: string;
|
|
26
|
+
conversationId: string;
|
|
27
|
+
forceCaching: boolean;
|
|
28
|
+
version: 1;
|
|
29
|
+
}
|
|
30
|
+
export { ProgressCallback };
|
|
31
|
+
export type AssetUrlData = AssetDataV1 | AssetDataV2 | AssetDataV3 | AssetDataV4;
|
|
12
32
|
export declare class AssetService {
|
|
13
33
|
private readonly apiClient;
|
|
14
34
|
constructor(apiClient: APIClient);
|
|
@@ -20,7 +40,10 @@ export declare class AssetService {
|
|
|
20
40
|
* @param progressCallback?
|
|
21
41
|
* @return Resolves when the asset has been uploaded
|
|
22
42
|
*/
|
|
23
|
-
downloadRawAsset(assetData: AssetUrlData, progressCallback?: ProgressCallback):
|
|
43
|
+
downloadRawAsset(assetData: AssetUrlData, progressCallback?: ProgressCallback): {
|
|
44
|
+
cancel: () => void;
|
|
45
|
+
response: Promise<AssetResponse>;
|
|
46
|
+
};
|
|
24
47
|
/**
|
|
25
48
|
* Uploads a raw asset to the backend without encrypting it
|
|
26
49
|
*
|
|
@@ -29,12 +52,7 @@ export declare class AssetService {
|
|
|
29
52
|
* @param progressCallback?
|
|
30
53
|
* @return cancellable request that resolves with the uploaded image
|
|
31
54
|
*/
|
|
32
|
-
uploadRawAsset(asset: Buffer | Uint8Array, options?: AssetOptions, progressCallback?: ProgressCallback): RequestCancelable<
|
|
33
|
-
key: string;
|
|
34
|
-
token: string;
|
|
35
|
-
expires: string;
|
|
36
|
-
domain?: string | undefined;
|
|
37
|
-
}>;
|
|
55
|
+
uploadRawAsset(asset: Buffer | Uint8Array, options?: AssetOptions, progressCallback?: ProgressCallback): RequestCancelable<import("@wireapp/api-client/lib/asset").AssetUploadData>;
|
|
38
56
|
/**
|
|
39
57
|
* Will encrypt and upload an asset to the backend
|
|
40
58
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssetService.d.ts","sourceRoot":"","sources":["../../../src/conversation/AssetService/AssetService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAC,gBAAgB,EAAE,iBAAiB,EAAC,MAAM,8BAA8B,CAAC;AAEjF,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAC,cAAc,EAAE,sBAAsB,EAAC,MAAM,oBAAoB,CAAC;AAG1E,
|
|
1
|
+
{"version":3,"file":"AssetService.d.ts","sourceRoot":"","sources":["../../../src/conversation/AssetService/AssetService.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,YAAY,EAAE,aAAa,EAAC,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAC,gBAAgB,EAAE,iBAAiB,EAAC,MAAM,8BAA8B,CAAC;AAEjF,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAE9C,OAAO,EAAC,cAAc,EAAE,sBAAsB,EAAC,MAAM,oBAAoB,CAAC;AAG1E,UAAU,WAAW;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,CAAC,CAAC;CACZ;AACD,UAAU,WAAW;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,CAAC,CAAC;CACZ;AAED,UAAU,WAAW;IACnB,OAAO,EAAE,MAAM,CAAC;IACh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loadRawAsset(assetData, progressCallback) {
|
|
37
|
-
|
|
37
|
+
const { forceCaching } = assetData;
|
|
38
|
+
switch (assetData.version) {
|
|
39
|
+
case 1:
|
|
40
|
+
return this.apiClient.api.asset.getAssetV1(assetData.assetId, assetData.conversationId, forceCaching, progressCallback);
|
|
41
|
+
case 2:
|
|
42
|
+
return this.apiClient.api.asset.getAssetV2(assetData.assetId, assetData.conversationId, forceCaching, progressCallback);
|
|
43
|
+
case 3:
|
|
44
|
+
return this.apiClient.api.asset.getAssetV3(assetData.assetKey, assetData.assetToken, forceCaching, progressCallback);
|
|
45
|
+
case 4:
|
|
46
|
+
return this.apiClient.api.asset.getAssetV4(assetData.assetKey, assetData.assetDomain, assetData.assetToken, forceCaching, progressCallback);
|
|
47
|
+
}
|
|
38
48
|
}
|
|
39
49
|
/**
|
|
40
50
|
* Uploads a raw asset to the backend without encrypting it
|
|
@@ -91,6 +91,17 @@ export declare class ConversationService extends TypedEventEmitter<Events> {
|
|
|
91
91
|
* @param conversationData
|
|
92
92
|
*/
|
|
93
93
|
createMLSConversation(conversationData: NewConversation, selfUserId: QualifiedId, selfClientId: string): Promise<BaseCreateConversationResponse>;
|
|
94
|
+
/**
|
|
95
|
+
* Centralized handler for scenarios where an MLS conversation is detected as broken.
|
|
96
|
+
* It resets the conversation and then invokes the provided callback so callers can retry
|
|
97
|
+
* their original operation (e.g., re-adding/removing users, re-joining, etc.) with the new group id.
|
|
98
|
+
*
|
|
99
|
+
* Contract:
|
|
100
|
+
* - input: conversationId to reset; callback invoked after reset with the new group id
|
|
101
|
+
* - output: the value returned by the callback
|
|
102
|
+
* - error: throws if reset fails or new group id is missing
|
|
103
|
+
*/
|
|
104
|
+
private handleBrokenMLSConversation;
|
|
94
105
|
/**
|
|
95
106
|
* Will create a conversation on backend and register it to CoreCrypto once created
|
|
96
107
|
* @param conversationData
|
|
@@ -104,9 +115,14 @@ export declare class ConversationService extends TypedEventEmitter<Events> {
|
|
|
104
115
|
* @param groupId Id of the group to which we want to add users
|
|
105
116
|
* @param conversationId Id of the conversation to which we want to add users
|
|
106
117
|
*/
|
|
107
|
-
addUsersToMLSConversation({ qualifiedUsers, groupId, conversationId, }: Required<AddUsersParams>
|
|
108
|
-
|
|
109
|
-
|
|
118
|
+
addUsersToMLSConversation({ qualifiedUsers, groupId, conversationId, shouldRetry, }: Required<AddUsersParams> & {
|
|
119
|
+
shouldRetry?: boolean;
|
|
120
|
+
}): Promise<BaseCreateConversationResponse>;
|
|
121
|
+
removeUsersFromMLSConversation({ groupId, conversationId, qualifiedUserIds, shouldRetry, }: RemoveUsersParams & {
|
|
122
|
+
shouldRetry?: boolean;
|
|
123
|
+
}): Promise<Conversation>;
|
|
124
|
+
joinByExternalCommit(conversationId: QualifiedId, shouldRetry?: boolean): Promise<void>;
|
|
125
|
+
private resetMLSConversation;
|
|
110
126
|
/**
|
|
111
127
|
* Will check if mls group exists locally.
|
|
112
128
|
* @param groupId groupId of the conversation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConversationService.d.ts","sourceRoot":"","sources":["../../../src/conversation/ConversationService/ConversationService.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,YAAY,EACZ,2BAA2B,EAC3B,WAAW,EACX,eAAe,EACf,oBAAoB,EAEpB,mBAAmB,EAEnB,eAAe,EACf,kBAAkB,EAGnB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACL,YAAY,EAIZ,4BAA4B,EAE7B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAC,GAAG,EAAC,MAAM,oCAAoC,CAAC;AAGvD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAa,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAI/D,OAAO,EACL,cAAc,EACd,8BAA8B,EAE9B,oBAAoB,EACpB,UAAU,EACX,MAAM,6BAA6B,CAAC;AAErC,OAAO,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B,GAAE,MAAM,GAAG,IAAiB,GAC3C,OAAO,CAAC,IAAI,CAAC;IAaT,yBAAyB,CAC9B,cAAc,EAAE,WAAW,EAC3B,MAAM,EAAE,WAAW,EACnB,gBAAgB,EAAE,2BAA2B,GAAG,MAAM,GACrD,OAAO,CAAC,IAAI,CAAC;IAMhB;;;;OAIG;IAEH;;;OAGG;IACU,qBAAqB,CAChC,gBAAgB,EAAE,eAAe,EACjC,UAAU,EAAE,WAAW,EACvB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,8BAA8B,CAAC;IAuB1C;;;OAGG;IACU,6BAA6B,CACxC,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,WAAW,EAAE,EAC3B,UAAU,EAAE,WAAW,EACvB,YAAY,EAAE,MAAM,EACpB,uBAAuB,EAAE,WAAW,GACnC,OAAO,CAAC,8BAA8B,CAAC;YAiB5B,cAAc;
|
|
1
|
+
{"version":3,"file":"ConversationService.d.ts","sourceRoot":"","sources":["../../../src/conversation/ConversationService/ConversationService.ts"],"names":[],"mappings":"AAmBA,OAAO,EACL,YAAY,EACZ,2BAA2B,EAC3B,WAAW,EACX,eAAe,EACf,oBAAoB,EAEpB,mBAAmB,EAEnB,eAAe,EACf,kBAAkB,EAGnB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACL,YAAY,EAIZ,4BAA4B,EAE7B,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAC,GAAG,EAAC,MAAM,oCAAoC,CAAC;AAGvD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAa,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AAI/D,OAAO,EACL,cAAc,EACd,8BAA8B,EAE9B,oBAAoB,EACpB,UAAU,EACX,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAC,YAAY,EAAuB,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACzF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W,kCAAkC;IA2BhD;;;OAGG;YACW,+BAA+B;IAqB7C;;;;;;;OAOG;YACW,gBAAgB;IAQ9B;;;OAGG;IACG,sBAAsB,CAAC,MAAM,EAAE,WAAW;IAShD;;;;;;;OAOG;IACH,SAAgB,4BAA4B,YACjC,MAAM,YACL;QAAC,IAAI,EAAE,WAAW,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,eAChC,WAAW,4BAEvB,OAAO,CAAC,eAAe,CAAC,CAwDzB;IAEF;;;;;;;;OAQG;IACU,uBAAuB,CAAC,EACnC,OAAO,EACP,cAAc,EACd,UAAU,EACV,cAAc,GACf,EAAE;QACD,OAAO,EAAE,MAAM,CAAC;QAChB,cAAc,EAAE,WAAW,CAAC;QAC5B,UAAU,EAAE,WAAW,CAAC;QACxB,cAAc,EAAE,WAAW,EAAE,CAAC;KAC/B,GAAG,OAAO,CAAC,IAAI,CAAC;YAkCH,wBAAwB;YAsBxB,gCAAgC;YAyBhC,4BAA4B;YA4B5B,wBAAwB;YAIxB,yBAAyB;IAKvC;;;;OAIG;IACU,WAAW,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAoB3E"}
|
|
@@ -206,6 +206,18 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
206
206
|
}
|
|
207
207
|
return this.establishMLSGroupConversation(groupId, qualifiedUsers, selfUserId, selfClientId, qualifiedId);
|
|
208
208
|
}
|
|
209
|
+
async handleBrokenMLSConversation(conversationId, afterReset) {
|
|
210
|
+
const { conversation: { group_id: newGroupId }, } = await this.resetMLSConversation(conversationId);
|
|
211
|
+
if (!newGroupId) {
|
|
212
|
+
const errorMessage = 'Tried to reset MLS conversation but no group_id found in response';
|
|
213
|
+
this.logger.error(errorMessage, { conversationId });
|
|
214
|
+
throw new Error(errorMessage);
|
|
215
|
+
}
|
|
216
|
+
if (afterReset) {
|
|
217
|
+
return afterReset(newGroupId);
|
|
218
|
+
}
|
|
219
|
+
return undefined;
|
|
220
|
+
}
|
|
209
221
|
/**
|
|
210
222
|
* Will create a conversation on backend and register it to CoreCrypto once created
|
|
211
223
|
* @param conversationData
|
|
@@ -228,7 +240,15 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
228
240
|
const { payload, groupId, conversationId } = params;
|
|
229
241
|
const groupIdBytes = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
|
|
230
242
|
// immediately execute pending commits before sending the message
|
|
231
|
-
await this.mlsService.commitPendingProposals(groupId)
|
|
243
|
+
await this.mlsService.commitPendingProposals(groupId, true, params).catch(async (error) => {
|
|
244
|
+
if (mls_1.MLSService.isBrokenMLSConversationError(error)) {
|
|
245
|
+
this.logger.info('Failed to execute pending proposals because broken MLS conversation, triggering a reset', {
|
|
246
|
+
error,
|
|
247
|
+
groupId,
|
|
248
|
+
});
|
|
249
|
+
await this.handleBrokenMLSConversation(conversationId);
|
|
250
|
+
}
|
|
251
|
+
});
|
|
232
252
|
const encrypted = await this.mlsService.encryptMessage(new core_crypto_1.ConversationId(groupIdBytes), protocol_messaging_1.GenericMessage.encode(payload).finish());
|
|
233
253
|
let response = null;
|
|
234
254
|
let sentAt = '';
|
|
@@ -266,31 +286,120 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
266
286
|
* @param groupId Id of the group to which we want to add users
|
|
267
287
|
* @param conversationId Id of the conversation to which we want to add users
|
|
268
288
|
*/
|
|
269
|
-
async addUsersToMLSConversation({ qualifiedUsers, groupId, conversationId, }) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
289
|
+
async addUsersToMLSConversation({ qualifiedUsers, groupId, conversationId, shouldRetry = true, }) {
|
|
290
|
+
try {
|
|
291
|
+
const exisitingClientIdsInGroup = await this.mlsService.getClientIdsInGroup(groupId);
|
|
292
|
+
const conversation = await this.getConversation(conversationId);
|
|
293
|
+
const { keyPackages, failures: keysClaimingFailures } = await this.mlsService.getKeyPackagesPayload(qualifiedUsers, exisitingClientIdsInGroup);
|
|
294
|
+
// We had cases where did not get any key packages, but still used core-crypto to call the backend (which results in failure).
|
|
295
|
+
if (keyPackages && keyPackages.length > 0) {
|
|
296
|
+
await this.mlsService.addUsersToExistingConversation(groupId, keyPackages);
|
|
297
|
+
//We store the info when user was added (and key material was created), so we will know when to renew it
|
|
298
|
+
await this.mlsService.resetKeyMaterialRenewal(groupId);
|
|
299
|
+
}
|
|
300
|
+
return {
|
|
301
|
+
conversation,
|
|
302
|
+
failedToAdd: keysClaimingFailures,
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
catch (error) {
|
|
306
|
+
if (mls_1.MLSService.isBrokenMLSConversationError(error)) {
|
|
307
|
+
if (!shouldRetry) {
|
|
308
|
+
this.logger.warn("Tried to add users to MLS conversation but it's still broken after reset", error);
|
|
309
|
+
throw error;
|
|
310
|
+
}
|
|
311
|
+
this.logger.warn("Tried to add users to MLS conversation but it's broken, resetting the conversation", error);
|
|
312
|
+
return this.handleBrokenMLSConversation(conversationId, newGroupId => this.addUsersToMLSConversation({ qualifiedUsers, groupId: newGroupId, conversationId, shouldRetry: false }));
|
|
313
|
+
}
|
|
314
|
+
throw error;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
async removeUsersFromMLSConversation({ groupId, conversationId, qualifiedUserIds, shouldRetry = true, }) {
|
|
318
|
+
try {
|
|
319
|
+
const clientsToRemove = await this.apiClient.api.user.postListClients({ qualified_users: qualifiedUserIds });
|
|
320
|
+
const fullyQualifiedClientIds = (0, fullyQualifiedClientIdUtils_1.mapQualifiedUserClientIdsToFullyQualifiedClientIds)(clientsToRemove.qualified_user_map);
|
|
321
|
+
await this.mlsService.removeClientsFromConversation(groupId, fullyQualifiedClientIds);
|
|
322
|
+
// key material gets updated after removing a user from the group, so we can reset last key update time value in the store
|
|
277
323
|
await this.mlsService.resetKeyMaterialRenewal(groupId);
|
|
324
|
+
return await this.getConversation(conversationId);
|
|
325
|
+
}
|
|
326
|
+
catch (error) {
|
|
327
|
+
if (mls_1.MLSService.isBrokenMLSConversationError(error)) {
|
|
328
|
+
if (!shouldRetry) {
|
|
329
|
+
this.logger.warn("Tried to remove users from MLS conversation but it's still broken after reset", error);
|
|
330
|
+
throw error;
|
|
331
|
+
}
|
|
332
|
+
this.logger.info("Tried to remove users from MLS conversation but it's broken, resetting the conversation", error);
|
|
333
|
+
return this.handleBrokenMLSConversation(conversationId, newGroupId => this.removeUsersFromMLSConversation({
|
|
334
|
+
groupId: newGroupId,
|
|
335
|
+
conversationId,
|
|
336
|
+
qualifiedUserIds,
|
|
337
|
+
shouldRetry: false,
|
|
338
|
+
}));
|
|
339
|
+
}
|
|
340
|
+
throw error;
|
|
278
341
|
}
|
|
279
|
-
return {
|
|
280
|
-
conversation,
|
|
281
|
-
failedToAdd: keysClaimingFailures,
|
|
282
|
-
};
|
|
283
342
|
}
|
|
284
|
-
async
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
343
|
+
async joinByExternalCommit(conversationId, shouldRetry = true) {
|
|
344
|
+
try {
|
|
345
|
+
await this.mlsService.joinByExternalCommit(() => this.apiClient.api.conversation.getGroupInfo(conversationId));
|
|
346
|
+
}
|
|
347
|
+
catch (error) {
|
|
348
|
+
if (mls_1.MLSService.isBrokenMLSConversationError(error)) {
|
|
349
|
+
this.logger.info("Failed to join MLS conversation via external commit because it's broken, resetting the conversation", error);
|
|
350
|
+
if (!shouldRetry) {
|
|
351
|
+
this.logger.warn("Tried to join MLS conversation but it's still broken after reset", error);
|
|
352
|
+
throw error;
|
|
353
|
+
}
|
|
354
|
+
return this.handleBrokenMLSConversation(conversationId);
|
|
355
|
+
}
|
|
356
|
+
throw error;
|
|
357
|
+
}
|
|
291
358
|
}
|
|
292
|
-
async
|
|
293
|
-
|
|
359
|
+
async resetMLSConversation(conversationId) {
|
|
360
|
+
this.logger.info(`Resetting MLS conversation with id ${conversationId.id}`);
|
|
361
|
+
// STEP 1: Fetch the conversation to retrieve the group ID & epoch
|
|
362
|
+
const conversation = await this.apiClient.api.conversation.getConversation(conversationId);
|
|
363
|
+
const { group_id: groupId, epoch } = conversation;
|
|
364
|
+
if (!groupId || !epoch) {
|
|
365
|
+
const errorMessage = 'Could not find group id or epoch for the conversation';
|
|
366
|
+
this.logger.error(errorMessage, { conversationId });
|
|
367
|
+
throw new Error(errorMessage);
|
|
368
|
+
}
|
|
369
|
+
// STEP 2: Request backend to reset the conversation
|
|
370
|
+
this.logger.info(`Requesting backend to reset the conversation (group_id: ${groupId}, epoch: ${String(epoch)})`);
|
|
371
|
+
await this.apiClient.api.conversation.resetMLSConversation({
|
|
372
|
+
epoch,
|
|
373
|
+
groupId,
|
|
374
|
+
});
|
|
375
|
+
// STEP 3: fetch self user info
|
|
376
|
+
this.logger.info(`Re-establishing the conversation by re-adding all members (conversation_id: ${conversationId.id})`);
|
|
377
|
+
const { validatedClientId: clientId, userId, domain } = this.apiClient;
|
|
378
|
+
if (!userId || !domain) {
|
|
379
|
+
const errorMessage = 'Could not find userId or domain of the self user';
|
|
380
|
+
this.logger.error(errorMessage, { conversationId });
|
|
381
|
+
throw new Error(errorMessage);
|
|
382
|
+
}
|
|
383
|
+
const selfUserQualifiedId = { id: userId, domain };
|
|
384
|
+
// STEP 4: Fetch the updated conversation data from backend to retrieve the new group ID
|
|
385
|
+
const updatedConversation = await this.apiClient.api.conversation.getConversation(conversationId);
|
|
386
|
+
const { group_id: newGroupId, members } = updatedConversation;
|
|
387
|
+
this.logger.info(`MLS conversation new group ID fetched from backend ${conversationId.id}`, {
|
|
388
|
+
newGroupId,
|
|
389
|
+
});
|
|
390
|
+
if (!newGroupId || !clientId) {
|
|
391
|
+
throw new Error(`Failed to recover MLS conversation: missing groupId (${newGroupId}), or clientId (${clientId})`);
|
|
392
|
+
}
|
|
393
|
+
const usersToReAdd = members.others.map(member => member.qualified_id).filter(userId => !!userId);
|
|
394
|
+
// STEP 5: Re-establish the conversation by re-adding all members
|
|
395
|
+
return await this.establishMLSGroupConversation(newGroupId, usersToReAdd, selfUserQualifiedId, clientId, conversationId).then(result => {
|
|
396
|
+
this.logger.info(`Successfully reset MLS conversation`, {
|
|
397
|
+
conversationId: conversationId.id,
|
|
398
|
+
oldGroupId: groupId,
|
|
399
|
+
newGroupId,
|
|
400
|
+
});
|
|
401
|
+
return result;
|
|
402
|
+
});
|
|
294
403
|
}
|
|
295
404
|
/**
|
|
296
405
|
* Will check if mls group exists locally.
|
|
@@ -448,27 +557,33 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
448
557
|
* @param qualifiedUsers - list of qualified users to add to the group (should not include the self user)
|
|
449
558
|
*/
|
|
450
559
|
async tryEstablishingMLSGroup({ groupId, conversationId, selfUserId, qualifiedUsers, }) {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
560
|
+
try {
|
|
561
|
+
const wasGroupEstablishedBySelfClient = await this.mlsService.tryEstablishingMLSGroup(groupId);
|
|
562
|
+
if (!wasGroupEstablishedBySelfClient) {
|
|
563
|
+
this.logger.debug('Group was not established by self client, skipping adding users to the group.');
|
|
564
|
+
return;
|
|
565
|
+
}
|
|
566
|
+
this.logger.debug('Group was established by self client, adding other users to the group...');
|
|
567
|
+
const usersToAdd = [
|
|
568
|
+
...qualifiedUsers,
|
|
569
|
+
{ ...selfUserId, skipOwnClientId: this.apiClient.validatedClientId },
|
|
570
|
+
];
|
|
571
|
+
const { conversation } = await this.addUsersToMLSConversation({
|
|
572
|
+
conversationId,
|
|
573
|
+
groupId,
|
|
574
|
+
qualifiedUsers: usersToAdd,
|
|
575
|
+
});
|
|
576
|
+
const addedUsers = conversation.members.others;
|
|
577
|
+
if (addedUsers.length > 0) {
|
|
578
|
+
this.logger.debug(`Successfully added ${addedUsers} users to the group.`);
|
|
579
|
+
}
|
|
580
|
+
else {
|
|
581
|
+
this.logger.debug('No other users were added to the group.');
|
|
582
|
+
}
|
|
469
583
|
}
|
|
470
|
-
|
|
471
|
-
this.logger.
|
|
584
|
+
catch (error) {
|
|
585
|
+
this.logger.error('Failed to establish MLS group', error);
|
|
586
|
+
throw error;
|
|
472
587
|
}
|
|
473
588
|
}
|
|
474
589
|
async handleMLSMessageAddEvent(event) {
|
|
@@ -482,7 +597,7 @@ class ConversationService extends commons_1.TypedEventEmitter {
|
|
|
482
597
|
if (!conversationId) {
|
|
483
598
|
throw new Error('Qualified conversation id is missing in the event');
|
|
484
599
|
}
|
|
485
|
-
(0, conversationRejoinQueue_1.queueConversationRejoin)(conversationId.id, () => this.recoverMLSGroupFromEpochMismatch(conversationId, subconv));
|
|
600
|
+
void (0, conversationRejoinQueue_1.queueConversationRejoin)(conversationId.id, () => this.recoverMLSGroupFromEpochMismatch(conversationId, subconv));
|
|
486
601
|
return null;
|
|
487
602
|
}
|
|
488
603
|
throw error;
|
|
@@ -6,7 +6,7 @@ import { CoreDatabase } from '../../../storage/CoreDB';
|
|
|
6
6
|
import { StringifiedQualifiedId } from '../../../util/qualifiedIdUtil';
|
|
7
7
|
import { RecurringTaskScheduler } from '../../../util/RecurringTaskScheduler';
|
|
8
8
|
import { MLSService } from '../MLSService';
|
|
9
|
-
export type DeviceIdentity = Omit<WireIdentity, 'free' | 'status'> & {
|
|
9
|
+
export type DeviceIdentity = Omit<WireIdentity, 'free' | 'status' | typeof Symbol.dispose> & {
|
|
10
10
|
status?: DeviceStatus;
|
|
11
11
|
deviceId: string;
|
|
12
12
|
qualifiedUserId: QualifiedId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"E2EIServiceExternal.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAIzD,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AACnD,OAAO,EACL,UAAU,EACV,qBAAqB,EACrB,YAAY,EACZ,YAAY,EAIb,MAAM,sBAAsB,CAAC;AAM9B,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;AAGrD,OAAO,EAAC,sBAAsB,EAAuB,MAAM,+BAA+B,CAAC;AAC3F,OAAO,EAAC,sBAAsB,EAAC,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAC,UAAU,EAAmB,MAAM,eAAe,CAAC;AAE3D,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ,CAAC,GAAG;
|
|
1
|
+
{"version":3,"file":"E2EIServiceExternal.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAIzD,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AACnD,OAAO,EACL,UAAU,EACV,qBAAqB,EACrB,YAAY,EACZ,YAAY,EAIb,MAAM,sBAAsB,CAAC;AAM9B,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;AAGrD,OAAO,EAAC,sBAAsB,EAAuB,MAAM,+BAA+B,CAAC;AAC3F,OAAO,EAAC,sBAAsB,EAAC,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAC,UAAU,EAAmB,MAAM,eAAe,CAAC;AAE3D,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ,GAAG,OA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M,EAAE,WAAW,CAAC,GAC1C,OAAO,CAAC,cAAc,EAAE,CAAC;IAiBf,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC;YAKvC,4BAA4B;IAO1C;;;;;OAKG;IACU,UAAU,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAW5D,OAAO,KAAK,WAAW,GAKtB;YAEa,+BAA+B;IAO7C;;;;;;;;;;;;OAYG;YACW,0BAA0B;IA2BxC,OAAO,CAAC,4BAA4B;YAStB,+BAA+B;YAQ/B,uBAAuB;YAKvB,0BAA0B;YAI1B,4BAA4B;YAO5B,WAAW;YAoBX,8BAA8B;CAM7C"}
|
|
@@ -57,6 +57,11 @@ export declare class MLSService extends TypedEventEmitter<Events> {
|
|
|
57
57
|
private _config?;
|
|
58
58
|
private readonly textEncoder;
|
|
59
59
|
private readonly textDecoder;
|
|
60
|
+
static UPLOAD_COMMIT_BUNDLE_ABORT_REASONS: {
|
|
61
|
+
BROKEN_MLS_CONVERSATION: string;
|
|
62
|
+
OTHER: string;
|
|
63
|
+
};
|
|
64
|
+
static isBrokenMLSConversationError(error: unknown): boolean;
|
|
60
65
|
constructor(apiClient: APIClient, coreCryptoClient: CoreCrypto, coreDatabase: CoreDatabase, recurringTaskScheduler: RecurringTaskScheduler);
|
|
61
66
|
/**
|
|
62
67
|
* return true if the MLS service if configured and ready to be used
|
|
@@ -230,7 +235,7 @@ export declare class MLSService extends TypedEventEmitter<Events> {
|
|
|
230
235
|
*
|
|
231
236
|
* @param groupId groupId of the conversation
|
|
232
237
|
*/
|
|
233
|
-
commitPendingProposals(groupId: string, shouldRetry?: boolean): Promise<void>;
|
|
238
|
+
commitPendingProposals(groupId: string, shouldRetry?: boolean, params?: any): Promise<void>;
|
|
234
239
|
/**
|
|
235
240
|
* Get all pending proposals from the database and schedule them
|
|
236
241
|
* Function must only be called once, after application start
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MLSService.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/MLSService/MLSService.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAqB,kBAAkB,EAAE,gBAAgB,EAAC,MAAM,gCAAgC,CAAC;AAC7G,OAAO,
|
|
1
|
+
{"version":3,"file":"MLSService.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/MLSService/MLSService.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAqB,kBAAkB,EAAE,gBAAgB,EAAC,MAAM,gCAAgC,CAAC;AAC7G,OAAO,EAGL,kBAAkB,EACnB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAC,8BAA8B,EAAE,2BAA2B,EAAC,MAAM,+BAA+B,CAAC;AAE1G,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAGzD,OAAO,EAAC,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAuB,iBAAiB,EAAC,MAAM,kBAAkB,CAAC;AACzE,OAAO,EACL,WAAW,EAIX,cAAc,EACd,UAAU,EAEV,gBAAgB,EASjB,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EAAC,eAAe,EAA0B,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AACnG,OAAO,EAAC,YAAY,EAAC,MAAM,yBAAyB,CAAC;AAGrD,OAAO,EAAC,sBAAsB,EAAC,MAAM,sCAAsC,CAAC;AAE5E,OAAO,EAAC,IAAI,EAAC,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAEL,2BAA2B,EAC3B,gBAAgB,EACjB,MAAM,2CAA2C,CAAC;AAQnD,OAAO,EAAC,QAAQ,EAAE,4BAA4B,EAAC,MAAM,UAAU,CAAC;AAGhE,KAAK,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEvE,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AAG,SAAS,CAAC;IAgBrB,4BAA4B,CAAC,KAAK,EAAE,2BAA2B,EAAE,QAAQ,EAAE,MAAM;IAc9F;;;;;;;;OAQG;IACU,UAAU,CACrB,YAAY,EAAE,MAAM,EACpB,IAAI,EAAE,IAAI,EACV,MAAM,EAAE,gBAAgB,EACxB,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,gBAAgB,EAC/B,mBAAmB,EAAE,2BAA2B,GAC/C,OAAO,CAAC,IAAI,CAAC;CA6BjB"}
|
|
@@ -19,12 +19,14 @@
|
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.MLSService = exports.MLSServiceEvents = exports.optionalToUint8Array = void 0;
|
|
22
|
+
const conversation_1 = require("@wireapp/api-client/lib/conversation");
|
|
23
|
+
const http_1 = require("@wireapp/api-client/lib/http");
|
|
22
24
|
const bazinga64_1 = require("bazinga64");
|
|
23
25
|
const commons_1 = require("@wireapp/commons");
|
|
24
26
|
const core_crypto_1 = require("@wireapp/core-crypto");
|
|
25
27
|
const ClientMLSError_1 = require("./ClientMLSError");
|
|
26
28
|
const CoreCryptoMLSError_1 = require("./CoreCryptoMLSError");
|
|
27
|
-
const
|
|
29
|
+
const conversation_2 = require("../../../conversation");
|
|
28
30
|
const fullyQualifiedClientIdUtils_1 = require("../../../util/fullyQualifiedClientIdUtils");
|
|
29
31
|
const numberToHex_1 = require("../../../util/numberToHex");
|
|
30
32
|
const TaskScheduler_1 = require("../../../util/TaskScheduler");
|
|
@@ -39,7 +41,7 @@ const optionalToUint8Array = (array) => {
|
|
|
39
41
|
};
|
|
40
42
|
exports.optionalToUint8Array = optionalToUint8Array;
|
|
41
43
|
const defaultConfig = {
|
|
42
|
-
keyingMaterialUpdateThreshold:
|
|
44
|
+
keyingMaterialUpdateThreshold: commons_1.TimeUtil.TimeInMillis.DAY * 30,
|
|
43
45
|
nbKeyPackages: 100,
|
|
44
46
|
};
|
|
45
47
|
var MLSServiceEvents;
|
|
@@ -58,6 +60,14 @@ class MLSService extends commons_1.TypedEventEmitter {
|
|
|
58
60
|
_config;
|
|
59
61
|
textEncoder = new TextEncoder();
|
|
60
62
|
textDecoder = new TextDecoder();
|
|
63
|
+
static UPLOAD_COMMIT_BUNDLE_ABORT_REASONS = {
|
|
64
|
+
BROKEN_MLS_CONVERSATION: 'BROKEN_MLS_CONVERSATION',
|
|
65
|
+
OTHER: 'OTHER',
|
|
66
|
+
};
|
|
67
|
+
static isBrokenMLSConversationError(error) {
|
|
68
|
+
return ((0, core_crypto_1.isMlsMessageRejectedError)(error) &&
|
|
69
|
+
error.context.context.reason === MLSService.UPLOAD_COMMIT_BUNDLE_ABORT_REASONS.BROKEN_MLS_CONVERSATION);
|
|
70
|
+
}
|
|
61
71
|
constructor(apiClient, coreCryptoClient, coreDatabase, recurringTaskScheduler) {
|
|
62
72
|
super();
|
|
63
73
|
this.apiClient = apiClient;
|
|
@@ -175,8 +185,17 @@ class MLSService extends commons_1.TypedEventEmitter {
|
|
|
175
185
|
}
|
|
176
186
|
catch (error) {
|
|
177
187
|
this.logger.error(`Failed to upload commit bundle`, error);
|
|
188
|
+
if (http_1.HttpClient.isBackendError(error)) {
|
|
189
|
+
const mappedError = http_1.BackendErrorMapper.map(new http_1.BackendError(error.response.data.message, error.response.data.label, error.response.data.code));
|
|
190
|
+
if (mappedError instanceof conversation_1.MLSInvalidLeafNodeSignatureError ||
|
|
191
|
+
mappedError instanceof conversation_1.MLSInvalidLeafNodeIndexError) {
|
|
192
|
+
return {
|
|
193
|
+
abort: { reason: MLSService.UPLOAD_COMMIT_BUNDLE_ABORT_REASONS.BROKEN_MLS_CONVERSATION },
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
}
|
|
178
197
|
return {
|
|
179
|
-
abort: { reason: error instanceof Error ? error.message :
|
|
198
|
+
abort: { reason: error instanceof Error ? error.message : MLSService.UPLOAD_COMMIT_BUNDLE_ABORT_REASONS.OTHER },
|
|
180
199
|
};
|
|
181
200
|
}
|
|
182
201
|
};
|
|
@@ -260,11 +279,11 @@ class MLSService extends commons_1.TypedEventEmitter {
|
|
|
260
279
|
}, []);
|
|
261
280
|
const failures = [];
|
|
262
281
|
if (emptyKeyPackagesUsers.length > 0) {
|
|
263
|
-
failures.push({ reason:
|
|
282
|
+
failures.push({ reason: conversation_2.AddUsersFailureReasons.OFFLINE_FOR_TOO_LONG, users: emptyKeyPackagesUsers });
|
|
264
283
|
}
|
|
265
284
|
if (failedToFetchKeyPackages.length > 0) {
|
|
266
285
|
failures.push({
|
|
267
|
-
reason:
|
|
286
|
+
reason: conversation_2.AddUsersFailureReasons.UNREACHABLE_BACKENDS,
|
|
268
287
|
users: failedToFetchKeyPackages,
|
|
269
288
|
backends: failedToFetchKeyPackages.map(({ domain }) => domain),
|
|
270
289
|
});
|
|
@@ -276,19 +295,27 @@ class MLSService extends commons_1.TypedEventEmitter {
|
|
|
276
295
|
return this.coreCryptoClient.conversationEpoch(new core_crypto_1.ConversationId(groupIdBytes));
|
|
277
296
|
}
|
|
278
297
|
async joinByExternalCommit(getGroupInfo) {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
298
|
+
try {
|
|
299
|
+
this.logger.info('Trying to join MLS group via external commit');
|
|
300
|
+
const credentialType = await this.getCredentialType();
|
|
301
|
+
const groupInfo = await getGroupInfo();
|
|
302
|
+
const welcomeBundle = await this.coreCryptoClient.transaction(cx => cx.joinByExternalCommit(new core_crypto_1.GroupInfo(groupInfo), credentialType));
|
|
303
|
+
await this.dispatchNewCrlDistributionPoints(welcomeBundle.crlNewDistributionPoints);
|
|
304
|
+
this.logger.info('welcome bundle after joining via external commit');
|
|
305
|
+
if (welcomeBundle.id) {
|
|
306
|
+
//after we've successfully joined via external commit, we schedule periodic key material renewal
|
|
307
|
+
const groupIdStr = bazinga64_1.Encoder.toBase64(welcomeBundle.id.copyBytes()).asString;
|
|
308
|
+
const newEpoch = await this.getEpoch(groupIdStr);
|
|
309
|
+
// Schedule the next key material renewal
|
|
310
|
+
await this.scheduleKeyMaterialRenewal(groupIdStr);
|
|
311
|
+
// Notify subscribers about the new epoch
|
|
312
|
+
this.emit(MLSServiceEvents.NEW_EPOCH, { groupId: groupIdStr, epoch: newEpoch });
|
|
313
|
+
this.logger.info(`Joined MLS group with id ${groupIdStr} via external commit, new epoch: ${newEpoch}`);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
catch (error) {
|
|
317
|
+
this.logger.error('Failed to join MLS group via external commit', error);
|
|
318
|
+
throw error;
|
|
292
319
|
}
|
|
293
320
|
}
|
|
294
321
|
async exportSecretKey(groupId, keyLength) {
|
|
@@ -413,7 +440,7 @@ class MLSService extends commons_1.TypedEventEmitter {
|
|
|
413
440
|
// If we're missing key packages for the user we want to add, we can't register the conversation
|
|
414
441
|
if (otherUserKeyPackages.length <= 0) {
|
|
415
442
|
if (otherUserKeysClaimingFailures.length > 0 &&
|
|
416
|
-
otherUserKeysClaimingFailures.some(({ reason }) => reason ===
|
|
443
|
+
otherUserKeysClaimingFailures.some(({ reason }) => reason === conversation_2.AddUsersFailureReasons.OFFLINE_FOR_TOO_LONG)) {
|
|
417
444
|
throw new ClientMLSError_1.ClientMLSError(ClientMLSError_1.ClientMLSErrorLabel.NO_KEY_PACKAGES_AVAILABLE);
|
|
418
445
|
}
|
|
419
446
|
}
|
|
@@ -450,6 +477,7 @@ class MLSService extends commons_1.TypedEventEmitter {
|
|
|
450
477
|
return true;
|
|
451
478
|
}
|
|
452
479
|
catch (error) {
|
|
480
|
+
this.logger.warn("Couldn't establish the MLS group", error);
|
|
453
481
|
// If conversation already existed, locally, nothing more to do, we've received a welcome message.
|
|
454
482
|
if ((0, CoreCryptoMLSError_1.isCoreCryptoMLSConversationAlreadyExistsError)(error)) {
|
|
455
483
|
this.logger.debug(`MLS Group with id ${groupId} already exists, skipping the initialisation.`);
|
|
@@ -680,7 +708,8 @@ class MLSService extends commons_1.TypedEventEmitter {
|
|
|
680
708
|
*
|
|
681
709
|
* @param groupId groupId of the conversation
|
|
682
710
|
*/
|
|
683
|
-
async commitPendingProposals(groupId, shouldRetry = true) {
|
|
711
|
+
async commitPendingProposals(groupId, shouldRetry = true, params) {
|
|
712
|
+
this.logger.info(`Committing pending proposals for groupId ${groupId}`, { shouldRetry, params });
|
|
684
713
|
const groupIdBytes = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
|
|
685
714
|
try {
|
|
686
715
|
await this.coreCryptoClient.transaction(cx => cx.commitPendingProposals(new core_crypto_1.ConversationId(groupIdBytes)));
|
|
@@ -690,7 +719,18 @@ class MLSService extends commons_1.TypedEventEmitter {
|
|
|
690
719
|
if (!shouldRetry) {
|
|
691
720
|
throw error;
|
|
692
721
|
}
|
|
693
|
-
|
|
722
|
+
if ((0, core_crypto_1.isMlsMessageRejectedError)(error)) {
|
|
723
|
+
this.logger.warn('Failed to commit proposals, conversation is broken, letting the error bubble up', {
|
|
724
|
+
error,
|
|
725
|
+
groupId,
|
|
726
|
+
});
|
|
727
|
+
throw error;
|
|
728
|
+
}
|
|
729
|
+
this.logger.warn('Failed to commit proposals, clearing the pending commit and retrying', {
|
|
730
|
+
error,
|
|
731
|
+
groupId,
|
|
732
|
+
shouldRetry,
|
|
733
|
+
});
|
|
694
734
|
return this.commitPendingProposals(groupId, false);
|
|
695
735
|
}
|
|
696
736
|
}
|
|
@@ -8,15 +8,10 @@ export declare const ProteusErrors: {
|
|
|
8
8
|
readonly DuplicateMessage: 209;
|
|
9
9
|
readonly Unknown: 999;
|
|
10
10
|
};
|
|
11
|
-
export declare const CORE_CRYPTO_PROTEUS_ERROR_NAMES: {
|
|
12
|
-
ProteusErrorSessionNotFound: string;
|
|
13
|
-
ProteusErrorRemoteIdentityChanged: string;
|
|
14
|
-
ProteusErrorDuplicateMessage: string;
|
|
15
|
-
};
|
|
16
11
|
type SenderInfo = {
|
|
17
12
|
clientId: string;
|
|
18
13
|
userId: QualifiedId;
|
|
19
14
|
};
|
|
20
|
-
export declare const generateDecryptionError: (senderInfo: SenderInfo, error:
|
|
15
|
+
export declare const generateDecryptionError: (senderInfo: SenderInfo, error: unknown) => DecryptionError;
|
|
21
16
|
export {};
|
|
22
17
|
//# sourceMappingURL=DecryptionErrorGenerator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecryptionErrorGenerator.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/proteus/ProteusService/DecryptionErrorGenerator/DecryptionErrorGenerator.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"DecryptionErrorGenerator.d.ts","sourceRoot":"","sources":["../../../../../src/messagingProtocols/proteus/ProteusService/DecryptionErrorGenerator/DecryptionErrorGenerator.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAUzD,OAAO,EAAC,eAAe,EAAC,MAAM,oCAAoC,CAAC;AAEnE,eAAO,MAAM,aAAa;;;;;;;CAOhB,CAAC;AAUX,KAAK,UAAU,GAAG;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAC,CAAC;AA8B1D,eAAO,MAAM,uBAAuB,eAAgB,UAAU,SAAS,OAAO,KAAG,eAWhF,CAAC"}
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.generateDecryptionError = exports.
|
|
21
|
+
exports.generateDecryptionError = exports.ProteusErrors = void 0;
|
|
22
|
+
const core_crypto_1 = require("@wireapp/core-crypto");
|
|
22
23
|
const DecryptionError_1 = require("../../../../errors/DecryptionError");
|
|
23
24
|
exports.ProteusErrors = {
|
|
24
25
|
SessionNotFound: 102,
|
|
@@ -28,40 +29,36 @@ exports.ProteusErrors = {
|
|
|
28
29
|
DuplicateMessage: 209,
|
|
29
30
|
Unknown: 999,
|
|
30
31
|
};
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
const isCryptoboxError = (error) => {
|
|
35
|
-
return 'code' in error;
|
|
36
|
-
};
|
|
37
|
-
exports.CORE_CRYPTO_PROTEUS_ERROR_NAMES = {
|
|
38
|
-
ProteusErrorSessionNotFound: 'ProteusErrorSessionNotFound',
|
|
39
|
-
ProteusErrorRemoteIdentityChanged: 'ProteusErrorRemoteIdentityChanged',
|
|
40
|
-
ProteusErrorDuplicateMessage: 'ProteusErrorDuplicateMessage',
|
|
41
|
-
};
|
|
32
|
+
const isCryptoboxError = (error) => typeof error?.code === 'number';
|
|
33
|
+
const hasProteusErrorCode = (error) => typeof error?.proteusErrorCode === 'number';
|
|
42
34
|
function getErrorCode(error) {
|
|
43
|
-
if (
|
|
44
|
-
return error.proteusErrorCode;
|
|
45
|
-
}
|
|
46
|
-
if (isCryptoboxError(error) && typeof error.code === 'number') {
|
|
47
|
-
return error.code;
|
|
48
|
-
}
|
|
49
|
-
if (error.name === exports.CORE_CRYPTO_PROTEUS_ERROR_NAMES.ProteusErrorSessionNotFound) {
|
|
35
|
+
if ((0, core_crypto_1.isProteusSessionNotFoundError)(error)) {
|
|
50
36
|
return exports.ProteusErrors.SessionNotFound;
|
|
51
37
|
}
|
|
52
|
-
if (
|
|
38
|
+
if ((0, core_crypto_1.isProteusRemoteIdentityChangedError)(error)) {
|
|
53
39
|
return exports.ProteusErrors.RemoteIdentityChanged;
|
|
54
40
|
}
|
|
55
|
-
if (
|
|
41
|
+
if ((0, core_crypto_1.isProteusDuplicateMessageError)(error)) {
|
|
56
42
|
return exports.ProteusErrors.DuplicateMessage;
|
|
57
43
|
}
|
|
44
|
+
if ((0, core_crypto_1.isProteusError)(error, core_crypto_1.ProteusErrorType.Other)) {
|
|
45
|
+
return exports.ProteusErrors.Unknown;
|
|
46
|
+
}
|
|
47
|
+
if (hasProteusErrorCode(error)) {
|
|
48
|
+
return error.proteusErrorCode;
|
|
49
|
+
}
|
|
50
|
+
if (isCryptoboxError(error)) {
|
|
51
|
+
return error.code;
|
|
52
|
+
}
|
|
58
53
|
return exports.ProteusErrors.Unknown;
|
|
59
54
|
}
|
|
60
55
|
const generateDecryptionError = (senderInfo, error) => {
|
|
61
56
|
const { clientId, userId } = senderInfo;
|
|
62
57
|
const sender = `${userId.id} (${clientId})`;
|
|
63
58
|
const code = getErrorCode(error);
|
|
64
|
-
const
|
|
59
|
+
const name = error?.name;
|
|
60
|
+
const text = error?.message ?? String(error);
|
|
61
|
+
const message = `Decryption error from ${sender} (name: ${name}) (message: ${text})`;
|
|
65
62
|
return new DecryptionError_1.DecryptionError(message, code);
|
|
66
63
|
};
|
|
67
64
|
exports.generateDecryptionError = generateDecryptionError;
|
package/package.json
CHANGED
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"./lib/cryptography/AssetCryptography/crypto.node": "./lib/cryptography/AssetCryptography/crypto.browser.js"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@wireapp/api-client": "^27.
|
|
14
|
+
"@wireapp/api-client": "^27.77.1",
|
|
15
15
|
"@wireapp/commons": "^5.4.5",
|
|
16
|
-
"@wireapp/core-crypto": "9.0
|
|
16
|
+
"@wireapp/core-crypto": "9.1.0",
|
|
17
17
|
"@wireapp/cryptobox": "12.8.0",
|
|
18
18
|
"@wireapp/priority-queue": "^2.1.12",
|
|
19
19
|
"@wireapp/promise-queue": "^2.4.5",
|
|
@@ -61,6 +61,6 @@
|
|
|
61
61
|
"test:coverage": "jest --coverage",
|
|
62
62
|
"watch": "tsc --watch"
|
|
63
63
|
},
|
|
64
|
-
"version": "46.
|
|
65
|
-
"gitHead": "
|
|
64
|
+
"version": "46.38.1",
|
|
65
|
+
"gitHead": "9104cb7a79a4ddd07ed402fe788656e4f09dcda3"
|
|
66
66
|
}
|