kopia lustrzana https://gitlab.com/jaywink/federation
Fix RSA object usage in type hints
It seems little-boxes replaced our crypto library which caused a bit of a mayhem since some of the internal objects don't match. If we need that library after all, will need to drop these type hints.merge-requests/131/head
rodzic
dc988add94
commit
db049c6638
|
@ -2,7 +2,7 @@ import json
|
||||||
import logging
|
import logging
|
||||||
from typing import List, Tuple, Union
|
from typing import List, Tuple, Union
|
||||||
|
|
||||||
from Crypto.PublicKey.RSA import RsaKey
|
from Crypto.PublicKey.RSA import _RSAobj
|
||||||
|
|
||||||
from federation.entities.diaspora.mappers import get_outbound_entity
|
from federation.entities.diaspora.mappers import get_outbound_entity
|
||||||
from federation.entities.mixins import BaseEntity
|
from federation.entities.mixins import BaseEntity
|
||||||
|
@ -15,7 +15,7 @@ logger = logging.getLogger("federation")
|
||||||
|
|
||||||
|
|
||||||
def handle_create_payload(
|
def handle_create_payload(
|
||||||
entity:BaseEntity, author_user:UserType, to_user_key:RsaKey=None, parent_user:UserType=None) -> str:
|
entity:BaseEntity, author_user:UserType, to_user_key:_RSAobj=None, parent_user:UserType=None) -> str:
|
||||||
"""Create a payload with the correct protocol.
|
"""Create a payload with the correct protocol.
|
||||||
|
|
||||||
Any given user arguments must have ``private_key`` and ``handle`` attributes.
|
Any given user arguments must have ``private_key`` and ``handle`` attributes.
|
||||||
|
@ -41,7 +41,7 @@ def handle_create_payload(
|
||||||
def handle_send(
|
def handle_send(
|
||||||
entity: BaseEntity,
|
entity: BaseEntity,
|
||||||
author_user: UserType,
|
author_user: UserType,
|
||||||
recipients: List[Union[Tuple[str, RsaKey], str]]=None,
|
recipients: List[Union[Tuple[str, _RSAobj], str]]=None,
|
||||||
parent_user: UserType=None,
|
parent_user: UserType=None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Send an entity to remote servers.
|
"""Send an entity to remote servers.
|
||||||
|
|
|
@ -4,7 +4,7 @@ from base64 import urlsafe_b64decode
|
||||||
from typing import Callable, Tuple, Union, Dict
|
from typing import Callable, Tuple, Union, Dict
|
||||||
from urllib.parse import unquote
|
from urllib.parse import unquote
|
||||||
|
|
||||||
from Crypto.PublicKey.RSA import RsaKey
|
from Crypto.PublicKey.RSA import _RSAobj
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
|
||||||
from federation.entities.mixins import BaseEntity
|
from federation.entities.mixins import BaseEntity
|
||||||
|
@ -122,7 +122,7 @@ class Protocol:
|
||||||
raise NoSenderKeyFoundError("Could not find a sender contact to retrieve key")
|
raise NoSenderKeyFoundError("Could not find a sender contact to retrieve key")
|
||||||
MagicEnvelope(doc=self.doc, public_key=sender_key, verify=True)
|
MagicEnvelope(doc=self.doc, public_key=sender_key, verify=True)
|
||||||
|
|
||||||
def build_send(self, entity:BaseEntity, from_user:UserType, to_user_key:RsaKey=None) -> Union[str, Dict]:
|
def build_send(self, entity:BaseEntity, from_user:UserType, to_user_key:_RSAobj=None) -> Union[str, Dict]:
|
||||||
"""
|
"""
|
||||||
Build POST data for sending out to remotes.
|
Build POST data for sending out to remotes.
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue