-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Implement lab for encrypted state events (MSC3414/MSC4362) #30877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Signed-off-by: Skye Elliot <[email protected]>
Two potential considerations:
|
47ec3fd
to
f568949
Compare
IMO it would make sense that clients with this flag enabled can create / enable rooms to have encrypted state, but all supporting clients regardless of features should be able to interact in these rooms. So, they should probably attempt to send encrypted state if the room requires it. |
I agree! The last commit I made locks |
It will be quite challenging to improve coverage on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First quick review :)
src/createRoom.ts
Outdated
const timeout = setTimeout(() => { | ||
logger.warn("Timed out while waiting for room to enable encryption"); | ||
roomState.off(RoomStateEvent.Update, onRoomStateUpdate); | ||
resolve(); | ||
}, 3000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have to wait for this long, we need a spinner or some feedback to the user
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an existing spinner, I could force it to be shown If state event encryption is enabled?
src/createRoom.ts
Outdated
|
||
const roomState = resolvedRoom.getLiveTimeline().getState(Direction.Forward)!; | ||
|
||
// Soft fail, since the room will still be functional if the initial state is not encrypted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also if it fails, how do we inform the user?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few drive-by comments; sorry, haven't done a full review
}); | ||
}); | ||
|
||
it("creates a private with encryption", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it("creates a private with encryption", async () => { | |
it("creates a private room with encryption", async () => { |
src/createRoom.ts
Outdated
// Set room avatar | ||
if (opts.avatar) { | ||
let url: string; | ||
if (opts.avatar instanceof File) { | ||
({ content_uri: url } = await client.uploadContent(opts.avatar)); | ||
} else { | ||
url = opts.avatar; | ||
} | ||
await client.sendStateEvent(roomId, EventType.RoomAvatar, { url }, ""); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like you could do with a test that hits this codepath
spinner?: boolean; | ||
guestAccess?: boolean; | ||
encryption?: boolean; | ||
stateEncryption?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new public field needs doc-comment, please
src/createRoom.ts
Outdated
await new Promise<void>((resolve, reject) => { | ||
if (resolvedRoom.hasEncryptionStateEvent()) { | ||
return resolve(); | ||
} | ||
|
||
const roomState = resolvedRoom.getLiveTimeline().getState(Direction.Forward)!; | ||
|
||
// Soft fail, since the room will still be functional if the initial state is not encrypted. | ||
const timeout = setTimeout(() => { | ||
logger.warn("Timed out while waiting for room to enable encryption"); | ||
roomState.off(RoomStateEvent.Update, onRoomStateUpdate); | ||
resolve(); | ||
}, 3000); | ||
|
||
const onRoomStateUpdate = (state: RoomState): void => { | ||
if (state.getStateEvents(EventType.RoomEncryption, "")) { | ||
roomState.off(RoomStateEvent.Update, onRoomStateUpdate); | ||
clearTimeout(timeout); | ||
resolve(); | ||
} | ||
}; | ||
|
||
roomState.on(RoomStateEvent.Update, onRoomStateUpdate); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the createRoom
function is way too long and complicated. Factor this bit (at least) out to a separate function?
}); | ||
} | ||
|
||
let stateEncryptedOpts: ICreateRoomOpts | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having a separate copy of the create opts feels like a confusing way to do things.
I think really, it's incorrect to pass the name
in the ICreateRoomOpts
(which is explicitly "a list of options to pass to the /createRoom
API."); instead we should add a new name
property to IOpts
. (We could also add a sanity-check that throws an exception if someone attempts to set ICreateRoomOpts.name
.) Suggest pulling this out to a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pulled it out here: #30981
Checklist
public
/exported
symbols have accurate TSDoc documentation.