Compare commits

..

169 Commits

Author SHA1 Message Date
tototomate123 5d613ea550 perf(collab): reduce cursor and preview update churn 2026-02-14 16:38:40 +01:00
tototomate123 0ffe410eeb feat(collab): add server-authoritative sync and preview-only updates 2026-02-13 20:47:05 +01:00
tototomate123 fd5470ada5 fix(editor): flush lifecycle saves and recover from version conflicts 2026-02-13 19:17:25 +01:00
tototomate123 75cbe97bc0 feat(collab): restore cross-account sharing and reliable realtime sync 2026-02-13 19:02:03 +01:00
tototomate123 12da89b815 Update README.md 2026-02-13 16:33:15 +00:00
tototomate123 9e248f9751 css fix 2026-02-12 20:38:05 +01:00
tototomate123 fe58cf7e89 update to excalidraw 0.18.0 2026-02-12 20:32:53 +01:00
tototomate123 6061d4ab94 fix(auth): align frontend password validation with production policy 2026-02-12 19:58:13 +01:00
tototomate123 6fe2ab3d28 fix(deploy): align /api routing, socket path, and proxy-aware auth limits 2026-02-12 19:43:49 +01:00
tototomate123 e05edff84d fix socket in editor 2026-02-12 19:29:17 +01:00
tototomate123 da131834ce add production stuff 2026-02-12 19:22:40 +01:00
tototomate123 08d2165a70 fix(dashboard): normalize route id params for express 5 typings 2026-02-12 19:10:41 +01:00
Zimeng Xiong 2cbd11cf0d fix impersonation issues 2026-02-10 22:45:00 -08:00
Zimeng Xiong 1c71a08bbe Plan OIDC integration and audit 2026-02-10 14:45:34 -08:00
Zimeng Xiong bb028ef2db fix csrf token hardset, remove cookie from localstorage 2026-02-10 13:16:04 -08:00
Zimeng Xiong 1117dc584e resolve e2e 2026-02-07 19:24:00 -08:00
Zimeng Xiong 70103e18fb sign CSRF with cookie, Login rate-limit key hardened against identifier-only lockout 2026-02-07 18:52:00 -08:00
Zimeng Xiong fd013de325 add tests on refactor 2026-02-07 18:03:05 -08:00
Zimeng Xiong 6bee0e2ded refactor index.ts 2026-02-07 17:47:41 -08:00
Zimeng Xiong 35bbbb9599 images in preview 2026-02-07 17:21:58 -08:00
Zimeng Xiong 2aa749a2f0 prevent preview updates from overwriting drawings 2026-02-07 15:51:35 -08:00
Zimeng Xiong 02736d663a chore: pre-release v0.4.6-dev 2026-02-07 12:46:00 -08:00
Zimeng Xiong de254d46f2 concurrency 2026-02-07 12:45:33 -08:00
Zimeng Xiong dd0f381ed1 chore: pre-release v0.4.5-dev 2026-02-07 12:09:21 -08:00
Zimeng Xiong c40a5f46a0 fix colliding drawing IDs 2026-02-07 12:09:02 -08:00
Zimeng Xiong 8fcca43b0d chore: pre-release v0.4.4-dev 2026-02-07 11:58:09 -08:00
Zimeng Xiong f20412cdfb separate debounced autosave 2026-02-07 11:57:32 -08:00
Zimeng Xiong a366acfedc chore: pre-release v0.4.3-dev 2026-02-07 11:08:03 -08:00
Zimeng Xiong 154dcbb151 update resopnsiveness hamburger 2026-02-07 11:07:15 -08:00
Zimeng Xiong 2e74d2ad1a chore: pre-release v0.4.2-dev 2026-02-07 10:34:36 -08:00
Zimeng Xiong 173c050f58 fix HTTPS reuqirement when frontend URL is nto HTTPS 2026-02-07 10:31:08 -08:00
Zimeng Xiong 8161a563f0 chore: pre-release v0.4.1-dev 2026-02-07 10:08:27 -08:00
Zimeng Xiong 812f1cbf58 chore: pre-release v0.4.1-dev 2026-02-07 10:01:14 -08:00
Zimeng Xiong 26017fa5d2 fix JWT secret 2026-02-07 10:00:58 -08:00
Zimeng Xiong 06f4c0f537 remove dev dependencies from development containers 2026-02-07 09:27:39 -08:00
Zimeng Xiong bbb23ca661 chore: pre-release v0.4.0-dev 2026-02-07 08:58:51 -08:00
Zimeng Xiong f214e4f7b7 Ensure non multi-user flow stays 2026-02-06 23:05:23 -08:00
Zimeng Xiong 7aa33a1bdf graph QL 2026-02-06 22:49:21 -08:00
Zimeng Xiong ea06cd9175 fix graphQL 2026-02-06 22:35:17 -08:00
Zimeng Xiong 734f0a292d fix graphQL 2026-02-06 22:28:36 -08:00
Zimeng Xiong 08135ee36a fix test failures, new export/backup solutions 2026-02-06 22:21:19 -08:00
Zimeng Xiong f462b2e288 minor UI fixes 2026-02-06 21:18:10 -08:00
Zimeng Xiong 01fda32bcd test(import): add legacy import compatibility coverage 2026-02-06 14:54:02 -08:00
copilot-swe-agent[bot] 94694deb91 fix: address code review feedback - add error handling and fix import style
Co-authored-by: ZimengXiong <83783148+ZimengXiong@users.noreply.github.com>
2026-02-06 14:52:47 -08:00
copilot-swe-agent[bot] ef75f9ebdf test: add user data sandboxing security tests
Co-authored-by: ZimengXiong <83783148+ZimengXiong@users.noreply.github.com>
2026-02-06 14:52:47 -08:00
copilot-swe-agent[bot] 5e782e4044 fix: scope drawings cache by userId and add Socket.io authentication
Security fixes:
1. Drawings cache now includes userId in cache key to prevent data leakage
   between users making identical queries.
2. Socket.io connections now require JWT authentication when auth is enabled.
3. Socket.io join-room verifies drawing ownership before allowing access.
4. Frontend passes auth token when connecting to Socket.io.

Co-authored-by: ZimengXiong <83783148+ZimengXiong@users.noreply.github.com>
2026-02-06 14:52:47 -08:00
Zimeng Xiong 0253ebb6b8 admin dashboard 2026-02-06 14:27:24 -08:00
Zimeng Xiong 1e617025df Add admin password reset flow 2026-02-06 14:11:13 -08:00
Zimeng Xiong e4941ad77f fix(dev): avoid native deps in predev migrate 2026-02-06 09:56:45 -08:00
Zimeng Xiong 2e370f9821 fix(dev): reset legacy dev.db and apply migrations 2026-02-06 09:54:13 -08:00
Zimeng Xiong b075a0cf9e fix(dev): avoid auth redirect when backend/schema missing 2026-02-06 09:50:27 -08:00
Zimeng Xiong 7977a3eb09 feat(auth): default to single-user mode with enable toggle 2026-02-06 09:45:38 -08:00
Zimeng Xiong 40a645b823 chore(deps): apply dependabot updates 2026-02-06 09:22:23 -08:00
Zimeng Xiong dd966f6d01 merge(pr): record PR #51 on pre-release 2026-02-06 09:20:35 -08:00
Zimeng Xiong d832e55dfd merge(pr): record PR #52 on pre-release 2026-02-06 09:20:35 -08:00
Zimeng Xiong 887818c9b4 merge(pr): record PR #47 on pre-release 2026-02-06 09:20:35 -08:00
Zimeng Xiong bc13cc3483 merge(pr): record PR #46 on pre-release 2026-02-06 09:20:35 -08:00
Zimeng Xiong da299d00d5 merge(pr): record PR #44 on pre-release 2026-02-06 09:20:35 -08:00
Zimeng Xiong 302d9bd94b merge(pr): record PR #41 on pre-release 2026-02-06 09:17:30 -08:00
Zimeng Xiong d68fe6a2c0 fix(auth): stabilize refresh expiry and frontend URL handling 2026-02-06 09:17:24 -08:00
Zimeng Xiong 7a54123e93 fix(export): include excalidraw source/version metadata 2026-02-06 00:26:31 -08:00
Zimeng Xiong 75a1f11a96 feat(auth): consolidate multi-user auth and admin controls 2026-02-06 00:25:13 -08:00
Zimeng Xiong 700e153740 merge: pull PR48 auth and UX into pre-release 2026-02-05 23:25:56 -08:00
Zimeng Xiong fd3b97225f merge: bring main into pre-release 2026-02-05 23:20:06 -08:00
dependabot[bot] 0d1fe8e0e5 Bump lodash from 4.17.21 to 4.17.23 in /backend
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.21 to 4.17.23.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.21...4.17.23)

