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

πŸ—‘οΈ Remove v1 protocol version and default to v2 #902

Merged
merged 25 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
232fd9d
:white_check_mark: remove v1 protocol version from parameterised tests
ff137 Jul 24, 2024
19779c3
:art: use "v2"
ff137 Jul 24, 2024
1bac90e
:fire: delete v1 services
ff137 Sep 6, 2024
85c4cd9
:white_check_mark: remove v1 from tests, or switch to v2 protocol
ff137 Sep 6, 2024
3760dc4
:art: remove usage of v1 protocol version or models
ff137 Sep 6, 2024
fdb9197
:art: remove protocol_version from request bodies in docs / switch to…
ff137 Sep 6, 2024
1486687
:art: remove protocol_version from request bodies / remove need for c…
ff137 Sep 6, 2024
fbb465c
:white_check_mark: update tests to no longer set protocol_version in …
ff137 Sep 6, 2024
913e1b1
:white_check_mark: fix tests
ff137 Sep 6, 2024
e106770
:art:
ff137 Sep 6, 2024
dd1e645
:fire: remove unused methods
ff137 Sep 6, 2024
a433143
:white_check_mark: 100% test coverage again
ff137 Sep 6, 2024
db08905
:art:
ff137 Sep 6, 2024
5802e7e
:white_check_mark: add look_back to fix sporadic error
ff137 Sep 6, 2024
f2e6ec0
Merge branch 'development' into deprecate/v1-protocol-version
ff137 Oct 9, 2024
8806e34
Merge branch 'development' into deprecate/v1-protocol-version
ff137 Oct 9, 2024
ee97e42
Merge branch 'development' into deprecate/v1-protocol-version
ff137 Oct 9, 2024
91b00d2
:loud_sound: Change ledger-browser and -nodes log level to WARN
ff137 Oct 9, 2024
f120300
:art: fix test module name
ff137 Oct 9, 2024
d855527
:wastebasket: drop protocol_version from exchange models
ff137 Oct 9, 2024
41583b1
:art: update docs to no longer reference protocol_version
ff137 Oct 9, 2024
91965b6
:test_tube: remove test usage or assertion of protocol_version
ff137 Oct 9, 2024
8d7e6fb
:memo: Update openapi docs
ff137 Oct 9, 2024
57b36bd
:art: apply pretty print formatting
ff137 Oct 9, 2024
7e10584
:memo: Update openapi docs with protocol version changes
ff137 Oct 9, 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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ method. For example:

```bash
poetry run pytest \
app/tests/e2e/test_verifier.py::test_accept_proof_request_oob_v1 \
app/tests/e2e/test_verifier_oob.py::test_accept_proof_request_oob \
--log-cli-level=1
```

Expand Down
9 changes: 2 additions & 7 deletions app/models/issuer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from pydantic import BaseModel, Field, ValidationInfo, field_validator, model_validator

from shared.exceptions import CloudApiValueError
from shared.models.protocol import IssueCredentialProtocolVersion


class CredentialType(str, Enum):
Expand Down Expand Up @@ -51,15 +50,11 @@ class CredentialWithConnection(CredentialBase):
connection_id: str


class CredentialWithProtocol(CredentialBase):
protocol_version: IssueCredentialProtocolVersion = IssueCredentialProtocolVersion.V2


class SendCredential(CredentialWithProtocol, CredentialWithConnection):
class SendCredential(CredentialWithConnection):
pass


class CreateOffer(CredentialWithProtocol):
class CreateOffer(CredentialBase):
pass


Expand Down
2 changes: 0 additions & 2 deletions app/models/verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from pydantic import BaseModel, Field, ValidationInfo, field_validator, model_validator

from shared.exceptions import CloudApiValueError
from shared.models.protocol import PresentProofProtocolVersion


class ProofRequestType(str, Enum):
Expand Down Expand Up @@ -60,7 +59,6 @@ def check_indy_proof_request(cls, values: Union[dict, "ProofRequestBase"]):


class ProofRequestMetadata(BaseModel):
protocol_version: PresentProofProtocolVersion = PresentProofProtocolVersion.V2
comment: Optional[str] = None


Expand Down
63 changes: 12 additions & 51 deletions app/routes/issuer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@
from app.services import revocation_registry
from app.services.acapy_ledger import schema_id_from_credential_definition_id
from app.services.acapy_wallet import assert_public_did
from app.services.issuer.acapy_issuer_v2 import IssuerV2
from app.services.trust_registry.util.issuer import assert_valid_issuer
from app.util.acapy_issuer_utils import (
IssueCredentialFacades,
issuer_from_id,
issuer_from_protocol_version,
)
from app.util.did import did_from_credential_definition_id, qualified_did_sov
from app.util.pagination import (
descending_query_parameter,
Expand All @@ -37,12 +33,7 @@
)
from app.util.retry_method import coroutine_with_retry_until_value
from shared.log_config import get_logger
from shared.models.credential_exchange import (
CredentialExchange,
Role,
State,
back_to_v1_credential_state,
)
from shared.models.credential_exchange import CredentialExchange, Role, State

logger = get_logger(__name__)

