Skip to content

Commit

Permalink
chore : remove xsss activation feature flag from patches (#644)
Browse files Browse the repository at this point in the history
* remove xsss activation feature flag from patch

* remove feature flags in config.json

* deprecate code from Tchap UI feature related to xsss

* remove unused code from patches

* remove unused feature flags

* remove depreacted code
  • Loading branch information
odelcroi authored Aug 25, 2023
1 parent cf34b58 commit 5bf825a
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 299 deletions.
4 changes: 1 addition & 3 deletions config.dev.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
"features": {
"feature_thread": true,
"feature_video_rooms": false,
"feature_new_device_manager": false,
"tchap_activate_cross_signing_and_secure_storage": true,
"tchap_disable_cross_signing_setup_toast": false
"feature_new_device_manager": false
},
"default_federate": true,
"default_theme": "light",
Expand Down
4 changes: 1 addition & 3 deletions config.preprod.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
"features": {
"feature_thread": true,
"feature_video_rooms": false,
"feature_new_device_manager": false,
"tchap_activate_cross_signing_and_secure_storage": true,
"tchap_disable_cross_signing_setup_toast": false
"feature_new_device_manager": false
},
"default_federate": true,
"default_theme": "light",
Expand Down
4 changes: 1 addition & 3 deletions config.prod.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@
"features": {
"feature_thread": true,
"feature_video_rooms": false,
"feature_new_device_manager": false,
"tchap_activate_cross_signing_and_secure_storage": true,
"tchap_disable_cross_signing_setup_toast": false
"feature_new_device_manager": false
},
"default_federate": true,
"default_theme": "light",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,57 +1,21 @@
diff --git a/node_modules/matrix-react-sdk/src/components/structures/MatrixChat.tsx b/node_modules/matrix-react-sdk/src/components/structures/MatrixChat.tsx
index 575ff07..ec8c98b 100644
index 575ff07..627b7aa 100644
--- a/node_modules/matrix-react-sdk/src/components/structures/MatrixChat.tsx
+++ b/node_modules/matrix-react-sdk/src/components/structures/MatrixChat.tsx
@@ -32,6 +32,8 @@ import { throttle } from "lodash";
import { CryptoEvent } from "matrix-js-sdk/src/crypto";
import { RoomType } from "matrix-js-sdk/src/@types/event";
import { DecryptionError } from "matrix-js-sdk/src/crypto/algorithms";
+//:tchap: import incoming key request handler from tchap project
+import KeyRequestHandler from '../../../../../src/tchap/lib/IncomingKeyRequestHandler';

// focus-visible is a Polyfill for the :focus-visible CSS pseudo-attribute used by various components
import "focus-visible";
@@ -143,6 +145,7 @@ import { findDMForUser } from "../../utils/dm/findDMForUser";
@@ -143,6 +143,7 @@ import { findDMForUser } from "../../utils/dm/findDMForUser";
import { Linkify } from "../../HtmlUtils";
import { NotificationColor } from "../../stores/notifications/NotificationColor";
import { UserTab } from "../views/dialogs/UserTab";
+import TchapUIFeature from "../../../../../src/tchap/util/TchapUIFeature";
+import TchapUrls from "../../../../../src/tchap/util/TchapUrls";

// legacy export
export { default as Views } from "../../Views";
@@ -1587,6 +1590,26 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
cli.on(HttpApiEvent.SessionLoggedOut, () => dft.stop());
cli.on(MatrixEventEvent.Decrypted, (e, err) => dft.eventDecrypted(e, err as DecryptionError));

+ //:tchap: add listener to handle incomingKeyRequest and trigger legacy verification process
+ //the one with the emoji
+ //this listener can be forced with forceLegacyIncomingRoomKeyVerification
+ //or is added only if the xs is not active
+ if(TchapUIFeature.forceLegacyIncomingRoomKeyVerification ||
+ !TchapUIFeature.isCrossSigningAndSecureStorageActive()){
+ /* :TCHAP: Désactiver le partage legacy de clefs avec les appareils mobiles */
+ console.log(':tchap: activate the legacy incoming key verification')
+ /* end :TCHAP: */
+ const krh = new KeyRequestHandler(cli);
+ cli.on(CryptoEvent.RoomKeyRequest, (req) => {
+ krh.handleKeyRequest(req);
+ });
+
+ cli.on(CryptoEvent.RoomKeyRequestCancellation, (req) => {
+ krh.handleKeyRequestCancellation(req);
+ });
+ }
+ //:tchap: end of tchap
+
cli.on(ClientEvent.Room, (room) => {
if (MatrixClientPeg.get().isCryptoEnabled()) {
const blacklistEnabled = SettingsStore.getValueAt(
@@ -1716,6 +1739,15 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
@@ -1716,6 +1717,15 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
return;
}

+ //:tchap:
+ if (screen === "sauvegarde-automatique") {
+ //:tchap: add a screen to open user tab security
+ if (screen === TchapUrls.secureBackupFragment) {
+ //open the security tab
+ //there is no anchor to sauvegarde-automatique subection
+ const payload: OpenToTabPayload = { action: Action.ViewUserSettings, initialTabId: UserTab.Security };
Expand All @@ -63,18 +27,10 @@ index 575ff07..ec8c98b 100644
dis.dispatch({
action: "start_registration",
diff --git a/node_modules/matrix-react-sdk/src/components/views/settings/CrossSigningPanel.tsx b/node_modules/matrix-react-sdk/src/components/views/settings/CrossSigningPanel.tsx
index e3f62d4..24c7f46 100644
index e3f62d4..dab34a8 100644
--- a/node_modules/matrix-react-sdk/src/components/views/settings/CrossSigningPanel.tsx
+++ b/node_modules/matrix-react-sdk/src/components/views/settings/CrossSigningPanel.tsx
@@ -28,6 +28,7 @@ import ConfirmDestroyCrossSigningDialog from "../dialogs/security/ConfirmDestroy
import SetupEncryptionDialog from "../dialogs/security/SetupEncryptionDialog";
import { accessSecretStorage } from "../../../SecurityManager";
import AccessibleButton from "../elements/AccessibleButton";
+import TchapUIFeature from "../../../../../../src/tchap/util/TchapUIFeature"; // :TCHAP:

interface IState {
error?: Error;
@@ -210,14 +211,21 @@ export default class CrossSigningPanel extends React.PureComponent<{}, IState> {
@@ -210,14 +210,21 @@ export default class CrossSigningPanel extends React.PureComponent<{}, IState> {
userSigningPrivateKeyCached;

const actions: JSX.Element[] = [];
Expand All @@ -98,7 +54,7 @@ index e3f62d4..24c7f46 100644
<AccessibleButton key="setup" kind="primary" onClick={this.onBootstrapClick}>
{buttonCaption}
</AccessibleButton>,
@@ -225,7 +233,9 @@ export default class CrossSigningPanel extends React.PureComponent<{}, IState> {
@@ -225,7 +232,9 @@ export default class CrossSigningPanel extends React.PureComponent<{}, IState> {
}

if (keysExistAnywhere) {
Expand All @@ -109,7 +65,7 @@ index e3f62d4..24c7f46 100644
<AccessibleButton key="reset" kind="danger" onClick={this.resetCrossSigning}>
{_t("Reset")}
</AccessibleButton>,
@@ -237,6 +247,19 @@ export default class CrossSigningPanel extends React.PureComponent<{}, IState> {
@@ -237,6 +246,12 @@ export default class CrossSigningPanel extends React.PureComponent<{}, IState> {
actionRow = <div className="mx_CrossSigningPanel_buttonRow">{actions}</div>;
}

Expand All @@ -119,84 +75,22 @@ index e3f62d4..24c7f46 100644
+ advancedActionRow = <div className="mx_CrossSigningPanel_buttonRow">{advancedActions}</div>;
+ }
+ // end :TCHAP:
+
+ // :TCHAP: hide cross-signing actions if cross-signing is not supported
+ if (!TchapUIFeature.isCrossSigningAndSecureStorageActive()) {
+ actionRow = null;
+ }
+ // end :TCHAP:
+
return (
<div>
{summarisedStatus}
@@ -274,6 +297,7 @@ export default class CrossSigningPanel extends React.PureComponent<{}, IState> {
@@ -274,6 +289,7 @@ export default class CrossSigningPanel extends React.PureComponent<{}, IState> {
</tr>
</tbody>
</table>
+ {advancedActionRow}
</details>
{errorSection}
{actionRow}
diff --git a/node_modules/matrix-react-sdk/src/components/views/settings/DevicesPanel.tsx b/node_modules/matrix-react-sdk/src/components/views/settings/DevicesPanel.tsx
index 603438e..ea4d47c 100644
--- a/node_modules/matrix-react-sdk/src/components/views/settings/DevicesPanel.tsx
+++ b/node_modules/matrix-react-sdk/src/components/views/settings/DevicesPanel.tsx
@@ -27,6 +27,7 @@ import AccessibleButton from "../elements/AccessibleButton";
import { deleteDevicesWithInteractiveAuth } from "./devices/deleteDevices";
import MatrixClientContext from "../../../contexts/MatrixClientContext";
import { isDeviceVerified } from "../../../utils/device/isDeviceVerified";
+import TchapUtils from '../../../../../../src/tchap/util/TchapUtils';

interface IProps {
className?: string;
@@ -37,6 +38,7 @@ interface IState {
deviceLoadError?: string;
selectedDevices: string[];
deleting?: boolean;
+ isCrossSigningSupported?: boolean;//:tchap: add a state to detect if crossSigning is supported
}

export default class DevicesPanel extends React.Component<IProps, IState> {
@@ -54,6 +56,12 @@ export default class DevicesPanel extends React.Component<IProps, IState> {
}

public componentDidMount(): void {
+ //:tchap: Detect cross signing support once
+ TchapUtils.isCrossSigningSupportedByServer().then((isCrossSigningSupported)=>{
+ this.setState({isCrossSigningSupported: isCrossSigningSupported})
+ });
+ //:end of tchap
+
this.context.on(CryptoEvent.DevicesUpdated, this.onDevicesUpdated);
this.loadDevices();
}
@@ -120,6 +128,13 @@ export default class DevicesPanel extends React.Component<IProps, IState> {
}

private isDeviceVerified(device: IMyDevice): boolean | null {
+ //:tchap: if cross signing is not supported, use the legacy device check
+ const cli = this.context;
+ if (!this.state.isCrossSigningSupported) {
+ return cli.checkDeviceTrust(cli.getUserId(), device.device_id).isVerified();
+ }
+ //:tchap: end
+
return isDeviceVerified(this.context, device.device_id);
}

diff --git a/node_modules/matrix-react-sdk/src/components/views/settings/SecureBackupPanel.tsx b/node_modules/matrix-react-sdk/src/components/views/settings/SecureBackupPanel.tsx
index 7473786..af8b424 100644
index 7473786..89bd1bf 100644
--- a/node_modules/matrix-react-sdk/src/components/views/settings/SecureBackupPanel.tsx
+++ b/node_modules/matrix-react-sdk/src/components/views/settings/SecureBackupPanel.tsx
@@ -31,6 +31,7 @@ import AccessibleButton from "../elements/AccessibleButton";
import QuestionDialog from "../dialogs/QuestionDialog";
import RestoreKeyBackupDialog from "../dialogs/security/RestoreKeyBackupDialog";
import { accessSecretStorage } from "../../../SecurityManager";
+import TchapUIFeature from "../../../../../../src/tchap/util/TchapUIFeature"; // :TCHAP:

interface IState {
loading: boolean;
@@ -248,6 +249,13 @@ export default class SecureBackupPanel extends React.PureComponent<{}, IState> {
@@ -248,6 +248,13 @@ export default class SecureBackupPanel extends React.PureComponent<{}, IState> {
statusDescription = (
<>
<p>
Expand All @@ -210,7 +104,7 @@ index 7473786..af8b424 100644
{_t(
"This session is <b>not backing up your keys</b>, " +
"but you do have an existing backup you can restore from " +
@@ -261,7 +269,7 @@ export default class SecureBackupPanel extends React.PureComponent<{}, IState> {
@@ -261,7 +268,7 @@ export default class SecureBackupPanel extends React.PureComponent<{}, IState> {
"Connect this session to key backup before signing out to avoid " +
"losing any keys that may only be on this session.",
)}
Expand All @@ -219,7 +113,7 @@ index 7473786..af8b424 100644
</>
);
restoreButtonCaption = _t("Connect this session to Key Backup");
@@ -415,13 +423,15 @@ export default class SecureBackupPanel extends React.PureComponent<{}, IState> {
@@ -415,13 +422,15 @@ export default class SecureBackupPanel extends React.PureComponent<{}, IState> {
</AccessibleButton>,
);

Expand All @@ -242,7 +136,7 @@ index 7473786..af8b424 100644
} else {
statusDescription = (
<>
@@ -432,7 +442,7 @@ export default class SecureBackupPanel extends React.PureComponent<{}, IState> {
@@ -432,7 +441,7 @@ export default class SecureBackupPanel extends React.PureComponent<{}, IState> {
{ b: (sub) => <b>{sub}</b> },
)}
</p>
Expand All @@ -251,7 +145,7 @@ index 7473786..af8b424 100644
</>
);
actions.push(
@@ -445,7 +455,9 @@ export default class SecureBackupPanel extends React.PureComponent<{}, IState> {
@@ -445,7 +454,9 @@ export default class SecureBackupPanel extends React.PureComponent<{}, IState> {
if (secretStorageKeyInAccount) {
actions.push(
<AccessibleButton key="reset" kind="danger" onClick={this.resetSecretStorage}>
Expand All @@ -262,17 +156,7 @@ index 7473786..af8b424 100644
</AccessibleButton>,
);
}
@@ -463,17 +475,24 @@ export default class SecureBackupPanel extends React.PureComponent<{}, IState> {
let actionRow;
if (actions.length) {
actionRow = <div className="mx_SecureBackupPanel_buttonRow">{actions}</div>;
+ // :TCHAP: hide action buttons if secure storage is not supported
+ // actionRow = <div className="mx_SecureBackupPanel_buttonRow">{actions}</div>;
+ if (!TchapUIFeature.isCrossSigningAndSecureStorageActive()) {
+ actionRow = null;
+ }
+ // end :TCHAP:
}
@@ -467,7 +478,7 @@ export default class SecureBackupPanel extends React.PureComponent<{}, IState> {

return (
<div>
Expand All @@ -281,10 +165,3 @@ index 7473786..af8b424 100644
{_t(
"Back up your encryption keys with your account data in case you " +
"lose access to your sessions. Your keys will be secured with a " +
"unique Security Key.",
)}
</p>
+
{statusDescription}
<details>
<summary>{_t("Advanced")}</summary>
Loading

0 comments on commit 5bf825a

Please sign in to comment.