From 98a975550aa4b0fc11c65ce43033e2466f0bb6dc Mon Sep 17 00:00:00 2001 From: Izalia Mae Date: Fri, 14 Jun 2024 13:34:05 -0400 Subject: [PATCH] use hs2019 for some servers that support it --- pyproject.toml | 19 ++++++++++++++++++- relay/http_client.py | 26 ++++++++++++++++++++------ 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index cf51b84..caf869b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ dependencies = [ "aiohttp >= 3.9.5", "aiohttp-swagger[performance] == 1.0.16", "argon2-cffi == 23.1.0", - "barkshark-lib >= 0.1.3", + "barkshark-lib >= 0.1.3-1", "barkshark-sql == 0.1.4-1", "click >= 8.1.2", "hiredis == 2.3.2", @@ -88,4 +88,21 @@ warn_redundant_casts = true warn_unreachable = true warn_unused_ignores = true ignore_missing_imports = true +implicit_reexport = true follow_imports = "silent" + +[[tool.mypy.overrides]] +module = "relay.database" +implicit_reexport = true + +[[tool.mypy.overrides]] +module = "aputils" +implicit_reexport = true + +[[tool.mypy.overrides]] +module = "blib" +implicit_reexport = true + +[[tool.mypy.overrides]] +module = "bsql" +implicit_reexport = true diff --git a/relay/http_client.py b/relay/http_client.py index c4d9da0..27c2dec 100644 --- a/relay/http_client.py +++ b/relay/http_client.py @@ -24,6 +24,21 @@ if typing.TYPE_CHECKING: from .cache import Cache +SUPPORTS_HS2019 = { + 'friendica', + 'gotosocial', + 'hubzilla' + 'mastodon', + 'socialhome', + 'misskey', + 'catodon', + 'cherrypick', + 'firefish', + 'foundkey', + 'iceshrimp', + 'sharkey' +} + T = typing.TypeVar('T', bound = JsonBase) HEADERS = { 'Accept': f'{MIMETYPES["activity"]}, {MIMETYPES["json"]};q=0.9', @@ -179,13 +194,12 @@ class HttpClient: if not self._session: raise RuntimeError('Client not open') - # there seems to be a problem with HS2019, so defaulting to RSASHA256 for now # akkoma and pleroma do not support HS2019 and other software still needs to be tested - # if instance and instance['software'] in {'mastodon'}: - # algorithm = AlgorithmType.HS2019 + if instance and instance['software'] in SUPPORTS_HS2019: + algorithm = AlgorithmType.HS2019 - # else: - # algorithm = AlgorithmType.RSASHA256 + else: + algorithm = AlgorithmType.RSASHA256 body: bytes message: Message @@ -204,7 +218,7 @@ class HttpClient: url, body, headers = {'Content-Type': 'application/activity+json'}, - algorithm = AlgorithmType.RSASHA256 + algorithm = algorithm ) try: