Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
af550d3
feat: add Kanon Storage as alternative to Askar storage
vinaysingh8866 Aug 19, 2025
9bc9ad9
fix: resolve poetry.lock conflict and update Dockerfile.bdd
vinaysingh8866 Aug 19, 2025
7c4214e
fix: removed libsqlcipher-dev libpq-dev installation
vinaysingh8866 Aug 19, 2025
84202f0
feat: add anoncreds profile type checking
vinaysingh8866 Aug 21, 2025
c73368f
refactor: reorganize and clean up imports
vinaysingh8866 Aug 21, 2025
46441b5
style: fix type annotation formatting
vinaysingh8866 Aug 21, 2025
410cf03
style: fix docstring formatting
vinaysingh8866 Aug 21, 2025
c35c1fc
style: remove unnecessary blank lines
vinaysingh8866 Aug 21, 2025
a1e186b
style: add blank lines for readability
vinaysingh8866 Aug 21, 2025
c065ee8
style: apply general formatting fixes
vinaysingh8866 Aug 21, 2025
411b312
test: add database manager test infrastructure and MongoDB WQL tests
vinaysingh8866 Aug 21, 2025
a14af16
fix: add error translation and optional pymongo imports
vinaysingh8866 Aug 22, 2025
ad0f233
test: skip performance tests in pytest collection
vinaysingh8866 Aug 22, 2025
9646021
fix: apply ruff 0.12.10 formatting
vinaysingh8866 Aug 25, 2025
8d8a6aa
fix: resolve code quality issues
vinaysingh8866 Aug 27, 2025
4633478
style: apply formatting to database components
vinaysingh8866 Aug 27, 2025
17ce22d
refactor: modernize WQL query components
vinaysingh8866 Aug 27, 2025
ba40a96
style: modernize askar error
vinaysingh8866 Aug 28, 2025
40d2477
style: format remaining files
vinaysingh8866 Aug 28, 2025
8ee3108
fix: use negate=True and correct inner.data typing
vinaysingh8866 Aug 29, 2025
6ee85c0
refactor: switch to PEP 604 unions and align signatures
vinaysingh8866 Aug 29, 2025
c48a90d
fix: pass tags={} to update_record instead of None
vinaysingh8866 Aug 29, 2025
48a0e4e
test: remove commented-out blocks and header banners
vinaysingh8866 Aug 29, 2025
ec1052d
refactor: remove commented migration code
vinaysingh8866 Aug 29, 2025
7be78f2
refactor: fixed logical errors and modernised syntax
vinaysingh8866 Aug 29, 2025
75b838b
style: wrap long comment
vinaysingh8866 Sep 6, 2025
9dd0312
test: update v2 tests
vinaysingh8866 Sep 6, 2025
4ab9273
refactor: logging and error mapping
vinaysingh8866 Sep 6, 2025
838fb74
test: update generic tests
vinaysingh8866 Sep 6, 2025
4e3a282
test: update scan generic tests
vinaysingh8866 Sep 6, 2025
44a5edf
test: update scan normalized tests
vinaysingh8866 Sep 6, 2025
ce0e3f6
test: remove commented code
vinaysingh8866 Sep 6, 2025
740059c
refactor: mask pass_key and seed in logs
vinaysingh8866 Sep 6, 2025
33242de
test: add Kanon storage tests
vinaysingh8866 Sep 6, 2025
95bb193
test: tidy imports
vinaysingh8866 Sep 6, 2025
4c43bd3
test: add public DID tests
vinaysingh8866 Sep 6, 2025
f398dee
test: remove commented code
vinaysingh8866 Sep 6, 2025
7d48408
test: add key tests
vinaysingh8866 Sep 6, 2025
7528073
test: add holder unit tests
vinaysingh8866 Sep 6, 2025
89dc003
test: add issuer unit tests
vinaysingh8866 Sep 6, 2025
dc4443d
test(multitenant): add kanon manager test
vinaysingh8866 Sep 6, 2025
1849c5e
test(dbstore): add postgres encoder unit
vinaysingh8866 Sep 6, 2025
9da2ae1
test(dbstore): add or update test_backend_registration_unit.py
vinaysingh8866 Sep 6, 2025
0f1f8fb
test(dbstore): add or update test_category_registry_unit.py
vinaysingh8866 Sep 6, 2025
202bd5c
test(dbstore): add or update test_dbstore_async_scan_unit.py
vinaysingh8866 Sep 6, 2025
0174bde
test(dbstore): add or update test_dbstore_backend_errors_unit.py
vinaysingh8866 Sep 6, 2025
2592ca5
test(dbstore): add or update test_dbstore_context_exceptions_unit.py
vinaysingh8866 Sep 6, 2025
298c269
test(dbstore): add or update test_dbstore_context_unit.py
vinaysingh8866 Sep 6, 2025
69a86c4
test(dbstore): add or update test_dbstore_initialize_and_open_guards_…
vinaysingh8866 Sep 6, 2025
ed3e2f8
test(dbstore): add or update test_dbstore_profiles_rekey_unit.py
vinaysingh8866 Sep 6, 2025
434ccd6
test(dbstore): add or update test_dbstore_scan_wrappers_unit.py
vinaysingh8866 Sep 6, 2025
ed37f01
test(dbstore): add or update test_dbstore_sessions_guards_unit.py
vinaysingh8866 Sep 6, 2025
b9b14dd
test(dbstore): add or update test_dbstore_success_backend_unit.py
vinaysingh8866 Sep 6, 2025
3cc81fe
test(dbstore): add or update test_key_unit.py
vinaysingh8866 Sep 6, 2025
9f23568
test(dbstore): add or update test_sqlite_config_migrations_happy_and_…
vinaysingh8866 Sep 6, 2025
3f66732
test(dbstore): add or update test_sqlite_config_migrations_unit.py
vinaysingh8866 Sep 6, 2025
2b207ee
test(dbstore): add or update test_sqlite_config_open_edge_cases_unit.py
vinaysingh8866 Sep 6, 2025
1fcbf6d
test(dbstore): add or update test_sqlite_config_open_mismatch_enforce…
vinaysingh8866 Sep 6, 2025
88492a1
test(dbstore): add or update test_sqlite_config_open_mismatch_unit.py
vinaysingh8866 Sep 6, 2025
5c23d73
test(dbstore): add or update test_sqlite_config_schema_branches_unit.py
vinaysingh8866 Sep 6, 2025
75e128d
test(dbstore): add or update test_sqlite_config_unit.py
vinaysingh8866 Sep 6, 2025
4238783
test(dbstore): add or update test_sqlite_session_enter_exit_translate…
vinaysingh8866 Sep 6, 2025
746164f
test(dbstore): add or update test_sqlite_session_paths_unit.py
vinaysingh8866 Sep 6, 2025
26dd705
test(dbstore): add or update test_sqlite_session_translate_error_unit.py
vinaysingh8866 Sep 6, 2025
acb86df
test(kanon): add or update test_didcomm_v1_unit.py
vinaysingh8866 Sep 6, 2025
485e7b7
test(kanon): add or update test_didcomm_v2_unit.py
vinaysingh8866 Sep 6, 2025
54bc734
test(kanon): add or update test_profile_anon_kanon_providers_unit.py
vinaysingh8866 Sep 6, 2025
f5791e0
test(kanon): add or update test_profile_anon_kanon_unit.py
vinaysingh8866 Sep 6, 2025
af620b6
test(kanon): add or update test_profile_manager_unit.py
vinaysingh8866 Sep 6, 2025
09d2972
test(kanon): add or update test_store_kanon_unit.py
vinaysingh8866 Sep 6, 2025
330e10f
style(ruff): applied ruff formating
vinaysingh8866 Sep 8, 2025
39847e9
fix(kanon-test): fixed failing error
vinaysingh8866 Sep 8, 2025
043ffad
merge: fixed lock file
vinaysingh8866 Sep 8, 2025
268639d
fix:skipped pool test due to async issues in test environment
vinaysingh8866 Sep 8, 2025
451f96a
fix:added skip mark with pytest
vinaysingh8866 Sep 8, 2025
eea3897
fix(tests): removed simple namespace issues
vinaysingh8866 Sep 9, 2025
401cf04
refactor: using db error to make exception syntax better
vinaysingh8866 Sep 9, 2025
c88295a
style: applied ruff formating
vinaysingh8866 Sep 9, 2025
027a480
style: rename self_inner to self
vinaysingh8866 Sep 9, 2025
a8b890c
style: removed unused variables and fixed minor issues
vinaysingh8866 Sep 10, 2025
26d45b7
fix: fixed kanon holder to handle both qualifies and unqialified dids
vinaysingh8866 Sep 10, 2025
998b10e
fix: removed unused variables and reverted async to needed functions
vinaysingh8866 Sep 10, 2025
3626c22
fix: fixed holder and storage to handle both sync and async
vinaysingh8866 Sep 10, 2025
0dfbdaa
style: fixed line too long issues
vinaysingh8866 Sep 10, 2025
128e347
style: fixed sonar issues
vinaysingh8866 Sep 10, 2025
795194e
style: reverted parms in key and config
vinaysingh8866 Sep 10, 2025
42810ee
style: applied ruff formating
vinaysingh8866 Sep 10, 2025
bd51ab2
fix: fixed sonar issues
vinaysingh8866 Sep 10, 2025
15a477f
fix: fixed logging issues
vinaysingh8866 Sep 13, 2025
c44ab36
fix: fixed logging issues
vinaysingh8866 Sep 13, 2025
1280e8c
style: applied ruff formatting
vinaysingh8866 Sep 15, 2025
ff3515e
fix: fix tests
vinaysingh8866 Sep 19, 2025
f8f8c48
chore: updated poetry lock
vinaysingh8866 Sep 19, 2025
2f934a1
fix: minor import fix
vinaysingh8866 Sep 19, 2025
5238ff2
fix:added tests to not be included in coverage
vinaysingh8866 Oct 6, 2025
f196bf1
fix:changed error check to use new DBError
vinaysingh8866 Oct 6, 2025
42dbd8e
fix:fixed tests
vinaysingh8866 Oct 7, 2025
d4773b5
fix:fixed poetry lock
vinaysingh8866 Oct 7, 2025
107e21c
fix:removed duplicate function
vinaysingh8866 Oct 7, 2025
cd45834
Merge upstream changes
vinaysingh8866 Oct 7, 2025
228859a
style:apllied ruff formatting
vinaysingh8866 Oct 7, 2025
522d1fa
style:added arg names to fix the errors
vinaysingh8866 Oct 7, 2025
3854e6d
fix:handle missing rev_reg_id safely
vinaysingh8866 Oct 7, 2025
a8a8d92
style:apllied ruff formating
vinaysingh8866 Oct 7, 2025
22bb2df
fix:removed reduanant code
vinaysingh8866 Oct 7, 2025
f2db0fc
style:moved test files
vinaysingh8866 Oct 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .devcontainer/post-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ markers = [
"postgres: Tests relating to the postgres storage plugin for Indy"]
junit_family = "xunit1"
asyncio_mode = auto
asyncio_default_fixture_loop_scope = module
EOF
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,7 @@ _build/
open-api/.build

