fast-paseto 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fast_paseto-0.0.1/.github/workflows/CI.yml +181 -0
- fast_paseto-0.0.1/.gitignore +47 -0
- fast_paseto-0.0.1/.hypothesis/examples/04e6b3400353b141/7367e70b57312087 +1 -0
- fast_paseto-0.0.1/.hypothesis/examples/7367e70b57312087/5228a5805998c2a1 +0 -0
- fast_paseto-0.0.1/.hypothesis/tmp/tmp1zlcrvd4 +0 -0
- fast_paseto-0.0.1/.hypothesis/tmp/tmp2owxeye9 +0 -0
- fast_paseto-0.0.1/.hypothesis/tmp/tmp9ulmd1j1 +0 -0
- fast_paseto-0.0.1/.hypothesis/tmp/tmpaa85lrcu +0 -0
- fast_paseto-0.0.1/.hypothesis/tmp/tmpbsv5aums +0 -0
- fast_paseto-0.0.1/.hypothesis/tmp/tmpntuzs9z9 +0 -0
- fast_paseto-0.0.1/.hypothesis/tmp/tmpya1fi1fh +0 -0
- fast_paseto-0.0.1/.hypothesis/tmp/tmpyf6cleyn +0 -0
- fast_paseto-0.0.1/.hypothesis/unicode_data/14.0.0/charmap.json.gz +0 -0
- fast_paseto-0.0.1/.hypothesis/unicode_data/14.0.0/codec-utf-8.json.gz +0 -0
- fast_paseto-0.0.1/.kiro/steering/Subagents.md +42 -0
- fast_paseto-0.0.1/.kiro/steering/product.md +52 -0
- fast_paseto-0.0.1/.kiro/steering/structure.md +73 -0
- fast_paseto-0.0.1/.kiro/steering/tech.md +72 -0
- fast_paseto-0.0.1/.pre-commit-config.yaml +37 -0
- fast_paseto-0.0.1/.python-version +1 -0
- fast_paseto-0.0.1/Cargo.lock +826 -0
- fast_paseto-0.0.1/Cargo.toml +30 -0
- fast_paseto-0.0.1/LICENSE +21 -0
- fast_paseto-0.0.1/PKG-INFO +12 -0
- fast_paseto-0.0.1/README.md +0 -0
- fast_paseto-0.0.1/fast_paseto.pyi +316 -0
- fast_paseto-0.0.1/main.py +6 -0
- fast_paseto-0.0.1/pyproject.toml +33 -0
- fast_paseto-0.0.1/src/claims_manager.rs +244 -0
- fast_paseto-0.0.1/src/error.rs +63 -0
- fast_paseto-0.0.1/src/key_generator.rs +436 -0
- fast_paseto-0.0.1/src/key_manager.rs +856 -0
- fast_paseto-0.0.1/src/lib.rs +1485 -0
- fast_paseto-0.0.1/src/pae.rs +180 -0
- fast_paseto-0.0.1/src/payload.rs +102 -0
- fast_paseto-0.0.1/src/token_generator.rs +746 -0
- fast_paseto-0.0.1/src/token_verifier.rs +795 -0
- fast_paseto-0.0.1/src/version.rs +75 -0
- fast_paseto-0.0.1/tests/test_custom_serialization.py +232 -0
- fast_paseto-0.0.1/tests/test_custom_serializer_property.py +328 -0
- fast_paseto-0.0.1/tests/test_encode_decode.py +214 -0
- fast_paseto-0.0.1/tests/test_exceptions.py +71 -0
- fast_paseto-0.0.1/tests/test_key_generation.py +117 -0
- fast_paseto-0.0.1/tests/test_paserk.py +175 -0
- fast_paseto-0.0.1/tests/test_paseto_instance.py +360 -0
- fast_paseto-0.0.1/tests/test_paseto_instance_basic.py +129 -0
- fast_paseto-0.0.1/tests/test_token_class.py +154 -0
- fast_paseto-0.0.1/tests/test_token_property.py +214 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# This file is autogenerated by maturin v1.10.2
|
|
2
|
+
# To update, run
|
|
3
|
+
#
|
|
4
|
+
# maturin generate-ci github
|
|
5
|
+
#
|
|
6
|
+
name: CI
|
|
7
|
+
|
|
8
|
+
on:
|
|
9
|
+
push:
|
|
10
|
+
branches:
|
|
11
|
+
- main
|
|
12
|
+
- master
|
|
13
|
+
tags:
|
|
14
|
+
- '*'
|
|
15
|
+
pull_request:
|
|
16
|
+
workflow_dispatch:
|
|
17
|
+
|
|
18
|
+
permissions:
|
|
19
|
+
contents: read
|
|
20
|
+
|
|
21
|
+
jobs:
|
|
22
|
+
linux:
|
|
23
|
+
runs-on: ${{ matrix.platform.runner }}
|
|
24
|
+
strategy:
|
|
25
|
+
matrix:
|
|
26
|
+
platform:
|
|
27
|
+
- runner: ubuntu-22.04
|
|
28
|
+
target: x86_64
|
|
29
|
+
- runner: ubuntu-22.04
|
|
30
|
+
target: x86
|
|
31
|
+
- runner: ubuntu-22.04
|
|
32
|
+
target: aarch64
|
|
33
|
+
- runner: ubuntu-22.04
|
|
34
|
+
target: armv7
|
|
35
|
+
- runner: ubuntu-22.04
|
|
36
|
+
target: s390x
|
|
37
|
+
- runner: ubuntu-22.04
|
|
38
|
+
target: ppc64le
|
|
39
|
+
steps:
|
|
40
|
+
- uses: actions/checkout@v4
|
|
41
|
+
- uses: actions/setup-python@v5
|
|
42
|
+
with:
|
|
43
|
+
python-version: 3.x
|
|
44
|
+
- name: Build wheels
|
|
45
|
+
uses: PyO3/maturin-action@v1
|
|
46
|
+
with:
|
|
47
|
+
target: ${{ matrix.platform.target }}
|
|
48
|
+
args: --release --out dist --find-interpreter
|
|
49
|
+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
50
|
+
manylinux: auto
|
|
51
|
+
- name: Upload wheels
|
|
52
|
+
uses: actions/upload-artifact@v4
|
|
53
|
+
with:
|
|
54
|
+
name: wheels-linux-${{ matrix.platform.target }}
|
|
55
|
+
path: dist
|
|
56
|
+
|
|
57
|
+
musllinux:
|
|
58
|
+
runs-on: ${{ matrix.platform.runner }}
|
|
59
|
+
strategy:
|
|
60
|
+
matrix:
|
|
61
|
+
platform:
|
|
62
|
+
- runner: ubuntu-22.04
|
|
63
|
+
target: x86_64
|
|
64
|
+
- runner: ubuntu-22.04
|
|
65
|
+
target: x86
|
|
66
|
+
- runner: ubuntu-22.04
|
|
67
|
+
target: aarch64
|
|
68
|
+
- runner: ubuntu-22.04
|
|
69
|
+
target: armv7
|
|
70
|
+
steps:
|
|
71
|
+
- uses: actions/checkout@v4
|
|
72
|
+
- uses: actions/setup-python@v5
|
|
73
|
+
with:
|
|
74
|
+
python-version: 3.x
|
|
75
|
+
- name: Build wheels
|
|
76
|
+
uses: PyO3/maturin-action@v1
|
|
77
|
+
with:
|
|
78
|
+
target: ${{ matrix.platform.target }}
|
|
79
|
+
args: --release --out dist --find-interpreter
|
|
80
|
+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
81
|
+
manylinux: musllinux_1_2
|
|
82
|
+
- name: Upload wheels
|
|
83
|
+
uses: actions/upload-artifact@v4
|
|
84
|
+
with:
|
|
85
|
+
name: wheels-musllinux-${{ matrix.platform.target }}
|
|
86
|
+
path: dist
|
|
87
|
+
|
|
88
|
+
windows:
|
|
89
|
+
runs-on: ${{ matrix.platform.runner }}
|
|
90
|
+
strategy:
|
|
91
|
+
matrix:
|
|
92
|
+
platform:
|
|
93
|
+
- runner: windows-latest
|
|
94
|
+
target: x64
|
|
95
|
+
- runner: windows-latest
|
|
96
|
+
target: x86
|
|
97
|
+
steps:
|
|
98
|
+
- uses: actions/checkout@v4
|
|
99
|
+
- uses: actions/setup-python@v5
|
|
100
|
+
with:
|
|
101
|
+
python-version: 3.x
|
|
102
|
+
architecture: ${{ matrix.platform.target }}
|
|
103
|
+
- name: Build wheels
|
|
104
|
+
uses: PyO3/maturin-action@v1
|
|
105
|
+
with:
|
|
106
|
+
target: ${{ matrix.platform.target }}
|
|
107
|
+
args: --release --out dist --find-interpreter
|
|
108
|
+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
109
|
+
- name: Upload wheels
|
|
110
|
+
uses: actions/upload-artifact@v4
|
|
111
|
+
with:
|
|
112
|
+
name: wheels-windows-${{ matrix.platform.target }}
|
|
113
|
+
path: dist
|
|
114
|
+
|
|
115
|
+
macos:
|
|
116
|
+
runs-on: ${{ matrix.platform.runner }}
|
|
117
|
+
strategy:
|
|
118
|
+
matrix:
|
|
119
|
+
platform:
|
|
120
|
+
- runner: macos-13
|
|
121
|
+
target: x86_64
|
|
122
|
+
- runner: macos-14
|
|
123
|
+
target: aarch64
|
|
124
|
+
steps:
|
|
125
|
+
- uses: actions/checkout@v4
|
|
126
|
+
- uses: actions/setup-python@v5
|
|
127
|
+
with:
|
|
128
|
+
python-version: 3.x
|
|
129
|
+
- name: Build wheels
|
|
130
|
+
uses: PyO3/maturin-action@v1
|
|
131
|
+
with:
|
|
132
|
+
target: ${{ matrix.platform.target }}
|
|
133
|
+
args: --release --out dist --find-interpreter
|
|
134
|
+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
135
|
+
- name: Upload wheels
|
|
136
|
+
uses: actions/upload-artifact@v4
|
|
137
|
+
with:
|
|
138
|
+
name: wheels-macos-${{ matrix.platform.target }}
|
|
139
|
+
path: dist
|
|
140
|
+
|
|
141
|
+
sdist:
|
|
142
|
+
runs-on: ubuntu-latest
|
|
143
|
+
steps:
|
|
144
|
+
- uses: actions/checkout@v4
|
|
145
|
+
- name: Build sdist
|
|
146
|
+
uses: PyO3/maturin-action@v1
|
|
147
|
+
with:
|
|
148
|
+
command: sdist
|
|
149
|
+
args: --out dist
|
|
150
|
+
- name: Upload sdist
|
|
151
|
+
uses: actions/upload-artifact@v4
|
|
152
|
+
with:
|
|
153
|
+
name: wheels-sdist
|
|
154
|
+
path: dist
|
|
155
|
+
|
|
156
|
+
release:
|
|
157
|
+
name: Release
|
|
158
|
+
runs-on: ubuntu-latest
|
|
159
|
+
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
|
|
160
|
+
needs: [linux, musllinux, windows, macos, sdist]
|
|
161
|
+
permissions:
|
|
162
|
+
# Use to sign the release artifacts
|
|
163
|
+
id-token: write
|
|
164
|
+
# Used to upload release artifacts
|
|
165
|
+
contents: write
|
|
166
|
+
# Used to generate artifact attestation
|
|
167
|
+
attestations: write
|
|
168
|
+
steps:
|
|
169
|
+
- uses: actions/download-artifact@v4
|
|
170
|
+
- name: Generate artifact attestation
|
|
171
|
+
uses: actions/attest-build-provenance@v2
|
|
172
|
+
with:
|
|
173
|
+
subject-path: 'wheels-*/*'
|
|
174
|
+
- name: Publish to PyPI
|
|
175
|
+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
|
|
176
|
+
uses: PyO3/maturin-action@v1
|
|
177
|
+
env:
|
|
178
|
+
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
|
|
179
|
+
with:
|
|
180
|
+
command: upload
|
|
181
|
+
args: --non-interactive --skip-existing wheels-*/*
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Rust
|
|
2
|
+
/target/
|
|
3
|
+
Cargo.lock
|
|
4
|
+
|
|
5
|
+
# Python
|
|
6
|
+
__pycache__/
|
|
7
|
+
*.py[cod]
|
|
8
|
+
*$py.class
|
|
9
|
+
*.so
|
|
10
|
+
*.pyd
|
|
11
|
+
.Python
|
|
12
|
+
build/
|
|
13
|
+
dist/
|
|
14
|
+
*.egg-info/
|
|
15
|
+
*.egg
|
|
16
|
+
.eggs/
|
|
17
|
+
|
|
18
|
+
# Virtual environments
|
|
19
|
+
.venv/
|
|
20
|
+
venv/
|
|
21
|
+
ENV/
|
|
22
|
+
|
|
23
|
+
# uv
|
|
24
|
+
uv.lock
|
|
25
|
+
|
|
26
|
+
# IDE
|
|
27
|
+
.idea/
|
|
28
|
+
.vscode/
|
|
29
|
+
*.swp
|
|
30
|
+
*.swo
|
|
31
|
+
*~
|
|
32
|
+
|
|
33
|
+
# OS
|
|
34
|
+
.DS_Store
|
|
35
|
+
Thumbs.db
|
|
36
|
+
|
|
37
|
+
# Testing
|
|
38
|
+
.pytest_cache/
|
|
39
|
+
.coverage
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
|
|
43
|
+
# Maturin
|
|
44
|
+
*.whl
|
|
45
|
+
|
|
46
|
+
# Kiro
|
|
47
|
+
.kiro/specs/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
��`T{�3��0邒�܆ 7��{��nkJJ�7��ӫ���^w"�
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
inclusion: manual
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Subagent Usage Guidelines
|
|
6
|
+
|
|
7
|
+
## When to Use Subagents
|
|
8
|
+
|
|
9
|
+
### context-gatherer (Use First for Unfamiliar Code)
|
|
10
|
+
- **Always use at the start** when working with unfamiliar parts of the codebase
|
|
11
|
+
- Investigating bugs or issues that span multiple files
|
|
12
|
+
- Understanding how components interact before making changes
|
|
13
|
+
- Repository-wide problems where relevant files are unclear
|
|
14
|
+
- Use **once per query** at the beginning, then work with gathered context
|
|
15
|
+
|
|
16
|
+
### general-task-execution (For Parallel Work)
|
|
17
|
+
- Delegating well-defined subtasks while continuing other work
|
|
18
|
+
- Parallelizing independent work streams (e.g., multiple file modifications)
|
|
19
|
+
- Tasks that benefit from isolated context and tool access
|
|
20
|
+
|
|
21
|
+
## Critical Rules
|
|
22
|
+
|
|
23
|
+
### Testing
|
|
24
|
+
- **Never run tests in subagents** - always run `pytest` and `cargo test` in the main agent
|
|
25
|
+
- Subagents should focus on code exploration, analysis, or isolated modifications
|
|
26
|
+
- Test execution requires the full context and should be done after all changes are complete
|
|
27
|
+
|
|
28
|
+
### Parallel Execution
|
|
29
|
+
- When a task has multiple independent subtasks, use subagents to parallelize work
|
|
30
|
+
- Example: Modifying multiple unrelated Rust modules simultaneously
|
|
31
|
+
- Do not parallelize dependent tasks (e.g., don't modify a function and its caller in parallel)
|
|
32
|
+
|
|
33
|
+
### Build Commands
|
|
34
|
+
- Subagents should not run `maturin develop` - this is a main agent responsibility
|
|
35
|
+
- After subagent modifications to Rust code, the main agent must rebuild before testing
|
|
36
|
+
|
|
37
|
+
## Best Practices
|
|
38
|
+
|
|
39
|
+
- Trust subagent output - avoid redundantly re-reading files they've analyzed
|
|
40
|
+
- Use context-gatherer proactively based on task type, not just when explicitly requested
|
|
41
|
+
- Choose the most specific subagent for the task
|
|
42
|
+
- Don't overuse subagents for simple, single-file tasks you can handle directly
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
inclusion: always
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Product Overview
|
|
6
|
+
|
|
7
|
+
fast-paseto is a high-performance PASETO (Platform-Agnostic Security Tokens) library implemented in Rust with Python bindings via PyO3.
|
|
8
|
+
|
|
9
|
+
## Core Purpose
|
|
10
|
+
|
|
11
|
+
Provide a secure, fast, and easy-to-use API for creating and verifying PASETO tokens in Python applications, leveraging Rust's performance and memory safety guarantees.
|
|
12
|
+
|
|
13
|
+
## Key Capabilities
|
|
14
|
+
|
|
15
|
+
### Token Operations
|
|
16
|
+
- **Local tokens** (symmetric): XChaCha20-Poly1305 encryption for confidential data
|
|
17
|
+
- **Public tokens** (asymmetric): Ed25519 signatures for verifiable, non-confidential data
|
|
18
|
+
- Support for v4 (primary), v3 (NIST-compliant), and v2 (legacy) protocols
|
|
19
|
+
|
|
20
|
+
### API Design Principles
|
|
21
|
+
- **Two usage patterns**: Module-level functions (`encode()`, `decode()`) for simple use cases; `Paseto` class for configurable defaults
|
|
22
|
+
- **Automatic claim management**: Optional auto-injection of `exp` (expiration) and `iat` (issued-at) claims
|
|
23
|
+
- **Flexible serialization**: JSON by default, custom serializers supported via Protocol
|
|
24
|
+
- **Type safety**: Full type stubs provided in `fast_paseto.pyi`
|
|
25
|
+
|
|
26
|
+
### Security Features
|
|
27
|
+
- Cryptographic operations handled entirely in Rust
|
|
28
|
+
- Time-based claim validation with configurable leeway
|
|
29
|
+
- Footer and implicit assertion support per PASETO spec
|
|
30
|
+
- Proper key length validation (32 bytes symmetric, 64 bytes secret, 32 bytes public)
|
|
31
|
+
|
|
32
|
+
## Design Constraints
|
|
33
|
+
|
|
34
|
+
- **No runtime Python dependencies**: Pure Rust extension module
|
|
35
|
+
- **Python 3.11+ only**: Leverages modern Python features
|
|
36
|
+
- **v4 tokens are default**: Older versions require explicit version parameter
|
|
37
|
+
- **Immutable Token objects**: Decoded tokens are read-only data containers
|
|
38
|
+
|
|
39
|
+
## Target Users
|
|
40
|
+
|
|
41
|
+
Python developers building authentication systems who need:
|
|
42
|
+
- Better security defaults than JWT
|
|
43
|
+
- High performance token operations
|
|
44
|
+
- Type-safe token handling
|
|
45
|
+
- Protection against common JWT vulnerabilities (algorithm confusion, weak signatures)
|
|
46
|
+
|
|
47
|
+
## Anti-Patterns to Avoid
|
|
48
|
+
|
|
49
|
+
- Don't use PASETO for session storage (use local tokens with short expiration instead)
|
|
50
|
+
- Don't put sensitive data in public tokens (they're signed, not encrypted)
|
|
51
|
+
- Don't reuse keys across different purposes (local vs public)
|
|
52
|
+
- Don't implement custom crypto - use provided key generation functions
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
---
|
|
2
|
+
inclusion: always
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Project Structure
|
|
6
|
+
|
|
7
|
+
## Directory Layout
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
fast-paseto/
|
|
11
|
+
├── src/ # Rust source code
|
|
12
|
+
│ ├── lib.rs # PyO3 module definition and Python bindings
|
|
13
|
+
│ ├── claims_manager.rs # JWT-like claims handling
|
|
14
|
+
│ ├── error.rs # Error types and conversions
|
|
15
|
+
│ ├── key_generator.rs # Cryptographic key generation
|
|
16
|
+
│ ├── pae.rs # Pre-Authentication Encoding
|
|
17
|
+
│ ├── payload.rs # Token payload structures
|
|
18
|
+
│ ├── token_generator.rs # Token creation logic
|
|
19
|
+
│ ├── token_verifier.rs # Token verification logic
|
|
20
|
+
│ └── version.rs # PASETO version handling
|
|
21
|
+
├── tests/ # Python test suite (pytest)
|
|
22
|
+
├── Cargo.toml # Rust package manifest (cdylib)
|
|
23
|
+
├── pyproject.toml # Python package config (maturin backend)
|
|
24
|
+
├── fast_paseto.pyi # Python type stubs
|
|
25
|
+
└── main.py # Example usage / manual testing
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Architecture Patterns
|
|
29
|
+
|
|
30
|
+
### Rust-Python Bridge
|
|
31
|
+
- Rust implements core cryptographic operations for performance and safety
|
|
32
|
+
- PyO3 exposes Rust functions/classes to Python via `#[pyfunction]`, `#[pyclass]`, `#[pymodule]`
|
|
33
|
+
- Python provides the user-facing API surface
|
|
34
|
+
- Type stubs in `fast_paseto.pyi` provide IDE support
|
|
35
|
+
|
|
36
|
+
### Module Organization
|
|
37
|
+
- `lib.rs`: Entry point, defines `#[pymodule] fn fast_paseto`
|
|
38
|
+
- Separate modules for distinct concerns (claims, keys, tokens, errors)
|
|
39
|
+
- Error types implement `From` traits for PyO3 exception conversion
|
|
40
|
+
- All public Rust APIs must be exposed through `lib.rs` module
|
|
41
|
+
|
|
42
|
+
### Build System
|
|
43
|
+
- Cargo builds Rust as `cdylib` (C-compatible dynamic library)
|
|
44
|
+
- Maturin bridges Cargo and Python packaging
|
|
45
|
+
- `maturin develop` for local development (editable install)
|
|
46
|
+
- `maturin build` for distribution wheels
|
|
47
|
+
|
|
48
|
+
## File Modification Guidelines
|
|
49
|
+
|
|
50
|
+
### When modifying Rust code:
|
|
51
|
+
- Changes in `src/*.rs` require `maturin develop` to rebuild
|
|
52
|
+
- Add new Python-facing functions to `lib.rs` with `#[pyfunction]`
|
|
53
|
+
- Update `fast_paseto.pyi` type stubs when changing Python API
|
|
54
|
+
- Run `cargo test` for Rust unit tests, `pytest` for integration tests
|
|
55
|
+
|
|
56
|
+
### When modifying Python code:
|
|
57
|
+
- `main.py` is for examples only, not part of the package
|
|
58
|
+
- Tests go in `tests/` directory using pytest conventions
|
|
59
|
+
- No Python runtime code in package (pure Rust extension)
|
|
60
|
+
|
|
61
|
+
### When adding dependencies:
|
|
62
|
+
- Rust deps: Add to `Cargo.toml` under `[dependencies]`
|
|
63
|
+
- Python dev deps: Add to `pyproject.toml` under `[project.optional-dependencies]`
|
|
64
|
+
- Build deps: Add to `[build-system.requires]` in `pyproject.toml`
|
|
65
|
+
|
|
66
|
+
## Key Conventions
|
|
67
|
+
|
|
68
|
+
- Module name: `fast_paseto` (importable after `maturin develop`)
|
|
69
|
+
- Rust edition: 2024
|
|
70
|
+
- Python version: 3.11+ required
|
|
71
|
+
- All cryptographic operations stay in Rust (never implement in Python)
|
|
72
|
+
- Error handling: Rust errors convert to Python exceptions via PyO3
|
|
73
|
+
- Testing: Rust unit tests in `src/`, Python integration tests in `tests/`
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
inclusion: always
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Technology Stack
|
|
6
|
+
|
|
7
|
+
## Core Technologies
|
|
8
|
+
- **Rust (Edition 2024)**: All cryptographic operations and core logic
|
|
9
|
+
- **Python 3.11+**: User-facing API via PyO3 bindings
|
|
10
|
+
- **PyO3 0.27.0**: Rust-Python FFI layer
|
|
11
|
+
- **Maturin**: Build tool for PyO3 projects (bridges Cargo and Python packaging)
|
|
12
|
+
|
|
13
|
+
## Critical Build Rules
|
|
14
|
+
- After ANY Rust code changes in `src/`, run `maturin develop` to rebuild the extension
|
|
15
|
+
- Python has NO runtime dependencies - this is a pure Rust extension module
|
|
16
|
+
- Use `uv` for Python environment management (not pip/venv directly)
|
|
17
|
+
- Windows users: Use `.venv\Scripts\activate` instead of `source .venv/bin/activate`
|
|
18
|
+
|
|
19
|
+
## Development Workflow
|
|
20
|
+
|
|
21
|
+
### Initial Setup
|
|
22
|
+
```bash
|
|
23
|
+
uv venv
|
|
24
|
+
.venv\Scripts\activate # Windows
|
|
25
|
+
maturin develop
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### After Modifying Rust Code
|
|
29
|
+
```bash
|
|
30
|
+
maturin develop # Required to see changes in Python
|
|
31
|
+
pytest # Verify changes work
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Before Committing
|
|
35
|
+
```bash
|
|
36
|
+
cargo fmt # Format Rust code
|
|
37
|
+
cargo clippy # Lint Rust code
|
|
38
|
+
ruff format . # Format Python code
|
|
39
|
+
ruff check . # Lint Python code
|
|
40
|
+
uvx ty check # Type check Python stubs
|
|
41
|
+
cargo test # Run Rust unit tests
|
|
42
|
+
pytest # Run Python integration tests
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Or use pre-commit hooks:
|
|
46
|
+
```bash
|
|
47
|
+
pre-commit run --all-files
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Testing Strategy
|
|
51
|
+
- **Rust tests** (`cargo test`): Unit tests for internal logic, run in Rust
|
|
52
|
+
- **Python tests** (`pytest`): Integration tests for Python API, require `maturin develop` first
|
|
53
|
+
- Never skip `maturin develop` before running pytest - tests will fail with import errors
|
|
54
|
+
- Pre-commit runs pytest on pre-push (not pre-commit) to avoid slow commits
|
|
55
|
+
|
|
56
|
+
## Code Quality Tools
|
|
57
|
+
- **Rust**: `cargo fmt` (formatting), `cargo clippy` (linting)
|
|
58
|
+
- **Python**: `ruff format` (formatting), `ruff check` (linting), `uvx ty` (type checking)
|
|
59
|
+
- All configured in `.pre-commit-config.yaml` with auto-fix enabled where safe
|
|
60
|
+
|
|
61
|
+
## Cryptographic Standards (PASETO v4)
|
|
62
|
+
- **v4.local**: XChaCha20-Poly1305 encryption + BLAKE2b-MAC (32-byte symmetric key)
|
|
63
|
+
- **v4.public**: Ed25519 signatures (64-byte secret key, 32-byte public key)
|
|
64
|
+
- All crypto operations MUST stay in Rust - never implement in Python
|
|
65
|
+
- Key lengths are validated at runtime - incorrect sizes will error
|
|
66
|
+
|
|
67
|
+
## Common Pitfalls
|
|
68
|
+
- Forgetting `maturin develop` after Rust changes (most common error)
|
|
69
|
+
- Using `pip install -e .` instead of `maturin develop` (won't work)
|
|
70
|
+
- Trying to run pytest without building the extension first
|
|
71
|
+
- Adding Python runtime dependencies (violates pure-extension design)
|
|
72
|
+
- Implementing crypto in Python instead of Rust (security risk)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
# Standard pre-commit hooks
|
|
3
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
4
|
+
rev: v5.0.0
|
|
5
|
+
hooks:
|
|
6
|
+
- id: check-yaml
|
|
7
|
+
- id: check-toml
|
|
8
|
+
- id: end-of-file-fixer
|
|
9
|
+
- id: trailing-whitespace
|
|
10
|
+
- id: check-added-large-files
|
|
11
|
+
- id: check-merge-conflict
|
|
12
|
+
|
|
13
|
+
# Ruff linter and formatter
|
|
14
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
15
|
+
rev: v0.8.6
|
|
16
|
+
hooks:
|
|
17
|
+
- id: ruff
|
|
18
|
+
args: [--fix, --exit-non-zero-on-fix]
|
|
19
|
+
- id: ruff-format
|
|
20
|
+
|
|
21
|
+
# ty type checker (via uvx since no official pre-commit hook yet)
|
|
22
|
+
- repo: local
|
|
23
|
+
hooks:
|
|
24
|
+
- id: ty
|
|
25
|
+
name: ty type check
|
|
26
|
+
entry: uvx ty check
|
|
27
|
+
language: system
|
|
28
|
+
types: [python]
|
|
29
|
+
pass_filenames: false
|
|
30
|
+
|
|
31
|
+
- id: pytest
|
|
32
|
+
name: pytest
|
|
33
|
+
entry: pytest
|
|
34
|
+
language: system
|
|
35
|
+
types: [python]
|
|
36
|
+
pass_filenames: false
|
|
37
|
+
stages: [pre-push]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.11
|