plugin XEP-0384: Implementation of Automatic Trust Management:

- Implementation of Trust Messages (XEP-0434)
- Implementation of Automatic Trust Management (XEP-0450)
- Implementations directly as part of the OMEMO plugin, since omemo:2 is the only protocol supported by ATM at the moment
- Trust system selection updated to allow choice between manual trust with ATM and BTBV
- dev-requirements.txt updated to include additional requirements for the e2e tests

fix 376
This commit is contained in:
Syndace 2022-10-28 18:50:06 +02:00
commit e062c2f0e5
6 changed files with 818 additions and 161 deletions

View file

@ -6,3 +6,7 @@ mypy
pylint
pytest
pytest_twisted
sh
libervia-templates @ hg+https://repos.goffi.org/sat_templates
libervia-web @ hg+https://repos.goffi.org/libervia-web

View file

@ -19,7 +19,7 @@ html2text==2020.1.16
hyperlink==21.0.0
idna==3.3
incremental==21.3.0
Jinja2==3.1.2
Jinja2==3.0.3
langid==1.1.6
lxml==4.8.0
Mako==1.2.0

View file

@ -207,8 +207,6 @@ class XEP_0374:
else:
# I'm not sure why this check is required, this code is copied from XEP-0384
if sender_jid.userhostJID() == client.jid.userhostJID():
# TODO: I've seen this cause an exception "builtins.KeyError: 'to'", seems
# like "to" isn't always set.
try:
feedback_jid = jid.JID(message_elt["to"])
except KeyError:

File diff suppressed because it is too large Load diff

View file

@ -20,7 +20,7 @@
from collections import OrderedDict
import html.entities
import re
from typing import Optional, Tuple, Union, Literal, overload
from typing import Dict, Optional, Tuple, Union, Literal, overload
from xml.dom import NotFoundErr, minidom
import xml.etree.ElementTree as ET
from lxml import etree
@ -2030,3 +2030,37 @@ def domish_elt_2_et_elt(elt, lxml = False):
for child in elt.elements():
et_elt.append(domish_elt_2_et_elt(child, lxml=lxml))
return et_elt
def domish_elt_2_et_elt2(element: domish.Element) -> ET.Element:
"""
WIP, originally from the OMEMO plugin
"""
element_name = element.name
if element.uri is not None:
element_name = "{" + element.uri + "}" + element_name
attrib: Dict[str, str] = {}
for qname, value in element.attributes.items():
attribute_name = qname[1] if isinstance(qname, tuple) else qname
attribute_namespace = qname[0] if isinstance(qname, tuple) else None
if attribute_namespace is not None:
attribute_name = "{" + attribute_namespace + "}" + attribute_name
attrib[attribute_name] = value
result = ET.Element(element_name, attrib)
last_child: Optional[ET.Element] = None
for child in element.children:
if isinstance(child, str):
if last_child is None:
result.text = child
else:
last_child.tail = child
else:
last_child = domish_elt_2_et_elt2(child)
result.append(last_child)
return result

View file

@ -52,8 +52,8 @@ install_requires = [
'urwid-satext == 0.9.*',
'wokkel >= 18.0.0, < 19.0.0',
'omemo >= 1.0.0, < 2',
'twomemo[xml] >= 1.0.0, < 2',
'oldmemo[xml] >= 1.0.0, < 2',
'twomemo >= 1.0.0, < 2',
'oldmemo >= 1.0.0, < 2',
'pyyaml < 7.0.0',
'sqlalchemy >= 1.4',
'alembic',