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

Commit

Permalink
Handle UIA fallback authDone API for cross signing reset unlock
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy committed Aug 9, 2024
1 parent 9ea77a9 commit 3d4a509
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions frontend/src/routes/reset-cross-signing.lazy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ import { graphql } from "../gql";

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

declare global {
interface Window {
// Synapse may fling the user here via UIA fallback,
// this is part of the API to signal completion to the calling client
// https://spec.matrix.org/v1.11/client-server-api/#fallback
onAuthDone?(): void;
}
}

const ALLOW_CROSS_SIGING_RESET_MUTATION = graphql(/* GraphQL */ `
mutation AllowCrossSigningReset($userId: ID!) {
allowUserCrossSigningReset(input: { userId: $userId }) {
Expand All @@ -52,8 +61,18 @@ function ResetCrossSigning(): React.ReactNode {

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

const onClick = (): void => {
allowReset({ userId });
const onClick = async (): Promise<void> => {
await allowReset({ userId });
setTimeout(() => {
// Synapse may fling the user here via UIA fallback,
// this is part of the API to signal completion to the calling client
// https://spec.matrix.org/v1.11/client-server-api/#fallback
if (window.onAuthDone) {
window.onAuthDone();
} else if (window.opener && window.opener.postMessage) {
window.opener.postMessage("authDone", "*");
}
});
};

return (
Expand Down

0 comments on commit 3d4a509

Please sign in to comment.