quantumapi 0.1.0b0__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 (29) hide show
  1. quantumapi-0.1.0b0/LICENSE +21 -0
  2. quantumapi-0.1.0b0/PKG-INFO +554 -0
  3. quantumapi-0.1.0b0/README.md +513 -0
  4. quantumapi-0.1.0b0/pyproject.toml +124 -0
  5. quantumapi-0.1.0b0/quantumapi/__init__.py +44 -0
  6. quantumapi-0.1.0b0/quantumapi/client/__init__.py +17 -0
  7. quantumapi-0.1.0b0/quantumapi/client/async_client.py +102 -0
  8. quantumapi-0.1.0b0/quantumapi/client/base.py +328 -0
  9. quantumapi-0.1.0b0/quantumapi/client/encryption.py +169 -0
  10. quantumapi-0.1.0b0/quantumapi/client/health.py +59 -0
  11. quantumapi-0.1.0b0/quantumapi/client/keys.py +234 -0
  12. quantumapi-0.1.0b0/quantumapi/client/secrets.py +248 -0
  13. quantumapi-0.1.0b0/quantumapi/client/sync_client.py +75 -0
  14. quantumapi-0.1.0b0/quantumapi/errors/__init__.py +27 -0
  15. quantumapi-0.1.0b0/quantumapi/errors/exceptions.py +129 -0
  16. quantumapi-0.1.0b0/quantumapi/models/__init__.py +61 -0
  17. quantumapi-0.1.0b0/quantumapi/models/encryption.py +86 -0
  18. quantumapi-0.1.0b0/quantumapi/models/health.py +30 -0
  19. quantumapi-0.1.0b0/quantumapi/models/keys.py +101 -0
  20. quantumapi-0.1.0b0/quantumapi/models/secrets.py +107 -0
  21. quantumapi-0.1.0b0/quantumapi/py.typed +2 -0
  22. quantumapi-0.1.0b0/quantumapi.egg-info/PKG-INFO +554 -0
  23. quantumapi-0.1.0b0/quantumapi.egg-info/SOURCES.txt +27 -0
  24. quantumapi-0.1.0b0/quantumapi.egg-info/dependency_links.txt +1 -0
  25. quantumapi-0.1.0b0/quantumapi.egg-info/requires.txt +15 -0
  26. quantumapi-0.1.0b0/quantumapi.egg-info/top_level.txt +1 -0
  27. quantumapi-0.1.0b0/setup.cfg +4 -0
  28. quantumapi-0.1.0b0/tests/test_exceptions.py +80 -0
  29. quantumapi-0.1.0b0/tests/test_models.py +122 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 QuantumAPI Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,554 @@
1
+ Metadata-Version: 2.4
2
+ Name: quantumapi
3
+ Version: 0.1.0b0
4
+ Summary: Official Python SDK for QuantumAPI - Quantum-safe encryption and identity platform
5
+ Author-email: QuantumAPI Team <developers@quantumapi.eu>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://quantumapi.eu
8
+ Project-URL: Documentation, https://docs.quantumapi.eu/sdk/python
9
+ Project-URL: Repository, https://github.com/victorZKov/mislata
10
+ Project-URL: Bug Tracker, https://github.com/victorZKov/mislata/issues
11
+ Project-URL: Changelog, https://github.com/victorZKov/mislata/blob/main/src/sdk/python-quantumapi/CHANGELOG.md
12
+ Keywords: quantum,encryption,post-quantum,cryptography,security,api,sdk,ml-kem,ml-dsa,pqc
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Security :: Cryptography
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: httpx<1.0.0,>=0.27.0
27
+ Requires-Dist: pydantic<3.0.0,>=2.0.0
28
+ Requires-Dist: python-dotenv<2.0.0,>=1.0.0
29
+ Requires-Dist: cryptography<43.0.0,>=42.0.0
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
32
+ Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
33
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
34
+ Requires-Dist: pytest-httpx>=0.30.0; extra == "dev"
35
+ Requires-Dist: black>=24.0.0; extra == "dev"
36
+ Requires-Dist: isort>=5.13.0; extra == "dev"
37
+ Requires-Dist: mypy>=1.8.0; extra == "dev"
38
+ Requires-Dist: flake8>=7.0.0; extra == "dev"
39
+ Requires-Dist: respx>=0.21.0; extra == "dev"
40
+ Dynamic: license-file
41
+
42
+ # QuantumAPI Python SDK
43
+
44
+ [![PyPI version](https://badge.fury.io/py/quantumapi.svg)](https://badge.fury.io/py/quantumapi)
45
+ [![Python Support](https://img.shields.io/pypi/pyversions/quantumapi)](https://pypi.org/project/quantumapi/)
46
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/quantumapi/quantumapi-python/blob/main/LICENSE)
47
+ [![Documentation](https://img.shields.io/badge/docs-quantumapi.eu-brightgreen)](https://docs.quantumapi.eu/sdk/python)
48
+
49
+ Official Python SDK for [QuantumAPI](https://quantumapi.eu) - The European quantum-safe encryption and identity platform.
50
+
51
+ ## Features
52
+
53
+ - 🔐 **Quantum-Safe Encryption** - ML-KEM-768, ML-DSA-65, and hybrid encryption
54
+ - 🔑 **Key Management** - Generate, rotate, and manage cryptographic keys
55
+ - 🗄️ **Secret Vault** - Securely store and manage secrets with versioning
56
+ - 👤 **User Management** - Create and manage end-users with roles
57
+ - 🔍 **Audit Logs** - Query comprehensive audit trails
58
+ - 💳 **Billing Integration** - Access subscription and usage metrics
59
+ - 🚀 **Async/Await Support** - Full async support with httpx
60
+ - ⚡ **Automatic Retries** - Exponential backoff for transient failures
61
+ - 📊 **Rate Limiting** - Client-side rate limit tracking
62
+ - 🎯 **Type Safety** - Complete type hints with Pydantic models
63
+
64
+ ## Installation
65
+
66
+ ```bash
67
+ pip install quantumapi
68
+ ```
69
+
70
+ For development:
71
+
72
+ ```bash
73
+ pip install quantumapi[dev]
74
+ ```
75
+
76
+ ## Quick Start
77
+
78
+ ```python
79
+ from quantumapi import QuantumAPIClient
80
+
81
+ # Initialize client with API key
82
+ client = QuantumAPIClient(api_key="qapi_xxx")
83
+
84
+ # Encrypt data
85
+ ciphertext = await client.encryption.encrypt(
86
+ plaintext="secret data",
87
+ key_id="550e8400-e29b-41d4-a716-446655440000"
88
+ )
89
+
90
+ # Store a secret
91
+ secret = await client.secrets.create(
92
+ name="database_password",
93
+ value="super_secret_password",
94
+ labels=["production", "database"]
95
+ )
96
+
97
+ # Generate a new key pair
98
+ key = await client.keys.generate(
99
+ name="encryption-key-2024",
100
+ algorithm="ML-KEM-768",
101
+ key_type="encryption"
102
+ )
103
+
104
+ # Retrieve secret
105
+ secret_value = await client.secrets.get(secret.id)
106
+ print(f"Secret: {secret_value.value}")
107
+ ```
108
+
109
+ ## Synchronous API
110
+
111
+ If you prefer synchronous code, use the `QuantumAPISyncClient`:
112
+
113
+ ```python
114
+ from quantumapi import QuantumAPISyncClient
115
+
116
+ client = QuantumAPISyncClient(api_key="qapi_xxx")
117
+
118
+ # All methods work the same without await
119
+ ciphertext = client.encryption.encrypt(plaintext="secret data")
120
+ ```
121
+
122
+ ## Configuration
123
+
124
+ The SDK can be configured via environment variables or constructor arguments:
125
+
126
+ ```python
127
+ client = QuantumAPIClient(
128
+ api_key="qapi_xxx", # Or set QUANTUMAPI_API_KEY
129
+ base_url="https://api.quantumapi.eu", # Optional, defaults to production
130
+ timeout=30.0, # Request timeout in seconds
131
+ max_retries=3, # Max retry attempts for failed requests
132
+ enable_logging=True, # Enable detailed logging
133
+ )
134
+ ```
135
+
136
+ ### Environment Variables
137
+
138
+ - `QUANTUMAPI_API_KEY` - Your API key
139
+ - `QUANTUMAPI_BASE_URL` - API base URL (default: https://api.quantumapi.eu)
140
+ - `QUANTUMAPI_TIMEOUT` - Request timeout in seconds (default: 30)
141
+ - `QUANTUMAPI_MAX_RETRIES` - Maximum retry attempts (default: 3)
142
+
143
+ ## Core Modules
144
+
145
+ ### Encryption Client
146
+
147
+ ```python
148
+ # Encrypt data
149
+ result = await client.encryption.encrypt(
150
+ plaintext="sensitive data",
151
+ key_id="key-id", # Optional, uses default key if not specified
152
+ encoding="utf8" # or "base64" for binary data
153
+ )
154
+
155
+ # Decrypt data
156
+ plaintext = await client.encryption.decrypt(
157
+ encrypted_payload=result.encrypted_payload
158
+ )
159
+
160
+ # Sign data
161
+ signature = await client.encryption.sign(
162
+ data="message to sign",
163
+ key_id="signing-key-id"
164
+ )
165
+
166
+ # Verify signature
167
+ is_valid = await client.encryption.verify(
168
+ data="message to sign",
169
+ signature=signature.signature,
170
+ key_id="signing-key-id"
171
+ )
172
+ ```
173
+
174
+ ### Keys Client
175
+
176
+ ```python
177
+ # Generate key pair
178
+ key = await client.keys.generate(
179
+ name="my-encryption-key",
180
+ key_type="encryption",
181
+ algorithm="ML-KEM-768",
182
+ set_as_default=True
183
+ )
184
+
185
+ # List keys
186
+ keys = await client.keys.list(
187
+ key_type="encryption",
188
+ page=1,
189
+ page_size=50
190
+ )
191
+
192
+ # Get key details
193
+ key = await client.keys.get(key_id="key-id")
194
+
195
+ # Rotate key
196
+ new_key = await client.keys.rotate(key_id="key-id")
197
+
198
+ # Delete key
199
+ await client.keys.delete(key_id="key-id")
200
+
201
+ # Set default key
202
+ await client.keys.set_default(key_id="key-id", key_type="encryption")
203
+ ```
204
+
205
+ ### Secrets Client
206
+
207
+ ```python
208
+ # Create secret
209
+ secret = await client.secrets.create(
210
+ name="api-key",
211
+ value="secret_value",
212
+ content_type="api-key",
213
+ labels=["prod", "stripe"],
214
+ expires_at="2025-12-31T23:59:59Z"
215
+ )
216
+
217
+ # List secrets
218
+ secrets = await client.secrets.list(
219
+ content_type="password",
220
+ label="production",
221
+ page=1
222
+ )
223
+
224
+ # Get secret
225
+ secret = await client.secrets.get(secret_id="secret-id")
226
+
227
+ # Update secret value
228
+ await client.secrets.update_value(
229
+ secret_id="secret-id",
230
+ value="new_secret_value"
231
+ )
232
+
233
+ # Update secret metadata
234
+ await client.secrets.update(
235
+ secret_id="secret-id",
236
+ name="new-name",
237
+ labels=["staging"]
238
+ )
239
+
240
+ # Delete secret
241
+ await client.secrets.delete(secret_id="secret-id")
242
+ ```
243
+
244
+ ### Users Client
245
+
246
+ ```python
247
+ # Create user
248
+ user = await client.users.create(
249
+ email="user@example.com",
250
+ name="John Doe",
251
+ role="developer"
252
+ )
253
+
254
+ # List users
255
+ users = await client.users.list(active_only=True)
256
+
257
+ # Update user
258
+ await client.users.update(
259
+ user_id="user-id",
260
+ name="Jane Doe",
261
+ role="admin"
262
+ )
263
+
264
+ # Deactivate user
265
+ await client.users.deactivate(user_id="user-id")
266
+ ```
267
+
268
+ ### Applications Client
269
+
270
+ ```python
271
+ # Create OIDC application
272
+ app = await client.applications.create(
273
+ name="My App",
274
+ redirect_uris=["https://myapp.com/callback"],
275
+ scopes=["openid", "profile", "email"]
276
+ )
277
+
278
+ # List applications
279
+ apps = await client.applications.list()
280
+
281
+ # Update application
282
+ await client.applications.update(
283
+ app_id="app-id",
284
+ redirect_uris=["https://myapp.com/callback", "https://myapp.com/callback2"]
285
+ )
286
+ ```
287
+
288
+ ### Audit Client
289
+
290
+ ```python
291
+ # Query audit logs
292
+ logs = await client.audit.list(
293
+ action="secret_accessed",
294
+ resource_type="Secret",
295
+ start_date="2024-01-01",
296
+ end_date="2024-12-31",
297
+ page=1
298
+ )
299
+
300
+ # Export audit logs
301
+ csv_data = await client.audit.export(
302
+ format="csv",
303
+ start_date="2024-01-01",
304
+ end_date="2024-12-31"
305
+ )
306
+ ```
307
+
308
+ ### Billing Client
309
+
310
+ ```python
311
+ # Get subscription details
312
+ subscription = await client.billing.get_subscription()
313
+
314
+ # Get usage metrics
315
+ usage = await client.billing.get_usage(
316
+ start_date="2024-01-01",
317
+ end_date="2024-01-31"
318
+ )
319
+
320
+ # List invoices
321
+ invoices = await client.billing.list_invoices()
322
+ ```
323
+
324
+ ### Health Client
325
+
326
+ ```python
327
+ # Check API health
328
+ health = await client.health.check()
329
+ print(f"API Status: {health.status}")
330
+
331
+ # Get API version
332
+ version = await client.health.version()
333
+ print(f"API Version: {version.version}")
334
+
335
+ # Get rate limit status
336
+ rate_limit = await client.health.rate_limit()
337
+ print(f"Remaining: {rate_limit.remaining}/{rate_limit.limit}")
338
+ ```
339
+
340
+ ## Error Handling
341
+
342
+ The SDK provides typed exceptions for all error scenarios:
343
+
344
+ ```python
345
+ from quantumapi import (
346
+ QuantumAPIClient,
347
+ AuthenticationError,
348
+ PermissionError,
349
+ NotFoundError,
350
+ RateLimitError,
351
+ ValidationError,
352
+ ServerError,
353
+ NetworkError,
354
+ )
355
+
356
+ try:
357
+ secret = await client.secrets.get("invalid-id")
358
+ except NotFoundError as e:
359
+ print(f"Secret not found: {e.message}")
360
+ except AuthenticationError as e:
361
+ print(f"Authentication failed: {e.message}")
362
+ except RateLimitError as e:
363
+ print(f"Rate limit exceeded. Retry after {e.retry_after} seconds")
364
+ except ServerError as e:
365
+ print(f"Server error: {e.message}")
366
+ except NetworkError as e:
367
+ print(f"Network error: {e.message}")
368
+ ```
369
+
370
+ ## Pagination
371
+
372
+ List methods support automatic pagination:
373
+
374
+ ```python
375
+ # Manual pagination
376
+ secrets = await client.secrets.list(page=1, page_size=100)
377
+
378
+ # Iterate through all pages
379
+ all_secrets = []
380
+ page = 1
381
+ while True:
382
+ result = await client.secrets.list(page=page, page_size=100)
383
+ all_secrets.extend(result.secrets)
384
+ if not result.has_more:
385
+ break
386
+ page += 1
387
+ ```
388
+
389
+ ## Webhook Verification
390
+
391
+ Verify webhook signatures from QuantumAPI:
392
+
393
+ ```python
394
+ from quantumapi.webhooks import verify_signature
395
+
396
+ # Verify webhook payload
397
+ is_valid = verify_signature(
398
+ payload=request.body,
399
+ signature=request.headers["X-QuantumAPI-Signature"],
400
+ secret="your_webhook_secret"
401
+ )
402
+
403
+ if is_valid:
404
+ # Process webhook event
405
+ pass
406
+ ```
407
+
408
+ ## Logging
409
+
410
+ Enable detailed logging for debugging:
411
+
412
+ ```python
413
+ import logging
414
+
415
+ logging.basicConfig(level=logging.DEBUG)
416
+
417
+ client = QuantumAPIClient(
418
+ api_key="qapi_xxx",
419
+ enable_logging=True
420
+ )
421
+ ```
422
+
423
+ ## Examples
424
+
425
+ Check out the [examples/](./examples/) directory for more comprehensive examples:
426
+
427
+ - [Basic encryption and decryption](./examples/01_encryption_basics.py)
428
+ - [Secret management](./examples/02_secret_management.py)
429
+ - [Key generation and rotation](./examples/03_key_management.py)
430
+ - [User management](./examples/04_user_management.py)
431
+ - [Audit log queries](./examples/05_audit_logs.py)
432
+ - [Django integration](./examples/frameworks/django_integration.py)
433
+ - [Flask integration](./examples/frameworks/flask_integration.py)
434
+
435
+ ## Framework Integrations
436
+
437
+ ### Django
438
+
439
+ ```bash
440
+ pip install quantumapi[django]
441
+ ```
442
+
443
+ ```python
444
+ # settings.py
445
+ QUANTUMAPI = {
446
+ 'API_KEY': 'qapi_xxx',
447
+ 'BASE_URL': 'https://api.quantumapi.eu',
448
+ }
449
+
450
+ # Use in views
451
+ from quantumapi.integrations.django import get_client
452
+
453
+ async def my_view(request):
454
+ client = get_client()
455
+ secret = await client.secrets.get('secret-id')
456
+ return JsonResponse({'value': secret.value})
457
+ ```
458
+
459
+ ### Flask
460
+
461
+ ```bash
462
+ pip install quantumapi[flask]
463
+ ```
464
+
465
+ ```python
466
+ from flask import Flask
467
+ from quantumapi.integrations.flask import QuantumAPIFlask
468
+
469
+ app = Flask(__name__)
470
+ app.config['QUANTUMAPI_API_KEY'] = 'qapi_xxx'
471
+ qapi = QuantumAPIFlask(app)
472
+
473
+ @app.route('/secret/<secret_id>')
474
+ async def get_secret(secret_id):
475
+ secret = await qapi.secrets.get(secret_id)
476
+ return {'value': secret.value}
477
+ ```
478
+
479
+ ## Testing
480
+
481
+ Run tests:
482
+
483
+ ```bash
484
+ pytest
485
+ ```
486
+
487
+ Run tests with coverage:
488
+
489
+ ```bash
490
+ pytest --cov=quantumapi --cov-report=html
491
+ ```
492
+
493
+ ## Development
494
+
495
+ ```bash
496
+ # Clone repository
497
+ git clone https://github.com/quantumapi/quantumapi-python
498
+ cd quantumapi-python
499
+
500
+ # Install development dependencies
501
+ pip install -e ".[dev]"
502
+
503
+ # Run tests
504
+ pytest
505
+
506
+ # Format code
507
+ black quantumapi tests
508
+ isort quantumapi tests
509
+
510
+ # Type checking
511
+ mypy quantumapi
512
+
513
+ # Linting
514
+ flake8 quantumapi tests
515
+ ```
516
+
517
+ ## Requirements
518
+
519
+ - Python 3.9 or higher
520
+ - httpx >= 0.27.0
521
+ - pydantic >= 2.0.0
522
+ - python-dotenv >= 1.0.0
523
+ - cryptography >= 42.0.0
524
+
525
+ ## License
526
+
527
+ MIT License - see [LICENSE](LICENSE) file for details.
528
+
529
+ ## Support
530
+
531
+ - 📖 [Documentation](https://docs.quantumapi.eu/sdk/python)
532
+ - 💬 [Discord Community](https://discord.gg/quantumapi)
533
+ - 🐛 [Issue Tracker](https://github.com/quantumapi/quantumapi-python/issues)
534
+ - 📧 [Email Support](mailto:support@quantumapi.eu)
535
+
536
+ ## Contributing
537
+
538
+ Contributions are welcome! Please read our [Contributing Guide](CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.
539
+
540
+ ## Changelog
541
+
542
+ See [CHANGELOG.md](CHANGELOG.md) for a history of changes to this SDK.
543
+
544
+ ## Security
545
+
546
+ For security concerns, please email security@quantumapi.eu. Do not create public issues for security vulnerabilities.
547
+
548
+ ## Links
549
+
550
+ - [QuantumAPI Website](https://quantumapi.eu)
551
+ - [API Documentation](https://docs.quantumapi.eu)
552
+ - [Python SDK Documentation](https://docs.quantumapi.eu/sdk/python)
553
+ - [GitHub Repository](https://github.com/quantumapi/quantumapi-python)
554
+ - [PyPI Package](https://pypi.org/project/quantumapi/)