Metadata-Version: 2.4
Name: securevault
Version: 0.1.0
Summary: Python client for SecureVault - secure secrets management
Home-page: https://github.com/jahdev/securevault
Author: JahDev
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.20; extra == "dev"
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: provides-extra
Dynamic: requires-python
Dynamic: summary

# SecureVault Python Client

Python wrapper for the SecureVault CLI tool.

## Installation

```bash
pip install securevault
```

Or install from source:

```bash
cd wrappers/python
pip install -e .
```

## Prerequisites

- SecureVault CLI must be installed and available in your PATH
- Python 3.7 or higher

## Quick Start

```python
from securevault import VaultClient

# Initialize client
vault = VaultClient()

# Set a secret
vault.set('api_key', 'my-secret-key')

# Get a secret
api_key = vault.get('api_key')
print(f"API Key: {api_key}")

# List all secrets
secrets = vault.list()
print(f"Secrets: {secrets}")

# Check if secret exists
if vault.exists('api_key'):
    print("API key is configured")

# Delete a secret
vault.delete('api_key')
```

## Usage Examples

### Context Manager

```python
from securevault import VaultClient

with VaultClient() as vault:
    vault.set('temp_key', 'temp_value')
    value = vault.get('temp_key')
    print(value)
```

### Load Secrets into Environment

```python
from securevault import VaultClient
import os

vault = VaultClient()

# Load all secrets as environment variables
vault.load_env()

# Access from environment
api_key = os.getenv('API_KEY')

# Load with prefix
vault.load_env(prefix='APP_')
# Now accessible as APP_API_KEY, APP_DB_PASSWORD, etc.
```

### Get All Secrets

```python
from securevault import VaultClient

vault = VaultClient()

# Get all secrets as dictionary
secrets = vault.get_all()
for name, value in secrets.items():
    print(f"{name}: {value}")
```

### Export/Import

```python
from securevault import VaultClient

vault = VaultClient()

# Export to JSON
vault.export_to_file('secrets.json')

# Import from JSON
vault.import_from_file('secrets.json')
```

### Async Support

```python
import asyncio
from securevault import AsyncVaultClient

async def main():
    vault = AsyncVaultClient()
    
    # All methods are async
    await vault.set('api_key', 'secret123')
    api_key = await vault.get('api_key')
    print(api_key)
    
    secrets = await vault.list()
    print(secrets)

asyncio.run(main())
```

### Custom CLI Path

```python
from securevault import VaultClient

# Specify custom path to CLI
vault = VaultClient(cli_path='/custom/path/to/securevault')
```

## API Reference

### `VaultClient`

#### Methods

- `get(name: str) -> str` - Get a secret value
- `set(name: str, value: str, description: Optional[str] = None)` - Set a secret
- `delete(name: str)` - Delete a secret
- `list() -> List[str]` - List all secret names
- `exists(name: str) -> bool` - Check if a secret exists
- `get_all() -> Dict[str, str]` - Get all secrets as dictionary
- `load_env(prefix: str = '')` - Load secrets into environment variables
- `export_to_file(filepath: str)` - Export secrets to JSON file
- `import_from_file(filepath: str)` - Import secrets from JSON file

### `AsyncVaultClient`

Async version with the same methods, but all are async/await.

## Error Handling

```python
from securevault import VaultClient, VaultError, SecretNotFoundError

vault = VaultClient()

try:
    value = vault.get('nonexistent')
except SecretNotFoundError:
    print("Secret not found")
except VaultError as e:
    print(f"Vault error: {e}")
```

## Development

### Running Tests

```bash
pip install -e ".[dev]"
pytest
```

### Running Async Tests

```bash
pytest -v tests/test_async.py
```

## License

MIT

## Author

JahDev
