Official AstraGuard SDK — license validation, HWID binding, and offline cache for Python server applications
Project description
astraguard
Official AstraGuard SDK for Python — license validation, HWID binding, and AES-256-GCM offline cache for server-side applications.
Server-Side Only This SDK is for Python server applications (Flask, FastAPI, Django, etc.). Do NOT embed it in client-side software — Python offers no meaningful anti-debug or anti-VM protection. For desktop protection use the C++ header or Rust SDK.
Installation
pip install astraguard
Async support (FastAPI, asyncio):
pip install "astraguard[async]"
Sync (Flask / Django)
from astraguard import AstraGuardClient
client = AstraGuardClient(
api_url="https://api.astraguard.io",
product_id="your-product-id",
)
result = client.validate("XXXX-XXXX-XXXX-XXXX")
if result.valid:
print("License valid!")
Async (FastAPI)
from astraguard import AsyncAstraGuardClient
client = AsyncAstraGuardClient(
api_url="https://api.astraguard.io",
product_id="your-product-id",
)
result = await client.validate("XXXX-XXXX-XXXX-XXXX")
Features
validate()/activate()with fully typed responses- HMAC-SHA256 response verification (fail-closed)
- AES-256-GCM encrypted offline cache (configurable grace period)
- Background heartbeat thread
- Cross-platform HWID derivation (Windows registry, /etc/machine-id, IOPlatformUUID)
- Update check via
/check-update - Zero mandatory dependencies beyond
cryptography - Full type annotations +
py.typedmarker
Error Handling
from astraguard import NetworkError, ServerError, SignatureMismatch
try:
result = client.validate(license_key)
except NetworkError:
pass # unreachable + no cache
except ServerError as e:
print(f"HTTP {e.status}")
except SignatureMismatch:
pass # tampered response
Heartbeat
import sys
client.start_heartbeat(
license_key="XXXX-XXXX-XXXX-XXXX",
interval=300,
on_lapse=lambda: sys.exit(1),
)
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file astraguard-1.1.0.tar.gz.
File metadata
- Download URL: astraguard-1.1.0.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
207aa869fc46a7c173294ca1889837e34021a28ae3649aa6d56b616af15c889b
|
|
| MD5 |
aabe02cda28386a8624bf5f197d48d19
|
|
| BLAKE2b-256 |
1dbe4b9fbd307ceb13fbdcaafacc8ab4a4fac8c4a4f0b9edcc344c8d793388e3
|
File details
Details for the file astraguard-1.1.0-py3-none-any.whl.
File metadata
- Download URL: astraguard-1.1.0-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7ce42d348ef22363f759534248100c1b651dda36978325f55e77756e33fcc38
|
|
| MD5 |
44a0ca6a5726a1f79c52c1dc9d72bbd3
|
|
| BLAKE2b-256 |
7cb439aae0d3a005d3e8ccd36227bc53b22d1c3a48f45a6ceaf5809e2751012a
|