Metadata-Version: 2.5
Name: secret-kernel-contracts
Version: 0.1.0a10
Summary: Provider-agnostic contracts for Secret Kernel.
Project-URL: Homepage, https://secret-kernel.foggia.zip/?code=py
Project-URL: Documentation, https://secret-kernel.foggia.zip/?code=py
Project-URL: Source, https://github.com/brunnofoggia/secret-kernel-py/tree/main/packages/contracts
Project-URL: Changelog, https://secret-kernel.foggia.zip/?code=py#changelog
Project-URL: Issues, https://github.com/brunnofoggia/secret-kernel-py/issues
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Typing :: Typed
Requires-Python: >=3.12
Description-Content-Type: text/markdown

# secret-kernel-contracts

Shared provider-agnostic contracts for Secret Kernel: types, error classes and the provider
registry.

Install this distribution alone when your code only declares types or catches errors, such as
a library that receives a client. An application that uses `secret-kernel-factory` gets all
of it from the factory, which re-exports this package.

```bash
uv add secret-kernel-contracts
```

## Usage

```python
from typing import Any

from secret_kernel.contracts import (
    GetSecretOptions,
    KeyValueParseOptions,
    SecretClient,
    SecretParseMode,
)


async def load_database_config(client: SecretClient) -> Any:
    secret = await client.get_secret(
        "database",
        GetSecretOptions(
            parse=SecretParseMode.KEY_VALUE,
            parse_options=KeyValueParseOptions(
                pair_separator=";", key_value_separator="=", trim=True
            ),
        ),
    )

    return secret.value
```

## Public Contract

- `SecretClient`: read-only secret client.
- `SecretParseMode.JSON`: parses the decrypted string as JSON.
- `SecretParseMode.KEY_VALUE`: parses key-value strings such as `user=app;password=secret`.
- `SecretNotFoundError`, `SecretPermissionError`, `SecretParseError`,
  `InvalidSecretNameError`, `SecretCapabilityNotSupportedError`,
  `SecretKernelConfigurationError` and `SecretProviderError`: the shared hierarchy, all
  rooted in `SecretKernelError`.
- `SecretClientOptions`: the client options — `env`, `project`, `prefix`, `parse_options`,
  `cache` and `logger`.
- `SecretLogger`: the observability contract. The `logger` option is an object with one
  optional method per level, each taking a single descriptive string, and it is the only
  sink the kernel writes to. A line whose level the logger does not implement is dropped,
  so `logging.getLogger("my-app")` is a drop-in.

Secret names are resolved as `/env/project/prefix/secret-name`. Every part but the secret
name is optional, and a per-call `prefix` replaces the client's.

## Documentation

The normative public surface is in
[`docs/secret-kernel-api-reference.md`](https://github.com/brunnofoggia/secret-kernel-py/blob/main/docs/secret-kernel-api-reference.md).

## License

MIT
