@wireapp/core 46.46.6-beta.14.f6fd03fe6 → 46.46.6
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/Account.d.ts +156 -51
- package/lib/Account.d.ts.map +1 -1
- package/lib/Account.js +503 -127
- package/lib/Account.test.js +158 -147
- package/lib/broadcast/AvailabilityType.d.ts +1 -1
- package/lib/broadcast/AvailabilityType.d.ts.map +1 -1
- package/lib/broadcast/BroadcastService.d.ts +1 -1
- package/lib/broadcast/BroadcastService.d.ts.map +1 -1
- package/lib/broadcast/BroadcastService.js +1 -1
- package/lib/client/ClientService.d.ts +4 -3
- package/lib/client/ClientService.d.ts.map +1 -1
- package/lib/client/ClientService.js +19 -5
- package/lib/conversation/AbortReason.d.ts +1 -1
- package/lib/conversation/AbortReason.d.ts.map +1 -1
- package/lib/conversation/AssetService/AssetService.d.ts +12 -30
- package/lib/conversation/AssetService/AssetService.d.ts.map +1 -1
- package/lib/conversation/AssetService/AssetService.js +1 -10
- package/lib/conversation/AssetService/AssetService.test.js +8 -3
- package/lib/conversation/ClientActionType.d.ts +1 -1
- package/lib/conversation/ClientActionType.d.ts.map +1 -1
- package/lib/conversation/ClientActionType.js +1 -1
- package/lib/conversation/ConversationService/ConversationService.d.ts +98 -14
- package/lib/conversation/ConversationService/ConversationService.d.ts.map +1 -1
- package/lib/conversation/ConversationService/ConversationService.js +314 -101
- package/lib/conversation/ConversationService/ConversationService.test.js +441 -47
- package/lib/conversation/ConversationService/ConversationService.types.d.ts +5 -4
- package/lib/conversation/ConversationService/ConversationService.types.d.ts.map +1 -1
- package/lib/conversation/ConversationService/Utility/getConversationQualifiedMembers.d.ts.map +1 -1
- package/lib/conversation/ConversationService/Utility/getConversationQualifiedMembers.js +6 -3
- package/lib/conversation/SubconversationService/SubconversationService.d.ts.map +1 -1
- package/lib/conversation/SubconversationService/SubconversationService.js +158 -11
- package/lib/conversation/SubconversationService/SubconversationService.test.js +8 -2
- package/lib/conversation/content/AssetContent.d.ts +1 -1
- package/lib/conversation/content/AssetContent.d.ts.map +1 -1
- package/lib/conversation/content/ButtonActionConfirmationContent.d.ts +1 -1
- package/lib/conversation/content/ButtonActionConfirmationContent.d.ts.map +1 -1
- package/lib/conversation/content/ButtonActionContent.d.ts +1 -1
- package/lib/conversation/content/ButtonActionContent.d.ts.map +1 -1
- package/lib/conversation/content/ClearedContent.d.ts +1 -1
- package/lib/conversation/content/ClearedContent.d.ts.map +1 -1
- package/lib/conversation/content/ClientActionContent.d.ts +1 -1
- package/lib/conversation/content/ClientActionContent.d.ts.map +1 -1
- package/lib/conversation/content/CompositeContent.d.ts +1 -1
- package/lib/conversation/content/CompositeContent.d.ts.map +1 -1
- package/lib/conversation/content/ConfirmationContent.d.ts +1 -1
- package/lib/conversation/content/ConfirmationContent.d.ts.map +1 -1
- package/lib/conversation/content/DeletedContent.d.ts +1 -1
- package/lib/conversation/content/DeletedContent.d.ts.map +1 -1
- package/lib/conversation/content/HiddenContent.d.ts +1 -1
- package/lib/conversation/content/HiddenContent.d.ts.map +1 -1
- package/lib/conversation/content/KnockContent.d.ts +1 -1
- package/lib/conversation/content/KnockContent.d.ts.map +1 -1
- package/lib/conversation/content/LinkPreviewContent.d.ts +1 -1
- package/lib/conversation/content/LinkPreviewContent.d.ts.map +1 -1
- package/lib/conversation/content/MentionContent.d.ts +1 -1
- package/lib/conversation/content/MentionContent.d.ts.map +1 -1
- package/lib/conversation/content/MultipartContent.d.ts +1 -1
- package/lib/conversation/content/MultipartContent.d.ts.map +1 -1
- package/lib/conversation/content/QuoteContent.d.ts +1 -1
- package/lib/conversation/content/QuoteContent.d.ts.map +1 -1
- package/lib/conversation/content/TweetContent.d.ts +1 -1
- package/lib/conversation/content/TweetContent.d.ts.map +1 -1
- package/lib/conversation/content/index.d.ts +1 -1
- package/lib/conversation/content/index.d.ts.map +1 -1
- package/lib/conversation/content/index.js +1 -1
- package/lib/conversation/message/MessageBuilder.d.ts +1 -1
- package/lib/conversation/message/MessageBuilder.d.ts.map +1 -1
- package/lib/conversation/message/MessageBuilder.js +1 -1
- package/lib/conversation/message/MessageService.d.ts.map +1 -1
- package/lib/conversation/message/MessageService.js +1 -1
- package/lib/conversation/message/MessageService.test.js +7 -1
- package/lib/conversation/message/MessageToProtoMapper.d.ts +1 -1
- package/lib/conversation/message/MessageToProtoMapper.d.ts.map +1 -1
- package/lib/conversation/message/MessageToProtoMapper.js +1 -1
- package/lib/conversation/message/messageSender.js +2 -2
- package/lib/cryptography/AssetCryptography/EncryptedAsset.d.ts +2 -2
- package/lib/cryptography/AssetCryptography/EncryptedAsset.d.ts.map +1 -1
- package/lib/messagingProtocols/common.types.d.ts +9 -0
- package/lib/messagingProtocols/common.types.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIService.types.d.ts +2 -2
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIService.types.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIService.types.js +2 -1
- 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/E2EIdentityService/E2EIServiceExternal.js +13 -11
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceExternal.test.js +21 -16
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.d.ts +9 -3
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/E2EIServiceInternal.js +31 -12
- package/lib/messagingProtocols/mls/E2EIdentityService/Helper/index.d.ts +6 -0
- package/lib/messagingProtocols/mls/E2EIdentityService/Helper/index.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/E2EIdentityService/Helper/index.js +19 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/IncomingProposalsQueue.d.ts +7 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/IncomingProposalsQueue.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/IncomingProposalsQueue.js +48 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/index.d.ts +2 -0
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/{IncomingMessagesQueue → IncomingProposalsQueue}/index.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/{IncomingMessagesQueue → IncomingProposalsQueue}/index.js +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/index.d.ts +0 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/index.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/index.js +0 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.js +23 -14
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.js +5 -2
- package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.test.js +13 -3
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.d.ts +38 -2
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.js +41 -6
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.test.d.ts +2 -0
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.test.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/MLSService/CoreCryptoMLSError.test.js +124 -0
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts +38 -34
- package/lib/messagingProtocols/mls/MLSService/MLSService.d.ts.map +1 -1
- package/lib/messagingProtocols/mls/MLSService/MLSService.js +267 -208
- package/lib/messagingProtocols/mls/MLSService/MLSService.test.js +157 -160
- package/lib/messagingProtocols/mls/MLSService/commitBundleUtil.js +3 -3
- package/lib/messagingProtocols/mls/MLSService/commitBundleUtil.test.js +5 -5
- package/lib/messagingProtocols/mls/conversationRejoinQueue.js +2 -2
- package/lib/messagingProtocols/mls/recovery/MlsErrorMapper.d.ts +78 -0
- package/lib/messagingProtocols/mls/recovery/MlsErrorMapper.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/recovery/MlsErrorMapper.js +173 -0
- package/lib/messagingProtocols/mls/recovery/MlsErrorMapper.test.d.ts +2 -0
- package/lib/messagingProtocols/mls/recovery/MlsErrorMapper.test.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/recovery/MlsErrorMapper.test.js +117 -0
- package/lib/messagingProtocols/mls/recovery/MlsRecoveryOrchestrator.d.ts +167 -0
- package/lib/messagingProtocols/mls/recovery/MlsRecoveryOrchestrator.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/recovery/MlsRecoveryOrchestrator.js +317 -0
- package/lib/messagingProtocols/mls/recovery/MlsRecoveryOrchestrator.test.d.ts +2 -0
- package/lib/messagingProtocols/mls/recovery/MlsRecoveryOrchestrator.test.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/recovery/MlsRecoveryOrchestrator.test.js +248 -0
- package/lib/messagingProtocols/mls/recovery/index.d.ts +5 -0
- package/lib/messagingProtocols/mls/recovery/index.d.ts.map +1 -0
- package/lib/messagingProtocols/mls/recovery/index.js +28 -0
- package/lib/messagingProtocols/mls/types.d.ts +0 -8
- package/lib/messagingProtocols/mls/types.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/EventHandler/events/otrMessageAdd/otrMessageAdd.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/EventHandler/events/otrMessageAdd/otrMessageAdd.js +7 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.d.ts +8 -15
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CoreCryptoWrapper/CoreCryptoWrapper.js +97 -62
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.d.ts +0 -6
- package/lib/messagingProtocols/proteus/ProteusService/CryptoClient/CryptoClient.types.d.ts.map +1 -1
- 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/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts +5 -3
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.js +11 -24
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts +1 -0
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.mocks.js +11 -2
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.test.js +13 -9
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.types.d.ts +3 -2
- package/lib/messagingProtocols/proteus/ProteusService/ProteusService.types.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/WithMockedGenerics.test.js +11 -4
- package/lib/messagingProtocols/proteus/ProteusService/cryptoMigrationStateStore.d.ts +0 -4
- package/lib/messagingProtocols/proteus/ProteusService/cryptoMigrationStateStore.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/cryptoMigrationStateStore.js +0 -5
- package/lib/messagingProtocols/proteus/ProteusService/identityClearer.d.ts +2 -1
- package/lib/messagingProtocols/proteus/ProteusService/identityClearer.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/ProteusService/identityClearer.js +8 -2
- package/lib/messagingProtocols/proteus/Utility/SessionHandler/SessionHandler.test.js +4 -0
- package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.d.ts +1 -1
- package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.d.ts.map +1 -1
- package/lib/messagingProtocols/proteus/Utility/getGenericMessageParams.js +1 -1
- package/lib/notification/NotificationService.d.ts +20 -6
- package/lib/notification/NotificationService.d.ts.map +1 -1
- package/lib/notification/NotificationService.js +23 -14
- package/lib/notification/NotificationService.test.js +8 -0
- package/lib/secretStore/secretKeyGenerator.d.ts +1 -0
- package/lib/secretStore/secretKeyGenerator.d.ts.map +1 -1
- package/lib/secretStore/secretKeyGenerator.js +3 -1
- package/lib/self/SelfService.d.ts +2 -2
- package/lib/self/SelfService.d.ts.map +1 -1
- package/lib/self/SelfService.test.js +5 -2
- package/lib/team/TeamService.d.ts +5 -2
- package/lib/team/TeamService.d.ts.map +1 -1
- package/lib/team/TeamService.js +12 -2
- package/lib/test/StoreHelper.d.ts +2 -0
- package/lib/test/StoreHelper.d.ts.map +1 -0
- package/lib/test/StoreHelper.js +27 -0
- package/lib/user/UserService.d.ts +2 -2
- package/lib/user/UserService.d.ts.map +1 -1
- package/lib/user/UserService.js +3 -3
- package/lib/util/TypePredicateUtil.d.ts.map +1 -1
- package/lib/util/TypePredicateUtil.js +2 -2
- package/package.json +3 -3
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/IncomingMesssagesQueue.d.ts +0 -4
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/IncomingMesssagesQueue.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/IncomingMesssagesQueue.js +0 -69
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingMessagesQueue/index.d.ts +0 -2
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.test.d.ts +0 -2
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.test.d.ts.map +0 -1
- package/lib/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.test.js +0 -98
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.isResponseStatusValid = exports.isMLSDevice = exports.getSignatureAlgorithmForCiphersuite = exports.getE2EIClientId = exports.jsonToByteArray = void 0;
|
|
21
|
+
exports.isResponseStatusValid = exports.getMLSDeviceStatus = exports.MLSDeviceStatus = exports.isMLSDevice = exports.getSignatureAlgorithmForCiphersuite = exports.getE2EIClientId = exports.jsonToByteArray = void 0;
|
|
22
22
|
const client_1 = require("@wireapp/api-client/lib/client");
|
|
23
23
|
const core_crypto_1 = require("@wireapp/core-crypto");
|
|
24
24
|
const fullyQualifiedClientIdUtils_1 = require("../../../../util/fullyQualifiedClientIdUtils");
|
|
@@ -58,5 +58,23 @@ const isMLSDevice = ({ mls_public_keys }, ciphersuite) => {
|
|
|
58
58
|
return typeof signature === 'string' && signature.length > 0;
|
|
59
59
|
};
|
|
60
60
|
exports.isMLSDevice = isMLSDevice;
|
|
61
|
+
var MLSDeviceStatus;
|
|
62
|
+
(function (MLSDeviceStatus) {
|
|
63
|
+
MLSDeviceStatus["REGISTERED"] = "registered";
|
|
64
|
+
MLSDeviceStatus["FRESH"] = "fresh";
|
|
65
|
+
MLSDeviceStatus["MISMATCH"] = "mismatch";
|
|
66
|
+
})(MLSDeviceStatus || (exports.MLSDeviceStatus = MLSDeviceStatus = {}));
|
|
67
|
+
const getMLSDeviceStatus = ({ mls_public_keys }, ciphersuite, existingClientSignature) => {
|
|
68
|
+
const signatureAlogrithm = (0, exports.getSignatureAlgorithmForCiphersuite)(ciphersuite);
|
|
69
|
+
const signature = mls_public_keys[signatureAlogrithm];
|
|
70
|
+
if (!signature || !existingClientSignature) {
|
|
71
|
+
return MLSDeviceStatus.FRESH;
|
|
72
|
+
}
|
|
73
|
+
if (signature !== existingClientSignature) {
|
|
74
|
+
return MLSDeviceStatus.MISMATCH;
|
|
75
|
+
}
|
|
76
|
+
return MLSDeviceStatus.REGISTERED;
|
|
77
|
+
};
|
|
78
|
+
exports.getMLSDeviceStatus = getMLSDeviceStatus;
|
|
61
79
|
const isResponseStatusValid = (status) => status && status === 'valid';
|
|
62
80
|
exports.isResponseStatusValid = isResponseStatusValid;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Task } from '@wireapp/promise-queue';
|
|
2
|
+
export declare function queueProposal<T>(cb: Task<T>): Promise<T>;
|
|
3
|
+
export declare function resumeProposalProcessing(): void;
|
|
4
|
+
export declare function pauseProposalProcessing(): void;
|
|
5
|
+
export declare function getProposalQueueLength(): number;
|
|
6
|
+
export declare function flushProposalsQueue(): void;
|
|
7
|
+
//# sourceMappingURL=IncomingProposalsQueue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IncomingProposalsQueue.d.ts","sourceRoot":"","sources":["../../../../../../../src/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/IncomingProposalsQueue.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAC,IAAI,EAAe,MAAM,wBAAwB,CAAC;AAM1D,wBAAgB,aAAa,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAGxD;AAED,wBAAgB,wBAAwB,IAAI,IAAI,CAG/C;AAED,wBAAgB,uBAAuB,IAAI,IAAI,CAG9C;AAED,wBAAgB,sBAAsB,WAErC;AAED,wBAAgB,mBAAmB,IAAI,IAAI,CAG1C"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Wire
|
|
4
|
+
* Copyright (C) 2025 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.queueProposal = queueProposal;
|
|
22
|
+
exports.resumeProposalProcessing = resumeProposalProcessing;
|
|
23
|
+
exports.pauseProposalProcessing = pauseProposalProcessing;
|
|
24
|
+
exports.getProposalQueueLength = getProposalQueueLength;
|
|
25
|
+
exports.flushProposalsQueue = flushProposalsQueue;
|
|
26
|
+
const commons_1 = require("@wireapp/commons");
|
|
27
|
+
const promise_queue_1 = require("@wireapp/promise-queue");
|
|
28
|
+
const logger = commons_1.LogFactory.getLogger('@wireapp/core/mls/IncomingProposalsQueue');
|
|
29
|
+
const proposalsQueue = new promise_queue_1.PromiseQueue({ name: 'incoming-proposals-queue', paused: true });
|
|
30
|
+
function queueProposal(cb) {
|
|
31
|
+
logger.info('Queueing proposal for processing');
|
|
32
|
+
return proposalsQueue.push(cb);
|
|
33
|
+
}
|
|
34
|
+
function resumeProposalProcessing() {
|
|
35
|
+
logger.info('Resuming proposal processing');
|
|
36
|
+
proposalsQueue.resume();
|
|
37
|
+
}
|
|
38
|
+
function pauseProposalProcessing() {
|
|
39
|
+
logger.info('Pausing proposal processing');
|
|
40
|
+
proposalsQueue.pause();
|
|
41
|
+
}
|
|
42
|
+
function getProposalQueueLength() {
|
|
43
|
+
return proposalsQueue.getLength();
|
|
44
|
+
}
|
|
45
|
+
function flushProposalsQueue() {
|
|
46
|
+
logger.info('Flushing proposals queue');
|
|
47
|
+
proposalsQueue.flush();
|
|
48
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/messagingProtocols/mls/EventHandler/events/messageAdd/
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/messagingProtocols/mls/EventHandler/events/messageAdd/IncomingProposalsQueue/index.ts"],"names":[],"mappings":"AAmBA,cAAc,0BAA0B,CAAC"}
|
|
@@ -32,4 +32,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
32
32
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
__exportStar(require("./
|
|
35
|
+
__exportStar(require("./IncomingProposalsQueue"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/EventHandler/events/messageAdd/index.ts"],"names":[],"mappings":"AAmBA,cAAc,cAAc,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/EventHandler/events/messageAdd/index.ts"],"names":[],"mappings":"AAmBA,cAAc,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageAdd.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"messageAdd.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/EventHandler/events/messageAdd/messageAdd.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,8BAA8B,EAAC,MAAM,+BAA+B,CAAC;AAS7E,OAAO,EAAC,mBAAmB,EAAC,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAC,UAAU,EAAuB,MAAM,gCAAgC,CAAC;AAIhF,UAAU,yBAAyB;IACjC,KAAK,EAAE,8BAA8B,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,eAAO,MAAM,mBAAmB,oCAI7B,yBAAyB,KAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAoChE,CAAC"}
|
|
@@ -19,32 +19,41 @@
|
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.handleMLSMessageAdd = void 0;
|
|
22
|
-
const protocol_messaging_1 = require("@pydio/protocol-messaging");
|
|
23
22
|
const bazinga64_1 = require("bazinga64");
|
|
23
|
+
const commons_1 = require("@wireapp/commons");
|
|
24
|
+
const core_crypto_1 = require("@wireapp/core-crypto");
|
|
25
|
+
const protocol_messaging_1 = require("@wireapp/protocol-messaging");
|
|
26
|
+
const IncomingProposalsQueue_1 = require("./IncomingProposalsQueue");
|
|
24
27
|
const MLSService_1 = require("../../../MLSService/MLSService");
|
|
28
|
+
const logger = commons_1.LogFactory.getLogger('@wireapp/core/mls/messageAdd');
|
|
25
29
|
const handleMLSMessageAdd = async ({ event, groupId, mlsService, }) => {
|
|
26
30
|
const encryptedData = bazinga64_1.Decoder.fromBase64(event.data).asBytes;
|
|
27
31
|
const groupIdBytes = bazinga64_1.Decoder.fromBase64(groupId).asBytes;
|
|
28
|
-
const
|
|
32
|
+
const decryptedMessage = await mlsService.decryptMessage(new core_crypto_1.ConversationId(groupIdBytes), encryptedData);
|
|
33
|
+
if (!decryptedMessage) {
|
|
34
|
+
// If the message is not decrypted, we return null
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const { message, commitDelay, senderClientId: encodedSenderClientId } = decryptedMessage;
|
|
29
38
|
if (encodedSenderClientId) {
|
|
30
39
|
const decoder = new TextDecoder();
|
|
31
|
-
const senderClientId = decoder.decode((0, MLSService_1.optionalToUint8Array)(encodedSenderClientId));
|
|
40
|
+
const senderClientId = decoder.decode((0, MLSService_1.optionalToUint8Array)(encodedSenderClientId.copyBytes()));
|
|
32
41
|
event.senderClientId = senderClientId;
|
|
33
42
|
}
|
|
34
43
|
// Check if the message includes proposals
|
|
35
|
-
if (typeof commitDelay === 'number'
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
if (typeof commitDelay === 'number') {
|
|
45
|
+
(0, IncomingProposalsQueue_1.queueProposal)(async () => {
|
|
46
|
+
// we are dealing with a proposal, add a task to process this proposal later on
|
|
47
|
+
// Those proposals are stored inside of coreCrypto and will be handled after a timeout
|
|
48
|
+
await mlsService.handlePendingProposals({
|
|
49
|
+
groupId,
|
|
50
|
+
delayInMs: commitDelay ?? 0,
|
|
51
|
+
eventTime: event.time,
|
|
52
|
+
});
|
|
53
|
+
}).catch(error => {
|
|
54
|
+
logger.error('Failed to process proposal:', error);
|
|
42
55
|
});
|
|
43
56
|
}
|
|
44
|
-
if (hasEpochChanged) {
|
|
45
|
-
const newEpoch = await mlsService.getEpoch(groupId);
|
|
46
|
-
mlsService.emit('newEpoch', { groupId, epoch: newEpoch });
|
|
47
|
-
}
|
|
48
57
|
return message ? { event, decryptedData: protocol_messaging_1.GenericMessage.decode(message) } : null;
|
|
49
58
|
};
|
|
50
59
|
exports.handleMLSMessageAdd = handleMLSMessageAdd;
|
package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"welcomeMessage.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,2BAA2B,EAAC,MAAM,+BAA+B,CAAC;AAG1E,OAAO,EAAC,mBAAmB,EAAC,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"welcomeMessage.d.ts","sourceRoot":"","sources":["../../../../../../src/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,2BAA2B,EAAC,MAAM,+BAA+B,CAAC;AAG1E,OAAO,EAAC,mBAAmB,EAAC,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAC,UAAU,EAAmB,MAAM,qBAAqB,CAAC;AAEjE,UAAU,0BAA0B;IAClC,KAAK,EAAE,2BAA2B,CAAC;IACnC,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,eAAO,MAAM,uBAAuB,2BAGjC,0BAA0B,KAAG,OAAO,CAAC,mBAAmB,CAmB1D,CAAC"}
|
|
@@ -20,16 +20,19 @@
|
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.handleMLSWelcomeMessage = void 0;
|
|
22
22
|
const bazinga64_1 = require("bazinga64");
|
|
23
|
+
const MLSService_1 = require("../../../MLSService");
|
|
23
24
|
const handleMLSWelcomeMessage = async ({ mlsService, event, }) => {
|
|
24
25
|
const data = bazinga64_1.Decoder.fromBase64(event.data).asBytes;
|
|
25
26
|
// We extract the groupId from the welcome message and let coreCrypto store this group
|
|
26
27
|
const newGroupId = await mlsService.processWelcomeMessage(data);
|
|
27
|
-
const groupIdStr = bazinga64_1.Encoder.toBase64(newGroupId).asString;
|
|
28
|
+
const groupIdStr = bazinga64_1.Encoder.toBase64(newGroupId.copyBytes()).asString;
|
|
28
29
|
// The groupId can then be sent back to the consumer
|
|
29
30
|
// After we were added to the group we need to schedule a periodic key material renewal
|
|
30
31
|
await mlsService.scheduleKeyMaterialRenewal(groupIdStr);
|
|
32
|
+
// We also need to emit a NEW_EPOCH event to notify the rest of the system that we have joined a new group
|
|
31
33
|
const newEpoch = await mlsService.getEpoch(groupIdStr);
|
|
32
|
-
mlsService.emit(
|
|
34
|
+
mlsService.emit(MLSService_1.MLSServiceEvents.NEW_EPOCH, { groupId: groupIdStr, epoch: newEpoch });
|
|
35
|
+
mlsService.logger.info(`Joined MLS group with id ${groupIdStr} via welcome message, new epoch: ${newEpoch}`);
|
|
33
36
|
return {
|
|
34
37
|
event: { ...event, data: groupIdStr },
|
|
35
38
|
};
|
package/lib/messagingProtocols/mls/EventHandler/events/welcomeMessage/welcomeMessage.test.js
CHANGED
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
const event_1 = require("@wireapp/api-client/lib/event");
|
|
22
|
+
const core_crypto_1 = require("@wireapp/core-crypto");
|
|
22
23
|
const welcomeMessage_1 = require("./welcomeMessage");
|
|
24
|
+
const MLSService_1 = require("../../../MLSService");
|
|
23
25
|
jest.mock('bazinga64', () => ({
|
|
24
26
|
...jest.requireActual('bazinga64'),
|
|
25
27
|
Decoder: {
|
|
@@ -39,10 +41,15 @@ const mockParams = {
|
|
|
39
41
|
},
|
|
40
42
|
source: {},
|
|
41
43
|
mlsService: {
|
|
42
|
-
processWelcomeMessage: jest.fn().mockResolvedValue(
|
|
44
|
+
processWelcomeMessage: jest.fn().mockResolvedValue(new core_crypto_1.Welcome(Uint8Array.from([1, 2, 3]))),
|
|
43
45
|
scheduleKeyMaterialRenewal: jest.fn(),
|
|
44
46
|
getEpoch: jest.fn(),
|
|
45
47
|
emit: jest.fn(),
|
|
48
|
+
logger: {
|
|
49
|
+
info: jest.fn(),
|
|
50
|
+
warn: jest.fn(),
|
|
51
|
+
error: jest.fn(),
|
|
52
|
+
},
|
|
46
53
|
},
|
|
47
54
|
dryRun: false,
|
|
48
55
|
};
|
|
@@ -56,12 +63,15 @@ describe('MLS welcomeMessage eventHandler', () => {
|
|
|
56
63
|
it('returns a eventHandlerResult', async () => {
|
|
57
64
|
const eventHandlerResult = await (0, welcomeMessage_1.handleMLSWelcomeMessage)(mockParams);
|
|
58
65
|
expect(eventHandlerResult).toBeDefined();
|
|
59
|
-
expect(eventHandlerResult.event).toEqual({ data:
|
|
66
|
+
expect(eventHandlerResult.event).toEqual({ data: Uint8Array.from([1, 2, 3]), type: 'conversation.mls-welcome' });
|
|
60
67
|
});
|
|
61
68
|
it('emits new epoch event after processing a welcome message', async () => {
|
|
62
69
|
jest.spyOn(mockParams.mlsService, 'getEpoch').mockResolvedValue(1);
|
|
63
70
|
await (0, welcomeMessage_1.handleMLSWelcomeMessage)(mockParams);
|
|
64
|
-
expect(mockParams.mlsService.emit).toHaveBeenCalledWith(
|
|
71
|
+
expect(mockParams.mlsService.emit).toHaveBeenCalledWith(MLSService_1.MLSServiceEvents.NEW_EPOCH, {
|
|
72
|
+
groupId: Uint8Array.from([1, 2, 3]),
|
|
73
|
+
epoch: 1,
|
|
74
|
+
});
|
|
65
75
|
});
|
|
66
76
|
});
|
|
67
77
|
});
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { QualifiedId } from '@wireapp/api-client/lib/user';
|
|
2
|
+
import { CoreCryptoError, ErrorContext, ErrorType, MlsErrorType } from '@wireapp/core-crypto';
|
|
1
3
|
export declare const CORE_CRYPTO_ERROR_NAMES: {
|
|
2
4
|
MlsErrorConversationAlreadyExists: string;
|
|
3
5
|
MlsErrorDuplicateMessage: string;
|
|
@@ -11,10 +13,44 @@ export declare const CORE_CRYPTO_ERROR_NAMES: {
|
|
|
11
13
|
ProteusErrorSessionNotFound: string;
|
|
12
14
|
ProteusErrorRemoteIdentityChanged: string;
|
|
13
15
|
MlsErrorWrongEpoch: string;
|
|
14
|
-
MlsErrorOrphanWelcomeMessage: string;
|
|
15
16
|
};
|
|
16
17
|
export declare const isCoreCryptoMLSWrongEpochError: (error: unknown) => boolean;
|
|
17
18
|
export declare const isCoreCryptoMLSConversationAlreadyExistsError: (error: unknown) => boolean;
|
|
18
|
-
export declare const isCoreCryptoMLSOrphanWelcomeMessageError: (error: unknown) => boolean;
|
|
19
19
|
export declare const shouldMLSDecryptionErrorBeIgnored: (error: unknown) => error is Error;
|
|
20
|
+
export declare const UPLOAD_COMMIT_BUNDLE_ABORT_REASONS: {
|
|
21
|
+
BROKEN_MLS_CONVERSATION: string;
|
|
22
|
+
MLS_STALE_MESSAGE: string;
|
|
23
|
+
MLS_GROUP_OUT_OF_SYNC: string;
|
|
24
|
+
OTHER: string;
|
|
25
|
+
};
|
|
26
|
+
export type ConversationAlreadyExistsError = CoreCryptoError<ErrorType.Mls> & {
|
|
27
|
+
context: Extract<ErrorContext[ErrorType.Mls], {
|
|
28
|
+
type: MlsErrorType.ConversationAlreadyExists;
|
|
29
|
+
}>;
|
|
30
|
+
};
|
|
31
|
+
type MessageRejectedError = CoreCryptoError<ErrorType.Mls> & {
|
|
32
|
+
context: Extract<ErrorContext[ErrorType.Mls], {
|
|
33
|
+
type: MlsErrorType.MessageRejected;
|
|
34
|
+
}>;
|
|
35
|
+
};
|
|
36
|
+
export declare function isBrokenMLSConversationError(error: unknown): error is MessageRejectedError;
|
|
37
|
+
export declare function isMLSStaleMessageError(error: unknown): error is MessageRejectedError;
|
|
38
|
+
export declare function isMLSGroupOutOfSyncError(error: unknown): error is MessageRejectedError;
|
|
39
|
+
export declare function getMLSGroupOutOfSyncErrorMissingUsers(error: unknown): QualifiedId[];
|
|
40
|
+
type AbortReasonBrokenMLSConversation = {
|
|
41
|
+
message: typeof UPLOAD_COMMIT_BUNDLE_ABORT_REASONS.BROKEN_MLS_CONVERSATION;
|
|
42
|
+
};
|
|
43
|
+
type AbortReasonMLSStaleMessage = {
|
|
44
|
+
message: typeof UPLOAD_COMMIT_BUNDLE_ABORT_REASONS.MLS_STALE_MESSAGE;
|
|
45
|
+
};
|
|
46
|
+
type AbortReasonMLSGroupOutOfSync = {
|
|
47
|
+
message: typeof UPLOAD_COMMIT_BUNDLE_ABORT_REASONS.MLS_GROUP_OUT_OF_SYNC;
|
|
48
|
+
missing_users: QualifiedId[];
|
|
49
|
+
};
|
|
50
|
+
type AbortReasonOther = {
|
|
51
|
+
message: typeof UPLOAD_COMMIT_BUNDLE_ABORT_REASONS.OTHER;
|
|
52
|
+
};
|
|
53
|
+
type AbortReasons = AbortReasonBrokenMLSConversation | AbortReasonMLSStaleMessage | AbortReasonMLSGroupOutOfSync | AbortReasonOther;
|
|
54
|
+
export declare function serializeAbortReason(reason: AbortReasons): string;
|
|
55
|
+
export {};
|
|
20
56
|
//# sourceMappingURL=CoreCryptoMLSError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CoreCryptoMLSError.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/MLSService/CoreCryptoMLSError.ts"],"names":[],"mappings":"AAmBA,eAAO,MAAM,uBAAuB
|
|
1
|
+
{"version":3,"file":"CoreCryptoMLSError.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/MLSService/CoreCryptoMLSError.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAEzD,OAAO,EAAC,eAAe,EAAE,YAAY,EAAE,SAAS,EAA6B,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAEvH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;CAanC,CAAC;AAEF,eAAO,MAAM,8BAA8B,UAAW,OAAO,KAAG,OAE/D,CAAC;AAEF,eAAO,MAAM,6CAA6C,UAAW,OAAO,KAAG,OAE9E,CAAC;AAoBF,eAAO,MAAM,iCAAiC,UAAW,OAAO,KAAG,KAAK,IAAI,KAI3E,CAAC;AAEF,eAAO,MAAM,kCAAkC;;;;;CAK9C,CAAC;AAEF,MAAM,MAAM,8BAA8B,GAAG,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG;IAC5E,OAAO,EAAE,OAAO,CACd,YAAY,CAAC,SAAS,CAAC,GAAG,CAAC,EAC3B;QACE,IAAI,EAAE,YAAY,CAAC,yBAAyB,CAAC;KAC9C,CACF,CAAC;CACH,CAAC;AAEF,KAAK,oBAAoB,GAAG,eAAe,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG;IAC3D,OAAO,EAAE,OAAO,CACd,YAAY,CAAC,SAAS,CAAC,GAAG,CAAC,EAC3B;QACE,IAAI,EAAE,YAAY,CAAC,eAAe,CAAC;KACpC,CACF,CAAC;CACH,CAAC;AAEF,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB,CAM1F;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB,CAMpF;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,oBAAoB,CAMtF;AAED,wBAAgB,qCAAqC,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,EAAE,CAOnF;AAED,KAAK,gCAAgC,GAAG;IACtC,OAAO,EAAE,OAAO,kCAAkC,CAAC,uBAAuB,CAAC;CAC5E,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAChC,OAAO,EAAE,OAAO,kCAAkC,CAAC,iBAAiB,CAAC;CACtE,CAAC;AAEF,KAAK,4BAA4B,GAAG;IAClC,OAAO,EAAE,OAAO,kCAAkC,CAAC,qBAAqB,CAAC;IACzE,aAAa,EAAE,WAAW,EAAE,CAAC;CAC9B,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,OAAO,EAAE,OAAO,kCAAkC,CAAC,KAAK,CAAC;CAC1D,CAAC;AAEF,KAAK,YAAY,GACb,gCAAgC,GAChC,0BAA0B,GAC1B,4BAA4B,GAC5B,gBAAgB,CAAC;AAErB,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAEjE"}
|
|
@@ -18,7 +18,13 @@
|
|
|
18
18
|
*
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.
|
|
21
|
+
exports.UPLOAD_COMMIT_BUNDLE_ABORT_REASONS = exports.shouldMLSDecryptionErrorBeIgnored = exports.isCoreCryptoMLSConversationAlreadyExistsError = exports.isCoreCryptoMLSWrongEpochError = exports.CORE_CRYPTO_ERROR_NAMES = void 0;
|
|
22
|
+
exports.isBrokenMLSConversationError = isBrokenMLSConversationError;
|
|
23
|
+
exports.isMLSStaleMessageError = isMLSStaleMessageError;
|
|
24
|
+
exports.isMLSGroupOutOfSyncError = isMLSGroupOutOfSyncError;
|
|
25
|
+
exports.getMLSGroupOutOfSyncErrorMissingUsers = getMLSGroupOutOfSyncErrorMissingUsers;
|
|
26
|
+
exports.serializeAbortReason = serializeAbortReason;
|
|
27
|
+
const core_crypto_1 = require("@wireapp/core-crypto");
|
|
22
28
|
exports.CORE_CRYPTO_ERROR_NAMES = {
|
|
23
29
|
MlsErrorConversationAlreadyExists: 'MlsErrorConversationAlreadyExists',
|
|
24
30
|
MlsErrorDuplicateMessage: 'MlsErrorDuplicateMessage',
|
|
@@ -32,7 +38,6 @@ exports.CORE_CRYPTO_ERROR_NAMES = {
|
|
|
32
38
|
ProteusErrorSessionNotFound: 'ProteusErrorSessionNotFound',
|
|
33
39
|
ProteusErrorRemoteIdentityChanged: 'ProteusErrorRemoteIdentityChanged',
|
|
34
40
|
MlsErrorWrongEpoch: 'MlsErrorWrongEpoch',
|
|
35
|
-
MlsErrorOrphanWelcomeMessage: 'MlsErrorOrphanWelcomeMessage',
|
|
36
41
|
};
|
|
37
42
|
const isCoreCryptoMLSWrongEpochError = (error) => {
|
|
38
43
|
return error instanceof Error && error.name === exports.CORE_CRYPTO_ERROR_NAMES.MlsErrorWrongEpoch;
|
|
@@ -42,10 +47,6 @@ const isCoreCryptoMLSConversationAlreadyExistsError = (error) => {
|
|
|
42
47
|
return error instanceof Error && error.name === exports.CORE_CRYPTO_ERROR_NAMES.MlsErrorConversationAlreadyExists;
|
|
43
48
|
};
|
|
44
49
|
exports.isCoreCryptoMLSConversationAlreadyExistsError = isCoreCryptoMLSConversationAlreadyExistsError;
|
|
45
|
-
const isCoreCryptoMLSOrphanWelcomeMessageError = (error) => {
|
|
46
|
-
return error instanceof Error && error.name === exports.CORE_CRYPTO_ERROR_NAMES.MlsErrorOrphanWelcomeMessage;
|
|
47
|
-
};
|
|
48
|
-
exports.isCoreCryptoMLSOrphanWelcomeMessageError = isCoreCryptoMLSOrphanWelcomeMessageError;
|
|
49
50
|
const mlsDecryptionErrorNamesToIgnore = [
|
|
50
51
|
exports.CORE_CRYPTO_ERROR_NAMES.MlsErrorStaleCommit,
|
|
51
52
|
exports.CORE_CRYPTO_ERROR_NAMES.MlsErrorStaleProposal,
|
|
@@ -64,3 +65,37 @@ const shouldMLSDecryptionErrorBeIgnored = (error) => {
|
|
|
64
65
|
return (error instanceof Error && (mlsDecryptionErrorNamesToIgnore.includes(error.name) || isOtherErrorToIgnore(error)));
|
|
65
66
|
};
|
|
66
67
|
exports.shouldMLSDecryptionErrorBeIgnored = shouldMLSDecryptionErrorBeIgnored;
|
|
68
|
+
exports.UPLOAD_COMMIT_BUNDLE_ABORT_REASONS = {
|
|
69
|
+
BROKEN_MLS_CONVERSATION: 'BROKEN_MLS_CONVERSATION',
|
|
70
|
+
MLS_STALE_MESSAGE: 'MLS_STALE_MESSAGE',
|
|
71
|
+
MLS_GROUP_OUT_OF_SYNC: 'MLS_GROUP_OUT_OF_SYNC',
|
|
72
|
+
OTHER: 'OTHER',
|
|
73
|
+
};
|
|
74
|
+
function isBrokenMLSConversationError(error) {
|
|
75
|
+
return ((0, core_crypto_1.isMlsMessageRejectedError)(error) &&
|
|
76
|
+
deserializeAbortReason(error.context.context.reason).message ===
|
|
77
|
+
exports.UPLOAD_COMMIT_BUNDLE_ABORT_REASONS.BROKEN_MLS_CONVERSATION);
|
|
78
|
+
}
|
|
79
|
+
function isMLSStaleMessageError(error) {
|
|
80
|
+
return ((0, core_crypto_1.isMlsMessageRejectedError)(error) &&
|
|
81
|
+
deserializeAbortReason(error.context.context.reason).message ===
|
|
82
|
+
exports.UPLOAD_COMMIT_BUNDLE_ABORT_REASONS.MLS_STALE_MESSAGE);
|
|
83
|
+
}
|
|
84
|
+
function isMLSGroupOutOfSyncError(error) {
|
|
85
|
+
return ((0, core_crypto_1.isMlsMessageRejectedError)(error) &&
|
|
86
|
+
deserializeAbortReason(error.context.context.reason).message ===
|
|
87
|
+
exports.UPLOAD_COMMIT_BUNDLE_ABORT_REASONS.MLS_GROUP_OUT_OF_SYNC);
|
|
88
|
+
}
|
|
89
|
+
function getMLSGroupOutOfSyncErrorMissingUsers(error) {
|
|
90
|
+
if (isMLSGroupOutOfSyncError(error)) {
|
|
91
|
+
const reason = deserializeAbortReason(error.context.context.reason);
|
|
92
|
+
return reason.missing_users;
|
|
93
|
+
}
|
|
94
|
+
throw new Error('Error is not MLSGroupOutOfSyncError');
|
|
95
|
+
}
|
|
96
|
+
function serializeAbortReason(reason) {
|
|
97
|
+
return JSON.stringify(reason);
|
|
98
|
+
}
|
|
99
|
+
function deserializeAbortReason(reasonString) {
|
|
100
|
+
return JSON.parse(reasonString);
|
|
101
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CoreCryptoMLSError.test.d.ts","sourceRoot":"","sources":["../../../../src/messagingProtocols/mls/MLSService/CoreCryptoMLSError.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Wire
|
|
4
|
+
* Copyright (C) 2025 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 core_crypto_1 = require("@wireapp/core-crypto");
|
|
22
|
+
const CoreCryptoMLSError_1 = require("./CoreCryptoMLSError");
|
|
23
|
+
describe('CoreCryptoMLSError helpers', () => {
|
|
24
|
+
describe('epoch and conversation existence guards', () => {
|
|
25
|
+
it('detects MlsErrorWrongEpoch by name', () => {
|
|
26
|
+
const err = new Error('wrong epoch');
|
|
27
|
+
err.name = CoreCryptoMLSError_1.CORE_CRYPTO_ERROR_NAMES.MlsErrorWrongEpoch;
|
|
28
|
+
expect((0, CoreCryptoMLSError_1.isCoreCryptoMLSWrongEpochError)(err)).toBe(true);
|
|
29
|
+
const other = new Error('nope');
|
|
30
|
+
expect((0, CoreCryptoMLSError_1.isCoreCryptoMLSWrongEpochError)(other)).toBe(false);
|
|
31
|
+
expect((0, CoreCryptoMLSError_1.isCoreCryptoMLSWrongEpochError)('not-an-error')).toBe(false);
|
|
32
|
+
});
|
|
33
|
+
it('detects MlsErrorConversationAlreadyExists by name', () => {
|
|
34
|
+
const err = new Error('already exists');
|
|
35
|
+
err.name = CoreCryptoMLSError_1.CORE_CRYPTO_ERROR_NAMES.MlsErrorConversationAlreadyExists;
|
|
36
|
+
expect((0, CoreCryptoMLSError_1.isCoreCryptoMLSConversationAlreadyExistsError)(err)).toBe(true);
|
|
37
|
+
const other = new Error('nope');
|
|
38
|
+
expect((0, CoreCryptoMLSError_1.isCoreCryptoMLSConversationAlreadyExistsError)(other)).toBe(false);
|
|
39
|
+
expect((0, CoreCryptoMLSError_1.isCoreCryptoMLSConversationAlreadyExistsError)(42)).toBe(false);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
describe('shouldMLSDecryptionErrorBeIgnored', () => {
|
|
43
|
+
const namesToIgnore = [
|
|
44
|
+
CoreCryptoMLSError_1.CORE_CRYPTO_ERROR_NAMES.MlsErrorStaleCommit,
|
|
45
|
+
CoreCryptoMLSError_1.CORE_CRYPTO_ERROR_NAMES.MlsErrorStaleProposal,
|
|
46
|
+
CoreCryptoMLSError_1.CORE_CRYPTO_ERROR_NAMES.MlsErrorDuplicateMessage,
|
|
47
|
+
CoreCryptoMLSError_1.CORE_CRYPTO_ERROR_NAMES.MlsErrorBufferedFutureMessage,
|
|
48
|
+
CoreCryptoMLSError_1.CORE_CRYPTO_ERROR_NAMES.MlsErrorUnmergedPendingGroup,
|
|
49
|
+
];
|
|
50
|
+
it('returns true for known ignorable error names', () => {
|
|
51
|
+
for (const name of namesToIgnore) {
|
|
52
|
+
const err = new Error('ignore me');
|
|
53
|
+
err.name = name;
|
|
54
|
+
expect((0, CoreCryptoMLSError_1.shouldMLSDecryptionErrorBeIgnored)(err)).toBe(true);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
it('returns true for generic MlsErrorOther with expected commit/proposals message', () => {
|
|
58
|
+
const err = new Error('Incoming message is a commit for which we have not yet received all the proposals: details...');
|
|
59
|
+
err.name = CoreCryptoMLSError_1.CORE_CRYPTO_ERROR_NAMES.MlsErrorOther;
|
|
60
|
+
expect((0, CoreCryptoMLSError_1.shouldMLSDecryptionErrorBeIgnored)(err)).toBe(true);
|
|
61
|
+
});
|
|
62
|
+
it('returns false for other errors or non-Error values', () => {
|
|
63
|
+
const err = new Error('some real failure');
|
|
64
|
+
err.name = 'RandomErrorName';
|
|
65
|
+
expect((0, CoreCryptoMLSError_1.shouldMLSDecryptionErrorBeIgnored)(err)).toBe(false);
|
|
66
|
+
expect((0, CoreCryptoMLSError_1.shouldMLSDecryptionErrorBeIgnored)('not-an-error')).toBe(false);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
describe('abort reason based guards', () => {
|
|
70
|
+
function makeRejectedError(reason) {
|
|
71
|
+
return {
|
|
72
|
+
type: core_crypto_1.ErrorType.Mls,
|
|
73
|
+
context: {
|
|
74
|
+
type: core_crypto_1.MlsErrorType.MessageRejected,
|
|
75
|
+
context: {
|
|
76
|
+
reason,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
it('detects broken MLS conversation errors', () => {
|
|
82
|
+
const err = makeRejectedError((0, CoreCryptoMLSError_1.serializeAbortReason)({ message: CoreCryptoMLSError_1.UPLOAD_COMMIT_BUNDLE_ABORT_REASONS.BROKEN_MLS_CONVERSATION }));
|
|
83
|
+
expect((0, CoreCryptoMLSError_1.isBrokenMLSConversationError)(err)).toBe(true);
|
|
84
|
+
expect((0, CoreCryptoMLSError_1.isMLSStaleMessageError)(err)).toBe(false);
|
|
85
|
+
expect((0, CoreCryptoMLSError_1.isMLSGroupOutOfSyncError)(err)).toBe(false);
|
|
86
|
+
});
|
|
87
|
+
it('detects MLS stale message errors', () => {
|
|
88
|
+
const err = makeRejectedError((0, CoreCryptoMLSError_1.serializeAbortReason)({ message: CoreCryptoMLSError_1.UPLOAD_COMMIT_BUNDLE_ABORT_REASONS.MLS_STALE_MESSAGE }));
|
|
89
|
+
expect((0, CoreCryptoMLSError_1.isMLSStaleMessageError)(err)).toBe(true);
|
|
90
|
+
expect((0, CoreCryptoMLSError_1.isBrokenMLSConversationError)(err)).toBe(false);
|
|
91
|
+
expect((0, CoreCryptoMLSError_1.isMLSGroupOutOfSyncError)(err)).toBe(false);
|
|
92
|
+
});
|
|
93
|
+
it('detects MLS group out-of-sync errors and exposes missing users', () => {
|
|
94
|
+
const missing = [
|
|
95
|
+
{ id: 'u1', domain: 'example.com' },
|
|
96
|
+
{ id: 'u2', domain: 'example.com' },
|
|
97
|
+
];
|
|
98
|
+
const err = makeRejectedError((0, CoreCryptoMLSError_1.serializeAbortReason)({
|
|
99
|
+
message: CoreCryptoMLSError_1.UPLOAD_COMMIT_BUNDLE_ABORT_REASONS.MLS_GROUP_OUT_OF_SYNC,
|
|
100
|
+
missing_users: missing,
|
|
101
|
+
}));
|
|
102
|
+
expect((0, CoreCryptoMLSError_1.isMLSGroupOutOfSyncError)(err)).toBe(true);
|
|
103
|
+
expect((0, CoreCryptoMLSError_1.getMLSGroupOutOfSyncErrorMissingUsers)(err)).toEqual(missing);
|
|
104
|
+
});
|
|
105
|
+
it('throws when getting missing users from non-MLSGroupOutOfSync error', () => {
|
|
106
|
+
const err = makeRejectedError((0, CoreCryptoMLSError_1.serializeAbortReason)({ message: CoreCryptoMLSError_1.UPLOAD_COMMIT_BUNDLE_ABORT_REASONS.MLS_STALE_MESSAGE }));
|
|
107
|
+
expect(() => (0, CoreCryptoMLSError_1.getMLSGroupOutOfSyncErrorMissingUsers)(err)).toThrow('Error is not MLSGroupOutOfSyncError');
|
|
108
|
+
});
|
|
109
|
+
it('returns false for non-mls message rejected errors', () => {
|
|
110
|
+
const err = {
|
|
111
|
+
type: core_crypto_1.ErrorType.Mls,
|
|
112
|
+
context: {
|
|
113
|
+
type: core_crypto_1.MlsErrorType.Other,
|
|
114
|
+
context: {
|
|
115
|
+
reason: (0, CoreCryptoMLSError_1.serializeAbortReason)({ message: CoreCryptoMLSError_1.UPLOAD_COMMIT_BUNDLE_ABORT_REASONS.MLS_STALE_MESSAGE }),
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
expect((0, CoreCryptoMLSError_1.isBrokenMLSConversationError)(err)).toBe(false);
|
|
120
|
+
expect((0, CoreCryptoMLSError_1.isMLSStaleMessageError)(err)).toBe(false);
|
|
121
|
+
expect((0, CoreCryptoMLSError_1.isMLSGroupOutOfSyncError)(err)).toBe(false);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
});
|