Skip to content

Commit 8c752c8

Browse files
authored
Merge branch 'main' into fix/revoc-tails
2 parents 8bfa60b + 3ee0dbb commit 8c752c8

6 files changed

Lines changed: 118 additions & 22 deletions

File tree

aries_cloudagent/askar/store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ async def open_store(self, provision: bool = False) -> "AskarOpenStore":
146146
"""
147147

148148
try:
149-
if provision:
149+
if provision or self.in_memory:
150150
store = await Store.provision(
151151
self.get_uri(create=True),
152152
self.key_derivation_method,

aries_cloudagent/core/profile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,14 +315,14 @@ def __init__(self):
315315

316316
def provide(self, settings: BaseSettings, injector: BaseInjector):
317317
"""Create the profile manager instance."""
318+
mgr_type = settings.get_value("wallet.type", default="in_memory")
318319

319-
mgr_type = settings.get_value("wallet.type", default="in_memory").lower()
320-
if mgr_type == "basic":
320+
if mgr_type.lower() == "basic":
321321
# map previous value
322322
mgr_type = "in_memory"
323323

324324
# mgr_type may be a fully qualified class name
325-
mgr_class = self.MANAGER_TYPES.get(mgr_type, mgr_type)
325+
mgr_class = self.MANAGER_TYPES.get(mgr_type.lower(), mgr_type)
326326

327327
if mgr_class not in self._inst:
328328
LOGGER.info("Create profile manager: %s", mgr_type)

aries_cloudagent/protocols/didexchange/v1_0/manager.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,10 @@ async def receive_request(
477477
conn_rec.their_did = request.did
478478
conn_rec.state = ConnRecord.State.REQUEST.rfc23
479479
conn_rec.request_id = request._id
480-
480+
async with self.profile.session() as session:
481+
await conn_rec.save(
482+
session, reason="Received connection request from invitation"
483+
)
481484
else:
482485
# request is against implicit invitation on public DID
483486
async with self.profile.session() as session:

aries_cloudagent/protocols/out_of_band/v1_0/routes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from marshmallow.exceptions import ValidationError
1010

1111
from ....admin.request_context import AdminRequestContext
12-
from ....connections.models.conn_record import ConnRecordSchema
1312
from ....messaging.models.base import BaseModelError
1413
from ....messaging.models.openapi import OpenAPISchema
1514
from ....messaging.valid import UUID4
@@ -22,6 +21,7 @@
2221
from .messages.invitation import HSProto, InvitationMessage, InvitationMessageSchema
2322
from .message_types import SPEC_URI
2423
from .models.invitation import InvitationRecordSchema
24+
from .models.oob_record import OobRecordSchema
2525

2626
LOGGER = logging.getLogger(__name__)
2727

@@ -188,7 +188,7 @@ async def invitation_create(request: web.BaseRequest):
188188
)
189189
@querystring_schema(InvitationReceiveQueryStringSchema())
190190
@request_schema(InvitationMessageSchema())
191-
@response_schema(ConnRecordSchema(), 200, description="")
191+
@response_schema(OobRecordSchema(), 200, description="")
192192
async def invitation_receive(request: web.BaseRequest):
193193
"""
194194
Request handler for receiving a new connection invitation.

aries_cloudagent/resolver/default/indy.py

