1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
from __future__ import annotations
import enum
from typing import Dict, FrozenSet, List, Mapping, NamedTuple, Optional, Tuple, Union
from typing_extensions import TypeAlias
__all__ = [
"AsyncFramework",
"DeviceInformation",
"DeviceList",
"JSONType",
"OMEMOException",
"SignedLabel",
"TrustLevel"
]
@enum.unique
class AsyncFramework(enum.Enum):
"""
Frameworks for asynchronous code supported by python-omemo.
"""
ASYNCIO = "ASYNCIO"
TWISTED = "TWISTED"
class OMEMOException(Exception):
"""
Parent type for all custom exceptions in this library.
"""
class SignedLabel(NamedTuple):
# pylint: disable=invalid-name
"""
Structure containing a device label and the corresponding signature.
"""
label: str
signature: bytes
class DeviceInformation(NamedTuple):
# pylint: disable=invalid-name
"""
Structure containing information about a single OMEMO device.
"""
namespaces: FrozenSet[str]
active: FrozenSet[Tuple[str, bool]]
bare_jid: str
device_id: int
identity_key: bytes
trust_level_name: str
label: Optional[str]
@enum.unique
class TrustLevel(enum.Enum):
"""
The three core trust levels.
"""
TRUSTED = "TRUSTED"
DISTRUSTED = "DISTRUSTED"
UNDECIDED = "UNDECIDED"
DeviceList: TypeAlias = Dict[int, Optional[SignedLabel]]
JSONType: TypeAlias = Union[Mapping[str, "JSONType"], List["JSONType"], str, int, float, bool, None]
|