forked from hyperledger/aries-acapy-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Adam Burdett <[email protected]>
- Loading branch information
1 parent
d1a610b
commit 3da6ec4
Showing
7 changed files
with
252 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
from typing import Any, Dict, Optional | ||
from aries_cloudagent.messaging.models.base_record import BaseRecord, BaseRecordSchema, BaseExchangeRecord | ||
from marshmallow import fields | ||
|
||
class OID4VCICredentialExchangeRecord(BaseExchangeRecord): | ||
class Meta: | ||
schema_class = "CredExRecordSchema" | ||
|
||
RECORD_ID_NAME = "oid4vci_ex_id" | ||
RECORD_TYPE= "oid4vci" | ||
EVENT_NAMESPACE= "oid4vci" | ||
TAG_NAMES = {"nonce", "pin", "token"} | ||
def __init__( | ||
self, | ||
*, | ||
credential_supported_id=None, | ||
credential_subject: Optional[Dict[str, Any]] = None, | ||
nonce=None, | ||
pin=None, | ||
token=None, | ||
**kwargs, | ||
): | ||
super().__init__( | ||
None, | ||
state="init", | ||
**kwargs, | ||
) | ||
self.credential_supported_id = credential_supported_id | ||
self.credential_subject = credential_subject # (received from submit) | ||
self.nonce = nonce # in offer | ||
self.pin = pin # (when relevant) | ||
self.token = token | ||
|
||
@property | ||
def credential_exchange_id(self) -> str: | ||
"""Accessor for the ID associated with this exchange.""" | ||
return self._id | ||
|
||
|
||
# TODO: add validation | ||
class CredExRecordSchema(BaseRecordSchema): | ||
class Meta: | ||
model_class = OID4VCICredentialExchangeRecord | ||
|
||
credential_supported_id = fields.Str( | ||
required=True, | ||
metadata={ | ||
"description": "Identifier used to identify credential supported record", | ||
}, | ||
) | ||
credential_subject = ( | ||
fields.Dict( | ||
required=True, | ||
metadata={ | ||
"description": "desired claim and value in credential", | ||
}, | ||
), | ||
) | ||
nonce = ( | ||
fields.Str( | ||
required=False, | ||
), | ||
) | ||
pin = ( | ||
fields.Str( | ||
required=False, | ||
), | ||
) | ||
token = fields.Str( | ||
required=False, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
from aries_cloudagent.messaging.models.base_record import BaseRecord, BaseRecordSchema | ||
from marshmallow import fields | ||
|
||
|
||
class OID4VCICredentialSupported(BaseRecord): | ||
class Meta: | ||
schema_class = "CredSupRecordSchema" | ||
|
||
RECORD_ID_NAME = "oid4vci_id" | ||
RECORD_TYPE= "oid4vci" | ||
EVENT_NAMESPACE= "oid4vci" | ||
TAG_NAMES = {"credential_definition_id", "types", "scope"} | ||
|
||
def __init__( | ||
self, | ||
*, | ||
credential_definition_id, | ||
format, | ||
types, | ||
cryptographic_binding_methods_supported, | ||
cryptographic_suites_supported, | ||
display, | ||
credential_subject, | ||
scope, | ||
**kwargs, | ||
): | ||
super().__init__( | ||
None, | ||
state="init", | ||
**kwargs, | ||
) | ||
self.credential_definition_id = credential_definition_id | ||
self.format = format | ||
self.types = types | ||
self.cryptographic_binding_methods_supported = ( | ||
cryptographic_binding_methods_supported | ||
) | ||
self.cryptographic_suites_supported = cryptographic_suites_supported | ||
self.display = display | ||
self.credential_subject = credential_subject | ||
self.scope = scope | ||
|
||
def web_serialize(self) -> dict: | ||
return self.serialize() | ||
|
||
@property | ||
def id(self): | ||
return self._id | ||
|
||
|
||
# TODO: add validation | ||
class CredSupRecordSchema(BaseRecordSchema): | ||
class Meta: | ||
model_class = OID4VCICredentialSupported | ||
|
||
credential_definition_id = fields.Str( | ||
required=True, metadata={"example": "UniversityDegree_JWT"} | ||
) | ||
format = fields.Str(required=True, metadata={"example": "jwt_vc_json"}) | ||
types = fields.List( | ||
fields.Str(), | ||
metadata={"example": ["VerifiableCredential", "UniversityDegreeCredential"]}, | ||
) | ||
cryptographic_binding_methods_supported = fields.List( | ||
fields.Str(), metadata={"example": []} | ||
) | ||
cryptographic_suites_supported = fields.List( | ||
fields.Str(), metadata={"example": ["ES256K"]} | ||
) | ||
display = fields.List( | ||
fields.Dict(), | ||
metadata={ | ||
"example": [ | ||
{ | ||
"name": "University Credential", | ||
"locale": "en-US", | ||
"logo": { | ||
"url": "https://exampleuniversity.com/public/logo.png", | ||
"alt_text": "a square logo of a university", | ||
}, | ||
"background_color": "#12107c", | ||
"text_color": "#FFFFFF", | ||
} | ||
] | ||
}, | ||
) | ||
credential_subject = fields.Dict( | ||
metadata={ | ||
"given_name": {"display": [{"name": "Given Name", "locale": "en-US"}]}, | ||
"family_name": {"display": [{"name": "Surname", "locale": "en-US"}]}, | ||
"degree": {}, | ||
"gpa": {"display": [{"name": "GPA"}]}, | ||
} | ||
) | ||
scope = fields.Str( | ||
required=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters