Technical Reference

Telegram Mini App Auth is sold separately on onlinepokerscript.com. This page is its technical reference; installing and configuring the plugin is covered in the Telegram Auth operator guide.

The @poker-addons/telegram-auth plugin (2.0, plugin API 1.4) lets players sign in from a Telegram Mini App. It registers the login provider telegram, a credential provider, with registry.auth.registerProvider (capability auth:provider). The plugin verifies Telegram’s initData; the engine’s provider-agnostic identity layer does the rest: finding or creating the account, the login guards, 2FA, linking, sessions. The plugin needs no Telegram code in core and has no routes of its own.

Upgrading from 1.0

1.02.0
Sign-inPOST /api/v1/plugins/telegram-auth/loginPOST /api/v1/auth/external/telegram/credential { credential: { initData }, intent: 'login', mode }
Link / unlinkPOST/DELETE /api/v1/plugins/telegram-auth/link, profile panelLink: the credential endpoint with intent: 'link' (the plugin’s Settings → Telegram section, inside the Mini App). Unlink: core Settings → Sign-in methods (DELETE /api/v1/user/identities/telegram)
Set a first passwordPOST /api/v1/plugins/telegram-auth/passwordintent: 'reauth' with the launch’s initData, then core’s POST /api/v1/user/identities/password { reauthTicket, newPassword } (the set-password form of Sign-in methods)
StatusGET /api/v1/plugins/telegram-auth/statusGET /api/v1/user/identities
AdminPlugin page Telegram Accounts, user-detail fill, /admin/accounts routesCore Players › Linked Accounts (filter by provider telegram), the Sign-in methods panel of the user drawer, Settings › Login Providers
2FA accountsThe login button gave up ("use the standard login form")The sign-in continues in the login page’s own 2FA step
ErrorsTELEGRAM_* codesCore codes: CREDENTIAL_INVALID (bad, expired or replayed initData), EXTERNAL_AUTH_NOT_LINKED, EXTERNAL_AUTH_ADMIN_FORBIDDEN, IDENTITY_*, PROVIDER_DISABLED
Datatelegram_accountsuser_identities (provider telegram)
  • The plugin routes are gone. /login, /link, /password, /status and /admin/* under /api/v1/plugins/telegram-auth return 404 in 2.0. Bots, scripts or a custom Mini App that called them must post to the credential endpoint instead.
  • Accounts carry over. The engine’s migration 20261110000201_telegram_identities copied every telegram_accounts row to user_identities (provider telegram, provider_user_id = the Telegram id, username, display name, photo, profile { languageCode, isPremium, firstName, lastName }; linked_via auto_provision stays, account_link becomes link, anything else migration). A player created by 1.0 signs in through 2.0 to the same account.
  • Capability consent. 2.0 declares auth:provider, which 1.0 did not. Upgrading an uploaded 1.0 asks the admin to grant it.
  • 1.0 keeps working until API 1.5. On this engine an installed 1.0 plugin still runs: registry.auth.telegram.* is a deprecated shim reimplemented on user_identities (it logs a one-time deprecation warning). The shim, the old verifier in src/services/legacy-telegram/ and the telegram_accounts table are removed in plugin API 1.5, so upgrade before then.

Configuration

Configure the plugin from Extensions › Plugins: Settings on the Telegram Mini App Auth row.

SettingDefaultNotes
botTokenrequiredTelegram bot token used as HMAC key material. The provider is disabled (hidden, PROVIDER_DISABLED) until a token of the form 123456:ABC... is stored.
maxInitDataAgeSeconds300Freshness window for auth_date, 30 to 86400. Payloads more than 60 seconds in the future are rejected.
allowAutoProvisiontrueThe provider’s sign-up mode: on is auto (an unknown Telegram user gets an account at once), off is link_only (EXTERNAL_AUTH_NOT_LINKED until the player links Telegram). An admin override on the Login providers page wins.
usernamePrefixtg_provisioning.usernamePrefix: core’s fallback when the Telegram username is missing or taken (<prefix><6 digits>).
botUsernameemptyOptional display metadata.

Settings validation rejects syntactically invalid bot tokens, ages outside 30..86400 and invalid prefixes. After a save the plugin re-registers the provider (sign-up mode and prefix) and calls Telegram getMe with a five second timeout; it logs a warning if Telegram is unreachable or rejects the token, and never blocks the save.

The provider

{
  kind: 'credential', id: 'telegram', displayName: 'Telegram',
  button: false,                  // the plugin's fills post initData; core renders no button
  platforms: ['web'],
  trustEmail: false,
  signupMode: allowAutoProvision ? 'auto' : 'link_only',
  provisioning: { placeholderEmail: (i) => `tg_${i.providerUserId}@telegram.invalid`, usernamePrefix },
  verifyCredential({ initData }, ctx) → ExternalIdentityInput,
}

verifyCredential returns providerUserId (the Telegram id), username, displayName (first and last name), firstName, lastName, avatarUrl (the Telegram photo, https only), locale, and profile { languageCode, isPremium, firstName, lastName }, the same fields the 1.0 data migration wrote. Telegram gives no email, so an auto-provisioned account gets the placeholder address (confirmed, never mailed) and a random unusable password (passwordSetAt = null) until the player sets one.

Security behaviour

  • initData is verified in the plugin (src/server/init-data.ts, ported from the 1.0 verifier) with HMAC-SHA256 keyed with HMAC-SHA256("WebAppData", botToken) and a constant-time comparison.
  • Payloads over 8 KB, duplicate keys, missing hash/auth_date, malformed user JSON, expired timestamps, future timestamps and HMAC mismatches are rejected. Every refusal reaches the client as CREDENTIAL_INVALID (401); the reason is only logged.
  • Replay protection: the plugin reserves SHA-256(hash) for the freshness window with registry.auth.reserveOnce (Redis SET NX EX when Redis is enabled, cluster-wide and failing closed; in memory on a single node). intent: 'reauth' skips it, so setting a first password inside the Mini App may present the launch’s initData again within the window, as in 1.0.
  • The bot token is read fresh on every sign-in, so rotating it invalidates outstanding payloads at once.
  • Core’s rules apply as for every provider: admin-group accounts are refused (EXTERNAL_AUTH_ADMIN_FORBIDDEN), blocked/frozen, pending approval and email verification guards, the per-username login rate limit, 30 credential requests a minute per IP, 2FA for every account that has it, unlink can never remove the last credential, and admin unlink revokes sessions and is audited.

Frontend surfaces

The plugin client bundle registers:

  • Login page fill (auth.login.below-form): Continue with Telegram, only inside the Telegram WebView and only while GET /api/v1/auth/providers lists the telegram descriptor. It posts { credential: { initData }, intent: 'login', mode: 'cookie' } (plus the launch’s start_param as the referral code) and hands the result to window.__pokerEngine.auth.continueExternalSignIn, which goes where the core finish page would: the lobby, or the 2FA step of the same login page.
  • Public page /plugins/telegram-auth/public/mini-app: the Mini App’s start URL; signs in straight away the same way. It loads telegram-web-app.js itself when Telegram opened the page and nothing loaded it yet.
  • Settings section Telegram (settings.sections, /settings#telegram): inside the WebView, Link Telegram (intent: 'link', session + CSRF) and, for an account without a password, Set a password (intent: 'reauth', then core’s set-password form in Sign-in methods). Outside Telegram it explains where to do it.

Linked accounts, unlinking and every admin view are core’s generic screens.

Try the live demo Pricing

Have questions about Poker Engine? We reply fast.