Skip to content

Commit

Permalink
runfix: Remove E2EI feature flag (#16818)
Browse files Browse the repository at this point in the history
  • Loading branch information
atomrc committed Feb 13, 2024
1 parent 5351502 commit 25bcaf9
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 47 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@peculiar/x509": "1.9.7",
"@wireapp/avs": "9.6.9",
"@wireapp/commons": "5.2.5",
"@wireapp/core": "43.14.3",
"@wireapp/core": "44.0.0",
"@wireapp/react-ui-kit": "9.15.1",
"@wireapp/store-engine-dexie": "2.1.7",
"@wireapp/webapp-events": "0.20.1",
Expand Down
1 change: 0 additions & 1 deletion server/config/client.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export function generateConfig(params: ConfigGeneratorParams, env: Env) {
ENABLE_EXTRA_CLIENT_ENTROPY: env.FEATURE_ENABLE_EXTRA_CLIENT_ENTROPY == 'true',
ENABLE_MEDIA_EMBEDS: env.FEATURE_ENABLE_MEDIA_EMBEDS != 'false',
ENABLE_MLS: env.FEATURE_ENABLE_MLS == 'true',
ENABLE_E2EI: env.FEATURE_ENABLE_MLS == 'true' && env.FEATURE_ENABLE_E2EI == 'true',
ENABLE_PHONE_LOGIN: env.FEATURE_ENABLE_PHONE_LOGIN != 'false',
ENABLE_PROTEUS_CORE_CRYPTO: env.FEATURE_ENABLE_PROTEUS_CORE_CRYPTO == 'true',
ENABLE_SSO: env.FEATURE_ENABLE_SSO == 'true',
Expand Down
3 changes: 0 additions & 3 deletions server/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ export type Env = {
/** will enable the MLS protocol */
FEATURE_ENABLE_MLS?: string;

/** will enable the E2E-Identification protocol, needs active FEATURE_ENABLE_MLS to work */
FEATURE_ENABLE_E2EI?: string;

FEATURE_USE_CORE_CRYPTO?: string;

FEATURE_MLS_CONFIG_KEYING_MATERIAL_UPDATE_THRESHOLD?: string;
Expand Down
4 changes: 1 addition & 3 deletions src/script/E2EIdentity/E2EIdentityEnrollment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {TimeInMillis} from '@wireapp/commons/lib/util/TimeUtil';
import {container} from 'tsyringe';

import {PrimaryModal} from 'Components/Modals/PrimaryModal';
import {Config} from 'src/script/Config';
import {Core} from 'src/script/service/CoreSingleton';
import {UserState} from 'src/script/user/UserState';
import {getCertificateDetails} from 'Util/certificateDetails';
Expand Down Expand Up @@ -95,9 +94,8 @@ describe('E2EIHandler', () => {
// Clear all mocks before each test
jest.clearAllMocks();

// Mock the Config service to return true for ENABLE_E2EI
// Mock the Config to enable e2eIdentity
(util.supportsMLS as jest.Mock).mockReturnValue(true);
Config.getConfig = jest.fn().mockReturnValue({FEATURE: {ENABLE_E2EI: true}});

jest.spyOn(PrimaryModal, 'show');

Expand Down
9 changes: 8 additions & 1 deletion src/script/auth/module/action/ClientAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import {ClientInfo} from '@wireapp/core/lib/client/';

import {Runtime} from '@wireapp/commons';

import {getE2EIConfig} from 'src/script/page/components/FeatureConfigChange/FeatureConfigChangeHandler/Features/E2EIdentity';

import {ClientActionCreator} from './creator/';

import * as StringUtil from '../../util/stringUtil';
Expand Down Expand Up @@ -62,7 +64,11 @@ export class ClientAction {
entropyData?: Uint8Array,
): ThunkAction => {
return async (dispatch, getState, {core, actions: {clientAction}}) => {
const localClient = await core.initClient();
const teamConfig = (await core.service?.team.getTeamFeatureConfig()) ?? {};
const hasE2EIEnabled = !!getE2EIConfig(teamConfig);

const localClient = await core.getLocalClient();

const creationStatus = localClient
? {isNew: false, client: localClient}
: {
Expand All @@ -74,6 +80,7 @@ export class ClientAction {
),
};

await core.initClient(creationStatus.client, hasE2EIEnabled);
dispatch(ClientActionCreator.successfulInitializeClient(creationStatus));
};
};
Expand Down
17 changes: 11 additions & 6 deletions src/script/main/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ import {joinConversationsAfterMigrationFinalisation} from '../mls/MLSMigration/m
import {NotificationRepository} from '../notification/NotificationRepository';
import {PreferenceNotificationRepository} from '../notification/PreferenceNotificationRepository';
import {configureDownloadPath} from '../page/components/FeatureConfigChange/FeatureConfigChangeHandler/Features/downloadPath';
import {configureE2EI} from '../page/components/FeatureConfigChange/FeatureConfigChangeHandler/Features/E2EIdentity';
import {
configureE2EI,
getE2EIConfig,
} from '../page/components/FeatureConfigChange/FeatureConfigChangeHandler/Features/E2EIdentity';
import {PermissionRepository} from '../permission/PermissionRepository';
import {PropertiesRepository} from '../properties/PropertiesRepository';
import {PropertiesService} from '../properties/PropertiesService';
Expand Down Expand Up @@ -377,11 +380,6 @@ export class App {
this.logger.error(`Error when initializing core: "${errorMessage}"`, error);
throw new AccessTokenError(AccessTokenError.TYPE.REQUEST_FORBIDDEN, 'Session has expired');
}
const localClient = await this.core.initClient();
if (!localClient) {
throw new ClientError(CLIENT_ERROR_TYPE.NO_VALID_CLIENT, 'Client has been deleted on backend');
}

this.core.on(CoreEvents.NEW_SESSION, ({userId, clientId}) => {
const newClient = {class: ClientClassification.UNKNOWN, id: clientId};
userRepository.addClientToUser(userId, newClient, true);
Expand All @@ -390,6 +388,13 @@ export class App {
const selfUser = await this.initiateSelfUser();

const {features: teamFeatures, members: teamMembers} = await teamRepository.initTeam(selfUser.teamId);
const willEnrollE2ei = getE2EIConfig(teamFeatures) !== undefined;
const localClient = await this.core.getLocalClient();
if (!localClient) {
throw new ClientError(CLIENT_ERROR_TYPE.NO_VALID_CLIENT, 'Client has been deleted on backend');
}
await this.core.initClient(localClient, willEnrollE2ei);

const e2eiHandler = await configureE2EI(this.logger, teamFeatures);
configureDownloadPath(teamFeatures);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,48 @@

import {FeatureStatus, FEATURE_KEY, FeatureList} from '@wireapp/api-client/lib/team';

import {Config} from 'src/script/Config';
import {E2EIHandler} from 'src/script/E2EIdentity';
import {Logger} from 'Util/Logger';
import {supportsMLS} from 'Util/util';

import {hasE2EIVerificationExpiration, hasMLSDefaultProtocol} from '../../../../../guards/Protocol';

export const configureE2EI = (logger: Logger, config: FeatureList): undefined | Promise<E2EIHandler> => {
export const getE2EIConfig = (config: FeatureList): FeatureList[FEATURE_KEY.MLSE2EID] | undefined => {
if (!supportsMLS()) {
return undefined;
}

const e2eiConfig = config[FEATURE_KEY.MLSE2EID];
const mlsConfig = config[FEATURE_KEY.MLS];
// Check if MLS or MLS E2EIdentity feature is existent
if (!hasE2EIVerificationExpiration(e2eiConfig) || !hasMLSDefaultProtocol(mlsConfig)) {
return undefined;
}

if (!supportsMLS() || !Config.getConfig().FEATURE.ENABLE_E2EI) {
// Check if E2EIdentity feature is enabled
if (e2eiConfig?.status !== FeatureStatus.ENABLED) {
return undefined;
}

// Check if E2EIdentity feature is enabled
if (e2eiConfig?.status === FeatureStatus.ENABLED) {
// Check if MLS feature is enabled
if (mlsConfig?.status !== FeatureStatus.ENABLED) {
logger.info('Warning: E2EIdentity feature enabled but MLS feature is not active');
return undefined;
}
// Check if E2EIdentity feature has a server discoveryUrl
if (!e2eiConfig.config || !e2eiConfig.config.acmeDiscoveryUrl || e2eiConfig.config.acmeDiscoveryUrl.length <= 0) {
logger.info('Warning: E2EIdentity feature enabled but no discoveryUrl provided');
return undefined;
}

// Either get the current E2EIdentity handler instance or create a new one
return E2EIHandler.getInstance().initialize({
discoveryUrl: e2eiConfig.config.acmeDiscoveryUrl!,
gracePeriodInSeconds: e2eiConfig.config.verificationExpiration,
});
// Check if MLS feature is enabled
if (mlsConfig?.status !== FeatureStatus.ENABLED) {
return undefined;
}
// Check if E2EIdentity feature has a server discoveryUrl
if (!e2eiConfig.config || !e2eiConfig.config.acmeDiscoveryUrl || e2eiConfig.config.acmeDiscoveryUrl.length <= 0) {
return undefined;
}
return e2eiConfig;
};

export const configureE2EI = (logger: Logger, config: FeatureList): undefined | Promise<E2EIHandler> => {
// Either get the current E2EIdentity handler instance or create a new one
const e2eiConfig = getE2EIConfig(config);
if (!e2eiConfig) {
return undefined;
}
return undefined;
return E2EIHandler.getInstance().initialize({
discoveryUrl: e2eiConfig.config.acmeDiscoveryUrl!,
gracePeriodInSeconds: e2eiConfig.config.verificationExpiration,
});
};
18 changes: 13 additions & 5 deletions src/script/service/CoreSingleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,21 @@ export class Core extends Account {
public key?: Uint8Array;

constructor(apiClient = container.resolve(APIClient)) {
const enableCoreCrypto = supportsMLS() || Config.getConfig().FEATURE.USE_CORE_CRYPTO;
const {
FEATURE: {
USE_CORE_CRYPTO,
MLS_CONFIG_DEFAULT_CIPHERSUITE,
MLS_CONFIG_KEYING_MATERIAL_UPDATE_THRESHOLD,
ENABLE_ENCRYPTION_AT_REST,
},
} = Config.getConfig();

const enableCoreCrypto = supportsMLS() || USE_CORE_CRYPTO;
super(apiClient, {
createStore: async (storeName, key) => {
this.key = key;
return createStorageEngine(storeName, DatabaseTypes.PERMANENT, {
key: Config.getConfig().FEATURE.ENABLE_ENCRYPTION_AT_REST ? key : undefined,
key: ENABLE_ENCRYPTION_AT_REST ? key : undefined,
});
},

Expand All @@ -60,9 +69,8 @@ export class Core extends Account {
wasmFilePath: '/min/core-crypto.wasm',
mls: supportsMLS()
? {
keyingMaterialUpdateThreshold: Config.getConfig().FEATURE.MLS_CONFIG_KEYING_MATERIAL_UPDATE_THRESHOLD,
cipherSuite: Config.getConfig().FEATURE.MLS_CONFIG_DEFAULT_CIPHERSUITE,
useE2EI: Config.getConfig().FEATURE.ENABLE_E2EI,
keyingMaterialUpdateThreshold: MLS_CONFIG_KEYING_MATERIAL_UPDATE_THRESHOLD,
cipherSuite: MLS_CONFIG_DEFAULT_CIPHERSUITE,
}
: undefined,
}
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5141,9 +5141,9 @@ __metadata:
languageName: node
linkType: hard

"@wireapp/core@npm:43.14.3":
version: 43.14.3
resolution: "@wireapp/core@npm:43.14.3"
"@wireapp/core@npm:44.0.0":
version: 44.0.0
resolution: "@wireapp/core@npm:44.0.0"
dependencies:
"@wireapp/api-client": ^26.10.6
"@wireapp/commons": ^5.2.5
Expand All @@ -5163,7 +5163,7 @@ __metadata:
long: ^5.2.0
uuidjs: 4.2.13
zod: 3.22.4
checksum: f5a519f3787ea234740c92e2c7a581cecb13573f3eb78338ea1af5bb72c2ef3c868903879fd544a2c78b991b27f032504f8afb0a759cf66aaed363c7e568b8c3
checksum: 297c6896ebabdd838abac0c51eff5dffa602fa4c05e8fbccd2f3c497f2b56ece596c8f1218c789446961efa795905e76fb7c556de41938d588f65e5fdf33ff6d
languageName: node
linkType: hard

Expand Down Expand Up @@ -17877,7 +17877,7 @@ __metadata:
"@wireapp/avs": 9.6.9
"@wireapp/commons": 5.2.5
"@wireapp/copy-config": 2.1.16
"@wireapp/core": 43.14.3
"@wireapp/core": 44.0.0
"@wireapp/eslint-config": 3.0.5
"@wireapp/prettier-config": 0.6.3
"@wireapp/react-ui-kit": 9.15.1
Expand Down

0 comments on commit 25bcaf9

Please sign in to comment.