Skip to content

Commit c8d9857

Browse files
authored
Merge branch 'main' into redis_plugin_doc
2 parents 19e1d0c + 4696a26 commit c8d9857

129 files changed

Lines changed: 3326 additions & 1475 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Endorser.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Endorsement:
5656
For Authors, specify whether to automatically create transactions for a cred def's revocation registry. (If not specified, the controller must invoke the endpoints required to create
5757
the revocation registry and assign to the cred def.) [env var: ACAPY_CREATE_REVOCATION_TRANSACTIONS]
5858
--auto-promote-author-did
59-
For Authors, specify whether to automatically promote a DID to the wallet public DID after writing to the ledger.
59+
For Authors, specify whether to automatically promote a DID to the wallet public DID after writing to the ledger. [env var: ACAPY_AUTO_PROMOTE_AUTHOR_DID]
6060
```
6161

6262
## How Aca-py Handles Endorsements

aries_cloudagent/config/argparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1837,7 +1837,7 @@ def add_arguments(self, parser: ArgumentParser):
18371837
parser.add_argument(
18381838
"--auto-promote-author-did",
18391839
action="store_true",
1840-
env_var="ACAPY_PROMOTE-AUTHOR-DID",
1840+
env_var="ACAPY_AUTO_PROMOTE_AUTHOR_DID",
18411841
help="For Authors, specify whether to automatically promote"
18421842
" a DID to the wallet public DID after writing to the ledger.",
18431843
)

aries_cloudagent/config/default_context.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
"""Classes for configuring the default injection context."""
22

3-
from .base_context import ContextBuilder
4-
from .injection_context import InjectionContext
5-
from .provider import CachedProvider, ClassProvider
6-
73
from ..cache.base import BaseCache
84
from ..cache.in_memory import InMemoryCache
95
from ..core.event_bus import EventBus
6+
from ..core.goal_code_registry import GoalCodeRegistry
107
from ..core.plugin_registry import PluginRegistry
118
from ..core.profile import ProfileManager, ProfileManagerProvider
129
from ..core.protocol_registry import ProtocolRegistry
13-
from ..core.goal_code_registry import GoalCodeRegistry
14-
from ..resolver.did_resolver import DIDResolver
15-
from ..tails.base import BaseTailsServer
16-
1710
from ..protocols.actionmenu.v1_0.base_service import BaseMenuService
1811
from ..protocols.actionmenu.v1_0.driver_service import DriverMenuService
1912
from ..protocols.didcomm_prefix import DIDCommPrefix
2013
from ..protocols.introduction.v0_1.base_service import BaseIntroductionService
2114
from ..protocols.introduction.v0_1.demo_service import DemoIntroductionService
15+
from ..resolver.did_resolver import DIDResolver
16+
from ..tails.base import BaseTailsServer
2217
from ..transport.wire_format import BaseWireFormat
23-
from ..utils.stats import Collector
2418
from ..utils.dependencies import is_indy_sdk_module_installed
19+
from ..utils.stats import Collector
20+
from ..wallet.did_method import DIDMethods
21+
from ..wallet.key_type import KeyTypes
22+
from .base_context import ContextBuilder
23+
from .injection_context import InjectionContext
24+
from .provider import CachedProvider, ClassProvider
2525

2626

2727
class DefaultContextBuilder(ContextBuilder):
@@ -51,6 +51,8 @@ async def build_context(self) -> InjectionContext:
5151

5252
# Global did resolver
5353
context.injector.bind_instance(DIDResolver, DIDResolver([]))
54+
context.injector.bind_instance(DIDMethods, DIDMethods())
55+
context.injector.bind_instance(KeyTypes, KeyTypes())
5456

5557
await self.bind_providers(context)
5658
await self.load_plugins(context)

aries_cloudagent/config/wallet.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
from ..wallet.base import BaseWallet
1212
from ..wallet.crypto import seed_to_did
1313
from ..wallet.did_info import DIDInfo
14-
from ..wallet.did_method import DIDMethod
15-
from ..wallet.key_type import KeyType
14+
from ..wallet.did_method import SOV
15+
from ..wallet.key_type import ED25519
1616
from .base import ConfigError
1717
from .injection_context import InjectionContext
1818

@@ -79,7 +79,7 @@ async def wallet_config(
7979
if wallet_seed and seed_to_did(wallet_seed) != public_did:
8080
if context.settings.get("wallet.replace_public_did"):
8181
replace_did_info = await wallet.create_local_did(
82-
method=DIDMethod.SOV, key_type=KeyType.ED25519, seed=wallet_seed
82+
method=SOV, key_type=ED25519, seed=wallet_seed
8383
)
8484
public_did = replace_did_info.did
8585
await wallet.set_public_did(public_did)
@@ -99,8 +99,8 @@ async def wallet_config(
9999
metadata = {"endpoint": endpoint} if endpoint else None
100100

101101
local_did_info = await wallet.create_local_did(
102-
method=DIDMethod.SOV,
103-
key_type=KeyType.ED25519,
102+
method=SOV,
103+
key_type=ED25519,
104104
seed=wallet_seed,
105105
metadata=metadata,
106106
)
@@ -110,7 +110,7 @@ async def wallet_config(
110110
print(f"Verkey: {local_did_info.verkey}")
111111
else:
112112
public_did_info = await wallet.create_public_did(
113-
method=DIDMethod.SOV, key_type=KeyType.ED25519, seed=wallet_seed
113+
method=SOV, key_type=ED25519, seed=wallet_seed
114114
)
115115
public_did = public_did_info.did
116116
if provision:
@@ -128,8 +128,8 @@ async def wallet_config(
128128
test_seed = "testseed000000000000000000000001"
129129
if test_seed:
130130
await wallet.create_local_did(
131-
method=DIDMethod.SOV,
132-
key_type=KeyType.ED25519,
131+
method=SOV,
132+
key_type=ED25519,
133133
seed=test_seed,
134134
metadata={"endpoint": "1.2.3.4:8021"},
135135
)

aries_cloudagent/connections/base_manager.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66

77
import logging
8-
from typing import List, Sequence, Tuple
8+
from typing import Optional, List, Sequence, Tuple, Text
99

1010
from pydid import (
1111
BaseDIDDocument as ResolvedDocument,
@@ -227,7 +227,9 @@ async def remove_keys_for_did(self, did: str):
227227
storage: BaseStorage = session.inject(BaseStorage)
228228
await storage.delete_all_records(self.RECORD_TYPE_DID_KEY, {"did": did})
229229

230-
async def resolve_invitation(self, did: str):
230+
async def resolve_invitation(
231+
self, did: str, service_accept: Optional[Sequence[Text]] = None
232+
):
231233
"""
232234
Resolve invitation with the DID Resolver.
233235
@@ -241,7 +243,7 @@ async def resolve_invitation(self, did: str):
241243

242244
resolver = self._profile.inject(DIDResolver)
243245
try:
244-
doc_dict: dict = await resolver.resolve(self._profile, did)
246+
doc_dict: dict = await resolver.resolve(self._profile, did, service_accept)
245247
doc: ResolvedDocument = pydid.deserialize_document(doc_dict, strict=True)
246248
except ResolverError as error:
247249
raise BaseConnectionManagerError(

aries_cloudagent/core/conductor.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,7 @@ async def start(self) -> None:
450450
if mediation_connections_invite
451451
else OutOfBandManager(self.root_profile)
452452
)
453-
454-
conn_record = await mgr.receive_invitation(
453+
record = await mgr.receive_invitation(
455454
invitation=invitation_handler.from_url(
456455
mediation_invite_record.invite
457456
),
@@ -464,10 +463,10 @@ async def start(self) -> None:
464463
).mark_default_invite_as_used()
465464
)
466465

467-
await conn_record.metadata_set(
466+
await record.metadata_set(
468467
session, MediationManager.SEND_REQ_AFTER_CONNECTION, True
469468
)
470-
await conn_record.metadata_set(
469+
await record.metadata_set(
471470
session, MediationManager.SET_TO_DEFAULT_ON_GRANTED, True
472471
)
473472

@@ -482,7 +481,8 @@ async def start(self) -> None:
482481
async def stop(self, timeout=1.0):
483482
"""Stop the agent."""
484483
# notify protcols that we are shutting down
485-
await self.root_profile.notify(SHUTDOWN_EVENT_TOPIC, {})
484+
if self.root_profile:
485+
await self.root_profile.notify(SHUTDOWN_EVENT_TOPIC, {})
486486

487487
shutdown = TaskQueue()
488488
if self.dispatcher:
@@ -494,13 +494,13 @@ async def stop(self, timeout=1.0):
494494
if self.outbound_transport_manager:
495495
shutdown.run(self.outbound_transport_manager.stop())
496496

497-
# close multitenant profiles
498-
multitenant_mgr = self.context.inject_or(BaseMultitenantManager)
499-
if multitenant_mgr:
500-
for profile in multitenant_mgr.open_profiles:
501-
shutdown.run(profile.close())
502-
503497
if self.root_profile:
498+
# close multitenant profiles
499+
multitenant_mgr = self.context.inject_or(BaseMultitenantManager)
500+
if multitenant_mgr:
501+
for profile in multitenant_mgr.open_profiles:
502+
shutdown.run(profile.close())
503+
504504
shutdown.run(self.root_profile.close())
505505

506506
await shutdown.complete(timeout)

aries_cloudagent/core/dispatcher.py

Lines changed: 67 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import os
1111
import warnings
1212

13-
from typing import Callable, Coroutine, Union
13+
from typing import Callable, Coroutine, Optional, Union, Tuple
1414
import weakref
1515

1616
from aiohttp.web import HTTPException
@@ -36,6 +36,13 @@
3636

3737
from .error import ProtocolMinorVersionNotSupported
3838
from .protocol_registry import ProtocolRegistry
39+
from .util import (
40+
get_version_from_message_type,
41+
validate_get_response_version,
42+
# WARNING_DEGRADED_FEATURES,
43+
# WARNING_VERSION_MISMATCH,
44+
# WARNING_VERSION_NOT_SUPPORTED,
45+
)
3946

4047
LOGGER = logging.getLogger(__name__)
4148

@@ -133,16 +140,22 @@ async def handle_message(
133140
inbound_message: The inbound message instance
134141
send_outbound: Async function to send outbound messages
135142
143+
# Raises:
144+
# MessageParseError: If the message type version is not supported
145+
136146
Returns:
137147
The response from the handler
138148
139149
"""
140150
r_time = get_timer()
141151

142152
error_result = None
153+
version_warning = None
143154
message = None
144155
try:
145-
message = await self.make_message(inbound_message.payload)
156+
(message, warning) = await self.make_message(
157+
profile, inbound_message.payload
158+
)
146159
except ProblemReportParseError:
147160
pass # avoid problem report recursion
148161
except MessageParseError as e:
@@ -155,6 +168,47 @@ async def handle_message(
155168
)
156169
if inbound_message.receipt.thread_id:
157170
error_result.assign_thread_id(inbound_message.receipt.thread_id)
171+
# if warning:
172+
# warning_message_type = inbound_message.payload.get("@type")
173+
# if warning == WARNING_DEGRADED_FEATURES:
174+
# LOGGER.error(
175+
# f"Sending {WARNING_DEGRADED_FEATURES} problem report, "
176+
# "message type received with a minor version at or higher"
177+
# " than protocol minimum supported and current minor version "
178+
# f"for message_type {warning_message_type}"
179+
# )
180+
# version_warning = ProblemReport(
181+
# description={
182+
# "en": (
183+
# "message type received with a minor version at or "
184+
# "higher than protocol minimum supported and current"
185+
# f" minor version for message_type {warning_message_type}"
186+
# ),
187+
# "code": WARNING_DEGRADED_FEATURES,
188+
# }
189+
# )
190+
# elif warning == WARNING_VERSION_MISMATCH:
191+
# LOGGER.error(
192+
# f"Sending {WARNING_VERSION_MISMATCH} problem report, message "
193+
# "type received with a minor version higher than current minor "
194+
# f"version for message_type {warning_message_type}"
195+
# )
196+
# version_warning = ProblemReport(
197+
# description={
198+
# "en": (
199+
# "message type received with a minor version higher"
200+
# " than current minor version for message_type"
201+
# f" {warning_message_type}"
202+
# ),
203+
# "code": WARNING_VERSION_MISMATCH,
204+
# }
205+
# )
206+
# elif warning == WARNING_VERSION_NOT_SUPPORTED:
207+
# raise MessageParseError(
208+
# f"Message type version not supported for {warning_message_type}"
209+
# )
210+
# if version_warning and inbound_message.receipt.thread_id:
211+
# version_warning.assign_thread_id(inbound_message.receipt.thread_id)
158212

159213
trace_event(
160214
self.profile.settings,
@@ -199,6 +253,8 @@ async def handle_message(
199253

200254
if error_result:
201255
await responder.send_reply(error_result)
256+
elif version_warning:
257+
await responder.send_reply(version_warning)
202258
elif context.message:
203259
context.injector.bind_instance(BaseResponder, responder)
204260

@@ -215,7 +271,9 @@ async def handle_message(
215271
perf_counter=r_time,
216272
)
217273

218-
async def make_message(self, parsed_msg: dict) -> BaseMessage:
274+
async def make_message(
275+
self, profile: Profile, parsed_msg: dict
276+
) -> Tuple[BaseMessage, Optional[str]]:
219277
"""
220278
Deserialize a message dict into the appropriate message instance.
221279
@@ -224,6 +282,7 @@ async def make_message(self, parsed_msg: dict) -> BaseMessage:
224282
225283
Args:
226284
parsed_msg: The parsed message
285+
profile: Profile
227286
228287
Returns:
229288
An instance of the corresponding message class for this message
@@ -240,6 +299,7 @@ async def make_message(self, parsed_msg: dict) -> BaseMessage:
240299

241300
if not message_type:
242301
raise MessageParseError("Message does not contain '@type' parameter")
302+
message_type_rec_version = get_version_from_message_type(message_type)
243303

244304
registry: ProtocolRegistry = self.profile.inject(ProtocolRegistry)
245305
try:
@@ -256,8 +316,10 @@ async def make_message(self, parsed_msg: dict) -> BaseMessage:
256316
if "/problem-report" in message_type:
257317
raise ProblemReportParseError("Error parsing problem report message")
258318
raise MessageParseError(f"Error deserializing message: {e}") from e
259-
260-
return instance
319+
_, warning = await validate_get_response_version(
320+
profile, message_type_rec_version, message_cls
321+
)
322+
return (instance, warning)
261323

262324
async def complete(self, timeout: float = 0.1):
263325
"""Wait for pending tasks to complete."""

0 commit comments

Comments
 (0)