Update files

This commit is contained in:
glpshchn 2025-12-15 04:55:04 +03:00
parent 7abadaf126
commit 7c379eb74d
1 changed files with 4 additions and 5 deletions

View File

@ -68,13 +68,12 @@ def validate_telegram_widget(auth_data: Dict[str, Any], bot_token: Optional[str]
print(f"[TelegramWidget] Data check string: {repr(data_check_string)}")
# Create secret key
secret_key = hmac.new(
'WebAppData'.encode('utf-8'),
token_to_use.encode('utf-8'),
hashlib.sha256
).digest()
# ВАЖНО: Для Login Widget используется SHA256(bot_token), а НЕ HMAC-SHA256('WebAppData', bot_token)
# Это отличается от WebApp initData!
secret_key = hashlib.sha256(token_to_use.encode('utf-8')).digest()
print(f"[TelegramWidget] Secret key (hex): {secret_key.hex()[:40]}...")
print(f"[TelegramWidget] Bot token для secret key: {token_to_use[:10]}...{token_to_use[-10:]}")
# Calculate hash
calculated_hash = hmac.new(