From d14276f5a94bea89ac8f7e011d99c89e2edb9487 Mon Sep 17 00:00:00 2001 From: krille-chan Date: Fri, 12 Apr 2024 19:29:58 +0200 Subject: [PATCH 1/4] fix: Allow unencrypted database if gnome keyring not present or platform does not support it --- assets/l10n/intl_en.arb | 3 +- lib/config/setting_keys.dart | 2 ++ .../builder.dart | 16 +++++---- .../cipher.dart | 35 ++++++++++++++----- 4 files changed, 40 insertions(+), 16 deletions(-) diff --git a/assets/l10n/intl_en.arb b/assets/l10n/intl_en.arb index 6d087c5b9..baa741ad5 100644 --- a/assets/l10n/intl_en.arb +++ b/assets/l10n/intl_en.arb @@ -2601,5 +2601,6 @@ "appname": {}, "unread": {} } - } + }, + "noDatabaseEncryption": "Database encryption is not supported on this platform" } diff --git a/lib/config/setting_keys.dart b/lib/config/setting_keys.dart index 0766249bf..5fbccc4aa 100644 --- a/lib/config/setting_keys.dart +++ b/lib/config/setting_keys.dart @@ -30,4 +30,6 @@ abstract class SettingKeys { static const String showPresences = 'chat.fluffy.show_presences'; static const String displayChatDetailsColumn = 'chat.fluffy.display_chat_details_column'; + static const String noEncryptionWarningShown = + 'chat.fluffy.no_encryption_warning_shown'; } diff --git a/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/builder.dart b/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/builder.dart index 8c182716e..2679ff72a 100644 --- a/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/builder.dart +++ b/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/builder.dart @@ -81,21 +81,23 @@ Future _constructDatabase(Client client) async { // in case we got a cipher, we use the encryption helper // to manage SQLite encryption - final helper = SQfLiteEncryptionHelper( - factory: factory, - path: path, - cipher: cipher, - ); + final helper = cipher == null + ? null + : SQfLiteEncryptionHelper( + factory: factory, + path: path, + cipher: cipher, + ); // check whether the DB is already encrypted and otherwise do so - await helper.ensureDatabaseFileEncrypted(); + await helper?.ensureDatabaseFileEncrypted(); final database = await factory.openDatabase( path, options: OpenDatabaseOptions( version: 1, // most important : apply encryption when opening the DB - onConfigure: helper.applyPragmaKey, + onConfigure: helper?.applyPragmaKey, ), ); diff --git a/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/cipher.dart b/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/cipher.dart index 0c1163c4a..a1903018d 100644 --- a/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/cipher.dart +++ b/lib/utils/matrix_sdk_extensions/flutter_matrix_dart_sdk_database/cipher.dart @@ -1,14 +1,20 @@ import 'dart:convert'; import 'dart:math'; +import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:matrix/matrix.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +import 'package:fluffychat/config/setting_keys.dart'; +import 'package:fluffychat/utils/client_manager.dart'; const _passwordStorageKey = 'database_password'; -Future getDatabaseCipher() async { +Future getDatabaseCipher() async { String? password; try { @@ -28,21 +34,34 @@ Future getDatabaseCipher() async { // workaround for if we just wrote to the key and it still doesn't exist password = await secureStorage.read(key: _passwordStorageKey); if (password == null) throw MissingPluginException(); - } on MissingPluginException catch (_) { + } on MissingPluginException catch (e) { const FlutterSecureStorage() .delete(key: _passwordStorageKey) .catchError((_) {}); - Logs().i('Database encryption is not supported on this platform'); + Logs().w('Database encryption is not supported on this platform', e); + _sendNoEncryptionWarning(e); } catch (e, s) { const FlutterSecureStorage() .delete(key: _passwordStorageKey) .catchError((_) {}); Logs().w('Unable to init database encryption', e, s); + _sendNoEncryptionWarning(e); } - // with the new database, we should no longer allow unencrypted storage - // secure_storage now supports all platforms we support - assert(password != null); - - return password!; + return password; +} + +void _sendNoEncryptionWarning(Object exception) async { + final store = await SharedPreferences.getInstance(); + final isStored = store.getBool(SettingKeys.noEncryptionWarningShown); + + if (isStored == true) return; + + final l10n = lookupL10n(PlatformDispatcher.instance.locale); + ClientManager.sendInitNotification( + l10n.noDatabaseEncryption, + exception.toString(), + ); + + await store.setBool(SettingKeys.noEncryptionWarningShown, true); } From e72a5af5b3da29cad5c41fe2338e0b81bb3b9f0f Mon Sep 17 00:00:00 2001 From: krille-chan Date: Sat, 13 Apr 2024 17:23:47 +0200 Subject: [PATCH 2/4] build: Bump version to 1.19.2 --- CHANGELOG.md | 37 +++++++++++++++++++++++++++++++++++++ pubspec.yaml | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f3199c00..744f2bbf8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,40 @@ +## v1.19.2 +Bugfix release to mostly fix the new database encryption on Linux and update the translations. + +- build: (deps): bump peaceiris/actions-gh-pages from 3 to 4 (dependabot[bot]) +- build: Update all dependencies and remove vibrator package (krille-chan) +- build: Update emoji picker package (krille-chan) +- build: Update flutter_map package (krille-chan) +- docs: Fix typo in android app description (Krille) +- fix: Allow unencrypted database if gnome keyring not present or platform does not support it (krille-chan) +- fix: Background color of images with transparency (Krille) +- fix: Localizations from weblate confused by unknownEvent locale (Krille) +- fix: More logs when database fails to init and trycatch sendInitNotification (Krille) +- Added translation using Weblate (Filipino) (searinminecraft) +- Translated using Weblate (Arabic) (Rex_sa) +- Translated using Weblate (Basque) (xabirequejo) +- Translated using Weblate (Catalan) (fadelkon) +- Translated using Weblate (Chinese (Simplified)) (大王叫我来巡山) +- Translated using Weblate (Chinese (Traditional)) (D0735) +- Translated using Weblate (Chinese (Traditional)) (Kyanos Chiu) +- Translated using Weblate (Croatian) (v1s7) +- Translated using Weblate (English) (v1s7) +- Translated using Weblate (Estonian) (Priit Jõerüüt) +- Translated using Weblate (Estonian) (Priit Jõerüüt) +- Translated using Weblate (Filipino) (searinminecraft) +- Translated using Weblate (Galician) (josé m) +- Translated using Weblate (Indonesian) (Linerly) +- Translated using Weblate (Interlingua) (kdh8219) +- Translated using Weblate (Italian) (Krystian) +- Translated using Weblate (Korean) (kdh8219) +- Translated using Weblate (Persian) (EndermanXD) +- Translated using Weblate (Polish) (Adam Strączek) +- Translated using Weblate (Polish) (Krystian) +- Translated using Weblate (Russian) (v1s7) +- Translated using Weblate (Swedish) (Joaquim Homrighausen) +- Translated using Weblate (Turkish) (v1s7) +- Translated using Weblate (Ukrainian) (Ihor Hordiichuk) + ## v1.19.1 Minor bugfix release for login with SSO on web. diff --git a/pubspec.yaml b/pubspec.yaml index 2c7d58943..1a4d125d6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: fluffychat description: Chat with your friends. publish_to: none # On version bump also increase the build number for F-Droid -version: 1.19.1+3530 +version: 1.19.2+3531 environment: sdk: ">=3.0.0 <4.0.0" From 86b0d04041d44f7c701948e28b9b216eddc85536 Mon Sep 17 00:00:00 2001 From: krille-chan Date: Sat, 13 Apr 2024 17:52:20 +0200 Subject: [PATCH 3/4] chore: Do not send video msc object yet --- lib/pages/chat/chat.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart index aa52f2a6d..ab7759198 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -635,7 +635,6 @@ class ChatController extends State ...file.info, 'duration': result.duration, }, - 'org.matrix.msc3245.voice': {}, 'org.matrix.msc1767.audio': { 'duration': result.duration, 'waveform': result.waveform, From 23f4c64e503f78602db7bb74d7bffcaf3002d511 Mon Sep 17 00:00:00 2001 From: krille-chan Date: Sat, 13 Apr 2024 18:23:02 +0200 Subject: [PATCH 4/4] Revert "chore: Do not send video msc object yet" This reverts commit 86b0d04041d44f7c701948e28b9b216eddc85536. --- lib/pages/chat/chat.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart index ab7759198..aa52f2a6d 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -635,6 +635,7 @@ class ChatController extends State ...file.info, 'duration': result.duration, }, + 'org.matrix.msc3245.voice': {}, 'org.matrix.msc1767.audio': { 'duration': result.duration, 'waveform': result.waveform,