Skip to content

Commit

Permalink
Remove other unnecessary changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hughns committed Sep 20, 2024
1 parent 58599b8 commit b26341a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/home/RegisteredView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ export const RegisteredView: FC<Props> = ({ client }) => {
roomName,
E2eeType.SHARED_KEY,
);
if (createRoomResult.encryptionSystem.kind !== E2eeType.SHARED_KEY)
if (!createRoomResult.password)
throw new Error("Failed to create room with shared secret");

history.push(
getRelativeRoomUrl(
createRoomResult.roomId,
createRoomResult.encryptionSystem,
{ kind: E2eeType.SHARED_KEY, secret: createRoomResult.password },
roomName,
),
);
Expand Down
4 changes: 2 additions & 2 deletions src/home/UnauthenticatedView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,14 @@ export const UnauthenticatedView: FC = () => {
if (!setClient) {
throw new Error("setClient is undefined");
}
if (createRoomResult.encryptionSystem.kind !== E2eeType.SHARED_KEY)
if (!createRoomResult.password)
throw new Error("Failed to create room with shared secret");

setClient({ client, session });
history.push(
getRelativeRoomUrl(
createRoomResult.roomId,
createRoomResult.encryptionSystem,
{ kind: E2eeType.SHARED_KEY, secret: createRoomResult.password },
roomName,
),
);
Expand Down
17 changes: 4 additions & 13 deletions src/utils/matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ export function sanitiseRoomNameInput(input: string): string {
interface CreateRoomResult {
roomId: string;
alias?: string;
encryptionSystem: EncryptionSystem;
password?: string;
}

/**
Expand Down Expand Up @@ -286,25 +286,16 @@ export async function createRoom(
client.on(ClientEvent.Room, onRoom);
});

let encryptionSystem: EncryptionSystem;

let password: string | undefined;
if (e2ee == E2eeType.SHARED_KEY) {
const password = secureRandomBase64Url(16);
password = secureRandomBase64Url(16);
saveKeyForRoom(roomId, password);
encryptionSystem = {
kind: E2eeType.SHARED_KEY,
secret: password,
};
} else {
encryptionSystem = {
kind: e2ee,
};
}

return {
roomId,
alias: e2ee ? undefined : fullAliasFromRoomName(name, client),
encryptionSystem,
password,
};
}

Expand Down

0 comments on commit b26341a

Please sign in to comment.