Skip to content

serejaris/telegram-skills / skills/tg-miniapp-launch-auth

tg-miniapp-launch-auth

Verified

Use when choosing how a Telegram Mini App opens (keyboard, inline or menu button, main app, direct link, startapp, join request) or when a server must trust a Mini App user: validating initData by HMAC or Ed25519, signature in the check string, auth_date, isVersionAtLeast gating, origin protection, test environment and debugging.

FileKindSize
SKILL.mdskill md10.0 KB
references/testing-debug.mdmarkdown2.3 KB
scripts/init_data.pyscript2.9 KB
tests/test_ed25519.pyscript1.2 KB
tests/test_init_data.pyscript5.7 KB
tests/vectors.pyscript1.1 KB

tests/vectors.py

View on GitHub
from urllib.parse import quote

TOKEN = 'test-token-not-a-real-bot'
OTHER_TOKEN = 'other-test-token-not-a-real-bot'
BOT_ID = 1000001
AUTH_DATE = 1700000000
CHAT_INSTANCE = '1000003'
PUBLIC_KEY = '021c5fa975dba9e91686148317ddbedcb7dd0913ed407fd5686fa11edb319bd6'
SIGNATURE = 'zrfDJAaAko0BaJ45zj_7L8pEEuKtIs-VLVhRMfYt8AJ5WRANhmsHoAMcuxkK4V_5j9u1b3qniw_aKKQu4cbTCQ'
SIGNED_HASH = 'dfbe54f85b4a08c63dd070e0494d00d792a7c7413a0474e390af61cc4ada8046'
USER = ('{"id":1000002,"first_name":"Test + - ? \\/","last_name":"User","username":"example_user",'
        '"language_code":"en","is_premium":true,"allows_write_to_pm":true,'
        '"photo_url":"https:\\/\\/example.com\\/avatar.svg"}')
SIGNED_INIT_DATA = (f'user={quote(USER, safe="")}&chat_instance={CHAT_INSTANCE}&chat_type=private'
                    f'&auth_date={AUTH_DATE}&signature={SIGNATURE}&hash={SIGNED_HASH}')

PLAIN_USER = '{"id":1000002,"first_name":"Test"}'
PLAIN_HASH = '9b6a56a25937df89fcd15f79ef3bf7fd03582fc7b55ba09273709120caea3f2f'
PLAIN_INIT_DATA = (f'query_id=test-query&user={quote(PLAIN_USER, safe="")}'
                   f'&auth_date={AUTH_DATE}&hash={PLAIN_HASH}')
finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the workStars: 322kUpdated Claude CodeCodexVerifiedInstall
systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixesStars: 322kUpdated Claude CodeCodexVerifiedInstall
test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation codeStars: 322kUpdated Claude CodeCodexVerifiedInstall
skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.Stars: 198kUpdated Claude CodeCodexVerifiedInstall