Compare commits
3 Commits
v0.3.2
...
4346b31637
| Author | SHA1 | Date | |
|---|---|---|---|
| 4346b31637 | |||
| fe1ba99b14 | |||
| 797bf69856 |
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
ko_fi: papatutuwawa
|
||||
@@ -56,3 +56,9 @@ messages' formatting.
|
||||
Licensed under the MIT license.
|
||||
|
||||
See `LICENSE`.
|
||||
|
||||
## Support
|
||||
|
||||
If you like what I do and you want to support me, feel free to donate to me on Ko-Fi.
|
||||
|
||||
[<img src="https://codeberg.org/moxxy/moxxyv2/raw/branch/master/assets/repo/kofi.png" height="36" style="height: 36px; border: 0px;"></img>](https://ko-fi.com/papatutuwawa)
|
||||
|
||||
@@ -5,16 +5,17 @@ abstract class OmemoEvent {}
|
||||
|
||||
/// Triggered when a ratchet has been modified
|
||||
class RatchetModifiedEvent extends OmemoEvent {
|
||||
|
||||
RatchetModifiedEvent(this.jid, this.deviceId, this.ratchet);
|
||||
RatchetModifiedEvent(this.jid, this.deviceId, this.ratchet, this.added);
|
||||
final String jid;
|
||||
final int deviceId;
|
||||
final OmemoDoubleRatchet ratchet;
|
||||
|
||||
/// Indicates whether the ratchet has just been created (true) or just modified (false).
|
||||
final bool added;
|
||||
}
|
||||
|
||||
/// Triggered when a ratchet has been removed and should be removed from storage.
|
||||
class RatchetRemovedEvent extends OmemoEvent {
|
||||
|
||||
RatchetRemovedEvent(this.jid, this.deviceId);
|
||||
final String jid;
|
||||
final int deviceId;
|
||||
@@ -22,7 +23,6 @@ class RatchetRemovedEvent extends OmemoEvent {
|
||||
|
||||
/// Triggered when the device map has been modified
|
||||
class DeviceMapModifiedEvent extends OmemoEvent {
|
||||
|
||||
DeviceMapModifiedEvent(this.map);
|
||||
final Map<String, List<int>> map;
|
||||
}
|
||||
@@ -30,7 +30,6 @@ class DeviceMapModifiedEvent extends OmemoEvent {
|
||||
/// Triggered by the OmemoSessionManager when our own device bundle was modified
|
||||
/// and thus should be republished.
|
||||
class DeviceModifiedEvent extends OmemoEvent {
|
||||
|
||||
DeviceModifiedEvent(this.device);
|
||||
final Device device;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import 'package:synchronized/synchronized.dart';
|
||||
const omemoPayloadInfoString = 'OMEMO Payload';
|
||||
|
||||
class OmemoSessionManager {
|
||||
|
||||
OmemoSessionManager(this._device, this._deviceMap, this._ratchetMap, this._trustManager)
|
||||
: _lock = Lock(),
|
||||
_deviceLock = Lock(),
|
||||
@@ -136,7 +135,7 @@ class OmemoSessionManager {
|
||||
_ratchetMap[key] = ratchet;
|
||||
|
||||
// Commit the ratchet
|
||||
_eventStreamController.add(RatchetModifiedEvent(jid, deviceId, ratchet));
|
||||
_eventStreamController.add(RatchetModifiedEvent(jid, deviceId, ratchet, true));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -321,7 +320,7 @@ class OmemoSessionManager {
|
||||
}
|
||||
|
||||
// Commit the ratchet
|
||||
_eventStreamController.add(RatchetModifiedEvent(jid, deviceId, ratchet));
|
||||
_eventStreamController.add(RatchetModifiedEvent(jid, deviceId, ratchet, false));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -346,6 +345,7 @@ class OmemoSessionManager {
|
||||
mapKey.jid,
|
||||
mapKey.deviceId,
|
||||
oldRatchet,
|
||||
false,
|
||||
),
|
||||
);
|
||||
});
|
||||
@@ -421,6 +421,7 @@ class OmemoSessionManager {
|
||||
senderJid,
|
||||
senderDeviceId,
|
||||
oldRatchet,
|
||||
false,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -476,7 +477,14 @@ class OmemoSessionManager {
|
||||
}
|
||||
|
||||
// Commit the ratchet
|
||||
_eventStreamController.add(RatchetModifiedEvent(senderJid, senderDeviceId, ratchet));
|
||||
_eventStreamController.add(
|
||||
RatchetModifiedEvent(
|
||||
senderJid,
|
||||
senderDeviceId,
|
||||
ratchet,
|
||||
false,
|
||||
),
|
||||
);
|
||||
|
||||
try {
|
||||
return _decryptAndVerifyHmac(ciphertext, keyAndHmac);
|
||||
@@ -606,7 +614,7 @@ class OmemoSessionManager {
|
||||
..acknowledged = true;
|
||||
|
||||
// Commit it
|
||||
_eventStreamController.add(RatchetModifiedEvent(jid, deviceId, ratchet));
|
||||
_eventStreamController.add(RatchetModifiedEvent(jid, deviceId, ratchet, false));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -122,17 +122,20 @@ abstract class BlindTrustBeforeVerificationTrustManager extends TrustManager {
|
||||
});
|
||||
}
|
||||
|
||||
/// Returns a mapping from the device identifiers of [jid] to their trust state.
|
||||
/// Returns a mapping from the device identifiers of [jid] to their trust state. If
|
||||
/// there are no devices known for [jid], then an empty map is returned.
|
||||
Future<Map<int, BTBVTrustState>> getDevicesTrust(String jid) async {
|
||||
final map = <int, BTBVTrustState>{};
|
||||
return _lock.synchronized(() async {
|
||||
final map = <int, BTBVTrustState>{};
|
||||
|
||||
await _lock.synchronized(() async {
|
||||
if (!devices.containsKey(jid)) return map;
|
||||
|
||||
for (final deviceId in devices[jid]!) {
|
||||
map[deviceId] = trustCache[RatchetMapKey(jid, deviceId)]!;
|
||||
}
|
||||
});
|
||||
|
||||
return map;
|
||||
return map;
|
||||
});
|
||||
}
|
||||
|
||||
/// Sets the trust of [jid]'s device with identifier [deviceId] to [state].
|
||||
|
||||
Reference in New Issue
Block a user