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

The features, handlers and tests Kene has been working on #3

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions aries_cloudagent/messaging/valid.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,7 @@ def __init__(
INDY_CRED_DEF_ID_VALIDATE = IndyCredDefId()
INDY_CRED_DEF_ID_EXAMPLE = IndyCredDefId.EXAMPLE


INDY_REV_REG_ID_VALIDATE = IndyRevRegId()
INDY_REV_REG_ID_EXAMPLE = IndyRevRegId.EXAMPLE

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,4 @@ class Meta:
"example": {"proofType": "Ed25519Signature2018"},
},
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
"""Linked data proof verifiable options detail artifacts to attach to RFC 453 messages."""

from typing import Optional, Union

from marshmallow import INCLUDE, fields


from .......messaging.models.base import BaseModel, BaseModelSchema
from .......vc.vc_ld import CredentialSchema
from .......vc.vc_ld.models.credential import VerifiableCredential
from .cred_detail_options import VCDIDetailOptions, VCDIDetailOptionsSchema

# class LDProofVCDetail(BaseModel):
# """Linked data proof verifiable credential detail."""

# class Meta:
# """LDProofVCDetail metadata."""

# schema_class = "LDProofVCDetailSchema"

# def __init__(
# self,
# credential: Optional[Union[dict, VerifiableCredential]],
# options: Optional[Union[dict, LDProofVCOptions]],
# ) -> None:
# """Initialize the LDProofVCDetail instance."""
# self.credential = credential
# self.options = options

# def __eq__(self, other: object) -> bool:
# """Comparison between linked data vc details."""
# if isinstance(other, LDProofVCDetail):
# return self.credential == other.credential and self.options == other.options
# return False

class VCDIDetail(BaseModel):
"""W3C verifiable credential detail"""
class Meta:
"""VCDIDetail meatdata"""

schema_class = "VCDIDetailSchema"

def __init__(
self,
credential: Optional[Union[dict, VerifiableCredential]],
options: Optional[Union[dict, VCDIDetailOptions]],
) -> None:
self.credential = credential

def __eq__(self, other: object) -> bool:
"""Comparison between W3C vc details."""
if isinstance(other, VCDIDetail):
return self.credential == other.credential and self.options == other.options
return False

class VCDIDetailSchema(BaseModelSchema):
"""VC_DI verifiable credential detail schema."""

class Meta:
"""Accept parameter overload."""

unknown = INCLUDE
model_class = VCDIDetail

credential = fields.Nested(
CredentialSchema(),
required=True,
metadata={
"description": "Detail of the VC_DI Credential to be issued",
"example": {
"@id": "284d3996-ba85-45d9-964b-9fd5805517b6",
"@type": "https://didcomm.org/issue-credential/2.0/issue-credential",
"comment": "<some comment>",
"formats": [
{
"attach_id": "5b38af88-d36f-4f77-bb7a-2f04ab806eb8",
"format": "didcomm/[email protected]"
}
],
"credentials~attach": [
{
"@id": "5b38af88-d36f-4f77-bb7a-2f04ab806eb8",
"mime-type": "application/ld+json",
"data": {
"base64": "ewogICAgICAgICAgIkBjb250ZXogWwogICAgICAg...(clipped)...RNVmR0SXFXZhWXgySkJBIgAgfQogICAgICAgIH0="
}
}
]
}
},
)

