Skip to content

Commit d0f9138

Browse files
authored
Remove present proof v1 (#3981)
* Initial commit Signed-off-by: jamshale <jamiehalebc@gmail.com> * Further removal Signed-off-by: jamshale <jamiehalebc@gmail.com> * Remove v1 protocol scenario test Signed-off-by: jamshale <jamiehalebc@gmail.com> --------- Signed-off-by: jamshale <jamiehalebc@gmail.com>
1 parent 9333e66 commit d0f9138

48 files changed

Lines changed: 36 additions & 9868 deletions

Some content is hidden

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

acapy_agent/core/oob_processor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from ..protocols.didcomm_prefix import DIDCommPrefix
1313
from ..protocols.issue_credential.v2_0.message_types import CRED_20_OFFER
1414
from ..protocols.out_of_band.v1_0.models.oob_record import OobRecord
15-
from ..protocols.present_proof.v1_0.message_types import PRESENTATION_REQUEST
1615
from ..protocols.present_proof.v2_0.message_types import PRES_20_REQUEST
1716
from ..storage.error import StorageNotFoundError
1817
from ..transport.inbound.message import InboundMessage
@@ -301,9 +300,9 @@ async def handle_message(
301300
"""Message handler for inbound messages."""
302301
supported_types = [
303302
CRED_20_OFFER,
304-
PRESENTATION_REQUEST,
305303
PRES_20_REQUEST,
306304
"issue-credential/1.0/offer-credential",
305+
"present-proof/1.0/request-presentation",
307306
]
308307

309308
supported_messages = [

acapy_agent/core/tests/test_oob_processor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ async def test_handle_message_unsupported_message_type(self):
735735
self.profile, [{"@type": "unsupported"}], mock.MagicMock()
736736
)
737737
assert (
738-
"None of the oob attached messages supported. Supported message types are issue-credential/2.0/offer-credential, present-proof/1.0/request-presentation, present-proof/2.0/request-presentation"
738+
"None of the oob attached messages supported. Supported message types are issue-credential/2.0/offer-credential, present-proof/2.0/request-presentation, issue-credential/1.0/offer-credential, present-proof/1.0/request-presentation"
739739
in err.exception.message
740740
)
741741

acapy_agent/protocols/out_of_band/v1_0/manager.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
from ...didcomm_prefix import DIDCommPrefix
3131
from ...didexchange.v1_0.manager import DIDXManager
3232
from ...issue_credential.v2_0.models.cred_ex_record import V20CredExRecord
33-
from ...present_proof.v1_0.models.presentation_exchange import V10PresentationExchange
3433
from ...present_proof.v2_0.models.pres_exchange import V20PresExRecord
3534
from .message_types import DEFAULT_VERSION
3635
from .messages.invitation import HSProto, InvitationMessage
@@ -202,12 +201,8 @@ async def create_attachment(
202201
)
203202
message = cred_ex_rec.cred_offer
204203
elif a_type == "present-proof":
205-
try:
206-
pres_ex_rec = await V10PresentationExchange.retrieve_by_id(session, a_id)
207-
message = pres_ex_rec.presentation_request_dict
208-
except StorageNotFoundError:
209-
pres_ex_rec = await V20PresExRecord.retrieve_by_id(session, a_id)
210-
message = pres_ex_rec.pres_request
204+
pres_ex_rec = await V20PresExRecord.retrieve_by_id(session, a_id)
205+
message = pres_ex_rec.pres_request
211206
else:
212207
raise OutOfBandManagerError(f"Unknown attachment type: {a_type}")
213208
message.assign_thread_id(pthid=pthid)

acapy_agent/protocols/out_of_band/v1_0/tests/test_manager.py

Lines changed: 3 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@
4545
V20CredPreview,
4646
)
4747
from ....issue_credential.v2_0.tests import INDY_OFFER
48-
from ....present_proof.v1_0.message_types import ATTACH_DECO_IDS as V10_PRES_ATTACH_FORMAT
49-
from ....present_proof.v1_0.message_types import PRESENTATION_REQUEST
50-
from ....present_proof.v1_0.messages.presentation_request import PresentationRequest
5148
from ....present_proof.v2_0.message_types import (
5249
ATTACHMENT_FORMAT as V20_PRES_ATTACH_FORMAT,
5350
)
@@ -173,29 +170,6 @@ class TestConfig:
173170
},
174171
}
175172

