forked from openwallet-foundation/acapy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openwallet-foundation#108 from Indicio-tech/featur…
…e/anoncreds-plugin-structure feat: add plugin structure
- Loading branch information
Showing
14 changed files
with
445 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
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 AnonCredsRegistry instance found in context") | ||
return | ||
|
||
indy_registry = ClassProvider( | ||
"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", | ||
).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="", | ||
).provide(context.settings, context.injector) | ||
await legacy_indy_registry.setup(context) | ||
registry.register_registry(legacy_indy_registry) | ||
|
||
# TODO: add context.settings |
69 changes: 69 additions & 0 deletions
69
aries_cloudagent/anoncreds/anoncreds/anoncreds_registry.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
"""AnonCreds Registry""" | ||
import logging | ||
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(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: 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) | ||
|
||
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.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
"""Base Registry""" | ||
from abc import ABC, abstractmethod | ||
from typing import List | ||
from ...config.injection_context import InjectionContext | ||
|
||
from .models import ( | ||
AnonCredsRegistryGetCredentialDefinition, | ||
AnonCredsRegistryGetRevocationList, | ||
AnonCredsRegistryGetRevocationRegistryDefinition, | ||
AnonCredsRegistryGetSchema, | ||
) | ||
|
||
|
||
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.""" | ||
|
||
@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.""" |
Empty file.
51 changes: 51 additions & 0 deletions
51
aries_cloudagent/anoncreds/anoncreds/default/did_indy_registry/registry.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
"""DID Indy Registry""" | ||
from ...models import ( | ||
AnonCredsRegistryGetCredentialDefinition, | ||
AnonCredsRegistryGetRevocationList, | ||
AnonCredsRegistryGetRevocationRegistryDefinition, | ||
AnonCredsRegistryGetSchema, | ||
) | ||
from .....config.injection_context import InjectionContext | ||
from ...anoncreds_registry import BaseRegistry | ||
|
||
|
||
class DIDIndyRegistry(BaseRegistry): | ||
"""DIDIndyRegistry""" | ||
|
||
async def setup(self, context: InjectionContext): | ||
"""Setup.""" | ||
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.""" |
1 change: 1 addition & 0 deletions
1
aries_cloudagent/anoncreds/anoncreds/default/did_indy_registry/routes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Routes for DID Indy Registry""" |
Empty file.
51 changes: 51 additions & 0 deletions
51
aries_cloudagent/anoncreds/anoncreds/default/did_web_registry/registry.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
"""DID Web Registry""" | ||
from ...models import ( | ||
AnonCredsRegistryGetCredentialDefinition, | ||
AnonCredsRegistryGetRevocationList, | ||
AnonCredsRegistryGetRevocationRegistryDefinition, | ||
AnonCredsRegistryGetSchema, | ||
) | ||
from .....config.injection_context import InjectionContext | ||
from ...anoncreds_registry import BaseRegistry | ||
|
||
|
||
class DIDWebRegistry(BaseRegistry): | ||
"""DIDWebRegistry""" | ||
|
||
async def setup(self, context: InjectionContext): | ||
"""Setup.""" | ||
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.""" |
1 change: 1 addition & 0 deletions
1
aries_cloudagent/anoncreds/anoncreds/default/did_web_registry/routes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Routes for DID Web Registry""" |
Empty file.
51 changes: 51 additions & 0 deletions
51
aries_cloudagent/anoncreds/anoncreds/default/legacy_indy_registry/registry.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
"""Legacy Indy Registry""" | ||
from ...models import ( | ||
AnonCredsRegistryGetCredentialDefinition, | ||
AnonCredsRegistryGetRevocationList, | ||
AnonCredsRegistryGetRevocationRegistryDefinition, | ||
AnonCredsRegistryGetSchema, | ||
) | ||
from .....config.injection_context import InjectionContext | ||
from ...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.""" |
1 change: 1 addition & 0 deletions
1
aries_cloudagent/anoncreds/anoncreds/default/legacy_indy_registry/routes.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Routes for Legacy Indy Registry""" |
Oops, something went wrong.