@@ -25,14 +25,18 @@ class _ConnectPageState extends State<ConnectPage> {
25
25
static const _storeKeyAdaptiveStream = 'adaptive-stream' ;
26
26
static const _storeKeyDynacast = 'dynacast' ;
27
27
static const _storeKeyFastConnect = 'fast-connect' ;
28
+ static const _storeKeyE2EE = 'e2ee' ;
29
+ static const _storeKeySharedKey = 'shared-key' ;
28
30
29
31
final _uriCtrl = TextEditingController ();
30
32
final _tokenCtrl = TextEditingController ();
33
+ final _sharedKeyCtrl = TextEditingController ();
31
34
bool _simulcast = true ;
32
35
bool _adaptiveStream = true ;
33
36
bool _dynacast = true ;
34
37
bool _busy = false ;
35
38
bool _fastConnect = false ;
39
+ bool _e2ee = false ;
36
40
37
41
@override
38
42
void initState () {
@@ -56,11 +60,15 @@ class _ConnectPageState extends State<ConnectPage> {
56
60
_tokenCtrl.text = const bool .hasEnvironment ('TOKEN' )
57
61
? const String .fromEnvironment ('TOKEN' )
58
62
: prefs.getString (_storeKeyToken) ?? '' ;
63
+ _sharedKeyCtrl.text = const bool .hasEnvironment ('E2EEKEY' )
64
+ ? const String .fromEnvironment ('E2EEKEY' )
65
+ : prefs.getString (_storeKeySharedKey) ?? '' ;
59
66
setState (() {
60
67
_simulcast = prefs.getBool (_storeKeySimulcast) ?? true ;
61
68
_adaptiveStream = prefs.getBool (_storeKeyAdaptiveStream) ?? true ;
62
69
_dynacast = prefs.getBool (_storeKeyDynacast) ?? true ;
63
70
_fastConnect = prefs.getBool (_storeKeyFastConnect) ?? false ;
71
+ _e2ee = prefs.getBool (_storeKeyE2EE) ?? false ;
64
72
});
65
73
}
66
74
@@ -69,10 +77,12 @@ class _ConnectPageState extends State<ConnectPage> {
69
77
final prefs = await SharedPreferences .getInstance ();
70
78
await prefs.setString (_storeKeyUri, _uriCtrl.text);
71
79
await prefs.setString (_storeKeyToken, _tokenCtrl.text);
80
+ await prefs.setString (_storeKeySharedKey, _sharedKeyCtrl.text);
72
81
await prefs.setBool (_storeKeySimulcast, _simulcast);
73
82
await prefs.setBool (_storeKeyAdaptiveStream, _adaptiveStream);
74
83
await prefs.setBool (_storeKeyDynacast, _dynacast);
75
84
await prefs.setBool (_storeKeyFastConnect, _fastConnect);
85
+ await prefs.setBool (_storeKeyE2EE, _e2ee);
76
86
}
77
87
78
88
Future <void > _connect (BuildContext ctx) async {
@@ -93,6 +103,13 @@ class _ConnectPageState extends State<ConnectPage> {
93
103
94
104
// Create a Listener before connecting
95
105
final listener = room.createListener ();
106
+ E2EEOptions ? e2eeOptions;
107
+ if (_e2ee) {
108
+ final keyProvider = await BaseKeyProvider .create ();
109
+ e2eeOptions = E2EEOptions (keyProvider: keyProvider);
110
+ var sharedKey = _sharedKeyCtrl.text;
111
+ await keyProvider.setKey (sharedKey);
112
+ }
96
113
97
114
// Try to connect to the room
98
115
// This will throw an Exception if it fails for any reason.
@@ -107,6 +124,7 @@ class _ConnectPageState extends State<ConnectPage> {
107
124
),
108
125
defaultScreenShareCaptureOptions:
109
126
const ScreenShareCaptureOptions (useiOSBroadcastExtension: true ),
127
+ e2eeOptions: e2eeOptions,
110
128
),
111
129
fastConnectOptions: _fastConnect
112
130
? FastConnectOptions (
@@ -115,6 +133,7 @@ class _ConnectPageState extends State<ConnectPage> {
115
133
)
116
134
: null ,
117
135
);
136
+
118
137
await Navigator .push <void >(
119
138
ctx,
120
139
MaterialPageRoute (builder: (_) => RoomPage (room, listener)),
@@ -136,6 +155,13 @@ class _ConnectPageState extends State<ConnectPage> {
136
155
});
137
156
}
138
157
158
+ void _setE2EE (bool ? value) async {
159
+ if (value == null || _e2ee == value) return ;
160
+ setState (() {
161
+ _e2ee = value;
162
+ });
163
+ }
164
+
139
165
void _setAdaptiveStream (bool ? value) async {
140
166
if (value == null || _adaptiveStream == value) return ;
141
167
setState (() {
@@ -192,6 +218,26 @@ class _ConnectPageState extends State<ConnectPage> {
192
218
ctrl: _tokenCtrl,
193
219
),
194
220
),
221
+ Padding (
222
+ padding: const EdgeInsets .only (bottom: 25 ),
223
+ child: LKTextField (
224
+ label: 'Shared Key' ,
225
+ ctrl: _sharedKeyCtrl,
226
+ ),
227
+ ),
228
+ Padding (
229
+ padding: const EdgeInsets .only (bottom: 5 ),
230
+ child: Row (
231
+ mainAxisAlignment: MainAxisAlignment .spaceBetween,
232
+ children: [
233
+ const Text ('E2EE' ),
234
+ Switch (
235
+ value: _e2ee,
236
+ onChanged: (value) => _setE2EE (value),
237
+ ),
238
+ ],
239
+ ),
240
+ ),
195
241
Padding (
196
242
padding: const EdgeInsets .only (bottom: 5 ),
197
243
child: Row (
0 commit comments