176-
PRES_REQ_V1 = PresentationRequest(
177-
comment="Test",
178-
request_presentations_attach=[
179-
AttachDecorator.data_base64(
180-
mapping=INDY_PROOF_REQ,
181-
ident=V10_PRES_ATTACH_FORMAT[PRESENTATION_REQUEST],
182-
)
183-
],
184-
)
185-
pres_req_dict = PRES_REQ_V1.request_presentations_attach[0].serialize()
186-
req_attach_v1 = {
187-
"@id": "request-0",
188-
"mime-type": "application/json",
189-
"data": {
190-
"json": {
191-
"@type": DIDCommPrefix.qualify_current(PRESENTATION_REQUEST),
192-
"@id": "12345678-0123-4567-1234-567812345678",
193-
"comment": "some comment",
194-
"request_presentations~attach": [pres_req_dict],
195-
}
196-
},
197-
}
198-
199173
PRES_REQ_V2 = V20PresRequest(
200174
comment="some comment",
201175
will_confirm=True,
@@ -504,55 +478,12 @@ async def test_create_invitation_attachment_v2_0_cred_offer(self):
504478
assert "~thread" in attach and "pthid" in attach["~thread"]
505479
assert attach["~thread"]["pthid"] == invi_rec.invi_msg_id
506480

507-
async def test_create_invitation_attachment_present_proof_v1_0(self):
508-
self.profile.context.update_settings({"public_invites": True})
509-
with (
510-
mock.patch.object(
511-
AskarWallet, "get_public_did", autospec=True
512-
) as mock_wallet_get_public_did,
513-
mock.patch.object(
514-
test_module.V10PresentationExchange,
515-
"retrieve_by_id",
516-
mock.CoroutineMock(),
517-
) as mock_retrieve_pxid,
518-
):
519-
mock_wallet_get_public_did.return_value = DIDInfo(
520-
TestConfig.test_did,
521-
TestConfig.test_verkey,
522-
None,
523-
method=SOV,
524-
key_type=ED25519,
525-
)
526-
mock_retrieve_pxid.return_value = mock.MagicMock(
527-
presentation_request_dict=self.PRES_REQ_V1
528-
)
529-
invi_rec = await self.manager.create_invitation(
530-
my_endpoint=TestConfig.test_endpoint,
531-
public=True,
532-
hs_protos=[test_module.HSProto.RFC23],
533-
multi_use=False,
534-
attachments=[{"type": "present-proof", "id": "dummy-id"}],
535-
)
536-
537-
mock_retrieve_pxid.assert_called_once_with(ANY, "dummy-id")
538-
assert isinstance(invi_rec, InvitationRecord)
539-
assert invi_rec.invitation.handshake_protocols
540-
assert invi_rec.invitation.requests_attach[0].content == {
541-
**self.PRES_REQ_V1.serialize(),
542-
"~thread": {"pthid": invi_rec.invi_msg_id},
543-
}
544-
545481
async def test_create_invitation_attachment_present_proof_v2_0(self):
546482
self.profile.context.update_settings({"public_invites": True})
547483
with (
548484
mock.patch.object(
549485
AskarWallet, "get_public_did", autospec=True
550486
) as mock_wallet_get_public_did,
551-
mock.patch.object(
552-
test_module.V10PresentationExchange,
553-
"retrieve_by_id",
554-
mock.CoroutineMock(),
555-
) as mock_retrieve_pxid_1,
556487
mock.patch.object(
557488
test_module.V20PresExRecord,
558489
"retrieve_by_id",
@@ -566,7 +497,6 @@ async def test_create_invitation_attachment_present_proof_v2_0(self):
566497
method=SOV,
567498
key_type=ED25519,
568499
)
569-
mock_retrieve_pxid_1.side_effect = StorageNotFoundError()
570500
mock_retrieve_pxid_2.return_value = mock.MagicMock(
571501
pres_request=TestConfig.PRES_REQ_V2
572502
)
@@ -1470,7 +1400,7 @@ async def test_receive_invitation_services_with_service_did(self):
14701400

14711401
async def test_request_attach_oob_message_processor_connectionless(self):
14721402
requests_attach: List[AttachDecorator] = [
1473-
AttachDecorator.deserialize(deepcopy(TestConfig.req_attach_v1))
1403+
AttachDecorator.deserialize(deepcopy(TestConfig.req_attach_v2))
14741404
]
14751405

14761406
mock_oob_processor = mock.MagicMock(OobMessageProcessor, autospec=True)
@@ -1539,7 +1469,7 @@ async def test_request_attach_oob_message_processor_connection(self):
15391469
)
15401470

15411471
requests_attach: List[AttachDecorator] = [
1542-
AttachDecorator.deserialize(deepcopy(TestConfig.req_attach_v1))
1472+
AttachDecorator.deserialize(deepcopy(TestConfig.req_attach_v2))
15431473
]
15441474

15451475
mock_oob_processor = mock.MagicMock(OobMessageProcessor, autospec=True)
@@ -1602,7 +1532,7 @@ async def test_request_attach_wait_for_conn_rec_active(self):
16021532
],
16031533
services=[TestConfig.test_target_did],
16041534
requests_attach=[
1605-
AttachDecorator.deserialize(deepcopy(TestConfig.req_attach_v1))
1535+
AttachDecorator.deserialize(deepcopy(TestConfig.req_attach_v2))
16061536
],
16071537
)
16081538

