Commit Graph

5 Commits

Author SHA1 Message Date
3ac82621c8 Security update: Patch React and Next.js CVE vulnerabilities
Updated React to 19.2.1 and Next.js to 16.0.7 to address critical security vulnerabilities:
- CVE-2025-55182: React Server Components deserialization flaw
- CVE-2025-66478: Next.js RSC implementation vulnerability

Also includes:
- Add PATCH endpoint for geofence updates
- Reorder admin navigation items
- Add geofence update functionality in database layer

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 09:30:47 +00:00
b4bd967400 Add comprehensive geofence testing scripts
Added three test scripts for validating geofence functionality:

1. test-geofence.js: Database-level geofence testing
   - Creates test geofence and mock locations
   - Tests distance calculations and event generation
   - Validates state tracking (enter/exit detection)

2. test-geofence-notification.js: Email notification testing
   - Tests SMTP connection and email delivery
   - Sends formatted geofence notification email
   - Validates email template rendering

3. test-mqtt-geofence.js: Full MQTT integration testing
   - Publishes OwnTracks-formatted MQTT messages
   - Tests complete flow: MQTT → Geofence → Email
   - Simulates device entering/exiting zones

**NPM Scripts:**
- npm run test:geofence - Database and logic test
- npm run test:geofence:email - Email notification test
- npm run test:geofence:mqtt - Full MQTT integration test

**Other Changes:**
- Updated admin user email to joachim.hummel@gmail.com
- All scripts include cleanup instructions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 18:32:06 +00:00
bd6a7ab187 Add Geofence MVP feature implementation
Implemented complete MVP for geofencing functionality with database,
backend logic, MQTT integration, and API endpoints.

**Phase 1: Database & Core Logic**
- scripts/init-geofence-db.js: Database initialization for Geofence tables
- lib/types.ts: TypeScript types for Geofence, GeofenceEvent, GeofenceStatus
- lib/geofence-engine.ts: Core geofencing logic (Haversine distance, state tracking)
- lib/geofence-db.ts: Database layer with CRUD operations
- package.json: Added db:init:geofence script

**Phase 2: MQTT Integration & Email Notifications**
- emails/geofence-enter.tsx: React Email template for enter events
- emails/geofence-exit.tsx: React Email template for exit events
- lib/email-renderer.ts: Added geofence email rendering functions
- lib/geofence-notifications.ts: Notification service for geofence events
- lib/mqtt-subscriber.ts: Integrated automatic geofence checking on location updates

**Phase 3: Minimal API**
- app/api/geofences/route.ts: GET (list) and POST (create) endpoints
- app/api/geofences/[id]/route.ts: DELETE endpoint
- All endpoints with authentication and ownership checks

**MVP Simplifications:**
- No zone limit enforcement (unlimited for all users)
- No notification flags (always send Enter + Exit emails)
- Device assignment required (no NULL device logic)
- Circular geofences only

**Features:**
 Automatic geofence detection on MQTT location updates
 Email notifications for enter/exit events
 State tracking to prevent duplicate events
 REST API for geofence management
 Non-blocking async processing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 18:14:24 +00:00
e64a22dee5 Clean up development artifacts and obsolete code
Dependencies:
- Remove unused bcrypt package (only bcryptjs is used)
- Remove @types/bcrypt (only @types/bcryptjs needed)

Scripts cleanup:
- Delete migration scripts (one-time use, already applied):
  - add-mqtt-tables.js
  - add-parent-user-column.js
  - migrate-device-ownership.js
  - fix-acl-topic-patterns.js
  - update-acl-permission.js
- Delete personal test/debug scripts:
  - reset-joachim-password.js
  - test-joachim-password.js
  - check-admin.js
  - check-user-password.js
  - test-password.js
  - test-device-access.js
  - test-user-visibility.js
- Move change-mqtt-admin-password.sh to scripts/ directory

Code cleanup:
- Remove debug console.log statements from:
  - app/api/locations/ingest/route.ts
  - components/map/MapView.tsx (2 debug logs)
  - lib/db.ts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 09:03:18 +00:00
843e93a274 first commit 2025-11-24 16:30:37 +00:00