Metadata-Version: 2.4
Name: spax-secret
Version: 1.1.4
Summary: Secret manager library for sixpetal network
Author-email: Prashant Kumar Prasad <info@sixpetal.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/krprashant94/spax-secret
Project-URL: Issues, https://github.com/krprashant94/spax-secret/issues
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: cryptography>=48.0.0
Requires-Dist: httpx>=0.28.1
Requires-Dist: pydantic>=2.13.4
Dynamic: license-file

# spax-secret

spax-secret is a Python client library for reading, writing, and validating secrets through the Sixpetal secret service.

It helps applications keep sensitive values such as API keys, database credentials, and configuration tokens outside source control while still retrieving them securely at runtime.

## Install

```bash
pip install spax-secret
```

## Quick start

```python
from spax_secret import SecretManager

client = SecretManager(
    project="my-project",
    enviroment="development",
    provider="https://secret.example.com",
)

client.set("API_KEY", "super-secret-value")
print(client.get("API_KEY"))
```

## Features

- Store secret values for a project and environment
- Read single or multiple secrets in one call
- Keep a local in-memory cache for repeated reads
- Verify signed payloads before returning decrypted values
- Use batch helpers for queued writes and reads

## Basic usage

### Create a client

```python
from spax_secret import SecretManager

client = SecretManager(
    project="my-project",
    enviroment="production",
    provider="https://secret.example.com",
)
```

### Read a secret

```python
api_key = client.get("API_KEY")
print(api_key)
```

### Write a secret

```python
client.set("API_KEY", "new-value")
```

### Read multiple secrets

```python
values = client.get_all(["API_KEY", "DB_HOST", "REDIS_URL"])
for item in values:
    print(item.key, item.value)
```

### Dictionary-style access

```python
client["APP_NAME"] = "spax-secret"
print(client["APP_NAME"])
```

## API summary

`SecretManager` supports the following main operations:

- `get(key)` — fetch one secret value
- `get_all(keys)` — fetch multiple secret values
- `set(key, value)` — set one secret value
- `set_all(items)` — set multiple secret values
- `queue_get_batch(key)` / `get_batch_value()` — queue and execute read operations
- `queue_set_batch(key, value)` / `set_batch_value()` — queue and execute write operations

## Notes

- The constructor parameter is named `enviroment` in the package source, matching the service contract.
- The client expects a remote secret service base URL such as `https://secret.example.com`.
- Use HTTPS in production and keep secret values out of logs and source control.
- If the backend response has an invalid signature, the client raises a `ValueError` when decrypting a protected value.

## Requirements

- Python >= 3.12
- `httpx`
- `pydantic`
- `cryptography`

## License

MIT
