Skip to content

Commit 40e0955

Browse files
committed
Unrevocation notification.
1 parent 00e53d9 commit 40e0955

26 files changed

Lines changed: 78 additions & 864 deletions

aries_cloudagent/protocols/revocation_notification/definition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{
1111
"major_version": 2,
1212
"minimum_minor_version": 0,
13-
"current_minor_version": 0,
13+
"current_minor_version": 1,
1414
"path": "v2_0",
1515
},
1616
]

aries_cloudagent/protocols/revocation_notification/v1_0/models/rev_notification_record.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ def revocation_notification_id(self) -> Optional[str]:
7070
def record_value(self) -> dict:
7171
"""Return record value."""
7272
return {
73-
prop: getattr(self, prop) for prop in ("thread_id", "comment", "unrevoke")
73+
prop: getattr(self, prop)
74+
for prop in ("thread_id", "comment", "revocation_format", "unrevoke")
7475
}
7576

7677
@classmethod

aries_cloudagent/protocols/revocation_notification/v2_0/handlers/revoke_handler.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
"""Handler for revoke message."""
22

3+
from aries_cloudagent.protocols.didcomm_prefix import DIDCommPrefix
4+
35
from .....messaging.base_handler import BaseHandler
46
from .....messaging.request_context import RequestContext
57
from .....messaging.responder import BaseResponder
6-
78
from ..messages.revoke import Revoke
9+
from ..messages.unrevoke import Unrevoke
810

911

1012
class RevokeHandler(BaseHandler):
@@ -15,18 +17,22 @@ class RevokeHandler(BaseHandler):
1517

