diff --git a/lib/cubit/vault_cubit.dart b/lib/cubit/vault_cubit.dart index a5c0bfa..14470e7 100644 --- a/lib/cubit/vault_cubit.dart +++ b/lib/cubit/vault_cubit.dart @@ -557,7 +557,7 @@ class VaultCubit extends Cubit { /// Our understanding of which situation we need to recover from can change as we proceed through the various attempts to recover. Future refresh(User user, {String? overridePasswordRemote, - PasswordMismatchRecoverySituation recovery = PasswordMismatchRecoverySituation.None}) async { + PasswordMismatchRecoverySituation recovery = PasswordMismatchRecoverySituation.none}) async { VaultState s = state; if (s is VaultLoaded) { @@ -569,11 +569,11 @@ class VaultCubit extends Cubit { l.i('refresh called during an ongoing refresh operation. Will not start a new refresh now.'); return; } - if (s is VaultRefreshCredentialsRequired && recovery == PasswordMismatchRecoverySituation.None) { + if (s is VaultRefreshCredentialsRequired && recovery == PasswordMismatchRecoverySituation.none) { l.i('refresh called during an ongoing refresh credentials repair operation. Will not refresh now.'); return; } - if (s is VaultUploadCredentialsRequired && recovery == PasswordMismatchRecoverySituation.None) { + if (s is VaultUploadCredentialsRequired && recovery == PasswordMismatchRecoverySituation.none) { l.i('refresh called during an ongoing upload credentials repair operation. Will not refresh now.'); return; } @@ -586,17 +586,17 @@ class VaultCubit extends Cubit { Credentials credsRemote = credsLocal; StrengthAssessedCredentials? credentialsOverrideWithStrength; - if (recovery != PasswordMismatchRecoverySituation.None && overridePasswordRemote != null) { + if (recovery != PasswordMismatchRecoverySituation.none && overridePasswordRemote != null) { l.d('we will attempt a recovery from a mismatched password'); final protectedValue = ProtectedValue.fromString(overridePasswordRemote); credentialsOverrideWithStrength = StrengthAssessedCredentials(protectedValue, user.emailParts); - if (recovery == PasswordMismatchRecoverySituation.RemoteUserDiffers) { + if (recovery == PasswordMismatchRecoverySituation.remoteUserDiffers) { l.d('we have a service password explicitly supplied'); final key = protectedValue.hash; await user.attachKey(key); } - if (recovery == PasswordMismatchRecoverySituation.RemoteFileDiffers) { + if (recovery == PasswordMismatchRecoverySituation.remoteFileDiffers) { l.d('we have a KDBX password explicitly supplied'); credsRemote = credentialsOverrideWithStrength.credentials; } @@ -642,7 +642,7 @@ class VaultCubit extends Cubit { l.d('lastRemoteEtag: $lastRemoteEtag'); final tempLockedFile = await _remoteVaultRepo.download(user, credsRemote, lastRemoteEtag); - if (recovery == PasswordMismatchRecoverySituation.RemoteUserDiffers) { + if (recovery == PasswordMismatchRecoverySituation.remoteUserDiffers) { // If we're in state 3 (or 4) this should get us into 2; User may need to enter the other password again when the next refresh operation happens (assuming we found no change to the kdbx to download this time) but they'll get the problem resolved eventually. l.d('Updating QU with newly successful service password'); await _qu.saveQuickUnlockUserPassKey(user.passKey); @@ -694,10 +694,10 @@ class VaultCubit extends Cubit { lockedFile = tempLockedFile; } on KdbxInvalidKeyException { // Pretty sure this can't happen - download doesn't actually attempt to unlock the downloaded file and autofillMerge handles the exception itself. - handleRefreshAuthError(s.vault, recovery: PasswordMismatchRecoverySituation.RemoteFileDiffers); + handleRefreshAuthError(s.vault, recovery: PasswordMismatchRecoverySituation.remoteFileDiffers); return; } on KeeLoginRequiredException { - handleRefreshAuthError(s.vault, recovery: PasswordMismatchRecoverySituation.RemoteUserDiffers); + handleRefreshAuthError(s.vault, recovery: PasswordMismatchRecoverySituation.remoteUserDiffers); return; } on KeeSubscriptionExpiredException { emitError( @@ -753,7 +753,7 @@ class VaultCubit extends Cubit { // RemoteFileDiffers only time and safe time to save the credentials? we are saying whatever creds worked to open the remote file is what we will save as the credentials needed to open the local file. // updatedLocalFile must be null if we are in remotefilediffers mode - if (recovery == PasswordMismatchRecoverySituation.RemoteFileDiffers && successfulCredentials != null) { + if (recovery == PasswordMismatchRecoverySituation.remoteFileDiffers && successfulCredentials != null) { l.d('Updating QU with newly successful KDBX password'); final requireFullPasswordPeriod = int.tryParse(Settings.getValue('requireFullPasswordPeriod') ?? '60') ?? 60; @@ -781,7 +781,7 @@ class VaultCubit extends Cubit { // etag during the next refresh or upload operation, we will re-download the update // and perform a merge. This should be a NOOP but is inefficient. handleRefreshAuthError(updatedLocalFile ?? s.vault, - recovery: PasswordMismatchRecoverySituation.RemoteFileDiffers); + recovery: PasswordMismatchRecoverySituation.remoteFileDiffers); } on Exception catch (e, stack) { l.e("Kee Vault failed to apply a change to your local vault for some unexpected reason or hardware fault. Please Share these application logs with us so that we can discuss and advise what to do next. If you have your Kee Vault on other devices, we recommend disconnecting them from the internet and exporting your vault to a KDBX file now, especially if you do not have a recent backup. We are likely to be able to restore all or most of your data but this may take a significant amount of time so the sooner you contact us to explain the details of what may have triggered the problem and share the error logs with us, the sooner we'll get you back up and running. Background refresh error: $e \n\n stack: $stack"); emitError( @@ -1132,7 +1132,7 @@ class VaultCubit extends Cubit { //TODO:f: check history after upload and warn user or attempt reconciliation in case that they uploaded a newer version from a different device in between our check for the latest version and the network upload completing. Future upload(User user, LocalVaultFile vault, {String? overridePasswordRemote, - PasswordMismatchRecoverySituation recovery = PasswordMismatchRecoverySituation.None}) async { + PasswordMismatchRecoverySituation recovery = PasswordMismatchRecoverySituation.none}) async { l.d('uploading vault with recovery mode $recovery'); VaultState s = state; if (s is VaultLoaded) { @@ -1157,17 +1157,17 @@ class VaultCubit extends Cubit { 'Cannot upload when we do not know the credentials required to perform merge operation or update KDBX password. Please tell us about this error so we can resolve it for you.'); } - if (recovery != PasswordMismatchRecoverySituation.None && overridePasswordRemote != null) { + if (recovery != PasswordMismatchRecoverySituation.none && overridePasswordRemote != null) { l.d('we will attempt a recovery from a mismatched password'); final protectedValue = ProtectedValue.fromString(overridePasswordRemote); credentialsOverrideWithStrength = StrengthAssessedCredentials(protectedValue, user.emailParts); - if (recovery == PasswordMismatchRecoverySituation.RemoteUserDiffers) { + if (recovery == PasswordMismatchRecoverySituation.remoteUserDiffers) { l.d('we have a service password explicitly supplied'); final key = protectedValue.hash; await user.attachKey(key); } - if (recovery == PasswordMismatchRecoverySituation.RemoteFileDiffers) { + if (recovery == PasswordMismatchRecoverySituation.remoteFileDiffers) { l.d('we have a KDBX password explicitly supplied'); credsRemote = credentialsOverrideWithStrength.credentials; } @@ -1191,7 +1191,7 @@ class VaultCubit extends Cubit { } on KeeLoginRequiredException { l.w('Unable to determine latest remote file etag due to authentication error. User recently changed password elsewhere?'); handleUploadAuthError(updatedLocalFile, state is VaultSaving ? (state as VaultSaving).locally : false, - PasswordMismatchRecoverySituation.RemoteUserDiffers); + PasswordMismatchRecoverySituation.remoteUserDiffers); return; } on KeeServiceTransportException catch (e) { final message = e.handle('Error establishing current remote file version'); @@ -1230,7 +1230,7 @@ class VaultCubit extends Cubit { // This should be rare because we've recently retrieved or checked our download auth token but can happen sometimes, maybe on very slow networks when the user is changing their master password elsewhere concurrently. l.w('Unable to download latest remote file for local merging due to authentication error. User recently changed password elsewhere?'); handleUploadAuthError(updatedLocalFile, state is VaultSaving ? (state as VaultSaving).locally : false, - PasswordMismatchRecoverySituation.RemoteUserDiffers); + PasswordMismatchRecoverySituation.remoteUserDiffers); return; } on KeeServiceTransportException catch (e) { final message = e.handle('Error while downloading more recent changes from remote'); @@ -1348,7 +1348,7 @@ class VaultCubit extends Cubit { _generatorProfilesCubit, updatedLocalFile.files.current.body.meta.keeVaultSettings); } on KeeLoginRequiredException { handleUploadAuthError(updatedLocalFile, state is VaultSaving ? (state as VaultSaving).locally : false, - PasswordMismatchRecoverySituation.RemoteUserDiffers); + PasswordMismatchRecoverySituation.remoteUserDiffers); return; } on KeeMissingPrimaryDBException { emitKeeMissingPrimaryDBExceptionError(); diff --git a/lib/password_mismatch_recovery_situation.dart b/lib/password_mismatch_recovery_situation.dart index 253e49e..ef8761a 100644 --- a/lib/password_mismatch_recovery_situation.dart +++ b/lib/password_mismatch_recovery_situation.dart @@ -1,7 +1,7 @@ enum PasswordMismatchRecoverySituation { - None, - RemoteUserDiffers, - RemoteFileDiffers, + none, + remoteUserDiffers, + remoteFileDiffers, //TODO: Probably can never know that these are the situation - can't tell the difference between user typing the wrong password and can't try the remote file password anyway until the service password is correct. Maybe delete these enum values? //RemoteUserAndFileDiffers, diff --git a/lib/widgets/vault.dart b/lib/widgets/vault.dart index 97e5f0b..5f7fca2 100644 --- a/lib/widgets/vault.dart +++ b/lib/widgets/vault.dart @@ -56,7 +56,7 @@ class _VaultWidgetState extends State with WidgetsBindingObserver { Future _refreshAuthenticate(String password) async { final user = BlocProvider.of(context).currentUser; final VaultState vaultState = BlocProvider.of(context).state; - PasswordMismatchRecoverySituation recovery = PasswordMismatchRecoverySituation.None; + PasswordMismatchRecoverySituation recovery = PasswordMismatchRecoverySituation.none; if (vaultState is VaultRefreshCredentialsRequired) { recovery = vaultState.recovery; }