Skip to content
This repository was archived by the owner on Sep 10, 2024. It is now read-only.

Commit 3d4a509

Browse files
committed
Handle UIA fallback authDone API for cross signing reset unlock
1 parent 9ea77a9 commit 3d4a509

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

frontend/src/routes/reset-cross-signing.lazy.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ import { graphql } from "../gql";
2828

2929
import { CURRENT_VIEWER_QUERY } from "./reset-cross-signing";
3030

31+
declare global {
32+
interface Window {
33+
// Synapse may fling the user here via UIA fallback,
34+
// this is part of the API to signal completion to the calling client
35+
// https://spec.matrix.org/v1.11/client-server-api/#fallback
36+
onAuthDone?(): void;
37+
}
38+
}
39+
3140
const ALLOW_CROSS_SIGING_RESET_MUTATION = graphql(/* GraphQL */ `
3241
mutation AllowCrossSigningReset($userId: ID!) {
3342
allowUserCrossSigningReset(input: { userId: $userId }) {
@@ -52,8 +61,18 @@ function ResetCrossSigning(): React.ReactNode {
5261

5362
const [result, allowReset] = useMutation(ALLOW_CROSS_SIGING_RESET_MUTATION);
5463

55-
const onClick = (): void => {
56-
allowReset({ userId });
64+
const onClick = async (): Promise<void> => {
65+
await allowReset({ userId });
66+
setTimeout(() => {
67+
// Synapse may fling the user here via UIA fallback,
68+
// this is part of the API to signal completion to the calling client
69+
// https://spec.matrix.org/v1.11/client-server-api/#fallback
70+
if (window.onAuthDone) {
71+
window.onAuthDone();
72+
} else if (window.opener && window.opener.postMessage) {
73+
window.opener.postMessage("authDone", "*");
74+
}
75+
});
5776
};
5877

5978
return (

0 commit comments

Comments
 (0)