Add e2ee settings
This commit is contained in:
parent
178e50a564
commit
c6c419f76d
15 changed files with 357 additions and 50 deletions
15
lib/utils/beautify_string_extension.dart
Normal file
15
lib/utils/beautify_string_extension.dart
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
extension BeautifyStringExtension on String {
|
||||
String get beautified {
|
||||
String beautifiedStr = "";
|
||||
for (int i = 0; i < this.length; i++) {
|
||||
beautifiedStr += this.substring(i, i + 1);
|
||||
if (i % 4 == 3) {
|
||||
beautifiedStr += " ";
|
||||
}
|
||||
if (i % 16 == 15) {
|
||||
beautifiedStr += "\n";
|
||||
}
|
||||
}
|
||||
return beautifiedStr;
|
||||
}
|
||||
}
|
||||
|
|
@ -162,7 +162,9 @@ extension LocalizedBody on Event {
|
|||
break;
|
||||
case EventTypes.Encryption:
|
||||
localizedBody =
|
||||
I18n.of(context).activatedEndToEndEncryption(senderName);
|
||||
I18n.of(context).activatedEndToEndEncryption(senderName) +
|
||||
". " +
|
||||
I18n.of(context).needPantalaimonWarning;
|
||||
break;
|
||||
case EventTypes.Encrypted:
|
||||
localizedBody = I18n.of(context).couldNotDecryptMessage;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,24 @@ class Store extends StoreAPI {
|
|||
return await secureStorage.write(key: key, value: value);
|
||||
}
|
||||
|
||||
Future<Map<String, DeviceKeysList>> getUserDeviceKeys() async {
|
||||
final deviceKeysListString = await getItem(_UserDeviceKeysKey);
|
||||
if (deviceKeysListString == null) return {};
|
||||
Map<String, dynamic> rawUserDeviceKeys = json.decode(deviceKeysListString);
|
||||
Map<String, DeviceKeysList> userDeviceKeys = {};
|
||||
for (final entry in rawUserDeviceKeys.entries) {
|
||||
userDeviceKeys[entry.key] = DeviceKeysList.fromJson(entry.value);
|
||||
}
|
||||
return userDeviceKeys;
|
||||
}
|
||||
|
||||
Future<void> storeUserDeviceKeys(
|
||||
Map<String, DeviceKeysList> userDeviceKeys) async {
|
||||
await setItem(_UserDeviceKeysKey, json.encode(userDeviceKeys));
|
||||
}
|
||||
|
||||
String get _UserDeviceKeysKey => "${client.clientName}.user_device_keys";
|
||||
|
||||
_init() async {
|
||||
final credentialsStr = await getItem(client.clientName);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue