infra-core-sdk 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. infra_core_sdk-0.1.0/PKG-INFO +275 -0
  2. infra_core_sdk-0.1.0/README.md +259 -0
  3. infra_core_sdk-0.1.0/pyproject.toml +37 -0
  4. infra_core_sdk-0.1.0/setup.cfg +4 -0
  5. infra_core_sdk-0.1.0/src/infra_core/__init__.py +27 -0
  6. infra_core_sdk-0.1.0/src/infra_core/core/__init__.py +25 -0
  7. infra_core_sdk-0.1.0/src/infra_core/core/path/__init__.py +8 -0
  8. infra_core_sdk-0.1.0/src/infra_core/core/path/exceptions.py +22 -0
  9. infra_core_sdk-0.1.0/src/infra_core/core/path/path_config.py +51 -0
  10. infra_core_sdk-0.1.0/src/infra_core/core/path/path_manager.py +124 -0
  11. infra_core_sdk-0.1.0/src/infra_core/core/path/root_resolver.py +99 -0
  12. infra_core_sdk-0.1.0/src/infra_core/credentials/__init__.py +0 -0
  13. infra_core_sdk-0.1.0/src/infra_core/credentials/exceptions/__init__.py +0 -0
  14. infra_core_sdk-0.1.0/src/infra_core/credentials/exceptions/credentials_exceptions.py +156 -0
  15. infra_core_sdk-0.1.0/src/infra_core/credentials/models/__init__.py +0 -0
  16. infra_core_sdk-0.1.0/src/infra_core/credentials/models/base_credentials.py +211 -0
  17. infra_core_sdk-0.1.0/src/infra_core/credentials/services/__init__.py +0 -0
  18. infra_core_sdk-0.1.0/src/infra_core/credentials/services/credentials_loader.py +280 -0
  19. infra_core_sdk-0.1.0/src/infra_core/credentials/services/credentials_service.py +249 -0
  20. infra_core_sdk-0.1.0/src/infra_core/credentials/setup/__init__.py +0 -0
  21. infra_core_sdk-0.1.0/src/infra_core/credentials/setup/credentials_setup_service.py +170 -0
  22. infra_core_sdk-0.1.0/src/infra_core/credentials/setup/secret_key_service.py +128 -0
  23. infra_core_sdk-0.1.0/src/infra_core/security/__init__.py +0 -0
  24. infra_core_sdk-0.1.0/src/infra_core/security/encryption_factory.py +75 -0
  25. infra_core_sdk-0.1.0/src/infra_core/security/fernet_encryption.py +130 -0
  26. infra_core_sdk-0.1.0/src/infra_core_sdk.egg-info/PKG-INFO +275 -0
  27. infra_core_sdk-0.1.0/src/infra_core_sdk.egg-info/SOURCES.txt +31 -0
  28. infra_core_sdk-0.1.0/src/infra_core_sdk.egg-info/dependency_links.txt +1 -0
  29. infra_core_sdk-0.1.0/src/infra_core_sdk.egg-info/requires.txt +7 -0
  30. infra_core_sdk-0.1.0/src/infra_core_sdk.egg-info/top_level.txt +1 -0
  31. infra_core_sdk-0.1.0/tests/test_loader.py +82 -0
  32. infra_core_sdk-0.1.0/tests/test_service.py +86 -0
  33. infra_core_sdk-0.1.0/tests/test_setup.py +90 -0
