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

refactor: introduce use_did and use_did_method #2862

Merged
merged 23 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
239ba8f
refactor: introduce use_did and use_did_method
dbluhm Apr 1, 2024
15f3e10
feat: oob route updates for use_did, use_did_method
dbluhm Apr 2, 2024
e61e709
fix: comment out create_unique_did for now in int tests
dbluhm Apr 3, 2024
4da0cb6
feat: remove emit args
dbluhm Apr 4, 2024
ccd92d8
refactor: delegate param checking to invite creator
dbluhm Apr 4, 2024
c2b1b80
fix: use_did_method is body param
dbluhm Apr 4, 2024
b15407a
fix: use_did_method should be none when not set
dbluhm Apr 4, 2024
e9f6e7b
fix: omit use_did_method when none
dbluhm Apr 4, 2024
a03db24
fix: condition for create_unique_did
dbluhm Apr 4, 2024
a52cf65
fix: more random dids
dbluhm Apr 4, 2024
c020a79
fix: move emit flag in issue cred test defs
dbluhm Apr 4, 2024
92f0187
feat: don't remove type info from agent message on deserialize
dbluhm Apr 4, 2024
eb7ee17
fix: conductor invite creation tests
dbluhm Apr 4, 2024
30fea83
fix: agent message tests with bad type
dbluhm Apr 4, 2024
5228382
fix: route manager test with updated params to route_verkey
dbluhm Apr 4, 2024
a2b69be
fix: remove out of spec attr for invitation message tests
dbluhm Apr 4, 2024
7f5eae7
fix: oob manager test failures
dbluhm Apr 4, 2024
536b650
fix: brittle test expected params in oob test routes
dbluhm Apr 4, 2024
58a5f62
fix: bad field on inv message
dbluhm Apr 4, 2024
ff8a613
test: invite creator config
dbluhm Apr 4, 2024
85f01f0
feat: implement auto-accept behavior
dbluhm Apr 4, 2024
fd73dd6
fix: a few critical tweaks
dbluhm Apr 8, 2024
27ed8f3
feat: new doc detailing qualified did use
dbluhm Apr 8, 2024
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
18 changes: 0 additions & 18 deletions aries_cloudagent/config/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -1166,19 +1166,6 @@ def add_arguments(self, parser: ArgumentParser):
"using unencrypted rather than encrypted tags"
),
)
parser.add_argument(
"--emit-did-peer-2",
action="store_true",
env_var="ACAPY_EMIT_DID_PEER_2",
help=("Emit did:peer:2 DIDs in DID Exchange Protocol"),
)

parser.add_argument(
"--emit-did-peer-4",
action="store_true",
env_var="ACAPY_EMIT_DID_PEER_4",
help=("Emit did:peer:4 DIDs in DID Exchange Protocol"),
)

def get_settings(self, args: Namespace) -> dict:
"""Get protocol settings."""
Expand Down Expand Up @@ -1246,11 +1233,6 @@ def get_settings(self, args: Namespace) -> dict:
settings["exch_use_unencrypted_tags"] = True
environ["EXCH_UNENCRYPTED_TAGS"] = "True"

if args.emit_did_peer_2:
settings["emit_did_peer_2"] = True
if args.emit_did_peer_4:
settings["emit_did_peer_4"] = True

return settings


Expand Down
9 changes: 5 additions & 4 deletions aries_cloudagent/connections/base_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
from ..wallet.base import BaseWallet
from ..wallet.crypto import create_keypair, seed_to_did
from ..wallet.did_info import INVITATION_REUSE_KEY, DIDInfo, KeyInfo
from ..wallet.did_method import PEER2, PEER4, SOV
from ..wallet.did_method import PEER2, PEER4, SOV, DIDMethod
from ..wallet.error import WalletNotFoundError
from ..wallet.key_type import ED25519
from ..wallet.util import b64_to_bytes, bytes_to_b58
Expand Down Expand Up @@ -245,19 +245,20 @@ async def create_did_peer_2(

async def fetch_invitation_reuse_did(
self,
did_method: str,
) -> DIDDoc:
did_method: DIDMethod,
) -> Optional[DIDInfo]:
"""Fetch a DID from the wallet to use across multiple invitations.

Args:
did_method: The DID method used (e.g. PEER2 or PEER4)

Returns:
The `DIDDoc` instance, or "None" if no DID is found
The `DIDInfo` instance, or "None" if no DID is found
"""
did_info = None
async with self._profile.session() as session:
wallet = session.inject(BaseWallet)
# TODO Iterating through all DIDs is problematic
did_list = await wallet.get_local_dids()
for did in did_list:
if did.method == did_method and INVITATION_REUSE_KEY in did.metadata:
Expand Down
2 changes: 2 additions & 0 deletions aries_cloudagent/core/tests/test_conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1149,6 +1149,8 @@ async def test_print_invite_connection(self):
"debug.print_connections_invitation": True,
"invite_base_url": "http://localhost",
"wallet.type": "askar",
"default_endpoint": "http://localhost",
"default_label": "test",
}
)
conductor = test_module.Conductor(builder)
Expand Down
3 changes: 1 addition & 2 deletions aries_cloudagent/messaging/agent_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def assign_thread_from(self, msg: "AgentMessage"):
pthid = thread and thread.pthid
self.assign_thread_id(thid, pthid)

