From 783a1ca0d2ab6e8bedf493b7f3a8f98e23beb653 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Fri, 11 May 2018 04:01:05 +0200 Subject: [PATCH] xep_0384: Add 'bundle' element --- stanza.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/stanza.py b/stanza.py index bc42009..e8a4f2d 100644 --- a/stanza.py +++ b/stanza.py @@ -69,6 +69,49 @@ class Payload(ElementBase): interfaces = set() +class Bundle(ElementBase): + namespace = OMEMO_BASE_NS + name = 'bundle' + plugin_attrib = name + interfaces = set() + + +class SignedPreKeyPublic(ElementBase): + namespace = OMEMO_BASE_NS + name = 'signedPreKeyPublic' + plugin_attrib = name + interfaces = {'id'} + + +class SignedPreKeySignature(ElementBase): + namespace = OMEMO_BASE_NS + name = 'signedPreKeySignature' + plugin_attrib = name + interfaces = set() + + +class IdentityKey(ElementBase): + namespace = OMEMO_BASE_NS + name = 'identityKey' + plugin_attrib = name + interfaces = set() + + +class PreKeys(ElementBase): + namespace = OMEMO_BASE_NS + name = 'prekeys' + plugin_attrib = name + interfaces = set() + + +class PreKeyPublic(ElementBase): + namespace = OMEMO_BASE_NS + name = 'preKeyPublic' + plugin_attrib = name + # TODO: XEP has mentions of "preKeyId" and "id" + interfaces = {'id'} + + register_stanza_plugin(Message, Encrypted) register_stanza_plugin(Encrypted, Header) register_stanza_plugin(Header, Key) @@ -77,3 +120,10 @@ register_stanza_plugin(Encrypted, Payload) register_stanza_plugin(EventItem, Devices) register_stanza_plugin(Devices, Device, iterable=True) + +register_stanza_plugin(EventItem, Bundle) +register_stanza_plugin(Bundle, SignedPreKeyPublic) +register_stanza_plugin(Bundle, SignedPreKeySignature) +register_stanza_plugin(Bundle, IdentityKey) +register_stanza_plugin(Bundle, PreKeys) +register_stanza_plugin(PreKeys, PreKeyPublic, iterable=True)