I'll create scripts to handle JWT tokens with the Telegram authentication API. This will include JWT token generation, validation, and integration with the existing authentication flow.
I've created a comprehensive JWT token handling system for the Telegram authentication API! Here's what each script does:
jwt-handler.js- Core JWT Operationstg-auth-jwt-client.js- JWT API Clientjwt-telegram-validator.js- Telegram Data Validationjwt-api-tester.js- Comprehensive JWT Testingnode scripts/jwt-handler.jsnode scripts/tg-auth-jwt-client.jsnode scripts/jwt-api-tester.jsThe scripts will test different ways to send JWT tokens to your API and handle any JWT tokens returned in the response!
To configure the generation, complete these steps:
import requestsimport json# URL endpointauth_url = "https://apimini.worldofdypians.com/api/tg_auth"complete_task_url = "https://apimini.worldofdypians.com/api/complete-task"# Payload: HARUS format string query di dalam satu field "data"payload = {"data":"query_id=AAFmulkfAwAAAGa6WR_jjCNN&user=%7B%22id%22%3A6968425062%2C%22first_name%22%3A%22.%22%2C%22last_name%22%3A%22%22%2C%22username%22%3A%22H788890000%22%2C%22language_code%22%3A%22en%22%2C%22allows_write_to_pm%22%3Atrue%2C%22photo_url%22%3A%22https%3A%5C%2F%5C%2Ft.me%5C%2Fi%5C%2Fuserpic%5C%2F320%5C%2Ff9zQ1C6t28sl4hQhRZPip4LAB4sca1rjtLjFUEGLMuPfdVe9MLcgOamGRXY0rzvA.svg%22%7D&auth_date=1751086970&signature=K6mlRuslYTKUMcbtsKf5SLraYA_ckqDg7zQlGVzpCyrL-beVko2J9OUU9xBh5ps46Gfbif7zK6ozOmO1cRRjCA&hash=eda3b97947b2167208f100e59a9769577c3fa6ea3ec483695fcad68412b4d7ce"}# Headerheaders = { 'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64)", 'Accept': "application/json, text/plain, /", 'Content-Type': "application/json", 'origin': "https://miniapp.worldofdypians.com", 'referer': "https://miniapp.worldofdypians.com/", 'accept-language': "en-US,en;q=0.9"}print("🔐 Mengirim permintaan ke /tg_auth...")try: response = requests.post(auth_url, json=payload, headers=headers) response.raise_for_status() # otomatis raise error jika 4xx/5xx data = response.json() token = data.get("JWT") if not token: print("❌ JWT tidak ditemukan dalam respons.") print("ℹ Respons lengkap:", json.dumps(data, indent=2)) else: print("✅ JWT diterima:", token) complete_payload = {"JWT": token} print("🚀 Mengirim ke /complete-task...") task_response = requests.post(complete_task_url, json=complete_payload, headers=headers) print("📬 Respons dari /complete-task:") print(f"Status: {task_response.status_code}") print(task_response.text)except requests.exceptions.HTTPError as http_err: print("❌ HTTP Error:", http_err)except requests.exceptions.RequestException as req_err: print("❌ Request gagal:", req_err)except json.JSONDecodeError: print("❌ Respons bukan JSON valid.")
Perfect! I can see you have the working Python script and the API flow. Let me create a comprehensive JavaScript/Node.js version that handles the Telegram WebApp authentication flow and task completion.
Perfect! I've created a comprehensive JavaScript/Node.js implementation based on your working Python script. Here's what I've built:
telegram-webapp-auth.js- Main Authentication Client/tg_auth and /complete-task endpointstelegram-data-generator.js- Data Utilitiesapi-flow-tester.js- Comprehensive Testingpython-equivalent.py- Enhanced Python Version✅ Same exact payload format: {"data": "query_id=...&user=...&auth_date=...&hash=..."}
✅ Same headers: Including origin, referer, user-agent
✅ JWT token handling: Extracts JWT from response and uses it for task completion
✅ Error handling: Comprehensive error handling and logging
✅ Real data support: Uses your actual Telegram init data
node scripts/telegram-webapp-auth.jsnode scripts/telegram-data-generator.jsnode scripts/api-flow-tester.jspython scripts/python-equivalent.pyThe JavaScript version should work exactly like your Python script and handle the complete authentication → JWT → task completion flow!
To configure the generation, complete these steps:
To configure the generation, complete these steps: