Personal Telegram developer console for GitHub

feat: serve Workspace Mini App and owner-only draft API

davoodmehraban89 committed Oct 4, 2026 at 11:17 UTC 48bbe109184963f22c539e178b7a25a827113f4c
1 file changed +17
src/index.js
+17
@@ -1,4 +1,6 @@
1 import { NexaDevBot } from './bot.js';
2 +import { DurableWorkspaceStoreClient } from './core/workspace-store.js';
3 +import { handleWorkspaceEditorRequest, workspaceEditorPageResponse } from './workspace-editor.js';
4 export { ApprovalReplayGuard } from './durable/approval-replay-guard.js';
5 export { WorkspaceStore } from './durable/workspace-store.js';
6
@@ -36,12 +38,27 @@ function safeErrorMessage(error, env = {}) {
38 * Security invariants:
39 * - Telegram webhook requests must carry the configured secret header.
40 * - Telegram updates are owner-only and unauthorized senders are ignored silently.
41 + * - Workspace Mini App API validates Telegram initData, freshness and owner identity.
42 + * - Mini App saves only the durable Draft; GitHub writes remain behind Safe Approval.
43 * - Missing security or transport configuration fails closed.
44 */
45 export default {
46 async fetch(request, env = {}, ctx = {}) {
47 const url = new URL(request.url);
48
49 + if (request.method === 'GET' && url.pathname === '/workspace/editor') {
50 + return workspaceEditorPageResponse();
51 + }
52 +
53 + if (url.pathname === '/workspace/api/editor' && (request.method === 'GET' || request.method === 'PUT')) {
54 + const workspaces = new DurableWorkspaceStoreClient({ namespace: env.WORKSPACE_STORE });
55 + return handleWorkspaceEditorRequest(request, {
56 + workspaces,
57 + botToken: env.TELEGRAM_BOT_TOKEN || '',
58 + ownerId: env.OWNER_TELEGRAM_ID || ''
59 + });
60 + }
61 +
62 if (request.method === 'GET') {
63 if (url.pathname === '/health' || url.pathname === '/') {
64 return jsonResponse({