Skip to content
Merged
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
2 changes: 2 additions & 0 deletions src/BasePlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,8 @@ export default abstract class BasePlatform {
// The redirect URL has to exactly match that registered at the OIDC server, so
// ensure that the fragment part of the URL is empty.
url.hash = "";
// Set no_universal_links=true to prevent the callback being handled by Element X installed on macOS Apple Silicon
url.searchParams.set("no_universal_links", "true");
return url;
}

Expand Down
1 change: 1 addition & 0 deletions src/vector/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ function onTokenLoginCompleted(): void {
// a little nasty but let's redirect to clear them.
const url = new URL(window.location.href);

url.searchParams.delete("no_universal_links");
url.searchParams.delete("loginToken");
url.searchParams.delete("state");
url.searchParams.delete("code");
Expand Down
23 changes: 22 additions & 1 deletion test/unit-tests/vector/init-test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* @jest-environment jsdom
* @jest-environment-options {"url": "https://app.element.io/?loginToken=123&state=abc&code=xyz&no_universal_links&something_else=value"}
*/

/*
Copyright 2024 New Vector Ltd.

Expand Down Expand Up @@ -42,11 +47,27 @@ describe("showError", () => {
describe("loadApp", () => {
beforeEach(setUpMatrixChatDiv);

it("should set window.matrixChat to the MatrixChat instance", async () => {
beforeEach(async () => {
fetchMock.get("https://matrix.org/_matrix/client/versions", { versions: ["v1.6"] });
SdkConfig.put({ default_server_config: { "m.homeserver": { base_url: "https://matrix.org" } } });
});

it("should set window.matrixChat to the MatrixChat instance", async () => {
await loadApp({});
await waitFor(() => expect(window.matrixChat).toBeInstanceOf(MatrixChat));
});

it("should pass onTokenLoginCompleted which strips searchParams to MatrixChat", async () => {
const spy = jest.spyOn(window.history, "replaceState");

await loadApp({});
await waitFor(() => expect(window.matrixChat).toBeInstanceOf(MatrixChat));
window.matrixChat!.props.onTokenLoginCompleted();

expect(spy).toHaveBeenCalledWith(
null,
"",
expect.stringContaining("https://app.element.io/?something_else=value"),
);
});
});
Loading