acapy_agent/protocols/present_proof/anoncreds/pres_exch_handler.py

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import json
44
import logging
55
import time
6-
from typing import Dict, Optional, Tuple, Union
6+
from typing import Dict, Optional, Protocol, Tuple
77

88
from ....anoncreds.holder import AnonCredsHolder, AnonCredsHolderError
99
from ....anoncreds.models.credential_definition import CredDef
@@ -15,9 +15,6 @@
1515
from ....askar.profile_anon import AskarAnonCredsProfile
1616
from ....core.error import BaseError
1717
from ....core.profile import Profile
18-
from ..v1_0.models.presentation_exchange import V10PresentationExchange
19-
from ..v2_0.messages.pres_format import V20PresFormat
20-
from ..v2_0.models.pres_exchange import V20PresExRecord
2118

2219
LOGGER = logging.getLogger(__name__)
2320

@@ -26,6 +23,13 @@ class AnonCredsPresExchHandlerError(BaseError):
2623
"""Base class for AnonCreds Presentation Exchange related errors."""
2724

2825

26+
class AnonCredsProofRequestContainer(Protocol):
27+
"""Protocol for a class that contains an AC Proof Request."""
28+
29+
def get_ac_proof_request(self) -> dict:
30+
"""Retrieve AC proof request object."""
31+
32+
2933
class AnonCredsPresExchHandler:
3034
"""Base Presentation Exchange Handler."""
3135

