Skip to content

Commit 9880a39

Browse files
committed
fix: comprehensive security, persistence, and AI authenticity improvements
Security: - Restrict static serving to ./public/ — .env.local no longer HTTP-accessible - Real JWT signature verification using jsonwebtoken (not base64 decode) - Stripe webhook signature verification via stripe.webhooks.constructEvent() - Add JWT_SECRET, STRIPE_WEBHOOK_SECRET to .env.example Persistence: - Replace in-memory Map() database with better-sqlite3 SQLite - WAL mode + UPSERT prepared statements for atomic operations - Data persists across server restarts AI Experience Fix: - LLM-first planning: Gemini/Groq always called first for all questions - Hardcoded analytic/heuristic planners are now fallback-only (not default) - buildAgentTrace() now reflects what actually ran — no more fake static strings - llmError propagated to agent trace for transparency Runtime Bug Fixes: - AbortController on both SSE stream loops prevents zombie LLM token burn on disconnect - MediaPipe hand tracking fails gracefully with UI fallback (no viewport crash) Code Quality: - Remove unused imports in planSchema.js and app.js - Fix consistent-return lint in auth.js and llmQuota.js Production: - GitHub Actions CI pipeline (.github/workflows/ci.yml) - New env vars documented in .env.example
1 parent d807486 commit 9880a39

18 files changed

Lines changed: 3428 additions & 98 deletions

File tree

.github/workflows/ci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main, develop]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
name: Lint & Test
12+
runs-on: ubuntu-latest
13+
14+
strategy:
15+
matrix:
16+
node-version: [20.x, 22.x]
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Node.js ${{ matrix.node-version }}
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: ${{ matrix.node-version }}
26+
cache: npm
27+
28+
- name: Install dependencies
29+
run: npm ci
30+
31+
- name: Run ESLint
32+
run: npm run lint
33+
34+
- name: Run test suite
35+
run: npm test
36+
env:
37+
# Use dummy keys so tests that check for env vars don't fail
38+
GEMINI_API_KEY: test_key_placeholder
39+
GROQ_API_KEY: test_key_placeholder
40+
JWT_SECRET: test_jwt_secret_for_ci_only_not_real
41+
42+
security:
43+
name: Security Audit
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v4
47+
- uses: actions/setup-node@v4
48+
with:
49+
node-version: 20.x
50+
cache: npm
51+
- run: npm ci
52+
- name: Audit for high/critical vulnerabilities
53+
run: npm audit --audit-level=high

data/mindscape.db

20 KB
Binary file not shown.

package-lock.json

Lines changed: 174 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@
1414
"dependencies": {
1515
"@google/generative-ai": "^0.24.1",
1616
"@hono/node-server": "^1.13.0",
17+
"better-sqlite3": "^13.0.3",
1718
"dotenv": "^16.4.0",
1819
"groq-sdk": "^1.1.2",
1920
"hono": "^4.6.0",
20-
"katex": "^0.16.25"
21+
"jsonwebtoken": "^9.0.3",
22+
"katex": "^0.16.25",
23+
"stripe": "^22.4.0"
2124
},
2225
"devDependencies": {
2326
"@eslint/js": "^9.22.0",
19.1 KB
Loading

public/favicon.svg

Lines changed: 14 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)