captchakit 0.2.0__tar.gz → 0.3.0__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.
- {captchakit-0.2.0 → captchakit-0.3.0}/CHANGELOG.md +22 -5
- {captchakit-0.2.0 → captchakit-0.3.0}/PKG-INFO +7 -7
- {captchakit-0.2.0 → captchakit-0.3.0}/README.md +6 -6
- captchakit-0.3.0/ROADMAP.md +63 -0
- {captchakit-0.2.0 → captchakit-0.3.0}/pyproject.toml +1 -1
- {captchakit-0.2.0 → captchakit-0.3.0}/src/captchakit/__init__.py +3 -1
- captchakit-0.3.0/src/captchakit/adapters/discord.py +85 -0
- {captchakit-0.2.0 → captchakit-0.3.0}/src/captchakit/challenges/__init__.py +2 -0
- captchakit-0.3.0/src/captchakit/challenges/word.py +56 -0
- captchakit-0.2.0/ROADMAP.md +0 -422
- {captchakit-0.2.0 → captchakit-0.3.0}/.gitignore +0 -0
- {captchakit-0.2.0 → captchakit-0.3.0}/LICENSE +0 -0
- {captchakit-0.2.0 → captchakit-0.3.0}/src/captchakit/_clock.py +0 -0
- {captchakit-0.2.0 → captchakit-0.3.0}/src/captchakit/adapters/__init__.py +0 -0
- {captchakit-0.2.0 → captchakit-0.3.0}/src/captchakit/adapters/aiogram.py +0 -0
- {captchakit-0.2.0 → captchakit-0.3.0}/src/captchakit/adapters/fastapi.py +0 -0
- {captchakit-0.2.0 → captchakit-0.3.0}/src/captchakit/challenges/base.py +0 -0
- {captchakit-0.2.0 → captchakit-0.3.0}/src/captchakit/challenges/grid.py +0 -0
- {captchakit-0.2.0 → captchakit-0.3.0}/src/captchakit/challenges/math.py +0 -0
- {captchakit-0.2.0 → captchakit-0.3.0}/src/captchakit/challenges/text.py +0 -0
- {captchakit-0.2.0 → captchakit-0.3.0}/src/captchakit/errors.py +0 -0
- {captchakit-0.2.0 → captchakit-0.3.0}/src/captchakit/manager.py +0 -0
- {captchakit-0.2.0 → captchakit-0.3.0}/src/captchakit/py.typed +0 -0
- {captchakit-0.2.0 → captchakit-0.3.0}/src/captchakit/renderers/__init__.py +0 -0
- {captchakit-0.2.0 → captchakit-0.3.0}/src/captchakit/renderers/base.py +0 -0
- {captchakit-0.2.0 → captchakit-0.3.0}/src/captchakit/renderers/image.py +0 -0
- {captchakit-0.2.0 → captchakit-0.3.0}/src/captchakit/storage/__init__.py +0 -0
- {captchakit-0.2.0 → captchakit-0.3.0}/src/captchakit/storage/base.py +0 -0
- {captchakit-0.2.0 → captchakit-0.3.0}/src/captchakit/storage/memory.py +0 -0
- {captchakit-0.2.0 → captchakit-0.3.0}/src/captchakit/storage/redis.py +0 -0
|
@@ -7,11 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
### Planned for 0.
|
|
11
|
-
- `
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
-
|
|
10
|
+
### Planned for 0.4
|
|
11
|
+
- `AudioChallenge` (optional extra — accessibility alternative to images).
|
|
12
|
+
- i18n hooks for challenge prompts.
|
|
13
|
+
- Theming presets (color palettes, font bundles) for `ImageRenderer`.
|
|
14
|
+
- Metrics callbacks (Prometheus-compatible counters for issue / verify).
|
|
15
|
+
|
|
16
|
+
## [0.3.0] - 2026-04-20
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
- `discord.py` adapter: `captchakit.adapters.discord.send_captcha(channel, manager)`
|
|
20
|
+
helper (`pip install "captchakit[discord]"`). Mirrors the aiogram adapter —
|
|
21
|
+
thin, stateless, returns the challenge id for the caller to persist.
|
|
22
|
+
- `WordChallengeFactory`: accessibility-oriented factory that picks a real
|
|
23
|
+
word from a bundled 50-word English list (or a user-supplied tuple).
|
|
24
|
+
- `mkdocs-material` documentation site: quickstart, adapter guides, storage
|
|
25
|
+
guide, API reference via `mkdocstrings`. Deployed from `main` to
|
|
26
|
+
`gh-pages` through `.github/workflows/docs.yml`.
|
|
27
|
+
|
|
28
|
+
### Changed
|
|
29
|
+
- `ROADMAP.md` rewritten as a concise English overview; detailed
|
|
30
|
+
implementation plans were migrated into CHANGELOG / CONTRIBUTING /
|
|
31
|
+
docs where they belong.
|
|
15
32
|
|
|
16
33
|
## [0.2.0] - 2026-04-20
|
|
17
34
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: captchakit
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Async-first, fully type-hinted, minimal captcha library with adapters for aiogram, FastAPI and Discord.
|
|
5
5
|
Project-URL: Homepage, https://github.com/akerem16/captchakit
|
|
6
6
|
Project-URL: Repository, https://github.com/akerem16/captchakit
|
|
@@ -60,7 +60,7 @@ Description-Content-Type: text/markdown
|
|
|
60
60
|
> **Async-first, fully type-hinted captcha library for Python 3.10+.**
|
|
61
61
|
> Zero runtime deps beyond Pillow. Drop-in adapters for FastAPI, aiogram and discord.py.
|
|
62
62
|
|
|
63
|
-
[](https://pypi.org/project/captchakit/)
|
|
64
64
|
[](https://pypi.org/project/captchakit/)
|
|
65
65
|
[](https://github.com/akerem16/captchakit/actions/workflows/ci.yml)
|
|
66
66
|
[](http://mypy-lang.org/)
|
|
@@ -86,12 +86,11 @@ Description-Content-Type: text/markdown
|
|
|
86
86
|
pip install captchakit # core
|
|
87
87
|
pip install "captchakit[fastapi]" # + FastAPI adapter
|
|
88
88
|
pip install "captchakit[aiogram]" # + aiogram adapter
|
|
89
|
-
pip install "captchakit[discord]" # + discord.py adapter
|
|
89
|
+
pip install "captchakit[discord]" # + discord.py adapter
|
|
90
90
|
pip install "captchakit[redis]" # + Redis storage backend
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
> adapter module itself is not yet shipped. See [ROADMAP.md](ROADMAP.md).
|
|
93
|
+
See [ROADMAP.md](ROADMAP.md) for what's next.
|
|
95
94
|
|
|
96
95
|
## 30-second example
|
|
97
96
|
|
|
@@ -177,9 +176,10 @@ See [ROADMAP.md](ROADMAP.md) for the full development plan.
|
|
|
177
176
|
|
|
178
177
|
| Version | Highlights |
|
|
179
178
|
|---|---|
|
|
180
|
-
| 0.1
|
|
179
|
+
| 0.1 ✅ | Core + Text/Math challenges + Image renderer + Memory storage + FastAPI |
|
|
181
180
|
| 0.2 ✅ | aiogram adapter + RedisStorage + EmojiGridChallenge |
|
|
182
|
-
| 0.3 | discord.py adapter +
|
|
181
|
+
| 0.3 ✅ | discord.py adapter + WordChallenge + docs site |
|
|
182
|
+
| 0.4 | AudioChallenge (optional) + i18n + theming + metrics hooks |
|
|
183
183
|
| 0.4 | i18n + theming + metrics hooks |
|
|
184
184
|
| 1.0 | Stable API, semver commitment |
|
|
185
185
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
> **Async-first, fully type-hinted captcha library for Python 3.10+.**
|
|
4
4
|
> Zero runtime deps beyond Pillow. Drop-in adapters for FastAPI, aiogram and discord.py.
|
|
5
5
|
|
|
6
|
-
[](https://pypi.org/project/captchakit/)
|
|
7
7
|
[](https://pypi.org/project/captchakit/)
|
|
8
8
|
[](https://github.com/akerem16/captchakit/actions/workflows/ci.yml)
|
|
9
9
|
[](http://mypy-lang.org/)
|
|
@@ -29,12 +29,11 @@
|
|
|
29
29
|
pip install captchakit # core
|
|
30
30
|
pip install "captchakit[fastapi]" # + FastAPI adapter
|
|
31
31
|
pip install "captchakit[aiogram]" # + aiogram adapter
|
|
32
|
-
pip install "captchakit[discord]" # + discord.py adapter
|
|
32
|
+
pip install "captchakit[discord]" # + discord.py adapter
|
|
33
33
|
pip install "captchakit[redis]" # + Redis storage backend
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
> adapter module itself is not yet shipped. See [ROADMAP.md](ROADMAP.md).
|
|
36
|
+
See [ROADMAP.md](ROADMAP.md) for what's next.
|
|
38
37
|
|
|
39
38
|
## 30-second example
|
|
40
39
|
|
|
@@ -120,9 +119,10 @@ See [ROADMAP.md](ROADMAP.md) for the full development plan.
|
|
|
120
119
|
|
|
121
120
|
| Version | Highlights |
|
|
122
121
|
|---|---|
|
|
123
|
-
| 0.1
|
|
122
|
+
| 0.1 ✅ | Core + Text/Math challenges + Image renderer + Memory storage + FastAPI |
|
|
124
123
|
| 0.2 ✅ | aiogram adapter + RedisStorage + EmojiGridChallenge |
|
|
125
|
-
| 0.3 | discord.py adapter +
|
|
124
|
+
| 0.3 ✅ | discord.py adapter + WordChallenge + docs site |
|
|
125
|
+
| 0.4 | AudioChallenge (optional) + i18n + theming + metrics hooks |
|
|
126
126
|
| 0.4 | i18n + theming + metrics hooks |
|
|
127
127
|
| 1.0 | Stable API, semver commitment |
|
|
128
128
|
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# captchakit — Roadmap
|
|
2
|
+
|
|
3
|
+
> Async-first, fully type-hinted, minimal captcha library with framework
|
|
4
|
+
> adapters.
|
|
5
|
+
|
|
6
|
+
**Python:** 3.10+ · **License:** MIT · **Audience:** Telegram / Discord bot
|
|
7
|
+
developers, FastAPI backend authors, small-to-mid self-hosted services that
|
|
8
|
+
want a lightweight human-check without pulling in a third-party service.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Vision
|
|
13
|
+
|
|
14
|
+
Most Python captcha libraries are sync, partially typed, and stop at "render
|
|
15
|
+
a PNG." They leave TTL, attempt tracking, storage, and framework integration
|
|
16
|
+
as homework. captchakit closes that gap: a small, modern SDK you drop into
|
|
17
|
+
an async codebase and forget about.
|
|
18
|
+
|
|
19
|
+
## Pillars
|
|
20
|
+
|
|
21
|
+
1. **Async-first.** Every public API is awaitable; CPU-bound Pillow work is
|
|
22
|
+
offloaded so the event loop never blocks.
|
|
23
|
+
2. **Fully typed.** `py.typed` marker + `mypy --strict` clean. IDEs get real
|
|
24
|
+
autocompletion.
|
|
25
|
+
3. **Minimal core.** One runtime dependency: Pillow. Everything else —
|
|
26
|
+
Redis, aiogram, FastAPI, discord.py — is an opt-in extra.
|
|
27
|
+
4. **Pluggable.** Challenges, renderers and storage are `Protocol`-based, so
|
|
28
|
+
you can swap any layer without subclassing.
|
|
29
|
+
5. **Safe defaults.** Crypto-safe randomness (`secrets`), constant-time
|
|
30
|
+
comparison (`hmac.compare_digest`), TTL + attempt limits enforced by the
|
|
31
|
+
manager.
|
|
32
|
+
|
|
33
|
+
## Non-goals
|
|
34
|
+
|
|
35
|
+
- Not a CAPTCHA-solving bot framework. captchakit generates challenges; it
|
|
36
|
+
does not bypass hCaptcha / reCAPTCHA / Turnstile.
|
|
37
|
+
- Not a defence against modern OCR or solver farms. For high-value surfaces
|
|
38
|
+
(login, payment, password reset), use a purpose-built service in addition.
|
|
39
|
+
- Not an orchestration framework. Adapters stay thin; user/session state
|
|
40
|
+
belongs to the host application (FSM, cookies, session store).
|
|
41
|
+
|
|
42
|
+
## Version roadmap
|
|
43
|
+
|
|
44
|
+
| Version | Status | Scope |
|
|
45
|
+
|---|---|---|
|
|
46
|
+
| **0.1** | ✅ released | Core `CaptchaManager` · Text / Math challenges · Image renderer · Memory storage · FastAPI adapter |
|
|
47
|
+
| **0.2** | ✅ released | `RedisStorage` · `EmojiGridChallenge` · aiogram adapter |
|
|
48
|
+
| **0.3** | in progress | `discord.py` adapter · `WordChallenge` · docs site |
|
|
49
|
+
| **0.4** | planned | `AudioChallenge` (optional extra) · i18n hooks · theming presets · metrics callbacks |
|
|
50
|
+
| **1.0** | planned | Stable API, semver commitment, ≥90% coverage on every adapter, hardened security docs |
|
|
51
|
+
|
|
52
|
+
Each release keeps the gate: `ruff` + `mypy --strict` + `pytest` green, coverage
|
|
53
|
+
≥ 90%, CHANGELOG entry, one runnable example.
|
|
54
|
+
|
|
55
|
+
## Contributing
|
|
56
|
+
|
|
57
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for local setup, adding a challenge /
|
|
58
|
+
storage / adapter, and the commit-message convention.
|
|
59
|
+
|
|
60
|
+
## Security
|
|
61
|
+
|
|
62
|
+
See [SECURITY.md](SECURITY.md) for the threat model and vulnerability
|
|
63
|
+
reporting channel.
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "captchakit"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.3.0"
|
|
8
8
|
description = "Async-first, fully type-hinted, minimal captcha library with adapters for aiogram, FastAPI and Discord."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -10,6 +10,7 @@ from captchakit.challenges import (
|
|
|
10
10
|
EmojiGridChallengeFactory,
|
|
11
11
|
MathChallengeFactory,
|
|
12
12
|
TextChallengeFactory,
|
|
13
|
+
WordChallengeFactory,
|
|
13
14
|
)
|
|
14
15
|
from captchakit.errors import (
|
|
15
16
|
CaptchaKitError,
|
|
@@ -23,7 +24,7 @@ from captchakit.manager import CaptchaManager
|
|
|
23
24
|
from captchakit.renderers import ImageRenderer, Renderer
|
|
24
25
|
from captchakit.storage import MemoryStorage, Storage
|
|
25
26
|
|
|
26
|
-
__version__ = "0.
|
|
27
|
+
__version__ = "0.3.0"
|
|
27
28
|
|
|
28
29
|
__all__ = [
|
|
29
30
|
"CaptchaKitError",
|
|
@@ -45,5 +46,6 @@ __all__ = [
|
|
|
45
46
|
"StorageError",
|
|
46
47
|
"TextChallengeFactory",
|
|
47
48
|
"TooManyAttempts",
|
|
49
|
+
"WordChallengeFactory",
|
|
48
50
|
"__version__",
|
|
49
51
|
]
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"""discord.py adapter.
|
|
2
|
+
|
|
3
|
+
Install with ``pip install "captchakit[discord]"``.
|
|
4
|
+
|
|
5
|
+
Exposes a single helper, :func:`send_captcha`, that issues a new challenge,
|
|
6
|
+
uploads the rendered PNG through ``channel.send`` as a file attachment, and
|
|
7
|
+
returns the challenge id. The caller persists that id (e.g. keyed by
|
|
8
|
+
``member.id`` in a dict, Redis, or a database) and calls
|
|
9
|
+
:meth:`CaptchaManager.verify` when the user replies.
|
|
10
|
+
|
|
11
|
+
Thin by design — the challenge lifecycle lives in
|
|
12
|
+
:class:`~captchakit.CaptchaManager`; state coordination with your bot's
|
|
13
|
+
cogs/commands is your concern.
|
|
14
|
+
|
|
15
|
+
Example::
|
|
16
|
+
|
|
17
|
+
import discord
|
|
18
|
+
from discord.ext import commands
|
|
19
|
+
from captchakit import CaptchaManager, ImageRenderer, MathChallengeFactory, MemoryStorage
|
|
20
|
+
from captchakit.adapters.discord import send_captcha
|
|
21
|
+
|
|
22
|
+
bot = commands.Bot(command_prefix="!", intents=discord.Intents.all())
|
|
23
|
+
manager = CaptchaManager(
|
|
24
|
+
MathChallengeFactory(), ImageRenderer(), MemoryStorage(),
|
|
25
|
+
)
|
|
26
|
+
pending: dict[int, str] = {} # member_id -> challenge_id
|
|
27
|
+
|
|
28
|
+
@bot.event
|
|
29
|
+
async def on_member_join(member: discord.Member) -> None:
|
|
30
|
+
dm = await member.create_dm()
|
|
31
|
+
pending[member.id] = await send_captcha(dm, manager)
|
|
32
|
+
|
|
33
|
+
@bot.event
|
|
34
|
+
async def on_message(msg: discord.Message) -> None:
|
|
35
|
+
cid = pending.get(msg.author.id)
|
|
36
|
+
if cid is None or msg.guild is not None:
|
|
37
|
+
return
|
|
38
|
+
if await manager.verify(cid, msg.content):
|
|
39
|
+
del pending[msg.author.id]
|
|
40
|
+
await msg.channel.send("Welcome!")
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
from __future__ import annotations
|
|
44
|
+
|
|
45
|
+
from io import BytesIO
|
|
46
|
+
from typing import TYPE_CHECKING
|
|
47
|
+
|
|
48
|
+
try:
|
|
49
|
+
import discord
|
|
50
|
+
except ImportError as exc: # pragma: no cover
|
|
51
|
+
raise ImportError(
|
|
52
|
+
"discord adapter requires the `discord` extra: pip install 'captchakit[discord]'"
|
|
53
|
+
) from exc
|
|
54
|
+
|
|
55
|
+
if TYPE_CHECKING:
|
|
56
|
+
from discord.abc import Messageable
|
|
57
|
+
|
|
58
|
+
from captchakit.manager import CaptchaManager
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
DEFAULT_CONTENT = "Please solve this captcha to continue."
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
async def send_captcha(
|
|
65
|
+
channel: Messageable,
|
|
66
|
+
manager: CaptchaManager,
|
|
67
|
+
*,
|
|
68
|
+
content: str = DEFAULT_CONTENT,
|
|
69
|
+
filename: str = "captcha.png",
|
|
70
|
+
) -> str:
|
|
71
|
+
"""Issue a captcha, send it to ``channel``, return the challenge id.
|
|
72
|
+
|
|
73
|
+
``channel`` is anything implementing ``discord.abc.Messageable`` — a
|
|
74
|
+
``TextChannel``, ``DMChannel`` or ``Thread``. The rendered PNG is
|
|
75
|
+
attached via :class:`discord.File`.
|
|
76
|
+
"""
|
|
77
|
+
challenge_id, png_bytes = await manager.issue()
|
|
78
|
+
await channel.send(
|
|
79
|
+
content=content,
|
|
80
|
+
file=discord.File(BytesIO(png_bytes), filename=filename),
|
|
81
|
+
)
|
|
82
|
+
return challenge_id
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
__all__ = ["send_captcha"]
|
|
@@ -6,6 +6,7 @@ from captchakit.challenges.base import Challenge, ChallengeFactory, ChallengeSpe
|
|
|
6
6
|
from captchakit.challenges.grid import EmojiGridChallengeFactory
|
|
7
7
|
from captchakit.challenges.math import MathChallengeFactory
|
|
8
8
|
from captchakit.challenges.text import TextChallengeFactory
|
|
9
|
+
from captchakit.challenges.word import WordChallengeFactory
|
|
9
10
|
|
|
10
11
|
__all__ = [
|
|
11
12
|
"Challenge",
|
|
@@ -14,4 +15,5 @@ __all__ = [
|
|
|
14
15
|
"EmojiGridChallengeFactory",
|
|
15
16
|
"MathChallengeFactory",
|
|
16
17
|
"TextChallengeFactory",
|
|
18
|
+
"WordChallengeFactory",
|
|
17
19
|
]
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""Wordlist-based challenges.
|
|
2
|
+
|
|
3
|
+
An accessibility-oriented alternative to :class:`TextChallengeFactory`:
|
|
4
|
+
the user reads a real word from the image instead of a random letter
|
|
5
|
+
scramble, which is easier for people using screen magnifiers or dealing
|
|
6
|
+
with dyslexia, while still providing a reasonable bot-deterrent.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import secrets
|
|
12
|
+
from dataclasses import dataclass, field
|
|
13
|
+
|
|
14
|
+
from captchakit.challenges.base import ChallengeSpec
|
|
15
|
+
|
|
16
|
+
# A small bundled wordlist of common, unambiguous 5-letter English words.
|
|
17
|
+
# Deliberately avoids offensive / politically charged terms.
|
|
18
|
+
DEFAULT_WORDS: tuple[str, ...] = (
|
|
19
|
+
"apple", "brave", "chair", "dream", "eagle",
|
|
20
|
+
"flame", "grape", "happy", "ivory", "jolly",
|
|
21
|
+
"knife", "lemon", "maple", "night", "olive",
|
|
22
|
+
"piano", "quilt", "river", "smile", "table",
|
|
23
|
+
"umbra", "voice", "wheat", "young", "zebra",
|
|
24
|
+
"bread", "cloud", "dance", "earth", "field",
|
|
25
|
+
"glory", "honey", "inbox", "jumbo", "karma",
|
|
26
|
+
"light", "music", "novel", "ocean", "paint",
|
|
27
|
+
"quick", "raven", "storm", "tiger", "urban",
|
|
28
|
+
"vivid", "waltz", "xenon", "yacht", "zesty",
|
|
29
|
+
) # fmt: skip
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@dataclass(slots=True)
|
|
33
|
+
class WordChallengeFactory:
|
|
34
|
+
"""Produces a single random word from a wordlist.
|
|
35
|
+
|
|
36
|
+
The default list avoids visually / phonetically ambiguous words and
|
|
37
|
+
ships ~50 common English nouns. Pass your own ``words`` tuple to
|
|
38
|
+
localise or narrow the pool.
|
|
39
|
+
"""
|
|
40
|
+
|
|
41
|
+
words: tuple[str, ...] = field(default_factory=lambda: DEFAULT_WORDS)
|
|
42
|
+
case_sensitive: bool = False
|
|
43
|
+
|
|
44
|
+
def __post_init__(self) -> None:
|
|
45
|
+
if not self.words:
|
|
46
|
+
raise ValueError("words must be non-empty")
|
|
47
|
+
if any(not w.strip() for w in self.words):
|
|
48
|
+
raise ValueError("words must not contain empty strings")
|
|
49
|
+
|
|
50
|
+
async def create(self) -> ChallengeSpec:
|
|
51
|
+
word = secrets.choice(self.words)
|
|
52
|
+
return ChallengeSpec(
|
|
53
|
+
prompt=word,
|
|
54
|
+
solution=word,
|
|
55
|
+
case_sensitive=self.case_sensitive,
|
|
56
|
+
)
|
captchakit-0.2.0/ROADMAP.md
DELETED
|
@@ -1,422 +0,0 @@
|
|
|
1
|
-
# captchakit — Geliştirme Yol Haritası
|
|
2
|
-
|
|
3
|
-
> Async-first, fully type-hinted, Pillow dışında runtime bağımlılığı olmayan, aiogram / FastAPI / Discord için hazır adapter'lı minimal captcha kütüphanesi.
|
|
4
|
-
|
|
5
|
-
**Python desteği:** 3.10+ (kullanıcı kararı; `match/case`, `X | Y` union, `ParamSpec`, `dataclass(slots=True)` kullanılabilir)
|
|
6
|
-
**Lisans:** MIT
|
|
7
|
-
**Hedef kitle:** Telegram/Discord bot geliştiricileri, FastAPI backend yazarları, küçük-orta ölçekli self-hosted servisler.
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## 1. Vizyon & Konumlandırma
|
|
12
|
-
|
|
13
|
-
### 1.1 Problem
|
|
14
|
-
Python ekosisteminde captcha üreten kütüphaneler mevcut (lepture/captcha, claptcha, multicolorcaptcha, easy-captcha), fakat hepsinde şu boşluklar var:
|
|
15
|
-
|
|
16
|
-
| Eksik | Mevcut kütüphaneler | captchakit'nın tutumu |
|
|
17
|
-
|---|---|---|
|
|
18
|
-
| Async API | yok (hepsi sync) | `async def generate(...)`, thread-pool'a offload |
|
|
19
|
-
| `py.typed` + tam type hint | kısmi / yok | PEP 561 uyumlu, mypy strict'te geçer |
|
|
20
|
-
| Framework adapter | yok | aiogram, FastAPI, Discord (py-cord/discord.py) |
|
|
21
|
-
| Storage soyutlaması (challenge ↔ solution eşleme + TTL) | yok | `Protocol` tabanlı `Storage`; in-memory + Redis |
|
|
22
|
-
| Challenge çeşitliliği | genelde sadece text | text, math, emoji-grid, audio (opsiyonel ekstra) |
|
|
23
|
-
| Modern toolchain | setup.py, flake8 | uv + Ruff + mypy + hatchling |
|
|
24
|
-
|
|
25
|
-
### 1.2 Konum
|
|
26
|
-
**"Use-case odaklı bir captcha SDK"** — sadece görüntü üretmiyor; "kullanıcıya soru sor, cevabı doğrula, TTL ile temizle" akışını başından sonuna çözüyor. Web servisleri ve botlar için "drop-in" olacak.
|
|
27
|
-
|
|
28
|
-
### 1.3 Non-goals (netleşsin ki scope creep olmasın)
|
|
29
|
-
- Bot-solver / bypass aracı değil (2captcha, capsolver gibi).
|
|
30
|
-
- Production-grade CV-dirençli güvenlik captcha'sı değil. hCaptcha/reCAPTCHA'nın yerine geçmez; "basit human-check" katmanıdır. README'de açıkça yazılacak.
|
|
31
|
-
- ML / audio üretimi v1 için opsiyonel extra; core'un dışında.
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
## 2. Rakip Analizi (özet)
|
|
36
|
-
|
|
37
|
-
- **lepture/captcha** (v0.7.1, Mart 2025): En yaygın. Sync, `ImageCaptcha` + `AudioCaptcha`. Type hint kısmi, adapter yok.
|
|
38
|
-
- **claptcha**: Basit, Pillow tabanlı, bakım azalmış.
|
|
39
|
-
- **multicolorcaptcha**: Telegram bot odaklı math captcha, ama sync ve type hint yok.
|
|
40
|
-
- **fast_captcha**: FastAPI örneği, storage/TTL yönetimi yok.
|
|
41
|
-
- **TLG_JoinCaptchaBot / discordpy-captcha**: Kütüphane değil, uygulama.
|
|
42
|
-
|
|
43
|
-
**Fark yaratacağımız 3 şey:** (1) async-first + tam typed, (2) storage/expiry yönetimi core'da, (3) framework adapter'ları.
|
|
44
|
-
|
|
45
|
-
---
|
|
46
|
-
|
|
47
|
-
## 3. Teknik Gereksinimler
|
|
48
|
-
|
|
49
|
-
### 3.1 Runtime
|
|
50
|
-
- **Zorunlu:** `Pillow>=10.0`
|
|
51
|
-
- **Hiçbir başka runtime dep yok** (kararlılık ve "minimal" vaadi için).
|
|
52
|
-
- **Opsiyonel extras** (pyproject `[project.optional-dependencies]`):
|
|
53
|
-
- `aiogram`: `aiogram>=3.4`
|
|
54
|
-
- `fastapi`: `fastapi>=0.110`, `starlette`
|
|
55
|
-
- `discord`: `discord.py>=2.3` (py-cord çatışmamak için tek seçim; adapter'ı soyutla)
|
|
56
|
-
- `redis`: `redis>=5.0` (async client)
|
|
57
|
-
- `audio`: opsiyonel; v0.3+ hedefi
|
|
58
|
-
- `dev`: ruff, mypy, pytest, pytest-asyncio, hypothesis, coverage, mkdocs-material
|
|
59
|
-
|
|
60
|
-
### 3.2 Geliştirme toolchain'i
|
|
61
|
-
- **uv** — paket + venv
|
|
62
|
-
- **Ruff** — lint + format (black+isort+flake8 yerine)
|
|
63
|
-
- **mypy --strict** — tip kontrol
|
|
64
|
-
- **pytest + pytest-asyncio + hypothesis** — test
|
|
65
|
-
- **hatchling** — build backend
|
|
66
|
-
- **pre-commit** — hooks (ruff, mypy, trailing whitespace)
|
|
67
|
-
- **GitHub Actions** — CI matrisi
|
|
68
|
-
|
|
69
|
-
### 3.3 Desteklenen Python sürümleri
|
|
70
|
-
3.10, 3.11, 3.12, 3.13 — CI matrisinde hepsi.
|
|
71
|
-
|
|
72
|
-
---
|
|
73
|
-
|
|
74
|
-
## 4. Repo & Paket Yapısı
|
|
75
|
-
|
|
76
|
-
```
|
|
77
|
-
captchakit/
|
|
78
|
-
├── pyproject.toml
|
|
79
|
-
├── README.md # hook + quickstart + badges
|
|
80
|
-
├── ROADMAP.md # (bu dosya)
|
|
81
|
-
├── CHANGELOG.md # Keep a Changelog formatı
|
|
82
|
-
├── LICENSE # MIT
|
|
83
|
-
├── .github/
|
|
84
|
-
│ ├── workflows/ci.yml # lint, type, test matrix
|
|
85
|
-
│ ├── workflows/release.yml # tag push -> PyPI trusted publishing
|
|
86
|
-
│ ├── ISSUE_TEMPLATE/
|
|
87
|
-
│ └── dependabot.yml
|
|
88
|
-
├── src/
|
|
89
|
-
│ └── captchakit/
|
|
90
|
-
│ ├── __init__.py # public API re-exports
|
|
91
|
-
│ ├── py.typed # PEP 561 işaretçisi
|
|
92
|
-
│ ├── types.py # TypedDict, Protocol, TypeAlias
|
|
93
|
-
│ ├── challenges/
|
|
94
|
-
│ │ ├── base.py # Challenge, Renderer protocolleri
|
|
95
|
-
│ │ ├── text.py # TextChallenge
|
|
96
|
-
│ │ ├── math.py # MathChallenge (2+3=?)
|
|
97
|
-
│ │ └── grid.py # EmojiGridChallenge
|
|
98
|
-
│ ├── renderers/
|
|
99
|
-
│ │ ├── image.py # Pillow renderer
|
|
100
|
-
│ │ └── fonts/ # DejaVu Sans (bundled, SIL OFL)
|
|
101
|
-
│ ├── storage/
|
|
102
|
-
│ │ ├── base.py # Storage Protocol
|
|
103
|
-
│ │ ├── memory.py # dict + asyncio.Lock
|
|
104
|
-
│ │ └── redis.py # opsiyonel extra
|
|
105
|
-
│ ├── manager.py # CaptchaManager (core orchestrator)
|
|
106
|
-
│ ├── errors.py # custom exceptions
|
|
107
|
-
│ └── adapters/
|
|
108
|
-
│ ├── __init__.py
|
|
109
|
-
│ ├── aiogram.py # middleware + helper
|
|
110
|
-
│ ├── fastapi.py # dependency + router
|
|
111
|
-
│ └── discord.py # cog + verification flow
|
|
112
|
-
├── tests/
|
|
113
|
-
│ ├── conftest.py
|
|
114
|
-
│ ├── test_manager.py
|
|
115
|
-
│ ├── test_challenges/
|
|
116
|
-
│ ├── test_renderers/
|
|
117
|
-
│ ├── test_storage/
|
|
118
|
-
│ └── adapters/
|
|
119
|
-
│ ├── test_aiogram.py
|
|
120
|
-
│ ├── test_fastapi.py
|
|
121
|
-
│ └── test_discord.py
|
|
122
|
-
├── examples/
|
|
123
|
-
│ ├── aiogram_bot.py
|
|
124
|
-
│ ├── fastapi_login.py
|
|
125
|
-
│ └── discord_verify.py
|
|
126
|
-
└── docs/ # mkdocs-material
|
|
127
|
-
├── index.md
|
|
128
|
-
├── quickstart.md
|
|
129
|
-
├── adapters/
|
|
130
|
-
└── api/
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
### 4.1 İsim kararı
|
|
134
|
-
- Dizin: `captchakit/` (GitHub repo adı da aynı).
|
|
135
|
-
- **Import adı da `captchakit`** (kullanıcı net şekilde aradığı için kısa olan tercih edildi).
|
|
136
|
-
- **PyPI'de `captchakit` müsaitliği kontrol edilmeli** (0.1 yayın öncesi). Alınmışsa alternatif: `captchakit` veya `captchakit-async`.
|
|
137
|
-
|
|
138
|
-
---
|
|
139
|
-
|
|
140
|
-
## 5. Mimari Kararlar
|
|
141
|
-
|
|
142
|
-
### 5.1 Katmanlar
|
|
143
|
-
```
|
|
144
|
-
┌─────────────────────────────────────────────────┐
|
|
145
|
-
│ Adapters (aiogram / fastapi / discord) │ <- opsiyonel extras
|
|
146
|
-
├─────────────────────────────────────────────────┤
|
|
147
|
-
│ CaptchaManager (public facade) │
|
|
148
|
-
├──────────────┬──────────────┬───────────────────┤
|
|
149
|
-
│ Challenge │ Renderer │ Storage │ <- Protocol'ler
|
|
150
|
-
│ (Text/Math) │ (Image) │ (Memory/Redis) │
|
|
151
|
-
└──────────────┴──────────────┴───────────────────┘
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
### 5.2 Temel tasarım prensipleri
|
|
155
|
-
- **Protocol > ABC:** structural typing ile dışarıdan implement edilebilsin.
|
|
156
|
-
- **Async pure:** CPU-bound Pillow işleri `asyncio.to_thread` ile offload.
|
|
157
|
-
- **Immutable challenge objects:** `@dataclass(frozen=True, slots=True)`.
|
|
158
|
-
- **Zamanı enjekte et:** `Clock` protocol'ü (test edilebilirlik). Varsayılan `time.monotonic`.
|
|
159
|
-
- **Kriptografik güvenli random:** `secrets.choice` (solution üretiminde). `random` kullanma.
|
|
160
|
-
- **Timing-safe comparison:** `hmac.compare_digest` çözüm doğrulamada.
|
|
161
|
-
|
|
162
|
-
### 5.3 Hataların hiyerarşisi
|
|
163
|
-
```python
|
|
164
|
-
class CaptchaKitError(Exception): ...
|
|
165
|
-
class ChallengeExpired(CaptchaKitError): ...
|
|
166
|
-
class ChallengeNotFound(CaptchaKitError): ...
|
|
167
|
-
class InvalidSolution(CaptchaKitError): ...
|
|
168
|
-
class TooManyAttempts(CaptchaKitError): ...
|
|
169
|
-
class StorageError(CaptchaKitError): ...
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
---
|
|
173
|
-
|
|
174
|
-
## 6. Core API (taslak)
|
|
175
|
-
|
|
176
|
-
### 6.1 Challenge & Renderer protocol'leri
|
|
177
|
-
```python
|
|
178
|
-
# challenges/base.py
|
|
179
|
-
from typing import Protocol, runtime_checkable
|
|
180
|
-
from dataclasses import dataclass
|
|
181
|
-
|
|
182
|
-
@dataclass(frozen=True, slots=True)
|
|
183
|
-
class Challenge:
|
|
184
|
-
id: str # uuid4
|
|
185
|
-
prompt: str # "7 + 3 = ?" veya rastgele string
|
|
186
|
-
solution: str # karşılaştırma için (storage'a sadece hash'i gider)
|
|
187
|
-
created_at: float
|
|
188
|
-
expires_at: float
|
|
189
|
-
max_attempts: int = 3
|
|
190
|
-
|
|
191
|
-
@runtime_checkable
|
|
192
|
-
class ChallengeFactory(Protocol):
|
|
193
|
-
async def create(self) -> Challenge: ...
|
|
194
|
-
|
|
195
|
-
@runtime_checkable
|
|
196
|
-
class Renderer(Protocol):
|
|
197
|
-
async def render(self, challenge: Challenge) -> bytes: ... # PNG bytes
|
|
198
|
-
content_type: str # "image/png"
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
### 6.2 Storage protocol'ü
|
|
202
|
-
```python
|
|
203
|
-
# storage/base.py
|
|
204
|
-
class Storage(Protocol):
|
|
205
|
-
async def put(self, challenge: Challenge) -> None: ...
|
|
206
|
-
async def get(self, challenge_id: str) -> Challenge | None: ...
|
|
207
|
-
async def delete(self, challenge_id: str) -> None: ...
|
|
208
|
-
async def incr_attempts(self, challenge_id: str) -> int: ...
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
### 6.3 CaptchaManager (facade)
|
|
212
|
-
```python
|
|
213
|
-
class CaptchaManager:
|
|
214
|
-
def __init__(
|
|
215
|
-
self,
|
|
216
|
-
factory: ChallengeFactory,
|
|
217
|
-
renderer: Renderer,
|
|
218
|
-
storage: Storage,
|
|
219
|
-
*,
|
|
220
|
-
ttl: float = 120.0,
|
|
221
|
-
max_attempts: int = 3,
|
|
222
|
-
) -> None: ...
|
|
223
|
-
|
|
224
|
-
async def issue(self) -> tuple[str, bytes]:
|
|
225
|
-
"""Yeni challenge üretir; (id, image_bytes) döner."""
|
|
226
|
-
|
|
227
|
-
async def verify(self, challenge_id: str, user_input: str) -> bool:
|
|
228
|
-
"""Timing-safe karşılaştırma; başarılıysa storage'dan siler."""
|
|
229
|
-
|
|
230
|
-
async def cleanup_expired(self) -> int:
|
|
231
|
-
"""Background task için; süresi geçenleri siler, sayısını döner."""
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
### 6.4 Public import yüzeyi
|
|
235
|
-
```python
|
|
236
|
-
# captchakit/__init__.py
|
|
237
|
-
from .manager import CaptchaManager
|
|
238
|
-
from .challenges import TextChallenge, MathChallenge
|
|
239
|
-
from .renderers import ImageRenderer
|
|
240
|
-
from .storage import MemoryStorage
|
|
241
|
-
from .errors import (
|
|
242
|
-
CaptchaKitError, ChallengeExpired, ChallengeNotFound,
|
|
243
|
-
InvalidSolution, TooManyAttempts,
|
|
244
|
-
)
|
|
245
|
-
__all__ = [...]
|
|
246
|
-
__version__ = "0.1.0"
|
|
247
|
-
```
|
|
248
|
-
|
|
249
|
-
---
|
|
250
|
-
|
|
251
|
-
## 7. Challenge Tipleri (sürüm planı)
|
|
252
|
-
|
|
253
|
-
| Tip | Örnek | Zorluk | Sürüm |
|
|
254
|
-
|---|---|---|---|
|
|
255
|
-
| `TextChallenge` | "h8k2x" (case-insensitive) | Temel | v0.1 |
|
|
256
|
-
| `MathChallenge` | "7 + 3 = ?" | Kolay, bot-spam önleme | v0.1 |
|
|
257
|
-
| `EmojiGridChallenge` | "🍎 olanları seç" (3×3) | Telegram/Discord inline button uyumlu | v0.2 |
|
|
258
|
-
| `WordChallenge` | "Sabit kelime listesinden 1 kelimeyi yaz" | Erişilebilirlik için | v0.2 |
|
|
259
|
-
| `AudioChallenge` | WAV (sayıları oku) | A11y | v0.3 (opsiyonel extra) |
|
|
260
|
-
|
|
261
|
-
---
|
|
262
|
-
|
|
263
|
-
## 8. Storage Backend'leri
|
|
264
|
-
|
|
265
|
-
- **`MemoryStorage`** (v0.1): `dict[str, Challenge]` + `asyncio.Lock`, periyodik `cleanup_expired` task'i.
|
|
266
|
-
- **`RedisStorage`** (v0.2, `extras=[redis]`): `SETEX` ile native TTL, `HINCRBY` ile attempt sayacı.
|
|
267
|
-
- **Kullanıcı kendi storage'ını yazabilir** (Protocol yüzünden).
|
|
268
|
-
|
|
269
|
-
---
|
|
270
|
-
|
|
271
|
-
## 9. Framework Adapter'ları
|
|
272
|
-
|
|
273
|
-
### 9.1 aiogram v3
|
|
274
|
-
```python
|
|
275
|
-
from captchakit.adapters.aiogram import CaptchaMiddleware
|
|
276
|
-
|
|
277
|
-
dp.chat_join_request.middleware(CaptchaMiddleware(manager=cm, ttl=120))
|
|
278
|
-
```
|
|
279
|
-
- `ChatJoinRequest` için otomatik captcha gönderimi (photo + InlineKeyboard veya reply text).
|
|
280
|
-
- Helper: `await send_captcha(bot, chat_id, manager)`.
|
|
281
|
-
|
|
282
|
-
### 9.2 FastAPI
|
|
283
|
-
```python
|
|
284
|
-
from captchakit.adapters.fastapi import captcha_router, get_captcha
|
|
285
|
-
|
|
286
|
-
app.include_router(captcha_router(manager=cm, prefix="/captcha"))
|
|
287
|
-
# GET /captcha/new -> {"id": "...", "image_url": "/captcha/{id}.png"}
|
|
288
|
-
# POST /captcha/verify {"id": ..., "answer": ...}
|
|
289
|
-
|
|
290
|
-
@app.post("/register")
|
|
291
|
-
async def register(_: None = Depends(get_captcha(cm))): ...
|
|
292
|
-
```
|
|
293
|
-
- Dependency `get_captcha(manager, form_field="captcha_id", answer_field="captcha_answer")`.
|
|
294
|
-
|
|
295
|
-
### 9.3 Discord (discord.py 2.x)
|
|
296
|
-
```python
|
|
297
|
-
from captchakit.adapters.discord import VerificationCog
|
|
298
|
-
bot.add_cog(VerificationCog(manager=cm, role_on_success="Verified"))
|
|
299
|
-
```
|
|
300
|
-
- `on_member_join` → DM ile captcha görseli gönder, cevap verene rol ata.
|
|
301
|
-
- Timeout → kick opsiyonu.
|
|
302
|
-
|
|
303
|
-
---
|
|
304
|
-
|
|
305
|
-
## 10. Test Stratejisi
|
|
306
|
-
|
|
307
|
-
- **Unit:** her challenge/renderer/storage bağımsız test (≥%90 coverage).
|
|
308
|
-
- **Property-based (hypothesis):** solution length/charset invariant'ları, TTL monotonluğu.
|
|
309
|
-
- **Integration:** `CaptchaManager.issue → verify` golden path + 5 hata yolu (expired, not found, wrong, attempts exhausted, storage error).
|
|
310
|
-
- **Visual regression:** `tests/fixtures/` altında referans PNG; pixel diff toleransı (font rendering platformlar arası farkı var — CI image'ı sabitle).
|
|
311
|
-
- **Adapter testleri:**
|
|
312
|
-
- aiogram: `aiogram.test_utils` / mock bot + fake update.
|
|
313
|
-
- FastAPI: `TestClient` / `httpx.AsyncClient`.
|
|
314
|
-
- Discord: mock'lu birim test (gerçek gateway'e bağlanma).
|
|
315
|
-
- **Redis:** `fakeredis[asyncio]` ile.
|
|
316
|
-
|
|
317
|
-
---
|
|
318
|
-
|
|
319
|
-
## 11. CI / CD
|
|
320
|
-
|
|
321
|
-
`.github/workflows/ci.yml`:
|
|
322
|
-
- Matrix: `{os: [ubuntu, windows, macos], python: [3.10, 3.11, 3.12, 3.13]}`
|
|
323
|
-
- Adımlar: `uv sync` → `ruff check` → `ruff format --check` → `mypy --strict` → `pytest --cov` → `codecov upload` (opsiyonel)
|
|
324
|
-
|
|
325
|
-
`release.yml`:
|
|
326
|
-
- `v*` tag push → hatch build → **PyPI Trusted Publishing** (OIDC, token'sız)
|
|
327
|
-
- GitHub Release otomatik changelog ile (`release-drafter` veya manuel).
|
|
328
|
-
|
|
329
|
-
---
|
|
330
|
-
|
|
331
|
-
## 12. Dokümantasyon
|
|
332
|
-
|
|
333
|
-
- **mkdocs-material** + `mkdocstrings` (autogen API ref).
|
|
334
|
-
- İçerik:
|
|
335
|
-
1. `index.md` — vaat, 10 satırlık quickstart
|
|
336
|
-
2. `quickstart.md` — memory + FastAPI ile ilk captcha
|
|
337
|
-
3. `challenges.md` — tipler, özelleştirme
|
|
338
|
-
4. `storage.md` — memory vs redis, kendi storage'ını yaz
|
|
339
|
-
5. `adapters/aiogram.md`, `fastapi.md`, `discord.md`
|
|
340
|
-
6. `security.md` — *"Bu kütüphane botnet-grade captcha değildir; neden?"* + önerilen yanlarda rate limiting
|
|
341
|
-
7. `api/` — mkdocstrings autogen
|
|
342
|
-
- **GitHub Pages'e deploy** (release workflow'unda).
|
|
343
|
-
|
|
344
|
-
---
|
|
345
|
-
|
|
346
|
-
## 13. Sürüm Yol Haritası
|
|
347
|
-
|
|
348
|
-
| Sürüm | İçerik | Tahmin |
|
|
349
|
-
|---|---|---|
|
|
350
|
-
| **v0.1.0** (MVP) | Core Manager, TextChallenge, MathChallenge, ImageRenderer, MemoryStorage, FastAPI adapter, README + quickstart | 1–2 hafta (akşam çalışmasıyla) |
|
|
351
|
-
| **v0.2.0** | aiogram adapter, RedisStorage, EmojiGridChallenge, mkdocs site yayın | +1 hafta |
|
|
352
|
-
| **v0.3.0** | Discord adapter, AudioChallenge (opsiyonel), WordChallenge | +1 hafta |
|
|
353
|
-
| **v0.4.0** | i18n (prompt çevirileri), özelleştirilebilir tema (renk/font preset), metrics hook (Prometheus-compatible callback) | +1 hafta |
|
|
354
|
-
| **v1.0.0** | API stabil, semver taahhüdü, tüm adapter'lar için ≥%90 coverage, ayrıntılı güvenlik dokümanı, CHANGELOG düzeni | Önceki adımlar sonrası |
|
|
355
|
-
|
|
356
|
-
### Her sürümde "Definition of Done"
|
|
357
|
-
- `mypy --strict` temiz
|
|
358
|
-
- `ruff check` temiz
|
|
359
|
-
- Coverage ≥ %90
|
|
360
|
-
- CHANGELOG güncel
|
|
361
|
-
- Yeni özellik için en az bir `examples/` örneği
|
|
362
|
-
- README badge'leri yeşil
|
|
363
|
-
|
|
364
|
-
---
|
|
365
|
-
|
|
366
|
-
## 14. GitHub Profil Etkisi (senin hedefin)
|
|
367
|
-
|
|
368
|
-
Bu kadar plan niye? Çünkü açık kaynak bir projeyi "yapıp attın mı profile güzel görünsün" bakışıyla değil, küçük ama **özenli** bir SDK gibi kurarsan:
|
|
369
|
-
- Tam typed + `py.typed` → recruiter'lar için "bu adam paketleme biliyor" sinyali.
|
|
370
|
-
- Framework adapter'ları → gerçek kullanım senaryosu, sadece toy değil.
|
|
371
|
-
- Test coverage badge + mypy strict badge + PyPI badge → README'de üç satır güven.
|
|
372
|
-
- mkdocs sitesi → dokümantasyon yazabildiğini gösterir (çok nadir).
|
|
373
|
-
- "Awesome-python" / "awesome-aiogram" PR'ı ile referans alma şansı yüksek.
|
|
374
|
-
|
|
375
|
-
Sürüm kesmeden *önce* yapılacaklar:
|
|
376
|
-
- [ ] Repo açılışında **iyi bir README** (vaat + karşılaştırma tablosu + 10-satırlık örnek)
|
|
377
|
-
- [ ] Sosyal preview image (GitHub repo settings)
|
|
378
|
-
- [ ] `CONTRIBUTING.md`, `CODE_OF_CONDUCT.md`, `SECURITY.md`
|
|
379
|
-
- [ ] İlk release'te r/Python + dev.to duyurusu
|
|
380
|
-
|
|
381
|
-
---
|
|
382
|
-
|
|
383
|
-
## 15. Riskler & Açık Sorular
|
|
384
|
-
|
|
385
|
-
| Risk | Etki | Azaltma |
|
|
386
|
-
|---|---|---|
|
|
387
|
-
| PyPI'de `captchakit` alınmış olabilir | Orta | Yayın öncesi kontrol, yedek ad: `captchakit` |
|
|
388
|
-
| Font rendering platform farkları → pixel diff testleri flaky | Düşük | Bundled tek font (DejaVu Sans OFL), CI image'ı sabit |
|
|
389
|
-
| Pillow ABI kırılmaları (her yıl) | Orta | CI'de Pillow son 2 major + güncel; `Pillow>=10,<12` pin |
|
|
390
|
-
| Discord.py vs py-cord çatallanması | Orta | Extra adını `discord` yerine `discordpy` yap, py-cord için ayrı extra |
|
|
391
|
-
| aiogram 3.x breaking API'ler (3.4→3.x) | Orta | CI'de aiogram son 2 minor, changelog izle |
|
|
392
|
-
| "Basit captcha güvenli değil" eleştirisi | Düşük | Dokümanda açıkça sınırı anlat; hCaptcha/Turnstile önerisi ekle |
|
|
393
|
-
|
|
394
|
-
### Açık sorular (sürüm öncesi cevaplanmalı)
|
|
395
|
-
1. Adapter'lar aynı pakette mi, ayrı paketler mi? → **Aynı pakette + extras** (tek repo, kolay bakım). Değişebilir.
|
|
396
|
-
2. `audio` için `pydub`/`numpy` zorunlu olur, "zero-dep" vaadiyle çatışır → opsiyonel extra + dok notu.
|
|
397
|
-
3. v1.0'dan sonra deprecation politikası: en az 1 minor önceden uyarı.
|
|
398
|
-
|
|
399
|
-
---
|
|
400
|
-
|
|
401
|
-
## 16. İlk Hafta Mikro Plan (yarın başlarsan)
|
|
402
|
-
|
|
403
|
-
**Gün 1:** `pyproject.toml`, `src/captchakit/__init__.py`, `py.typed`, `ruff + mypy + pytest` kurulum, CI iskeleti.
|
|
404
|
-
**Gün 2:** `errors.py`, `types.py`, `challenges/base.py`, `TextChallenge`.
|
|
405
|
-
**Gün 3:** `renderers/image.py` (Pillow) + `tests/test_renderers`.
|
|
406
|
-
**Gün 4:** `storage/memory.py` + `manager.py` + uçtan uca test.
|
|
407
|
-
**Gün 5:** FastAPI adapter + `examples/fastapi_login.py`.
|
|
408
|
-
**Gün 6:** README yaz, badge'leri ekle, mkdocs iskeleti.
|
|
409
|
-
**Gün 7:** PyPI kontrol → `v0.1.0-rc1` → feedback → `v0.1.0`.
|
|
410
|
-
|
|
411
|
-
---
|
|
412
|
-
|
|
413
|
-
## Kaynaklar
|
|
414
|
-
|
|
415
|
-
- lepture/captcha: <https://github.com/lepture/captcha>
|
|
416
|
-
- claptcha: <https://github.com/kuszaj/claptcha>
|
|
417
|
-
- multicolorcaptcha: <https://github.com/J-Rios/multicolorcaptcha>
|
|
418
|
-
- aiogram 3.x: <https://github.com/aiogram/aiogram>
|
|
419
|
-
- FastAPI best practices 2026: <https://fastlaunchapi.dev/blog/fastapi-best-practices-production-2026>
|
|
420
|
-
- Python packaging 2026 (uv + ruff + mypy): <https://www.kdnuggets.com/python-project-setup-2026-uv-ruff-ty-polars>
|
|
421
|
-
- PEP 561 (py.typed): <https://peps.python.org/pep-0561/>
|
|
422
|
-
- PyPI Trusted Publishing: <https://docs.pypi.org/trusted-publishers/>
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|