15 Commits

Author SHA1 Message Date
976a2594b7 fix: security and robustness improvements, add project docs
- Hash inputs in timingSafeEqual to prevent length leak side-channel
- Add quote escaping to escapeHtml for defense in depth
- Normalize chatId to Number in parseKvKey for type consistency
- Log Retry-After header on 429 rate limit responses
- Slim README to focused overview, move details to docs/
- Add docs/: system-architecture, setup-guide, feature-decisions
- Add documentation section and README guidelines to CLAUDE.md
2026-04-09 09:27:45 +07:00
923ad7a40e refactor: remove migration route and logic after successful migration 2026-04-09 09:11:38 +07:00
fce23b3c59 refactor: make setup script interactive instead of using env vars 2026-04-09 09:02:54 +07:00
e8b30743d3 refactor: remove cron, use KV metadata, extract shared crypto util
- Remove cron status polling (statuspage notifies via email on webhook failure)
- Store subscriber types/components as KV metadata for O(1) filtering
- Extract timingSafeEqual to shared crypto-utils.js (was duplicated)
- Change /migrate route from GET to POST (prevent CSRF/prefetch)
- Preserve existing subscriber preferences on /start re-subscribe
- Remove dead getAllSubscribers export
- Update docs to reflect changes
2026-04-09 08:58:52 +07:00
392fecf350 refactor: replace metrics with console.log, remove HMAC
Statuspage doesn't support HMAC signatures - removed all HMAC code.
Replaced KV-based metrics with simple console.log for CF Workers logs.
Queue consumer logs batch summary (sent/failed/retried/removed).
2026-04-09 00:52:41 +07:00
d78e761731 feat: add metrics tracking and remove unsupported HMAC verification
- Add metrics.js tracking webhooks, messages, cron, commands
- Add GET /metrics/:secret endpoint (text + JSON format)
- Remove HMAC verification (Statuspage doesn't support it)
- Extract validateSecret helper in index.js
- Integrate trackMetrics across webhook, queue, cron, bot handlers
2026-04-09 00:48:42 +07:00
b728ae7d38 refactor: per-subscriber KV keys, HMAC verification, cron trigger
Major refactor addressing scalability, security, and reliability:

- KV schema: single-key → per-subscriber keys (sub:{chatId}:{threadId})
  eliminates read-modify-write race conditions
- Component-specific subscriptions: /subscribe component <name>
- HMAC-SHA256 webhook verification with URL secret fallback
- Cron trigger (every 5 min) polls status.claude.com as safety net
- Shared telegram-api.js module (DRY fix)
- Error logging in all catch blocks
- Migration endpoint for existing subscribers
- Setup moved to standalone script (scripts/setup-bot.js)
- Removed setup HTTP route to reduce attack surface
2026-04-09 00:43:07 +07:00
30ffaae612 feat: add /help, /history, /uptime commands and enhance /status
- /help: detailed guide with examples for all commands
- /status: overall indicator, emoji markers, updated time, status page link
- /history [count]: recent incidents with impact, dates, links (max 10)
- /uptime: component health with last change time
- Split info commands into bot-info-commands.js for modularity
- Register all 7 commands in bot-setup.js
2026-04-08 23:41:53 +07:00
37c2a01677 feat: add setup endpoint to register bot commands and webhook
GET /webhook/setup/:secret registers commands with Telegram
and sets webhook URL in one step.
2026-04-08 23:31:11 +07:00
68b9604598 refactor: update bindings to match CF resource names
KV binding: claude_status, Queue binding: claude-status.
Real KV namespace ID configured with remote flag.
2026-04-08 23:23:32 +07:00
b3d1f5acb4 fix: rename KV binding to CLAUDE_STATUS and fix threadId nullish check
- Rename KV binding SUBSCRIBERS → CLAUDE_STATUS for consistent naming
- Fix || null → ?? null to preserve threadId 0 (General topic)
- Update KV namespace creation command in README
2026-04-08 23:14:26 +07:00
41bdcf36ef refactor: rename queue to claude-status and remove KV key prefix
Namespace provides scoping, prefix on KV key is redundant.
2026-04-08 23:09:02 +07:00
cb9fd58565 fix: correct license to Apache-2.0 in package.json and README 2026-04-08 23:07:03 +07:00
cc35e8a649 update README with setup instructions and project documentation 2026-04-08 23:06:00 +07:00
902b46720d Initial commit 2026-04-08 22:19:28 +07:00