def assign_thread_id(self, thid: str, pthid: Optional[str] = None):
def assign_thread_id(self, thid: Optional[str] = None, pthid: Optional[str] = None):
"""Assign a specific thread ID.

Args:
Expand Down Expand Up @@ -450,7 +450,6 @@ class Meta:
# Avoid clobbering keywords
_type = fields.Str(
data_key="@type",
dump_only=True,
required=False,
metadata={
"description": "Message type",
Expand Down
8 changes: 4 additions & 4 deletions aries_cloudagent/messaging/tests/test_agent_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,12 @@ class BadImplementationClass(AgentMessageSchema):
def test_extract_decorators_x(self):
for serial in [
{
"@type": "signed-agent-message",
"@type": "doc/proto/1.0/signed-agent-message",
"@id": "030ac9e6-0d60-49d3-a8c6-e7ce0be8df5a",
"value": "Test value",
},
{
"@type": "signed-agent-message",
"@type": "doc/proto/1.0/signed-agent-message",
"@id": "030ac9e6-0d60-49d3-a8c6-e7ce0be8df5a",
"value": "Test value",
"value~sig": {
Expand All @@ -231,7 +231,7 @@ def test_extract_decorators_x(self):
},
},
{
"@type": "signed-agent-message",
"@type": "doc/proto/1.0/signed-agent-message",
"@id": "030ac9e6-0d60-49d3-a8c6-e7ce0be8df5a",
"superfluous~sig": {
"@type": DIDCommPrefix.qualify_current(
Expand All @@ -251,7 +251,7 @@ def test_extract_decorators_x(self):

def test_serde(self):
serial = {
"@type": "signed-agent-message",
"@type": "doc/proto/1.0/signed-agent-message",
"@id": "030ac9e6-0d60-49d3-a8c6-e7ce0be8df5a",
"value~sig": {
"@type": DIDCommPrefix.qualify_current(
Expand Down
6 changes: 3 additions & 3 deletions aries_cloudagent/messaging/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from datetime import datetime, timedelta, timezone
from hashlib import sha256
from math import floor
from typing import Any, Dict, List, Optional, Union
from typing import Any, Dict, List, Union


LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -151,7 +151,7 @@ def canon(raw_attr_name: str) -> str:

def get_proto_default_version(
versions: List[Dict[str, Any]], major_version: int = 1
) -> Optional[str]:
) -> str:
"""Return default protocol version from version definition list."""

for version in versions:
Expand All @@ -160,4 +160,4 @@ def get_proto_default_version(
default_minor_version = version["current_minor_version"]
return f"{default_major_version}.{default_minor_version}"

return None
return "1.0"
4 changes: 0 additions & 4 deletions aries_cloudagent/multitenant/admin/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
"ACAPY_AUTO_VERIFY_PRESENTATION": "debug.auto_verify_presentation",
"ACAPY_AUTO_WRITE_TRANSACTIONS": "endorser.auto_write",
"ACAPY_CREATE_REVOCATION_TRANSACTIONS": "endorser.auto_create_rev_reg",
"ACAPY_EMIT_DID_PEER_2": "emit_did_peer_2",
"ACAPY_EMIT_DID_PEER_4": "emit_did_peer_4",
"ACAPY_ENDORSER_ALIAS": "endorser.endorser_alias",
"ACAPY_ENDORSER_INVITATION": "endorser.endorser_invitation",
"ACAPY_ENDORSER_PUBLIC_DID": "endorser.endorser_public_did",
Expand All @@ -63,8 +61,6 @@
"auto-respond-messages": "debug.auto_respond_messages",
"auto-verify-presentation": "debug.auto_verify_presentation",
"auto-write-transactions": "endorser.auto_write",
"emit-did-peer-2": "emit_did_peer_2",
"emit-did-peer-4": "emit_did_peer_4",
"endorser-alias": "endorser.endorser_alias",
"endorser-invitation": "endorser.endorser_invitation",
"endorser-protocol-role": "endorser.protocol_role",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,16 @@ async def route_invitation(

raise ValueError("Expected connection to have invitation_key")

async def route_verkey(self, profile: Profile, verkey: str):
async def route_verkey(
self,
profile: Profile,
verkey: str,
mediation_record: Optional[MediationRecord] = None,
):
"""Establish routing for a public DID."""
return await self._route_for_key(profile, verkey, skip_if_exists=True)
return await self._route_for_key(
profile, verkey, mediation_record, skip_if_exists=True
)

async def route_public_did(self, profile: Profile, verkey: str):
"""Establish routing for a public DID.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ async def test_route_public_did(profile: Profile, route_manager: RouteManager):
async def test_route_verkey(profile: Profile, route_manager: RouteManager):
await route_manager.route_verkey(profile, "test-verkey")
route_manager._route_for_key.assert_called_once_with(
profile, "test-verkey", skip_if_exists=True
profile, "test-verkey", None, skip_if_exists=True
)


Expand Down
Loading