use hs2019 for some servers that support it

This commit is contained in:
Izalia Mae 2024-06-14 13:34:05 -04:00
parent ed03779a11
commit 98a975550a
2 changed files with 38 additions and 7 deletions

View file

@ -20,7 +20,7 @@ dependencies = [
"aiohttp >= 3.9.5", "aiohttp >= 3.9.5",
"aiohttp-swagger[performance] == 1.0.16", "aiohttp-swagger[performance] == 1.0.16",
"argon2-cffi == 23.1.0", "argon2-cffi == 23.1.0",
"barkshark-lib >= 0.1.3", "barkshark-lib >= 0.1.3-1",
"barkshark-sql == 0.1.4-1", "barkshark-sql == 0.1.4-1",
"click >= 8.1.2", "click >= 8.1.2",
"hiredis == 2.3.2", "hiredis == 2.3.2",
@ -88,4 +88,21 @@ warn_redundant_casts = true
warn_unreachable = true warn_unreachable = true
warn_unused_ignores = true warn_unused_ignores = true
ignore_missing_imports = true ignore_missing_imports = true
implicit_reexport = true
follow_imports = "silent" 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

View file

@ -24,6 +24,21 @@ if typing.TYPE_CHECKING:
from .cache import Cache from .cache import Cache
SUPPORTS_HS2019 = {
'friendica',
'gotosocial',
'hubzilla'
'mastodon',
'socialhome',
'misskey',
'catodon',
'cherrypick',
'firefish',
'foundkey',
'iceshrimp',
'sharkey'
}
T = typing.TypeVar('T', bound = JsonBase) T = typing.TypeVar('T', bound = JsonBase)
HEADERS = { HEADERS = {
'Accept': f'{MIMETYPES["activity"]}, {MIMETYPES["json"]};q=0.9', 'Accept': f'{MIMETYPES["activity"]}, {MIMETYPES["json"]};q=0.9',
@ -179,13 +194,12 @@ class HttpClient:
if not self._session: if not self._session:
raise RuntimeError('Client not open') 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 # akkoma and pleroma do not support HS2019 and other software still needs to be tested
# if instance and instance['software'] in {'mastodon'}: if instance and instance['software'] in SUPPORTS_HS2019:
# algorithm = AlgorithmType.HS2019 algorithm = AlgorithmType.HS2019
# else: else:
# algorithm = AlgorithmType.RSASHA256 algorithm = AlgorithmType.RSASHA256
body: bytes body: bytes
message: Message message: Message
@ -204,7 +218,7 @@ class HttpClient:
url, url,
body, body,
headers = {'Content-Type': 'application/activity+json'}, headers = {'Content-Type': 'application/activity+json'},
algorithm = AlgorithmType.RSASHA256 algorithm = algorithm
) )
try: try: