From c8e660c0bbe28e2d5ab15b5a6ba28e02b4001d7f Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Thu, 7 Sep 2023 10:10:42 -0400 Subject: [PATCH 1/2] fix: unique ids for services in legacy peer Signed-off-by: Daniel Bluhm --- .../resolver/default/legacy_peer.py | 6 +- .../default/tests/test_legacy_peer.py | 89 ++++++++++++++++++- 2 files changed, 88 insertions(+), 7 deletions(-) diff --git a/aries_cloudagent/resolver/default/legacy_peer.py b/aries_cloudagent/resolver/default/legacy_peer.py index a04c525cd4..3027df1b71 100644 --- a/aries_cloudagent/resolver/default/legacy_peer.py +++ b/aries_cloudagent/resolver/default/legacy_peer.py @@ -115,13 +115,13 @@ def authentication_is_list_of_verification_methods_and_refs(value: dict) -> dict def didcomm_services_use_updated_conventions(value: dict) -> dict: """Update DIDComm services to use updated conventions.""" if "service" in value: - for service in value["service"]: + for index, service in enumerate(value["service"]): if "type" in service and service["type"] == "IndyAgent": service["type"] = "did-communication" if ";" in service["id"]: - service["id"] = value["id"] + "#didcomm" + service["id"] = value["id"] + f"#didcomm-{index}" if "#" not in service["id"]: - service["id"] += "#didcomm" + service["id"] += f"#didcomm-{index}" if "priority" in service and service["priority"] is None: service.pop("priority") return value diff --git a/aries_cloudagent/resolver/default/tests/test_legacy_peer.py b/aries_cloudagent/resolver/default/tests/test_legacy_peer.py index deff566127..e55b040e6c 100644 --- a/aries_cloudagent/resolver/default/tests/test_legacy_peer.py +++ b/aries_cloudagent/resolver/default/tests/test_legacy_peer.py @@ -173,7 +173,7 @@ async def test_resolve_x_not_found( "authentication": ["did:sov:JNKL9kJxQi5pNCfA8QBXdJ#1"], "service": [ { - "id": "did:sov:JNKL9kJxQi5pNCfA8QBXdJ#didcomm", + "id": "did:sov:JNKL9kJxQi5pNCfA8QBXdJ#didcomm-0", "type": "did-communication", "priority": 0, "recipientKeys": ["did:sov:JNKL9kJxQi5pNCfA8QBXdJ#1"], @@ -229,7 +229,7 @@ async def test_resolve_x_not_found( "authentication": ["did:sov:5qXMeLdyWEQhieFUBNw5ux#1"], "service": [ { - "id": "did:sov:5qXMeLdyWEQhieFUBNw5ux#didcomm", + "id": "did:sov:5qXMeLdyWEQhieFUBNw5ux#didcomm-0", "type": "did-communication", "recipientKeys": ["did:sov:5qXMeLdyWEQhieFUBNw5ux#1"], "serviceEndpoint": "http://172.17.0.1:9031/a2a/5b6dyY6PndLaCnWxZbeEYW/5b6dyY6PndLaCnWxZbeEYW/2f6aae0c-6b04-40ff-a25e-faecaea39f83", @@ -276,7 +276,7 @@ async def test_resolve_x_not_found( "authentication": [], "service": [ { - "id": "did:sov:1H6d1WS29Bcfr7Bb9tZxA#didcomm", + "id": "did:sov:1H6d1WS29Bcfr7Bb9tZxA#didcomm-0", "type": "did-communication", "priority": 0, "recipientKeys": ["did:sov:1H6d1WS29Bcfr7Bb9tZxA#cSwsDbSW"], @@ -338,7 +338,7 @@ async def test_resolve_x_not_found( "authentication": ["did:sov:PkWfCgY4SSAYeSoaWx3RFP#1"], "service": [ { - "id": "did:sov:PkWfCgY4SSAYeSoaWx3RFP#didcomm", + "id": "did:sov:PkWfCgY4SSAYeSoaWx3RFP#didcomm-0", "type": "did-communication", "priority": 0, "recipientKeys": ["did:sov:PkWfCgY4SSAYeSoaWx3RFP#1"], @@ -409,6 +409,87 @@ async def test_resolve_x_not_found( ], }, ), + ( # Doc with multiple services + { + "@context": "https://w3id.org/did/v1", + "id": "did:sov:JNKL9kJxQi5pNCfA8QBXdJ", + "publicKey": [ + { + "id": "did:sov:JNKL9kJxQi5pNCfA8QBXdJ#1", + "type": "Ed25519VerificationKey2018", + "controller": "did:sov:JNKL9kJxQi5pNCfA8QBXdJ", + "publicKeyBase58": "AU2FFjtkVzjFuirgWieqGGqtNrAZWS9LDuB8TDp6EUrG", + } + ], + "authentication": [ + { + "type": "Ed25519SignatureAuthentication2018", + "publicKey": "did:sov:JNKL9kJxQi5pNCfA8QBXdJ#1", + } + ], + "service": [ + { + "id": "did:sov:JNKL9kJxQi5pNCfA8QBXdJ;indy", + "type": "IndyAgent", + "priority": 0, + "recipientKeys": [ + "AU2FFjtkVzjFuirgWieqGGqtNrAZWS9LDuB8TDp6EUrG" + ], + "routingKeys": [ + "9NnKFUZoYcCqYC2PcaXH3cnaGsoRfyGgyEHbvbLJYh8j" + ], + "serviceEndpoint": "http://bob:3000", + }, + { + "id": "did:sov:JNKL9kJxQi5pNCfA8QBXdJ;indy-ws", + "type": "IndyAgent", + "priority": 1, + "recipientKeys": [ + "AU2FFjtkVzjFuirgWieqGGqtNrAZWS9LDuB8TDp6EUrG" + ], + "routingKeys": [ + "9NnKFUZoYcCqYC2PcaXH3cnaGsoRfyGgyEHbvbLJYh8j" + ], + "serviceEndpoint": "ws://bob:3000", + }, + ], + }, + { + "@context": "https://w3id.org/did/v1", + "id": "did:sov:JNKL9kJxQi5pNCfA8QBXdJ", + "verificationMethod": [ + { + "id": "did:sov:JNKL9kJxQi5pNCfA8QBXdJ#1", + "type": "Ed25519VerificationKey2018", + "controller": "did:sov:JNKL9kJxQi5pNCfA8QBXdJ", + "publicKeyBase58": "AU2FFjtkVzjFuirgWieqGGqtNrAZWS9LDuB8TDp6EUrG", + } + ], + "authentication": ["did:sov:JNKL9kJxQi5pNCfA8QBXdJ#1"], + "service": [ + { + "id": "did:sov:JNKL9kJxQi5pNCfA8QBXdJ#didcomm-0", + "type": "did-communication", + "priority": 0, + "recipientKeys": ["did:sov:JNKL9kJxQi5pNCfA8QBXdJ#1"], + "routingKeys": [ + "did:key:z6Mknq3MqipEt9hJegs6J9V7tiLa6T5H5rX3fFCXksJKTuv7#z6Mknq3MqipEt9hJegs6J9V7tiLa6T5H5rX3fFCXksJKTuv7" + ], + "serviceEndpoint": "http://bob:3000", + }, + { + "id": "did:sov:JNKL9kJxQi5pNCfA8QBXdJ#didcomm-1", + "type": "did-communication", + "priority": 1, + "recipientKeys": ["did:sov:JNKL9kJxQi5pNCfA8QBXdJ#1"], + "routingKeys": [ + "did:key:z6Mknq3MqipEt9hJegs6J9V7tiLa6T5H5rX3fFCXksJKTuv7#z6Mknq3MqipEt9hJegs6J9V7tiLa6T5H5rX3fFCXksJKTuv7" + ], + "serviceEndpoint": "ws://bob:3000", + }, + ], + }, + ), ], ) def test_corrections(self, input_doc: dict, expected: dict): From 468f1e30f236a06d16b70e05bec5d472b1a14bfb Mon Sep 17 00:00:00 2001 From: Shaanjot Gill Date: Thu, 7 Sep 2023 23:03:19 +0530 Subject: [PATCH 2/2] fix issue_2477 Signed-off-by: Shaanjot Gill --- aries_cloudagent/revocation/routes.py | 2 +- aries_cloudagent/tails/indy_tails_server.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/aries_cloudagent/revocation/routes.py b/aries_cloudagent/revocation/routes.py index 96cf06060b..51ea8a2bba 100644 --- a/aries_cloudagent/revocation/routes.py +++ b/aries_cloudagent/revocation/routes.py @@ -901,7 +901,7 @@ async def update_rev_reg_revoked_state(request: web.BaseRequest): available_write_ledgers = await ledger_manager.get_write_ledgers() LOGGER.debug(f"available write_ledgers = {available_write_ledgers}") LOGGER.debug(f"write_ledger = {write_ledger}") - pool = write_ledger[1].pool + pool = write_ledger.pool LOGGER.debug(f"write_ledger pool = {pool}") genesis_transactions = pool.genesis_txns diff --git a/aries_cloudagent/tails/indy_tails_server.py b/aries_cloudagent/tails/indy_tails_server.py index 04b9ab9b78..6118e641a5 100644 --- a/aries_cloudagent/tails/indy_tails_server.py +++ b/aries_cloudagent/tails/indy_tails_server.py @@ -47,7 +47,7 @@ async def upload_tails_file( available_write_ledgers = await ledger_manager.get_write_ledgers() LOGGER.debug(f"available write_ledgers = {available_write_ledgers}") LOGGER.debug(f"write_ledger = {write_ledger}") - pool = write_ledger[1].pool + pool = write_ledger.pool LOGGER.debug(f"write_ledger pool = {pool}") genesis_transactions = pool.genesis_txns