Metadata-Version: 2.5
Name: balabs-kit
Version: 0.8.0
Author-email: tsifrer <3967564+tsifrer@users.noreply.github.com>
License-Expression: Apache-2.0
Requires-Python: >=3.13
Requires-Dist: aiocache[redis]>=0.12.3
Requires-Dist: aiohttp>=3.13.5
Requires-Dist: asyncclick>=8.4.2.1
Requires-Dist: asyncpg>=0.31.0
Requires-Dist: discord-py>=2.7.1
Requires-Dist: environs<15,>=14.6.0
Requires-Dist: ipython>=9.16.1
Requires-Dist: nest-asyncio>=1.6.0
Requires-Dist: sentry-sdk>=2.66.1
Requires-Dist: statsd>=4.0.1
Requires-Dist: tortoise-orm==1.1.8
Requires-Dist: uvloop>=0.22.1
Provides-Extra: arq
Requires-Dist: arq==0.28.0; extra == 'arq'
Provides-Extra: clerk
Requires-Dist: pyjwt[crypto]>=2.10.1; extra == 'clerk'
Provides-Extra: sanic
Requires-Dist: pydantic>=2.13.4; extra == 'sanic'
Requires-Dist: sanic-ext==25.12.0; extra == 'sanic'
Requires-Dist: sanic==25.12.1; extra == 'sanic'
Description-Content-Type: text/markdown

# BA Kit

## bakit dependency installation for local development and testing

`uv sync --all-extras --dev`

## Optional Clerk authentication

Install the Sanic and Clerk extras:

```shell
pip install "balabs-kit[sanic,clerk]"
```

Set `CLERK_ISSUER` (e.g. `https://your-app.clerk.accounts.dev`, or your
production Clerk domain). Optionally set `CLERK_AUDIENCE` to enforce `aud`,
`CLERK_AUTHORIZED_PARTIES` to a comma-separated list of trusted browser
origins for `azp`, and `CLERK_JWKS_URL` to override only the key endpoint.

Then mark any view with `@clerk_auth` to require a valid Clerk session
token (`Authorization: Bearer <token>` or the `__session` cookie):

```python
from bakit.sanic.decorators import clerk_auth
from bakit.sanic.views import APIView, Response, route


@route(bp, "/me/")
@clerk_auth
class MeView(APIView):
    async def get(self, request):
        return Response({"user_id": request.ctx.auth_claims["sub"]})
```

Unmarked views are unaffected. Marked views return 401 without a valid
token and are automatically excluded from the cache middleware (an
authenticated response must never be shared between users). On success the
token claims are on `request.ctx.auth_claims`.
