Skip to content

Commit

Permalink
refactor: rearrange plugin structure slightly
Browse files Browse the repository at this point in the history
Since this is not a DIDComm protocol plugin, it doesn't make sense to
follow the same conventions

Signed-off-by: Daniel Bluhm <[email protected]>
  • Loading branch information
dbluhm committed Nov 26, 2023
1 parent d7d51c7 commit c6a6ac7
Show file tree
Hide file tree
Showing 18 changed files with 56 additions and 66 deletions.
2 changes: 1 addition & 1 deletion oid4vci/demo/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ services:
--auto-provision
--log-level debug
--debug-webhooks
--plugin oid4vci.v1_0
--plugin oid4vci
healthcheck:
test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null
start_period: 30s
Expand Down
2 changes: 1 addition & 1 deletion oid4vci/docker/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ endpoint:

# plugins
plugin:
- oid4vci.v1_0
- oid4vci

#config
genesis-url: https://indy.igrant.io/genesis
Expand Down
2 changes: 1 addition & 1 deletion oid4vci/int/afj_runner/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ services:
--auto-provision
--log-level debug
--debug-webhooks
--plugin oid4vci.v1_0
--plugin oid4vci
healthcheck:
test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null
start_period: 30s
Expand Down
2 changes: 1 addition & 1 deletion oid4vci/int/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ services:
--auto-provision
--log-level debug
--debug-webhooks
--plugin oid4vci.v1_0
--plugin oid4vci
healthcheck:
test: curl -s -o /dev/null -w '%{http_code}' "http://localhost:3001/status/live" | grep "200" > /dev/null
start_period: 30s
Expand Down
44 changes: 44 additions & 0 deletions oid4vci/oid4vci/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"""OID4VCI plugin."""

import logging
from os import getenv

from aries_cloudagent.config.injection_context import InjectionContext
from aries_cloudagent.core.event_bus import Event, EventBus
from aries_cloudagent.core.profile import Profile
from aries_cloudagent.core.util import STARTUP_EVENT_PATTERN
from .oid4vci_server import Oid4vciServer
from .config import Config

LOGGER = logging.getLogger(__name__)

OID4VCI_HOST = getenv("OID4VCI_HOST", default="0.0.0.0")
OID4VCI_PORT = int(getenv("OID4VCI_PORT", default="8081"))


async def setup(context: InjectionContext):
"""Setup the plugin."""
LOGGER.info("> oid4vci plugin setup...")
event_bus = context.inject(EventBus)
event_bus.subscribe(STARTUP_EVENT_PATTERN, started_event_handler)
LOGGER.info("< oid4vci plugin setup.")


async def started_event_handler(profile: Profile, event: Event):
"""Event handler for Basic Messages."""
LOGGER.info(event.payload)
try:
config = Config(profile.context)
oid4vci = Oid4vciServer(
config.host,
config.port,
profile.context,
profile,
)
profile.context.injector.bind_instance(Oid4vciServer, oid4vci)
except Exception:
LOGGER.exception("Unable to register admin server")
raise

oid4vci = profile.inject(Oid4vciServer)
await oid4vci.start()
File renamed without changes.
10 changes: 0 additions & 10 deletions oid4vci/oid4vci/definition.py

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 3 additions & 1 deletion oid4vci/oid4vci/v1_0/routes.py → oid4vci/oid4vci/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
GENERIC_DID_VALIDATE,
Uri,
)
from aries_cloudagent.protocols.basicmessage.v1_0.message_types import SPEC_URI
from aries_cloudagent.messaging.models.base import BaseModelError
from aries_cloudagent.storage.error import StorageError, StorageNotFoundError
from aries_cloudagent.wallet.default_verification_key_strategy import (
Expand All @@ -32,6 +31,9 @@
from .models.supported_cred import SupportedCredential
from .models.exchange import OID4VCIExchangeRecord, OID4VCIExchangeRecordSchema

SPEC_URI = (
"https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0-11.html"
)
LOGGER = logging.getLogger(__name__)
code_size = 8 # TODO: check

Expand Down
46 changes: 0 additions & 46 deletions oid4vci/oid4vci/v1_0/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion oid4vci/tests/models/test_exchange.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from aries_cloudagent.core.profile import Profile
import pytest
from oid4vci.v1_0.models.exchange import OID4VCIExchangeRecord
from oid4vci.models.exchange import OID4VCIExchangeRecord


@pytest.fixture
Expand Down
2 changes: 1 addition & 1 deletion oid4vci/tests/models/test_supported_cred.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from aries_cloudagent.core.profile import Profile
import pytest

from oid4vci.v1_0.models.supported_cred import SupportedCredential
from oid4vci.models.supported_cred import SupportedCredential


@pytest.fixture
Expand Down
4 changes: 2 additions & 2 deletions oid4vci/tests/routes/test_admin.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from aiohttp import web
from unittest.mock import AsyncMock
from aries_cloudagent.admin.request_context import AdminRequestContext
from oid4vci.v1_0 import routes as test_module
from oid4vci import routes as test_module
import pytest

from oid4vci.v1_0.models.supported_cred import SupportedCredential
from oid4vci.models.supported_cred import SupportedCredential


@pytest.mark.asyncio
Expand Down
2 changes: 1 addition & 1 deletion oid4vci/tests/routes/test_public_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from aries_cloudagent.admin.request_context import AdminRequestContext
import pytest

from oid4vci.v1_0 import public_routes as test_module
from oid4vci import public_routes as test_module


@pytest.mark.asyncio
Expand Down

0 comments on commit c6a6ac7

Please sign in to comment.