# devcontainer
.pytest.ini
.pytest.ini

# test lock files
acatest.lock
4 changes: 3 additions & 1 deletion acapy_agent/anoncreds/error_messages.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""Error messages for anoncreds."""

ANONCREDS_PROFILE_REQUIRED_MSG = "AnonCreds interface requires AskarAnonCreds profile"
ANONCREDS_PROFILE_REQUIRED_MSG = (
"AnonCreds interface requires AskarAnonCreds or KanonAnonCreds profile"
)
40 changes: 28 additions & 12 deletions acapy_agent/anoncreds/holder.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
W3cPresentation,
create_link_secret,
)
from aries_askar import AskarError, AskarErrorCode
from marshmallow import INCLUDE
from pyld import jsonld
from pyld.jsonld import JsonLdProcessor
from uuid_utils import uuid4

from ..askar.profile_anon import AskarAnonCredsProfile
from ..core.error import BaseError
from ..core.profile import Profile
from ..database_manager.db_errors import DBCode, DBError
from ..storage.vc_holder.base import VCHolder
from ..storage.vc_holder.vc_record import VCRecord
from ..vc.ld_proofs import DocumentLoader
Expand Down Expand Up @@ -78,11 +77,28 @@ def __init__(self, profile: Profile):
self._profile = profile

@property
def profile(self) -> AskarAnonCredsProfile:
def profile(self) -> Profile:
"""Accessor for the profile instance."""
if not isinstance(self._profile, AskarAnonCredsProfile):
# Check if profile is AskarAnonCredsProfile or KanonAnonCredsProfile
# by checking the backend attribute
if not isinstance(self._profile, Profile):
raise ValueError(ANONCREDS_PROFILE_REQUIRED_MSG)

# Check if it's a supported anoncreds profile type
if hasattr(self._profile, "backend"):
backend = (
self._profile.backend.lower()
if isinstance(self._profile.backend, str)
else ""
)
if "anoncreds" not in backend and "kanon" not in backend:
raise ValueError(ANONCREDS_PROFILE_REQUIRED_MSG)
else:
# For AskarAnonCredsProfile, check the class name
class_name = self._profile.__class__.__name__
if "AnonCreds" not in class_name and "Kanon" not in class_name:
raise ValueError(ANONCREDS_PROFILE_REQUIRED_MSG)

return self._profile

async def get_master_secret(self) -> str:
Expand All @@ -93,7 +109,7 @@ async def get_master_secret(self) -> str:
record = await session.handle.fetch(
CATEGORY_MASTER_SECRET, AnonCredsHolder.MASTER_SECRET_ID
)
except AskarError as err:
except DBError as err:
raise AnonCredsHolderError("Error fetching master secret") from err
if record:
try:
Expand All @@ -116,8 +132,8 @@ async def get_master_secret(self) -> str:
AnonCredsHolder.MASTER_SECRET_ID,
secret,
)
except AskarError as err:
if err.code != AskarErrorCode.DUPLICATE:
except DBError as err:
if err.code not in DBCode.DUPLICATE:
raise AnonCredsHolderError(
"Error saving master secret"
) from err
Expand Down Expand Up @@ -270,7 +286,7 @@ async def _finish_store_credential(
value_json=mime_types,
)
await txn.commit()
except AskarError as err:
except DBError as err:
raise AnonCredsHolderError("Error storing credential") from err

return credential_id
Expand Down Expand Up @@ -393,7 +409,7 @@ async def get_credentials(self, *, offset: int, limit: int, wql: dict) -> list[d
async for row in rows:
cred = Credential.load(row.raw_value)
result.append(_make_cred_info(row.name, cred))
except AskarError as err:
except DBError as err:
raise AnonCredsHolderError("Error retrieving credentials") from err
except AnoncredsError as err:
raise AnonCredsHolderError("Error loading stored credential") from err
Expand Down Expand Up @@ -493,7 +509,7 @@ async def _get_credential(self, credential_id: str) -> Credential:
try:
async with self.profile.session() as session:
cred = await session.handle.fetch(CATEGORY_CREDENTIAL, credential_id)
except AskarError as err:
except DBError as err:
raise AnonCredsHolderError("Error retrieving credential") from err

if not cred:
Expand Down Expand Up @@ -555,7 +571,7 @@ async def delete_credential(self, credential_id: str) -> None:
await session.handle.remove(
AnonCredsHolder.RECORD_TYPE_MIME_TYPES, credential_id
)
except AskarError as err:
except DBError as err:
raise AnonCredsHolderError(
"Error deleting credential", error_code=err.code
) from err
Expand All @@ -579,7 +595,7 @@ async def get_mime_type(
AnonCredsHolder.RECORD_TYPE_MIME_TYPES,
credential_id,
)
except AskarError as err:
except DBError as err:
raise AnonCredsHolderError("Error retrieving credential mime types") from err
values = mime_types_record and mime_types_record.value_json
if values:
Expand Down
41 changes: 29 additions & 12 deletions acapy_agent/anoncreds/issuer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
Schema,
W3cCredential,
)
from aries_askar import AskarError

from ..askar.profile_anon import AskarAnonCredsProfile, AskarAnonCredsProfileSession
from ..core.error import BaseError
from ..core.event_bus import Event, EventBus
from ..core.profile import Profile
from ..core.profile import Profile, ProfileSession
from ..database_manager.db_errors import DBError
from ..protocols.endorse_transaction.v1_0.util import is_author_role
from .base import AnonCredsSchemaAlreadyExists, BaseAnonCredsError
from .error_messages import ANONCREDS_PROFILE_REQUIRED_MSG
Expand Down Expand Up @@ -91,11 +90,28 @@ def __init__(self, profile: Profile):
self._profile = profile

@property
def profile(self) -> AskarAnonCredsProfile:
def profile(self) -> Profile:
"""Accessor for the profile instance."""
if not isinstance(self._profile, AskarAnonCredsProfile):
# Check if profile is AskarAnonCredsProfile or KanonAnonCredsProfile
# by checking the backend attribute
if not isinstance(self._profile, Profile):
raise ValueError(ANONCREDS_PROFILE_REQUIRED_MSG)

# Check if it's a supported anoncreds profile type
if hasattr(self._profile, "backend"):
backend = (
self._profile.backend.lower()
if isinstance(self._profile.backend, str)
else ""
)
if "anoncreds" not in backend and "kanon" not in backend:
raise ValueError(ANONCREDS_PROFILE_REQUIRED_MSG)
else:
# For AskarAnonCredsProfile, check the class name
class_name = self._profile.__class__.__name__
if "AnonCreds" not in class_name and "Kanon" not in class_name:
raise ValueError(ANONCREDS_PROFILE_REQUIRED_MSG)

return self._profile

async def notify(self, event: Event) -> None:
Expand All @@ -105,7 +121,7 @@ async def notify(self, event: Event) -> None:

async def _finish_registration(
self,
txn: AskarAnonCredsProfileSession,
txn: ProfileSession,
category: str,
job_id: str,
registered_id: str,
Expand Down Expand Up @@ -153,7 +169,7 @@ async def store_schema(
"state": result.schema_state.state,
},
)
except AskarError as err:
except DBError as err:
raise AnonCredsIssuerError("Error storing schema") from err

async def create_and_register_schema(
Expand Down Expand Up @@ -281,7 +297,7 @@ async def credential_definition_in_wallet(
CATEGORY_CRED_DEF_PRIVATE, credential_definition_id
)
) is not None
except AskarError as err:
except DBError as err:
raise AnonCredsIssuerError(
"Error checking for credential definition"
) from err
Expand Down Expand Up @@ -439,7 +455,8 @@ async def store_credential_definition(
options=options,
)
)
except AskarError as err:

except DBError as err:
raise AnonCredsIssuerError("Error storing credential definition") from err

async def finish_cred_def(
Expand Down Expand Up @@ -574,7 +591,7 @@ async def create_credential_offer(self, credential_definition_id: str) -> str:
key_proof = await session.handle.fetch(
CATEGORY_CRED_DEF_KEY_PROOF, credential_definition_id
)
except AskarError as err:
except DBError as err:
raise AnonCredsIssuerError("Error retrieving credential definition") from err
if not cred_def or not key_proof:
raise AnonCredsIssuerError(
Expand Down Expand Up @@ -615,7 +632,7 @@ async def create_credential(
cred_def_private = await session.handle.fetch(
CATEGORY_CRED_DEF_PRIVATE, cred_def_id
)
except AskarError as err:
except DBError as err:
raise AnonCredsIssuerError("Error retrieving credential definition") from err

if not cred_def or not cred_def_private:
Expand Down Expand Up @@ -672,7 +689,7 @@ async def create_credential_w3c(
cred_def_private = await session.handle.fetch(
CATEGORY_CRED_DEF_PRIVATE, cred_def_id
)
except AskarError as err:
except DBError as err:
raise AnonCredsIssuerError("Error retrieving credential definition") from err

if not cred_def or not cred_def_private:
Expand Down
Loading
Loading