Lines changed: 67 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
Resolution is performed using the IndyLedger class.
44
"""
55

6-
from typing import Pattern
6+
from typing import Any, Mapping, Pattern
77

88
from pydid import DID, DIDDocumentBuilder
9-
from pydid.verification_method import Ed25519VerificationKey2018
9+
from pydid.verification_method import Ed25519VerificationKey2018, VerificationMethod
1010

1111
from ...config.injection_context import InjectionContext
1212
from ...core.profile import Profile
@@ -29,7 +29,10 @@ class NoIndyLedger(ResolverError):
2929
class IndyDIDResolver(BaseDIDResolver):
3030
"""Indy DID Resolver."""
3131

32-
AGENT_SERVICE_TYPE = "did-communication"
32+
SERVICE_TYPE_DID_COMMUNICATION = "did-communication"
33+
SERVICE_TYPE_DIDCOMM = "DIDComm"
34+
SERVICE_TYPE_ENDPOINT = "endpoint"
35+
CONTEXT_DIDCOMM_V2 = "https://didcomm.org/messaging/contexts/v2"
3336

3437
def __init__(self):
3538
"""Initialize Indy Resolver."""
@@ -43,6 +46,60 @@ def supported_did_regex(self) -> Pattern:
4346
"""Return supported_did_regex of Indy DID Resolver."""
4447
return IndyDID.PATTERN
4548

49+
def _add_endpoint_as_endpoint_value_pair(
50+
self,
51+
builder: DIDDocumentBuilder,
52+
endpoint: str,
53+
recipient_key: VerificationMethod,
54+
):
55+
builder.service.add_didcomm(
56+
ident=self.SERVICE_TYPE_DID_COMMUNICATION,
57+
type_=self.SERVICE_TYPE_DID_COMMUNICATION,
58+
service_endpoint=endpoint,
59+
priority=1,
60+
recipient_keys=[recipient_key],
61+
routing_keys=[],
62+
)
63+
64+
def _add_endpoint_as_map(
65+
self,
66+
builder: DIDDocumentBuilder,
67+
endpoint: Mapping[str, Any],
68+
recipient_key: VerificationMethod,
69+
):
70+
types = endpoint.get("types", [self.SERVICE_TYPE_DID_COMMUNICATION])
71+
routing_keys = endpoint.get("routingKeys", [])
72+
endpoint_url = endpoint.get("endpoint")
73+
if not endpoint_url:
74+
raise ValueError("endpoint url not found in endpoint attrib")
75+
76+
if self.SERVICE_TYPE_DIDCOMM in types:
77+
builder.service.add(
78+
ident="#didcomm-1",
79+
type_=self.SERVICE_TYPE_DIDCOMM,
80+
service_endpoint=endpoint_url,
81+
recipient_keys=[recipient_key.id],
82+
routing_keys=routing_keys,
83+
accept=["didcomm/v2"],
84+
)
85+
builder.context.append(self.CONTEXT_DIDCOMM_V2)
86+
if self.SERVICE_TYPE_DID_COMMUNICATION in types:
87+
builder.service.add(
88+
ident="did-communication",
89+
type_=self.SERVICE_TYPE_DID_COMMUNICATION,
90+
service_endpoint=endpoint_url,
91+
priority=1,
92+
routing_keys=routing_keys,
93+
recipient_keys=[recipient_key.id],
94+
accept=["didcomm/aip2;env=rfc19"],
95+
)
96+
if self.SERVICE_TYPE_ENDPOINT in types:
97+
builder.service.add(
98+
ident="endpoint",
99+
service_endpoint=endpoint_url,
100+
type_=self.SERVICE_TYPE_ENDPOINT,
101+
)
102+
46103
async def _resolve(self, profile: Profile, did: str) -> dict:
47104
"""Resolve an indy DID."""
48105
multitenant_mgr = profile.inject_or(BaseMultitenantManager)
@@ -76,16 +133,14 @@ async def _resolve(self, profile: Profile, did: str) -> dict:
76133
if endpoints:
77134
for type_, endpoint in endpoints.items():
78135
if type_ == EndpointType.ENDPOINT.indy:
79-
builder.service.add_didcomm(
80-
ident=self.AGENT_SERVICE_TYPE,
81-
type_=self.AGENT_SERVICE_TYPE,
82-
service_endpoint=endpoint,
83-
priority=1,
84-
recipient_keys=[vmethod],
85-
routing_keys=[],
86-
)
136+
if isinstance(endpoint, dict):
137+
self._add_endpoint_as_map(builder, endpoint, vmethod)
138+
else:
139+
self._add_endpoint_as_endpoint_value_pair(
140+
builder, endpoint, vmethod
141+
)
87142
else:
88-
# Accept all service types for now
143+
# Accept all service types for now, i.e. profile, linked_domains
89144
builder.service.add(
90145
ident=type_,
91146
type_=type_,

aries_cloudagent/resolver/default/tests/test_indy.py

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from ....multitenant.manager import MultitenantManager
1717

1818
from ...base import DIDNotFound, ResolverError
19-
from .. import indy as test_module
2019
from ..indy import IndyDIDResolver
2120

2221
# pylint: disable=W0621
@@ -33,8 +32,11 @@ def resolver():
3332
def ledger():
3433
"""Ledger fixture."""
3534
ledger = async_mock.MagicMock(spec=BaseLedger)
36-
ledger.get_endpoint_for_did = async_mock.CoroutineMock(
37-
return_value="https://github.com/"
35+
ledger.get_all_endpoints_for_did = async_mock.CoroutineMock(
36+
return_value={
37+
"endpoint": "https://github.com/",
38+
"profile": "https://example.com/profile",
39+
}
3840
)
3941
ledger.get_key_for_did = async_mock.CoroutineMock(return_value="key")
4042
yield ledger
@@ -107,3 +109,39 @@ async def test_resolve_x_did_not_found(
107109
ledger.get_key_for_did.side_effect = LedgerError
108110
with pytest.raises(DIDNotFound):
109111
await resolver.resolve(profile, TEST_DID0)
112+
113+
@pytest.mark.asyncio
114+
async def test_supports_updated_did_sov_rules(
115+
self, resolver: IndyDIDResolver, ledger: BaseLedger, profile: Profile
116+
):
117+
"""Test that new attrib structure is supported."""
118+
example = {
119+
"endpoint": {
120+
"endpoint": "https://example.com/endpoint",
121+
"routingKeys": ["a-routing-key"],
122+
"types": ["DIDComm", "did-communication", "endpoint"],
123+
}
124+
}
125+
126+
ledger.get_all_endpoints_for_did = async_mock.CoroutineMock(
127+
return_value=example
128+
)
129+
assert await resolver.resolve(profile, TEST_DID0)
130+
131+
@pytest.mark.asyncio
132+
async def test_supports_updated_did_sov_rules_x_no_endpoint_url(
133+
self, resolver: IndyDIDResolver, ledger: BaseLedger, profile: Profile
134+
):
135+
"""Test that new attrib structure is supported."""
136+
example = {
137+
"endpoint": {
138+
"routingKeys": ["a-routing-key"],
139+
"types": ["DIDComm", "did-communication", "endpoint"],
140+
}
141+
}
142+
143+
ledger.get_all_endpoints_for_did = async_mock.CoroutineMock(
144+
return_value=example
145+
)
146+
with pytest.raises(ValueError):
147+
await resolver.resolve(profile, TEST_DID0)

0 commit comments

Comments
 (0)