Metadata-Version: 2.5
Name: authguard-sdk
Version: 1.0.0
Summary: Client SDK for AuthGuard, a software licensing platform with Ed25519-signed responses
Project-URL: Homepage, https://authguard.dk
Project-URL: Documentation, https://authguard.dk/docs.php
Author: AuthGuard
License-Expression: MIT
License-File: LICENSE
Keywords: authguard,ed25519,keyauth,license-key,licensing
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Security :: Cryptography
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: cryptography<47,>=43
Requires-Dist: requests<3,>=2.32
Description-Content-Type: text/markdown

# AuthGuard Python SDK

Client SDK for [AuthGuard](https://authguard.dk), a software licensing platform.
It talks to a single signed endpoint and verifies every reply with Ed25519, so a
tampered or replayed response is rejected before your code sees it.

## Install

```bash
pip install authguard-sdk
```

## Usage

Copy the app ID and public key from **Dashboard -> your app -> Settings**.

```python
import sys

from authguard_sdk import AuthGuard, AuthGuardError

app = AuthGuard(
    app_id="YOUR_APP_ID",
    version="1.0",
    public_key="YOUR_PUBLIC_KEY",
)

try:
    app.init()
    app.license("XXXX-XXXX-XXXX-XXXX")
except AuthGuardError as e:
    if e.response.get("update_required"):
        print("Update required. Download:", e.response.get("download_url"))
    else:
        print("Error:", e)
    sys.exit(1)

print("Access granted. Expires:", app.info.get("expires_at") or "never")
```

## API

`AuthGuard(app_id, version, public_key, url="https://authguard.dk/api/client")`

| Method | Purpose |
| --- | --- |
| `init()` | Open a session. Must be called first. Raises if the app is disabled or the version is out of date. |
| `license(key)` | Authenticate with a licence key. Returns the `info` dict. |
| `login(username, password)` | Authenticate an app user. Returns the `info` dict. |
| `register(username, password, key)` | Create an app user from a licence key. Returns the `info` dict. |
| `var(name)` | Read a server-side variable defined in the dashboard. |
| `check()` | Re-validate the session later on. Returns `True` or `False`. |

After a successful `license`, `login` or `register`, `app.info` holds the
subscription details (`expires_at`, `username`, `hwid`, ...).

Every failure raises `AuthGuardError`. Its `.response` attribute carries the
server's decoded payload when there was one, which is how you detect
`update_required` and read `download_url`.

## Security notes

- Responses are Ed25519-signed over the exact payload bytes; the signature is
  verified before the payload is parsed.
- Each request carries a random nonce that must be echoed back, and replies more
  than five minutes from the local clock are rejected.
- The app ID and public key are identifiers, not secrets. It is fine for them to
  sit in your source.
- The SDK sends a `User-Agent` of `AuthGuard-SDK/1.0`. Do not change it: some
  hosting firewalls block the default `python-requests` user agent.

Full documentation: <https://authguard.dk/docs.php>