---
updated-dependencies:
- dependency-name: lodash
  dependency-version: 4.17.23
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-02-02 00:07:20 +00:00
Zimeng Xiong b6d0150d44 chore: release v0.3.2 2026-02-01 16:06:19 -08:00
Zimeng Xiong 55cd816cca fix: correct test assertions for trust proxy behavior in supertest
The demonstration tests had incorrect assumptions about how Express
trust proxy works in supertest (no real socket connection). Updated
assertions to match actual behavior while preserving the test's purpose
of showing that trust proxy: true extracts the correct client IP.
2026-02-01 16:05:58 -08:00
Zimeng Xiong d67bd1daf8 fix express proxy headers 2026-02-01 16:04:52 -08:00
Zimeng Xiong 4b56d3cfc6 repro issue 2026-02-01 16:04:52 -08:00
Zimeng Xiong 88ed4360c0 docs: document comma-separated FRONTEND_URL support
Clarifies that FRONTEND_URL accepts multiple comma-separated URLs
for accessing ExcaliDash from different addresses (e.g., localhost
and LAN IP simultaneously).
2026-02-01 16:01:02 -08:00
Zimeng Xiong 7dfa69de2a fix export source and verisoning 2026-01-30 14:57:27 -08:00
Matteo 4f53b899c9 chore: add dependencies for authentication features
- Add bcrypt for password hashing
- Add jsonwebtoken for JWT tokens
- Add zod for input validation
- Update package-lock.json
2026-01-24 17:13:07 +01:00
Matteo 9fe3a2193d chore: update tests and configuration for auth integration
- Update test utilities for user authentication
- Update Settings page for authenticated export
- Update docker-compose.yml if needed
- Update package-lock.json files
2026-01-24 17:12:39 +01:00
Matteo 804adb7347 docs: add FORK.md with feature summary
- Document all security features added
- Document UX improvements added
- Include migration strategy and backward compatibility notes
- Provide enable instructions for optional features
2026-01-24 17:12:36 +01:00
Matteo 9c6b7dd727 test: add tests for audit logging utility
- Add comprehensive tests for logAuditEvent
- Add tests for getAuditLogs with user filtering
- Test graceful degradation when feature disabled
- Test JSON details parsing
- Follow existing test patterns and style
2026-01-24 17:12:34 +01:00
Matteo f6e337aa98 feat(frontend): add auto-hide header to Editor
- Add mouse-based auto-hide functionality
- Add toggle button to enable/disable auto-hide
- Prevent auto-hide during drawing name editing
- Smooth transitions with translate-y animations
- Dynamic canvas height adjustment based on header visibility
2026-01-24 17:12:31 +01:00
Matteo cbe83efe1f feat(frontend): add select all button to Dashboard
- Add Select All button with CheckSquare/Square icons
- Toggle selection of all drawings in current view
- Match styling with other icon buttons
- Add tooltip for better UX
2026-01-24 17:12:27 +01:00
Matteo 112d58a92a feat(frontend): add profile page for user management
- Add Profile page for viewing/editing user info
- Add display name editing functionality
- Add change password functionality with validation
- Add Profile button to Sidebar navigation
- Handle authentication errors gracefully
2026-01-24 17:12:26 +01:00
Matteo b834f777b5 feat(frontend): add password reset pages
- Add PasswordResetRequest page for requesting reset
- Add PasswordResetConfirm page for confirming reset
- Handle feature disabled state gracefully
- Add routes to App.tsx
2026-01-24 17:12:24 +01:00
Matteo 5f476542e2 feat(frontend): add login and register pages
- Add Login page with email/password form
- Add Register page with email validation
- Add forgot password link to login page
- Update App.tsx with auth routes and AuthProvider
- Add email validation in registration form
2026-01-24 17:12:23 +01:00
Matteo f1a1ff3a8a feat(frontend): add authentication context and API client
- Add AuthContext for managing user authentication state
- Add ProtectedRoute component for route protection
- Update API client with JWT token injection
- Add refresh token rotation support
- Add CSRF token handling
2026-01-24 17:12:21 +01:00
Matteo 29af9fac62 feat(backend): integrate authentication and user isolation
- Add authentication middleware to protected routes
- Add user isolation to drawing and collection queries
- Add audit logging to delete operations
- Update CSRF token handling for authenticated users
2026-01-24 17:12:18 +01:00
Matteo 2998fad8e7 feat(security): add audit logging utility
- Add logAuditEvent function for security event logging
- Add getAuditLogs function for retrieving audit logs
- Gracefully handles disabled feature or missing table
- Feature disabled by default via config flag
2026-01-24 17:12:16 +01:00
Matteo b6e9514eb3 feat(auth): add authentication endpoints (login, register, refresh, me)
- Add POST /auth/register endpoint with email validation
- Add POST /auth/login endpoint with JWT token generation
- Add POST /auth/refresh endpoint for token refresh
- Add GET /auth/me endpoint for current user info
- Add rate limiting for auth endpoints
- Add bcrypt password hashing
- Add JWT access and refresh token generation
2026-01-24 17:12:06 +01:00
Matteo b175706da1 feat(auth): add authentication middleware and utilities
- Add requireAuth middleware for protecting routes
- Add errorHandler and asyncHandler middleware
- Add user isolation helpers for database queries
2026-01-24 17:11:52 +01:00
Matteo 381dd95543 feat(config): add feature flags for optional security features
- Add enablePasswordReset, enableRefreshTokenRotation, enableAuditLogging flags
- All flags default to false for backward compatibility
- Add getOptionalBoolean helper for parsing boolean env vars
- Update .env.example with feature flag documentation
2026-01-24 17:11:50 +01:00
Matteo 78ab52b762 feat(security): add database schema for security features
- Add PasswordResetToken model for password reset flow
- Add RefreshToken model for token rotation tracking
- Add AuditLog model for security event logging
- All features disabled by default via feature flags
2026-01-24 17:11:46 +01:00
Matteo d9013b8f7a feat(auth): add user authentication database schema
- Add User model with email, passwordHash, and name fields
- Add userId foreign key to Drawing and Collection models
- Create initial migration for user authentication
2026-01-24 17:11:40 +01:00
dependabot[bot] 5d29cd919d Bump lodash from 4.17.21 to 4.17.23 in /frontend
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.21 to 4.17.23.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.21...4.17.23)

