# soul-auth
Framework-agnostic JWT claims and auth error primitives for the Soul platform.
Extracted from the Rainbow-Auth service. This crate keeps **only** the
framework-independent core (JWT encode/decode + a unified `AuthError`),
so it can be reused from any HTTP framework, database, or runtime.
## Add to your project
```toml
[dependencies]
soul-auth = "0.1"
```
## Usage
```rust
use soul_auth::{Claims, SubjectType, encode_token, decode_token};
let secret = b"my-secret-key";
let claims = Claims {
sub: "user:42".into(),
exp: 9_999_999_999,
iat: 1_700_000_000,
session_id: Some("session:1".into()),
subject_type: Some(SubjectType::Human),
};
let token = encode_token(&claims, secret).unwrap();
let decoded = decode_token(&token, secret).unwrap();
assert_eq!(decoded.sub, "user:42");
```
## What's included
| `AuthError` | Unified auth-flow error enum (`thiserror`-derived) |
| `Result<T>` | Alias for `Result<T, AuthError>` |
| `Claims` | JWT claims (`sub`, `exp`, `iat`, `session_id`, ...) |
| `SubjectType` | `Human` / `Agent` discriminator |
| `encode_token` | HS256 sign helper |
| `decode_token` | HS256 verify helper |
## License
MIT