* chore: e2ee.

* update.

* update.

* update.

* update.

* chore: Use feat/frame-encryption branch of flutter-webrtc.

* chore: Add E2EEKEY defines for dart environment, and e2ee switch.

* Add encodedInsertableStreams to RTCConfiguration.

* update.

* feat: Add e2ee indicator for Participant.

* feat: add e2ee worker js for flutter web.

* dart format.

* remove unused file.

* fix flutter analyze .

* update.

* update.

* add: indicate for decryption failure, and string key.

* remove .lock files.

* update.

* update.

* update e2ee.worker for web.

* feat: support setCodecPreferences.

* state TrackE2EEStateEvent.

* fix wrong import interface from dart_webrtc.

* update.

* update.

* update.

* update.

* update pubspec.lock.

* chore: update protocol and add EncryptionType for Participant.

* Update lib/src/e2ee/options.dart

Co-authored-by: Théo Monnom <[email protected]>

* fix typo.

* revert changes for internal import.

* Add _cleanUp() for previous room.

* Add e2ee supports detection method for native/web.

* Remove redundant overriding methods.

* dart format.

* Add e2ee.worker code and deployment docs.

* chore: remove duplicate words.

* chore: using Pbkdf2 derive the key.

* Update pubspec.yaml

* fix e2ee for safari.

* fix key length.

* update e2ee.worker.dart.js.

* fix.

* update proto.

* update.

* chore: add simulate for rachetKey.

* update.

* chore: key ratchet for flutter web.

* update.

* update.

* update.

* chore: key ratchet export for web.

* bump version for xframeworks.

* update.

* chore: some changes for key safety ratcheting.

* update.

* fix typo.

* update.

* rename.

* magic bytes for web.

* bump version for flutter-webrtc.

* fix analyzer.

---------

Co-authored-by: Théo Monnom <[email protected]>
This commit is contained in:
CloudWebRTC
2023-04-27 17:54:32 +08:00
committed by GitHub
co-authored by Théo Monnom
parent 3407221fc4
commit 26947e96d6
42 changed files with 12523 additions and 39 deletions
+22
View File
@@ -6,6 +6,7 @@ import 'package:collection/collection.dart';
import 'package:flutter_webrtc/flutter_webrtc.dart' as rtc;
import 'package:meta/meta.dart';
import '../e2ee/options.dart';
import '../events.dart';
import '../exceptions.dart';
import '../extensions.dart';
@@ -188,6 +189,21 @@ class Engine extends Disposable with EventsEmittable<EngineEvent> {
}) async {
// TODO: Check if cid already published
lk_models.Encryption_Type encryptionType = lk_models.Encryption_Type.NONE;
if (roomOptions.e2eeOptions != null) {
switch (roomOptions.e2eeOptions!.encryptionType) {
case EncryptionType.kNone:
encryptionType = lk_models.Encryption_Type.NONE;
break;
case EncryptionType.kGcm:
encryptionType = lk_models.Encryption_Type.GCM;
break;
case EncryptionType.kCustom:
encryptionType = lk_models.Encryption_Type.CUSTOM;
break;
}
}
// send request to add track
signalClient.sendAddTrack(
cid: cid,
@@ -197,6 +213,7 @@ class Engine extends Disposable with EventsEmittable<EngineEvent> {
dimensions: dimensions,
dtx: dtx,
videoLayers: videoLayers,
encryptionType: encryptionType,
);
// wait for response, or timeout
@@ -299,6 +316,11 @@ class Engine extends Disposable with EventsEmittable<EngineEvent> {
);
}
if (kIsWeb && roomOptions.e2eeOptions != null) {
rtcConfiguration =
rtcConfiguration.copyWith(encodedInsertableStreams: true);
}
return rtcConfiguration;
}
+29 -8
View File
@@ -7,7 +7,9 @@ import 'package:livekit_client/src/support/app_state.dart';
import 'package:meta/meta.dart';
import '../core/signal_client.dart';
import '../e2ee/e2ee_manager.dart';
import '../events.dart';
import '../exceptions.dart';
import '../extensions.dart';
import '../internal/events.dart';
import '../logger.dart';
@@ -71,6 +73,9 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {
String? get serverRegion => _serverRegion;
String? _serverRegion;
E2EEManager? get e2eeManager => _e2eeManager;
E2EEManager? _e2eeManager;
bool get isRecording => _isRecording;
bool _isRecording = false;
@@ -140,14 +145,22 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {
ConnectOptions? connectOptions,
RoomOptions? roomOptions,
FastConnectOptions? fastConnectOptions,
}) =>
engine.connect(
url,
token,
connectOptions: connectOptions,
roomOptions: roomOptions,
fastConnectOptions: fastConnectOptions,
);
}) {
if (roomOptions?.e2eeOptions != null) {
if (!lkPlatformSupportsE2EE()) {
throw LiveKitE2EEException('E2EE is not supported on this platform');
}
_e2eeManager = E2EEManager(roomOptions!.e2eeOptions!.keyProvider);
_e2eeManager!.setup(this);
}
return engine.connect(
url,
token,
connectOptions: connectOptions,
roomOptions: roomOptions,
fastConnectOptions: fastConnectOptions,
);
}
void _setUpSignalListeners() => _signalListener
..on<SignalJoinResponseEvent>((event) {
@@ -378,6 +391,14 @@ class Room extends DisposableChangeNotifier with EventsEmittable<RoomEvent> {
await _cleanUp();
}
Future<void> setE2EEEnabled(bool enabled) async {
if (_e2eeManager != null) {
await _e2eeManager!.setEnabled(enabled);
} else {
throw LiveKitE2EEException('_e2eeManager not setup!');
}
}
RemoteParticipant _getOrCreateRemoteParticipant(
String sid, lk_models.ParticipantInfo? info) {
RemoteParticipant? participant = _participants[sid];
+2
View File
@@ -350,6 +350,7 @@ extension SignalClientRequests on SignalClient {
required String name,
required lk_models.TrackType type,
required lk_models.TrackSource source,
required lk_models.Encryption_Type encryptionType,
VideoDimensions? dimensions,
bool? dtx,
Iterable<lk_models.VideoLayer>? videoLayers,
@@ -359,6 +360,7 @@ extension SignalClientRequests on SignalClient {
name: name,
type: type,
source: source,
encryption: encryptionType,
);
if (type == lk_models.TrackType.VIDEO) {