From b5efc2dfae81e648c08d5608b7b3d04e190ba82d Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Tue, 20 Jun 2023 16:35:51 +0200 Subject: [PATCH] feat(xep): Expose new/replaced ratchets in the MessageEvent --- packages/moxxmpp/lib/src/xeps/xep_0384/types.dart | 9 +++++++++ packages/moxxmpp/lib/src/xeps/xep_0384/xep_0384.dart | 6 ++++++ packages/moxxmpp/pubspec.yaml | 9 ++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/moxxmpp/lib/src/xeps/xep_0384/types.dart b/packages/moxxmpp/lib/src/xeps/xep_0384/types.dart index bb1331a..c21ffc6 100644 --- a/packages/moxxmpp/lib/src/xeps/xep_0384/types.dart +++ b/packages/moxxmpp/lib/src/xeps/xep_0384/types.dart @@ -1,3 +1,4 @@ +import 'package:moxxmpp/src/managers/data.dart'; import 'package:omemo_dart/omemo_dart.dart'; /// A simple wrapper class for defining elements that should not be encrypted. @@ -18,3 +19,11 @@ class OmemoEncryptionError { /// See omemo_dart's EncryptionResult for info on this field. final Map> deviceEncryptionErrors; } + +class OmemoData extends StanzaHandlerExtension { + OmemoData(this.newRatchets, this.replacedRatchets); + + final Map> newRatchets; + + final Map> replacedRatchets; +} diff --git a/packages/moxxmpp/lib/src/xeps/xep_0384/xep_0384.dart b/packages/moxxmpp/lib/src/xeps/xep_0384/xep_0384.dart index 2ea82c3..cdddcd8 100644 --- a/packages/moxxmpp/lib/src/xeps/xep_0384/xep_0384.dart +++ b/packages/moxxmpp/lib/src/xeps/xep_0384/xep_0384.dart @@ -516,6 +516,12 @@ class OmemoManager extends XmppManagerBase { children: children, tag: stanza.tag, attributes: Map.from(stanza.attributes), + ) + ..extensions.set( + OmemoData( + result.newRatchets, + result.replacedRatchets, + ), ); } diff --git a/packages/moxxmpp/pubspec.yaml b/packages/moxxmpp/pubspec.yaml index b6d7e95..e57a52b 100644 --- a/packages/moxxmpp/pubspec.yaml +++ b/packages/moxxmpp/pubspec.yaml @@ -19,7 +19,7 @@ dependencies: version: ^0.2.0 omemo_dart: hosted: https://git.polynom.me/api/packages/PapaTutuWawa/pub - version: ^0.5.0 + version: ^0.5.1 random_string: ^2.3.1 saslprep: ^1.0.2 synchronized: ^3.0.0+2 @@ -30,3 +30,10 @@ dev_dependencies: build_runner: ^2.1.11 test: ^1.16.0 very_good_analysis: ^3.0.1 + +# TODO: Remove once we release 0.5.1 +dependency_overrides: + omemo_dart: + git: + url: https://github.com/PapaTutuWawa/omemo_dart.git + rev: 49c7e114e6cf80dcde55fbbd218bba3182045862