Metadata-Version: 2.5
Name: rudeauth
Version: 0.1.0
Summary: Python client SDK for a RudeAuth licensing server
Project-URL: Homepage, https://rudeauth.com
Project-URL: Documentation, https://docs.rudeauth.com
Project-URL: Repository, https://github.com/Rudevin17/rudeauth-python
Author-email: RudeAuth <support@rudeauth.com>
License: MIT
License-File: LICENSE
Keywords: authentication,drm,ed25519,licensing,security
Requires-Python: >=3.8
Requires-Dist: pynacl>=1.5
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == 'dev'
Description-Content-Type: text/markdown

# RudeAuth Python SDK

Python client for a RudeAuth licensing server. The client embeds only an
application id and an Ed25519 public key. Every response is signed and verified
against that key before any field is trusted, so a patched binary cannot be
talked into a forged "success".

Crypto is libsodium via PyNaCl, the only dependency.

## Install

```
pip install rudeauth
```

Requires Python 3.8 or newer.

## Quick start

```python
from rudeauth import Client, RudeAuthError, ErrorCode

# app_id and public_key come from `rudeauth-cli app create`. Both are safe to
# embed: the public key verifies responses, it cannot forge them.
client = Client(app_id, public_key, "https://api.yourproduct.com")

try:
    session = client.authenticate(user_entered_key)
except RudeAuthError as e:
    # e.code is ErrorCode.LICENSE_EXPIRED, ErrorCode.DEVICE_LIMIT, ...
    raise

with session:
    offset = session.variable("offset")  # server-side, rotatable
    core = session.file("core.dll")      # never shipped in your binary
```

## No "is licensed" boolean, by design

There is deliberately no function that returns a bool meaning "is this user
licensed". `authenticate` returns a `Session` or raises `RudeAuthError`, and the
gating calls exist only on a `Session`, which cannot be built without a response
signature that verified against the key you embedded. A rejected licence is a
specific `ErrorCode`, not `False`.

## Errors

Every failure raises `RudeAuthError`; read `e.code`, an `ErrorCode`:

`NETWORK`, `BAD_RESPONSE`, `SIGNATURE_INVALID`, `NONCE_MISMATCH`, `CLOCK_SKEW`,
`LICENSE_INVALID`, `LICENSE_EXPIRED`, `DEVICE_LIMIT`, `DEVICE_BLACKLISTED`,
`RATE_LIMITED`, `SESSION_EXPIRED`, `ENDPOINT_DISABLED`, `APP_DISABLED`,
`RESET_UNAVAILABLE`, `FILE_NOT_FOUND`, `SERVER_ERROR`.

## Behaviour worth knowing

- No offline mode, no cache. If the server is unreachable, calls raise. A cached
  "last known good" state is exactly what an attacker induces by blocking the network.
- A missed heartbeat is not a logout. The session retries until its TTL lapses.
  `close()`, or leaving the `with` block, stops the heartbeat and zeroes the key.
- Fewer than two readable hardware components and the SDK refuses to authenticate.
- Fingerprints are forgeable. Device binding deters casual licence sharing, nothing more.

## Platforms

Hardware fingerprinting follows a shared per-OS component set: Windows (machine
GUID, volume serial, CPU, BIOS, board), Linux (machine-id, DMI ids), macOS
(IOPlatformUUID, serial).

## Tests

The crypto is checked against known-answer vectors generated by the server's own
code; the protocol flow against an in-process server that signs and seals exactly
as the real one does.

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

## License

MIT. The SDK holds only a public key; there is nothing in it to protect.
