make that cleints can only use "verified"
This commit is contained in:
parent
ead44e4014
commit
eaefdb64ca
|
@ -1661,7 +1661,7 @@ class Client {
|
||||||
if (!oldKeys.containsKey(deviceId) || oldKeys[deviceId].ed25519Key == entry.ed25519Key) {
|
if (!oldKeys.containsKey(deviceId) || oldKeys[deviceId].ed25519Key == entry.ed25519Key) {
|
||||||
if (oldKeys.containsKey(deviceId)) {
|
if (oldKeys.containsKey(deviceId)) {
|
||||||
// be sure to save the verified status
|
// be sure to save the verified status
|
||||||
entry.verified = oldKeys[deviceId].verified;
|
entry.setDirectVerified(oldKeys[deviceId].directVerified);
|
||||||
entry.blocked = oldKeys[deviceId].blocked;
|
entry.blocked = oldKeys[deviceId].blocked;
|
||||||
entry.validSignatures = oldKeys[deviceId].validSignatures;
|
entry.validSignatures = oldKeys[deviceId].validSignatures;
|
||||||
}
|
}
|
||||||
|
@ -1670,7 +1670,7 @@ class Client {
|
||||||
entry.ed25519Key ==
|
entry.ed25519Key ==
|
||||||
fingerprintKey) {
|
fingerprintKey) {
|
||||||
// Always trust the own device
|
// Always trust the own device
|
||||||
entry.verified = true;
|
entry.setDirectVerified(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// This shouldn't ever happen. The same device ID has gotten
|
// This shouldn't ever happen. The same device ID has gotten
|
||||||
|
@ -1729,7 +1729,7 @@ class Client {
|
||||||
if (!oldKeys.containsKey(publicKey) || oldKeys[publicKey].ed25519Key == entry.ed25519Key) {
|
if (!oldKeys.containsKey(publicKey) || oldKeys[publicKey].ed25519Key == entry.ed25519Key) {
|
||||||
if (oldKeys.containsKey(publicKey)) {
|
if (oldKeys.containsKey(publicKey)) {
|
||||||
// be sure to save the verification status
|
// be sure to save the verification status
|
||||||
entry.verified = oldKeys[publicKey].verified;
|
entry.setDirectVerified(oldKeys[publicKey].directVerified);
|
||||||
entry.blocked = oldKeys[publicKey].blocked;
|
entry.blocked = oldKeys[publicKey].blocked;
|
||||||
entry.validSignatures = oldKeys[publicKey].validSignatures;
|
entry.validSignatures = oldKeys[publicKey].validSignatures;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,11 +76,19 @@ abstract class _SignedKey {
|
||||||
Map<String, String> keys;
|
Map<String, String> keys;
|
||||||
Map<String, dynamic> signatures;
|
Map<String, dynamic> signatures;
|
||||||
Map<String, dynamic> validSignatures;
|
Map<String, dynamic> validSignatures;
|
||||||
bool verified;
|
bool _verified;
|
||||||
bool blocked;
|
bool blocked;
|
||||||
|
|
||||||
String get ed25519Key => keys['ed25519:$identifier'];
|
String get ed25519Key => keys['ed25519:$identifier'];
|
||||||
|
|
||||||
|
bool get verified => directVerified || crossVerified;
|
||||||
|
|
||||||
|
void setDirectVerified(bool v) {
|
||||||
|
_verified = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool get directVerified => _verified;
|
||||||
|
|
||||||
bool get crossVerified {
|
bool get crossVerified {
|
||||||
try {
|
try {
|
||||||
return hasValidSignatureChain();
|
return hasValidSignatureChain();
|
||||||
|
@ -182,7 +190,7 @@ class CrossSigningKey extends _SignedKey {
|
||||||
bool get isValid => userId != null && publicKey != null && keys != null && ed25519Key != null;
|
bool get isValid => userId != null && publicKey != null && keys != null && ed25519Key != null;
|
||||||
|
|
||||||
Future<void> setVerified(bool newVerified) {
|
Future<void> setVerified(bool newVerified) {
|
||||||
verified = newVerified;
|
_verified = newVerified;
|
||||||
return client.database?.setVerifiedUserCrossSigningKey(newVerified, client.id, userId, publicKey);
|
return client.database?.setVerifiedUserCrossSigningKey(newVerified, client.id, userId, publicKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +215,7 @@ class CrossSigningKey extends _SignedKey {
|
||||||
validSignatures = validSignaturesContent.cast<String, dynamic>();
|
validSignatures = validSignaturesContent.cast<String, dynamic>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
verified = dbEntry.verified;
|
_verified = dbEntry.verified;
|
||||||
blocked = dbEntry.blocked;
|
blocked = dbEntry.blocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +229,7 @@ class CrossSigningKey extends _SignedKey {
|
||||||
? Map<String, dynamic>.from(json['signatures'])
|
? Map<String, dynamic>.from(json['signatures'])
|
||||||
: null;
|
: null;
|
||||||
validSignatures = null;
|
validSignatures = null;
|
||||||
verified = json['verified'] ?? false;
|
_verified = json['verified'] ?? false;
|
||||||
blocked = json['blocked'] ?? false;
|
blocked = json['blocked'] ?? false;
|
||||||
if (keys != null) {
|
if (keys != null) {
|
||||||
identifier = keys.values.first;
|
identifier = keys.values.first;
|
||||||
|
@ -238,7 +246,7 @@ class CrossSigningKey extends _SignedKey {
|
||||||
if (signatures != null) {
|
if (signatures != null) {
|
||||||
data['signatures'] = signatures;
|
data['signatures'] = signatures;
|
||||||
}
|
}
|
||||||
data['verified'] = verified;
|
data['verified'] = _verified;
|
||||||
data['blocked'] = blocked;
|
data['blocked'] = blocked;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
@ -254,7 +262,7 @@ class DeviceKeys extends _SignedKey {
|
||||||
bool get isValid => userId != null && deviceId != null && keys != null && curve25519Key != null && ed25519Key != null;
|
bool get isValid => userId != null && deviceId != null && keys != null && curve25519Key != null && ed25519Key != null;
|
||||||
|
|
||||||
Future<void> setVerified(bool newVerified) {
|
Future<void> setVerified(bool newVerified) {
|
||||||
verified = newVerified;
|
_verified = newVerified;
|
||||||
return client.database?.setVerifiedUserDeviceKey(newVerified, client.id, userId, deviceId);
|
return client.database?.setVerifiedUserDeviceKey(newVerified, client.id, userId, deviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,7 +298,7 @@ class DeviceKeys extends _SignedKey {
|
||||||
validSignatures = validSignaturesContent.cast<String, dynamic>();
|
validSignatures = validSignaturesContent.cast<String, dynamic>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
verified = dbEntry.verified;
|
_verified = dbEntry.verified;
|
||||||
blocked = dbEntry.blocked;
|
blocked = dbEntry.blocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,7 +315,7 @@ class DeviceKeys extends _SignedKey {
|
||||||
unsigned = json['unsigned'] != null
|
unsigned = json['unsigned'] != null
|
||||||
? Map<String, dynamic>.from(json['unsigned'])
|
? Map<String, dynamic>.from(json['unsigned'])
|
||||||
: null;
|
: null;
|
||||||
verified = json['verified'] ?? false;
|
_verified = json['verified'] ?? false;
|
||||||
blocked = json['blocked'] ?? false;
|
blocked = json['blocked'] ?? false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,7 +333,7 @@ class DeviceKeys extends _SignedKey {
|
||||||
if (unsigned != null) {
|
if (unsigned != null) {
|
||||||
data['unsigned'] = unsigned;
|
data['unsigned'] = unsigned;
|
||||||
}
|
}
|
||||||
data['verified'] = verified;
|
data['verified'] = _verified;
|
||||||
data['blocked'] = blocked;
|
data['blocked'] = blocked;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue