feat(kik): Implement document ID encryption for KİK v2 API

Reverse engineered the AES-256-CBC encryption used by KİK's Angular web
application to generate document URL hashes from numeric IDs.

Key findings:
- Algorithm: AES-256-CBC with PKCS7 padding
- Key location: ekapv2.kik.gov.tr module 21554 (environment config)
- Output format: IV (16 bytes hex) + Ciphertext (16 bytes hex) = 64 chars

Changes:
- Added encrypt_document_id() static method to KikV2ApiClient
- Updated get_document_markdown() to auto-encrypt numeric gundemMaddesiId
- Added cryptography>=44.0.0 dependency for AES encryption
- Both primary and fallback URL paths now support encryption

This enables direct document retrieval from numeric search result IDs
without requiring the pre-encrypted hash from the web interface.
This commit is contained in:
saidsurucu
2025-12-04 15:17:13 +03:00
parent 91ad04cf09
commit a2b50951e9
3 changed files with 84 additions and 6 deletions
Generated
+2
View File
@@ -2333,6 +2333,7 @@ source = { editable = "." }
dependencies = [
{ name = "aiohttp" },
{ name = "beautifulsoup4" },
{ name = "cryptography" },
{ name = "fastapi" },
{ name = "fastmcp" },
{ name = "httpx" },
@@ -2368,6 +2369,7 @@ requires-dist = [
{ name = "aiohttp", specifier = ">=3.11.18" },
{ name = "beautifulsoup4", specifier = ">=4.13.4" },
{ name = "clerk-backend-api", marker = "extra == 'saas'", specifier = ">=3.0.0" },
{ name = "cryptography", specifier = ">=44.0.0" },
{ name = "fastapi", specifier = ">=0.115.14" },
{ name = "fastapi", marker = "extra == 'api'", specifier = ">=0.115.0" },
{ name = "fastmcp", specifier = ">=2.10.5" },