Skip to content

Commit a61a95e

Browse files
committed
refactor: rename some components for clarity
Signed-off-by: Daniel Bluhm <[email protected]>
1 parent 648a69e commit a61a95e

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

didcomm_messaging/didcomm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from pydid import DIDUrl, VerificationMethod
88
from didcomm_messaging.crypto import P, S, CryptoService, SecretsManager
99
from didcomm_messaging.jwe import JweEnvelope, from_b64url
10-
from didcomm_messaging.resolver import Resolver
10+
from didcomm_messaging.resolver import DIDResolver
1111

1212

1313
@dataclass
@@ -24,12 +24,12 @@ class DIDCommMessagingError(Exception):
2424
"""Represents an error from the DIDComm Messaging interface."""
2525

2626

27-
class DIDCommMessaging(Generic[P, S]):
27+
class PackagingService(Generic[P, S]):
2828
"""DIDComm Messaging interface."""
2929

3030
def __init__(
3131
self,
32-
resolver: Resolver,
32+
resolver: DIDResolver,
3333
crypto: CryptoService[P, S],
3434
secrets: SecretsManager[S],
3535
):

didcomm_messaging/resolver/__init__.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@
55
from pydid import DIDDocument, DIDUrl, Resource, VerificationMethod
66

77

8-
class ResolutionError(Exception):
8+
class DIDResolutionError(Exception):
99
"""Represents an error from a DID Resolver."""
1010

1111

12-
class DIDNotFound(ResolutionError):
12+
class DIDNotFound(DIDResolutionError):
1313
"""Represents a DID not found error."""
1414

1515

16-
class DIDMethodNotSupported(ResolutionError):
16+
class DIDMethodNotSupported(DIDResolutionError):
1717
"""Represents a DID method not supported error."""
1818

1919

20-
class Resolver(ABC):
20+
class DIDResolver(ABC):
2121
"""DID Resolver interface."""
2222

2323
@abstractmethod
@@ -33,7 +33,7 @@ async def resolve_and_dereference(self, did_url: str) -> Resource:
3333
"""Resolve a DID URL and dereference the identifier."""
3434
url = DIDUrl.parse(did_url)
3535
if not url.did:
36-
raise ResolutionError("Invalid DID URL; must be absolute")
36+
raise DIDResolutionError("Invalid DID URL; must be absolute")
3737

3838
doc = await self.resolve_and_parse(url.did)
3939
return doc.dereference(url)
@@ -44,15 +44,15 @@ async def resolve_and_dereference_verification_method(
4444
"""Resolve a DID URL and dereference the identifier."""
4545
resource = await self.resolve_and_dereference(did_url)
4646
if not isinstance(resource, VerificationMethod):
47-
raise ResolutionError("Resource is not a verification method")
47+
raise DIDResolutionError("Resource is not a verification method")
4848

4949
return resource
5050

5151

52-
class PrefixResolver(Resolver):
52+
class PrefixResolver(DIDResolver):
5353
"""DID Resolver delegates to sub-resolvers by DID prefix."""
5454

55-
def __init__(self, resolvers: Dict[str, Resolver]):
55+
def __init__(self, resolvers: Dict[str, DIDResolver]):
5656
"""Initialize the resolver."""
5757
self.resolvers = resolvers
5858

didcomm_messaging/resolver/peer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""did:peer resolver."""
22

3-
from didcomm_messaging.resolver import Resolver
3+
from didcomm_messaging.resolver import DIDResolver
44

55
try:
66
from did_peer_2 import resolve as resolve_peer_2
@@ -12,15 +12,15 @@
1212
)
1313

1414

15-
class Peer2(Resolver):
15+
class Peer2(DIDResolver):
1616
"""did:peer:2 resolver."""
1717

1818
async def resolve(self, did: str) -> dict:
1919
"""Resolve a did:peer:2 DID."""
2020
return resolve_peer_2(did)
2121

2222

23-
class Peer4(Resolver):
23+
class Peer4(DIDResolver):
2424
"""did:peer:4 resolver."""
2525

2626
async def resolve(self, did: str) -> dict:

example.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from aries_askar import Key, KeyAlg
44
from didcomm_messaging.crypto.askar import AskarCryptoService, AskarSecretKey
55
from didcomm_messaging.crypto.basic import InMemorySecretsManager
6-
from didcomm_messaging.didcomm import DIDCommMessaging
6+
from didcomm_messaging.didcomm import PackagingService
77
from didcomm_messaging.multiformats import multibase
88
from didcomm_messaging.multiformats import multicodec
99
from didcomm_messaging.resolver.peer import Peer2, Peer4
@@ -15,7 +15,7 @@ async def main():
1515
"""An example of using DIDComm Messaging."""
1616
secrets = InMemorySecretsManager()
1717
crypto = AskarCryptoService()
18-
didcomm = DIDCommMessaging(
18+
packer = PackagingService(
1919
PrefixResolver({"did:peer:2": Peer2(), "did:peer:4": Peer4()}), crypto, secrets
2020
)
2121
verkey = Key.generate(KeyAlg.ED25519)
@@ -39,9 +39,9 @@ async def main():
3939
await secrets.add_secret(AskarSecretKey(verkey, f"{did}#key-1"))
4040
await secrets.add_secret(AskarSecretKey(xkey, f"{did}#key-2"))
4141
print(did)
42-
packed = await didcomm.pack(b"hello world", [did], did)
42+
packed = await packer.pack(b"hello world", [did], did)
4343
print(json.dumps(json.loads(packed), indent=2))
44-
unpacked = await didcomm.unpack(packed)
44+
unpacked = await packer.unpack(packed)
4545
print(unpacked)
4646

4747

0 commit comments

Comments
 (0)