Remove redundant MSC implementation for io.element.rendezvous (#28583)
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
08418c16c9
commit
95175caf0c
4 changed files with 5 additions and 26 deletions
|
@ -108,12 +108,9 @@ export default class LoginWithQR extends React.Component<IProps, IState> {
|
||||||
private generateAndShowCode = async (): Promise<void> => {
|
private generateAndShowCode = async (): Promise<void> => {
|
||||||
let rendezvous: MSC4108SignInWithQR;
|
let rendezvous: MSC4108SignInWithQR;
|
||||||
try {
|
try {
|
||||||
const fallbackRzServer = this.props.client?.getClientWellKnown()?.["io.element.rendezvous"]?.server;
|
|
||||||
|
|
||||||
const transport = new MSC4108RendezvousSession({
|
const transport = new MSC4108RendezvousSession({
|
||||||
onFailure: this.onFailure,
|
onFailure: this.onFailure,
|
||||||
client: this.props.client,
|
client: this.props.client,
|
||||||
fallbackRzServer,
|
|
||||||
});
|
});
|
||||||
await transport.send("");
|
await transport.send("");
|
||||||
const channel = new MSC4108SecureChannel(transport, undefined, this.onFailure);
|
const channel = new MSC4108SecureChannel(transport, undefined, this.onFailure);
|
||||||
|
|
|
@ -7,13 +7,7 @@ Please see LICENSE files in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import {
|
import { IServerVersions, OidcClientConfig, MatrixClient, DEVICE_CODE_SCOPE } from "matrix-js-sdk/src/matrix";
|
||||||
IServerVersions,
|
|
||||||
IClientWellKnown,
|
|
||||||
OidcClientConfig,
|
|
||||||
MatrixClient,
|
|
||||||
DEVICE_CODE_SCOPE,
|
|
||||||
} from "matrix-js-sdk/src/matrix";
|
|
||||||
import QrCodeIcon from "@vector-im/compound-design-tokens/assets/web/icons/qr-code";
|
import QrCodeIcon from "@vector-im/compound-design-tokens/assets/web/icons/qr-code";
|
||||||
import { Text } from "@vector-im/compound-web";
|
import { Text } from "@vector-im/compound-web";
|
||||||
|
|
||||||
|
@ -25,7 +19,6 @@ import { useMatrixClientContext } from "../../../../contexts/MatrixClientContext
|
||||||
interface IProps {
|
interface IProps {
|
||||||
onShowQr: () => void;
|
onShowQr: () => void;
|
||||||
versions?: IServerVersions;
|
versions?: IServerVersions;
|
||||||
wellKnown?: IClientWellKnown;
|
|
||||||
oidcClientConfig?: OidcClientConfig;
|
oidcClientConfig?: OidcClientConfig;
|
||||||
isCrossSigningReady?: boolean;
|
isCrossSigningReady?: boolean;
|
||||||
}
|
}
|
||||||
|
@ -35,10 +28,8 @@ export function shouldShowQr(
|
||||||
isCrossSigningReady: boolean,
|
isCrossSigningReady: boolean,
|
||||||
oidcClientConfig?: OidcClientConfig,
|
oidcClientConfig?: OidcClientConfig,
|
||||||
versions?: IServerVersions,
|
versions?: IServerVersions,
|
||||||
wellKnown?: IClientWellKnown,
|
|
||||||
): boolean {
|
): boolean {
|
||||||
const msc4108Supported =
|
const msc4108Supported = !!versions?.unstable_features?.["org.matrix.msc4108"];
|
||||||
!!versions?.unstable_features?.["org.matrix.msc4108"] || !!wellKnown?.["io.element.rendezvous"]?.server;
|
|
||||||
|
|
||||||
const deviceAuthorizationGrantSupported =
|
const deviceAuthorizationGrantSupported =
|
||||||
oidcClientConfig?.metadata?.grant_types_supported.includes(DEVICE_CODE_SCOPE);
|
oidcClientConfig?.metadata?.grant_types_supported.includes(DEVICE_CODE_SCOPE);
|
||||||
|
@ -51,15 +42,9 @@ export function shouldShowQr(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const LoginWithQRSection: React.FC<IProps> = ({
|
const LoginWithQRSection: React.FC<IProps> = ({ onShowQr, versions, oidcClientConfig, isCrossSigningReady }) => {
|
||||||
onShowQr,
|
|
||||||
versions,
|
|
||||||
wellKnown,
|
|
||||||
oidcClientConfig,
|
|
||||||
isCrossSigningReady,
|
|
||||||
}) => {
|
|
||||||
const cli = useMatrixClientContext();
|
const cli = useMatrixClientContext();
|
||||||
const offerShowQr = shouldShowQr(cli, !!isCrossSigningReady, oidcClientConfig, versions, wellKnown);
|
const offerShowQr = shouldShowQr(cli, !!isCrossSigningReady, oidcClientConfig, versions);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingsSubsection heading={_t("settings|sessions|sign_in_with_qr")}>
|
<SettingsSubsection heading={_t("settings|sessions|sign_in_with_qr")}>
|
||||||
|
|
|
@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
||||||
Please see LICENSE files in the repository root for full details.
|
Please see LICENSE files in the repository root for full details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { lazy, Suspense, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
import React, { lazy, Suspense, useCallback, useContext, useEffect, useRef, useState } from "react";
|
||||||
import { discoverAndValidateOIDCIssuerWellKnown, MatrixClient } from "matrix-js-sdk/src/matrix";
|
import { discoverAndValidateOIDCIssuerWellKnown, MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||||
import { logger } from "matrix-js-sdk/src/logger";
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
import { defer } from "matrix-js-sdk/src/utils";
|
import { defer } from "matrix-js-sdk/src/utils";
|
||||||
|
@ -184,7 +184,6 @@ const SessionManagerTab: React.FC<{
|
||||||
const userId = matrixClient?.getUserId();
|
const userId = matrixClient?.getUserId();
|
||||||
const currentUserMember = (userId && matrixClient?.getUser(userId)) || undefined;
|
const currentUserMember = (userId && matrixClient?.getUser(userId)) || undefined;
|
||||||
const clientVersions = useAsyncMemo(() => matrixClient.getVersions(), [matrixClient]);
|
const clientVersions = useAsyncMemo(() => matrixClient.getVersions(), [matrixClient]);
|
||||||
const wellKnown = useMemo(() => matrixClient?.getClientWellKnown(), [matrixClient]);
|
|
||||||
const oidcClientConfig = useAsyncMemo(async () => {
|
const oidcClientConfig = useAsyncMemo(async () => {
|
||||||
try {
|
try {
|
||||||
const authIssuer = await matrixClient?.getAuthIssuer();
|
const authIssuer = await matrixClient?.getAuthIssuer();
|
||||||
|
@ -305,7 +304,6 @@ const SessionManagerTab: React.FC<{
|
||||||
<LoginWithQRSection
|
<LoginWithQRSection
|
||||||
onShowQr={onShowQrClicked}
|
onShowQr={onShowQrClicked}
|
||||||
versions={clientVersions}
|
versions={clientVersions}
|
||||||
wellKnown={wellKnown}
|
|
||||||
oidcClientConfig={oidcClientConfig}
|
oidcClientConfig={oidcClientConfig}
|
||||||
isCrossSigningReady={isCrossSigningReady}
|
isCrossSigningReady={isCrossSigningReady}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -56,7 +56,6 @@ describe("<LoginWithQRSection />", () => {
|
||||||
const defaultProps = {
|
const defaultProps = {
|
||||||
onShowQr: () => {},
|
onShowQr: () => {},
|
||||||
versions: makeVersions({ "org.matrix.msc4108": true }),
|
versions: makeVersions({ "org.matrix.msc4108": true }),
|
||||||
wellKnown: {},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getComponent = (props = {}) => <LoginWithQRSection {...defaultProps} {...props} />;
|
const getComponent = (props = {}) => <LoginWithQRSection {...defaultProps} {...props} />;
|
||||||
|
|
Loading…
Reference in a new issue