Skip to content

Commit ef2b708

Browse files
committed
wip
1 parent 904bf54 commit ef2b708

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

lib/cubit/vault_cubit.dart

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ class VaultCubit extends Cubit<VaultState> {
557557
/// Our understanding of which situation we need to recover from can change as we proceed through the various attempts to recover.
558558
Future<void> refresh(User user,
559559
{String? overridePasswordRemote,
560-
PasswordMismatchRecoverySituation recovery = PasswordMismatchRecoverySituation.None}) async {
560+
PasswordMismatchRecoverySituation recovery = PasswordMismatchRecoverySituation.none}) async {
561561
VaultState s = state;
562562

563563
if (s is VaultLoaded) {
@@ -569,11 +569,11 @@ class VaultCubit extends Cubit<VaultState> {
569569
l.i('refresh called during an ongoing refresh operation. Will not start a new refresh now.');
570570
return;
571571
}
572-
if (s is VaultRefreshCredentialsRequired && recovery == PasswordMismatchRecoverySituation.None) {
572+
if (s is VaultRefreshCredentialsRequired && recovery == PasswordMismatchRecoverySituation.none) {
573573
l.i('refresh called during an ongoing refresh credentials repair operation. Will not refresh now.');
574574
return;
575575
}
576-
if (s is VaultUploadCredentialsRequired && recovery == PasswordMismatchRecoverySituation.None) {
576+
if (s is VaultUploadCredentialsRequired && recovery == PasswordMismatchRecoverySituation.none) {
577577
l.i('refresh called during an ongoing upload credentials repair operation. Will not refresh now.');
578578
return;
579579
}
@@ -586,17 +586,17 @@ class VaultCubit extends Cubit<VaultState> {
586586
Credentials credsRemote = credsLocal;
587587
StrengthAssessedCredentials? credentialsOverrideWithStrength;
588588

589-
if (recovery != PasswordMismatchRecoverySituation.None && overridePasswordRemote != null) {
589+
if (recovery != PasswordMismatchRecoverySituation.none && overridePasswordRemote != null) {
590590
l.d('we will attempt a recovery from a mismatched password');
591591
final protectedValue = ProtectedValue.fromString(overridePasswordRemote);
592592
credentialsOverrideWithStrength = StrengthAssessedCredentials(protectedValue, user.emailParts);
593-
if (recovery == PasswordMismatchRecoverySituation.RemoteUserDiffers) {
593+
if (recovery == PasswordMismatchRecoverySituation.remoteUserDiffers) {
594594
l.d('we have a service password explicitly supplied');
595595

596596
final key = protectedValue.hash;
597597
await user.attachKey(key);
598598
}
599-
if (recovery == PasswordMismatchRecoverySituation.RemoteFileDiffers) {
599+
if (recovery == PasswordMismatchRecoverySituation.remoteFileDiffers) {
600600
l.d('we have a KDBX password explicitly supplied');
601601
credsRemote = credentialsOverrideWithStrength.credentials;
602602
}
@@ -642,7 +642,7 @@ class VaultCubit extends Cubit<VaultState> {
642642
l.d('lastRemoteEtag: $lastRemoteEtag');
643643
final tempLockedFile = await _remoteVaultRepo.download(user, credsRemote, lastRemoteEtag);
644644

645-
if (recovery == PasswordMismatchRecoverySituation.RemoteUserDiffers) {
645+
if (recovery == PasswordMismatchRecoverySituation.remoteUserDiffers) {
646646
// 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.
647647
l.d('Updating QU with newly successful service password');
648648
await _qu.saveQuickUnlockUserPassKey(user.passKey);
@@ -694,10 +694,10 @@ class VaultCubit extends Cubit<VaultState> {
694694
lockedFile = tempLockedFile;
695695
} on KdbxInvalidKeyException {
696696
// Pretty sure this can't happen - download doesn't actually attempt to unlock the downloaded file and autofillMerge handles the exception itself.
697-
handleRefreshAuthError(s.vault, recovery: PasswordMismatchRecoverySituation.RemoteFileDiffers);
697+
handleRefreshAuthError(s.vault, recovery: PasswordMismatchRecoverySituation.remoteFileDiffers);
698698
return;
699699
} on KeeLoginRequiredException {
700-
handleRefreshAuthError(s.vault, recovery: PasswordMismatchRecoverySituation.RemoteUserDiffers);
700+
handleRefreshAuthError(s.vault, recovery: PasswordMismatchRecoverySituation.remoteUserDiffers);
701701
return;
702702
} on KeeSubscriptionExpiredException {
703703
emitError(
@@ -753,7 +753,7 @@ class VaultCubit extends Cubit<VaultState> {
753753

754754
// 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.
755755
// updatedLocalFile must be null if we are in remotefilediffers mode
756-
if (recovery == PasswordMismatchRecoverySituation.RemoteFileDiffers && successfulCredentials != null) {
756+
if (recovery == PasswordMismatchRecoverySituation.remoteFileDiffers && successfulCredentials != null) {
757757
l.d('Updating QU with newly successful KDBX password');
758758
final requireFullPasswordPeriod =
759759
int.tryParse(Settings.getValue<String>('requireFullPasswordPeriod') ?? '60') ?? 60;
@@ -781,7 +781,7 @@ class VaultCubit extends Cubit<VaultState> {
781781
// etag during the next refresh or upload operation, we will re-download the update
782782
// and perform a merge. This should be a NOOP but is inefficient.
783783
handleRefreshAuthError(updatedLocalFile ?? s.vault,
784-
recovery: PasswordMismatchRecoverySituation.RemoteFileDiffers);
784+
recovery: PasswordMismatchRecoverySituation.remoteFileDiffers);
785785
} on Exception catch (e, stack) {
786786
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");
787787
emitError(
@@ -1132,7 +1132,7 @@ class VaultCubit extends Cubit<VaultState> {
11321132
//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.
11331133
Future<void> upload(User user, LocalVaultFile vault,
11341134
{String? overridePasswordRemote,
1135-
PasswordMismatchRecoverySituation recovery = PasswordMismatchRecoverySituation.None}) async {
1135+
PasswordMismatchRecoverySituation recovery = PasswordMismatchRecoverySituation.none}) async {
11361136
l.d('uploading vault with recovery mode $recovery');
11371137
VaultState s = state;
11381138
if (s is VaultLoaded) {
@@ -1157,17 +1157,17 @@ class VaultCubit extends Cubit<VaultState> {
11571157
'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.');
11581158
}
11591159

1160-
if (recovery != PasswordMismatchRecoverySituation.None && overridePasswordRemote != null) {
1160+
if (recovery != PasswordMismatchRecoverySituation.none && overridePasswordRemote != null) {
11611161
l.d('we will attempt a recovery from a mismatched password');
11621162
final protectedValue = ProtectedValue.fromString(overridePasswordRemote);
11631163
credentialsOverrideWithStrength = StrengthAssessedCredentials(protectedValue, user.emailParts);
1164-
if (recovery == PasswordMismatchRecoverySituation.RemoteUserDiffers) {
1164+
if (recovery == PasswordMismatchRecoverySituation.remoteUserDiffers) {
11651165
l.d('we have a service password explicitly supplied');
11661166

11671167
final key = protectedValue.hash;
11681168
await user.attachKey(key);
11691169
}
1170-
if (recovery == PasswordMismatchRecoverySituation.RemoteFileDiffers) {
1170+
if (recovery == PasswordMismatchRecoverySituation.remoteFileDiffers) {
11711171
l.d('we have a KDBX password explicitly supplied');
11721172
credsRemote = credentialsOverrideWithStrength.credentials;
11731173
}
@@ -1191,7 +1191,7 @@ class VaultCubit extends Cubit<VaultState> {
11911191
} on KeeLoginRequiredException {
11921192
l.w('Unable to determine latest remote file etag due to authentication error. User recently changed password elsewhere?');
11931193
handleUploadAuthError(updatedLocalFile, state is VaultSaving ? (state as VaultSaving).locally : false,
1194-
PasswordMismatchRecoverySituation.RemoteUserDiffers);
1194+
PasswordMismatchRecoverySituation.remoteUserDiffers);
11951195
return;
11961196
} on KeeServiceTransportException catch (e) {
11971197
final message = e.handle('Error establishing current remote file version');
@@ -1230,7 +1230,7 @@ class VaultCubit extends Cubit<VaultState> {
12301230
// 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.
12311231
l.w('Unable to download latest remote file for local merging due to authentication error. User recently changed password elsewhere?');
12321232
handleUploadAuthError(updatedLocalFile, state is VaultSaving ? (state as VaultSaving).locally : false,
1233-
PasswordMismatchRecoverySituation.RemoteUserDiffers);
1233+
PasswordMismatchRecoverySituation.remoteUserDiffers);
12341234
return;
12351235
} on KeeServiceTransportException catch (e) {
12361236
final message = e.handle('Error while downloading more recent changes from remote');
@@ -1348,7 +1348,7 @@ class VaultCubit extends Cubit<VaultState> {
13481348
_generatorProfilesCubit, updatedLocalFile.files.current.body.meta.keeVaultSettings);
13491349
} on KeeLoginRequiredException {
13501350
handleUploadAuthError(updatedLocalFile, state is VaultSaving ? (state as VaultSaving).locally : false,
1351-
PasswordMismatchRecoverySituation.RemoteUserDiffers);
1351+
PasswordMismatchRecoverySituation.remoteUserDiffers);
13521352
return;
13531353
} on KeeMissingPrimaryDBException {
13541354
emitKeeMissingPrimaryDBExceptionError();

lib/password_mismatch_recovery_situation.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
enum PasswordMismatchRecoverySituation {
2-
None,
3-
RemoteUserDiffers,
4-
RemoteFileDiffers,
2+
none,
3+
remoteUserDiffers,
4+
remoteFileDiffers,
55

66
//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?
77
//RemoteUserAndFileDiffers,

lib/widgets/vault.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class _VaultWidgetState extends State<VaultWidget> with WidgetsBindingObserver {
5656
Future<void> _refreshAuthenticate(String password) async {
5757
final user = BlocProvider.of<AccountCubit>(context).currentUser;
5858
final VaultState vaultState = BlocProvider.of<VaultCubit>(context).state;
59-
PasswordMismatchRecoverySituation recovery = PasswordMismatchRecoverySituation.None;
59+
PasswordMismatchRecoverySituation recovery = PasswordMismatchRecoverySituation.none;
6060
if (vaultState is VaultRefreshCredentialsRequired) {
6161
recovery = vaultState.recovery;
6262
}

0 commit comments

Comments
 (0)