Skip to content
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

Merged
merged 9 commits into from
Apr 10, 2025

Conversation

BillCarsonFr
Copy link
Member

@BillCarsonFr BillCarsonFr commented Apr 2, 2025

Require changes on StopGapWidget to properly pass to device events without stripping things

Checklist

  • Tests written for new code (and old code if feasible).
  • New or updated public/exported symbols have accurate TSDoc documentation.
  • Linter and other CI checks pass.
  • Sign-off given on the changes (see CONTRIBUTING.md).

@toger5 toger5 force-pushed the valere/matrix_rtc_key_transport branch from 538ad63 to bd6dda1 Compare April 3, 2025 13:18
@BillCarsonFr BillCarsonFr force-pushed the valere/matrix_rtc_to_device_keys branch from d3733d7 to ee6747f Compare April 4, 2025 09:41
@toger5 toger5 added the T-Feature Request to add a new feature which does not exist right now label Apr 7, 2025
Base automatically changed from valere/matrix_rtc_key_transport to develop April 7, 2025 08:50
@toger5 toger5 force-pushed the valere/matrix_rtc_to_device_keys branch 2 times, most recently from 29c5d75 to 499c56e Compare April 7, 2025 09:35
@BillCarsonFr BillCarsonFr changed the title DRAFT DRAFT TO DEVICE KEYS MatrixRTC: ToDevice distribution for media stream keys Apr 7, 2025
 - use correct value for: `onEncryptionKeysChanged`
 - only update `latestGeneratedKeyIndex` for "this user" key
Comment on lines 83 to 87
// 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;
Copy link
Contributor

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?

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.
Copy link
Contributor

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.

@toger5 toger5 marked this pull request as ready for review April 9, 2025 10:18
@toger5 toger5 requested review from a team as code owners April 9, 2025 10:18
@toger5 toger5 requested a review from robintown April 9, 2025 10:18
@toger5 toger5 requested a review from dbkr April 9, 2025 10:18
@toger5 toger5 force-pushed the valere/matrix_rtc_to_device_keys branch from d93b1db to 3178269 Compare April 9, 2025 11:01
Copy link
Member

@dbkr dbkr left a 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(
Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Contributor

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);
Copy link
Member

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.

Copy link
Contributor

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.)

Comment on lines 79 to 83
// 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;
Copy link
Member

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?

Copy link
Contributor

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.

@toger5 toger5 added this pull request to the merge queue Apr 10, 2025
github-merge-queue bot pushed a commit that referenced this pull request Apr 10, 2025
* 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]>
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 10, 2025
@toger5 toger5 added this pull request to the merge queue Apr 10, 2025
Merged via the queue into develop with commit 3f03c1d Apr 10, 2025
30 checks passed
@toger5 toger5 deleted the valere/matrix_rtc_to_device_keys branch April 10, 2025 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-Enhancement T-Feature Request to add a new feature which does not exist right now
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants