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: handle stored afgo and findy docs in corrections #2450

Merged
merged 3 commits into from
Aug 28, 2023
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
19 changes: 18 additions & 1 deletion aries_cloudagent/resolver/default/legacy_peer.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,34 @@ def didcomm_services_use_updated_conventions(value: dict) -> dict:
service["type"] = "did-communication"
if ";" in service["id"]:
service["id"] = value["id"] + "#didcomm"
if "#" not in service["id"]:
service["id"] += "#didcomm"
if "priority" in service and service["priority"] is None:
service.pop("priority")
return value

@staticmethod
def recip_base58_to_ref(vms: List[dict], recip: str) -> str:
"""Convert base58 public key to ref."""
for vm in vms:
if "publicKeyBase58" in vm and vm["publicKeyBase58"] == recip:
return vm["id"]
return recip

@classmethod
def didcomm_services_recip_keys_are_refs_routing_keys_are_did_key(
cls,
value: dict,
) -> dict:
"""Update DIDComm service recips to use refs and routingKeys to use did:key."""
vms = value.get("verificationMethod", [])
if "service" in value:
for service in value["service"]:
if "type" in service and service["type"] == "did-communication":
service["recipientKeys"] = [f"{value['id']}#1"]
service["recipientKeys"] = [
cls.recip_base58_to_ref(vms, recip)
for recip in service.get("recipientKeys", [])
]
if "routingKeys" in service:
service["routingKeys"] = [
DIDKey.from_public_key_b58(key, ED25519).key_id
Expand Down
Loading