-
-
Notifications
You must be signed in to change notification settings - Fork 617
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
MatrixRTC: ToDevice distribution for media stream keys #4785
Conversation
538ad63
to
bd6dda1
Compare
d3733d7
to
ee6747f
Compare
29c5d75
to
499c56e
Compare
499c56e
to
0a587e9
Compare
297e635
to
b3b5347
Compare
- use correct value for: `onEncryptionKeysChanged` - only update `latestGeneratedKeyIndex` for "this user" key
src/matrixrtc/EncryptionManager.ts
Outdated
// TODO: remove this value since I think this is not helpful to use | ||
// it represents what index we actually sent over to ElementCall (which we do in a delayed manner) | ||
// but it has no releavnt information for the encryption manager. | ||
private mediaTrailerKeyIndexInUse = -1; | ||
private latestGeneratedKeyIndex = -1; |
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.
We intentionally want the transparency here. This class EncryptionManager will be deprecated soon
and replaced by a refactored version.
It might be worth renaming this to LegacyEncryptionManager
already?
src/matrixrtc/EncryptionManager.ts
Outdated
logger.warn("Tried to send encryption keys event but no current key index found!"); | ||
return; | ||
} | ||
|
||
const keyIndexToSend = indexToSend ?? this.currentEncryptionKeyIndex; | ||
const keyIndexToSend = indexToSend ?? this.latestGeneratedKeyIndex; | ||
// TODO remove this debug log. it just shows then when sending mediaTrailerKeyIndexInUse contained the wrong index. |
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.
this TODO comment is also expected and will help building the refactored manager.
d93b1db
to
3178269
Compare
3178269
to
778db8c
Compare
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 quick PR description saying what this is doing might have been helpful, although I think I've worked it out now apart from maybe some of the changes to EncryptionManager which don't seem all that relevant.
* @param payload - The payload to send. This will be encrypted. | ||
* @returns Promise which resolves once queued. | ||
*/ | ||
public async encryptAndSendToDevice( |
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 this is actually calling queueToDevice
maybe it should be called encryptAndQueueToDevice
to be less confusing.
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.
I think since it will send the event eventually calling it send it okay?
Also we are considering to allow error handling in the widget so this should not resolve once queued but once send and return the error. This is a tracked issue we will tackle as a second iteration on both rust sdk ec and js-sdk.
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.
Well, so does queueToDevice, but fair enough - as long as we don't end up wanting to add another one that doesn't queue.
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.
I created: #4793
So we can tackle this in a better way and get rid of the TODO comment. (not yet ready to review needs to wait until next week i suspect.)
} | ||
|
||
public stop(): void { | ||
this.client.off(ClientEvent.ToDeviceEvent, this.onToDeviceEvent); |
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.
This won't work as you've wrapped it in an anonymous function when adding.
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.
This is a very good catch thx. I dont know why the wrapper was added (maybe some params were different eventually.)
src/matrixrtc/EncryptionManager.ts
Outdated
// TODO: remove this value since I think this is not helpful to use | ||
// it represents what index we actually sent over to ElementCall (which we do in a delayed manner) | ||
// but it has no releavnt information for the encryption manager. | ||
private mediaTrailerKeyIndexInUse = -1; | ||
private latestGeneratedKeyIndex = -1; |
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.
Not sure why you're adding something and then claiming in a comment that it should be removed...
Also, why the rename?
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.
Mostly because of: #4785 (comment)
But you might be right. we did the testing where we needed the logging so probably its best to just remove it.
* MatrixRTC: ToDevice distribution for media stream keys * test: Add RTC to device transport test * lint * fix key indexing * fix indexing take two - use correct value for: `onEncryptionKeysChanged` - only update `latestGeneratedKeyIndex` for "this user" key * test: add test for join config `useExperimentalToDeviceTransport` * update test to fail without the fixed encryption key index * review * review (dave) --------- Co-authored-by: Timo <[email protected]>
Require changes on StopGapWidget to properly pass to device events without stripping things
Checklist
public
/exported
symbols have accurate TSDoc documentation.