diff --git a/package.json b/package.json index 401e1957d04..d295ce145e0 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "@lexical/react": "0.12.5", "@wireapp/avs": "9.6.12", "@wireapp/commons": "5.2.7", - "@wireapp/core": "46.0.4", + "@wireapp/core": "46.0.5", "@wireapp/react-ui-kit": "9.16.4", "@wireapp/store-engine-dexie": "2.1.8", "@wireapp/webapp-events": "0.20.1", diff --git a/src/__mocks__/@wireapp/core.ts b/src/__mocks__/@wireapp/core.ts index 9ed5a5d9b08..dfccf5a7c65 100644 --- a/src/__mocks__/@wireapp/core.ts +++ b/src/__mocks__/@wireapp/core.ts @@ -31,6 +31,9 @@ export class Account extends EventEmitter { cancelTask: jest.fn(), }; + get hasMLSDevice() { + return true; + } configureMLSCallbacks = jest.fn(); enrollE2EI = jest.fn(); service = { diff --git a/src/script/conversation/ConversationVerificationStateHandler/MLS/MLSStateHandler.test.ts b/src/script/conversation/ConversationVerificationStateHandler/MLS/MLSStateHandler.test.ts index 729c36376c9..d91d31abb3f 100644 --- a/src/script/conversation/ConversationVerificationStateHandler/MLS/MLSStateHandler.test.ts +++ b/src/script/conversation/ConversationVerificationStateHandler/MLS/MLSStateHandler.test.ts @@ -33,7 +33,7 @@ import {ConversationVerificationState} from '../../ConversationVerificationState describe('MLSConversationVerificationStateHandler', () => { const conversationState = new ConversationState(); - let core = new Core(); + let core: Core; const groupId = 'AAEAAKA0LuGtiU7NjqqlZIE2dQUAZWxuYS53aXJlLmxpbms='; const conversation = new Conversation(createUuid(), '', ConversationProtocol.MLS); conversationState.conversations.push(conversation); @@ -73,6 +73,20 @@ describe('MLSConversationVerificationStateHandler', () => { expect(core.service?.mls?.on).not.toHaveBeenCalled(); }); + it('should do nothing if the user does not have an mls device', () => { + jest.spyOn(core, 'hasMLSDevice', 'get').mockReturnValue(false); + + new MLSConversationVerificationStateHandler( + 'domain', + () => {}, + async () => {}, + conversationState, + core, + ); + + expect(core.service?.mls?.on).not.toHaveBeenCalled(); + }); + describe('checkConversationVerificationState', () => { it('should reset to unverified if mls group does not exist anymore', async () => { let triggerEpochChange: Function = () => {}; diff --git a/src/script/conversation/ConversationVerificationStateHandler/MLS/MLSStateHandler.ts b/src/script/conversation/ConversationVerificationStateHandler/MLS/MLSStateHandler.ts index 971227358b4..4ed2ae3f1c1 100644 --- a/src/script/conversation/ConversationVerificationStateHandler/MLS/MLSStateHandler.ts +++ b/src/script/conversation/ConversationVerificationStateHandler/MLS/MLSStateHandler.ts @@ -57,13 +57,13 @@ export class MLSConversationVerificationStateHandler { private readonly core: Core, ) { this.logger = getLogger('MLSConversationVerificationStateHandler'); - // We need to check if the core service is available and if the e2eIdentity is available - if (!this.core.service?.mls || !this.core.service?.e2eIdentity) { + // We need to check if the core account has a valid MLS device and that e2ei is enabled + if (!this.core.hasMLSDevice || !this.core.service?.e2eIdentity) { return; } // We hook into the newEpoch event of the MLS service to check if the conversation needs to be verified or degraded - this.core.service.mls.on('newEpoch', this.onEpochChanged); + this.core.service?.mls?.on('newEpoch', this.onEpochChanged); this.core.service.e2eIdentity.on('crlChanged', ({domain}) => this.handleNewRevocationList(domain)); } diff --git a/src/script/main/app.ts b/src/script/main/app.ts index 00eca6383e2..0768374052f 100644 --- a/src/script/main/app.ts +++ b/src/script/main/app.ts @@ -40,7 +40,7 @@ import {getLogger, Logger} from 'Util/Logger'; import {includesString} from 'Util/StringUtil'; import {TIME_IN_MILLIS} from 'Util/TimeUtil'; import {appendParameter} from 'Util/UrlUtil'; -import {checkIndexedDb, supportsMLS} from 'Util/util'; +import {checkIndexedDb} from 'Util/util'; import '../../style/default.less'; import {AssetRepository} from '../assets/AssetRepository'; @@ -443,7 +443,7 @@ export class App { // We load all the users the self user is connected with await userRepository.loadUsers(selfUser, connections, conversations, teamMembers); - if (supportsMLS()) { + if (this.core.hasMLSDevice) { //if mls is supported, we need to initialize the callbacks (they are used when decrypting messages) conversationRepository.initMLSConversationRecoveredListener(); conversationRepository.registerMLSConversationVerificationStateHandler( @@ -472,7 +472,7 @@ export class App { await conversationRepository.init1To1Conversations(connections, conversations); - if (supportsMLS()) { + if (this.core.hasMLSDevice) { //add the potential `self` and `team` conversations await initialiseSelfAndTeamConversations(conversations, selfUser, clientEntity.id, this.core); diff --git a/yarn.lock b/yarn.lock index bf5db8624df..4548b437f21 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4763,9 +4763,9 @@ __metadata: languageName: node linkType: hard -"@wireapp/core@npm:46.0.4": - version: 46.0.4 - resolution: "@wireapp/core@npm:46.0.4" +"@wireapp/core@npm:46.0.5": + version: 46.0.5 + resolution: "@wireapp/core@npm:46.0.5" dependencies: "@wireapp/api-client": ^27.0.1 "@wireapp/commons": ^5.2.7 @@ -4785,7 +4785,7 @@ __metadata: long: ^5.2.0 uuidjs: 4.2.13 zod: 3.23.4 - checksum: 15a9d8a9a7ddbdc220dba21a22a80fc20f93793717947c1a2a802266659d6adfe27c3904064dc592aac88858e4a8a9abe6e3ba90e4cdd714db3074cc9fb25c56 + checksum: f78001b45cdac85c4a3918a60f9d4c06b82e9f750f64b60789c1f196830d27fb9eca37ede190ca8bcd9ee96c5a019cdf3b5f2a9f3c0700726efd19cbd18e3f60 languageName: node linkType: hard @@ -17457,7 +17457,7 @@ __metadata: "@wireapp/avs": 9.6.12 "@wireapp/commons": 5.2.7 "@wireapp/copy-config": 2.1.14 - "@wireapp/core": 46.0.4 + "@wireapp/core": 46.0.5 "@wireapp/eslint-config": 3.0.5 "@wireapp/prettier-config": 0.6.3 "@wireapp/react-ui-kit": 9.16.4