Skip to content

Commit 9312736

Browse files
Merge branch 'feature/igrantio-integrations'
2 parents 7470353 + c3e1daf commit 9312736

File tree

18 files changed

+1943
-840
lines changed

18 files changed

+1943
-840
lines changed

mydata_did/patched_protocols/issue_credential/v1_0/models/credential_exchange.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from aries_cloudagent.messaging.valid import INDY_CRED_DEF_ID, INDY_SCHEMA_ID, UUIDFour
1111

1212
unencrypted_tags = environ.get(
13-
"EXCH_UNENCRYPTED_TAGS", "False").upper() == "TRUE"
13+
"EXCH_UNENCRYPTED_TAGS", "false").upper() == "TRUE"
1414

1515

1616
class V10CredentialExchange(BaseExchangeRecord):

mydata_did/patched_protocols/issue_credential/v1_0/routes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -940,8 +940,8 @@ async def credential_exchange_send_free_offer(request: web.BaseRequest):
940940
# Tag filter
941941
tag_filter = {
942942
"data_agreement_id": data_agreement_id,
943-
"published_flag": "True",
944-
"delete_flag": "False",
943+
"publish_flag": "true",
944+
"delete_flag": "false",
945945
}
946946

947947
try:
@@ -1069,8 +1069,8 @@ async def credential_exchange_send_bound_offer(request: web.BaseRequest):
10691069
# Tag filter
10701070
tag_filter = {
10711071
"data_agreement_id": data_agreement_id,
1072-
"published_flag": "True",
1073-
"delete_flag": "False",
1072+
"publish_flag": "true",
1073+
"delete_flag": "false",
10741074
}
10751075

10761076
try:

mydata_did/patched_protocols/present_proof/v1_0/models/presentation_exchange.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from aries_cloudagent.messaging.models.base_record import BaseExchangeRecord, BaseExchangeSchema
99
from aries_cloudagent.messaging.valid import UUIDFour
1010

11-
unencrypted_tags = environ.get("EXCH_UNENCRYPTED_TAGS", "False").upper() == "TRUE"
11+
unencrypted_tags = environ.get("EXCH_UNENCRYPTED_TAGS", "false").upper() == "TRUE"
1212

1313

1414
class V10PresentationExchange(BaseExchangeRecord):

mydata_did/patched_protocols/present_proof/v1_0/routes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,8 +1194,8 @@ async def send_presentation_request_for_data_agreement(request: web.BaseRequest)
11941194
# Tag filter
11951195
tag_filter = {
11961196
"data_agreement_id": data_agreement_id,
1197-
"published_flag": "True",
1198-
"delete_flag": "False",
1197+
"publish_flag": "true",
1198+
"delete_flag": "false",
11991199
}
12001200

12011201
try:

mydata_did/v1_0/manager.py

Lines changed: 754 additions & 620 deletions
Large diffs are not rendered by default.

mydata_did/v1_0/models/data_agreement_model.py

Lines changed: 76 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from aries_cloudagent.messaging.models.base import BaseModel, BaseModelSchema
66
from aries_cloudagent.messaging.valid import UUIDFour
7-
from marshmallow import fields, EXCLUDE, validate, validates
7+
from marshmallow import fields, EXCLUDE, validate, validates, pre_load
88
from marshmallow.exceptions import ValidationError
99
from typing import List
1010

@@ -186,6 +186,65 @@ def validate_dpia_date(self, dpia_date):
186186
)
187187

188188

