|
4 | 4 | import logging |
5 | 5 | from typing import Optional |
6 | 6 |
|
7 | | -from acapy_agent.core.error import BaseError |
8 | | -from acapy_agent.core.profile import Profile |
9 | | -from acapy_agent.did.did_key import DIDKey |
10 | | -from acapy_agent.resolver.did_resolver import DIDResolver |
| 7 | +from pydid import DIDDocument |
| 8 | + |
| 9 | +from ..core.error import BaseError |
| 10 | +from ..core.profile import Profile |
| 11 | +from ..did.did_key import DIDKey |
| 12 | +from ..resolver.did_resolver import DIDResolver |
11 | 13 |
|
12 | 14 | LOGGER = logging.getLogger(__name__) |
13 | 15 |
|
@@ -90,11 +92,21 @@ async def get_verification_method_id_for_did( |
90 | 92 | return did + "#key-1" |
91 | 93 |
|
92 | 94 | resolver = profile.inject(DIDResolver) |
93 | | - did_document = await resolver.resolve(profile=profile, did=did) |
94 | | - method_types = self.key_types_mapping[proof_type] |
| 95 | + doc_raw = await resolver.resolve(profile=profile, did=did) |
| 96 | + doc = DIDDocument.deserialize(doc_raw) |
| 97 | + |
| 98 | + methods_or_refs = getattr(doc, proof_purpose, []) |
| 99 | + # Dereference any refs in the verification relationship |
| 100 | + methods = [ |
| 101 | + await resolver.dereference_verification_method(profile, method, document=doc) |
| 102 | + if isinstance(method, str) |
| 103 | + else method |
| 104 | + for method in methods_or_refs |
| 105 | + ] |
95 | 106 |
|
96 | | - methods = did_document.get(proof_purpose, []) |
97 | | - methods = [vm for vm in methods if vm.get("type") in method_types] |
| 107 | + method_types = self.key_types_mapping[proof_type] |
| 108 | + # Filter methods by type expected for proof_type |
| 109 | + methods = [vm for vm in methods if vm.type in method_types] |
98 | 110 | if not methods: |
99 | 111 | raise VerificationKeyStrategyError( |
100 | 112 | f"No matching verification method found for did {did} with proof " |
|
0 commit comments