refactor: capture member variables as finals
This commit is contained in:
parent
41d905ca60
commit
85004e1faf
|
|
@ -687,31 +687,35 @@ class OpenSSSS {
|
|||
}
|
||||
|
||||
Future<String> getStored(String type) async {
|
||||
final privateKey = this.privateKey;
|
||||
if (privateKey == null) {
|
||||
throw Exception('SSSS not unlocked');
|
||||
}
|
||||
return await ssss.getStored(type, keyId, privateKey!);
|
||||
return await ssss.getStored(type, keyId, privateKey);
|
||||
}
|
||||
|
||||
Future<void> store(String type, String secret, {bool add = false}) async {
|
||||
final privateKey = this.privateKey;
|
||||
if (privateKey == null) {
|
||||
throw Exception('SSSS not unlocked');
|
||||
}
|
||||
await ssss.store(type, secret, keyId, privateKey!, add: add);
|
||||
await ssss.store(type, secret, keyId, privateKey, add: add);
|
||||
}
|
||||
|
||||
Future<void> validateAndStripOtherKeys(String type, String secret) async {
|
||||
final privateKey = this.privateKey;
|
||||
if (privateKey == null) {
|
||||
throw Exception('SSSS not unlocked');
|
||||
}
|
||||
await ssss.validateAndStripOtherKeys(type, secret, keyId, privateKey!);
|
||||
await ssss.validateAndStripOtherKeys(type, secret, keyId, privateKey);
|
||||
}
|
||||
|
||||
Future<void> maybeCacheAll() async {
|
||||
final privateKey = this.privateKey;
|
||||
if (privateKey == null) {
|
||||
throw Exception('SSSS not unlocked');
|
||||
}
|
||||
await ssss.maybeCacheAll(keyId, privateKey!);
|
||||
await ssss.maybeCacheAll(keyId, privateKey);
|
||||
}
|
||||
|
||||
Future<void> _postUnlock() async {
|
||||
|
|
|
|||
|
|
@ -232,10 +232,10 @@ class Bootstrap {
|
|||
|
||||
void migrateOldSsss() {
|
||||
final keys = allNeededKeys();
|
||||
oldSsssKeys = <String, OpenSSSS>{};
|
||||
final oldSsssKeys = this.oldSsssKeys = {};
|
||||
try {
|
||||
for (final key in keys) {
|
||||
oldSsssKeys![key] = encryption.ssss.open(key);
|
||||
oldSsssKeys[key] = encryption.ssss.open(key);
|
||||
}
|
||||
} catch (e, s) {
|
||||
Logs().e('[Bootstrapping] Error construction ssss key', e, s);
|
||||
|
|
@ -312,15 +312,15 @@ class Bootstrap {
|
|||
}
|
||||
|
||||
Future<void> openExistingSsss() async {
|
||||
final newSsssKey_ = newSsssKey;
|
||||
if (state != BootstrapState.openExistingSsss || newSsssKey_ == null) {
|
||||
final newSsssKey = this.newSsssKey;
|
||||
if (state != BootstrapState.openExistingSsss || newSsssKey == null) {
|
||||
throw BootstrapBadStateException();
|
||||
}
|
||||
if (!newSsssKey_.isUnlocked) {
|
||||
if (!newSsssKey.isUnlocked) {
|
||||
throw BootstrapBadStateException('Key not unlocked');
|
||||
}
|
||||
Logs().v('Maybe cache all...');
|
||||
await newSsssKey_.maybeCacheAll();
|
||||
await newSsssKey.maybeCacheAll();
|
||||
checkCrossSigning();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -252,8 +252,9 @@ class KeyVerification {
|
|||
// as such, we better set it *before* we send our start
|
||||
lastStep = type;
|
||||
// TODO: Pick method?
|
||||
method = _makeVerificationMethod(possibleMethods.first, this);
|
||||
await method!.sendStart();
|
||||
final method = this.method =
|
||||
_makeVerificationMethod(possibleMethods.first, this);
|
||||
await method.sendStart();
|
||||
setState(KeyVerificationState.waitingAccept);
|
||||
break;
|
||||
case EventTypes.KeyVerificationStart:
|
||||
|
|
@ -320,8 +321,9 @@ class KeyVerification {
|
|||
setState(KeyVerificationState.error);
|
||||
break;
|
||||
default:
|
||||
final method = this.method;
|
||||
if (method != null) {
|
||||
await method!.handlePayload(type, payload);
|
||||
await method.handlePayload(type, payload);
|
||||
} else {
|
||||
await cancel('m.invalid_message');
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue