Commit b976d8f
fix: Improve safety, security, and stability
Security:
- Remove unverified third-party script (cdn.gpteng.co/gptengineer.js)
- Add Content Security Policy meta tag (connect-src, frame-src, object-src, base-uri)
- Patch 12 high-severity npm vulnerabilities via audit fix + overrides
- Move Gemini API calls server-side via Supabase Edge Function (ai-proxy);
VITE_GEMINI_API_KEY no longer exposed to the browser
Stability:
- Wrap all localStorage.setItem calls in try-catch to handle QuotaExceededError
and private/incognito mode (Safari) without crashing
- Fix beforeunload handler: async save replaced with synchronous localStorage
write as a crash-safe backup (async saves cannot be awaited on page unload)
- Replace Promise.all with Promise.allSettled in forceSyncToDatabase so a single
failed save no longer silently leaves other data in an inconsistent state
- Show destructive toast when endDay save fails instead of only logging to console
- Add private requireUser() helper in SupabaseService to validate user ID before
every DB operation; removes scattered inconsistent null-check pattern
- Wrap localStorage access in InstallPrompt in try-catch for private mode safety
- Sanitize chart ID and color values before interpolation into dangerouslySetInnerHTML
- Add SCHEMA_VERSION stamp to all localStorage writes; version mismatch on read
clears stale data and returns safe defaults instead of passing corrupt state
through the application; legacy bare-array format remains readable
https://claude.ai/code/session_01JorBRWb89cm8BakhSoeWVx1 parent a2d4a78 commit b976d8f
12 files changed
Lines changed: 4231 additions & 4006 deletions
File tree
- src
- components
- ui
- contexts
- hooks
- services
- supabase
- .temp
- functions/ai-proxy
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
38 | 55 | | |
39 | 56 | | |
40 | 57 | | |
41 | 58 | | |
42 | 59 | | |
43 | 60 | | |
44 | | - | |
45 | 61 | | |
46 | 62 | | |
0 commit comments