Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: consider all resolvable dids in invites "public" #2900

Merged
merged 3 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions aries_cloudagent/connections/base_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ def _key_info_to_multikey(key_info: KeyInfo) -> str:
multicodec.wrap("ed25519-pub", b58decode(key_info.verkey)), "base58btc"
)

def long_did_peer_to_short(self, long_did: str) -> DIDInfo:
def long_did_peer_to_short(self, long_did: str) -> str:
"""Convert did:peer:4 long format to short format and return."""

short_did_peer = long_to_short(long_did)
return short_did_peer

async def long_did_peer_4_to_short(self, long_dp4: str) -> DIDInfo:
async def long_did_peer_4_to_short(self, long_dp4: str) -> str:
"""Convert did:peer:4 long format to short format and store in wallet."""

async with self._profile.session() as session:
Expand Down
5 changes: 1 addition & 4 deletions aries_cloudagent/connections/models/conn_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,7 @@ async def find_existing_connection(
session: The active profile session
their_public_did: Inviter public DID (or did:peer)
"""
if their_public_did.startswith("did:peer"):
tag_filter = {"their_did": their_public_did}
else:
tag_filter = {"their_public_did": their_public_did}
tag_filter = {"their_public_did": their_public_did}
conn_records = await cls.query(
session,
tag_filter=tag_filter,
Expand Down
16 changes: 11 additions & 5 deletions aries_cloudagent/protocols/out_of_band/v1_0/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,14 +705,16 @@ async def receive_invitation(
if (
public_did is not None and use_existing_connection
): # invite has public DID: seek existing connection
LOGGER.debug(
"Trying to find existing connection for oob invitation with "
f"did {public_did}"
)
if public_did.startswith("did:peer:4"):
search_public_did = self.long_did_peer_to_short(public_did)
else:
search_public_did = public_did

LOGGER.debug(
"Trying to find existing connection for oob invitation with "
f"did {search_public_did}"
)

async with self._profile.session() as session:
conn_rec = await ConnRecord.find_existing_connection(
session=session, their_public_did=search_public_did
Expand Down Expand Up @@ -1046,7 +1048,11 @@ async def _perform_handshake(
# in an out-of-band message (RFC 0434).
# OR did:peer:2 or did:peer:4.

if not service.startswith("did:peer"):
if service.startswith("did:peer"):
public_did = service
if public_did.startswith("did:peer:4"):
public_did = self.long_did_peer_to_short(public_did)
else:
public_did = service.split(":")[-1]

# TODO: resolve_invitation should resolve key_info objects
Expand Down