Skip to content

Commit

Permalink
edit proof options
Browse files Browse the repository at this point in the history
Signed-off-by: PatStLouis <[email protected]>
  • Loading branch information
PatStLouis committed Oct 21, 2024
1 parent 3f94919 commit 115c80f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
5 changes: 3 additions & 2 deletions acapy_agent/vc/api/models/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def __init__(
) -> None:
"""Initialize the IssueCredentialOptions instance."""

self.type = type
self.cryptosuite = cryptosuite
self.type = type or 'DataIntegrityProof'
self.cryptosuite = cryptosuite or 'eddsa-jcs-2022'
self.verification_method = verification_method
self.credential_id = credential_id
self.extra = kwargs
Expand Down Expand Up @@ -78,6 +78,7 @@ class Meta:
credential_id = fields.Str(
data_key="credentialId",
required=False,
validate=Uri(),
metadata={
"description": "",
"example": UUID4_EXAMPLE,
Expand Down
6 changes: 4 additions & 2 deletions acapy_agent/vc/api/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,18 @@ async def issue_credential_route(request: web.BaseRequest):
CredentialV2.model_validate(credential)
except Exception as err:
raise web.HTTPBadRequest(reason=err.errors()[0])
options['proofPurpose'] = 'assertionMethod'

issuer = credential.get('issuer')
if isinstance(issuer, dict):
issuer = issuer.get('id')

if not options.get('verificationMethod'):
if 'key' in issuer:
multikey = issuer.split(':')[-1]
options['verificaitonMethod'] = f'{issuer}#{multikey}'
options['verificationMethod'] = f'{issuer}#{multikey}'
else:
raise web.HTTPBadRequest(reason='Missing VerificationMethod')

options = DataIntegrityProofOptions.deserialize(options)
async with context.session() as session:
vc = await DataIntegrityManager(session).add_proof(credential, options)
Expand Down
12 changes: 6 additions & 6 deletions acapy_agent/vc/data_integrity/models/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ def __init__(
"""Initialize the DataIntegrityProofOptions instance."""

self.id = id
self.type = type
self.proof_purpose = proof_purpose
self.type = type or 'DataIntegrityProof'
self.proof_purpose = proof_purpose or 'assertionMethod'
self.verification_method = verification_method
self.cryptosuite = cryptosuite
self.cryptosuite = cryptosuite or 'eddsa-jcs-2022'
self.created = created
self.expires = expires
self.domain = domain
Expand Down Expand Up @@ -78,7 +78,7 @@ class Meta:
)

type = fields.Str(
required=True,
required=False,
metadata={
"description": (
"The specific type of proof MUST be specified as a string that maps \
Expand All @@ -90,7 +90,7 @@ class Meta:

proof_purpose = fields.Str(
data_key="proofPurpose",
required=True,
required=False,
metadata={
"description": "The proof purpose acts as a safeguard to prevent the \
proof from being misused by being applied to a purpose other than \
Expand All @@ -114,7 +114,7 @@ class Meta:
)

cryptosuite = fields.Str(
required=True,
required=False,
metadata={
"description": (
"An identifier for the cryptographic suite that can be used to \
Expand Down

0 comments on commit 115c80f

Please sign in to comment.