Metadata-Version: 2.4
Name: elua-sdk
Version: 0.1.0
Summary: Sign in with elua, licences and feedback, for apps published on elua (Windows).
Author: 691alpha
License-Expression: MIT OR Apache-2.0
Project-URL: Homepage, https://elua.691alpha.com
Keywords: elua,sign-in,oauth,pkce,licence
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE-MIT
License-File: LICENSE-APACHE
Requires-Dist: cryptography>=3.1
Dynamic: license-file

# elua-sdk

Sign in with an elua account, check a licence and send bug reports and ideas, for apps a
developer organisation publishes on [elua](https://elua.691alpha.com). For Python 3.9+, on
Windows.

```powershell
pip install elua-sdk
```

```python
from elua_sdk import Elua, EluaError

elua = Elua("acme.notes", "ec_0123456789abcdef")
session = elua.session() or elua.sign_in(["profile", "license", "feedback"])
me = session.profile()                # user, display_name, language, avatar
ok = session.license().allowed        # signed by elua; holds offline for a while
session.report("bug", "Crashes on save", "Steps: …", "1.2.0")
```

`sign_in` blocks until the person answers in Elua Hub (up to three minutes): call it off your
UI thread. It takes `wait=` (seconds) and `cancel=` (a `threading.Event`; set it to stop
waiting). `session.sign_out()` signs out of your app.

Errors are `EluaError`s, and their `code` says what happened: `no_hub` (Elua Hub isn't
installed; send people to `HUB_DOWNLOAD`), `cancelled`, `signed_out` (sign in again),
`refused` (with `status`) or `other` (the network, or something unexpected).

The session is kept in `%LOCALAPPDATA%\elua-sdk\<app id>\session.json`, the same file as the
Rust and TypeScript libraries', sealed with DPAPI for this Windows user. To seal it another
way, pass `sealer=` an object with `seal(text) -> str` and `open(sealed) -> str`.

The one dependency is [`cryptography`](https://pypi.org/project/cryptography/), to check the
ed25519 signature on elua's licence answers: a widely used, reviewed library, rather than
signature code of our own.

## How signing in works

Your app never sees a password. Elua Hub signs people in (OAuth 2.0 with PKCE for desktop
apps, RFC 8252): the library listens on `http://127.0.0.1:<port>/elua/callback` and opens
`elua://authorize?…`; Elua Hub asks the person, and on **Allow** hands a one-time code back,
which the library trades for tokens that work only for your app.

## What you need

An organisation on elua and a project for your app (Elua Hub › My apps), its **client id**
(`ec_…`), and the modules you use turned on: `auth` to sign in, then `license` and `feedback`
as needed.

Try it with `python examples/sign_in.py <app id> <client id>`.

## Licence

Licensed under either of MIT or Apache-2.0, at your option.
