From 4ed41c3e01ab9b3bbdd4fe77df72be623d9b0615 Mon Sep 17 00:00:00 2001 From: Char Howland Date: Wed, 8 Mar 2023 14:27:52 -0700 Subject: [PATCH 1/7] feat: add plugin structure Signed-off-by: Char Howland --- .../anoncreds/anoncreds/__init__.py | 30 +++++++ .../anoncreds/anoncreds/anoncreds_objects.py | 80 +++++++++++++++++++ .../anoncreds/anoncreds/anoncreds_registry.py | 19 +++++ .../anoncreds/anoncreds/base_registry.py | 57 +++++++++++++ .../anoncreds/did_indy_registry/__init__.py | 0 .../anoncreds/did_indy_registry/definition.py | 10 +++ .../did_indy_registry/v1_0/__init__.py | 0 .../v1_0/did_indy_registry.py | 47 +++++++++++ .../did_indy_registry/v1_0/routes.py | 0 .../anoncreds/did_web_registry/__init__.py | 0 .../anoncreds/did_web_registry/definition.py | 10 +++ .../did_web_registry/v1_0/__init__.py | 0 .../did_web_registry/v1_0/did_web_registry.py | 47 +++++++++++ .../anoncreds/did_web_registry/v1_0/routes.py | 0 aries_cloudagent/config/default_context.py | 9 +++ 15 files changed, 309 insertions(+) create mode 100644 aries_cloudagent/anoncreds/anoncreds/anoncreds_objects.py create mode 100644 aries_cloudagent/anoncreds/anoncreds/anoncreds_registry.py create mode 100644 aries_cloudagent/anoncreds/anoncreds/base_registry.py create mode 100644 aries_cloudagent/anoncreds/did_indy_registry/__init__.py create mode 100644 aries_cloudagent/anoncreds/did_indy_registry/definition.py create mode 100644 aries_cloudagent/anoncreds/did_indy_registry/v1_0/__init__.py create mode 100644 aries_cloudagent/anoncreds/did_indy_registry/v1_0/did_indy_registry.py create mode 100644 aries_cloudagent/anoncreds/did_indy_registry/v1_0/routes.py create mode 100644 aries_cloudagent/anoncreds/did_web_registry/__init__.py create mode 100644 aries_cloudagent/anoncreds/did_web_registry/definition.py create mode 100644 aries_cloudagent/anoncreds/did_web_registry/v1_0/__init__.py create mode 100644 aries_cloudagent/anoncreds/did_web_registry/v1_0/did_web_registry.py create mode 100644 aries_cloudagent/anoncreds/did_web_registry/v1_0/routes.py diff --git a/aries_cloudagent/anoncreds/anoncreds/__init__.py b/aries_cloudagent/anoncreds/anoncreds/__init__.py index e69de29bb2..3992d2d9e4 100644 --- a/aries_cloudagent/anoncreds/anoncreds/__init__.py +++ b/aries_cloudagent/anoncreds/anoncreds/__init__.py @@ -0,0 +1,30 @@ +import logging + +from ...config.injection_context import InjectionContext +from ...config.provider import ClassProvider + +from ..anoncreds.anoncreds_registry import AnonCredsRegistry + +LOGGER = logging.getLogger(__name__) + + +async def setup(context: InjectionContext): + """Set up default resolvers.""" + registry = context.inject_or(AnonCredsRegistry) + if not registry: + LOGGER.warning("No DID Resolver instance found in context") + return + + indy_registry = ClassProvider( + "aries_cloudagent.anoncreds.did_indy_registry.v1_0.did_indy_registry.DIDIndyRegistry" + ).provide(context.settings, context.injector) + await indy_registry.setup(context) + registry.register_registry(indy_registry) + + web_registry = ClassProvider( + "aries_cloudagent.anoncreds.did_web_registry.v1_0.did_web_registry.DIDWebRegistry" + ).provide(context.settings, context.injector) + await web_registry.setup(context) + registry.register_registry(web_registry) + + # TODO: add context.settings diff --git a/aries_cloudagent/anoncreds/anoncreds/anoncreds_objects.py b/aries_cloudagent/anoncreds/anoncreds/anoncreds_objects.py new file mode 100644 index 0000000000..c074c621d1 --- /dev/null +++ b/aries_cloudagent/anoncreds/anoncreds/anoncreds_objects.py @@ -0,0 +1,80 @@ +from typing import Any, Dict, List, Optional +from typing_extensions import Literal +from dataclasses import dataclass + + +@dataclass +class AnonCredsSchema: + issuerId: str + attrNames: List[str] + name: str + version: str + + +@dataclass +class AnonCredsRegistryGetSchema: + schema: AnonCredsSchema + schema_id: str + resolution_metadata: Dict[str, Any] + schema_metadata: Dict[str, Any] + + +# TODO: determine types for `primary` and `revocation` +@dataclass +class AnonCredsCredentialDefinitionValue: + primary: Any + revocation: Optional[Any] + + +@dataclass +class AnonCredsCredentialDefinition: + issuerId: str + schemaId: str + type: Literal["CL"] + tag: str + value: AnonCredsCredentialDefinitionValue + + +@dataclass +class AnonCredsRegistryGetCredentialDefinition: + credential_definition: AnonCredsCredentialDefinition + credential_definition_id: str + resolution_metadata: Dict[str, Any] + credential_definition_metadata: Dict[str, Any] + + +@dataclass +class AnonCredsRevocationRegistryDefinition: + issuerId: str + type: Literal["CL_ACCUM"] + credDefId: str + tag: str + # TODO: determine type for `publicKeys` + publicKeys: Any + maxCredNum: int + tailsLocation: str + tailsHash: str + + +@dataclass +class AnonCredsRegistryGetRevocationRegistryDefinition: + revocation_registry: AnonCredsRevocationRegistryDefinition + revocation_registry_id: str + resolution_metadata: Dict[str, Any] + revocation_registry_metadata: Dict[str, Any] + + +@dataclass +class AnonCredsRevocationList: + issuerId: str + revRegId: str + revocationList: List[int] + currentAccumulator: str + timestamp: int + + +@dataclass +class AnonCredsRegistryGetRevocationList: + revocation_list: AnonCredsRevocationList + resolution_metadata: Dict[str, Any] + revocation_registry_metadata: Dict[str, Any] diff --git a/aries_cloudagent/anoncreds/anoncreds/anoncreds_registry.py b/aries_cloudagent/anoncreds/anoncreds/anoncreds_registry.py new file mode 100644 index 0000000000..4430f05a7c --- /dev/null +++ b/aries_cloudagent/anoncreds/anoncreds/anoncreds_registry.py @@ -0,0 +1,19 @@ +import logging +from typing import List + +from .base_registry import BaseRegistry + +LOGGER = logging.getLogger(__name__) + + +class AnonCredsRegistry: + def __init__(self, registries: List[BaseRegistry] = None): + """Create DID Resolver.""" + self.registries = registries or [] + # TODO: add schema and cred def registries + + def register_registry(self, registry: BaseRegistry): + """Register a new registry.""" + self.registries.append(registry) + + # TODO: add logic for picking the correct registry diff --git a/aries_cloudagent/anoncreds/anoncreds/base_registry.py b/aries_cloudagent/anoncreds/anoncreds/base_registry.py new file mode 100644 index 0000000000..9b8177da7d --- /dev/null +++ b/aries_cloudagent/anoncreds/anoncreds/base_registry.py @@ -0,0 +1,57 @@ +from abc import abstractmethod +from ...config.injection_context import InjectionContext + +from .anoncreds_objects import ( + AnonCredsRegistryGetCredentialDefinition, + AnonCredsRegistryGetRevocationList, + AnonCredsRegistryGetRevocationRegistryDefinition, + AnonCredsRegistryGetSchema, +) + + +class BaseRegistry: + @abstractmethod + async def setup(self, context: InjectionContext): + """Setup method""" + + @abstractmethod + async def get_schema(self, schema_id: str) -> AnonCredsRegistryGetSchema: + """Get a schema from the registry.""" + + # TODO: determine keyword arguments + @abstractmethod + async def register_schema(self): + """Register a schema on the registry.""" + + @abstractmethod + async def get_credential_definition( + self, credential_definition_id: str + ) -> AnonCredsRegistryGetCredentialDefinition: + """Get a credential definition from the registry.""" + + # TODO: determine keyword arguments + @abstractmethod + async def register_credential_definition(self): + """Register a credential definition on the registry.""" + + @abstractmethod + async def get_revocation_registry_definition( + self, revocation_registry_id: str + ) -> AnonCredsRegistryGetRevocationRegistryDefinition: + """Get a revocation registry definition from the registry.""" + + # TODO: determine keyword arguments + @abstractmethod + async def register_revocation_registry_definition(self): + """Register a revocation registry definition on the registry.""" + + @abstractmethod + async def get_revocation_list( + self, revocation_registry_id: str, timestamp: str + ) -> AnonCredsRegistryGetRevocationList: + """Get a revocation list from the registry.""" + + # TODO: determine keyword arguments + @abstractmethod + async def register_revocation_list(self): + """Register a revocation list on the registry.""" diff --git a/aries_cloudagent/anoncreds/did_indy_registry/__init__.py b/aries_cloudagent/anoncreds/did_indy_registry/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/aries_cloudagent/anoncreds/did_indy_registry/definition.py b/aries_cloudagent/anoncreds/did_indy_registry/definition.py new file mode 100644 index 0000000000..62bddef6f5 --- /dev/null +++ b/aries_cloudagent/anoncreds/did_indy_registry/definition.py @@ -0,0 +1,10 @@ +"""Version definitions for this protocol.""" + +versions = [ + { + "major_version": 1, + "minimum_minor_version": 0, + "current_minor_version": 0, + "path": "v1_0", + } +] diff --git a/aries_cloudagent/anoncreds/did_indy_registry/v1_0/__init__.py b/aries_cloudagent/anoncreds/did_indy_registry/v1_0/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/aries_cloudagent/anoncreds/did_indy_registry/v1_0/did_indy_registry.py b/aries_cloudagent/anoncreds/did_indy_registry/v1_0/did_indy_registry.py new file mode 100644 index 0000000000..7c042e8a75 --- /dev/null +++ b/aries_cloudagent/anoncreds/did_indy_registry/v1_0/did_indy_registry.py @@ -0,0 +1,47 @@ +from ...anoncreds.anoncreds_objects import ( + AnonCredsRegistryGetCredentialDefinition, + AnonCredsRegistryGetRevocationList, + AnonCredsRegistryGetRevocationRegistryDefinition, + AnonCredsRegistryGetSchema, +) +from ....config.injection_context import InjectionContext +from ....anoncreds.anoncreds.anoncreds_registry import BaseRegistry + + +class DIDIndyRegistry(BaseRegistry): + async def setup(self, context: InjectionContext): + print("Successfully registered DIDIndyRegistry") + + async def get_schema(self, schema_id: str) -> AnonCredsRegistryGetSchema: + """Get a schema from the registry.""" + + # TODO: determine keyword arguments + async def register_schema(self): + """Register a schema on the registry.""" + + async def get_credential_definition( + self, credential_definition_id: str + ) -> AnonCredsRegistryGetCredentialDefinition: + """Get a credential definition from the registry.""" + + # TODO: determine keyword arguments + async def register_credential_definition(self): + """Register a credential definition on the registry.""" + + async def get_revocation_registry_definition( + self, revocation_registry_id: str + ) -> AnonCredsRegistryGetRevocationRegistryDefinition: + """Get a revocation registry definition from the registry.""" + + # TODO: determine keyword arguments + async def register_revocation_registry_definition(self): + """Register a revocation registry definition on the registry.""" + + async def get_revocation_list( + self, revocation_registry_id: str, timestamp: str + ) -> AnonCredsRegistryGetRevocationList: + """Get a revocation list from the registry.""" + + # TODO: determine keyword arguments + async def register_revocation_list(self): + """Register a revocation list on the registry.""" diff --git a/aries_cloudagent/anoncreds/did_indy_registry/v1_0/routes.py b/aries_cloudagent/anoncreds/did_indy_registry/v1_0/routes.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/aries_cloudagent/anoncreds/did_web_registry/__init__.py b/aries_cloudagent/anoncreds/did_web_registry/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/aries_cloudagent/anoncreds/did_web_registry/definition.py b/aries_cloudagent/anoncreds/did_web_registry/definition.py new file mode 100644 index 0000000000..62bddef6f5 --- /dev/null +++ b/aries_cloudagent/anoncreds/did_web_registry/definition.py @@ -0,0 +1,10 @@ +"""Version definitions for this protocol.""" + +versions = [ + { + "major_version": 1, + "minimum_minor_version": 0, + "current_minor_version": 0, + "path": "v1_0", + } +] diff --git a/aries_cloudagent/anoncreds/did_web_registry/v1_0/__init__.py b/aries_cloudagent/anoncreds/did_web_registry/v1_0/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/aries_cloudagent/anoncreds/did_web_registry/v1_0/did_web_registry.py b/aries_cloudagent/anoncreds/did_web_registry/v1_0/did_web_registry.py new file mode 100644 index 0000000000..4585625a60 --- /dev/null +++ b/aries_cloudagent/anoncreds/did_web_registry/v1_0/did_web_registry.py @@ -0,0 +1,47 @@ +from ...anoncreds.anoncreds_objects import ( + AnonCredsRegistryGetCredentialDefinition, + AnonCredsRegistryGetRevocationList, + AnonCredsRegistryGetRevocationRegistryDefinition, + AnonCredsRegistryGetSchema, +) +from ....config.injection_context import InjectionContext +from ....anoncreds.anoncreds.anoncreds_registry import BaseRegistry + + +class DIDWebRegistry(BaseRegistry): + async def setup(self, context: InjectionContext): + print("Successfully registered DIDWebRegistry") + + async def get_schema(self, schema_id: str) -> AnonCredsRegistryGetSchema: + """Get a schema from the registry.""" + + # TODO: determine keyword arguments + async def register_schema(self): + """Register a schema on the registry.""" + + async def get_credential_definition( + self, credential_definition_id: str + ) -> AnonCredsRegistryGetCredentialDefinition: + """Get a credential definition from the registry.""" + + # TODO: determine keyword arguments + async def register_credential_definition(self): + """Register a credential definition on the registry.""" + + async def get_revocation_registry_definition( + self, revocation_registry_id: str + ) -> AnonCredsRegistryGetRevocationRegistryDefinition: + """Get a revocation registry definition from the registry.""" + + # TODO: determine keyword arguments + async def register_revocation_registry_definition(self): + """Register a revocation registry definition on the registry.""" + + async def get_revocation_list( + self, revocation_registry_id: str, timestamp: str + ) -> AnonCredsRegistryGetRevocationList: + """Get a revocation list from the registry.""" + + # TODO: determine keyword arguments + async def register_revocation_list(self): + """Register a revocation list on the registry.""" diff --git a/aries_cloudagent/anoncreds/did_web_registry/v1_0/routes.py b/aries_cloudagent/anoncreds/did_web_registry/v1_0/routes.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/aries_cloudagent/config/default_context.py b/aries_cloudagent/config/default_context.py index 360f103fa1..99cd638d76 100644 --- a/aries_cloudagent/config/default_context.py +++ b/aries_cloudagent/config/default_context.py @@ -1,5 +1,6 @@ """Classes for configuring the default injection context.""" +from ..anoncreds.anoncreds.anoncreds_registry import AnonCredsRegistry from ..cache.base import BaseCache from ..cache.in_memory import InMemoryCache from ..core.event_bus import EventBus @@ -51,6 +52,7 @@ async def build_context(self) -> InjectionContext: # Global did resolver context.injector.bind_instance(DIDResolver, DIDResolver([])) + context.injector.bind_instance(AnonCredsRegistry, AnonCredsRegistry()) context.injector.bind_instance(DIDMethods, DIDMethods()) context.injector.bind_instance(KeyTypes, KeyTypes()) @@ -127,6 +129,13 @@ async def load_plugins(self, context: InjectionContext): plugin_registry.register_plugin("aries_cloudagent.revocation") plugin_registry.register_plugin("aries_cloudagent.resolver") plugin_registry.register_plugin("aries_cloudagent.wallet") + plugin_registry.register_plugin("aries_cloudagent.anoncreds.anoncreds") + plugin_registry.register_plugin("aries_cloudagent.anoncreds.did_indy_registry") + plugin_registry.register_plugin("aries_cloudagent.anoncreds.did_web_registry") + + # TODO: add anoncreds_plugins to argparse settings + for plugin_path in self.settings.get("anoncreds_plugins", []): + plugin_registry.register_plugin(plugin_path) if context.settings.get("multitenant.admin_enabled"): plugin_registry.register_plugin("aries_cloudagent.multitenant.admin") From 0f59de81319518556ca7677bb5788c1d48502975 Mon Sep 17 00:00:00 2001 From: Char Howland Date: Wed, 8 Mar 2023 14:52:30 -0700 Subject: [PATCH 2/7] fix: flake8 Signed-off-by: Char Howland --- aries_cloudagent/anoncreds/anoncreds/__init__.py | 3 ++- .../anoncreds/anoncreds/anoncreds_objects.py | 10 ++++++++++ .../anoncreds/anoncreds/anoncreds_registry.py | 2 ++ aries_cloudagent/anoncreds/anoncreds/base_registry.py | 4 +++- .../did_indy_registry/v1_0/did_indy_registry.py | 3 +++ .../anoncreds/did_indy_registry/v1_0/routes.py | 1 + .../did_web_registry/v1_0/did_web_registry.py | 3 +++ .../anoncreds/did_web_registry/v1_0/routes.py | 1 + 8 files changed, 25 insertions(+), 2 deletions(-) diff --git a/aries_cloudagent/anoncreds/anoncreds/__init__.py b/aries_cloudagent/anoncreds/anoncreds/__init__.py index 3992d2d9e4..117bf7ec8e 100644 --- a/aries_cloudagent/anoncreds/anoncreds/__init__.py +++ b/aries_cloudagent/anoncreds/anoncreds/__init__.py @@ -16,7 +16,8 @@ async def setup(context: InjectionContext): return indy_registry = ClassProvider( - "aries_cloudagent.anoncreds.did_indy_registry.v1_0.did_indy_registry.DIDIndyRegistry" + "aries_cloudagent.anoncreds.did_indy_registry.v1_0.did_indy_registry." + "DIDIndyRegistry" ).provide(context.settings, context.injector) await indy_registry.setup(context) registry.register_registry(indy_registry) diff --git a/aries_cloudagent/anoncreds/anoncreds/anoncreds_objects.py b/aries_cloudagent/anoncreds/anoncreds/anoncreds_objects.py index c074c621d1..c09a362cee 100644 --- a/aries_cloudagent/anoncreds/anoncreds/anoncreds_objects.py +++ b/aries_cloudagent/anoncreds/anoncreds/anoncreds_objects.py @@ -1,3 +1,4 @@ +"""AnonCreds Objects""" from typing import Any, Dict, List, Optional from typing_extensions import Literal from dataclasses import dataclass @@ -5,6 +6,7 @@ @dataclass class AnonCredsSchema: + """AnonCredsSchema""" issuerId: str attrNames: List[str] name: str @@ -13,6 +15,7 @@ class AnonCredsSchema: @dataclass class AnonCredsRegistryGetSchema: + """AnonCredsRegistryGetSchema""" schema: AnonCredsSchema schema_id: str resolution_metadata: Dict[str, Any] @@ -22,12 +25,14 @@ class AnonCredsRegistryGetSchema: # TODO: determine types for `primary` and `revocation` @dataclass class AnonCredsCredentialDefinitionValue: + """"AnonCredsCredentialDefinitionValue""" primary: Any revocation: Optional[Any] @dataclass class AnonCredsCredentialDefinition: + """AnonCredsCredentialDefinition""" issuerId: str schemaId: str type: Literal["CL"] @@ -37,6 +42,7 @@ class AnonCredsCredentialDefinition: @dataclass class AnonCredsRegistryGetCredentialDefinition: + """AnonCredsRegistryGetCredentialDefinition""" credential_definition: AnonCredsCredentialDefinition credential_definition_id: str resolution_metadata: Dict[str, Any] @@ -45,6 +51,7 @@ class AnonCredsRegistryGetCredentialDefinition: @dataclass class AnonCredsRevocationRegistryDefinition: + """AnonCredsRevocationRegistryDefinition""" issuerId: str type: Literal["CL_ACCUM"] credDefId: str @@ -58,6 +65,7 @@ class AnonCredsRevocationRegistryDefinition: @dataclass class AnonCredsRegistryGetRevocationRegistryDefinition: + """AnonCredsRegistryGetRevocationRegistryDefinition""" revocation_registry: AnonCredsRevocationRegistryDefinition revocation_registry_id: str resolution_metadata: Dict[str, Any] @@ -66,6 +74,7 @@ class AnonCredsRegistryGetRevocationRegistryDefinition: @dataclass class AnonCredsRevocationList: + """AnonCredsRevocationList""" issuerId: str revRegId: str revocationList: List[int] @@ -75,6 +84,7 @@ class AnonCredsRevocationList: @dataclass class AnonCredsRegistryGetRevocationList: + """AnonCredsRegistryGetRevocationList""" revocation_list: AnonCredsRevocationList resolution_metadata: Dict[str, Any] revocation_registry_metadata: Dict[str, Any] diff --git a/aries_cloudagent/anoncreds/anoncreds/anoncreds_registry.py b/aries_cloudagent/anoncreds/anoncreds/anoncreds_registry.py index 4430f05a7c..a7902bc18b 100644 --- a/aries_cloudagent/anoncreds/anoncreds/anoncreds_registry.py +++ b/aries_cloudagent/anoncreds/anoncreds/anoncreds_registry.py @@ -1,3 +1,4 @@ +"""AnonCreds Registry""" import logging from typing import List @@ -7,6 +8,7 @@ class AnonCredsRegistry: + """AnonCredsRegistry""" def __init__(self, registries: List[BaseRegistry] = None): """Create DID Resolver.""" self.registries = registries or [] diff --git a/aries_cloudagent/anoncreds/anoncreds/base_registry.py b/aries_cloudagent/anoncreds/anoncreds/base_registry.py index 9b8177da7d..ba8174ef5f 100644 --- a/aries_cloudagent/anoncreds/anoncreds/base_registry.py +++ b/aries_cloudagent/anoncreds/anoncreds/base_registry.py @@ -1,3 +1,4 @@ +"""Base Registry""" from abc import abstractmethod from ...config.injection_context import InjectionContext @@ -10,9 +11,10 @@ class BaseRegistry: + """BaseRegistry""" @abstractmethod async def setup(self, context: InjectionContext): - """Setup method""" + """Setup method.""" @abstractmethod async def get_schema(self, schema_id: str) -> AnonCredsRegistryGetSchema: diff --git a/aries_cloudagent/anoncreds/did_indy_registry/v1_0/did_indy_registry.py b/aries_cloudagent/anoncreds/did_indy_registry/v1_0/did_indy_registry.py index 7c042e8a75..5363adbd5a 100644 --- a/aries_cloudagent/anoncreds/did_indy_registry/v1_0/did_indy_registry.py +++ b/aries_cloudagent/anoncreds/did_indy_registry/v1_0/did_indy_registry.py @@ -1,3 +1,4 @@ +"""DID Indy Registry""" from ...anoncreds.anoncreds_objects import ( AnonCredsRegistryGetCredentialDefinition, AnonCredsRegistryGetRevocationList, @@ -9,7 +10,9 @@ class DIDIndyRegistry(BaseRegistry): + """DIDIndyRegistry""" async def setup(self, context: InjectionContext): + """Setup.""" print("Successfully registered DIDIndyRegistry") async def get_schema(self, schema_id: str) -> AnonCredsRegistryGetSchema: diff --git a/aries_cloudagent/anoncreds/did_indy_registry/v1_0/routes.py b/aries_cloudagent/anoncreds/did_indy_registry/v1_0/routes.py index e69de29bb2..9d3bc1ba85 100644 --- a/aries_cloudagent/anoncreds/did_indy_registry/v1_0/routes.py +++ b/aries_cloudagent/anoncreds/did_indy_registry/v1_0/routes.py @@ -0,0 +1 @@ +"""Routes for DID Indy Registry""" \ No newline at end of file diff --git a/aries_cloudagent/anoncreds/did_web_registry/v1_0/did_web_registry.py b/aries_cloudagent/anoncreds/did_web_registry/v1_0/did_web_registry.py index 4585625a60..60ff7d7b92 100644 --- a/aries_cloudagent/anoncreds/did_web_registry/v1_0/did_web_registry.py +++ b/aries_cloudagent/anoncreds/did_web_registry/v1_0/did_web_registry.py @@ -1,3 +1,4 @@ +"""DID Web Registry""" from ...anoncreds.anoncreds_objects import ( AnonCredsRegistryGetCredentialDefinition, AnonCredsRegistryGetRevocationList, @@ -9,7 +10,9 @@ class DIDWebRegistry(BaseRegistry): + """DIDWebRegistry""" async def setup(self, context: InjectionContext): + """Setup.""" print("Successfully registered DIDWebRegistry") async def get_schema(self, schema_id: str) -> AnonCredsRegistryGetSchema: diff --git a/aries_cloudagent/anoncreds/did_web_registry/v1_0/routes.py b/aries_cloudagent/anoncreds/did_web_registry/v1_0/routes.py index e69de29bb2..def7cc9e24 100644 --- a/aries_cloudagent/anoncreds/did_web_registry/v1_0/routes.py +++ b/aries_cloudagent/anoncreds/did_web_registry/v1_0/routes.py @@ -0,0 +1 @@ +"""Routes for DID Web Registry""" \ No newline at end of file From 33e77fada9a0356976854b3cbac8c4ebf355d38d Mon Sep 17 00:00:00 2001 From: Char Howland Date: Fri, 10 Mar 2023 10:20:23 -0700 Subject: [PATCH 3/7] fix: file naming and structure Signed-off-by: Char Howland --- aries_cloudagent/anoncreds/anoncreds/__init__.py | 7 +++---- aries_cloudagent/anoncreds/anoncreds/base_registry.py | 2 +- .../anoncreds/{anoncreds_objects.py => models.py} | 0 .../anoncreds/did_indy_registry/definition.py | 10 ---------- .../{v1_0/did_indy_registry.py => registry.py} | 6 +++--- .../anoncreds/did_indy_registry/{v1_0 => }/routes.py | 0 .../anoncreds/did_indy_registry/v1_0/__init__.py | 0 .../anoncreds/did_web_registry/definition.py | 10 ---------- .../{v1_0/did_web_registry.py => registry.py} | 6 +++--- .../anoncreds/did_web_registry/{v1_0 => }/routes.py | 0 .../anoncreds/did_web_registry/v1_0/__init__.py | 0 11 files changed, 10 insertions(+), 31 deletions(-) rename aries_cloudagent/anoncreds/anoncreds/{anoncreds_objects.py => models.py} (100%) delete mode 100644 aries_cloudagent/anoncreds/did_indy_registry/definition.py rename aries_cloudagent/anoncreds/did_indy_registry/{v1_0/did_indy_registry.py => registry.py} (91%) rename aries_cloudagent/anoncreds/did_indy_registry/{v1_0 => }/routes.py (100%) delete mode 100644 aries_cloudagent/anoncreds/did_indy_registry/v1_0/__init__.py delete mode 100644 aries_cloudagent/anoncreds/did_web_registry/definition.py rename aries_cloudagent/anoncreds/did_web_registry/{v1_0/did_web_registry.py => registry.py} (91%) rename aries_cloudagent/anoncreds/did_web_registry/{v1_0 => }/routes.py (100%) delete mode 100644 aries_cloudagent/anoncreds/did_web_registry/v1_0/__init__.py diff --git a/aries_cloudagent/anoncreds/anoncreds/__init__.py b/aries_cloudagent/anoncreds/anoncreds/__init__.py index 117bf7ec8e..366e713119 100644 --- a/aries_cloudagent/anoncreds/anoncreds/__init__.py +++ b/aries_cloudagent/anoncreds/anoncreds/__init__.py @@ -12,18 +12,17 @@ async def setup(context: InjectionContext): """Set up default resolvers.""" registry = context.inject_or(AnonCredsRegistry) if not registry: - LOGGER.warning("No DID Resolver instance found in context") + LOGGER.warning("No AnonCredsRegistry instance found in context") return indy_registry = ClassProvider( - "aries_cloudagent.anoncreds.did_indy_registry.v1_0.did_indy_registry." - "DIDIndyRegistry" + "aries_cloudagent.anoncreds.did_indy_registry.registry.DIDIndyRegistry" ).provide(context.settings, context.injector) await indy_registry.setup(context) registry.register_registry(indy_registry) web_registry = ClassProvider( - "aries_cloudagent.anoncreds.did_web_registry.v1_0.did_web_registry.DIDWebRegistry" + "aries_cloudagent.anoncreds.did_web_registry.registry.DIDWebRegistry" ).provide(context.settings, context.injector) await web_registry.setup(context) registry.register_registry(web_registry) diff --git a/aries_cloudagent/anoncreds/anoncreds/base_registry.py b/aries_cloudagent/anoncreds/anoncreds/base_registry.py index ba8174ef5f..4e03442b9e 100644 --- a/aries_cloudagent/anoncreds/anoncreds/base_registry.py +++ b/aries_cloudagent/anoncreds/anoncreds/base_registry.py @@ -2,7 +2,7 @@ from abc import abstractmethod from ...config.injection_context import InjectionContext -from .anoncreds_objects import ( +from .models import ( AnonCredsRegistryGetCredentialDefinition, AnonCredsRegistryGetRevocationList, AnonCredsRegistryGetRevocationRegistryDefinition, diff --git a/aries_cloudagent/anoncreds/anoncreds/anoncreds_objects.py b/aries_cloudagent/anoncreds/anoncreds/models.py similarity index 100% rename from aries_cloudagent/anoncreds/anoncreds/anoncreds_objects.py rename to aries_cloudagent/anoncreds/anoncreds/models.py diff --git a/aries_cloudagent/anoncreds/did_indy_registry/definition.py b/aries_cloudagent/anoncreds/did_indy_registry/definition.py deleted file mode 100644 index 62bddef6f5..0000000000 --- a/aries_cloudagent/anoncreds/did_indy_registry/definition.py +++ /dev/null @@ -1,10 +0,0 @@ -"""Version definitions for this protocol.""" - -versions = [ - { - "major_version": 1, - "minimum_minor_version": 0, - "current_minor_version": 0, - "path": "v1_0", - } -] diff --git a/aries_cloudagent/anoncreds/did_indy_registry/v1_0/did_indy_registry.py b/aries_cloudagent/anoncreds/did_indy_registry/registry.py similarity index 91% rename from aries_cloudagent/anoncreds/did_indy_registry/v1_0/did_indy_registry.py rename to aries_cloudagent/anoncreds/did_indy_registry/registry.py index 5363adbd5a..ab619eaed3 100644 --- a/aries_cloudagent/anoncreds/did_indy_registry/v1_0/did_indy_registry.py +++ b/aries_cloudagent/anoncreds/did_indy_registry/registry.py @@ -1,12 +1,12 @@ """DID Indy Registry""" -from ...anoncreds.anoncreds_objects import ( +from ..anoncreds.models import ( AnonCredsRegistryGetCredentialDefinition, AnonCredsRegistryGetRevocationList, AnonCredsRegistryGetRevocationRegistryDefinition, AnonCredsRegistryGetSchema, ) -from ....config.injection_context import InjectionContext -from ....anoncreds.anoncreds.anoncreds_registry import BaseRegistry +from ...config.injection_context import InjectionContext +from ..anoncreds.anoncreds_registry import BaseRegistry class DIDIndyRegistry(BaseRegistry): diff --git a/aries_cloudagent/anoncreds/did_indy_registry/v1_0/routes.py b/aries_cloudagent/anoncreds/did_indy_registry/routes.py similarity index 100% rename from aries_cloudagent/anoncreds/did_indy_registry/v1_0/routes.py rename to aries_cloudagent/anoncreds/did_indy_registry/routes.py diff --git a/aries_cloudagent/anoncreds/did_indy_registry/v1_0/__init__.py b/aries_cloudagent/anoncreds/did_indy_registry/v1_0/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/aries_cloudagent/anoncreds/did_web_registry/definition.py b/aries_cloudagent/anoncreds/did_web_registry/definition.py deleted file mode 100644 index 62bddef6f5..0000000000 --- a/aries_cloudagent/anoncreds/did_web_registry/definition.py +++ /dev/null @@ -1,10 +0,0 @@ -"""Version definitions for this protocol.""" - -versions = [ - { - "major_version": 1, - "minimum_minor_version": 0, - "current_minor_version": 0, - "path": "v1_0", - } -] diff --git a/aries_cloudagent/anoncreds/did_web_registry/v1_0/did_web_registry.py b/aries_cloudagent/anoncreds/did_web_registry/registry.py similarity index 91% rename from aries_cloudagent/anoncreds/did_web_registry/v1_0/did_web_registry.py rename to aries_cloudagent/anoncreds/did_web_registry/registry.py index 60ff7d7b92..9f38c9057a 100644 --- a/aries_cloudagent/anoncreds/did_web_registry/v1_0/did_web_registry.py +++ b/aries_cloudagent/anoncreds/did_web_registry/registry.py @@ -1,12 +1,12 @@ """DID Web Registry""" -from ...anoncreds.anoncreds_objects import ( +from ..anoncreds.models import ( AnonCredsRegistryGetCredentialDefinition, AnonCredsRegistryGetRevocationList, AnonCredsRegistryGetRevocationRegistryDefinition, AnonCredsRegistryGetSchema, ) -from ....config.injection_context import InjectionContext -from ....anoncreds.anoncreds.anoncreds_registry import BaseRegistry +from ...config.injection_context import InjectionContext +from ..anoncreds.anoncreds_registry import BaseRegistry class DIDWebRegistry(BaseRegistry): diff --git a/aries_cloudagent/anoncreds/did_web_registry/v1_0/routes.py b/aries_cloudagent/anoncreds/did_web_registry/routes.py similarity index 100% rename from aries_cloudagent/anoncreds/did_web_registry/v1_0/routes.py rename to aries_cloudagent/anoncreds/did_web_registry/routes.py diff --git a/aries_cloudagent/anoncreds/did_web_registry/v1_0/__init__.py b/aries_cloudagent/anoncreds/did_web_registry/v1_0/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 From b3a6944f7faf6cf4b658e20c34770bf18ff9b906 Mon Sep 17 00:00:00 2001 From: Char Howland Date: Fri, 10 Mar 2023 11:15:45 -0700 Subject: [PATCH 4/7] fix: AnonCredsRegistry inherits from BaseRegistry Signed-off-by: Char Howland --- .../anoncreds/anoncreds/__init__.py | 4 +- .../anoncreds/anoncreds/anoncreds_registry.py | 48 +++++++++++++++++-- .../anoncreds/anoncreds/base_registry.py | 9 +++- aries_cloudagent/config/default_context.py | 4 -- 4 files changed, 54 insertions(+), 11 deletions(-) diff --git a/aries_cloudagent/anoncreds/anoncreds/__init__.py b/aries_cloudagent/anoncreds/anoncreds/__init__.py index 366e713119..1908022f5a 100644 --- a/aries_cloudagent/anoncreds/anoncreds/__init__.py +++ b/aries_cloudagent/anoncreds/anoncreds/__init__.py @@ -16,13 +16,13 @@ async def setup(context: InjectionContext): return indy_registry = ClassProvider( - "aries_cloudagent.anoncreds.did_indy_registry.registry.DIDIndyRegistry" + "aries_cloudagent.anoncreds.did_indy_registry.registry.DIDIndyRegistry", supported_identifiers=[], method_name="did:indy", ).provide(context.settings, context.injector) await indy_registry.setup(context) registry.register_registry(indy_registry) web_registry = ClassProvider( - "aries_cloudagent.anoncreds.did_web_registry.registry.DIDWebRegistry" + "aries_cloudagent.anoncreds.did_web_registry.registry.DIDWebRegistry", supported_identifiers=[], method_name="did:web", ).provide(context.settings, context.injector) await web_registry.setup(context) registry.register_registry(web_registry) diff --git a/aries_cloudagent/anoncreds/anoncreds/anoncreds_registry.py b/aries_cloudagent/anoncreds/anoncreds/anoncreds_registry.py index a7902bc18b..96a1fa7615 100644 --- a/aries_cloudagent/anoncreds/anoncreds/anoncreds_registry.py +++ b/aries_cloudagent/anoncreds/anoncreds/anoncreds_registry.py @@ -3,19 +3,61 @@ from typing import List from .base_registry import BaseRegistry +from .models import AnonCredsRegistryGetCredentialDefinition, AnonCredsRegistryGetRevocationList, AnonCredsRegistryGetRevocationRegistryDefinition, AnonCredsRegistryGetSchema +from ...config.injection_context import InjectionContext + LOGGER = logging.getLogger(__name__) -class AnonCredsRegistry: +class AnonCredsRegistry(BaseRegistry): """AnonCredsRegistry""" def __init__(self, registries: List[BaseRegistry] = None): """Create DID Resolver.""" + super().__init__(supported_identifiers=[], method_name="") + # TODO: need both supported_identifiers and method_name? self.registries = registries or [] - # TODO: add schema and cred def registries + + # TODO: use supported_identifier and method_name to select which registry should + # resolve or register a given object + identifier def register_registry(self, registry: BaseRegistry): """Register a new registry.""" self.registries.append(registry) - # TODO: add logic for picking the correct registry + async def setup(self, context: InjectionContext): + """Setup method.""" + + async def get_schema(self, schema_id: str) -> AnonCredsRegistryGetSchema: + """Get a schema from the registry.""" + + # TODO: determine keyword arguments + async def register_schema(self): + """Register a schema on the registry.""" + + async def get_credential_definition( + self, credential_definition_id: str + ) -> AnonCredsRegistryGetCredentialDefinition: + """Get a credential definition from the registry.""" + + # TODO: determine keyword arguments + async def register_credential_definition(self): + """Register a credential definition on the registry.""" + + async def get_revocation_registry_definition( + self, revocation_registry_id: str + ) -> AnonCredsRegistryGetRevocationRegistryDefinition: + """Get a revocation registry definition from the registry.""" + + # TODO: determine keyword arguments + async def register_revocation_registry_definition(self): + """Register a revocation registry definition on the registry.""" + + async def get_revocation_list( + self, revocation_registry_id: str, timestamp: str + ) -> AnonCredsRegistryGetRevocationList: + """Get a revocation list from the registry.""" + + # TODO: determine keyword arguments + async def register_revocation_list(self): + """Register a revocation list on the registry.""" \ No newline at end of file diff --git a/aries_cloudagent/anoncreds/anoncreds/base_registry.py b/aries_cloudagent/anoncreds/anoncreds/base_registry.py index 4e03442b9e..0ebe38456e 100644 --- a/aries_cloudagent/anoncreds/anoncreds/base_registry.py +++ b/aries_cloudagent/anoncreds/anoncreds/base_registry.py @@ -1,5 +1,6 @@ """Base Registry""" -from abc import abstractmethod +from abc import ABC, abstractmethod +from typing import List from ...config.injection_context import InjectionContext from .models import ( @@ -10,8 +11,12 @@ ) -class BaseRegistry: +class BaseRegistry(ABC): """BaseRegistry""" + + def __init__(self, supported_identifiers: List[str], method_name: str): + """Initialize Base Registry.""" + @abstractmethod async def setup(self, context: InjectionContext): """Setup method.""" diff --git a/aries_cloudagent/config/default_context.py b/aries_cloudagent/config/default_context.py index 99cd638d76..297c1be75c 100644 --- a/aries_cloudagent/config/default_context.py +++ b/aries_cloudagent/config/default_context.py @@ -133,10 +133,6 @@ async def load_plugins(self, context: InjectionContext): plugin_registry.register_plugin("aries_cloudagent.anoncreds.did_indy_registry") plugin_registry.register_plugin("aries_cloudagent.anoncreds.did_web_registry") - # TODO: add anoncreds_plugins to argparse settings - for plugin_path in self.settings.get("anoncreds_plugins", []): - plugin_registry.register_plugin(plugin_path) - if context.settings.get("multitenant.admin_enabled"): plugin_registry.register_plugin("aries_cloudagent.multitenant.admin") From 420aba6de28532c6371121718e0f2b771a06261e Mon Sep 17 00:00:00 2001 From: Char Howland Date: Fri, 10 Mar 2023 11:20:17 -0700 Subject: [PATCH 5/7] feat: add legacy indy registry plugin structure Signed-off-by: Char Howland --- .../anoncreds/anoncreds/__init__.py | 6 +++ .../legacy_indy_registry/__init__.py | 0 .../legacy_indy_registry/registry.py | 50 +++++++++++++++++++ .../anoncreds/legacy_indy_registry/routes.py | 1 + aries_cloudagent/config/default_context.py | 1 + 5 files changed, 58 insertions(+) create mode 100644 aries_cloudagent/anoncreds/legacy_indy_registry/__init__.py create mode 100644 aries_cloudagent/anoncreds/legacy_indy_registry/registry.py create mode 100644 aries_cloudagent/anoncreds/legacy_indy_registry/routes.py diff --git a/aries_cloudagent/anoncreds/anoncreds/__init__.py b/aries_cloudagent/anoncreds/anoncreds/__init__.py index 1908022f5a..5ac21c3499 100644 --- a/aries_cloudagent/anoncreds/anoncreds/__init__.py +++ b/aries_cloudagent/anoncreds/anoncreds/__init__.py @@ -27,4 +27,10 @@ async def setup(context: InjectionContext): await web_registry.setup(context) registry.register_registry(web_registry) + legacy_indy_registry = ClassProvider( + "aries_cloudagent.anoncreds.legacy_indy_registry.registry.LegacyIndyRegistry", supported_identifiers=[], method_name="", + ).provide(context.settings, context.injector) + await legacy_indy_registry.setup(context) + registry.register_registry(legacy_indy_registry) + # TODO: add context.settings diff --git a/aries_cloudagent/anoncreds/legacy_indy_registry/__init__.py b/aries_cloudagent/anoncreds/legacy_indy_registry/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/aries_cloudagent/anoncreds/legacy_indy_registry/registry.py b/aries_cloudagent/anoncreds/legacy_indy_registry/registry.py new file mode 100644 index 0000000000..5063a17aa8 --- /dev/null +++ b/aries_cloudagent/anoncreds/legacy_indy_registry/registry.py @@ -0,0 +1,50 @@ +"""Legacy Indy Registry""" +from ..anoncreds.models import ( + AnonCredsRegistryGetCredentialDefinition, + AnonCredsRegistryGetRevocationList, + AnonCredsRegistryGetRevocationRegistryDefinition, + AnonCredsRegistryGetSchema, +) +from ...config.injection_context import InjectionContext +from ..anoncreds.anoncreds_registry import BaseRegistry + + +class LegacyIndyRegistry(BaseRegistry): + """LegacyIndyRegistry""" + async def setup(self, context: InjectionContext): + """Setup.""" + print("Successfully registered LegacyIndyRegistry") + + async def get_schema(self, schema_id: str) -> AnonCredsRegistryGetSchema: + """Get a schema from the registry.""" + + # TODO: determine keyword arguments + async def register_schema(self): + """Register a schema on the registry.""" + + async def get_credential_definition( + self, credential_definition_id: str + ) -> AnonCredsRegistryGetCredentialDefinition: + """Get a credential definition from the registry.""" + + # TODO: determine keyword arguments + async def register_credential_definition(self): + """Register a credential definition on the registry.""" + + async def get_revocation_registry_definition( + self, revocation_registry_id: str + ) -> AnonCredsRegistryGetRevocationRegistryDefinition: + """Get a revocation registry definition from the registry.""" + + # TODO: determine keyword arguments + async def register_revocation_registry_definition(self): + """Register a revocation registry definition on the registry.""" + + async def get_revocation_list( + self, revocation_registry_id: str, timestamp: str + ) -> AnonCredsRegistryGetRevocationList: + """Get a revocation list from the registry.""" + + # TODO: determine keyword arguments + async def register_revocation_list(self): + """Register a revocation list on the registry.""" diff --git a/aries_cloudagent/anoncreds/legacy_indy_registry/routes.py b/aries_cloudagent/anoncreds/legacy_indy_registry/routes.py new file mode 100644 index 0000000000..def7cc9e24 --- /dev/null +++ b/aries_cloudagent/anoncreds/legacy_indy_registry/routes.py @@ -0,0 +1 @@ +"""Routes for DID Web Registry""" \ No newline at end of file diff --git a/aries_cloudagent/config/default_context.py b/aries_cloudagent/config/default_context.py index 297c1be75c..f021ce0651 100644 --- a/aries_cloudagent/config/default_context.py +++ b/aries_cloudagent/config/default_context.py @@ -132,6 +132,7 @@ async def load_plugins(self, context: InjectionContext): plugin_registry.register_plugin("aries_cloudagent.anoncreds.anoncreds") plugin_registry.register_plugin("aries_cloudagent.anoncreds.did_indy_registry") plugin_registry.register_plugin("aries_cloudagent.anoncreds.did_web_registry") + plugin_registry.register_plugin("aries_cloudagent.anoncreds.legacy_indy_registry") if context.settings.get("multitenant.admin_enabled"): plugin_registry.register_plugin("aries_cloudagent.multitenant.admin") From 9ca2d92074625dd9eb5d21510c566934756beb14 Mon Sep 17 00:00:00 2001 From: Char Howland Date: Fri, 10 Mar 2023 11:51:02 -0700 Subject: [PATCH 6/7] feat: create default directory for registries Signed-off-by: Char Howland --- aries_cloudagent/anoncreds/anoncreds/__init__.py | 6 +++--- .../{ => anoncreds/default}/did_indy_registry/__init__.py | 0 .../{ => anoncreds/default}/did_indy_registry/registry.py | 6 +++--- .../{ => anoncreds/default}/did_indy_registry/routes.py | 0 .../{ => anoncreds/default}/did_web_registry/__init__.py | 0 .../{ => anoncreds/default}/did_web_registry/registry.py | 6 +++--- .../{ => anoncreds/default}/did_web_registry/routes.py | 0 .../default}/legacy_indy_registry/__init__.py | 0 .../default}/legacy_indy_registry/registry.py | 6 +++--- .../anoncreds/default/legacy_indy_registry/routes.py | 1 + aries_cloudagent/anoncreds/legacy_indy_registry/routes.py | 1 - aries_cloudagent/config/default_context.py | 6 +++--- 12 files changed, 16 insertions(+), 16 deletions(-) rename aries_cloudagent/anoncreds/{ => anoncreds/default}/did_indy_registry/__init__.py (100%) rename aries_cloudagent/anoncreds/{ => anoncreds/default}/did_indy_registry/registry.py (92%) rename aries_cloudagent/anoncreds/{ => anoncreds/default}/did_indy_registry/routes.py (100%) rename aries_cloudagent/anoncreds/{ => anoncreds/default}/did_web_registry/__init__.py (100%) rename aries_cloudagent/anoncreds/{ => anoncreds/default}/did_web_registry/registry.py (92%) rename aries_cloudagent/anoncreds/{ => anoncreds/default}/did_web_registry/routes.py (100%) rename aries_cloudagent/anoncreds/{ => anoncreds/default}/legacy_indy_registry/__init__.py (100%) rename aries_cloudagent/anoncreds/{ => anoncreds/default}/legacy_indy_registry/registry.py (92%) create mode 100644 aries_cloudagent/anoncreds/anoncreds/default/legacy_indy_registry/routes.py delete mode 100644 aries_cloudagent/anoncreds/legacy_indy_registry/routes.py diff --git a/aries_cloudagent/anoncreds/anoncreds/__init__.py b/aries_cloudagent/anoncreds/anoncreds/__init__.py index 5ac21c3499..0c461cb05c 100644 --- a/aries_cloudagent/anoncreds/anoncreds/__init__.py +++ b/aries_cloudagent/anoncreds/anoncreds/__init__.py @@ -16,19 +16,19 @@ async def setup(context: InjectionContext): return indy_registry = ClassProvider( - "aries_cloudagent.anoncreds.did_indy_registry.registry.DIDIndyRegistry", supported_identifiers=[], method_name="did:indy", + "aries_cloudagent.anoncreds.anoncreds.default.did_indy_registry.registry.DIDIndyRegistry", supported_identifiers=[], method_name="did:indy", ).provide(context.settings, context.injector) await indy_registry.setup(context) registry.register_registry(indy_registry) web_registry = ClassProvider( - "aries_cloudagent.anoncreds.did_web_registry.registry.DIDWebRegistry", supported_identifiers=[], method_name="did:web", + "aries_cloudagent.anoncreds.anoncreds.default.did_web_registry.registry.DIDWebRegistry", supported_identifiers=[], method_name="did:web", ).provide(context.settings, context.injector) await web_registry.setup(context) registry.register_registry(web_registry) legacy_indy_registry = ClassProvider( - "aries_cloudagent.anoncreds.legacy_indy_registry.registry.LegacyIndyRegistry", supported_identifiers=[], method_name="", + "aries_cloudagent.anoncreds.anoncreds.default.legacy_indy_registry.registry.LegacyIndyRegistry", supported_identifiers=[], method_name="", ).provide(context.settings, context.injector) await legacy_indy_registry.setup(context) registry.register_registry(legacy_indy_registry) diff --git a/aries_cloudagent/anoncreds/did_indy_registry/__init__.py b/aries_cloudagent/anoncreds/anoncreds/default/did_indy_registry/__init__.py similarity index 100% rename from aries_cloudagent/anoncreds/did_indy_registry/__init__.py rename to aries_cloudagent/anoncreds/anoncreds/default/did_indy_registry/__init__.py diff --git a/aries_cloudagent/anoncreds/did_indy_registry/registry.py b/aries_cloudagent/anoncreds/anoncreds/default/did_indy_registry/registry.py similarity index 92% rename from aries_cloudagent/anoncreds/did_indy_registry/registry.py rename to aries_cloudagent/anoncreds/anoncreds/default/did_indy_registry/registry.py index ab619eaed3..51009f347f 100644 --- a/aries_cloudagent/anoncreds/did_indy_registry/registry.py +++ b/aries_cloudagent/anoncreds/anoncreds/default/did_indy_registry/registry.py @@ -1,12 +1,12 @@ """DID Indy Registry""" -from ..anoncreds.models import ( +from ...models import ( AnonCredsRegistryGetCredentialDefinition, AnonCredsRegistryGetRevocationList, AnonCredsRegistryGetRevocationRegistryDefinition, AnonCredsRegistryGetSchema, ) -from ...config.injection_context import InjectionContext -from ..anoncreds.anoncreds_registry import BaseRegistry +from .....config.injection_context import InjectionContext +from ...anoncreds_registry import BaseRegistry class DIDIndyRegistry(BaseRegistry): diff --git a/aries_cloudagent/anoncreds/did_indy_registry/routes.py b/aries_cloudagent/anoncreds/anoncreds/default/did_indy_registry/routes.py similarity index 100% rename from aries_cloudagent/anoncreds/did_indy_registry/routes.py rename to aries_cloudagent/anoncreds/anoncreds/default/did_indy_registry/routes.py diff --git a/aries_cloudagent/anoncreds/did_web_registry/__init__.py b/aries_cloudagent/anoncreds/anoncreds/default/did_web_registry/__init__.py similarity index 100% rename from aries_cloudagent/anoncreds/did_web_registry/__init__.py rename to aries_cloudagent/anoncreds/anoncreds/default/did_web_registry/__init__.py diff --git a/aries_cloudagent/anoncreds/did_web_registry/registry.py b/aries_cloudagent/anoncreds/anoncreds/default/did_web_registry/registry.py similarity index 92% rename from aries_cloudagent/anoncreds/did_web_registry/registry.py rename to aries_cloudagent/anoncreds/anoncreds/default/did_web_registry/registry.py index 9f38c9057a..d5ebd87041 100644 --- a/aries_cloudagent/anoncreds/did_web_registry/registry.py +++ b/aries_cloudagent/anoncreds/anoncreds/default/did_web_registry/registry.py @@ -1,12 +1,12 @@ """DID Web Registry""" -from ..anoncreds.models import ( +from ...models import ( AnonCredsRegistryGetCredentialDefinition, AnonCredsRegistryGetRevocationList, AnonCredsRegistryGetRevocationRegistryDefinition, AnonCredsRegistryGetSchema, ) -from ...config.injection_context import InjectionContext -from ..anoncreds.anoncreds_registry import BaseRegistry +from .....config.injection_context import InjectionContext +from ...anoncreds_registry import BaseRegistry class DIDWebRegistry(BaseRegistry): diff --git a/aries_cloudagent/anoncreds/did_web_registry/routes.py b/aries_cloudagent/anoncreds/anoncreds/default/did_web_registry/routes.py similarity index 100% rename from aries_cloudagent/anoncreds/did_web_registry/routes.py rename to aries_cloudagent/anoncreds/anoncreds/default/did_web_registry/routes.py diff --git a/aries_cloudagent/anoncreds/legacy_indy_registry/__init__.py b/aries_cloudagent/anoncreds/anoncreds/default/legacy_indy_registry/__init__.py similarity index 100% rename from aries_cloudagent/anoncreds/legacy_indy_registry/__init__.py rename to aries_cloudagent/anoncreds/anoncreds/default/legacy_indy_registry/__init__.py diff --git a/aries_cloudagent/anoncreds/legacy_indy_registry/registry.py b/aries_cloudagent/anoncreds/anoncreds/default/legacy_indy_registry/registry.py similarity index 92% rename from aries_cloudagent/anoncreds/legacy_indy_registry/registry.py rename to aries_cloudagent/anoncreds/anoncreds/default/legacy_indy_registry/registry.py index 5063a17aa8..2fe3b078de 100644 --- a/aries_cloudagent/anoncreds/legacy_indy_registry/registry.py +++ b/aries_cloudagent/anoncreds/anoncreds/default/legacy_indy_registry/registry.py @@ -1,12 +1,12 @@ """Legacy Indy Registry""" -from ..anoncreds.models import ( +from ...models import ( AnonCredsRegistryGetCredentialDefinition, AnonCredsRegistryGetRevocationList, AnonCredsRegistryGetRevocationRegistryDefinition, AnonCredsRegistryGetSchema, ) -from ...config.injection_context import InjectionContext -from ..anoncreds.anoncreds_registry import BaseRegistry +from .....config.injection_context import InjectionContext +from ...anoncreds_registry import BaseRegistry class LegacyIndyRegistry(BaseRegistry): diff --git a/aries_cloudagent/anoncreds/anoncreds/default/legacy_indy_registry/routes.py b/aries_cloudagent/anoncreds/anoncreds/default/legacy_indy_registry/routes.py new file mode 100644 index 0000000000..66b5eab23d --- /dev/null +++ b/aries_cloudagent/anoncreds/anoncreds/default/legacy_indy_registry/routes.py @@ -0,0 +1 @@ +"""Routes for Legacy Indy Registry""" \ No newline at end of file diff --git a/aries_cloudagent/anoncreds/legacy_indy_registry/routes.py b/aries_cloudagent/anoncreds/legacy_indy_registry/routes.py deleted file mode 100644 index def7cc9e24..0000000000 --- a/aries_cloudagent/anoncreds/legacy_indy_registry/routes.py +++ /dev/null @@ -1 +0,0 @@ -"""Routes for DID Web Registry""" \ No newline at end of file diff --git a/aries_cloudagent/config/default_context.py b/aries_cloudagent/config/default_context.py index f021ce0651..26e1c1684d 100644 --- a/aries_cloudagent/config/default_context.py +++ b/aries_cloudagent/config/default_context.py @@ -130,9 +130,9 @@ async def load_plugins(self, context: InjectionContext): plugin_registry.register_plugin("aries_cloudagent.resolver") plugin_registry.register_plugin("aries_cloudagent.wallet") plugin_registry.register_plugin("aries_cloudagent.anoncreds.anoncreds") - plugin_registry.register_plugin("aries_cloudagent.anoncreds.did_indy_registry") - plugin_registry.register_plugin("aries_cloudagent.anoncreds.did_web_registry") - plugin_registry.register_plugin("aries_cloudagent.anoncreds.legacy_indy_registry") + plugin_registry.register_plugin("aries_cloudagent.anoncreds.anoncreds.default.did_indy_registry") + plugin_registry.register_plugin("aries_cloudagent.anoncreds.anoncreds.default.did_web_registry") + plugin_registry.register_plugin("aries_cloudagent.anoncreds.anoncreds.default.legacy_indy_registry") if context.settings.get("multitenant.admin_enabled"): plugin_registry.register_plugin("aries_cloudagent.multitenant.admin") From dc0170310f8e22cb3c13565d994af81dfdd453dc Mon Sep 17 00:00:00 2001 From: Char Howland Date: Fri, 10 Mar 2023 12:34:51 -0700 Subject: [PATCH 7/7] fix: flake8 Signed-off-by: Char Howland --- aries_cloudagent/anoncreds/anoncreds/__init__.py | 15 ++++++++++++--- .../anoncreds/anoncreds/anoncreds_registry.py | 10 ++++++++-- .../default/did_indy_registry/registry.py | 1 + .../anoncreds/default/did_indy_registry/routes.py | 2 +- .../default/did_web_registry/registry.py | 1 + .../anoncreds/default/did_web_registry/routes.py | 2 +- .../default/legacy_indy_registry/registry.py | 1 + .../default/legacy_indy_registry/routes.py | 2 +- aries_cloudagent/anoncreds/anoncreds/models.py | 11 ++++++++++- aries_cloudagent/config/default_context.py | 12 +++++++++--- 10 files changed, 45 insertions(+), 12 deletions(-) diff --git a/aries_cloudagent/anoncreds/anoncreds/__init__.py b/aries_cloudagent/anoncreds/anoncreds/__init__.py index 0c461cb05c..9506346d5d 100644 --- a/aries_cloudagent/anoncreds/anoncreds/__init__.py +++ b/aries_cloudagent/anoncreds/anoncreds/__init__.py @@ -16,19 +16,28 @@ async def setup(context: InjectionContext): return indy_registry = ClassProvider( - "aries_cloudagent.anoncreds.anoncreds.default.did_indy_registry.registry.DIDIndyRegistry", supported_identifiers=[], method_name="did:indy", + "aries_cloudagent.anoncreds.anoncreds.default.did_indy_registry.registry" + ".DIDIndyRegistry", + supported_identifiers=[], + method_name="did:indy", ).provide(context.settings, context.injector) await indy_registry.setup(context) registry.register_registry(indy_registry) web_registry = ClassProvider( - "aries_cloudagent.anoncreds.anoncreds.default.did_web_registry.registry.DIDWebRegistry", supported_identifiers=[], method_name="did:web", + "aries_cloudagent.anoncreds.anoncreds.default.did_web_registry.registry" + ".DIDWebRegistry", + supported_identifiers=[], + method_name="did:web", ).provide(context.settings, context.injector) await web_registry.setup(context) registry.register_registry(web_registry) legacy_indy_registry = ClassProvider( - "aries_cloudagent.anoncreds.anoncreds.default.legacy_indy_registry.registry.LegacyIndyRegistry", supported_identifiers=[], method_name="", + "aries_cloudagent.anoncreds.anoncreds.default.legacy_indy_registry.registry" + ".LegacyIndyRegistry", + supported_identifiers=[], + method_name="", ).provide(context.settings, context.injector) await legacy_indy_registry.setup(context) registry.register_registry(legacy_indy_registry) diff --git a/aries_cloudagent/anoncreds/anoncreds/anoncreds_registry.py b/aries_cloudagent/anoncreds/anoncreds/anoncreds_registry.py index 96a1fa7615..fbc82f633e 100644 --- a/aries_cloudagent/anoncreds/anoncreds/anoncreds_registry.py +++ b/aries_cloudagent/anoncreds/anoncreds/anoncreds_registry.py @@ -3,7 +3,12 @@ from typing import List from .base_registry import BaseRegistry -from .models import AnonCredsRegistryGetCredentialDefinition, AnonCredsRegistryGetRevocationList, AnonCredsRegistryGetRevocationRegistryDefinition, AnonCredsRegistryGetSchema +from .models import ( + AnonCredsRegistryGetCredentialDefinition, + AnonCredsRegistryGetRevocationList, + AnonCredsRegistryGetRevocationRegistryDefinition, + AnonCredsRegistryGetSchema, +) from ...config.injection_context import InjectionContext @@ -12,6 +17,7 @@ class AnonCredsRegistry(BaseRegistry): """AnonCredsRegistry""" + def __init__(self, registries: List[BaseRegistry] = None): """Create DID Resolver.""" super().__init__(supported_identifiers=[], method_name="") @@ -60,4 +66,4 @@ async def get_revocation_list( # TODO: determine keyword arguments async def register_revocation_list(self): - """Register a revocation list on the registry.""" \ No newline at end of file + """Register a revocation list on the registry.""" diff --git a/aries_cloudagent/anoncreds/anoncreds/default/did_indy_registry/registry.py b/aries_cloudagent/anoncreds/anoncreds/default/did_indy_registry/registry.py index 51009f347f..68a2f729d2 100644 --- a/aries_cloudagent/anoncreds/anoncreds/default/did_indy_registry/registry.py +++ b/aries_cloudagent/anoncreds/anoncreds/default/did_indy_registry/registry.py @@ -11,6 +11,7 @@ class DIDIndyRegistry(BaseRegistry): """DIDIndyRegistry""" + async def setup(self, context: InjectionContext): """Setup.""" print("Successfully registered DIDIndyRegistry") diff --git a/aries_cloudagent/anoncreds/anoncreds/default/did_indy_registry/routes.py b/aries_cloudagent/anoncreds/anoncreds/default/did_indy_registry/routes.py index 9d3bc1ba85..f38bfd6623 100644 --- a/aries_cloudagent/anoncreds/anoncreds/default/did_indy_registry/routes.py +++ b/aries_cloudagent/anoncreds/anoncreds/default/did_indy_registry/routes.py @@ -1 +1 @@ -"""Routes for DID Indy Registry""" \ No newline at end of file +"""Routes for DID Indy Registry""" diff --git a/aries_cloudagent/anoncreds/anoncreds/default/did_web_registry/registry.py b/aries_cloudagent/anoncreds/anoncreds/default/did_web_registry/registry.py index d5ebd87041..ad0749fe7d 100644 --- a/aries_cloudagent/anoncreds/anoncreds/default/did_web_registry/registry.py +++ b/aries_cloudagent/anoncreds/anoncreds/default/did_web_registry/registry.py @@ -11,6 +11,7 @@ class DIDWebRegistry(BaseRegistry): """DIDWebRegistry""" + async def setup(self, context: InjectionContext): """Setup.""" print("Successfully registered DIDWebRegistry") diff --git a/aries_cloudagent/anoncreds/anoncreds/default/did_web_registry/routes.py b/aries_cloudagent/anoncreds/anoncreds/default/did_web_registry/routes.py index def7cc9e24..0900c1440c 100644 --- a/aries_cloudagent/anoncreds/anoncreds/default/did_web_registry/routes.py +++ b/aries_cloudagent/anoncreds/anoncreds/default/did_web_registry/routes.py @@ -1 +1 @@ -"""Routes for DID Web Registry""" \ No newline at end of file +"""Routes for DID Web Registry""" diff --git a/aries_cloudagent/anoncreds/anoncreds/default/legacy_indy_registry/registry.py b/aries_cloudagent/anoncreds/anoncreds/default/legacy_indy_registry/registry.py index 2fe3b078de..5badd4de1b 100644 --- a/aries_cloudagent/anoncreds/anoncreds/default/legacy_indy_registry/registry.py +++ b/aries_cloudagent/anoncreds/anoncreds/default/legacy_indy_registry/registry.py @@ -11,6 +11,7 @@ class LegacyIndyRegistry(BaseRegistry): """LegacyIndyRegistry""" + async def setup(self, context: InjectionContext): """Setup.""" print("Successfully registered LegacyIndyRegistry") diff --git a/aries_cloudagent/anoncreds/anoncreds/default/legacy_indy_registry/routes.py b/aries_cloudagent/anoncreds/anoncreds/default/legacy_indy_registry/routes.py index 66b5eab23d..759ee608c8 100644 --- a/aries_cloudagent/anoncreds/anoncreds/default/legacy_indy_registry/routes.py +++ b/aries_cloudagent/anoncreds/anoncreds/default/legacy_indy_registry/routes.py @@ -1 +1 @@ -"""Routes for Legacy Indy Registry""" \ No newline at end of file +"""Routes for Legacy Indy Registry""" diff --git a/aries_cloudagent/anoncreds/anoncreds/models.py b/aries_cloudagent/anoncreds/anoncreds/models.py index c09a362cee..c034c52466 100644 --- a/aries_cloudagent/anoncreds/anoncreds/models.py +++ b/aries_cloudagent/anoncreds/anoncreds/models.py @@ -7,6 +7,7 @@ @dataclass class AnonCredsSchema: """AnonCredsSchema""" + issuerId: str attrNames: List[str] name: str @@ -16,6 +17,7 @@ class AnonCredsSchema: @dataclass class AnonCredsRegistryGetSchema: """AnonCredsRegistryGetSchema""" + schema: AnonCredsSchema schema_id: str resolution_metadata: Dict[str, Any] @@ -25,7 +27,8 @@ class AnonCredsRegistryGetSchema: # TODO: determine types for `primary` and `revocation` @dataclass class AnonCredsCredentialDefinitionValue: - """"AnonCredsCredentialDefinitionValue""" + """AnonCredsCredentialDefinitionValue""" + primary: Any revocation: Optional[Any] @@ -33,6 +36,7 @@ class AnonCredsCredentialDefinitionValue: @dataclass class AnonCredsCredentialDefinition: """AnonCredsCredentialDefinition""" + issuerId: str schemaId: str type: Literal["CL"] @@ -43,6 +47,7 @@ class AnonCredsCredentialDefinition: @dataclass class AnonCredsRegistryGetCredentialDefinition: """AnonCredsRegistryGetCredentialDefinition""" + credential_definition: AnonCredsCredentialDefinition credential_definition_id: str resolution_metadata: Dict[str, Any] @@ -52,6 +57,7 @@ class AnonCredsRegistryGetCredentialDefinition: @dataclass class AnonCredsRevocationRegistryDefinition: """AnonCredsRevocationRegistryDefinition""" + issuerId: str type: Literal["CL_ACCUM"] credDefId: str @@ -66,6 +72,7 @@ class AnonCredsRevocationRegistryDefinition: @dataclass class AnonCredsRegistryGetRevocationRegistryDefinition: """AnonCredsRegistryGetRevocationRegistryDefinition""" + revocation_registry: AnonCredsRevocationRegistryDefinition revocation_registry_id: str resolution_metadata: Dict[str, Any] @@ -75,6 +82,7 @@ class AnonCredsRegistryGetRevocationRegistryDefinition: @dataclass class AnonCredsRevocationList: """AnonCredsRevocationList""" + issuerId: str revRegId: str revocationList: List[int] @@ -85,6 +93,7 @@ class AnonCredsRevocationList: @dataclass class AnonCredsRegistryGetRevocationList: """AnonCredsRegistryGetRevocationList""" + revocation_list: AnonCredsRevocationList resolution_metadata: Dict[str, Any] revocation_registry_metadata: Dict[str, Any] diff --git a/aries_cloudagent/config/default_context.py b/aries_cloudagent/config/default_context.py index 26e1c1684d..03ba24f45c 100644 --- a/aries_cloudagent/config/default_context.py +++ b/aries_cloudagent/config/default_context.py @@ -130,9 +130,15 @@ async def load_plugins(self, context: InjectionContext): plugin_registry.register_plugin("aries_cloudagent.resolver") plugin_registry.register_plugin("aries_cloudagent.wallet") plugin_registry.register_plugin("aries_cloudagent.anoncreds.anoncreds") - plugin_registry.register_plugin("aries_cloudagent.anoncreds.anoncreds.default.did_indy_registry") - plugin_registry.register_plugin("aries_cloudagent.anoncreds.anoncreds.default.did_web_registry") - plugin_registry.register_plugin("aries_cloudagent.anoncreds.anoncreds.default.legacy_indy_registry") + plugin_registry.register_plugin( + "aries_cloudagent.anoncreds.anoncreds.default.did_indy_registry" + ) + plugin_registry.register_plugin( + "aries_cloudagent.anoncreds.anoncreds.default.did_web_registry" + ) + plugin_registry.register_plugin( + "aries_cloudagent.anoncreds.anoncreds.default.legacy_indy_registry" + ) if context.settings.get("multitenant.admin_enabled"): plugin_registry.register_plugin("aries_cloudagent.multitenant.admin")