189+
class DataAgreementPersonalDataRestriction(BaseModel):
190+
"""
191+
Personal data restriction model class
192+
"""
193+
194+
class Meta:
195+
# Schema class
196+
schema_class = "DataAgreementPersonalDataRestrictionSchema"
197+
198+
def __init__(
199+
self,
200+
*,
201+
schema_id: str = None,
202+
cred_def_id: str = None,
203+
**kwargs
204+
):
205+
"""
206+
Initialise personal data restriction model.
207+
"""
208+
209+
# Call parent constructor
210+
super().__init__(**kwargs)
211+
212+
# Set attributes
213+
self.schema_id = schema_id
214+
self.cred_def_id = cred_def_id
215+
216+
217+
class DataAgreementPersonalDataRestrictionSchema(BaseModelSchema):
218+
"""
219+
Personal data restriction schema class
220+
"""
221+
222+
class Meta:
223+
# Model class
224+
model_class = DataAgreementPersonalDataRestriction
225+
226+
schema_id = fields.Str(
227+
description="Schema identifier",
228+
example="WgWxqztrNooG92RXvxSTWv:2:schema_name:1.0",
229+
required=False
230+
)
231+
232+
cred_def_id = fields.Str(
233+
description="Credential definition identifier",
234+
example="WgWxqztrNooG92RXvxSTWv:3:CL:20:tag",
235+
required=False
236+
)
237+
238+
@pre_load
239+
def unwrap_envelope(self, data: dict, **kwargs):
240+
241+
if len(data.values()) < 1:
242+
raise ValidationError(
243+
"Personal data restriction must contain at least one attribute.")
244+
245+
return data
246+
247+
189248
class DataAgreementPersonalData(BaseModel):
190249
"""
191250
Personal data model class
@@ -201,6 +260,7 @@ def __init__(self,
201260
attribute_sensitive: bool = None,
202261
attribute_category: str = None,
203262
attribute_description: str = None,
263+
restrictions: List[DataAgreementPersonalDataRestriction] = None,
204264
**kwargs
205265
):
206266
"""
@@ -216,6 +276,7 @@ def __init__(self,
216276
self.attribute_sensitive = attribute_sensitive
217277
self.attribute_category = attribute_category
218278
self.attribute_description = attribute_description
279+
self.restrictions = restrictions
219280

220281

221282
class DataAgreementPersonalDataSchema(BaseModelSchema):
@@ -270,6 +331,11 @@ def validate_attribute_name(self, attribute_name):
270331
example="Name of the customer"
271332
)
272333

334+
restrictions = fields.List(
335+
fields.Nested(DataAgreementPersonalDataRestrictionSchema),
336+
required=False
337+
)
338+
273339

274340
class DataAgreementEvent(BaseModel):
275341
"""
@@ -283,12 +349,12 @@ class Meta:
283349
unknown = EXCLUDE
284350

285351
def __init__(
286-
self,
287-
*,
288-
event_id: str = None,
289-
time_stamp: str = None,
290-
principle_did: str = None,
291-
state: str = None,
352+
self,
353+
*,
354+
event_id: str = None,
355+
time_stamp: str = None,
356+
principle_did: str = None,
357+
state: str = None,
292358
**kwargs
293359
):
294360
# Call parent constructor
@@ -308,7 +374,7 @@ class DataAgreementEventSchema(BaseModelSchema):
308374
class Meta:
309375
# Model class
310376
model_class = DataAgreementEvent
311-
377+
312378
event_id = fields.Str(
313379
data_key="id",
314380
example="did:mydata:z6MkfiSdYhnLnS6jfwSf2yS2CiwwjZGmFUFL5QbyL2Xu8z2E",
@@ -579,7 +645,8 @@ def validate_usage_purpose_description(self, value):
579645
# Data agreement personal data (attributes)
580646
personal_data = fields.List(
581647
fields.Nested(DataAgreementPersonalDataSchema),
582-
required=True
648+
required=True,
649+
validate=validate.Length(min=1)
583650
)
584651

585652
# Data agreement DPIA metadata

mydata_did/v1_0/models/exchange_records/data_agreement_personal_data_record.py

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
from os import environ
2+
import typing
23
from typing import Any
34

45
from marshmallow import fields, validate
56

67
from aries_cloudagent.messaging.models.base_record import BaseExchangeRecord, BaseExchangeSchema
78
from aries_cloudagent.messaging.valid import UUIDFour
89

9-
from ..data_agreement_model import DataAgreementPersonalData, DataAgreementPersonalDataSchema
10+
from ..data_agreement_model import DataAgreementPersonalDataRestriction, DataAgreementPersonalDataRestrictionSchema
1011

1112
class DataAgreementPersonalDataRecord(BaseExchangeRecord):
1213
"""
@@ -20,46 +21,52 @@ class Meta:
2021
RECORD_TYPE = "data_agreement_personal_data_record"
2122

