Coverage for src / lexigram / contracts / security / stores.py: 0%
9 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-15 18:57 +0800
« prev ^ index » next coverage.py v7.13.5, created at 2026-08-15 18:57 +0800
1"""Async persistent secret store protocol.
3Unlike the synchronous :class:`~lexigram.contracts.security.secrets.SecretStoreProtocol`
4(which targets external secret managers such as Vault or AWS Secrets Manager),
5this protocol targets database-backed secret tables where async I/O is required.
6It is intentionally minimal — no rotation, no versioning — leaving those concerns
7to the implementation layer.
9Implementations ship in ``lexigram-sql`` (``lexigram.sql.stores``) so they can share
10the application's database connection pool.
12Example::
14 from lexigram.contracts.security.stores import AsyncSecretStoreProtocol
16 store = await container.resolve(AsyncSecretStoreProtocol)
17 token = await store.get("stripe_api_key")
18"""
20from __future__ import annotations
22from typing import Protocol, runtime_checkable
25@runtime_checkable
26class AsyncSecretStoreProtocol(Protocol):
27 """Async persistent store for sensitive named secret values.
29 Typical usage::
31 store = await container.resolve(AsyncSecretStoreProtocol)
32 token = await store.get("stripe_api_key")
33 """
35 async def get(self, name: str) -> str | None:
36 """Return the secret value for *name*, or ``None`` if absent.
38 Args:
39 name: Unique secret identifier.
40 """
41 ...
43 async def get_bulk(self, *names: str) -> dict[str, str]:
44 """Return a mapping of name → value for all requested secrets.
46 Args:
47 names: One or more secret names.
49 Returns:
50 Dict containing only the names that were found.
51 """
52 ...
54 async def set(self, name: str, value: str) -> None:
55 """Write or overwrite a secret value.
57 Args:
58 name: Unique secret identifier.
59 value: Plaintext secret value.
60 """
61 ...
63 async def delete(self, name: str) -> None:
64 """Remove a secret. No-op if absent.
66 Args:
67 name: Unique secret identifier.
68 """
69 ...
72__all__ = ["AsyncSecretStoreProtocol"]