Expand All @@ -67,7 +58,6 @@ async def send_credential(
"ld_credential_detail": {...}, <-- Required if type is ld_proof
"save_exchange_record": true, <-- Whether the credential exchange record should be saved on completion.
"connection_id": "string", <-- The issuer's reference to the connection they want to submit the credential to.
"protocol_version": "v2" <-- v1 is supported, but deprecated.
}
```
Setting the `save_exchange_record` field to True will save the exchange record after the credential is accepted.
Expand All @@ -90,14 +80,11 @@ async def send_credential(
body={
# Do not log credential attributes:
"connection_id": credential.connection_id,
"protocol_version": credential.protocol_version,
"credential_type": credential.type,
}
)
bound_logger.debug("POST request received: Send credential")

issuer = issuer_from_protocol_version(credential.protocol_version)

async with client_from_auth(auth) as aries_controller:
# Assert the agent has a public did
try:
Expand All @@ -122,7 +109,7 @@ async def send_credential(

try:
bound_logger.debug("Sending credential")
result = await issuer.send_credential(
result = await IssuerV2.send_credential(
controller=aries_controller, credential=credential
)
except CloudApiException as e:
Expand Down Expand Up @@ -162,7 +149,6 @@ async def create_offer(
"indy_credential_detail": {...}, <-- Required if type is indy
"ld_credential_detail": {...}, <-- Required if type is ld_proof
"save_exchange_record": true, <-- Whether the credential exchange record should be saved on completion.
"protocol_version": "v2" <-- v1 is supported, but deprecated.
}
```
For a detailed technical specification of the credential issuing process, refer to the [Aries Issue Credential v2
Expand All @@ -181,14 +167,11 @@ async def create_offer(
bound_logger = logger.bind(
body={
# Do not log credential attributes:
"protocol_version": credential.protocol_version,
"credential_type": credential.type,
}
)
bound_logger.debug("POST request received: Create credential offer")

issuer = issuer_from_protocol_version(credential.protocol_version)

async with client_from_auth(auth) as aries_controller:
# Assert the agent has a public did
try:
Expand All @@ -212,7 +195,7 @@ async def create_offer(
await assert_valid_issuer(public_did, schema_id)

bound_logger.debug("Creating offer")
result = await issuer.create_offer(
result = await IssuerV2.create_offer(
controller=aries_controller,
credential=credential,
)
Expand Down Expand Up @@ -251,11 +234,9 @@ async def request_credential(
bound_logger = logger.bind(body={"credential_exchange_id": credential_exchange_id})
bound_logger.debug("POST request received: Send credential request")

issuer = issuer_from_id(credential_exchange_id)

async with client_from_auth(auth) as aries_controller:
bound_logger.debug("Fetching records")
record = await issuer.get_record(aries_controller, credential_exchange_id)
record = await IssuerV2.get_record(aries_controller, credential_exchange_id)

schema_id = None
if record.type == "indy":
Expand All @@ -279,7 +260,7 @@ async def request_credential(
# Make sure the issuer is allowed to issue this credential according to trust registry rules

bound_logger.debug("Requesting credential")
result = await issuer.request_credential(
result = await IssuerV2.request_credential(
controller=aries_controller, credential_exchange_id=credential_exchange_id
)

Expand Down Expand Up @@ -323,11 +304,9 @@ async def store_credential(
bound_logger = logger.bind(body={"credential_exchange_id": credential_exchange_id})
bound_logger.debug("POST request received: Store credential")

issuer = issuer_from_id(credential_exchange_id)

async with client_from_auth(auth) as aries_controller:
bound_logger.debug("Storing credential")
result = await issuer.store_credential(
result = await IssuerV2.store_credential(
controller=aries_controller, credential_exchange_id=credential_exchange_id
)

Expand Down Expand Up @@ -389,21 +368,8 @@ async def get_credentials(
bound_logger.debug("GET request received: Get credentials")

async with client_from_auth(auth) as aries_controller:
bound_logger.debug("Fetching v1 records")
v1_records = await IssueCredentialFacades.V1.value.get_records(
controller=aries_controller,
limit=limit,
offset=offset,
order_by=order_by,
descending=descending,
connection_id=connection_id,
role=role,
state=back_to_v1_credential_state(state) if state else None,
thread_id=str(thread_id) if thread_id else None,
)

bound_logger.debug("Fetching v2 records")
v2_records = await IssueCredentialFacades.V2.value.get_records(
result = await IssuerV2.get_records(
controller=aries_controller,
limit=limit,
offset=offset,
Expand All @@ -415,11 +381,10 @@ async def get_credentials(
thread_id=str(thread_id) if thread_id else None,
)

result = v1_records + v2_records
if result:
bound_logger.debug("Successfully fetched v1 and v2 records.")
bound_logger.debug("Successfully fetched records.")
else:
bound_logger.debug("No v1 or v2 records returned.")
bound_logger.debug("No records returned.")
return result


Expand Down Expand Up @@ -462,11 +427,9 @@ async def get_credential(
bound_logger = logger.bind(body={"credential_exchange_id": credential_exchange_id})
bound_logger.debug("GET request received: Get credentials by credential id")

issuer = issuer_from_id(credential_exchange_id)

async with client_from_auth(auth) as aries_controller:
bound_logger.debug("Getting credential record")
result = await issuer.get_record(
result = await IssuerV2.get_record(
controller=aries_controller, credential_exchange_id=credential_exchange_id
)

Expand Down Expand Up @@ -500,11 +463,9 @@ async def remove_credential_exchange_record(
"DELETE request received: Remove credential exchange record by id"
)

issuer = issuer_from_id(credential_exchange_id)

async with client_from_auth(auth) as aries_controller:
bound_logger.debug("Deleting credential")
await issuer.delete_credential_exchange_record(
await IssuerV2.delete_credential_exchange_record(
controller=aries_controller, credential_exchange_id=credential_exchange_id
)

Expand Down
Loading
Loading