π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Limit offline key warning to offline-only users
Neeraj Gupta06b86579e4be
diff --git a/docs/docs/auth/troubleshooting/offline-codes-unavailable.md b/docs/docs/auth/troubleshooting/offline-codes-unavailable.mdindex 794546f714..7417f5c67d 100644--- a/docs/docs/auth/troubleshooting/offline-codes-unavailable.md+++ b/docs/docs/auth/troubleshooting/offline-codes-unavailable.md@@ -5,7 +5,7 @@ description: Recover or reset Ente Auth when the key for offline codes is unavai# Offline codes unavailable-Ente Auth shows **Unable to access your codes** when the app was configured for offline mode but its encryption key is no longer available from the operating system's secure storage.+Ente Auth shows **Unable to access your codes** when an offline-only installation no longer has access to its encryption key in the operating system's secure storage.## When this can happendiff --git a/mobile/apps/auth/changes/offline-restore-without-key.md b/mobile/apps/auth/changes/offline-restore-without-key.mdindex 3a215ce348..8a5868e0bc 100644--- a/mobile/apps/auth/changes/offline-restore-without-key.md+++ b/mobile/apps/auth/changes/offline-restore-without-key.md@@ -1 +1 @@-- Show troubleshooting guidance when Auth cannot access the encryption key for offline codes.+- Show troubleshooting guidance when an offline-only Auth installation cannot access its encryption key.diff --git a/mobile/apps/auth/lib/app/view/app.dart b/mobile/apps/auth/lib/app/view/app.dartindex f5c2735c49..7928d858d5 100644--- a/mobile/apps/auth/lib/app/view/app.dart+++ b/mobile/apps/auth/lib/app/view/app.dart@@ -23,12 +23,10 @@ import 'package:flutter_localizations/flutter_localizations.dart';class App extends StatefulWidget {final Locale? locale;final ThemeMode savedThemeMode;- final bool hasInaccessibleOfflineCodes;const App({super.key,this.locale = const Locale("en"),this.savedThemeMode = ThemeMode.system,- this.hasInaccessibleOfflineCodes = false,});static void setLocale(BuildContext context, Locale newLocale) {@@ -147,15 +145,14 @@ class _AppState extends State<App> with WidgetsBindingObserver {return {"/": (context) {final config = Configuration.instance;+ final hasConfiguredAccount = config.hasConfiguredAccount();final hasOfflineAccount = config.hasOptedForOfflineMode();final isOfflineKeyMissing =hasOfflineAccount && config.getOfflineSecretKey() == null;final shouldShowOfflineKeyUnavailableDialog =- isOfflineKeyMissing &&- (!config.hasConfiguredAccount() ||- widget.hasInaccessibleOfflineCodes);+ !hasConfiguredAccount && isOfflineKeyMissing;return !shouldShowOfflineKeyUnavailableDialog &&- (config.hasConfiguredAccount() || hasOfflineAccount)+ (hasConfiguredAccount || hasOfflineAccount)? const HomePage(): OnboardingPage(showOfflineKeyUnavailableDialog:diff --git a/mobile/apps/auth/lib/main.dart b/mobile/apps/auth/lib/main.dartindex 5239640e2b..17d823df91 100644--- a/mobile/apps/auth/lib/main.dart+++ b/mobile/apps/auth/lib/main.dart@@ -19,7 +19,6 @@ import 'package:ente_auth/services/window_listener_service.dart';import 'package:ente_auth/store/authenticator_db.dart';import 'package:ente_auth/store/code_display_store.dart';import 'package:ente_auth/store/code_store.dart';-import 'package:ente_auth/store/offline_authenticator_db.dart';import 'package:ente_auth/ui/home_page.dart';import 'package:ente_auth/ui/utils/icon_utils.dart';import 'package:ente_auth/utils/debug_build_flags.dart';@@ -146,17 +145,10 @@ Future<void> _runInForeground() async {rethrow;}final Locale? locale = await getLocale(noFallback: true);- final hasInaccessibleOfflineCodes = await _hasInaccessibleOfflineCodes(- configuration,- );unawaited(UpdateService.instance.showUpdateNotification());runApp(AppLock(- builder: (args) => App(- locale: locale,- savedThemeMode: savedThemeMode,- hasInaccessibleOfflineCodes: hasInaccessibleOfflineCodes,- ),+ builder: (args) => App(locale: locale, savedThemeMode: savedThemeMode),debugShowCheckedModeBanner: false,lockScreen: LockScreen(configuration),enabled: await LockScreenSettings.instance.shouldShowLockScreen(),@@ -175,20 +167,6 @@ Future<void> _runInForeground() async {});}-Future<bool> _hasInaccessibleOfflineCodes(Configuration configuration) async {- if (!configuration.hasConfiguredAccount() ||- !configuration.hasOptedForOfflineMode() ||- configuration.getOfflineSecretKey() != null) {- return false;- }- try {- return await OfflineAuthenticatorDB.instance.hasEntries();- } catch (error, stackTrace) {- _logger.severe("Failed to inspect offline codes", error, stackTrace);- return true;- }-}-Future _runWithLogs(Function() function, {String prefix = ""}) async {String dir = "";try {diff --git a/mobile/apps/auth/lib/onboarding/view/onboarding_page.dart b/mobile/apps/auth/lib/onboarding/view/onboarding_page.dartindex d92258e194..c0b3fb77bd 100644--- a/mobile/apps/auth/lib/onboarding/view/onboarding_page.dart+++ b/mobile/apps/auth/lib/onboarding/view/onboarding_page.dart@@ -267,7 +267,8 @@ class _OnboardingPageState extends State<OnboardingPage> {return;}final bool hasOptedBefore = Configuration.instance.hasOptedForOfflineMode();- if (hasOptedBefore &&+ if (!Configuration.instance.hasConfiguredAccount() &&+ hasOptedBefore &&Configuration.instance.getOfflineSecretKey() == null) {await _showOfflineKeyUnavailableDialog();return;diff --git a/mobile/apps/auth/lib/store/offline_authenticator_db.dart b/mobile/apps/auth/lib/store/offline_authenticator_db.dartindex 12cb81c349..9fe86f2660 100644--- a/mobile/apps/auth/lib/store/offline_authenticator_db.dart+++ b/mobile/apps/auth/lib/store/offline_authenticator_db.dart@@ -146,16 +146,6 @@ class OfflineAuthenticatorDB {return _convertRows(rows);}- Future<bool> hasEntries() async {- final db = await instance.database;- final rows = await db.query(- entityTable,- columns: ['_generatedID'],- limit: 1,- );- return rows.isNotEmpty;- }-Future<void> deleteByIDs({List<int>? generatedIDs, List<String>? ids}) async {final db = await instance.database;final batch = db.batch();