@wireapp/core 42.5.1 → 42.6.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.
@@ -33,7 +33,7 @@ const ConversationService_types_1 = require("./ConversationService.types");
33
33
  const conversation_2 = require("../../conversation/");
34
34
  const AssetCryptography_1 = require("../../cryptography/AssetCryptography");
35
35
  const mls_1 = require("../../messagingProtocols/mls");
36
- const CoreCryptoMLSErrors_1 = require("../../messagingProtocols/mls/MLSService/CoreCryptoMLSErrors");
36
+ const CoreCryptoMLSError_1 = require("../../messagingProtocols/mls/MLSService/CoreCryptoMLSError");
37
37
  const proteus_1 = require("../../messagingProtocols/proteus");
38
38
  const util_1 = require("../../util");
39
39
  const fullyQualifiedClientIdUtils_1 = require("../../util/fullyQualifiedClientIdUtils");
@@ -390,7 +390,7 @@ class ConversationService extends TypedEventEmitter_1.TypedEventEmitter {
390
390
  return await this.mlsService.handleMLSMessageAddEvent(event);
391
391
  }
392
392
  catch (error) {
393
- if ((0, CoreCryptoMLSErrors_1.isCoreCryptoMLSWrongEpochError)(error)) {
393
+ if ((0, CoreCryptoMLSError_1.isCoreCryptoMLSWrongEpochError)(error)) {
394
394
  this.logger.info(`Received message for the wrong epoch in conversation ${event.conversation}, handling epoch mismatch...`);
395
395
  const conversationId = event.qualified_conversation;
396
396
  if (!conversationId) {
@@ -46,7 +46,7 @@ const conversation_1 = require("@wireapp/api-client/lib/conversation");
46
46
  const event_1 = require("@wireapp/api-client/lib/event");
47
47
  const api_client_1 = require("@wireapp/api-client");
48
48
  const __1 = require("..");
49
- const CoreCryptoMLSErrors_1 = require("../../messagingProtocols/mls/MLSService/CoreCryptoMLSErrors");
49
+ const CoreCryptoMLSError_1 = require("../../messagingProtocols/mls/MLSService/CoreCryptoMLSError");
50
50
  const MessagingProtocols = __importStar(require("../../messagingProtocols/proteus"));
51
51
  const PayloadHelper = __importStar(require("../../test/PayloadHelper"));
52
52
  const MessageBuilder = __importStar(require("../message/MessageBuilder"));
@@ -327,7 +327,7 @@ describe('ConversationService', () => {
327
327
  const mockMLSMessageAddEvent = createMLSMessageAddEventMock(conversationId);
328
328
  jest
329
329
  .spyOn(mlsService, 'handleMLSMessageAddEvent')
330
- .mockRejectedValueOnce(new Error(CoreCryptoMLSErrors_1.CoreCryptoMLSErrors.WRONG_EPOCH));
330
+ .mockRejectedValueOnce(new Error(CoreCryptoMLSError_1.CoreCryptoMLSError.DECRYPTION.WRONG_EPOCH));
331
331
  const remoteEpoch = 5;
332
332
  const localEpoch = 4;
333
333
  jest.spyOn(mlsService, 'conversationExists').mockResolvedValueOnce(true);
@@ -0,0 +1,11 @@
1
+ export declare const CoreCryptoMLSError: {
2
+ readonly DECRYPTION: {
3
+ readonly WRONG_EPOCH: "Incoming message is for the wrong epoch";
4
+ readonly ALREADY_DECRYPTED: "We already decrypted this message once";
5
+ readonly EXTERNAL_COMMIT_NOT_MERGED: "You tried to join with an external commit but did not merge it yet. We will reapply this message for you when you merge your external commit";
6
+ readonly FUTURE_EPOCH: "Incoming message is for a future epoch. We will buffer it until the commit for that epoch arrives";
7
+ };
8
+ };
9
+ export declare const isCoreCryptoMLSWrongEpochError: (error: unknown) => boolean;
10
+ export declare const shouldMLSDecryptionErrorBeIgnored: (error: unknown) => error is Error;
11
+ //# sourceMappingURL=CoreCryptoMLSError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CoreCryptoMLSError.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/MLSService/CoreCryptoMLSError.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,kBAAkB;;;;;;;CAQrB,CAAC;AAEX,eAAO,MAAM,8BAA8B,UAAW,OAAO,KAAG,OAE/D,CAAC;AAQF,eAAO,MAAM,iCAAiC,UAAW,OAAO,mBAE/D,CAAC"}
@@ -0,0 +1,42 @@
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.shouldMLSDecryptionErrorBeIgnored = exports.isCoreCryptoMLSWrongEpochError = exports.CoreCryptoMLSError = void 0;
22
+ exports.CoreCryptoMLSError = {
23
+ DECRYPTION: {
24
+ WRONG_EPOCH: 'Incoming message is for the wrong epoch',
25
+ ALREADY_DECRYPTED: 'We already decrypted this message once',
26
+ EXTERNAL_COMMIT_NOT_MERGED: 'You tried to join with an external commit but did not merge it yet. We will reapply this message for you when you merge your external commit',
27
+ FUTURE_EPOCH: 'Incoming message is for a future epoch. We will buffer it until the commit for that epoch arrives',
28
+ },
29
+ };
30
+ const isCoreCryptoMLSWrongEpochError = (error) => {
31
+ return error instanceof Error && error.message === exports.CoreCryptoMLSError.DECRYPTION.WRONG_EPOCH;
32
+ };
33
+ exports.isCoreCryptoMLSWrongEpochError = isCoreCryptoMLSWrongEpochError;
34
+ const mlsDecryptionErrorsToIgnore = [
35
+ exports.CoreCryptoMLSError.DECRYPTION.ALREADY_DECRYPTED,
36
+ exports.CoreCryptoMLSError.DECRYPTION.EXTERNAL_COMMIT_NOT_MERGED,
37
+ exports.CoreCryptoMLSError.DECRYPTION.FUTURE_EPOCH,
38
+ ];
39
+ const shouldMLSDecryptionErrorBeIgnored = (error) => {
40
+ return error instanceof Error && mlsDecryptionErrorsToIgnore.includes(error.message);
41
+ };
42
+ exports.shouldMLSDecryptionErrorBeIgnored = shouldMLSDecryptionErrorBeIgnored;
@@ -38,7 +38,7 @@ export declare class MLSService extends TypedEventEmitter<Events> {
38
38
  private readonly textDecoder;
39
39
  constructor(apiClient: APIClient, coreCryptoClient: CoreCrypto, { keyingMaterialUpdateThreshold, nbKeyPackages, defaultCiphersuite, defaultCredentialType, }: Partial<MLSServiceConfig>);
40
40
  initClient(userId: QualifiedId, client: RegisteredClient): Promise<void>;
41
- private uploadCommitBundle;
41
+ private readonly uploadCommitBundle;
42
42
  /**
43
43
  * Will add users to an existing MLS group and send a commit bundle to backend.
44
44
  * Cannot be called with an empty array of keys.
@@ -1 +1 @@
1
- {"version":3,"file":"MLSService.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/MLSService/MLSService.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAqB,gBAAgB,EAAC,MAAM,gCAAgC,CAAC;AACzF,OAAO,EAAC,sBAAsB,EAAE,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;AAChG,OAAO,EAAC,eAAe,EAAC,MAAM,sDAAsD,CAAC;AACrF,OAAO,EAAC,8BAA8B,EAAE,2BAA2B,EAAC,MAAM,+BAA+B,CAAC;AAE1G,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAGzD,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,OAAO,EACP,YAAY,EACZ,YAAY,EACZ,kBAAkB,EACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAC,gBAAgB,EAAsB,MAAM,oBAAoB,CAAC;AAIzE,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAM1D,OAAO,EAAC,iBAAiB,EAAC,MAAM,iCAAiC,CAAC;AAElE,OAAO,EAAC,4BAA4B,EAAE,4BAA4B,EAAE,YAAY,EAAC,MAAM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ACrC,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAQ9B;;;;;;;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;IAY5F,wBAAwB,CAAC,KAAK,EAAE,8BAA8B;IAI9D,4BAA4B,CAAC,KAAK,EAAE,2BAA2B,EAAE,QAAQ,EAAE,MAAM;CAa/F"}
@@ -40,6 +40,7 @@ const bazinga64_1 = require("bazinga64");
40
40
  const logdown_1 = __importDefault(require("logdown"));
41
41
  const commons_1 = require("@wireapp/commons");
42
42
  const core_crypto_1 = require("@wireapp/core-crypto");
43
+ const CoreCryptoMLSError_1 = require("./CoreCryptoMLSError");
43
44
  const pendingProposalsStore_1 = require("./stores/pendingProposalsStore");
44
45
  const subconversationGroupIdStore_1 = require("./stores/subconversationGroupIdStore/subconversationGroupIdStore");
45
46
  const messageSender_1 = require("../../../conversation/message/messageSender");
@@ -69,6 +70,43 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
69
70
  this.logger = (0, logdown_1.default)('@wireapp/core/MLSService');
70
71
  this.textEncoder = new TextEncoder();
71
72
  this.textDecoder = new TextDecoder();
73
+ // We need to lock the websocket while commit bundle is being processed by backend,
74
+ // it's possible that we will be sent some mls messages before we receive the response from backend and accept a commit locally.
75
+ this.uploadCommitBundle = this.apiClient.withLockedWebSocket(async (groupId, commitBundle, { regenerateCommitBundle, isExternalCommit } = {}) => {
76
+ const { commit, groupInfo, welcome } = commitBundle;
77
+ const bundlePayload = new Uint8Array([...commit, ...groupInfo.payload, ...(welcome || [])]);
78
+ try {
79
+ const response = await this.apiClient.api.conversation.postMlsCommitBundle(bundlePayload);
80
+ if (isExternalCommit) {
81
+ await this.coreCryptoClient.mergePendingGroupFromExternalCommit(groupId);
82
+ }
83
+ else {
84
+ await this.coreCryptoClient.commitAccepted(groupId);
85
+ }
86
+ const newEpoch = await this.getEpoch(groupId);
87
+ const groupIdStr = bazinga64_1.Encoder.toBase64(groupId).asString;
88
+ this.emit('newEpoch', { epoch: newEpoch, groupId: groupIdStr });
89
+ return response;
90
+ }
91
+ catch (error) {
92
+ if (isExternalCommit) {
93
+ await this.coreCryptoClient.clearPendingGroupFromExternalCommit(groupId);
94
+ }
95
+ else {
96
+ await this.coreCryptoClient.clearPendingCommit(groupId);
97
+ }
98
+ const shouldRetry = error instanceof http_1.BackendError && error.code === http_1.StatusCode.CONFLICT;
99
+ if (shouldRetry && regenerateCommitBundle) {
100
+ // in case of a 409, we want to retry to generate the commit and resend it
101
+ // could be that we are trying to upload a commit to a conversation that has a different epoch on backend
102
+ // in this case we will most likely receive a commit from backend that will increase our local epoch
103
+ this.logger.warn(`Uploading commitBundle failed. Will retry generating a new bundle`);
104
+ const updatedCommitBundle = await regenerateCommitBundle();
105
+ return this.uploadCommitBundle(groupId, updatedCommitBundle, { isExternalCommit });
106
+ }
107
+ throw error;
108
+ }
109
+ });
72
110
  this.config = {
73
111
  keyingMaterialUpdateThreshold,
74
112
  nbKeyPackages,
@@ -84,41 +122,6 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
84
122
  await this.uploadMLSPublicKeys(client);
85
123
  await this.verifyRemoteMLSKeyPackagesAmount(client.id);
86
124
  }
87
- async uploadCommitBundle(groupId, commitBundle, { regenerateCommitBundle, isExternalCommit } = {}) {
88
- const { commit, groupInfo, welcome } = commitBundle;
89
- const bundlePayload = new Uint8Array([...commit, ...groupInfo.payload, ...(welcome || [])]);
90
- try {
91
- const response = await this.apiClient.api.conversation.postMlsCommitBundle(bundlePayload);
92
- if (isExternalCommit) {
93
- await this.coreCryptoClient.mergePendingGroupFromExternalCommit(groupId);
94
- }
95
- else {
96
- await this.coreCryptoClient.commitAccepted(groupId);
97
- }
98
- const newEpoch = await this.getEpoch(groupId);
99
- const groupIdStr = bazinga64_1.Encoder.toBase64(groupId).asString;
100
- this.emit('newEpoch', { epoch: newEpoch, groupId: groupIdStr });
101
- return response;
102
- }
103
- catch (error) {
104
- if (isExternalCommit) {
105
- await this.coreCryptoClient.clearPendingGroupFromExternalCommit(groupId);
106
- }
107
- else {
108
- await this.coreCryptoClient.clearPendingCommit(groupId);
109
- }
110
- const shouldRetry = error instanceof http_1.BackendError && error.code === http_1.StatusCode.CONFLICT;
111
- if (shouldRetry && regenerateCommitBundle) {
112
- // in case of a 409, we want to retry to generate the commit and resend it
113
- // could be that we are trying to upload a commit to a conversation that has a different epoch on backend
114
- // in this case we will most likely receive a commit from backend that will increase our local epoch
115
- this.logger.warn(`Uploading commitBundle failed. Will retry generating a new bundle`);
116
- const updatedCommitBundle = await regenerateCommitBundle();
117
- return this.uploadCommitBundle(groupId, updatedCommitBundle, { isExternalCommit });
118
- }
119
- throw error;
120
- }
121
- }
122
125
  /**
123
126
  * Will add users to an existing MLS group and send a commit bundle to backend.
124
127
  * Cannot be called with an empty array of keys.
@@ -284,7 +287,21 @@ class MLSService extends TypedEventEmitter_1.TypedEventEmitter {
284
287
  return this.coreCryptoClient.processWelcomeMessage(welcomeMessage);
285
288
  }
286
289
  async decryptMessage(conversationId, payload) {
287
- return this.coreCryptoClient.decryptMessage(conversationId, payload);
290
+ try {
291
+ const decryptedMessage = await this.coreCryptoClient.decryptMessage(conversationId, payload);
292
+ return decryptedMessage;
293
+ }
294
+ catch (error) {
295
+ // According to CoreCrypto JS doc on .decryptMessage method, we should ignore some errors (corecrypto handle them internally)
296
+ if ((0, CoreCryptoMLSError_1.shouldMLSDecryptionErrorBeIgnored)(error)) {
297
+ return {
298
+ hasEpochChanged: false,
299
+ isActive: false,
300
+ proposals: [],
301
+ };
302
+ }
303
+ throw error;
304
+ }
288
305
  }
289
306
  async encryptMessage(conversationId, message) {
290
307
  return this.coreCryptoClient.encryptMessage(conversationId, message);
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "./lib/cryptography/AssetCryptography/crypto.node": "./lib/cryptography/AssetCryptography/crypto.browser.js"
12
12
  },
13
13
  "dependencies": {
14
- "@wireapp/api-client": "^26.1.2",
14
+ "@wireapp/api-client": "^26.2.0",
15
15
  "@wireapp/commons": "^5.1.3",
16
16
  "@wireapp/core-crypto": "1.0.0-rc.12",
17
17
  "@wireapp/cryptobox": "12.8.0",
@@ -23,7 +23,7 @@
23
23
  "bazinga64": "^6.3.1",
24
24
  "deepmerge-ts": "5.1.0",
25
25
  "hash.js": "1.1.7",
26
- "http-status-codes": "2.2.0",
26
+ "http-status-codes": "2.3.0",
27
27
  "idb": "7.1.1",
28
28
  "logdown": "3.3.1",
29
29
  "long": "^5.2.0",
@@ -60,6 +60,6 @@
60
60
  "test:coverage": "jest --coverage",
61
61
  "watch": "tsc --watch"
62
62
  },
63
- "version": "42.5.1",
64
- "gitHead": "3f2d47314bb99a0d5e10a4011e2d45b46b073ee9"
63
+ "version": "42.6.1",
64
+ "gitHead": "755c2a5d525a7a2671f8cb82475bfc129edae683"
65
65
  }
@@ -1,5 +0,0 @@
1
- export declare enum CoreCryptoMLSErrors {
2
- WRONG_EPOCH = "Incoming message is for the wrong epoch"
3
- }
4
- export declare const isCoreCryptoMLSWrongEpochError: (error: unknown) => boolean;
5
- //# sourceMappingURL=CoreCryptoMLSErrors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CoreCryptoMLSErrors.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/MLSService/CoreCryptoMLSErrors.ts"],"names":[],"mappings":"AAmBA,oBAAY,mBAAmB;IAC7B,WAAW,4CAA4C;CACxD;AAED,eAAO,MAAM,8BAA8B,UAAW,OAAO,KAAG,OAE/D,CAAC"}
@@ -1,29 +0,0 @@
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.isCoreCryptoMLSWrongEpochError = exports.CoreCryptoMLSErrors = void 0;
22
- var CoreCryptoMLSErrors;
23
- (function (CoreCryptoMLSErrors) {
24
- CoreCryptoMLSErrors["WRONG_EPOCH"] = "Incoming message is for the wrong epoch";
25
- })(CoreCryptoMLSErrors || (exports.CoreCryptoMLSErrors = CoreCryptoMLSErrors = {}));
26
- const isCoreCryptoMLSWrongEpochError = (error) => {
27
- return error instanceof Error && error.message === CoreCryptoMLSErrors.WRONG_EPOCH;
28
- };
29
- exports.isCoreCryptoMLSWrongEpochError = isCoreCryptoMLSWrongEpochError;