Metadata-Version: 2.4
Name: pyzt
Version: 0.0.4
Summary: Life is short, I Use Python with pyzt.
Author-email: Azat <8280770+azataiot@users.noreply.github.com>
Requires-Python: >=3.13
Description-Content-Type: text/markdown
Classifier: License :: OSI Approved :: MIT License
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Typing :: Typed
Classifier: Topic :: Utilities
Classifier: Topic :: Terminals
Classifier: Topic :: System :: System Shells
Classifier: Topic :: System :: Networking
Classifier: Topic :: System :: Operating System
Classifier: Topic :: System :: Logging
Classifier: Topic :: System :: Monitoring
Classifier: Topic :: System :: Hardware
Classifier: Topic :: System :: Filesystems
License-File: LICENSE
Requires-Dist: passlib[argon2]>=1.7.4
Requires-Dist: pydantic>=2.11.3
Requires-Dist: pyjwt>=2.10.1
Project-URL: Home, https://azat.cc

# pyzt

Life is short, I use Python.

`pyzt` is a Python library that provides a simple and efficient way to work with various tasks.
It is designed to be easy to use and flexible, allowing you to quickly implement and customize your tasks as needed.

## pyzt.auth

A reusable and secure Python authentication toolkit for JWT-based APIs and Applications.

### Features

- Create and verify JWT tokens (access and refresh tokens).
- Customizable `issuer` and `audience` and expiry and scopes.
- Defends against signature stripping, invalid types, and expired tokens.
- Secure password hashing with `argon2` or `bcrypt`.
- Zero-framework dependency — plug into any FastAPI, Flask, Django, or any other Python web frameworks, APIs, or even CLIs.


## Installation

```bash
uv add pyzt
```

## Usage

### 🔐 JWTAuth

```python
from pyzt.auth.jwt import JWTAuth

jwt_auth = JWTAuth(
    secret="your-secret",
    issuer="your-api",
    audience="your-app"
)

# Create a token with optional custom claims
access_token = jwt_auth.create_access_token("user@example.com", {
    "role": "admin",
    "scope": "read write"
})

# Validate token
payload = jwt_auth.decode_token(access_token, token_type="access")
```

### 🔁 Token Pair

```python
pair = jwt_auth.create_token_pair("user@example.com")
print(pair.access_token, pair.refresh_token)
```


### 🔒 Password Hashing

```python
from pyzt.auth.crypto import PasswordHasher

hasher = PasswordHasher("argon2")
hash = hasher.hash("mypassword")
assert hasher.verify("mypassword", hash)
```


## Models

```python
from pyzt.types.tokens import TokenPair, TokenPayload
```

## Security Coverage

- ✅ HS256 token signing
- ✅ Expiry checks
- ✅ Signature stripping attack defense
- ✅ Token type validation
- ✅ Role/scope claim support

## Testing

```bash
pytest tests/
```

## License
MIT