@@ -0,0 +1,275 @@
1
+ Metadata-Version: 2.4
2
+ Name: infra-core-sdk
3
+ Version: 0.1.0
4
+ Summary: Secure and extensible credential management SDK for Python applications.
5
+ Author: Rafael Cavalcante
6
+ Project-URL: Homepage, https://github.com/rmcavalcante7/
7
+ Project-URL: Repository, https://github.com/rmcavalcante7/infra-core-sdk
8
+ Requires-Python: <3.15,>=3.14
9
+ Description-Content-Type: text/markdown
10
+ Requires-Dist: cryptography>=46.0.6
11
+ Provides-Extra: dev
12
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
13
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
14
+ Requires-Dist: black>=24.0.0; extra == "dev"
15
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
16
+
17
+ # 🔐 infra_core
18
+
19
+ **infra_core** é um SDK Python para gerenciamento seguro de credenciais com suporte a criptografia automática, múltiplos ambientes e arquitetura extensível.
20
+
21
+ ---
22
+
23
+ ## 🚀 Features
24
+
25
+ * 🔐 Criptografia automática (Fernet)
26
+ * 📦 Suporte a múltiplas credenciais (`name`)
27
+ * ⚙️ Setup e Load desacoplados
28
+ * 📁 Gerenciamento automático de paths
29
+ * 🧩 Arquitetura modular e extensível
30
+ * 🔄 Compatível com `pip install -e` (desenvolvimento)
31
+
32
+ ---
33
+
34
+ ## 📦 Instalação
35
+
36
+ ### 🔹 Desenvolvimento (recomendado)
37
+
38
+ Dentro do projeto que irá **usar o SDK**:
39
+
40
+ ```bash
41
+ pip install -e caminho/para/infra_core
42
+ ```
43
+
44
+ Exemplo:
45
+
46
+ ```bash
47
+ pip install -e C:\Users\rafael.m.cavalcante\PycharmProjects\infra_core
48
+ ```
49
+
50
+ ---
51
+
52
+ ### 🔹 Produção
53
+
54
+ ```bash
55
+ pip install infra-core
56
+ ```
57
+
58
+ ---
59
+
60
+ ## 🧱 Estrutura esperada
61
+
62
+ Após o uso:
63
+
64
+ ```
65
+ seu_projeto/
66
+ ├── main.py
67
+ ├── secret/
68
+ │ ├── secret.key
69
+ │ ├── aws.json
70
+ │ ├── pipefy.json
71
+ ```
72
+
73
+ ---
74
+
75
+ ## 🧠 Conceitos principais
76
+
77
+ ### 🔑 Secret Key
78
+
79
+ * Gerada automaticamente no primeiro uso
80
+ * Armazenada em `secret/secret.key`
81
+ * Nunca deve ser criada manualmente
82
+
83
+ ---
84
+
85
+ ### 📄 Credenciais
86
+
87
+ * Cada credencial é armazenada em um arquivo separado
88
+ * Nome controlado pelo parâmetro `name`
89
+
90
+ ```python
91
+ name="aws" → secret/aws.json
92
+ ```
93
+
94
+ ---
95
+
96
+ ## 🧩 Criando um modelo de credenciais
97
+
98
+ ```python
99
+ from dataclasses import dataclass
100
+ from infra_core import BaseCredentials
101
+
102
+ @dataclass(frozen=True)
103
+ class MyCreds(BaseCredentials):
104
+ api_token: str
105
+ ```
106
+
107
+ ---
108
+
109
+ ## 💾 Salvando credenciais (Setup)
110
+
111
+ ```python
112
+ from infra_core import FernetEncryption
113
+ from infra_core.credentials.setup.credentials_setup_service import CredentialsSetupService
114
+
115
+ setup = CredentialsSetupService(FernetEncryption)
116
+
117
+ setup.setup(
118
+ MyCreds(api_token="123"),
119
+ name="pipefy"
120
+ )
121
+ ```
122
+
123
+ ---
124
+
125
+ ## 🔓 Carregando credenciais (Load)
126
+
127
+ ```python
128
+ from infra_core import CredentialsLoader, FernetEncryption
129
+
130
+ creds = CredentialsLoader.load(
131
+ MyCreds,
132
+ FernetEncryption,
133
+ name="pipefy"
134
+ )
135
+
136
+ print(creds.api_token)
137
+ ```
138
+
139
+ ---
140
+
141
+ ## 🔄 Multi-credenciais
142
+
143
+ ```python
144
+ setup.setup(..., name="aws")
145
+ setup.setup(..., name="pipefy")
146
+ setup.setup(..., name="stripe")
147
+ ```
148
+
149
+ ---
150
+
151
+ ## 🔐 Encryption
152
+
153
+ ### Default
154
+
155
+ ```python
156
+ from infra_core import FernetEncryption
157
+ ```
158
+
159
+ ---
160
+
161
+ ### Custom (avançado)
162
+
163
+ ```python
164
+ class CustomEncryption:
165
+ def encrypt(self, value: str) -> str:
166
+ ...
167
+
168
+ def decrypt(self, value: str) -> str:
169
+ ...
170
+ ```
171
+
172
+ ---
173
+
174
+ ## ⚠️ Regras importantes
175
+
176
+ ### ❌ Não faça
177
+
178
+ ```python
179
+ Fernet.generate_key()
180
+ FernetEncryption(key)
181
+ ```
182
+
183
+ ---
184
+
185
+ ### ✅ Faça
186
+
187
+ ```python
188
+ CredentialsSetupService(FernetEncryption)
189
+ ```
190
+
191
+ ---
192
+
193
+ ## 🧪 Testes
194
+
195
+ ```bash
196
+ pytest tests
197
+ ```
198
+
199
+ ---
200
+
201
+ ## 🧠 Arquitetura
202
+
203
+ ```
204
+ infra_core/
205
+ ├── core/ # Path management
206
+ ├── credentials/
207
+ │ ├── models/ # BaseCredentials
208
+ │ ├── services/ # Load / Save
209
+ │ ├── setup/ # Setup flow
210
+ │ └── exceptions/
211
+ ├── security/ # Encryption
212
+ ```
213
+
214
+ ---
215
+
216
+ ## ⚠️ Problemas comuns
217
+
218
+ ### ModuleNotFoundError
219
+
220
+ ```bash
221
+ pip install -e caminho/infra_core
222
+ ```
223
+
224
+ ---
225
+
226
+ ### Dependência não encontrada
227
+
228
+ ```bash
229
+ pip install cryptography
230
+ ```
231
+
232
+ ---
233
+
234
+ ### PyCharm não reconhece imports
235
+
236
+ ```
237
+ File → Invalidate Caches → Restart
238
+ ```
239
+
240
+ ---
241
+
242
+ ## 🎯 Fluxo completo
243
+
244
+ ```
245
+ SETUP:
246
+ → gera key
247
+ → criptografa
248
+ → salva arquivo
249
+
250
+ LOAD:
251
+ → lê key
252
+ → descriptografa
253
+ → retorna objeto tipado
254
+ ```
255
+
256
+ ---
257
+
258
+ ## 🚀 Roadmap
259
+
260
+ * [ ] CLI (`infra-core setup`)
261
+ * [ ] Registry de credenciais
262
+ * [ ] Multi-env (dev/prod)
263
+ * [ ] Publish no PyPI
264
+
265
+ ---
266
+
267
+ ## 📄 Licença
268
+
269
+ MIT
270
+
271
+ ---
272
+
273
+ ## 👨‍💻 Autor
274
+
275
+ Rafael Cavalcante
@@ -0,0 +1,259 @@
1
+ # 🔐 infra_core
2
+
3
+ **infra_core** é um SDK Python para gerenciamento seguro de credenciais com suporte a criptografia automática, múltiplos ambientes e arquitetura extensível.
4
+
5
+ ---
6
+
7
+ ## 🚀 Features
8
+
9
+ * 🔐 Criptografia automática (Fernet)
10
+ * 📦 Suporte a múltiplas credenciais (`name`)
11
+ * ⚙️ Setup e Load desacoplados
12
+ * 📁 Gerenciamento automático de paths
13
+ * 🧩 Arquitetura modular e extensível
14
+ * 🔄 Compatível com `pip install -e` (desenvolvimento)
15
+
16
+ ---
17
+
18
+ ## 📦 Instalação
19
+
20
+ ### 🔹 Desenvolvimento (recomendado)
21
+
22
+ Dentro do projeto que irá **usar o SDK**:
23
+
24
+ ```bash
25
+ pip install -e caminho/para/infra_core
26
+ ```
27
+
28
+ Exemplo:
29
+
30
+ ```bash
31
+ pip install -e C:\Users\rafael.m.cavalcante\PycharmProjects\infra_core
32
+ ```
33
+
34
+ ---
35
+
36
+ ### 🔹 Produção
37
+
38
+ ```bash
39
+ pip install infra-core
40
+ ```
41
+
42
+ ---
43
+
44
+ ## 🧱 Estrutura esperada
45
+
46
+ Após o uso:
47
+
48
+ ```
49
+ seu_projeto/
50
+ ├── main.py
51
+ ├── secret/
52
+ │ ├── secret.key
53
+ │ ├── aws.json
54
+ │ ├── pipefy.json
55
+ ```
56
+
57
+ ---
58
+
59
+ ## 🧠 Conceitos principais
60
+
61
+ ### 🔑 Secret Key
62
+
63
+ * Gerada automaticamente no primeiro uso
64
+ * Armazenada em `secret/secret.key`
65
+ * Nunca deve ser criada manualmente
66
+
67
+ ---
68
+
69
+ ### 📄 Credenciais
70
+
71
+ * Cada credencial é armazenada em um arquivo separado
72
+ * Nome controlado pelo parâmetro `name`
73
+
74
+ ```python
75
+ name="aws" → secret/aws.json
76
+ ```
77
+
78
+ ---
79
+
80
+ ## 🧩 Criando um modelo de credenciais
81
+
82
+ ```python
83
+ from dataclasses import dataclass
84
+ from infra_core import BaseCredentials
85
+
86
+ @dataclass(frozen=True)
87
+ class MyCreds(BaseCredentials):
88
+ api_token: str
89
+ ```
90
+
91
+ ---
92
+
93
+ ## 💾 Salvando credenciais (Setup)
94
+
95
+ ```python
96
+ from infra_core import FernetEncryption
97
+ from infra_core.credentials.setup.credentials_setup_service import CredentialsSetupService
98
+
99
+ setup = CredentialsSetupService(FernetEncryption)
100
+
101
+ setup.setup(
102
+ MyCreds(api_token="123"),
103
+ name="pipefy"
104
+ )
105
+ ```
106
+
107
+ ---
108
+
109
+ ## 🔓 Carregando credenciais (Load)
110
+
111
+ ```python
112
+ from infra_core import CredentialsLoader, FernetEncryption
113
+
114
+ creds = CredentialsLoader.load(
115
+ MyCreds,
116
+ FernetEncryption,
117
+ name="pipefy"
118
+ )
119
+
120
+ print(creds.api_token)
121
+ ```
122
+
123
+ ---
124
+
125
+ ## 🔄 Multi-credenciais
126
+
127
+ ```python
128
+ setup.setup(..., name="aws")
129
+ setup.setup(..., name="pipefy")
130
+ setup.setup(..., name="stripe")
131
+ ```
132
+
133
+ ---
134
+
135
+ ## 🔐 Encryption
136
+
137
+ ### Default
138
+
139
+ ```python
140
+ from infra_core import FernetEncryption
141
+ ```
142
+
143
+ ---
144
+
145
+ ### Custom (avançado)
146
+
147
+ ```python
148
+ class CustomEncryption:
149
+ def encrypt(self, value: str) -> str:
150
+ ...
151
+
152
+ def decrypt(self, value: str) -> str:
153
+ ...
154
+ ```
155
+
156
+ ---
157
+
158
+ ## ⚠️ Regras importantes
159
+
160
+ ### ❌ Não faça
161
+
162
+ ```python
163
+ Fernet.generate_key()
164
+ FernetEncryption(key)
165
+ ```
166
+
167
+ ---
168
+
169
+ ### ✅ Faça
170
+
171
+ ```python
172
+ CredentialsSetupService(FernetEncryption)
173
+ ```
174
+
175
+ ---
176
+
177
+ ## 🧪 Testes
178
+
179
+ ```bash
180
+ pytest tests
181
+ ```
182
+
183
+ ---
184
+
185
+ ## 🧠 Arquitetura
186
+
187
+ ```
188
+ infra_core/
189
+ ├── core/ # Path management
190
+ ├── credentials/
191
+ │ ├── models/ # BaseCredentials
192
+ │ ├── services/ # Load / Save
193
+ │ ├── setup/ # Setup flow
194
+ │ └── exceptions/
195
+ ├── security/ # Encryption
196
+ ```
197
+
198
+ ---
199
+
200
+ ## ⚠️ Problemas comuns
201
+
202
+ ### ModuleNotFoundError
203
+
204
+ ```bash
205
+ pip install -e caminho/infra_core
206
+ ```
207
+
208
+ ---
209
+
210
+ ### Dependência não encontrada
211
+
212
+ ```bash
213
+ pip install cryptography
214
+ ```
215
+
216
+ ---
217
+
218
+ ### PyCharm não reconhece imports
219
+
220
+ ```
221
+ File → Invalidate Caches → Restart
222
+ ```
223
+
224
+ ---
225
+
226
+ ## 🎯 Fluxo completo
227
+
228
+ ```
229
+ SETUP:
230
+ → gera key
231
+ → criptografa
232
+ → salva arquivo
233
+
234
+ LOAD:
235
+ → lê key
236
+ → descriptografa
237
+ → retorna objeto tipado
238
+ ```
239
+
240
+ ---
241
+
242
+ ## 🚀 Roadmap
243
+
244
+ * [ ] CLI (`infra-core setup`)
245
+ * [ ] Registry de credenciais
246
+ * [ ] Multi-env (dev/prod)
247
+ * [ ] Publish no PyPI
248
+
249
+ ---
250
+
251
+ ## 📄 Licença
252
+
253
+ MIT
254
+
255
+ ---
256
+
257
+ ## 👨‍💻 Autor
258
+
259
+ Rafael Cavalcante
@@ -0,0 +1,37 @@
1
+ [build-system]
2
+ requires = [ "setuptools>=61.0",]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "infra-core-sdk"
7
+ version = "0.1.0"
8
+ description = "Secure and extensible credential management SDK for Python applications."
9
+ readme = "README.md"
10
+ requires-python = ">=3.14,<3.15"
11
+ dependencies = [ "cryptography>=46.0.6",]
12
+ [[project.authors]]
13
+ name = "Rafael Cavalcante"
14
+
15
+ [project.optional-dependencies]
16
+ dev = [ "pytest>=8.0.0", "pytest-cov>=4.0.0", "black>=24.0.0", "mypy>=1.0.0",]
17
+
18
+ [project.urls]
19
+ Homepage = "https://github.com/rmcavalcante7/"
20
+ Repository = "https://github.com/rmcavalcante7/infra-core-sdk"
21
+
22
+ [tool.setuptools.packages.find]
23
+ where = [ "src",]
24
+
25
+ [tool.black]
26
+ line-length = 88
27
+ target-version = ["py310"]
28
+
29
+ [tool.mypy]
30
+ python_version = "3.10"
31
+ strict = true
32
+ ignore_missing_imports = true
33
+
34
+ [tool.pytest.ini_options]
35
+ testpaths = ["tests"]
36
+ python_files = ["test_*.py"]
37
+ addopts = "-ra -q"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,27 @@
1
+ # ============================================================
2
+ # Public API - infra_core
3
+ # ============================================================
4
+
5
+ from infra_core.core.path import (
6
+ PathManager,
7
+ PathConfig,
8
+ DEFAULT_PATH_CONFIG,
9
+ )
10
+
11
+ from infra_core.credentials.models.base_credentials import BaseCredentials
12
+
13
+ from infra_core.credentials.services.credentials_service import CredentialsService
14
+ from infra_core.credentials.services.credentials_loader import CredentialsLoader
15
+ from infra_core.security.fernet_encryption import FernetEncryption
16
+
17
+ __all__ = [
18
+ # Path
19
+ "PathManager",
20
+ "PathConfig",
21
+ "DEFAULT_PATH_CONFIG",
22
+ # Credentials
23
+ "BaseCredentials",
24
+ "CredentialsService",
25
+ "CredentialsLoader",
26
+ "FernetEncryption",
27
+ ]
@@ -0,0 +1,25 @@
1
+ # ============================================================
2
+ # Public API - infra_core
3
+ # ============================================================
4
+
5
+ from infra_core.core.path import (
6
+ PathManager,
7
+ PathConfig,
8
+ DEFAULT_PATH_CONFIG,
9
+ )
10
+
11
+ from infra_core.credentials.models.base_credentials import BaseCredentials
12
+
13
+ from infra_core.credentials.services.credentials_service import CredentialsService
14
+ from infra_core.credentials.services.credentials_loader import CredentialsLoader
15
+
16
+ __all__ = [
17
+ # Path
18
+ "PathManager",
19
+ "PathConfig",
20
+ "DEFAULT_PATH_CONFIG",
21
+ # Credentials
22
+ "BaseCredentials",
23
+ "CredentialsService",
24
+ "CredentialsLoader",
25
+ ]
@@ -0,0 +1,8 @@
1
+ from infra_core.core.path.path_manager import PathManager
2
+ from infra_core.core.path.path_config import PathConfig, DEFAULT_PATH_CONFIG
3
+
4
+ __all__ = [
5
+ "PathManager",
6
+ "PathConfig",
7
+ "DEFAULT_PATH_CONFIG",
8
+ ]
@@ -0,0 +1,22 @@
1
+ # ============================================================
2
+ # Dependencies:
3
+
4
+ # ============================================================
5
+
6
+
7
+ class PathResolutionError(Exception):
8
+ """
9
+ Exception raised when path resolution fails.
10
+
11
+ This error indicates failure in determining project root or resolving
12
+ logical paths.
13
+
14
+ :example:
15
+ >>> try:
16
+ ... raise PathResolutionError("error")
17
+ ... except PathResolutionError:
18
+ ... True
19
+ True
20
+ """
21
+
22
+ pass
@@ -0,0 +1,51 @@
1
+ # ============================================================
2
+ # Dependencies:
3
+ # - dataclasses
4
+ # - typing
5
+ # ============================================================
6
+
7
+ from dataclasses import dataclass
8
+ from typing import Dict, Tuple
9
+
10
+
11
+ @dataclass(frozen=True)
12
+ class PathConfig:
13
+ """
14
+ Configuration object defining path resolution behavior.
15
+
16
+ This class encapsulates all configurable aspects of the path system,
17
+ including how the project root is detected and how logical paths are mapped.
18
+
19
+ :param root_markers: Tuple[str, ...] = Files or directories used to detect project root.
20
+ :param directories: Dict[str, str] = Logical key → relative path mapping.
21
+
22
+ :example:
23
+ >>> config = PathConfig(
24
+ ... root_markers=(".git",),
25
+ ... directories={"data": "data"}
26
+ ... )
27
+ >>> config.directories["data"]
28
+ 'data'
29
+ """
30
+
31
+ root_markers: Tuple[str, ...]
32
+ directories: Dict[str, str]
33
+
34
+
35
+ DEFAULT_PATH_CONFIG: PathConfig = PathConfig(
36
+ root_markers=(
37
+ ".git",
38
+ "pyproject.toml",
39
+ "requirements.txt",
40
+ "setup.py",
41
+ ".root",
42
+ ".venv",
43
+ "venv",
44
+ ),
45
+ directories={
46
+ "secret_dir": "secret",
47
+ "secret_key": "secret/secret.key",
48
+ "credentials": "secret/{name}.json",
49
+ "downloads": "downloads",
50
+ },
51
+ )