Skip to content

Commit

Permalink
Merge pull request #47 from Indicio-tech/fix/request-no-rotate
Browse files Browse the repository at this point in the history
fix: request won't have rotate
  • Loading branch information
dbluhm authored Feb 26, 2024
2 parents b19da54 + ef5a0ca commit 06358d5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
11 changes: 5 additions & 6 deletions docker/setup/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from functools import partial, wraps
import json
from os import getenv
from typing import Any, Awaitable, Callable, Optional, TypeVar, cast
from typing import Any, Awaitable, Callable, Mapping, Optional, TypeVar, cast

from httpx import AsyncClient

Expand Down Expand Up @@ -157,7 +157,7 @@ async def get_invite(self) -> str:
)
return invitation.invitation_url

async def receive_invitation(self, invite: dict) -> ConnRecord:
async def receive_invitation(self, invite: dict) -> Mapping[str, Any]:
oob_record = await self.controller.post(
"/out-of-band/receive-invitation",
json=invite,
Expand All @@ -166,7 +166,6 @@ async def receive_invitation(self, invite: dict) -> ConnRecord:

conn_record = await self.controller.record_with_values(
"connections",
record_type=ConnRecord,
invitation_msg_id=oob_record["invi_msg_id"],
rfc23_state="completed",
)
Expand Down Expand Up @@ -220,10 +219,10 @@ async def main():
conn_record = await agent.receive_invitation(invite)

print("Proxy and agent are now connected.")
print(f"Proxy connection id: {conn_record.connection_id}")
print(f"Proxy connection id: {conn_record['connection_id']}")

assert isinstance(conn_record.connection_id, str)
mediation_id = await agent.request_mediation(conn_record.connection_id)
assert isinstance(conn_record["connection_id"], str)
mediation_id = await agent.request_mediation(conn_record["connection_id"])
print("Proxy has granted mediation to agent.")
print(f"Proxy mediation id: {mediation_id}")

Expand Down
10 changes: 4 additions & 6 deletions proxy_mediator/protocols/oob_didexchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def _filter(service: Service) -> bool:

async def doc_from_request_or_response(
self, message: Message
) -> Tuple[DIDDocument, bytes]:
) -> Tuple[DIDDocument, Optional[bytes]]:
"""Extract DID Document from a DID Exchange Request or Response."""
if "did_doc~attach" in message:
verified, signer = self.verify_signed_attachment(message["did_doc~attach"])
Expand All @@ -261,17 +261,15 @@ async def doc_from_request_or_response(
normalized = LegacyDocCorrections.apply(doc)
return deserialize_document(normalized), signer

elif "did_rotate~attach" in message:
elif "response" in message.type and "did_rotate~attach" in message:
verified, signer = self.verify_signed_attachment(
message["did_rotate~attach"]
)
if not verified:
raise ProtocolError("Invalid signature on DID Rotattion")

resolver = DIDResolver()
return await resolver.resolve_and_parse(message["did"]), signer

raise ProtocolError("No DID Doc or DID Rotation attachment")
resolver = DIDResolver()
return await resolver.resolve_and_parse(message["did"]), None

@route
@route(doc_uri=DIDCOMM_OLD)
Expand Down

0 comments on commit 06358d5

Please sign in to comment.