Skip to content

Commit 4806fab

Browse files
committed
feat: (WIP) add DCV2 protocol registry
Signed-off-by: Micah Peltier <[email protected]>
1 parent d7511ce commit 4806fab

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""Registry for DIDComm V2 Protocols."""
2+
3+
from typing import Coroutine, Dict, Sequence
4+
5+
6+
class V2ProtocolRegistry:
7+
"""DIDComm V2 Protocols."""
8+
9+
def __init__(self):
10+
"""Initialize a V2ProtocolRegistry instance."""
11+
self._type_to_message_handler: Dict[str, Coroutine] = {}
12+
13+
@property
14+
def protocols(self) -> Sequence[str]:
15+
"""Accessor for a list of all message protocols."""
16+
return [str(key) for key in self._type_to_message_handler.keys()]
17+
18+
def protocols_matching_query(self, query: str) -> Sequence[str]:
19+
"""Return a list of message protocols matching a query string."""
20+
all_types = self.protocols
21+
result = None
22+
23+
if query == "*" or query is None:
24+
result = all_types
25+
elif query:
26+
if query.endswith("*"):
27+
match = query[:-1]
28+
result = tuple(k for k in all_types if k.startswith(match))
29+
elif query in all_types:
30+
result = (query,)
31+
return result or ()
32+
33+
def register_handler(self, message_type: str, handler: Coroutine):
34+
"""Register a new message type to handler association."""
35+
self._type_to_message_handler[message_type] = handler
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
"""Handler for the trust ping protocol."""
2+
3+
from acapy_agent.transport.inbound.message import InboundMessage
4+
5+
6+
async def handle_trust_ping(message: InboundMessage):
7+
"""."""
8+
return False

0 commit comments

Comments
 (0)