---
updated-dependencies:
- dependency-name: lodash
  dependency-version: 4.17.23
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-23 23:44:41 +00:00
dependabot[bot] 9170930e8e Bump lodash-es from 4.17.21 to 4.17.23 in /frontend
Bumps [lodash-es](https://github.com/lodash/lodash) from 4.17.21 to 4.17.23.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.21...4.17.23)

---
updated-dependencies:
- dependency-name: lodash-es
  dependency-version: 4.17.23
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-22 01:37:02 +00:00
Adrian Acala f7c9a1ab80 chore(tests): enable server start during end-to-end tests 2026-01-20 20:38:11 -08:00
Adrian Acala af07a73a07 feat(auth): enhance authentication system with login attempt tracking and configuration options
- Added a new `LoginAttempt` model to track login attempts, including rate limiting and lockout functionality.
- Introduced environment variables for configuring login rate limits and maximum failures.
- Updated the authentication middleware to handle login attempts and enforce rate limits.
- Enhanced the user model with indexing for username and email for improved lookup performance.
- Modified the `.env.example` file to include new optional authentication settings.
- Updated integration tests to cover new login attempt features and authentication state management.
2026-01-20 19:55:32 -08:00
Adrian-Ryan Acala 865285fbb7 fix: sync pasted/uploaded images across collaborating tabs (#36)
* fix: sync pasted/uploaded images across collaborating tabs

- Implement file delta synchronization to broadcast image file data
- Add periodic file sync check to catch async file data arrival
- Wrap Excalidraw addFiles API to automatically emit file changes
- Enhance socket element-update to include file payloads
- Add comprehensive E2E test for image collaboration scenarios
- Improve CORS flexibility for development localhost ports

Fixes #25: New images not appearing when collaborating - collaborators
now see uploaded images immediately instead of placeholder until refresh.

* perf: increase file sync polling interval from 500ms to 1000ms

Reduces CPU overhead while still catching async file arrivals. Most
updates go through the addFiles wrapper anyway.

---------

Co-authored-by: Zimeng Xiong <zxzimeng@gmail.com>
2026-01-20 13:49:00 -08:00
Sushil Kumar 77c22916a8 Fix: Save complete app state (#40)
* pass rest of appState in put request

* fix: support both legacy and current currentItemRoundness formats

Add union type to accept both the old object format {type, value} and
the new enum format for backwards compatibility with existing drawings.

---------

Co-authored-by: Zimeng Xiong <zxzimeng@gmail.com>
2026-01-20 13:49:00 -08:00
dependabot[bot] 08d1479a01 Bump react-router and react-router-dom in /frontend
Bumps [react-router](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router) to 7.12.0 and updates ancestor dependency [react-router-dom](https://github.com/remix-run/react-router/tree/HEAD/packages/react-router-dom). These dependencies need to be updated together.


Updates `react-router` from 7.9.6 to 7.12.0
- [Release notes](https://github.com/remix-run/react-router/releases)
- [Changelog](https://github.com/remix-run/react-router/blob/main/packages/react-router/CHANGELOG.md)
- [Commits](https://github.com/remix-run/react-router/commits/react-router@7.12.0/packages/react-router)

Updates `react-router-dom` from 7.9.6 to 7.12.0
- [Release notes](https://github.com/remix-run/react-router/releases)
- [Changelog](https://github.com/remix-run/react-router/blob/main/packages/react-router-dom/CHANGELOG.md)
- [Commits](https://github.com/remix-run/react-router/commits/react-router-dom@7.12.0/packages/react-router-dom)

---
updated-dependencies:
- dependency-name: react-router
  dependency-version: 7.12.0
  dependency-type: indirect
- dependency-name: react-router-dom
  dependency-version: 7.12.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-20 13:49:00 -08:00
dependabot[bot] 7ea1c3ebf0 Bump qs from 6.14.0 to 6.14.1 in /backend
Bumps [qs](https://github.com/ljharb/qs) from 6.14.0 to 6.14.1.
- [Changelog](https://github.com/ljharb/qs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ljharb/qs/compare/v6.14.0...v6.14.1)

---
updated-dependencies:
- dependency-name: qs
  dependency-version: 6.14.1
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-20 13:49:00 -08:00
Zimeng Xiong 81918b00cd chore: release v0.3.1 2026-01-20 13:41:22 -08:00
Zimeng Xiong 3b384dc5fb CSRF token validation failing behind nginx proxy (#38)
Express was not configured to trust proxy headers, causing req.ip to return nginx's internal container IP instead of the actual client IP. In Docker environments, nginx can appear with different internal IPs between requests, causing the CSRF clientId to change and token validation to fail.
2026-01-20 13:39:33 -08:00
dependabot[bot] 5d819b0234 Bump diff from 5.2.0 to 5.2.2 in /frontend
Bumps [diff](https://github.com/kpdecker/jsdiff) from 5.2.0 to 5.2.2.
- [Changelog](https://github.com/kpdecker/jsdiff/blob/master/release-notes.md)
- [Commits](https://github.com/kpdecker/jsdiff/compare/v5.2.0...v5.2.2)

---
updated-dependencies:
- dependency-name: diff
  dependency-version: 5.2.2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-01-20 20:46:06 +00:00
Adrian Acala 260a898e3e test: stabilize e2e auth and rate limits 2026-01-19 00:07:27 -08:00
Adrian Acala 15ac634d15 feat(auth): add password reset functionality and user model update
- Introduced a `mustResetPassword` field in the User model to manage password reset requirements.
- Enhanced authentication flow to support password changes, including validation and error handling.
- Updated frontend components to handle password reset scenarios and integrate with the new API endpoints.
- Modified authentication context and hooks to accommodate the new password reset logic.
- Adjusted E2E tests to ensure proper coverage for the password reset functionality.
2026-01-18 13:02:18 -08:00
Adrian Acala 1a52fe80f3 feat(auth): enhance authentication system with multi-user support and admin role management
- Implemented multi-user authentication with role-based access control.
- Added environment variables for initial admin user setup.
- Updated README and example environment file with new authentication options.
- Introduced user and system configuration models in the database schema.
- Enhanced authentication middleware to support user registration and role management.
- Updated frontend to handle new authentication flows, including admin user creation and role updates.
2026-01-18 09:43:32 -08:00
Adrian Acala 20ef4ee295 feat: implement basic authentication system 2026-01-16 21:34:58 -08:00
Adrian Acala d1dbde95e4 chore(frontend): add eslint v9 config and fix lint issues 2026-01-16 21:34:58 -08:00
Zimeng Xiong 7c238701b7 Update RELEASE.md with CSRF_SECRET instructions (#33)
Added instructions for the required CSRF_SECRET environment variable for CSRF protection in Kubernetes deployments.
2026-01-14 13:11:25 -08:00
Zimeng Xiong c5c8b15e75 Update README header to remove version number
Removed version number from README header.
2026-01-14 13:10:43 -08:00
Zimeng Xiong 9bc3c7c8fc chore: release v0.3.0 2026-01-14 11:26:20 -08:00
Zimeng Xiong 0476315322 0.2.1 Release (#32)
* feat(security): implement CSRF protection

* chore: clean up CSRF implementation

  - Remove unused generateCsrfToken export from security.ts
  - Remove redundant /csrf-token path check (GET already exempt)
  - Restore defineConfig wrapper in vitest.config.ts for type safety

* add K8S note in README, fix broken e2e

* feat/upload-bar (#30)

* feat/upload-bar: add a upload bar when user upload file, indicate the upload process

* feat/save-loading-status: add save status when click back button from editor

* fix: address PR review issues in upload and save features

- Replace deprecated substr() with substring() in UploadContext
- Fix broken error handling that checked stale task status
- Fix missing useEffect dependency in UploadStatus
- Fix CSS class conflict in progress bar styling
- Add error recovery for save state in Editor (reset on failure)
- Use .finally() instead of .then() to ensure refresh on upload failure
- Fix inconsistent indentation in UploadContext

* fix e2e tests

---------

Co-authored-by: Zimeng Xiong <zxzimeng@gmail.com>

* chore: pre-release v0.2.1-dev

* Update backend/src/security.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix filename/math random UUID generation

---------

Co-authored-by: AdrianAcala <adrianacala017@gmail.com>
Co-authored-by: adamant368 <60790941+Yiheng-Liu@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-01-14 11:25:27 -08:00
dependabot[bot] e75b727a5a Bump body-parser from 2.2.0 to 2.2.1 in /backend (#11)
Bumps [body-parser](https://github.com/expressjs/body-parser) from 2.2.0 to 2.2.1.
- [Release notes](https://github.com/expressjs/body-parser/releases)
- [Changelog](https://github.com/expressjs/body-parser/blob/master/HISTORY.md)
- [Commits](https://github.com/expressjs/body-parser/compare/v2.2.0...v2.2.1)

---
updated-dependencies:
- dependency-name: body-parser
  dependency-version: 2.2.1
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-19 15:22:06 -08:00
dependabot[bot] c2aa742a79 Bump express from 5.1.0 to 5.2.0 in /backend (#16)
Bumps [express](https://github.com/expressjs/express) from 5.1.0 to 5.2.0.
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/master/History.md)
- [Commits](https://github.com/expressjs/express/compare/v5.1.0...v5.2.0)

---
updated-dependencies:
- dependency-name: express
  dependency-version: 5.2.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-19 15:21:55 -08:00
Zimeng Xiong 49b413bf07 Testing infrastructure, fix truncating of dataURLs (#26)
* feat: implement comprehensive testing infrastructure

- Fix image dataURL truncation bug in security.ts with configurable size limits
- Add backend integration tests (22 tests) with Vitest for API validation
- Add frontend unit tests (11 tests) for JSON serialization
- Implement browser-based E2E tests (8 tests) with Playwright
- Create Docker setup for repeatable E2E testing environment
- Add GitHub Actions CI workflow for automated testing
- Update .gitignore for test artifacts and temporary files

Testing Infrastructure:
- Backend: Vitest + Supertest for API integration tests
- Frontend: Vitest + Testing Library for component tests
- E2E: Playwright with Chromium for full browser automation
- CI/CD: GitHub Actions with parallel test execution

Security Improvements:
- Make dataURL size limit configurable (default: 10MB)
- Enhanced validation for image dataURLs
- Block malicious content (javascript:, script tags)

All tests pass: 41 total (22 backend + 11 frontend + 8 E2E)

* feat(tests): add comprehensive E2E tests for dashboard workflows and image persistence
chore(env): update environment variables for consistent API URL usage
fix(api): centralize API request helpers for drawing and collection management
style(DrawingCard): enhance accessibility with ARIA attributes and data-testid for testing

* cleanup/revise documentation

* cleanup/revise documentation

* Add end-to-end tests for drawing CRUD, export/import, search/sort, and theme toggle functionalities

- Implemented E2E tests for drawing creation, editing, and deletion in `drawing-crud.spec.ts`.
- Added tests for export and import features, including JSON and SQLite formats in `export-import.spec.ts`.
- Created tests for searching and sorting drawings by name and date in `search-and-sort.spec.ts`.
- Developed tests for theme toggle functionality to ensure persistence across sessions in `theme-toggle.spec.ts`.

* fix: exclude test files from production build to fix Docker build

* feat: implement comprehensive testing infrastructure (#19)

* bump version 0.1.7

* feat: implement comprehensive testing infrastructure

- Fix image dataURL truncation bug in security.ts with configurable size limits
- Add backend integration tests (22 tests) with Vitest for API validation
- Add frontend unit tests (11 tests) for JSON serialization
- Implement browser-based E2E tests (8 tests) with Playwright
- Create Docker setup for repeatable E2E testing environment
- Add GitHub Actions CI workflow for automated testing
- Update .gitignore for test artifacts and temporary files

Testing Infrastructure:
- Backend: Vitest + Supertest for API integration tests
- Frontend: Vitest + Testing Library for component tests
- E2E: Playwright with Chromium for full browser automation
- CI/CD: GitHub Actions with parallel test execution

Security Improvements:
- Make dataURL size limit configurable (default: 10MB)
- Enhanced validation for image dataURLs
- Block malicious content (javascript:, script tags)

All tests pass: 41 total (22 backend + 11 frontend + 8 E2E)

* feat(tests): add comprehensive E2E tests for dashboard workflows and image persistence
chore(env): update environment variables for consistent API URL usage
fix(api): centralize API request helpers for drawing and collection management
style(DrawingCard): enhance accessibility with ARIA attributes and data-testid for testing

* Add end-to-end tests for drawing CRUD, export/import, search/sort, and theme toggle functionalities

- Implemented E2E tests for drawing creation, editing, and deletion in `drawing-crud.spec.ts`.
- Added tests for export and import features, including JSON and SQLite formats in `export-import.spec.ts`.
- Created tests for searching and sorting drawings by name and date in `search-and-sort.spec.ts`.
- Developed tests for theme toggle functionality to ensure persistence across sessions in `theme-toggle.spec.ts`.

* Update backend/src/__tests__/testUtils.ts

---------

Co-authored-by: Zimeng Xiong <zxzimeng@gmail.com>
* version bump 0.1.8

* fix(ci): consolidate E2E server startup to prevent shell isolation issues

Background processes started with & in separate GitHub Actions run steps
can terminate when those steps complete because each step creates a new
shell. This caused the backend and frontend servers to die before the
E2E tests could run.

Fixed by consolidating server startup and test execution into a single
shell step with:
- Proper PID tracking for cleanup
- Health check loops instead of fixed sleep times
- All processes run in the same shell session

* fix(ci): use absolute database path for E2E tests

* fix(backend): use resolved DATABASE_URL path for export/import endpoints

---------

Co-authored-by: Adrian Acala <adrianacala017@gmail.com>
2025-12-19 15:09:15 -08:00
Zimeng Xiong 18c8595c2e bump version 0.1.7 2025-12-01 14:09:37 -08:00
Zimeng Xiong 2e6b94644f bump version 0.1.7 2025-12-01 14:02:32 -08:00
Zimeng Xiong b0bdc05071 Merge pull request #15 from AdrianAcala/perf/drawings-optim
perf: optimize drawings endpoint with caching and lazy loading
2025-12-01 13:59:08 -08:00
Zimeng Xiong 2520d7e7a2 fix(drawings): stabilize lazy loading, improve export error handling, and tidy cache invalidation 2025-12-01 13:58:24 -08:00
Zimeng Xiong 32985ea6fe Merge pull request #13 from AdrianAcala/12-backend-url-config-fix
Add backend URL configuration for frontend and update nginx setup
2025-12-01 13:28:44 -08:00
Zimeng Xiong f8830a8b0f add example in docker-compose, clarify README, add clearer validation, longer timeouts for websocket connections 2025-12-01 13:27:31 -08:00
Adrian Acala c4352185d6 refactor: optimize drawing data handling and cache management
- Improve cache key generation using JSON.stringify for consistent formatting
- Add promise deduplication in DrawingCard to prevent redundant API calls for full drawing data
- Clear full data state when drawing ID changes to ensure fresh data loading
- Fix async cache invalidation in drawing update and collection delete endpoints
- Move cache invalidation after database operations in SQLite import endpoint
- Add HydratedDrawingData type for better type safety in drawing data management
2025-11-29 11:48:47 -08:00
Adrian Acala f9986513f8 Refactor nginx configuration and update README
- Moved BACKEND_URL configuration to the frontend service in the README.
- Added validation for the generated nginx configuration in the entrypoint script.
- Removed fallback nginx configuration copy from the Dockerfile.
- Adjusted nginx template to ensure proper header formatting.

This improves the deployment process and clarifies configuration instructions.
2025-11-29 11:29:43 -08:00
Adrian Acala 6f050aec7d perf: optimize drawings endpoint with caching and lazy loading
- Add 5s in-memory cache for /drawings responses with automatic cleanup
- Split Drawing/DrawingSummary types for efficient data fetching
- Implement lazy loading of drawing data in DrawingCard component
- Add configurable DRAWINGS_CACHE_TTL_MS and RATE_LIMIT_MAX_REQUESTS env vars
- Prevent memory leaks with periodic cleanup of cache and rate limit maps
- Add loading states and better UX for export operations
- Improve JSON parsing with error handling for malformed stored data

Benchmark results (100 drawings, cached):
- Avg latency: 6.94ms (p50: 4ms, p97.5: 8ms)
- Avg throughput: 668 req/s (peak: 1,023)
- 3k requests in 5s with 0 errors

Update .gitignore to exclude generated files, env files, and build artifacts
2025-11-29 04:30:28 +00:00
Adrian Acala 05b787bc27 Add backend URL configuration for frontend and update nginx setup
- Added BACKEND_URL environment variable to docker-compose for frontend service.
- Introduced a new entrypoint script to configure nginx with the BACKEND_URL at runtime.
- Created a template for nginx configuration to handle API and WebSocket requests dynamically.
- Updated README with instructions for configuring reverse proxy setups.

Fixes #12
2025-11-28 17:56:19 -08:00
Zimeng Xiong 971046d568 Update README 2025-11-24 15:04:52 -08:00
Zimeng Xiong 602350d2e6 Merge pull request #9 from ZimengXiong/pre-release
v0.1.6 Add export button, store library in database
2025-11-24 15:01:02 -08:00
Zimeng Xiong f20d48fea2 fix migration issues 2025-11-24 14:53:17 -08:00
Zimeng Xiong c53dc010de Merge branch '8-export-drawing' into pre-release 2025-11-24 14:43:58 -08:00
Zimeng Xiong 03e778a06f add export functionality via exportUtils 2025-11-24 14:39:38 -08:00
Zimeng Xiong fa73708d97 allow importing of libraries via URL, update db schema 2025-11-24 14:32:48 -08:00
Zimeng Xiong ee8204532d Update README.md 2025-11-23 10:23:24 -08:00
Zimeng Xiong a347403a26 Fix caution message formatting in README 2025-11-23 10:15:51 -08:00
Zimeng Xiong 8becfd87bb Merge pull request #6 from ZimengXiong/pre-release
v0.1.5 Fix security issues.
2025-11-23 10:08:42 -08:00
Zimeng Xiong 1b78597649 Merge branch 'main' into pre-release 2025-11-23 10:06:08 -08:00
Zimeng Xiong d93b6493c1 fix database import in docker 2025-11-23 09:40:00 -08:00
Zimeng Xiong d581eb3e88 fix database import, allow sqlite and db format 2025-11-23 09:22:01 -08:00
Zimeng Xiong 4728ef151c release notes 2025-11-23 09:12:36 -08:00
Zimeng Xiong eb5f54a6d0 unify version numbering 2025-11-23 08:53:36 -08:00
Zimeng Xiong c502f1c0bd add version card to settings, branch push protection 2025-11-23 08:35:36 -08:00
Zimeng Xiong 8f9ac1f9c0 add dev tag to pre release dockerhub images 2025-11-23 08:03:48 -08:00
Zimeng Xiong 0787989496 add version managment script 2025-11-23 08:02:00 -08:00
Zimeng Xiong 9bc25a3dc2 update README, release notes 2025-11-23 07:43:14 -08:00
Zimeng Xiong 3cc3fd18f4 add prerelease docker script 2025-11-23 07:30:20 -08:00
Zimeng Xiong 997fa4af03 add prisma cli to dependencies, make zod checks more permissive 2025-11-23 07:08:41 -08:00
Zimeng Xiong b864e82318 Merge branch '1-413-request-entity-too-large' into pre-release 2025-11-22 22:50:40 -08:00
Zimeng Xiong 2f22be2bd7 Merge branch 'fix-CPU-blocking' into pre-release 2025-11-22 22:48:51 -08:00
Zimeng Xiong fcfb850168 Merge branch 'fix-DoS-event-blocking' into pre-release 2025-11-22 22:44:27 -08:00
Zimeng Xiong 4a224c1f92 Merge branch 'fix-rce-via-upload' into pre-release 2025-11-22 22:43:47 -08:00
Zimeng Xiong d1d17e1288 Merge branch 'fix-xss-root-execution' into pre-release 2025-11-22 22:43:31 -08:00
Zimeng Xiong 9055661b51 make async database integrity check 2025-11-22 21:59:18 -08:00
Zimeng Xiong d25a32cdd3 Fix license badge URL in README.md 2025-11-22 21:56:14 -08:00
Zimeng Xiong 8d65404514 Fix license badge URL in README.md 2025-11-22 21:56:14 -08:00
Zimeng Xiong 1b6c32d773 Merge pull request #3 from ZimengXiong/ZimengXiong-patch-1
Create LICENSE
2025-11-22 21:54:46 -08:00
Zimeng Xiong 352bcfca29 Merge pull request #3 from ZimengXiong/ZimengXiong-patch-1
Create LICENSE
2025-11-22 21:54:46 -08:00
Zimeng Xiong 448c678ecc Merge pull request #4 from ZimengXiong/ZimengXiong-readme-license
Update license badge in README.md
2025-11-22 21:53:55 -08:00
Zimeng Xiong e980b96091 Merge pull request #4 from ZimengXiong/ZimengXiong-readme-license
Update license badge in README.md
2025-11-22 21:53:55 -08:00
Zimeng Xiong fabe0fcd54 Update license badge in README.md 2025-11-22 21:53:38 -08:00
Zimeng Xiong ef27256879 Update license badge in README.md 2025-11-22 21:53:38 -08:00
Zimeng Xiong c1da41474f Create LICENSE 2025-11-22 21:51:20 -08:00
Zimeng Xiong 815dcd5c80 Create LICENSE 2025-11-22 21:51:20 -08:00
Zimeng Xiong 29936417fc convert all sync op to async, implemented streaming 2025-11-22 21:36:02 -08:00
Zimeng Xiong 49e32f7d96 validate SQlite magic header 2025-11-22 21:27:34 -08:00
Zimeng Xiong cd9c242983 filter with dompurify 2025-11-22 21:21:28 -08:00
Zimeng Xiong 3835557e67 update nginx config 2025-11-22 21:06:01 -08:00
Zimeng Xiong 69bffab745 fix XSS and Root execution of NPM in docker 2025-11-22 20:38:40 -08:00
Zimeng Xiong ef412a3887 Merge pull request #2 from ZimengXiong/fix-bind-mount-prisma
fix bind mount prisma, auto hydrate empty folder
2025-11-22 20:25:44 -08:00
Zimeng Xiong 2e2b4ca455 fix bind mount prisma, auto hydrate empty folder 2025-11-22 20:25:07 -08:00
Zimeng Xiong fb5fe1235c add fallback for browsers that do not have crypto.randomUUID 2025-11-22 19:18:05 -08:00
Zimeng Xiong e21cdbe6a8 add CORS fallback 2025-11-22 19:14:55 -08:00
Zimeng Xiong 94f33f0a56 fix: add linux-musl-openssl-3.0.x 2025-11-22 19:07:28 -08:00
Zimeng Xiong 5d5e22c8a1 fix: pinning CORS to FRONTEND_URL, validate drawing payloads with Zod, staging SQLite imports with integrity checks and atomic swaps in index.ts 2025-11-22 17:17:50 -08:00
Zimeng Xiong b3dbcc2376 Update caution note in README
Added cautionary note about security and production use.
2025-11-22 16:33:23 -08:00
211 changed files with 41157 additions and 18204 deletions
+6
View File
@@ -7,3 +7,9 @@ dist
.env
.DS_Store
*.log
backend
frontend/node_modules
frontend/dist
frontend/coverage
frontend/test-results
frontend/playwright-report
+199
View File
@@ -0,0 +1,199 @@
name: Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
backend-tests:
name: Backend Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: backend/package-lock.json
- name: Install backend dependencies
run: |
cd backend
npm ci
- name: Generate Prisma client
run: |
cd backend
npx prisma generate
- name: Run backend tests
run: |
cd backend
npm test
frontend-unit-tests:
name: Frontend Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: frontend/package-lock.json
- name: Install frontend dependencies
run: |
cd frontend
npm ci
- name: Run frontend tests
run: |
cd frontend
npm test
e2e-tests:
name: E2E Browser Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install backend dependencies
run: |
cd backend
npm ci
- name: Generate Prisma client
run: |
cd backend
npx prisma generate
- name: Setup backend database
run: |
cd backend
npx prisma db push
env:
DATABASE_URL: file:${{ github.workspace }}/backend/prisma/e2e-test.db
- name: Install frontend dependencies
run: |
cd frontend
npm ci
- name: Install E2E test dependencies
run: |
cd e2e
npm ci
- name: Install Playwright browsers
run: |
cd e2e
npx playwright install chromium --with-deps
- name: Start servers and run E2E tests
run: |
# Start backend server in background
cd backend
DATABASE_URL="file:${{ github.workspace }}/backend/prisma/e2e-test.db" FRONTEND_URL="http://localhost:6767" npm run dev &
BACKEND_PID=$!
cd ..
# Wait for backend to be ready
echo "Waiting for backend server..."
for i in {1..30}; do
if curl -s http://localhost:8000/health > /dev/null; then
echo "Backend is ready!"
break
fi
echo "Attempt $i: Backend not ready yet..."
sleep 2
done
# Start frontend server in background
cd frontend
npm run dev -- --host &
FRONTEND_PID=$!
cd ..
# Wait for frontend to be ready
echo "Waiting for frontend server..."
for i in {1..30}; do
if curl -s http://localhost:6767 > /dev/null; then
echo "Frontend is ready!"
break
fi
echo "Attempt $i: Frontend not ready yet..."
sleep 2
done
# Run E2E tests
cd e2e
NO_SERVER=true CI=true npx playwright test
TEST_EXIT_CODE=$?
# Cleanup
kill $BACKEND_PID $FRONTEND_PID 2>/dev/null || true
exit $TEST_EXIT_CODE
env:
DATABASE_URL: file:${{ github.workspace }}/backend/prisma/e2e-test.db
- name: Upload Playwright report
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: e2e/playwright-report/
retention-days: 7
- name: Upload test results
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-results
path: e2e/test-results/
retention-days: 7
# Security tests for data sanitization
security-tests:
name: Security Sanitization Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: backend/package-lock.json
- name: Install backend dependencies
run: |
cd backend
npm ci
- name: Generate Prisma client
run: |
cd backend
npx prisma generate
- name: Run security tests
run: |
cd backend
npx ts-node src/securityTest.ts
+110 -1
View File
@@ -1,3 +1,112 @@
# Dependencies
frontend/node_modules
.DS_Store
backend/node_modules
# Database
backend/prisma/*.db
backend/prisma/**/*.db
backend/prisma/*.db-journal
backend/prisma/**/*.db-journal
backend/prisma/dev.db
backend/prisma/e2e-test.db
backend/prisma/*.backup
# Uploads
backend/uploads/
# Generated files
backend/src/generated/
# Environment variables
.env
.env.local
.env.production
.env.staging
# Build outputs
frontend/dist/
frontend/build/
backend/dist/
# E2E Testing
e2e/node_modules/
e2e/test-results/
e2e/test-results-user/
e2e/playwright-report/
e2e/playwright-report-user/
e2e/.playwright/
# Temporary files
*.tmp
*.temp
*.bak
# Test artifacts (in case they appear in other locations)
**/playwright-report/
**/test-results/
**/playwright/.cache/
# Docker volumes (if any temporary ones are created)
docker-volumes/
# Logs
*.log
logs/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Coverage directory used by tools like istanbul
coverage/
*.lcov
# Vitest cache
.vitest/
# Playwright screenshots/videos on failure
**/screenshots/
**/videos/
# Dependency directories
jspm_packages/
# Optional npm cache directory
.npm
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env.test
# IDE/Editor files
.vscode/
.idea/
*.swp
*.swo
*~
# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# Temporary files
*.tmp
*.temp
@@ -0,0 +1 @@
../../../frontend
+1 -1
View File
@@ -148,7 +148,7 @@ ExcaliDash/
**Backend (.env):**
```bash
DATABASE_URL="file:./prisma/dev.db"
DATABASE_URL="file:./dev.db"
PORT=8000
NODE_ENV=development
```
+69
View File
@@ -0,0 +1,69 @@
# Fork Summary
This fork adds optional security features and UX improvements with **zero breaking changes** and **minimal migration overhead**. All security features are **disabled by default** via feature flags.
## Security Features Added
1. **Password Reset** - Token-based password reset flow (`/auth/password-reset-request`, `/auth/password-reset-confirm`)
2. **Refresh Token Rotation** - Prevents token reuse by rotating refresh tokens on each use
3. **Audit Logging** - Logs security events (logins, password changes, deletions) for compliance
## UX Improvements Added
1. **Profile Page** - View and edit personal information, change password (`/profile`)
2. **Select All Button** - Quick selection of all drawings in current view
3. **Sort Dropdown** - Improved sort controls with icons and separate direction toggle
4. **Auto-hide Header** - Editor header auto-hides to maximize drawing space (with toggle)
## Backward Compatibility
✅ All security features disabled by default
✅ No breaking changes to existing code
✅ Graceful degradation (missing tables don't cause errors)
✅ Optional database migration
## Enable Security Features
Set in `backend/.env`:
```bash
ENABLE_PASSWORD_RESET=true
ENABLE_REFRESH_TOKEN_ROTATION=true
ENABLE_AUDIT_LOGGING=true
```
Then run migration:
```bash
cd backend && npx prisma migrate deploy
```
## Migration Strategy
**For base project:** Keep features disabled (default) - no migration needed, zero risk.
**For this fork:** Enable features via environment variables when ready.
## Database Changes
Migration adds 3 optional tables (only used when features enabled):
- `PasswordResetToken` - For password reset flow
- `RefreshToken` - For token rotation tracking
- `AuditLog` - For security event logging
## Code Changes
### Backend
- Feature flags in `backend/src/config.ts`
- Conditional logic in auth endpoints
- Graceful error handling for missing tables
- New endpoints: `/auth/profile` (PUT), `/auth/change-password` (POST)
- Audit logging utility (`backend/src/utils/audit.ts`)
### Frontend
- Password reset pages (`/reset-password`, `/reset-password-confirm`)
- Profile page (`/profile`)
- Select All button in Dashboard
- Sort dropdown with icons
- Auto-hide header in Editor with toggle
- Updated API client for token rotation
All changes are backward compatible and optional.
+661
View File
File diff suppressed because it is too large Load Diff
+561
View File
File diff suppressed because it is too large Load Diff
+106 -3
View File
@@ -1,10 +1,13 @@
<img src="logoExcaliDash.png" alt="ExcaliDash Logo" width="80" height="88">
# ExcaliDash v0.1.0
# ExcaliDash
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
![License](https://img.shields.io/github/license/zimengxiong/ExcaliDash)
![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)
[![Docker](https://img.shields.io/badge/docker-ready-blue.svg)](https://hub.docker.com)
_Original repo can be found [here](https://github.com/ZimengXiong/ExcaliDash)_
A self-hosted dashboard and organizer for [Excalidraw](https://github.com/excalidraw/excalidraw) with live collaboration features.
## Screenshots
@@ -21,6 +24,8 @@ A self-hosted dashboard and organizer for [Excalidraw](https://github.com/excali
- [Installation](#installation)
- [Docker Hub (Recommended)](#dockerhub-recommended)
- [Docker Build](#docker-build)
- [Reverse Proxy / Traefik Setups](#reverse-proxy--traefik-setups-docker)
- [Multi-Container / Kubernetes Deployments](#multi-container--kubernetes-deployments)
- [Development](#development)
- [Clone the Repository](#clone-the-repository)
- [Frontend](#frontend)
@@ -74,7 +79,10 @@ See [release notes](https://github.com/ZimengXiong/ExcaliDash/releases) for a sp
# Installation
> [!CAUTION]
> NOT for production use. This is just a side project (and also the first release), and it likely contains some bugs. DO NOT open ports to the internet (e.g. CORS is set to allow all)
> NOT for production use. While attempts have been made at hardening (XSS/dompurify, CORS, rate-limiting, sanitization), they are inadequate for public deployment. Do not expose any ports.
> [!CAUTION]
> ExcaliDash is in BETA. Please backup your data regularly (e.g. with cron).
## Docker Hub (Recommended)
@@ -93,6 +101,10 @@ docker compose -f docker-compose.prod.yml up -d
# Access the frontend at localhost:6767
```
For single-container deployments, `JWT_SECRET` can be omitted and will be auto-generated and persisted in the backend volume on first start. For portability and all multi-instance deployments, set a fixed `JWT_SECRET` explicitly.
By default, the provided Compose files set `TRUST_PROXY=false` for safer setup. Only set `TRUST_PROXY` to a positive hop count (for example, `1`) when requests always pass through a trusted reverse proxy that correctly sets forwarded headers.
## Docker Build
[Install Docker](https://docs.docker.com/desktop/)
@@ -110,6 +122,76 @@ docker compose up -d
# Access the frontend at localhost:6767
```
### Reverse Proxy / Traefik Setups (Docker)
When running ExcaliDash behind Traefik, Nginx, or another reverse proxy, configure both containers so that API + WebSocket calls resolve correctly:
- `FRONTEND_URL` (backend) must match the public URL that users hit (e.g. `https://excalidash.example.com`). This controls CORS and Socket.IO origin checks. **Supports multiple comma-separated URLs** for accessing from different addresses.
- `TRUST_PROXY` (backend) should be set to `1` when requests pass through one trusted reverse proxy hop (for example: frontend nginx -> backend) and forwarded headers are sanitized. This ensures rate limiting and logging use the real client IP from trusted proxy headers.
- `BACKEND_URL` (frontend) tells the Nginx container how to reach the backend from inside Docker/Kubernetes. Override it if your reverse proxy exposes the backend under a different hostname.
```yaml
# docker-compose.yml example
backend:
environment:
# Single URL
- FRONTEND_URL=https://excalidash.example.com
# Trust exactly one reverse-proxy hop
- TRUST_PROXY=1
# Or multiple URLs (comma-separated) for local + network access
# - FRONTEND_URL=http://localhost:6767,http://192.168.1.100:6767,http://nas.local:6767
frontend:
environment:
# For standard Docker Compose (default)
# - BACKEND_URL=backend:8000
# For Kubernetes, use the service DNS name:
- BACKEND_URL=excalidash-backend.default.svc.cluster.local:8000
```
### Multi-Container / Kubernetes Deployments
When running multiple backend replicas (e.g., Kubernetes, Docker Swarm, or load-balanced containers), you **must** set both `JWT_SECRET` and `CSRF_SECRET` to the same values across all instances.
```bash
# Generate a secure secret
openssl rand -base64 32
```
```yaml
# docker-compose.yml or k8s deployment
backend:
environment:
- JWT_SECRET=your-generated-jwt-secret-here
- CSRF_SECRET=your-generated-secret-here
```
Without this, each container generates its own ephemeral CSRF secret, causing token validation failures when requests are routed to different replicas. Single-container deployments work without this setting.
### Authentication Modes (Local + OIDC)
ExcaliDash supports three auth modes via backend `AUTH_MODE`:
- `local` (default): native email/password login only.
- `hybrid`: native login + OIDC login.
- `oidc_enforced`: OIDC-only login (native login/register disabled).
For OIDC modes (`hybrid` or `oidc_enforced`), set:
```yaml
backend:
environment:
- AUTH_MODE=oidc_enforced
- OIDC_PROVIDER_NAME=Authentik
- OIDC_ISSUER_URL=https://auth.example.com/application/o/excalidash/
- OIDC_CLIENT_ID=your-client-id
- OIDC_CLIENT_SECRET=your-client-secret
- OIDC_REDIRECT_URI=https://excalidash.example.com/api/auth/oidc/callback
- OIDC_SCOPES=openid profile email
```
In `oidc_enforced` mode, unauthenticated users are automatically redirected to `/api/auth/oidc/start`.
Users are linked by `(issuer, sub)` first, then by verified email, and optionally auto-provisioned.
# Development
## Clone the Repository
@@ -150,6 +232,27 @@ npx prisma db push
npm run dev
```
### Simulate Auth Onboarding (Development)
To simulate first-run authentication choice flows in local development:
```bash
cd ExcaliDash/backend
# Preview what would change (no data modifications)
npm run dev:simulate-auth-onboarding:dry-run
# Simulate "fresh install" onboarding state
# (wipes drawings/collections/libraries and removes non-bootstrap users)
npm run dev:simulate-auth-onboarding:fresh
# Simulate "migration" onboarding state (ensures legacy data exists)
npm run dev:simulate-auth-onboarding:migration
```
After running a simulation while the backend is already running, wait about 5 seconds
(auth mode cache TTL) or restart the backend before refreshing the UI.
## Project Structure
```
+9
View File
@@ -0,0 +1,9 @@
Multi user setup is opt-in, single user by default
Multi-user support for excalidash
- Admin dashboard
- Password reset, force user password reset (admin only), account lockout recovery
- Rate limits
Deprecates .json and .sqlite database backups in favor of .excalidash archives (user scoped, prevents exporting of senstive information). Legacy import is maintained.
-202
View File
@@ -1,202 +0,0 @@
# Security Fixes Implementation Summary
## Overview
This document summarizes the comprehensive security fixes implemented to address two critical security vulnerabilities identified in ExcaliDash:
1. **Stored XSS Vector (High Severity)** - Data sanitization negligence
2. **Root Execution Privilege (Critical Severity)** - Container escape risk
## Security Issues Fixed
### Issue 1: Stored XSS Vector (High Severity) ✅ FIXED
**Problem**: Backend used lazy `z.object({}).passthrough()` validation for elements and appState, allowing arbitrary JSON storage without sanitization.
**Attack Vectors**:
- Malicious `.excalidraw` files containing `<script>` tags in element properties
- `javascript:` URIs in link attributes
- SVG previews with embedded malicious code
- Compromised clients sending XSS payloads
**Solution Implemented**:
- **Strict Zod Schemas**: Replaced `.passthrough()` with detailed validation schemas for elements and appState
- **HTML/JS Sanitization**: Implemented comprehensive sanitization layer removing script tags, event handlers, and malicious URLs
- **SVG Sanitization**: Special handling for SVG content to prevent script execution
- **URL Validation**: Whitelist-only approach for URL schemes (http, https, mailto, relative paths only)
- **Input Sanitization**: All string inputs are sanitized before database persistence
- **Import Validation**: Additional security checks for imported .excalidraw files with `X-Imported-File` header
### Issue 2: Root Execution Privilege (Critical Severity) ✅ FIXED
**Problem**: Container ran Node.js process as root without USER directive, providing immediate root access in case of RCE.
**Attack Vectors**:
- RCE vulnerabilities in `better-sqlite3` native bindings
- File upload processing vulnerabilities
- Import functionality exploits
**Solution Implemented**:
- **Non-Root User**: Created dedicated `nodejs` user with UID 1001
- **Permission Management**: Proper ownership and permissions for data directories
- **Dockerfile Security**: Added USER directive to switch to non-root execution
- **Entry Point Security**: Updated docker-entrypoint.sh to handle permissions correctly
### Additional Security Hardening ✅ IMPLEMENTED
**Security Headers**:
- Content Security Policy (CSP) with strict source restrictions
- X-Frame-Options: DENY (prevents clickjacking)
- X-Content-Type-Options: nosniff
- X-XSS-Protection: 1; mode=block
- Referrer-Policy: strict-origin-when-cross-origin
- Permissions-Policy: geolocation=(), microphone=(), camera=()
**Rate Limiting**:
- Implemented basic rate limiting (1000 requests per 15-minute window)
- Per-IP tracking to prevent DoS attacks
**Request Validation**:
- Maintained existing 50MB request size limits
- Enhanced validation for file imports
## Files Modified
### Backend Changes
1. **`backend/src/security.ts`** - New security utilities module
- HTML/JS sanitization functions
- SVG sanitization functions
- Strict Zod schemas for elements and appState
- Drawing data validation and sanitization
- URL sanitization with whitelist validation
2. **`backend/src/index.ts`** - Updated backend security
- Replaced lazy `.passthrough()` schemas with strict validation
- Added security middleware with headers and rate limiting
- Enhanced POST /drawings endpoint with import validation
- Added malicious content detection and rejection
3. **`backend/Dockerfile`** - Container security hardening
- Created non-root `nodejs` user (UID 1001)
- Added USER directive for non-root execution
- Set proper file ownership and permissions
4. **`backend/docker-entrypoint.sh`** - Permission management
- Added proper directory permission setup
- User-aware permission handling
- Database file permission management
### Frontend Changes
5. **`frontend/src/utils/importUtils.ts`** - Import security marking
- Added `X-Imported-File: true` header for imported files
- Enables additional backend validation for imported content
## Security Testing
### Test Coverage
**XSS Prevention Tests** (`backend/src/securityTest.ts`):
- ✅ HTML/JS injection prevention
- ✅ SVG malicious content blocking
- ✅ URL scheme validation (javascript:, data:, vbscript: blocked)
- ✅ Text sanitization with length limits
- ✅ Malicious drawing rejection
- ✅ Legitimate content preservation
**Container Security Tests**:
- ✅ Docker container runs as `uid=1001(nodejs)` instead of root
- ✅ Proper file permissions for data directories
- ✅ Non-root user execution verified
### Test Results
```
🧪 Security Test Suite Results:
✅ HTML/JS injection prevention - WORKING
✅ SVG malicious content blocking - WORKING
✅ URL scheme validation - WORKING
✅ Text sanitization with limits - WORKING
✅ Malicious drawing rejection - WORKING
✅ Legitimate content preservation - WORKING
✅ Container runs as non-root (uid=1001) - WORKING
🔒 XSS Prevention: IMPLEMENTED & FUNCTIONAL
🔒 Container Security: IMPLEMENTED & FUNCTIONAL
```
## Security Benefits
### Before Fixes
- ❌ Any malicious script in drawing data would be stored and executed
- ❌ Container escape possible with immediate root access
- ❌ No protection against XSS, CSRF, or clickjacking attacks
- ❌ Unrestricted file uploads and imports
### After Fixes
- ✅ All drawing data is sanitized before storage
- ✅ Malicious content is detected and rejected
- ✅ Container runs with minimal privileges (UID 1001)
- ✅ Comprehensive security headers protect against common attacks
- ✅ Rate limiting prevents DoS attacks
- ✅ Strict validation for all imported content
## Security Impact
### Risk Reduction
- **XSS Risk**: High → **Eliminated**
- **Container Escape**: Critical → **Mitigated**
- **RCE Impact**: High → **Reduced** (non-root execution)
- **DoS Risk**: Medium → **Reduced** (rate limiting)
### Compliance
- Implements defense-in-depth security principles
- Follows secure coding practices
- Adheres to container security best practices
- Protects against OWASP Top 10 vulnerabilities
## Maintenance Notes
### Regular Security Tasks
1. **Security Test Suite**: Run `npm run security-test` to verify XSS prevention
2. **Container Security**: Verify non-root execution in production
3. **Dependency Updates**: Keep dependencies updated for security patches
4. **Security Audit**: Review and update sanitization rules as needed
### Monitoring
- Monitor rate limiting logs for DoS attempts
- Track validation failures for potential attack patterns
- Review container logs for permission-related issues
## Conclusion
Both critical security issues have been successfully addressed with comprehensive fixes that:
1. **Eliminate XSS vulnerabilities** through strict validation and sanitization
2. **Reduce container escape risk** through non-root execution
3. **Add defense-in-depth** security measures
4. **Maintain full functionality** while improving security posture
The implementation includes thorough testing to ensure security measures work correctly while preserving legitimate functionality.
**Security Status**: ✅ **RESOLVED**
+1
View File
@@ -0,0 +1 @@
0.4.6
+4
View File
@@ -9,3 +9,7 @@ dist
*.log
prisma/dev.db
prisma/dev.db-journal
src/generated
coverage
*.test.ts
*.spec.ts
+25
View File
@@ -2,3 +2,28 @@
PORT=8000
NODE_ENV=production
DATABASE_URL=file:/app/prisma/dev.db
FRONTEND_URL=https://draw.louiscreates.com
API_BASE_PATH=/api
# Keep disabled unless traffic always comes through a trusted reverse proxy.
TRUST_PROXY=false
AUTH_MODE=local
JWT_SECRET=change-this-secret-in-production-min-32-chars
# Optional Feature Flags (all default to false for backward compatibility)
# Set to "true" or "1" to enable:
# ENABLE_PASSWORD_RESET=false
# ENABLE_REFRESH_TOKEN_ROTATION=false
# ENABLE_AUDIT_LOGGING=false
# OIDC Configuration (required when AUTH_MODE=hybrid or AUTH_MODE=oidc_enforced)
# OIDC_PROVIDER_NAME=Authentik
# OIDC_ISSUER_URL=https://auth.example.com/application/o/excalidash/
# OIDC_CLIENT_ID=your-client-id
# OIDC_CLIENT_SECRET=your-client-secret
# OIDC_REDIRECT_URI=https://excalidash.example.com/api/auth/oidc/callback
# OIDC_SCOPES=openid profile email
# OIDC_EMAIL_CLAIM=email
# OIDC_EMAIL_VERIFIED_CLAIM=email_verified
# OIDC_REQUIRE_EMAIL_VERIFIED=true
# OIDC_JIT_PROVISIONING=true
# OIDC_FIRST_USER_ADMIN=true
+14 -14
View File
@@ -3,12 +3,15 @@ FROM node:20-alpine AS builder
WORKDIR /app
# Native build deps for modules that may compile from source (e.g., better-sqlite3 on arm64)
RUN apk add --no-cache python3 make g++
# Copy package files
COPY package*.json ./
COPY tsconfig.json ./
# Install dependencies
RUN npm ci
RUN npm ci && npm cache clean --force
# Copy prisma schema
COPY prisma ./prisma/
@@ -25,8 +28,8 @@ RUN npx tsc
# Production stage
FROM node:20-alpine
# Install OpenSSL for Prisma and create non-root user
RUN apk add --no-cache openssl && \
# Install runtime packages and create non-root user
RUN apk add --no-cache openssl su-exec && \
addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001
@@ -36,7 +39,10 @@ WORKDIR /app
COPY package*.json ./
# Install production dependencies only
RUN npm ci --only=production
RUN apk add --no-cache --virtual .build-deps python3 make g++ && \
npm ci --omit=dev && \
npm cache clean --force && \
apk del .build-deps
# Copy prisma schema and migrations for runtime and hydration template
COPY prisma ./prisma/
@@ -48,20 +54,14 @@ COPY --from=builder /app/dist ./dist
# Copy the generated Prisma Client from builder to maintain the same structure
COPY --from=builder /app/src/generated ./dist/generated
# Generate Prisma Client in production (updates node_modules)
RUN npx prisma generate
# Create necessary directories and set proper ownership
RUN mkdir -p /app/uploads /app/prisma && \
chown -R nodejs:nodejs /app
# Create necessary directories (ownership will be set in entrypoint)
RUN mkdir -p /app/uploads /app/prisma
# Copy and set permissions for entrypoint script
COPY docker-entrypoint.sh ./
RUN chmod +x docker-entrypoint.sh && \
chown nodejs:nodejs docker-entrypoint.sh
RUN chmod +x docker-entrypoint.sh
# Switch to non-root user
USER nodejs
# REMOVED: USER nodejs (We must stay root to fix permissions in entrypoint)
EXPOSE 8000
+67 -21
View File
@@ -1,36 +1,82 @@
#!/bin/sh
set -e
# Auto-hydrate prisma directory when bind-mounted volume is empty
if [ ! -f "/app/prisma/schema.prisma" ]; then
echo "Mount is empty. Hydrating /app/prisma from /app/prisma_template..."
cp -R /app/prisma_template/. /app/prisma/
JWT_SECRET_FILE="/app/prisma/.jwt_secret"
CSRF_SECRET_FILE="/app/prisma/.csrf_secret"
# Ensure JWT secret exists for production startup.
# Backward compatibility: older installs may not have JWT_SECRET configured.
if [ -z "${JWT_SECRET:-}" ]; then
echo "JWT_SECRET not provided, resolving persisted secret..."
if [ -f "${JWT_SECRET_FILE}" ]; then
JWT_SECRET="$(tr -d '\r\n' < "${JWT_SECRET_FILE}")"
fi
# Ensure proper ownership and permissions for data directories
echo "Setting up data directory permissions..."
mkdir -p /app/uploads
mkdir -p /app/prisma
if [ -z "${JWT_SECRET}" ]; then
echo "No persisted JWT secret found. Generating a new secret..."
JWT_SECRET="$(openssl rand -hex 32)"
umask 077
printf "%s" "${JWT_SECRET}" > "${JWT_SECRET_FILE}"
fi
else
# Persist explicitly provided secret to support future restarts without env injection.
umask 077
printf "%s" "${JWT_SECRET}" > "${JWT_SECRET_FILE}"
fi
# Set ownership to the node user (UID 1000)
if [ "$(id -u)" = "0" ]; then
# If running as root (for some reason), fix ownership
export JWT_SECRET
# Ensure CSRF secret exists for stable token validation across restarts.
# (Still recommend setting explicitly for multi-instance deployments.)
if [ -z "${CSRF_SECRET:-}" ]; then
echo "CSRF_SECRET not provided, resolving persisted secret..."
if [ -f "${CSRF_SECRET_FILE}" ]; then
CSRF_SECRET="$(tr -d '\r\n' < "${CSRF_SECRET_FILE}")"
fi
if [ -z "${CSRF_SECRET}" ]; then
echo "No persisted CSRF secret found. Generating a new secret..."
CSRF_SECRET="$(openssl rand -base64 32)"
umask 077
printf "%s" "${CSRF_SECRET}" > "${CSRF_SECRET_FILE}"
fi
else
umask 077
printf "%s" "${CSRF_SECRET}" > "${CSRF_SECRET_FILE}"
fi
export CSRF_SECRET
# 1. Hydrate volume if empty (Running as root)
if [ ! -f "/app/prisma/schema.prisma" ]; then
echo "Mount is empty. Hydrating /app/prisma..."
cp -R /app/prisma_template/. /app/prisma/
else
# Volume exists but may be missing new migrations from an upgrade
# Always sync schema and migrations from template to ensure upgrades work
echo "Syncing schema and migrations from template..."
cp /app/prisma_template/schema.prisma /app/prisma/schema.prisma
cp -R /app/prisma_template/migrations/. /app/prisma/migrations/
fi
# 2. Fix permissions unconditionally (Running as root)
echo "Fixing filesystem permissions..."
chown -R nodejs:nodejs /app/uploads
chown -R nodejs:nodejs /app/prisma
fi
chmod 755 /app/uploads
chmod 600 "${JWT_SECRET_FILE}"
chmod 600 "${CSRF_SECRET_FILE}"
# Ensure database file has proper permissions
if [ -f "/app/prisma/dev.db" ]; then
chmod 664 /app/prisma/dev.db 2>/dev/null || true
echo "Database file found, ensuring write permissions..."
chmod 600 /app/prisma/dev.db
fi
# Set appropriate permissions for uploads directory
chmod 755 /app/uploads
# Run migrations as the current user
# 3. Run Migrations (Drop privileges to nodejs)
echo "Running database migrations..."
npx prisma migrate deploy
su-exec nodejs npx prisma migrate deploy
# Start the application
echo "Starting application as user $(whoami) (UID: $(id -u))"
node dist/index.js
# 4. Start Application (Drop privileges to nodejs)
echo "Starting application as nodejs..."
exec su-exec nodejs node dist/index.js
+2286 -366
View File
File diff suppressed because it is too large Load Diff
+31 -9
View File
@@ -1,11 +1,18 @@
{
"name": "backend",
"version": "1.0.0",
"version": "0.4.6",
"description": "",
"main": "index.js",
"scripts": {
"predev": "node scripts/predev-migrate.cjs",
"dev": "nodemon src/index.ts",
"test": "echo \"Error: no test specified\" && exit 1"
"admin:recover": "node scripts/admin-recover.cjs",
"dev:simulate-auth-onboarding:fresh": "node scripts/simulate-auth-onboarding.cjs --scenario fresh",
"dev:simulate-auth-onboarding:migration": "node scripts/simulate-auth-onboarding.cjs --scenario migration",
"dev:simulate-auth-onboarding:dry-run": "node scripts/simulate-auth-onboarding.cjs --scenario migration --dry-run",
"test": "vitest run",
"test:watch": "vitest",
"test:coverage": "vitest run --coverage"
},
"keywords": [],
"author": "",
@@ -13,28 +20,43 @@
"type": "commonjs",
"dependencies": {
"@prisma/client": "^5.22.0",
"@types/archiver": "^7.0.0",
"@types/jsdom": "^27.0.0",
"@types/multer": "^2.0.0",
"@types/socket.io": "^3.0.1",
"archiver": "^7.0.1",
"bcrypt": "^6.0.0",
"better-sqlite3": "^12.4.6",
"cors": "^2.8.5",
"dompurify": "^3.3.0",
"dotenv": "^17.2.3",
"express": "^5.1.0",
"jsdom": "^27.2.0",
"express-rate-limit": "^8.2.1",
"helmet": "^8.1.0",
"jsdom": "^22.1.0",
"jsonwebtoken": "^9.0.3",
"jszip": "^3.10.1",
"ms": "^2.1.3",
"multer": "^2.0.2",
"openid-client": "^5.7.1",
"prisma": "^5.22.0",
"socket.io": "^4.8.1",
"uuid": "^13.0.0",
"zod": "^4.1.12"
},
"devDependencies": {
"@types/archiver": "^7.0.0",
"@types/bcrypt": "^6.0.0",
"@types/cors": "^2.8.19",
"@types/express": "^5.0.5",
"@types/jsdom": "^21.1.7",
"@types/jsonwebtoken": "^9.0.10",
"@types/ms": "^2.1.0",
"@types/multer": "^2.0.0",
"@types/node": "^24.10.1",
"@types/socket.io": "^3.0.1",
"@types/supertest": "^6.0.3",
"@types/uuid": "^10.0.0",
"nodemon": "^3.1.11",
"prisma": "^5.22.0",
"supertest": "^7.1.4",
"ts-node": "^10.9.2",
"typescript": "^5.9.3"
"typescript": "^5.9.3",
"vitest": "^4.0.15"
}
}
+3783
View File
File diff suppressed because it is too large Load Diff
Binary file not shown.
@@ -0,0 +1,7 @@
-- CreateTable
CREATE TABLE "Library" (
"id" TEXT NOT NULL PRIMARY KEY DEFAULT 'default',
"items" TEXT NOT NULL DEFAULT '[]',
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);
@@ -0,0 +1,96 @@
-- NOTE:
-- This migration assigns all pre-existing data to a bootstrap admin user so that
-- upgrading an existing (non-empty) database doesn't fail and the data remains accessible.
-- The bootstrap admin user starts inactive and must be activated via the app's
-- initial registration flow.
-- Constants
-- Keep in sync with backend/src/auth.ts
-- (SQLite doesn't support variables; we inline the values instead.)
-- BOOTSTRAP_USER_ID = 'bootstrap-admin'
-- BOOTSTRAP_LIBRARY_ID = 'user_bootstrap-admin'
-- CreateTable
CREATE TABLE "User" (
"id" TEXT NOT NULL PRIMARY KEY,
"username" TEXT,
"email" TEXT NOT NULL,
"passwordHash" TEXT NOT NULL,
"name" TEXT NOT NULL,
"role" TEXT NOT NULL DEFAULT 'USER',
"mustResetPassword" BOOLEAN NOT NULL DEFAULT false,
"isActive" BOOLEAN NOT NULL DEFAULT true,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);
-- CreateTable
CREATE TABLE "SystemConfig" (
"id" TEXT NOT NULL PRIMARY KEY DEFAULT 'default',
"registrationEnabled" BOOLEAN NOT NULL DEFAULT false,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);
-- Bootstrap state:
-- - Insert a singleton config row (registration disabled by default)
-- - Insert an inactive bootstrap admin user and assign all existing data to it
INSERT INTO "SystemConfig" ("id", "registrationEnabled", "createdAt", "updatedAt")
VALUES ('default', false, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
INSERT INTO "User" ("id", "username", "email", "passwordHash", "name", "role", "mustResetPassword", "isActive", "createdAt", "updatedAt")
VALUES ('bootstrap-admin', NULL, 'bootstrap@excalidash.local', '', 'Bootstrap Admin', 'ADMIN', true, false, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
-- RedefineTables
PRAGMA defer_foreign_keys=ON;
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_Collection" (
"id" TEXT NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL,
"userId" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
CONSTRAINT "Collection_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO "new_Collection" ("createdAt", "id", "name", "userId", "updatedAt")
SELECT "createdAt", "id", "name", 'bootstrap-admin', "updatedAt" FROM "Collection";
DROP TABLE "Collection";
ALTER TABLE "new_Collection" RENAME TO "Collection";
CREATE TABLE "new_Drawing" (
"id" TEXT NOT NULL PRIMARY KEY,
"name" TEXT NOT NULL,
"elements" TEXT NOT NULL,
"appState" TEXT NOT NULL,
"files" TEXT NOT NULL DEFAULT '{}',
"preview" TEXT,
"version" INTEGER NOT NULL DEFAULT 1,
"userId" TEXT NOT NULL,
"collectionId" TEXT,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
CONSTRAINT "Drawing_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "Drawing_collectionId_fkey" FOREIGN KEY ("collectionId") REFERENCES "Collection" ("id") ON DELETE SET NULL ON UPDATE CASCADE
);
INSERT INTO "new_Drawing" ("appState", "collectionId", "createdAt", "elements", "files", "id", "name", "preview", "userId", "updatedAt", "version")
SELECT "appState", "collectionId", "createdAt", "elements", "files", "id", "name", "preview", 'bootstrap-admin', "updatedAt", "version" FROM "Drawing";
DROP TABLE "Drawing";
ALTER TABLE "new_Drawing" RENAME TO "Drawing";
CREATE TABLE "new_Library" (
"id" TEXT NOT NULL PRIMARY KEY,
"items" TEXT NOT NULL DEFAULT '[]',
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);
-- Migrate the singleton library to the bootstrap user's library key.
INSERT INTO "new_Library" ("createdAt", "id", "items", "updatedAt")
SELECT "createdAt", 'user_bootstrap-admin', "items", "updatedAt" FROM "Library" WHERE "id" = 'default';
DROP TABLE "Library";
ALTER TABLE "new_Library" RENAME TO "Library";
PRAGMA foreign_keys=ON;
PRAGMA defer_foreign_keys=OFF;
-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");
-- CreateIndex
CREATE UNIQUE INDEX "User_username_key" ON "User"("username");
@@ -0,0 +1,40 @@
-- CreateTable
CREATE TABLE "PasswordResetToken" (
"id" TEXT NOT NULL PRIMARY KEY,
"userId" TEXT NOT NULL,
"token" TEXT NOT NULL,
"expiresAt" DATETIME NOT NULL,
"used" BOOLEAN NOT NULL DEFAULT false,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "PasswordResetToken_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "RefreshToken" (
"id" TEXT NOT NULL PRIMARY KEY,
"userId" TEXT NOT NULL,
"token" TEXT NOT NULL,
"expiresAt" DATETIME NOT NULL,
"revoked" BOOLEAN NOT NULL DEFAULT false,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "RefreshToken_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
-- CreateTable
CREATE TABLE "AuditLog" (
"id" TEXT NOT NULL PRIMARY KEY,
"userId" TEXT,
"action" TEXT NOT NULL,
"resource" TEXT,
"ipAddress" TEXT,
"userAgent" TEXT,
"details" TEXT,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "AuditLog_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE SET NULL ON UPDATE CASCADE
);
-- CreateIndex
CREATE UNIQUE INDEX "PasswordResetToken_token_key" ON "PasswordResetToken"("token");
-- CreateIndex
CREATE UNIQUE INDEX "RefreshToken_token_key" ON "RefreshToken"("token");
@@ -0,0 +1,5 @@
-- Add authEnabled flag to SystemConfig to support single-user mode by default.
-- SQLite supports simple ADD COLUMN for non-null with default.
ALTER TABLE "SystemConfig" ADD COLUMN "authEnabled" BOOLEAN NOT NULL DEFAULT false;
@@ -0,0 +1,5 @@
-- AlterTable
ALTER TABLE "SystemConfig" ADD COLUMN "authLoginRateLimitEnabled" BOOLEAN NOT NULL DEFAULT 1;
ALTER TABLE "SystemConfig" ADD COLUMN "authLoginRateLimitWindowMs" INTEGER NOT NULL DEFAULT 900000;
ALTER TABLE "SystemConfig" ADD COLUMN "authLoginRateLimitMax" INTEGER NOT NULL DEFAULT 20;

Some files were not shown because too many files have changed in this diff Show More