Skip to content

Commit

Permalink
Bring develop to version 3.100.0 (#73)
Browse files Browse the repository at this point in the history
* Upgrade dependency to [email protected]

* v3.100.0-rc.0

* Upgrade dependency to [email protected]

* Remove code smell assertion identified by Sonar (matrix-org#12547)

* This assertion is unnecessary since the receiver accepts the original type of the expression

* Implement `client.getDomain()` null check

* Update comment since `AutoDiscovery.findClientConfig` may still throw

* Report verification and recovery state to posthog (matrix-org#12516)

* Report verification and recovery state to posthog

* Fix CryptoApi import

* Fix js-sdk import

* Review: Use DeviceVerificationStatus instead of CrossSigningStatus

* Review: Clean condition to check secrets in 4S

* review: Fix redundent !!

* Deprecate `Tooltip.tsx`

* Use tooltip compound in `MessageComposer.tsx`

* Use tooltip compound in `ReadReceiptGroup` component

* Use tooltip compound in `ReadReceiptPerson` component

* Delete `useTooltip.tsx`

* Use compound tooltip in `ReactionRowButton`

* Upgrade dependency to [email protected]

* Migrate `TooltipTarget` usage to compound `Tooltip` (matrix-org#12542)

* Use new tooltip in `RoomTopic.tsx`

* Use new tooltip in `MLocationBody.tsx`

* Fix room topic

* Update location snapshot

* Use new tooltip in `AppPermission.tsx`

* Remove `TooltipTarget`

* Add tests for `RoomTopic`

* Add tests for `ReadReceiptGroup.tsx`

* Add more tests for `ReadReceiptGroup.tsx`

* Add more test for `ReactionsRowButton.tsx`

* Add seedrandom dep to `resolutions` (matrix-org#12552)

* Move seedrandom dep to `resolutions`

... to shut renovate up

* Reinstate `seedrandom` as dev dependency

If we just declare it in `resolutions`, it doesn't get installed at all,
because it is only a devDependency of `bloom-filters`.

* [create-pull-request] automated change (matrix-org#12554)

Co-authored-by: github-merge-queue <[email protected]>

* Avoid using deprecated exports, fields, and duplicate code (matrix-org#12555)

* Fix tabbedview breakpoint width (matrix-org#12556)

Which should be 1024 according to the designs, not 768

* Tooltip: close field tooltip when ESC is pressed (matrix-org#12553)

* Close field tooltip when ESC is pressed

* Use `Key.ESCAPE`

* Close the release announcement when a dialog is opened (matrix-org#12559)

* Fire `ModalManagerEvent.Closed` when a dialog is closed

* Listen to modal events in the RA

* Fix first RA test

* Upgrade dependency to [email protected]

* v3.100.0-rc.1

* Upgrade dependency to [email protected]

* v3.100.0

---------

Co-authored-by: RiotRobot <[email protected]>
Co-authored-by: Ed Geraghty <[email protected]>
Co-authored-by: Valere <[email protected]>
Co-authored-by: Florian Duros <[email protected]>
Co-authored-by: Florian Duros <[email protected]>
Co-authored-by: David Baker <[email protected]>
Co-authored-by: Richard van der Hoff <[email protected]>
Co-authored-by: github-merge-queue <[email protected]>
Co-authored-by: Michael Telatynski <[email protected]>
  • Loading branch information
10 people authored Aug 15, 2024
1 parent 6a1173b commit 040bacb
Show file tree
Hide file tree
Showing 97 changed files with 1,346 additions and 860 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
Changes in [3.100.0](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v3.100.0) (2024-06-04)
=======================================================================================================
## ✨ Features

* Tooltip: Improve accessibility for context menus ([#12462](https://github.com/matrix-org/matrix-react-sdk/pull/12462)). Contributed by @florianduros.
* Tooltip: Improve accessibility of space panel ([#12525](https://github.com/matrix-org/matrix-react-sdk/pull/12525)). Contributed by @florianduros.

## 🐛 Bug Fixes

* Close the release announcement when a dialog is opened ([#12559](https://github.com/matrix-org/matrix-react-sdk/pull/12559)). Contributed by @florianduros.
* Tooltip: close field tooltip when ESC is pressed ([#12553](https://github.com/matrix-org/matrix-react-sdk/pull/12553)). Contributed by @florianduros.
* Fix tabbedview breakpoint width ([#12556](https://github.com/matrix-org/matrix-react-sdk/pull/12556)). Contributed by @dbkr.
* Fix E2E icon display in room header ([#12545](https://github.com/matrix-org/matrix-react-sdk/pull/12545)). Contributed by @florianduros.
* Tooltip: Improve placement for space settings ([#12541](https://github.com/matrix-org/matrix-react-sdk/pull/12541)). Contributed by @florianduros.
* Fix deformed avatar in a call in a narrow timeline ([#12538](https://github.com/matrix-org/matrix-react-sdk/pull/12538)). Contributed by @florianduros.
* Shown own sent state indicator even when showReadReceipts is disabled ([#12540](https://github.com/matrix-org/matrix-react-sdk/pull/12540)). Contributed by @t3chguy.
* Ensure we do not fire the verification mismatch modal multiple times ([#12526](https://github.com/matrix-org/matrix-react-sdk/pull/12526)). Contributed by @t3chguy.
* Fix avatar in chat export ([#12537](https://github.com/matrix-org/matrix-react-sdk/pull/12537)). Contributed by @florianduros.
* Use `*` for italics as it doesn't break when used mid-word ([#12523](https://github.com/matrix-org/matrix-react-sdk/pull/12523)). Contributed by @t3chguy.


Changes in [3.99.0](https://github.com/matrix-org/matrix-react-sdk/releases/tag/v3.99.0) (2024-05-07)
=====================================================================================================
## ✨ Features
Expand Down
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "matrix-react-sdk",
"version": "3.99.0",
"version": "3.100.0",
"description": "SDK for matrix.org using React",
"author": "matrix.org",
"repository": {
Expand All @@ -23,7 +23,7 @@
"package.json",
".stylelintrc.js"
],
"main": "./src/index.ts",
"main": "./lib/index.ts",
"matrix_src_main": "./src/index.ts",
"matrix_lib_main": "./lib/index.ts",
"matrix_lib_typings": "./lib/index.d.ts",
Expand Down Expand Up @@ -62,12 +62,13 @@
"resolutions": {
"@types/react-dom": "17.0.25",
"@types/react": "17.0.80",
"@types/seedrandom": "3.0.4",
"oidc-client-ts": "3.0.1",
"jwt-decode": "4.0.0"
},
"dependencies": {
"@babel/runtime": "^7.12.5",
"@matrix-org/analytics-events": "^0.20.0",
"@matrix-org/analytics-events": "^0.21.0",
"@matrix-org/emojibase-bindings": "^1.1.2",
"@matrix-org/matrix-wysiwyg": "2.17.0",
"@matrix-org/olm": "3.2.15",
Expand Down Expand Up @@ -109,7 +110,7 @@
"maplibre-gl": "^2.0.0",
"matrix-encrypt-attachment": "^1.0.3",
"matrix-events-sdk": "0.0.1",
"matrix-js-sdk": "github:matrix-org/matrix-js-sdk#develop",
"matrix-js-sdk": "33.0.0",
"matrix-widget-api": "^1.5.0",
"memoize-one": "^6.0.0",
"minimist": "^1.2.5",
Expand Down Expand Up @@ -183,7 +184,7 @@
"@types/react-transition-group": "^4.4.0",
"@types/sanitize-html": "2.11.0",
"@types/sdp-transform": "^2.4.6",
"@types/seedrandom": "<3.0.5",
"@types/seedrandom": "3.0.4",
"@types/tar-js": "^0.3.2",
"@types/ua-parser-js": "^0.7.36",
"@types/uuid": "^9.0.2",
Expand Down Expand Up @@ -235,5 +236,6 @@
"outputDirectory": "coverage",
"outputName": "jest-sonar-report.xml",
"relativePaths": true
}
},
"typings": "./lib/index.d.ts"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 0 additions & 21 deletions res/css/components/views/elements/_AppPermission.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,3 @@ limitations under the License.
}
}
}

.mx_Tooltip.mx_Tooltip--appPermission {
box-shadow: none;
background-color: $tooltip-timeline-bg-color;
color: $tooltip-timeline-fg-color;
border: none;
border-radius: 3px;
padding: 6px 8px;

&.mx_Tooltip--appPermission--dark {
.mx_Tooltip_chevron::after {
border-right-color: $tooltip-timeline-bg-color;
}
}

ul {
list-style-position: inside;
padding-left: 2px;
margin-left: 0;
}
}
2 changes: 1 addition & 1 deletion res/css/structures/_TabbedView.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ limitations under the License.
}

/* Hide the labels on tabs, showing only the icons, on narrow viewports. */
@media (max-width: 768px) {
@media (max-width: 1024px) {
.mx_TabbedView_tabsOnLeft.mx_TabbedView_responsive {
.mx_TabbedView_tabLabel_text {
display: none;
Expand Down
71 changes: 71 additions & 0 deletions src/DeviceListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import {
import { logger } from "matrix-js-sdk/src/logger";
import { CryptoEvent } from "matrix-js-sdk/src/crypto";
import { KeyBackupInfo } from "matrix-js-sdk/src/crypto-api";
import { CryptoSessionStateChange } from "@matrix-org/analytics-events/types/typescript/CryptoSessionStateChange";

import { PosthogAnalytics } from "./PosthogAnalytics";
import dis from "./dispatcher/dispatcher";
import {
hideToast as hideBulkUnverifiedSessionsToast,
Expand Down Expand Up @@ -79,6 +81,10 @@ export default class DeviceListener {
private enableBulkUnverifiedSessionsReminder = true;
private deviceClientInformationSettingWatcherRef: string | undefined;

// Remember the current analytics state to avoid sending the same event multiple times.
private analyticsVerificationState?: string;
private analyticsRecoveryState?: string;

public static sharedInstance(): DeviceListener {
if (!window.mxDeviceListener) window.mxDeviceListener = new DeviceListener();
return window.mxDeviceListener;
Expand Down Expand Up @@ -301,6 +307,7 @@ export default class DeviceListener {
const crossSigningReady = await crypto.isCrossSigningReady();
const secretStorageReady = await crypto.isSecretStorageReady();
const allSystemsReady = crossSigningReady && secretStorageReady;
await this.reportCryptoSessionStateToAnalytics(cli);

if (this.dismissedThisDeviceToast || allSystemsReady) {
hideSetupEncryptionToast();
Expand Down Expand Up @@ -407,6 +414,70 @@ export default class DeviceListener {
this.displayingToastsForDeviceIds = newUnverifiedDeviceIds;
}

/**
* Reports current recovery state to analytics.
* Checks if the session is verified and if the recovery is correctly set up (i.e all secrets known locally and in 4S).
* @param cli - the matrix client
* @private
*/
private async reportCryptoSessionStateToAnalytics(cli: MatrixClient): Promise<void> {
const crypto = cli.getCrypto()!;
const secretStorageReady = await crypto.isSecretStorageReady();
const crossSigningStatus = await crypto.getCrossSigningStatus();
const backupInfo = await this.getKeyBackupInfo();
const is4SEnabled = (await cli.secretStorage.getDefaultKeyId()) != null;
const deviceVerificationStatus = await crypto.getDeviceVerificationStatus(cli.getUserId()!, cli.getDeviceId()!);

const verificationState =
deviceVerificationStatus?.signedByOwner && deviceVerificationStatus?.crossSigningVerified
? "Verified"
: "NotVerified";

let recoveryState: "Disabled" | "Enabled" | "Incomplete";
if (!is4SEnabled) {
recoveryState = "Disabled";
} else {
const allCrossSigningSecretsCached =
crossSigningStatus.privateKeysCachedLocally.masterKey &&
crossSigningStatus.privateKeysCachedLocally.selfSigningKey &&
crossSigningStatus.privateKeysCachedLocally.userSigningKey;
if (backupInfo != null) {
// There is a backup. Check that all secrets are stored in 4S and known locally.
// If they are not, recovery is incomplete.
const backupPrivateKeyIsInCache = (await crypto.getSessionBackupPrivateKey()) != null;
if (secretStorageReady && allCrossSigningSecretsCached && backupPrivateKeyIsInCache) {
recoveryState = "Enabled";
} else {
recoveryState = "Incomplete";
}
} else {
// No backup. Just consider cross-signing secrets.
if (secretStorageReady && allCrossSigningSecretsCached) {
recoveryState = "Enabled";
} else {
recoveryState = "Incomplete";
}
}
}

if (this.analyticsVerificationState === verificationState && this.analyticsRecoveryState === recoveryState) {
// No changes, no need to send the event nor update the user properties
return;
}
this.analyticsRecoveryState = recoveryState;
this.analyticsVerificationState = verificationState;

// Update user properties
PosthogAnalytics.instance.setProperty("recoveryState", recoveryState);
PosthogAnalytics.instance.setProperty("verificationState", verificationState);

PosthogAnalytics.instance.trackEvent<CryptoSessionStateChange>({
eventName: "CryptoSessionState",
verificationState: verificationState,
recoveryState: recoveryState,
});
}

/**
* Check if key backup is enabled, and if not, raise an `Action.ReportKeyBackupNotEnabled` event (which will
* trigger an auto-rageshake).
Expand Down
17 changes: 0 additions & 17 deletions src/MatrixClientPeg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,6 @@ export interface IMatrixClientPeg {
*/
opts: IStartClientOpts;

/**
* Return the server name of the user's homeserver
* Throws an error if unable to deduce the homeserver name
* (e.g. if the user is not logged in)
*
* @returns {string} The homeserver name, if present.
*/
getHomeserverName(): string;

/**
* Get the current MatrixClient, if any
*/
Expand Down Expand Up @@ -384,14 +375,6 @@ class MatrixClientPegClass implements IMatrixClientPeg {
logger.log(`MatrixClientPeg: MatrixClient started`);
}

public getHomeserverName(): string {
const matches = /^@[^:]+:(.+)$/.exec(this.safeGet().getSafeUserId());
if (matches === null || matches.length < 1) {
throw new Error("Failed to derive homeserver name from user ID!");
}
return matches[1];
}

private namesToRoomName(names: string[], count: number): string | undefined {
const countWithoutMe = count - 1;
if (!names.length) {
Expand Down
11 changes: 11 additions & 0 deletions src/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ interface IOptions<C extends ComponentType> {

export enum ModalManagerEvent {
Opened = "opened",
Closed = "closed",
}

type HandlerMap = {
[ModalManagerEvent.Opened]: () => void;
[ModalManagerEvent.Closed]: () => void;
};

export class ModalManager extends TypedEventEmitter<ModalManagerEvent, HandlerMap> {
Expand Down Expand Up @@ -232,6 +234,7 @@ export class ModalManager extends TypedEventEmitter<ModalManagerEvent, HandlerMa
}

this.reRender();
this.emitClosed();
},
deferred.promise,
];
Expand Down Expand Up @@ -328,6 +331,14 @@ export class ModalManager extends TypedEventEmitter<ModalManagerEvent, HandlerMa
}
}

/**
* Emit the closed event
* @private
*/
private emitClosed(): void {
this.emit(ModalManagerEvent.Closed);
}

private onBackgroundClick = (): void => {
const modal = this.getCurrentModal();
if (!modal) {
Expand Down
10 changes: 2 additions & 8 deletions src/SecurityManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import {
DeviceVerificationStatus,
ICryptoCallbacks,
MatrixClient,
encodeBase64,
SecretStorage,
} from "matrix-js-sdk/src/matrix";
import { Crypto, ICryptoCallbacks, MatrixClient, encodeBase64, SecretStorage } from "matrix-js-sdk/src/matrix";
import { deriveKey } from "matrix-js-sdk/src/crypto/key_passphrase";
import { decodeRecoveryKey } from "matrix-js-sdk/src/crypto/recoverykey";
import { logger } from "matrix-js-sdk/src/logger";
Expand Down Expand Up @@ -249,7 +243,7 @@ async function onSecretRequested(
deviceId: string,
requestId: string,
name: string,
deviceTrust: DeviceVerificationStatus,
deviceTrust: Crypto.DeviceVerificationStatus,
): Promise<string | undefined> {
logger.log("onSecretRequested", userId, deviceId, requestId, name, deviceTrust);
const client = MatrixClientPeg.safeGet();
Expand Down
8 changes: 6 additions & 2 deletions src/SlidingSyncManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,14 @@ export class SlidingSyncManager {
let proxyUrl: string | undefined;

try {
const clientWellKnown = await AutoDiscovery.findClientConfig(client.getDomain()!);
const clientDomain = await client.getDomain();
if (clientDomain === null) {
throw new RangeError("Homeserver domain is null");
}
const clientWellKnown = await AutoDiscovery.findClientConfig(clientDomain);
proxyUrl = clientWellKnown?.["org.matrix.msc3575.proxy"]?.url;
} catch (e) {
// client.getDomain() is invalid, `AutoDiscovery.findClientConfig` has thrown
// Either client.getDomain() is null so we've shorted out, or is invalid so `AutoDiscovery.findClientConfig` has thrown
}

if (proxyUrl != undefined) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/dialogs/CreateRoomDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ export default class CreateRoomDialog extends React.Component<IProps, IState> {
</summary>
<LabelledToggleSwitch
label={_t("create_room|unfederated", {
serverName: MatrixClientPeg.getHomeserverName(),
serverName: MatrixClientPeg.safeGet().getDomain(),
})}
onChange={this.onNoFederateChange}
value={this.state.noFederate}
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/dialogs/ServerOfflineDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default class ServerOfflineDialog extends React.PureComponent<IProps> {
timeline = [<div key={1}>{_t("server_offline|empty_timeline")}</div>];
}

const serverName = MatrixClientPeg.getHomeserverName();
const serverName = MatrixClientPeg.safeGet().getDomain();
return (
<BaseDialog
title={_t("server_offline|title")}
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/dialogs/devtools/ServerInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export async function getServerVersionFromFederationApi(client: MatrixClient): P
let baseUrl = client.getHomeserverUrl();

try {
const hsName = MatrixClientPeg.getHomeserverName();
const hsName = MatrixClientPeg.safeGet().getDomain();
// We don't use the js-sdk Autodiscovery module here as it only support client well-known, not server ones.
const response = await fetch(`https://${hsName}/.well-known/matrix/server`);
const json = await response.json();
Expand Down
2 changes: 1 addition & 1 deletion src/components/views/directory/NetworkDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function useServers(): ServerList {
SettingLevel.ACCOUNT,
);

const homeServer = MatrixClientPeg.getHomeserverName();
const homeServer = MatrixClientPeg.safeGet().getDomain()!;
const configServers = new Set<string>(SdkConfig.getObject("room_directory")?.get("servers") ?? []);
removeAll(configServers, homeServer);
// configured servers take preference over user-defined ones, if one occurs in both ignore the latter one.
Expand Down
Loading

0 comments on commit 040bacb

Please sign in to comment.