Metadata-Version: 2.4
Name: idswyft
Version: 0.1.0
Summary: Python package from LLM scan data (PyPI).
Author: 
License: MIT
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# idswyft

`idswyft` is the Python SDK for [IDSwyft](https://www.idswyft.app). It gives
your backend a typed way to issue and verify identity assertions, hand off
SSO flows, and exchange short-lived tokens for the user's verified attributes.
Use it to add "login with IDS" to a Flask/FastAPI app, or to verify an
assertion your service receives from a partner system.

## Features

- `Client(client_id=, client_secret=)` with typed request/response models.
- `Authorization.begin(...)` — return the redirect URL for a login handoff.
- `Authorization.exchange(code)` — swap the callback code for an `Assertion`.
- `Client.verify(assertion)` — verify signature, expiry, and audience.
- Attribute accessors on an `Assertion`: `sub`, `email`, `scopes`, `expires_at`.
- Sync and async APIs; thread-safe single client instance.

## Installation

```bash
pip install idswyft
# with FastAPI helpers (SignIn callback, session cookie):
pip install "idswyft[fastapi]"
```

## Quick start

```python
from idswyft import Client

client = Client(client_id="ic_...", client_secret="cs_...")

# Step 1: send the user to IDS
auth_url = client.authorization.begin(
    redirect_uri="https://app.example.com/auth/callback",
    scope=["openid", "email"],
)

# Step 2: on the callback, exchange the code:
assertion = client.authorization.exchange(code=request.args["code"])
print(assertion.sub, assertion.email, assertion.expires_at)

# Step 3: verify a token you received later:
verified = client.verify(assertion_token)
```

## API

- `idswyft.Client.authorization.begin(redirect_uri, scope=)` — return a URL.
- `idswyft.Client.authorization.exchange(code)` — return an `Assertion`.
- `idswyft.Client.verify(token)` — return a verified `Assertion` or raise.
- `idswyft.fastapi.install(app, client, callback_path=)` — wire the callback.

## Configuration

`Client` reads `IDSWYFT_CLIENT_ID`, `IDSWYFT_CLIENT_SECRET`, and
`IDSWYFT_ISSUER` from the environment. The FastAPI helper also reads
`IDSWYFT_COOKIE_NAME` (default `idswyft_session`).

## License

MIT
