Add e2ee settings

This commit is contained in:
Christian Pauly 2020-02-04 14:42:35 +01:00
commit c6c419f76d
15 changed files with 357 additions and 50 deletions

View 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;
}
}

View file

@ -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;

View file

@ -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);