serejaris/telegram-skills / skills/tg-miniapp-launch-auth
tg-miniapp-launch-auth
VerifiedUse 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.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 10.0 KB |
| references/testing-debug.md | markdown | 2.3 KB |
| scripts/init_data.py | script | 2.9 KB |
| tests/test_ed25519.py | script | 1.2 KB |
| tests/test_init_data.py | script | 5.7 KB |
| tests/vectors.py | script | 1.1 KB |
tests/test_ed25519.py
View on GitHubimport importlib.util
from pathlib import Path
import unittest
from cryptography.exceptions import InvalidSignature
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PublicKey
from vectors import BOT_ID, PUBLIC_KEY, SIGNED_INIT_DATA
SPEC = importlib.util.spec_from_file_location(
'init_data', Path(__file__).parents[1] / 'scripts/init_data.py')
init_data = importlib.util.module_from_spec(SPEC)
SPEC.loader.exec_module(init_data)
class Ed25519Verification(unittest.TestCase):
def setUp(self):
self.key = Ed25519PublicKey.from_public_bytes(bytes.fromhex(PUBLIC_KEY))
self.message, self.signature = init_data.third_party_payload(SIGNED_INIT_DATA, BOT_ID)
def test_payload_verifies_with_the_test_key(self):
self.key.verify(self.signature, self.message)
def test_changed_message_is_rejected(self):
with self.assertRaises(InvalidSignature):
self.key.verify(self.signature, self.message + b'x')
def test_other_bot_id_is_rejected(self):
message, signature = init_data.third_party_payload(SIGNED_INIT_DATA, BOT_ID + 1)
with self.assertRaises(InvalidSignature):
self.key.verify(signature, message)
if __name__ == '__main__':
unittest.main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| 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: 198k | Updated | Claude CodeCodex | Verified | Install |