-
Notifications
You must be signed in to change notification settings - Fork 96
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
E2EE for embeded mode #1350
Closed
Closed
E2EE for embeded mode #1350
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
fa5b014
E2EE for embeded mode
SimonBrandner b45c892
Handle embedding
SimonBrandner f279bd6
Remove unnecessary call
SimonBrandner 127e8c9
`sharedKeyManagement.ts` -> `e2eeHooks.ts`
SimonBrandner b57454f
Change embedded E2EE implementation
SimonBrandner ee304fb
Update js-sdk
SimonBrandner 1a7b7c9
Update-js sdk
SimonBrandner 912ed55
Update js-sdk
SimonBrandner ae04cfc
Add a comment
SimonBrandner 720e138
Merge remote-tracking branch 'upstream/dbkr/matrixrtcsession' into Si…
SimonBrandner 2ec7557
Fix `useEnableSPAE2EE`
SimonBrandner 5862f91
Fix map
SimonBrandner 8516e52
Update js-sdk
SimonBrandner 18185be
Update js-sdk
SimonBrandner 0ac651b
Explicit logging
SimonBrandner 6bc6d50
Update js-sdk
SimonBrandner ba5c042
Update js-sdk
SimonBrandner 3a16dbe
Update encryption key on mute change
SimonBrandner 3d57fac
Update js-sdk
SimonBrandner 8bae276
Update js-sdk
SimonBrandner 3a62ecc
Update js-sdk
SimonBrandner 2f6b1ea
Update js-sdk
SimonBrandner ff99826
Update js-sdk
SimonBrandner a0f1184
Update js-sdk
SimonBrandner 645b123
Handle indices
SimonBrandner fce220c
Update js-sdk
SimonBrandner d14d1e1
Merge remote-tracking branch 'upstream/livekit' into SimonBrandner/fe…
SimonBrandner 28035b5
Post-merge fix
SimonBrandner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
Copyright 2023 New Vector Ltd | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import { BaseKeyProvider, createKeyMaterialFromString } from "livekit-client"; | ||
import { | ||
MatrixRTCSession, | ||
MatrixRTCSessionEvent, | ||
} from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession"; | ||
|
||
export class MatrixKeyProvider extends BaseKeyProvider { | ||
private rtcSession?: MatrixRTCSession; | ||
|
||
public setRTCSession(rtcSession: MatrixRTCSession) { | ||
if (this.rtcSession) { | ||
this.rtcSession.off( | ||
MatrixRTCSessionEvent.EncryptionKeyChanged, | ||
this.onEncryptionKeyChanged | ||
); | ||
} | ||
|
||
this.rtcSession = rtcSession; | ||
|
||
this.rtcSession.on( | ||
MatrixRTCSessionEvent.EncryptionKeyChanged, | ||
this.onEncryptionKeyChanged | ||
); | ||
|
||
// The new session could be aware of keys of which the old session wasn't, | ||
// so emit a key changed event. | ||
for (const [ | ||
participant, | ||
encryptionKeys, | ||
] of this.rtcSession.getEncryptionKeys()) { | ||
for (const [index, encryptionKey] of encryptionKeys.entries()) { | ||
this.onEncryptionKeyChanged(encryptionKey, index, participant); | ||
} | ||
} | ||
} | ||
|
||
private onEncryptionKeyChanged = async ( | ||
encryptionKey: string, | ||
encryptionKeyIndex: number, | ||
participantId: string | ||
) => { | ||
this.onSetEncryptionKey( | ||
await createKeyMaterialFromString(encryptionKey), | ||
participantId, | ||
encryptionKeyIndex | ||
); | ||
|
||
console.log( | ||
`Embedded-E2EE-LOG onEncryptionKeyChanged participantId=${participantId} encryptionKeyIndex=${encryptionKeyIndex} encryptionKey=${encryptionKey}`, | ||
this.getKeys() | ||
); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should
setRTCSession
be called withundefined
somewhere to remove the listener?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 assume that if the class gets destroyed, so do the listeners, so there is no need to call it with
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.
Well, not explicitly: there's no destructors run here (it's javascript) so the emitter will continue to retain a reference to the listener, we'd just be relying on them being GCed, so it depends whether anything else holds on to the thing doing the listening (the key provider in this case I think). Assuming everything gets torn down then everything should be detached from the GC root, but we shouldn't be relying on it given the choice IMO.
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 am not really sure I see a case where this would be necessary -> I don't think I see where/when we should destroy it manually...