6 Commits

6 changed files with 28 additions and 10 deletions

View File

@@ -9,3 +9,14 @@
- Fix bug with the Double Ratchet causing only the initial message to be decryptable - Fix bug with the Double Ratchet causing only the initial message to be decryptable
- Expose `getDeviceMap` as a developer usable function - Expose `getDeviceMap` as a developer usable function
## 0.2.0
- Add convenience functions `getDeviceId` and `getDeviceBundle`
- Creating a new ratchet with an id for which we already have a ratchet will now overwrite the old ratchet
- Ratchet now carry an "acknowledged" attribute
## 0.2.1
- Add `isRatchetAcknowledged`
- Ratchets that are created due to accepting a kex are now unacknowledged

View File

@@ -28,7 +28,7 @@ Include `omemo_dart` in your `pubspec.yaml` like this:
dependencies: dependencies:
omemo_dart: omemo_dart:
hosted: https://git.polynom.me/api/packages/PapaTutuWawa/pub hosted: https://git.polynom.me/api/packages/PapaTutuWawa/pub
version: ^0.1.0 version: ^0.2.0
# [...] # [...]
# [...] # [...]

View File

@@ -197,7 +197,7 @@ class OmemoDoubleRatchet {
ik, ik,
ad, ad,
{}, {},
true, false,
); );
} }

View File

@@ -446,20 +446,27 @@ class OmemoSessionManager {
/// Returns the list of device identifiers belonging to [jid] that are yet unacked, i.e. /// Returns the list of device identifiers belonging to [jid] that are yet unacked, i.e.
/// we have not yet received an empty OMEMO message from. /// we have not yet received an empty OMEMO message from.
Future<List<int>> getUnacknowledgedRatchets(String jid) async { Future<List<int>?> getUnacknowledgedRatchets(String jid) async {
final ret = List<int>.empty(growable: true); return _lock.synchronized(() async {
final ret = List<int>.empty(growable: true);
final devices = _deviceMap[jid];
if (devices == null) return null;
await _lock.synchronized(() async {
final devices = _deviceMap[jid]!;
for (final device in devices) { for (final device in devices) {
final ratchet = _ratchetMap[RatchetMapKey(jid, device)]!; final ratchet = _ratchetMap[RatchetMapKey(jid, device)]!;
if (!ratchet.acknowledged) ret.add(device); if (!ratchet.acknowledged) ret.add(device);
} }
});
return ret; return ret;
});
} }
/// Returns true if the ratchet for [jid] with device identifier [deviceId] is
/// acknowledged. Returns false if not.
Future<bool> isRatchetAcknowledged(String jid, int deviceId) async {
return _lock.synchronized(() => _ratchetMap[RatchetMapKey(jid, deviceId)]!.acknowledged);
}
/// Mark the ratchet for device [deviceId] from [jid] as acked. /// Mark the ratchet for device [deviceId] from [jid] as acked.
Future<void> ratchetAcknowledged(String jid, int deviceId) async { Future<void> ratchetAcknowledged(String jid, int deviceId) async {
await _lock.synchronized(() async { await _lock.synchronized(() async {

View File

@@ -1,6 +1,6 @@
name: omemo_dart name: omemo_dart
description: An XMPP library independent OMEMO library description: An XMPP library independent OMEMO library
version: 0.1.3 version: 0.2.1
homepage: https://github.com/PapaTutuWawa/omemo_dart homepage: https://github.com/PapaTutuWawa/omemo_dart
publish_to: https://git.polynom.me/api/packages/PapaTutuWawa/pub publish_to: https://git.polynom.me/api/packages/PapaTutuWawa/pub

View File

@@ -539,7 +539,7 @@ void main() {
// Alice marks the ratchet as acknowledged // Alice marks the ratchet as acknowledged
await aliceSession.ratchetAcknowledged(bobJid, await bobSession.getDeviceId()); await aliceSession.ratchetAcknowledged(bobJid, await bobSession.getDeviceId());
expect( expect(
(await aliceSession.getUnacknowledgedRatchets(bobJid)).isEmpty, (await aliceSession.getUnacknowledgedRatchets(bobJid))!.isEmpty,
true, true,
); );
}); });