2223
# Wallet record identifier field
23-
RECORD_ID_NAME = "data_agreement_personal_data_record_id"
24+
RECORD_ID_NAME = "personal_data_id"
2425

2526
# Webhook topic name for this record type
2627
WEBHOOK_TOPIC = None
2728

2829
# Wallet record tags used for filtering
2930
# Note: These are not tags for the ledger, but rather tags for the wallet
3031
# to group records.
31-
TAG_NAMES = {"~attribute_category", "~attribute_sensitive"}
32+
TAG_NAMES = {"~attribute_category", "~attribute_sensitive", "~da_template_id"}
3233

3334
def __init__(
3435
self,
3536
*,
36-
data_agreement_personal_data_record_id: str = None,
37+
personal_data_id: str = None,
3738
attribute_name: str = None,
3839
attribute_category: str = "Other",
39-
attribute_sensitive: str = "True",
40+
attribute_sensitive: str = "true",
4041
attribute_description: str = "Nil",
4142
state: str = None,
43+
restrictions: typing.List[dict] = None,
44+
da_template_id: str = None,
45+
da_template_version: int = None,
4246
**kwargs
4347
):
4448
"""
4549
Initialise a new DataAgreementPersonalDataRecord instance.
4650
4751
Args:
48-
data_agreement_personal_data_record_id: The unique identifier for the data agreement personal data record.
52+
personal_data_id: The unique identifier for the data agreement personal data record.
4953
attribute_name: The name of the attribute.
5054
attribute_category: The category of the attribute.
5155
attribute_sensitive: The sensitive flag of the attribute.
5256
state: The state of the data agreement personal data record.
5357
"""
54-
super().__init__(data_agreement_personal_data_record_id, state, **kwargs)
58+
super().__init__(personal_data_id, state, **kwargs)
5559
self.state = state
5660
self.attribute_name = attribute_name
5761
self.attribute_category = attribute_category
5862
self.attribute_sensitive = attribute_sensitive
5963
self.attribute_description = attribute_description
64+
self.restrictions = restrictions
65+
self.da_template_id = da_template_id
66+
self.da_template_version = da_template_version
6067

6168
@property
62-
def data_agreement_personal_data_record_id(self) -> str:
69+
def personal_data_id(self) -> str:
6370
"""
6471
Get the data agreement personal data record identifier.
6572
@@ -78,6 +85,9 @@ def record_value(self) -> dict:
7885
"attribute_category",
7986
"attribute_sensitive",
8087
"attribute_description",
88+
"restrictions",
89+
"da_template_id",
90+
"da_template_version"
8191
)
8292
}
8393

@@ -95,7 +105,7 @@ class Meta:
95105
model_class = DataAgreementPersonalDataRecord
96106

97107

98-
data_agreement_personal_data_record_id = fields.Str(
108+
personal_data_id = fields.Str(
99109
required=True,
100110
example=UUIDFour.EXAMPLE
101111
)
@@ -122,7 +132,20 @@ class Meta:
122132
attribute_sensitive = fields.Str(
123133
required=True,
124134
description="The sensitive flag of the attribute.",
125-
example="True"
135+
example="true"
136+
)
137+
138+
restrictions = fields.List(fields.Nested(DataAgreementPersonalDataRestrictionSchema), required=False)
139+
140+
da_template_id = fields.Str(
141+
required=True,
142+
description="The data agreement template identifier.",
143+
example=UUIDFour.EXAMPLE
144+
)
145+
146+
da_template_version = fields.Int(
147+
example=1,
148+
description="Data agreement template version"
126149
)
127150

128151

0 commit comments

Comments
 (0)