@@ -38,18 +42,6 @@ def __init__(
3842
self._profile = profile
3943
self.holder = AnonCredsHolder(profile)
4044

41-
def _extract_proof_request(self, pres_ex_record):
42-
if isinstance(pres_ex_record, V20PresExRecord):
43-
return pres_ex_record.pres_request.attachment(
44-
V20PresFormat.Format.ANONCREDS
45-
) or pres_ex_record.pres_request.attachment(V20PresFormat.Format.INDY)
46-
elif isinstance(pres_ex_record, V10PresentationExchange):
47-
return pres_ex_record._presentation_request.ser
48-
49-
raise TypeError(
50-
"pres_ex_record must be V10PresentationExchange or V20PresExRecord"
51-
)
52-
5345
def _get_requested_referents(
5446
self,
5547
proof_request: dict,
@@ -229,7 +221,7 @@ def _set_timestamps(self, requested_credentials: dict, requested_referents: dict
229221

230222
async def return_presentation(
231223
self,
232-
pres_ex_record: Union[V10PresentationExchange, V20PresExRecord],
224+
pres_ex_record: AnonCredsProofRequestContainer,
233225
requested_credentials: Optional[dict] = None,
234226
) -> dict:
235227
"""Return AnonCreds proof request as dict."""
@@ -244,7 +236,7 @@ async def return_presentation(
244236
)
245237

246238
requested_credentials = requested_credentials or {}
247-
proof_request = self._extract_proof_request(pres_ex_record)
239+
proof_request = pres_ex_record.get_ac_proof_request()
248240
non_revoc_intervals = extract_non_revocation_intervals_from_proof_request(
249241
proof_request
250242
)

acapy_agent/protocols/present_proof/definition.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
"""Version definitions for this protocol."""
22

33
versions = [
4-
{
5-
"major_version": 1,
6-
"minimum_minor_version": 0,
7-
"current_minor_version": 0,
8-
"path": "v1_0",
9-
},
104
{
115
"major_version": 2,
126
"minimum_minor_version": 0,

acapy_agent/protocols/present_proof/indy/pres_exch_handler.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import json
44
import logging
55
import time
6-
from typing import Optional, Tuple, Union
6+
from typing import Optional, Tuple
77

88
from ....core.error import BaseError
99
from ....core.profile import Profile
@@ -16,9 +16,7 @@
1616
)
1717
from ....multitenant.base import BaseMultitenantManager
1818
from ....revocation.models.revocation_registry import RevocationRegistry
19-
from ..v1_0.models.presentation_exchange import V10PresentationExchange
20-
from ..v2_0.messages.pres_format import V20PresFormat
21-
from ..v2_0.models.pres_exchange import V20PresExRecord
19+
from ..anoncreds.pres_exch_handler import AnonCredsProofRequestContainer
2220

2321
LOGGER = logging.getLogger(__name__)
2422

@@ -40,7 +38,7 @@ def __init__(
4038

4139
async def return_presentation(
4240
self,
43-
pres_ex_record: Union[V10PresentationExchange, V20PresExRecord],
41+
pres_ex_record: AnonCredsProofRequestContainer,
4442
requested_credentials: Optional[dict] = None,
4543
) -> dict:
4644
"""Return Indy proof request as dict."""
@@ -51,19 +49,7 @@ async def return_presentation(
5149

5250
# extract credential ids and non_revoked
5351
requested_referents = {}
54-
if isinstance(pres_ex_record, V20PresExRecord):
55-
proof_request = pres_ex_record.pres_request.attachment(
56-
V20PresFormat.Format.INDY
57-
)
58-
# If indy filter fails try anoncreds filter format. This is for a
59-
# non-anoncreds agent that gets a anoncreds format proof request and
60-
# should removed when indy format is fully retired.
61-
if not proof_request:
62-
proof_request = pres_ex_record.pres_request.attachment(
63-
V20PresFormat.Format.ANONCREDS
64-
)
65-
elif isinstance(pres_ex_record, V10PresentationExchange):
66-
proof_request = pres_ex_record._presentation_request.ser
52+
proof_request = pres_ex_record.get_ac_proof_request()
6753
non_revoc_intervals = indy_proof_req2non_revoc_intervals(proof_request)
6854
attr_creds = requested_credentials.get("requested_attributes", {})
6955
req_attrs = proof_request.get("requested_attributes", {})

acapy_agent/protocols/present_proof/v1_0/__init__.py

Lines changed: 0 additions & 60 deletions
This file was deleted.

acapy_agent/protocols/present_proof/v1_0/controller.py

Lines changed: 0 additions & 16 deletions
This file was deleted.

acapy_agent/protocols/present_proof/v1_0/handlers/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)