Metadata-Version: 2.4
Name: infra-core-sdk
Version: 0.1.1
Summary: Secure and extensible credential management SDK for Python applications.
Author: Rafael Cavalcante
Project-URL: Homepage, https://github.com/rmcavalcante7/
Project-URL: Repository, https://github.com/rmcavalcante7/infra-core-sdk
Requires-Python: <3.15,>=3.14
Description-Content-Type: text/markdown
Requires-Dist: cryptography>=46.0.6
Provides-Extra: dev
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: black>=24.0.0; extra == "dev"
Requires-Dist: mypy>=1.0.0; extra == "dev"

# 🔐 infra-core-sdk

Secure and extensible credential management SDK for Python applications.

---

## 🚀 Features

* 🔐 Automatic encryption (Fernet)
* 📦 Multiple credential support (`name`)
* ⚙️ Decoupled setup and load flows
* 📁 Automatic path management
* 🧩 Modular and extensible architecture

---

## 📦 Installation

```bash
pip install infra-core-sdk
```

---

## 🧩 Usage

### 🔹 Define your credentials model

```python
from dataclasses import dataclass
from infra_core import BaseCredentials

@dataclass(frozen=True)
class MyCreds(BaseCredentials):
    api_token: str
```

---

### 🔹 Save credentials (setup)

```python
from infra_core import FernetEncryption
from infra_core.credentials.setup.credentials_setup_service import CredentialsSetupService

setup = CredentialsSetupService(FernetEncryption)

setup.setup(
    MyCreds(api_token="123"),
    name="pipefy"
)
```

---

### 🔹 Load credentials

```python
from infra_core import CredentialsLoader, FernetEncryption

creds = CredentialsLoader.load(
    MyCreds,
    FernetEncryption,
    name="pipefy"
)

print(creds.api_token)
```

---

## 📁 Generated structure

```text
your_project/
├── secret/
│   ├── secret.key
│   ├── pipefy.json
```

---

## 🔄 Multiple credentials

```python
setup.setup(..., name="aws")
setup.setup(..., name="stripe")
```

---

## 🔐 Encryption

### Default

```python
from infra_core import FernetEncryption
```

---

### Custom implementation

```python
class CustomEncryption:
    def encrypt(self, value: str) -> str:
        ...

    def decrypt(self, value: str) -> str:
        ...
```

---

## ⚠️ Important rules

### ❌ Do NOT manually create keys

```python
Fernet.generate_key()
FernetEncryption(key)
```

---

### ✅ Let the SDK manage it

```python
CredentialsSetupService(FernetEncryption)
```

---

## 🧠 How it works

```text
SETUP:
    → generates key
    → encrypts data
    → saves file

LOAD:
    → reads key
    → decrypts data
    → returns typed object
```

---

## 🧪 Development

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

---

## 📄 License

MIT

---

## 👨‍💻 Author

Rafael Cavalcante
