feat(telegram): Mini App chat bridge — initData auth, update webhook, chat proxy - #9812
Closed
benzntech wants to merge 0 commit into
Closed
feat(telegram): Mini App chat bridge — initData auth, update webhook, chat proxy#9812benzntech wants to merge 0 commit into
benzntech wants to merge 0 commit into
Conversation
Owner
|
Thanks for the PR. Please address the mandatory items (tests and/or merge blockers) in this branch, then rerun checks before /merge-prs. |
Owner
|
Thanks for the PR. Please address the mandatory items (tests and/or merge blockers) in this branch, then rerun checks before /merge-prs. |
1 similar comment
Owner
|
Thanks for the PR. Please address the mandatory items (tests and/or merge blockers) in this branch, then rerun checks before /merge-prs. |
Owner
|
Obrigado pelo PR. Mantive a revisão de
|
diegosouzapw
added a commit
that referenced
this pull request
Aug 9, 2026
* fix(deps): bump transitive deps for 6 Dependabot + remaining audit vulns on main Same overrides as #9464 (ip-address, hono, fast-uri, socket.io-parser, undici) applied directly to main. Also covers brace-expansion (scoped), js-yaml v4 copies, and mermaid. npm audit: 6→0 vulnerabilities. Closes Dependabot #161-#166. * fix(deps): bump nanoid, dompurify for 2 new Dependabot alerts (#189, #190) Bumps: nanoid ^3.3.17 (was transitive, now overridden), dompurify ^3.4.13 (with monaco-editor scoped override). Closes Dependabot #189, #190. Remaining #182-#188 (js-yaml + mermaid) already closed by #9651 merge — awaiting Dependabot re-scan. npm audit → 0 vulnerabilities. * fix(repo): harden .gitignore to also ignore a _tasks symlink (/_tasks) _tasks is a SEPARATE nested git repo (gitignored). The pattern _tasks/ (trailing slash) ignores only a directory, not a SYMLINK named _tasks. A self-referential _tasks symlink can slip in via git add -A and, once pulled, checkout materializes it over the real _tasks repo (destroying plans/specs/hands-off). Anchored /_tasks ignores the symlink too, preventing re-capture. * feat(telegram): Mini App chat bridge — initData auth, update webhook, chat proxy Implements the Phase-1 slice of the Telegram Mini App integration (docs/proposals/TELEGRAM-MINIAPP.md): - src/lib/telegram/initData.ts — dependency-free WebApp initData HMAC-SHA256 verification (Telegram Bot API spec), with auth_date freshness check. - src/lib/telegram/config.ts — TELEGRAM_BOT_TOKEN / model / API base / timeout env config; token format validation; enabled gate. - src/lib/telegram/botApi.ts — minimal fetch-based Bot API client (sendMessage, editMessageText, setWebhook) + update shape helpers. - src/lib/telegram/chatProxy.ts — maps a Telegram user to a per-user OmniRoute API key (createApiKey, name telegram:<userId>) and proxies prompts through the existing handleChat pipeline. - src/app/api/telegram/update/route.ts — inbound endpoint serving both the Bot API update webhook (/start + chat replies) and the Mini App direct path (initData HMAC verified → 401 on mismatch). Public route prefix; own auth only. - src/app/miniapp/page.tsx — Telegram WebApp SDK chat UI. - Tests: telegram-init-data (7), telegram-botapi (5) — 12/12 pass. - Env docs: TELEGRAM_* vars in .env.example + ENVIRONMENT.md (sync ✓). - Route-validation check: PASS (body validated via Zod). --------- Co-authored-by: diegosouzapw <diegosouzapw@users.noreply.github.com> Co-authored-by: benzntech <bensonkbmca@gmail.com>
diegosouzapw
force-pushed
the
feat/telegram-miniapp
branch
from
August 11, 2026 01:06
4f9600b to
5fd2325
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Phase-1 implementation of the Telegram Mini App integration (feasibility analysis: #9810). Adds an inbound Telegram Bot API webhook + a Mini App chat surface that proxies through OmniRoute's existing
handleChatpipeline.What's included
src/lib/telegram/initData.tsinitDataHMAC-SHA256 verification (Bot API spec) +auth_datefreshness checksrc/lib/telegram/config.tsTELEGRAM_BOT_TOKEN/ model / API base / timeout env config, token-format validationsrc/lib/telegram/botApi.tssendMessage,editMessageText,setWebhooksrc/lib/telegram/chatProxy.tstelegram:<userId>) + prompt proxy throughhandleChatsrc/app/api/telegram/update/route.ts/start+ chat replies) and the Mini App direct path (initData HMAC → 401 on mismatch)src/app/miniapp/page.tsxSecurity model
initDataHMAC verified server-side againstTELEGRAM_BOT_TOKEN; tampered payloads → 401. User id extracted from verified initData for key mapping.telegram:<userId>) so existing policy/rate-limit/model-allowlist code applies unchanged./api/skills/collect/chaos).Verification
telegram-init-data.test.ts— 7/7 pass (valid sig, tamper, wrong token, missing hash, stale auth_date, encoded keys)telegram-botapi.test.ts— 5/5 pass (update parsing, initData end-to-end)tsc --noEmit— 0 errors in new filescheck-route-validation— PASS (607 routes, all request.json() validated)check-env-doc-sync— ✓ in sync (TELEGRAM_* vars documented)Known limitations (Phase 2)
TELEGRAM_BOT_USERNAMEdeep-link placeholder (uses YOUR_BOT until set)