feat: Add a base trust manager class

This commit is contained in:
2022-08-08 18:03:05 +02:00
parent e9f190036c
commit dafd0af1e5
6 changed files with 133 additions and 25 deletions

11
lib/src/trust/always.dart Normal file
View File

@@ -0,0 +1,11 @@
import 'package:meta/meta.dart';
import 'package:omemo_dart/src/trust/base.dart';
/// Only use for testing!
/// An implementation of TrustManager that always trusts every device and thus
/// has no internal state.
@visibleForTesting
class AlwaysTrustingTrustManager extends TrustManager {
@override
Future<bool> isTrusted(String jid, int deviceId) async => true;
}

7
lib/src/trust/base.dart Normal file
View File

@@ -0,0 +1,7 @@
/// The base class for managing trust in OMEMO sessions.
// ignore: one_member_abstracts
abstract class TrustManager {
/// Return true when the device with id [deviceId] of Jid [jid] is trusted, i.e. if an
/// encrypted message should be sent to this device. If not, return false.
Future<bool> isTrusted(String jid, int deviceId);
}