options = fields.Nested(
VCDIDetailOptionsSchema(),
required=True,
metadata={
"description": (
"Options for specifying how the linked data proof is created."
),
"example": {"proofType": "Ed25519Signature2018"},
},
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
"""LDProofVCDetailOptions."""

from typing import Optional

from marshmallow import INCLUDE, Schema, fields

from .......messaging.models.base import BaseModel, BaseModelSchema
from .......messaging.valid import (
INDY_ISO8601_DATETIME_EXAMPLE,
INDY_ISO8601_DATETIME_VALIDATE,
UUID4_EXAMPLE,
)


class VCDIDetailOptions(BaseModel):
"""W3C verifiable credential options model."""

class Meta:
"""VCDIDetailOptions metadata."""

schema_class = "VCDIDetailOptionsSchema"

def __init__(
self,
proof_type: Optional[str] = None,
proof_purpose: Optional[str] = None,
created: Optional[str] = None,
domain: Optional[str] = None,
challenge: Optional[str] = None,
credential_status: Optional[dict] = None,
) -> None:
"""Initialize the VCDIDetailOptions instance."""

self.proof_type = proof_type
self.proof_purpose = proof_purpose
self.created = created
self.domain = domain
self.challenge = challenge
self.credential_status = credential_status

def __eq__(self, o: object) -> bool:
"""Check equalness."""
if isinstance(o, VCDIDetailOptions):
return (
self.proof_type == o.proof_type
and self.proof_purpose == o.proof_purpose
and self.created == o.created
and self.domain == o.domain
and self.challenge == o.challenge
and self.credential_status == o.credential_status
)

return False


class CredentialStatusOptionsSchema(Schema):
"""W3C credential status options schema."""

class Meta:
"""Accept parameter overload."""

unknown = INCLUDE

type = fields.Str(
required=True,
metadata={
"description": (
"Credential status method type to use for the credential. Should match"
" status method registered in the Verifiable Credential Extension"
" Registry"
),
"example": "CredentialStatusList2017",
},
)


class VCDIDetailOptionsSchema(BaseModelSchema):
"""W3C verifiable credential options schema."""

class Meta:
"""Accept parameter overload."""

unknown = INCLUDE
model_class = VCDIDetailOptions

proof_type = fields.Str(
data_key="proofType",
required=True,
metadata={
"description": (
"The proof type used for the proof. Should match suites registered in"
" the Linked Data Cryptographic Suite Registry"
),
"example": "Ed25519Signature2018",
},
)

proof_purpose = fields.Str(
data_key="proofPurpose",
required=False,
metadata={
"description": (
"The proof purpose used for the proof. Should match proof purposes"
" registered in the W3Cs Specification"
),
"example": "assertionMethod",
},
)

created = fields.Str(
required=False,
validate=INDY_ISO8601_DATETIME_VALIDATE,
metadata={
"description": (
"The date and time of the proof (with a maximum accuracy in seconds)."
" Defaults to current system time"
),
"example": INDY_ISO8601_DATETIME_EXAMPLE,
},
)

domain = fields.Str(
required=False,
metadata={
"description": "The intended domain of validity for the proof",
"example": "example.com",
},
)

challenge = fields.Str(
required=False,
metadata={
"description": (
"A challenge to include in the proof. SHOULD be provided by the"
" requesting party of the credential (=holder)"
),
"example": UUID4_EXAMPLE,
},
)

credential_status = fields.Nested(
CredentialStatusOptionsSchema(),
data_key="credentialStatus",
required=False,
metadata={
"description": (
"The credential status mechanism to use for the credential. Omitting"
" the property indicates the issued credential will not include a"
" credential status"
)
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@

MESSAGE_TYPES = DIDCommPrefix.qualify_all(
{
CRED_20_PROPOSAL: (
f"{PROTOCOL_PACKAGE}.messages.cred_proposal.V20CredProposal"
),
CRED_20_PROPOSAL: (f"{PROTOCOL_PACKAGE}.messages.cred_proposal.V20CredProposal"),
CRED_20_OFFER: f"{PROTOCOL_PACKAGE}.messages.cred_offer.V20CredOffer",
CRED_20_REQUEST: f"{PROTOCOL_PACKAGE}.messages.cred_request.V20CredRequest",
CRED_20_ISSUE: f"{PROTOCOL_PACKAGE}.messages.cred_issue.V20CredIssue",
Expand Down
48 changes: 48 additions & 0 deletions aries_cloudagent/protocols/issue_credential/v2_0/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
from .models.cred_ex_record import V20CredExRecord, V20CredExRecordSchema
from .models.detail.indy import V20CredExRecordIndySchema
from .models.detail.ld_proof import V20CredExRecordLDProofSchema
from .formats.vc_di.models.cred_detail import VCDIDetailSchema


LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -172,6 +174,45 @@ class V20CredFilterIndySchema(OpenAPISchema):
metadata={"description": "Credential issuer DID", "example": INDY_DID_EXAMPLE},
)

class V20CredFilterVCDISchema(OpenAPISchema):
"""Indy credential filtration criteria."""

cred_def_id = fields.Str(
required=False,
validate=INDY_CRED_DEF_ID_VALIDATE,
metadata={
"description": "Credential definition identifier",
"example": INDY_CRED_DEF_ID_EXAMPLE,
},
)
schema_id = fields.Str(
required=False,
validate=INDY_SCHEMA_ID_VALIDATE,
metadata={
"description": "Schema identifier",
"example": INDY_SCHEMA_ID_EXAMPLE,
},
)
schema_issuer_did = fields.Str(
required=False,
validate=INDY_DID_VALIDATE,
metadata={"description": "Schema issuer DID", "example": INDY_DID_EXAMPLE},
)
schema_name = fields.Str(
required=False,
metadata={"description": "Schema name", "example": "preferences"},
)
schema_version = fields.Str(
required=False,
validate=INDY_VERSION_VALIDATE,
metadata={"description": "Schema version", "example": INDY_VERSION_EXAMPLE},
)
issuer_did = fields.Str(
required=False,
validate=INDY_DID_VALIDATE,
metadata={"description": "Credential issuer DID", "example": INDY_DID_EXAMPLE},
)


class V20CredFilterVCDISchema(OpenAPISchema):
"""VCDI credential filtration criteria."""
Expand Down Expand Up @@ -226,6 +267,13 @@ class V20CredFilterSchema(OpenAPISchema):
required=False,
metadata={"description": "Credential filter for linked data proof"},
)
vc_di = fields.Nested(
VCDIDetailSchema,
# V20CredFilterVCDISchema,
required=False,
metadata={"description": "Credential filter for vc_di"},
)


vc_di = fields.Nested(
V20CredFilterVCDISchema,
Expand Down
Empty file modified demo/alice-local.sh
100755 → 100644
Empty file.
Empty file modified demo/docker-agent/ngrok-wait.sh
100755 → 100644
Empty file.
Empty file modified demo/elk-stack/extensions/logspout/build.sh
100755 → 100644
Empty file.
Empty file modified demo/elk-stack/setup/entrypoint.sh
100755 → 100644
Empty file.
Empty file modified demo/faber-local.sh
100755 → 100644
Empty file.
Empty file modified demo/multi-demo/ngrok-wait.sh
100755 → 100644
Empty file.
Empty file modified demo/ngrok-wait.sh
100755 → 100644
Empty file.
Empty file modified demo/run_bdd
100755 → 100644
Empty file.
Empty file modified demo/run_demo
100755 → 100644
Empty file.
Loading
Loading