1- """Legacy messaging service."""
1+ """V1 messaging service."""
22
33from dataclasses import dataclass
44import json
1010from pydid .service import DIDCommV1Service
1111
1212from didcomm_messaging .crypto import P , S , SecretsManager
13- from didcomm_messaging .legacy .base import LegacyCryptoService
14- from didcomm_messaging .legacy .packaging import LegacyPackagingService
13+ from didcomm_messaging .legacy .base import V1CryptoService
14+ from didcomm_messaging .legacy .packaging import V1PackagingService
1515from didcomm_messaging .resolver import DIDResolver
1616
1717
18- class LegacyDIDCommMessagingError (Exception ):
18+ class V1DIDCommMessagingError (Exception ):
1919 """Raised on error in legacy didcomm messaging."""
2020
2121
2222@dataclass
23- class LegacyPackResult :
23+ class V1PackResult :
2424 """Result of packing a message."""
2525
2626 message : bytes
2727 target_service : str
2828
2929
3030@dataclass
31- class LegacyUnpackResult :
31+ class V1UnpackResult :
3232 """Result of unpacking a message."""
3333
3434 unpacked : bytes
@@ -55,11 +55,11 @@ class Target:
5555 endpoint : str
5656
5757
58- class LegacyDIDCommMessagingService (Generic [P , S ]):
58+ class V1DIDCommMessagingService (Generic [P , S ]):
5959 """Main entrypoint for DIDComm Messaging."""
6060
6161 async def did_to_target (
62- self , crypto : LegacyCryptoService [P , S ], resolver : DIDResolver , did : str
62+ self , crypto : V1CryptoService [P , S ], resolver : DIDResolver , did : str
6363 ) -> Target :
6464 """Resolve recipient information from a DID."""
6565 doc = await resolver .resolve_and_parse (did )
@@ -69,7 +69,7 @@ async def did_to_target(
6969 if isinstance (service , DIDCommV1Service )
7070 ]
7171 if not services :
72- raise LegacyDIDCommMessagingError (f"Unable to send message to DID { did } " )
72+ raise V1DIDCommMessagingError (f"Unable to send message to DID { did } " )
7373 target = services [0 ]
7474
7575 recipient_keys = [
@@ -92,14 +92,14 @@ async def did_to_target(
9292 if isinstance (endpoint , AnyUrl ):
9393 endpoint = str (endpoint )
9494 if not endpoint .startswith ("http" ) and not endpoint .startswith ("ws" ):
95- raise LegacyDIDCommMessagingError (
95+ raise V1DIDCommMessagingError (
9696 f"Unable to send message to endpoint { endpoint } "
9797 )
9898
9999 return Target (recipient_keys , routing_keys , endpoint )
100100
101101 async def from_did_to_kid (
102- self , crypto : LegacyCryptoService [P , S ], resolver : DIDResolver , did : str
102+ self , crypto : V1CryptoService [P , S ], resolver : DIDResolver , did : str
103103 ) -> str :
104104 """Resolve our DID to a kid to be used by crypto layers."""
105105 doc = await resolver .resolve_and_parse (did )
@@ -109,7 +109,7 @@ async def from_did_to_kid(
109109 if isinstance (service , DIDCommV1Service )
110110 ]
111111 if not services :
112- raise LegacyDIDCommMessagingError (f"Unable to send message to DID { did } " )
112+ raise V1DIDCommMessagingError (f"Unable to send message to DID { did } " )
113113 target = services [0 ]
114114
115115 recipient_keys = [
@@ -133,10 +133,10 @@ def forward_wrap(self, to: str, msg: str) -> bytes:
133133
134134 async def pack (
135135 self ,
136- crypto : LegacyCryptoService [P , S ],
136+ crypto : V1CryptoService [P , S ],
137137 resolver : DIDResolver ,
138138 secrets : SecretsManager [S ],
139- packaging : LegacyPackagingService [P , S ],
139+ packaging : V1PackagingService [P , S ],
140140 message : Union [dict , str , bytes ],
141141 to : Union [str , Target ],
142142 frm : Optional [str ] = None ,
@@ -197,19 +197,19 @@ async def pack(
197197 )
198198 forward_to = routing_key
199199
200- return LegacyPackResult (encoded_message .to_json ().encode (), target .endpoint )
200+ return V1PackResult (encoded_message .to_json ().encode (), target .endpoint )
201201
202202 async def unpack (
203203 self ,
204- crypto : LegacyCryptoService [P , S ],
204+ crypto : V1CryptoService [P , S ],
205205 secrets : SecretsManager [S ],
206- packaging : LegacyPackagingService [P , S ],
206+ packaging : V1PackagingService [P , S ],
207207 encoded_message : bytes ,
208208 ** options ,
209- ) -> LegacyUnpackResult :
209+ ) -> V1UnpackResult :
210210 """Unpack a message."""
211211 unpacked , recip , sender = await packaging .unpack (crypto , secrets , encoded_message )
212- return LegacyUnpackResult (
212+ return V1UnpackResult (
213213 unpacked ,
214214 encrytped = bool (recip ),
215215 authenticated = bool (sender ),
@@ -218,30 +218,30 @@ async def unpack(
218218 )
219219
220220
221- class LegacyDIDCommMessaging (Generic [P , S ]):
221+ class V1DIDCommMessaging (Generic [P , S ]):
222222 """Main entrypoint for DIDComm Messaging."""
223223
224224 def __init__ (
225225 self ,
226- crypto : LegacyCryptoService [P , S ],
226+ crypto : V1CryptoService [P , S ],
227227 secrets : SecretsManager [S ],
228228 resolver : DIDResolver ,
229- packaging : LegacyPackagingService [P , S ],
229+ packaging : V1PackagingService [P , S ],
230230 ):
231231 """Initialize the DIDComm Messaging service."""
232232 self .crypto = crypto
233233 self .secrets = secrets
234234 self .resolver = resolver
235235 self .packaging = packaging
236- self .dmp = LegacyDIDCommMessagingService ()
236+ self .dmp = V1DIDCommMessagingService ()
237237
238238 async def pack (
239239 self ,
240240 message : Union [dict , str , bytes ],
241241 to : Union [str , Target ],
242242 frm : Optional [str ] = None ,
243243 ** options ,
244- ) -> LegacyPackResult :
244+ ) -> V1PackResult :
245245 """Pack a message.
246246
247247 Args:
@@ -252,7 +252,7 @@ async def pack(
252252 options: arbitrary values to pass to the packaging service
253253
254254 Returns:
255- LegacyPackResult with packed message and target services
255+ V1PackResult with packed message and target services
256256 """
257257 return await self .dmp .pack (
258258 self .crypto ,
@@ -269,7 +269,7 @@ async def unpack(
269269 self ,
270270 encoded_message : bytes ,
271271 ** options ,
272- ) -> LegacyUnpackResult :
272+ ) -> V1UnpackResult :
273273 """Unpack a message."""
274274 return await self .dmp .unpack (
275275 self .crypto ,
0 commit comments