19 lines
609 B
Python
19 lines
609 B
Python
import aiohttp
|
|
|
|
__all__ = ('request_signature',)
|
|
|
|
from v6d0auth import certs
|
|
|
|
|
|
async def request_signature(base_url: str) -> bytes:
|
|
async with aiohttp.ClientSession() as session:
|
|
async with session.post(f'{base_url}/push', data=certs.vkey.encode()) as response:
|
|
if response.status not in [200, 429]:
|
|
raise RuntimeError
|
|
async with session.ws_connect(f'{base_url}/pullws') as ws:
|
|
await ws.send_bytes(certs.vkey.encode())
|
|
try:
|
|
return await ws.receive_bytes()
|
|
except TypeError:
|
|
raise TimeoutError
|