1618
async def handle(self, context: RequestContext, responder: BaseResponder):
1719
"""Handle revoke message."""
18-
assert isinstance(context.message, Revoke)
20+
assert isinstance(context.message, (Revoke, Unrevoke))
1921
self._logger.debug(
2022
"Received notification of revocation for %s cred %s with comment: %s",
2123
context.message.revocation_format,
2224
context.message.credential_id,
2325
context.message.comment,
2426
)
27+
28+
message_type = DIDCommPrefix.NEW.qualify(context.message.Meta.message_type)
29+
2530
# Emit a webhook
2631
if context.settings.get("revocation.monitor_notification"):
2732
await context.profile.notify(
2833
self.WEBHOOK_TOPIC,
2934
{
35+
"@type": message_type,
3036
"revocation_format": context.message.revocation_format,
3137
"credential_id": context.message.credential_id,
3238
"comment": context.message.comment,
@@ -37,6 +43,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder):
3743
await context.profile.notify(
3844
self.RECEIVED_TOPIC,
3945
{
46+
"@type": message_type,
4047
"revocation_format": context.message.revocation_format,
4148
"credential_id": context.message.credential_id,
4249
"comment": context.message.comment,
Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
"""Message type identifiers for Revocation Notification protocol."""
22

3+
from ....messaging.util import get_proto_default_version
34
from ...didcomm_prefix import DIDCommPrefix
4-
5+
from ..definition import versions
56

67
SPEC_URI = (
78
"https://github.com/hyperledger/aries-rfcs/blob/main/features/"
89
"0721-revocation-notification-v2/README.md"
910
)
11+
12+
CURRENT_VERSION = get_proto_default_version(versions, 2)
13+
REV_NOTIF_2_0 = "revocation_notification/2.0"
1014
PROTOCOL = "revocation_notification"
11-
VERSION = "2.0"
12-
BASE = f"{PROTOCOL}/{VERSION}"
15+
BASE = f"{PROTOCOL}/{CURRENT_VERSION}"
1316

1417
# Message types
1518
REVOKE = f"{BASE}/revoke"
19+
UNREVOKE = f"{BASE}/unrevoke"
1620

1721
PROTOCOL_PACKAGE = "aries_cloudagent.protocols.revocation_notification.v2_0"
1822
MESSAGE_TYPES = DIDCommPrefix.qualify_all(
19-
{REVOKE: f"{PROTOCOL_PACKAGE}.messages.revoke.Revoke"}
23+
{
24+
REVOKE: f"{PROTOCOL_PACKAGE}.messages.revoke.Revoke",
25+
UNREVOKE: f"{PROTOCOL_PACKAGE}.messages.unrevoke.Unrevoke",
26+
}
2027
)

aries_cloudagent/protocols/revocation_notification/v2_0/messages/revoke.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Meta:
4949

5050
revocation_format = fields.Str(
5151
required=True,
52-
validate=validate.OneOf(["indy-anoncreds"]),
52+
validate=validate.OneOf(["indy-anoncreds", "anoncreds"]),
5353
metadata={
5454
"description": "The format of the credential revocation ID",
5555
"example": "indy-anoncreds",

aries_cloudagent/protocols/revocation_notification/v2_0/models/rev_notification_record.py

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
from marshmallow import fields
66
from marshmallow.utils import EXCLUDE
77

8+
from aries_cloudagent.protocols.revocation_notification.v2_0.messages.unrevoke import (
9+
Unrevoke,
10+
)
11+
812
from .....core.profile import ProfileSession
913
from .....messaging.models.base_record import BaseRecord, BaseRecordSchema
1014
from .....messaging.valid import (
@@ -46,6 +50,7 @@ def __init__(
4650
thread_id: str = None,
4751
comment: str = None,
4852
version: str = None,
53+
unrevoke: bool = None,
4954
revocation_format: str = "indy-anoncreds",
5055
**kwargs,
5156
):
@@ -57,6 +62,7 @@ def __init__(
5762
self.thread_id = thread_id
5863
self.comment = comment
5964
self.version = version
65+
self.unrevoke = unrevoke
6066
self.revocation_format = revocation_format
6167

6268
@property
@@ -67,7 +73,10 @@ def revocation_notification_id(self) -> Optional[str]:
6773
@property
6874
def record_value(self) -> dict:
6975
"""Return record value."""
70-
return {prop: getattr(self, prop) for prop in ("thread_id", "comment")}
76+
return {
77+
prop: getattr(self, prop)
78+
for prop in ("thread_id", "comment", "revocation_format", "unrevoke")
79+
}
7180

7281
@classmethod
7382
async def query_by_ids(
@@ -84,7 +93,12 @@ async def query_by_ids(
8493
rev_reg_id: the rev reg id by which to filter
8594
"""
8695
tag_filter = {
87-
**{"version": "v2_0"},
96+
**{
97+
"$or": [
98+
{"version": "v2_0"},
99+
{"version": "v2_1"},
100+
]
101+
},
88102
**{"cred_rev_id": cred_rev_id for _ in [""] if cred_rev_id},
89103
**{"rev_reg_id": rev_reg_id for _ in [""] if rev_reg_id},
90104
}
@@ -113,7 +127,12 @@ async def query_by_rev_reg_id(
113127
rev_reg_id: the rev reg id by which to filter
114128
"""
115129
tag_filter = {
116-
**{"version": "v2_0"},
130+
**{
131+
"$or": [
132+
{"version": "v2_0"},
133+
{"version": "v2_1"},
134+
]
135+
},
117136
**{"rev_reg_id": rev_reg_id for _ in [""] if rev_reg_id},
118137
}
119138

@@ -126,11 +145,19 @@ def to_message(self):
126145
"No thread ID set on revocation notification record, "
127146
"cannot create message"
128147
)
129-
return Revoke(
130-
revocation_format=self.revocation_format,
131-
credential_id=f"{self.rev_reg_id}::{self.cred_rev_id}",
132-
comment=self.comment,
133-
)
148+
149+
if self.unrevoke and self.version == "v2_1":
150+
return Unrevoke(
151+
revocation_format=self.revocation_format,
152+
credential_id=f"{self.rev_reg_id}::{self.cred_rev_id}",
153+
comment=self.comment,
154+
)
155+
else:
156+
return Revoke(
157+
revocation_format=self.revocation_format,
158+
credential_id=f"{self.rev_reg_id}::{self.cred_rev_id}",
159+
comment=self.comment,
160+
)
134161

135162

136163
class RevNotificationRecordSchema(BaseRecordSchema):
@@ -188,3 +215,7 @@ class Meta:
188215
required=False,
189216
metadata={"description": "Version of Revocation Notification to send out"},
190217
)
218+
unrevoke = fields.Bool(
219+
required=False,
220+
metadata={"description": "If it is Unrevoked"},
221+
)

aries_cloudagent/protocols/revocation_notification/v2_1/__init__.py

Whitespace-only changes.

aries_cloudagent/protocols/revocation_notification/v2_1/handlers/__init__.py

Whitespace-only changes.

aries_cloudagent/protocols/revocation_notification/v2_1/handlers/revoke_handler.py

Lines changed: 0 additions & 51 deletions
This file was deleted.

aries_cloudagent/protocols/revocation_notification/v2_1/handlers/tests/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)