This commit is contained in:
John Smith
2023-06-16 11:57:55 -04:00
parent d114ea3b72
commit 14ba85efda
18 changed files with 158 additions and 75 deletions

View File

@@ -159,10 +159,10 @@ class VeilidAPI(ABC):
async def detach(self):
pass
@abstractmethod
async def new_private_route(self) -> NewPrivateRouteResult:
async def new_private_route(self) -> Tuple[RouteId, bytes]:
pass
@abstractmethod
async def new_custom_private_route(self, kinds: list[CryptoKind], stability: Stability, sequencing: Sequencing) -> NewPrivateRouteResult:
async def new_custom_private_route(self, kinds: list[CryptoKind], stability: Stability, sequencing: Sequencing) -> Tuple[RouteId, bytes]:
pass
@abstractmethod
async def import_remote_private_route(self, blob: bytes) -> RouteId:

View File

@@ -223,15 +223,15 @@ class _JsonVeilidAPI(VeilidAPI):
raise_api_result(await self.send_ndjson_request(Operation.ATTACH))
async def detach(self):
raise_api_result(await self.send_ndjson_request(Operation.DETACH))
async def new_private_route(self) -> NewPrivateRouteResult:
return NewPrivateRouteResult.from_json(raise_api_result(await self.send_ndjson_request(Operation.NEW_PRIVATE_ROUTE)))
async def new_custom_private_route(self, kinds: list[CryptoKind], stability: Stability, sequencing: Sequencing) -> NewPrivateRouteResult:
async def new_private_route(self) -> Tuple[RouteId, bytes]:
return NewPrivateRouteResult.from_json(raise_api_result(await self.send_ndjson_request(Operation.NEW_PRIVATE_ROUTE))).to_tuple()
async def new_custom_private_route(self, kinds: list[CryptoKind], stability: Stability, sequencing: Sequencing) -> Tuple[RouteId, bytes]:
return NewPrivateRouteResult.from_json(raise_api_result(
await self.send_ndjson_request(Operation.NEW_CUSTOM_PRIVATE_ROUTE,
kinds = kinds,
stability = stability,
sequencing = sequencing)
))
)).to_tuple()
async def import_remote_private_route(self, blob: bytes) -> RouteId:
return RouteId(raise_api_result(
await self.send_ndjson_request(Operation.IMPORT_REMOTE_PRIVATE_ROUTE,

View File

@@ -2347,12 +2347,12 @@
"description": "Direct question blob passed to hosting application for processing to send an eventual AppReply",
"type": "object",
"required": [
"id",
"call_id",
"kind",
"message"
],
"properties": {
"id": {
"call_id": {
"description": "The id to reply to",
"type": "string"
},

View File

@@ -250,12 +250,12 @@ class VeilidAppMessage:
class VeilidAppCall:
sender: Optional[TypedKey]
message: bytes
operation_id: str
call_id: str
def __init__(self, sender: Optional[TypedKey], message: bytes, operation_id: str):
def __init__(self, sender: Optional[TypedKey], message: bytes, call_id: str):
self.sender = sender
self.message = message
self.operation_id = operation_id
self.call_id = call_id
@staticmethod
def from_json(j: dict) -> Self:
@@ -263,7 +263,7 @@ class VeilidAppCall:
return VeilidAppCall(
None if j['sender'] is None else TypedKey(j['sender']),
urlsafe_b64decode_no_pad(j['message']),
j['operation_id'])
j['call_id'])
class VeilidRouteChange:
dead_routes: list[RouteId]

View File

@@ -204,6 +204,9 @@ class NewPrivateRouteResult:
self.route_id = route_id
self.blob = blob
def to_tuple(self) -> Tuple[RouteId, bytes]:
return (self.route_id, self.blob)
@staticmethod
def from_json(j: dict) -> Self:
return NewPrivateRouteResult(