Add own-key support to fingerprint method
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
d40a9d90cc
commit
5a14785334
2 changed files with 21 additions and 7 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Version 0.7.0:
|
||||||
|
xxxx-xx-xx Maxime “pep” Buquet <pep@bouah.net>
|
||||||
|
* Changes:
|
||||||
|
- Add own-key support to fingerprint method. Requires Poezio 237fd74.
|
||||||
|
|
||||||
Version 0.6.0:
|
Version 0.6.0:
|
||||||
2022-04-03 Maxime “pep” Buquet <pep@bouah.net>
|
2022-04-03 Maxime “pep” Buquet <pep@bouah.net>
|
||||||
* Changes:
|
* Changes:
|
||||||
|
|
|
@ -16,12 +16,12 @@ import base64
|
||||||
import hashlib
|
import hashlib
|
||||||
import logging
|
import logging
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Dict, List, Optional
|
from typing import Dict, List, Optional, Tuple
|
||||||
|
|
||||||
from poezio import colors
|
from poezio import colors
|
||||||
from poezio.plugin_e2ee import E2EEPlugin
|
from poezio.plugin_e2ee import E2EEPlugin
|
||||||
from poezio.xdg import DATA_HOME
|
from poezio.xdg import DATA_HOME
|
||||||
from poezio.theming import Theme
|
from poezio.theming import Theme, dump_tuple
|
||||||
from poezio.tabs import ChatTab, DynamicConversationTab, StaticConversationTab, MucTab
|
from poezio.tabs import ChatTab, DynamicConversationTab, StaticConversationTab, MucTab
|
||||||
|
|
||||||
from omemo.exceptions import MissingBundleException
|
from omemo.exceptions import MissingBundleException
|
||||||
|
@ -123,13 +123,17 @@ class Plugin(E2EEPlugin):
|
||||||
"""Poezio logger Helper"""
|
"""Poezio logger Helper"""
|
||||||
self.api.information(txt, 'Error')
|
self.api.information(txt, 'Error')
|
||||||
|
|
||||||
async def get_fingerprints(self, jid: JID) -> List[str]:
|
async def get_fingerprints(self, jid: JID) -> List[Tuple[str, bool]]:
|
||||||
"""Return fingerprints for the provided JID"""
|
"""Return fingerprints for the provided JID"""
|
||||||
# XXX: Do we want to keep this here?
|
# XXX: Do we want to keep this here?
|
||||||
self.core.information('Fetching up-to-date fingerprint information…', 'Info')
|
self.core.information('Fetching up-to-date fingerprint information…', 'Info')
|
||||||
await self.core.xmpp['xep_0384'].fetch_devices(jid)
|
await self.core.xmpp['xep_0384'].fetch_devices(jid)
|
||||||
await self.core.xmpp['xep_0384'].fetch_bundles(jid)
|
await self.core.xmpp['xep_0384'].fetch_bundles(jid)
|
||||||
|
|
||||||
|
res: List[Tuple[str, bool]] = []
|
||||||
|
if jid.bare == self.core.xmpp.boundjid.bare:
|
||||||
|
res = [(await self.core.xmpp['xep_0384'].my_fingerprint(), True)]
|
||||||
|
|
||||||
devices = await self.core.xmpp['xep_0384'].get_trust_for_jid(jid)
|
devices = await self.core.xmpp['xep_0384'].get_trust_for_jid(jid)
|
||||||
|
|
||||||
# XXX: What to do with did -> None entries?
|
# XXX: What to do with did -> None entries?
|
||||||
|
@ -137,14 +141,16 @@ class Plugin(E2EEPlugin):
|
||||||
# For now I'll merge both. We should probably display them separately
|
# For now I'll merge both. We should probably display them separately
|
||||||
# later on.
|
# later on.
|
||||||
devices['active'].update(devices['inactive'])
|
devices['active'].update(devices['inactive'])
|
||||||
return [
|
res.extend([
|
||||||
slixmpp_omemo.fp_from_ik(trust['key'])
|
(slixmpp_omemo.fp_from_ik(trust['key']), False)
|
||||||
for trust in devices['active'].values()
|
for trust in devices['active'].values()
|
||||||
if trust is not None
|
if trust is not None
|
||||||
]
|
])
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def format_fingerprint(fingerprint: str, theme: Theme) -> str:
|
def format_fingerprint(fingerprint: str, own: bool, theme: Theme) -> str:
|
||||||
"""
|
"""
|
||||||
Color fingerprint as specified in in XEP-0384 0.8.3 Ҥ8 Security
|
Color fingerprint as specified in in XEP-0384 0.8.3 Ҥ8 Security
|
||||||
Considerations”.
|
Considerations”.
|
||||||
|
@ -166,6 +172,9 @@ class Plugin(E2EEPlugin):
|
||||||
elif i == size - 1:
|
elif i == size - 1:
|
||||||
separator = ''
|
separator = ''
|
||||||
colored_fp += f'\x19{fg_color}}}{part}{separator}'
|
colored_fp += f'\x19{fg_color}}}{part}{separator}'
|
||||||
|
if own:
|
||||||
|
normal_color = dump_tuple(theme.COLOR_NORMAL_TEXT)
|
||||||
|
colored_fp += f'\x19{normal_color}}} (this device)'
|
||||||
return colored_fp
|
return colored_fp
|
||||||
|
|
||||||
def reset_session(self, args: str) -> None:
|
def reset_session(self, args: str) -> None:
|
||||||
|
|
Loading…
Reference in a new issue