Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/IConfigOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ export interface IConfigOptions {
client_id: string;
}
>;

login_with_qr?: {
/**
* Default rendezvous server to use even if the Homeserver doesn't provide one.
*/
default_rz_server?: string;
};
}

export interface ISsoRedirectOptions {
Expand Down
4 changes: 4 additions & 0 deletions src/components/views/auth/LoginWithQR.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { MatrixClient } from "matrix-js-sdk/src/matrix";
import { _t } from "../../../languageHandler";
import { wrapRequestWithDialog } from "../../../utils/UserInteractiveAuth";
import LoginWithQRFlow from "./LoginWithQRFlow";
import SdkConfig from "../../../SdkConfig";

/**
* The intention of this enum is to have a mode that scans a QR code instead of generating one.
Expand Down Expand Up @@ -153,9 +154,12 @@ export default class LoginWithQR extends React.Component<IProps, IState> {
private generateCode = async (): Promise<void> => {
let rendezvous: MSC3906Rendezvous;
try {
const fallbackRzServer = SdkConfig.get().login_with_qr?.default_rz_server;

const transport = new MSC3886SimpleHttpRendezvousTransport<MSC3903ECDHPayload>({
onFailure: this.onFailure,
client: this.props.client,
fallbackRzServer,
});

const channel = new MSC3903ECDHv2RendezvousChannel<MSC3906RendezvousPayload>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
import { _t } from "../../../../languageHandler";
import AccessibleButton from "../../elements/AccessibleButton";
import SettingsSubsection from "../shared/SettingsSubsection";
import SdkConfig from "../../../../SdkConfig";

interface IProps {
onShowQr: () => void;
Expand All @@ -43,7 +44,9 @@ export default class LoginWithQRSection extends React.Component<IProps> {
const capability = UNSTABLE_MSC3882_CAPABILITY.findIn<IMSC3882GetLoginTokenCapability>(this.props.capabilities);
const msc3882Supported =
!!this.props.versions?.unstable_features?.["org.matrix.msc3882"] || !!capability?.enabled;
const msc3886Supported = !!this.props.versions?.unstable_features?.["org.matrix.msc3886"];
const msc3886Supported =
!!this.props.versions?.unstable_features?.["org.matrix.msc3886"] ||
!!SdkConfig.get().login_with_qr?.default_rz_server;
const offerShowQr = msc3882Supported && msc3886Supported;

// don't show anything if no method is available
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import React from "react";

import LoginWithQRSection from "../../../../../src/components/views/settings/devices/LoginWithQRSection";
import { MatrixClientPeg } from "../../../../../src/MatrixClientPeg";
import SdkConfig from "../../../../../src/SdkConfig";

function makeClient() {
return mocked({
Expand Down Expand Up @@ -114,5 +115,18 @@ describe("<LoginWithQRSection />", () => {
);
expect(container).toMatchSnapshot();
});

it("MSC3882 r1 + default_rz_server", async () => {
jest.spyOn(SdkConfig, "get").mockReturnValue({ login_with_qr: { default_rz_server: "https://rz.local" } });
const { container } = render(
getComponent({
versions: makeVersions({}),
capabilities: {
[UNSTABLE_MSC3882_CAPABILITY.name]: { enabled: true },
},
}),
);
expect(container).toMatchSnapshot();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,41 @@ exports[`<LoginWithQRSection /> should render panel MSC3882 r1 + MSC3886 1`] = `
</div>
</div>
`;

exports[`<LoginWithQRSection /> should render panel MSC3882 r1 + default_rz_server 1`] = `
<div>
<div
class="mx_SettingsSubsection"
>
<div
class="mx_SettingsSubsectionHeading"
>
<h3
class="mx_Heading_h4 mx_SettingsSubsectionHeading_heading"
>
Sign in with QR code
</h3>
</div>
<div
class="mx_SettingsSubsection_content"
>
<div
class="mx_LoginWithQRSection"
>
<p
class="mx_SettingsTab_subsectionText"
>
You can use this device to sign in a new device with a QR code. You will need to scan the QR code shown on this device with your device that's signed out.
</p>
<div
class="mx_AccessibleButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_primary"
role="button"
tabindex="0"
>
Show QR code
</div>
</div>
</div>
</div>
</div>
`;