ysn-rfd commited on
Commit
057576a
·
verified ·
1 Parent(s): db37698

Upload 302 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. ysnrfd_messenger/BACKUP/README.md +67 -0
  2. ysnrfd_messenger/BACKUP/backend/.env +7 -0
  3. ysnrfd_messenger/BACKUP/backend/.env.example +16 -0
  4. ysnrfd_messenger/BACKUP/backend/.gitignore +7 -0
  5. ysnrfd_messenger/BACKUP/backend/package-lock.json +1981 -0
  6. ysnrfd_messenger/BACKUP/backend/package.json +37 -0
  7. ysnrfd_messenger/BACKUP/backend/server.js +200 -0
  8. ysnrfd_messenger/BACKUP/backend/src/config/database.js +17 -0
  9. ysnrfd_messenger/BACKUP/backend/src/controllers/authController.js +208 -0
  10. ysnrfd_messenger/BACKUP/backend/src/controllers/conversationController.js +232 -0
  11. ysnrfd_messenger/BACKUP/backend/src/controllers/messageController.js +199 -0
  12. ysnrfd_messenger/BACKUP/backend/src/controllers/uploadController.js +113 -0
  13. ysnrfd_messenger/BACKUP/backend/src/controllers/userController.js +103 -0
  14. ysnrfd_messenger/BACKUP/backend/src/middleware/auth.js +38 -0
  15. ysnrfd_messenger/BACKUP/backend/src/middleware/upload.js +64 -0
  16. ysnrfd_messenger/BACKUP/backend/src/models/Conversation.js +74 -0
  17. ysnrfd_messenger/BACKUP/backend/src/models/Message.js +71 -0
  18. ysnrfd_messenger/BACKUP/backend/src/models/User.js +81 -0
  19. ysnrfd_messenger/BACKUP/backend/src/routes/auth.js +19 -0
  20. ysnrfd_messenger/BACKUP/backend/src/routes/conversations.js +21 -0
  21. ysnrfd_messenger/BACKUP/backend/src/routes/messages.js +19 -0
  22. ysnrfd_messenger/BACKUP/backend/src/routes/upload.js +16 -0
  23. ysnrfd_messenger/BACKUP/backend/src/routes/users.js +17 -0
  24. ysnrfd_messenger/BACKUP/backend/src/sockets/socketHandlers.js +233 -0
  25. ysnrfd_messenger/BACKUP/backend/src/utils/fileValidation.js +49 -0
  26. ysnrfd_messenger/BACKUP/backend/src/utils/helpers.js +31 -0
  27. ysnrfd_messenger/BACKUP/frontend/.env +3 -0
  28. ysnrfd_messenger/BACKUP/frontend/.env.example +3 -0
  29. ysnrfd_messenger/BACKUP/frontend/.gitignore +7 -0
  30. ysnrfd_messenger/BACKUP/frontend/index.html +13 -0
  31. ysnrfd_messenger/BACKUP/frontend/package-lock.json +0 -0
  32. ysnrfd_messenger/BACKUP/frontend/package.json +33 -0
  33. ysnrfd_messenger/BACKUP/frontend/postcss.config.js +6 -0
  34. ysnrfd_messenger/BACKUP/frontend/public/index.html +15 -0
  35. ysnrfd_messenger/BACKUP/frontend/public/manifest.json +24 -0
  36. ysnrfd_messenger/BACKUP/frontend/public/sw.js +43 -0
  37. ysnrfd_messenger/BACKUP/frontend/src/App.css +47 -0
  38. ysnrfd_messenger/BACKUP/frontend/src/App.jsx +259 -0
  39. ysnrfd_messenger/BACKUP/frontend/src/components/Auth/Login.jsx +178 -0
  40. ysnrfd_messenger/BACKUP/frontend/src/components/Auth/Register.jsx +315 -0
  41. ysnrfd_messenger/BACKUP/frontend/src/components/Chat/ChatArea.jsx +121 -0
  42. ysnrfd_messenger/BACKUP/frontend/src/components/Chat/MessageBubble.jsx +242 -0
  43. ysnrfd_messenger/BACKUP/frontend/src/components/Chat/MessageInput.jsx +280 -0
  44. ysnrfd_messenger/BACKUP/frontend/src/components/Chat/MessageList.jsx +155 -0
  45. ysnrfd_messenger/BACKUP/frontend/src/components/Chat/TypingIndicator.jsx +18 -0
  46. ysnrfd_messenger/BACKUP/frontend/src/components/Dashboard/Dashboard.jsx +254 -0
  47. ysnrfd_messenger/BACKUP/frontend/src/components/Dashboard/Sidebar.jsx +237 -0
  48. ysnrfd_messenger/BACKUP/frontend/src/components/Dashboard/UserSearch.jsx +256 -0
  49. ysnrfd_messenger/BACKUP/frontend/src/components/Files/AudioPlayer.jsx +120 -0
  50. ysnrfd_messenger/BACKUP/frontend/src/components/Files/FilePreview.jsx +61 -0
ysnrfd_messenger/BACKUP/README.md ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # YSNRFD Messenger
2
+
3
+ A modern, real-time messaging application built with the MERN stack (MongoDB, Express.js, React, Node.js) and Socket.IO.
4
+
5
+ ## 🚀 Features
6
+
7
+ ### Core Messaging
8
+ - Real-time one-on-one and group messaging
9
+ - Read receipts and typing indicators
10
+ - Message status (sending, sent, delivered, read)
11
+ - Message editing and deletion
12
+ - Emoji reactions
13
+
14
+ ### File Sharing
15
+ - Image files with preview and download
16
+ - Audio files with built-in player
17
+ - Document files (PDF, TXT) with download
18
+ - File size validation and type checking
19
+ - Drag & drop file upload
20
+
21
+ ### User Experience
22
+ - Dark/Light theme support
23
+ - Responsive design for all devices
24
+ - Progressive Web App (PWA) support
25
+ - Auto-login with token persistence
26
+ - Online/offline status
27
+ - User search and contact management
28
+
29
+ ### Advanced Features
30
+ - Group chats with admin roles
31
+ - Invite links for group joining
32
+ - Message search and filtering
33
+ - File caching for offline access
34
+ - Real-time notifications
35
+ - Cross-device synchronization
36
+
37
+ ## 🛠️ Tech Stack
38
+
39
+ ### Frontend
40
+ - **React 18** with TypeScript
41
+ - **Tailwind CSS** for styling
42
+ - **Socket.IO Client** for real-time communication
43
+ - **Vite** for build tooling
44
+ - **Lucide React** for icons
45
+
46
+ ### Backend
47
+ - **Node.js** with Express.js
48
+ - **Socket.IO** for WebSocket communication
49
+ - **MongoDB** with Mongoose ODM
50
+ - **JWT** for authentication
51
+ - **Multer** for file uploads
52
+
53
+ ## 📦 Installation
54
+
55
+ ### Prerequisites
56
+ - Node.js 16+
57
+ - MongoDB 4.4+
58
+ - npm or yarn
59
+
60
+ ### Backend Setup
61
+ ```bash
62
+ cd backend
63
+ npm install
64
+ cp .env.example .env
65
+ # Configure your environment variables
66
+ npm run dev
67
+ ```
ysnrfd_messenger/BACKUP/backend/.env ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ NODE_ENV=development
2
+ PORT=5000
3
+ CLIENT_URL=http://localhost:3000
4
+ MONGODB_URI=mongodb://localhost:27017/ysnrfd-messenger
5
+ JWT_SECRET=your-super-secret-jwt-key-here
6
+ JWT_EXPIRES_IN=30d
7
+ UPLOAD_PATH=./uploads
ysnrfd_messenger/BACKUP/backend/.env.example ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ NODE_ENV=development
2
+ PORT=5000
3
+ CLIENT_URL=http://localhost:3000
4
+ MONGODB_URI=mongodb://localhost:27017/ysnrfd-messenger
5
+ JWT_SECRET=your-super-secret-jwt-key-here
6
+ JWT_EXPIRES_IN=30d
7
+
8
+ # File Upload Configuration
9
+ AWS_ACCESS_KEY_ID=your-aws-access-key
10
+ AWS_SECRET_ACCESS_KEY=your-aws-secret-key
11
+ AWS_REGION=us-east-1
12
+ S3_BUCKET_NAME=ysnrfd-messenger-files
13
+ UPLOAD_MAX_SIZE=52428800
14
+
15
+ # For local file storage (fallback)
16
+ UPLOAD_PATH=./uploads
ysnrfd_messenger/BACKUP/backend/.gitignore ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ node_modules/
2
+ uploads/
3
+ .env
4
+ *.log
5
+ .DS_Store
6
+ coverage/
7
+ .nyc_output/
ysnrfd_messenger/BACKUP/backend/package-lock.json ADDED
@@ -0,0 +1,1981 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "ysnrfd-messenger-backend",
3
+ "version": "1.0.0",
4
+ "lockfileVersion": 3,
5
+ "requires": true,
6
+ "packages": {
7
+ "": {
8
+ "name": "ysnrfd-messenger-backend",
9
+ "version": "1.0.0",
10
+ "license": "MIT",
11
+ "dependencies": {
12
+ "bcryptjs": "2.4.3",
13
+ "cors": "2.8.5",
14
+ "dotenv": "16.3.1",
15
+ "express": "^4.21.2",
16
+ "express-rate-limit": "6.8.1",
17
+ "helmet": "7.0.0",
18
+ "jsonwebtoken": "9.0.1",
19
+ "mongoose": "^7.8.7",
20
+ "multer": "2.0.2",
21
+ "socket.io": "^4.8.1",
22
+ "uuid": "9.0.0",
23
+ "validator": "^13.15.23"
24
+ },
25
+ "devDependencies": {
26
+ "nodemon": "3.0.1"
27
+ }
28
+ },
29
+ "node_modules/@mongodb-js/saslprep": {
30
+ "version": "1.3.2",
31
+ "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.3.2.tgz",
32
+ "integrity": "sha512-QgA5AySqB27cGTXBFmnpifAi7HxoGUeezwo6p9dI03MuDB6Pp33zgclqVb6oVK3j6I9Vesg0+oojW2XxB59SGg==",
33
+ "license": "MIT",
34
+ "optional": true,
35
+ "dependencies": {
36
+ "sparse-bitfield": "^3.0.3"
37
+ }
38
+ },
39
+ "node_modules/@socket.io/component-emitter": {
40
+ "version": "3.1.2",
41
+ "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz",
42
+ "integrity": "sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA==",
43
+ "license": "MIT"
44
+ },
45
+ "node_modules/@types/cors": {
46
+ "version": "2.8.19",
47
+ "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.19.tgz",
48
+ "integrity": "sha512-mFNylyeyqN93lfe/9CSxOGREz8cpzAhH+E93xJ4xWQf62V8sQ/24reV2nyzUWM6H6Xji+GGHpkbLe7pVoUEskg==",
49
+ "license": "MIT",
50
+ "dependencies": {
51
+ "@types/node": "*"
52
+ }
53
+ },
54
+ "node_modules/@types/node": {
55
+ "version": "24.10.1",
56
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.1.tgz",
57
+ "integrity": "sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ==",
58
+ "license": "MIT",
59
+ "dependencies": {
60
+ "undici-types": "~7.16.0"
61
+ }
62
+ },
63
+ "node_modules/@types/webidl-conversions": {
64
+ "version": "7.0.3",
65
+ "resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.3.tgz",
66
+ "integrity": "sha512-CiJJvcRtIgzadHCYXw7dqEnMNRjhGZlYK05Mj9OyktqV8uVT8fD2BFOB7S1uwBE3Kj2Z+4UyPmFw/Ixgw/LAlA==",
67
+ "license": "MIT"
68
+ },
69
+ "node_modules/@types/whatwg-url": {
70
+ "version": "8.2.2",
71
+ "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-8.2.2.tgz",
72
+ "integrity": "sha512-FtQu10RWgn3D9U4aazdwIE2yzphmTJREDqNdODHrbrZmmMqI0vMheC/6NE/J1Yveaj8H+ela+YwWTjq5PGmuhA==",
73
+ "license": "MIT",
74
+ "dependencies": {
75
+ "@types/node": "*",
76
+ "@types/webidl-conversions": "*"
77
+ }
78
+ },
79
+ "node_modules/accepts": {
80
+ "version": "1.3.8",
81
+ "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
82
+ "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
83
+ "license": "MIT",
84
+ "dependencies": {
85
+ "mime-types": "~2.1.34",
86
+ "negotiator": "0.6.3"
87
+ },
88
+ "engines": {
89
+ "node": ">= 0.6"
90
+ }
91
+ },
92
+ "node_modules/anymatch": {
93
+ "version": "3.1.3",
94
+ "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz",
95
+ "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==",
96
+ "dev": true,
97
+ "license": "ISC",
98
+ "dependencies": {
99
+ "normalize-path": "^3.0.0",
100
+ "picomatch": "^2.0.4"
101
+ },
102
+ "engines": {
103
+ "node": ">= 8"
104
+ }
105
+ },
106
+ "node_modules/append-field": {
107
+ "version": "1.0.0",
108
+ "resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz",
109
+ "integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==",
110
+ "license": "MIT"
111
+ },
112
+ "node_modules/array-flatten": {
113
+ "version": "1.1.1",
114
+ "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
115
+ "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
116
+ "license": "MIT"
117
+ },
118
+ "node_modules/balanced-match": {
119
+ "version": "1.0.2",
120
+ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
121
+ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
122
+ "dev": true,
123
+ "license": "MIT"
124
+ },
125
+ "node_modules/base64id": {
126
+ "version": "2.0.0",
127
+ "resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz",
128
+ "integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==",
129
+ "license": "MIT",
130
+ "engines": {
131
+ "node": "^4.5.0 || >= 5.9"
132
+ }
133
+ },
134
+ "node_modules/bcryptjs": {
135
+ "version": "2.4.3",
136
+ "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz",
137
+ "integrity": "sha512-V/Hy/X9Vt7f3BbPJEi8BdVFMByHi+jNXrYkW3huaybV/kQ0KJg0Y6PkEMbn+zeT+i+SiKZ/HMqJGIIt4LZDqNQ==",
138
+ "license": "MIT"
139
+ },
140
+ "node_modules/binary-extensions": {
141
+ "version": "2.3.0",
142
+ "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz",
143
+ "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==",
144
+ "dev": true,
145
+ "license": "MIT",
146
+ "engines": {
147
+ "node": ">=8"
148
+ },
149
+ "funding": {
150
+ "url": "https://github.com/sponsors/sindresorhus"
151
+ }
152
+ },
153
+ "node_modules/body-parser": {
154
+ "version": "1.20.3",
155
+ "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz",
156
+ "integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==",
157
+ "license": "MIT",
158
+ "dependencies": {
159
+ "bytes": "3.1.2",
160
+ "content-type": "~1.0.5",
161
+ "debug": "2.6.9",
162
+ "depd": "2.0.0",
163
+ "destroy": "1.2.0",
164
+ "http-errors": "2.0.0",
165
+ "iconv-lite": "0.4.24",
166
+ "on-finished": "2.4.1",
167
+ "qs": "6.13.0",
168
+ "raw-body": "2.5.2",
169
+ "type-is": "~1.6.18",
170
+ "unpipe": "1.0.0"
171
+ },
172
+ "engines": {
173
+ "node": ">= 0.8",
174
+ "npm": "1.2.8000 || >= 1.4.16"
175
+ }
176
+ },
177
+ "node_modules/brace-expansion": {
178
+ "version": "1.1.12",
179
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz",
180
+ "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==",
181
+ "dev": true,
182
+ "license": "MIT",
183
+ "dependencies": {
184
+ "balanced-match": "^1.0.0",
185
+ "concat-map": "0.0.1"
186
+ }
187
+ },
188
+ "node_modules/braces": {
189
+ "version": "3.0.3",
190
+ "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
191
+ "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
192
+ "dev": true,
193
+ "license": "MIT",
194
+ "dependencies": {
195
+ "fill-range": "^7.1.1"
196
+ },
197
+ "engines": {
198
+ "node": ">=8"
199
+ }
200
+ },
201
+ "node_modules/bson": {
202
+ "version": "5.5.1",
203
+ "resolved": "https://registry.npmjs.org/bson/-/bson-5.5.1.tgz",
204
+ "integrity": "sha512-ix0EwukN2EpC0SRWIj/7B5+A6uQMQy6KMREI9qQqvgpkV2frH63T0UDVd1SYedL6dNCmDBYB3QtXi4ISk9YT+g==",
205
+ "license": "Apache-2.0",
206
+ "engines": {
207
+ "node": ">=14.20.1"
208
+ }
209
+ },
210
+ "node_modules/buffer-equal-constant-time": {
211
+ "version": "1.0.1",
212
+ "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz",
213
+ "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==",
214
+ "license": "BSD-3-Clause"
215
+ },
216
+ "node_modules/buffer-from": {
217
+ "version": "1.1.2",
218
+ "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
219
+ "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
220
+ "license": "MIT"
221
+ },
222
+ "node_modules/busboy": {
223
+ "version": "1.6.0",
224
+ "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
225
+ "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==",
226
+ "dependencies": {
227
+ "streamsearch": "^1.1.0"
228
+ },
229
+ "engines": {
230
+ "node": ">=10.16.0"
231
+ }
232
+ },
233
+ "node_modules/bytes": {
234
+ "version": "3.1.2",
235
+ "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
236
+ "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
237
+ "license": "MIT",
238
+ "engines": {
239
+ "node": ">= 0.8"
240
+ }
241
+ },
242
+ "node_modules/call-bind-apply-helpers": {
243
+ "version": "1.0.2",
244
+ "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
245
+ "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
246
+ "license": "MIT",
247
+ "dependencies": {
248
+ "es-errors": "^1.3.0",
249
+ "function-bind": "^1.1.2"
250
+ },
251
+ "engines": {
252
+ "node": ">= 0.4"
253
+ }
254
+ },
255
+ "node_modules/call-bound": {
256
+ "version": "1.0.4",
257
+ "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
258
+ "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
259
+ "license": "MIT",
260
+ "dependencies": {
261
+ "call-bind-apply-helpers": "^1.0.2",
262
+ "get-intrinsic": "^1.3.0"
263
+ },
264
+ "engines": {
265
+ "node": ">= 0.4"
266
+ },
267
+ "funding": {
268
+ "url": "https://github.com/sponsors/ljharb"
269
+ }
270
+ },
271
+ "node_modules/chokidar": {
272
+ "version": "3.6.0",
273
+ "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz",
274
+ "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==",
275
+ "dev": true,
276
+ "license": "MIT",
277
+ "dependencies": {
278
+ "anymatch": "~3.1.2",
279
+ "braces": "~3.0.2",
280
+ "glob-parent": "~5.1.2",
281
+ "is-binary-path": "~2.1.0",
282
+ "is-glob": "~4.0.1",
283
+ "normalize-path": "~3.0.0",
284
+ "readdirp": "~3.6.0"
285
+ },
286
+ "engines": {
287
+ "node": ">= 8.10.0"
288
+ },
289
+ "funding": {
290
+ "url": "https://paulmillr.com/funding/"
291
+ },
292
+ "optionalDependencies": {
293
+ "fsevents": "~2.3.2"
294
+ }
295
+ },
296
+ "node_modules/concat-map": {
297
+ "version": "0.0.1",
298
+ "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
299
+ "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
300
+ "dev": true,
301
+ "license": "MIT"
302
+ },
303
+ "node_modules/concat-stream": {
304
+ "version": "2.0.0",
305
+ "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-2.0.0.tgz",
306
+ "integrity": "sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A==",
307
+ "engines": [
308
+ "node >= 6.0"
309
+ ],
310
+ "license": "MIT",
311
+ "dependencies": {
312
+ "buffer-from": "^1.0.0",
313
+ "inherits": "^2.0.3",
314
+ "readable-stream": "^3.0.2",
315
+ "typedarray": "^0.0.6"
316
+ }
317
+ },
318
+ "node_modules/content-disposition": {
319
+ "version": "0.5.4",
320
+ "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
321
+ "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
322
+ "license": "MIT",
323
+ "dependencies": {
324
+ "safe-buffer": "5.2.1"
325
+ },
326
+ "engines": {
327
+ "node": ">= 0.6"
328
+ }
329
+ },
330
+ "node_modules/content-type": {
331
+ "version": "1.0.5",
332
+ "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
333
+ "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
334
+ "license": "MIT",
335
+ "engines": {
336
+ "node": ">= 0.6"
337
+ }
338
+ },
339
+ "node_modules/cookie": {
340
+ "version": "0.7.1",
341
+ "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz",
342
+ "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==",
343
+ "license": "MIT",
344
+ "engines": {
345
+ "node": ">= 0.6"
346
+ }
347
+ },
348
+ "node_modules/cookie-signature": {
349
+ "version": "1.0.6",
350
+ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
351
+ "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==",
352
+ "license": "MIT"
353
+ },
354
+ "node_modules/cors": {
355
+ "version": "2.8.5",
356
+ "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
357
+ "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
358
+ "license": "MIT",
359
+ "dependencies": {
360
+ "object-assign": "^4",
361
+ "vary": "^1"
362
+ },
363
+ "engines": {
364
+ "node": ">= 0.10"
365
+ }
366
+ },
367
+ "node_modules/debug": {
368
+ "version": "2.6.9",
369
+ "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
370
+ "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
371
+ "license": "MIT",
372
+ "dependencies": {
373
+ "ms": "2.0.0"
374
+ }
375
+ },
376
+ "node_modules/depd": {
377
+ "version": "2.0.0",
378
+ "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
379
+ "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
380
+ "license": "MIT",
381
+ "engines": {
382
+ "node": ">= 0.8"
383
+ }
384
+ },
385
+ "node_modules/destroy": {
386
+ "version": "1.2.0",
387
+ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
388
+ "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
389
+ "license": "MIT",
390
+ "engines": {
391
+ "node": ">= 0.8",
392
+ "npm": "1.2.8000 || >= 1.4.16"
393
+ }
394
+ },
395
+ "node_modules/dotenv": {
396
+ "version": "16.3.1",
397
+ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.1.tgz",
398
+ "integrity": "sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==",
399
+ "license": "BSD-2-Clause",
400
+ "engines": {
401
+ "node": ">=12"
402
+ },
403
+ "funding": {
404
+ "url": "https://github.com/motdotla/dotenv?sponsor=1"
405
+ }
406
+ },
407
+ "node_modules/dunder-proto": {
408
+ "version": "1.0.1",
409
+ "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
410
+ "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
411
+ "license": "MIT",
412
+ "dependencies": {
413
+ "call-bind-apply-helpers": "^1.0.1",
414
+ "es-errors": "^1.3.0",
415
+ "gopd": "^1.2.0"
416
+ },
417
+ "engines": {
418
+ "node": ">= 0.4"
419
+ }
420
+ },
421
+ "node_modules/ecdsa-sig-formatter": {
422
+ "version": "1.0.11",
423
+ "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz",
424
+ "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==",
425
+ "license": "Apache-2.0",
426
+ "dependencies": {
427
+ "safe-buffer": "^5.0.1"
428
+ }
429
+ },
430
+ "node_modules/ee-first": {
431
+ "version": "1.1.1",
432
+ "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
433
+ "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
434
+ "license": "MIT"
435
+ },
436
+ "node_modules/encodeurl": {
437
+ "version": "2.0.0",
438
+ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
439
+ "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
440
+ "license": "MIT",
441
+ "engines": {
442
+ "node": ">= 0.8"
443
+ }
444
+ },
445
+ "node_modules/engine.io": {
446
+ "version": "6.6.4",
447
+ "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-6.6.4.tgz",
448
+ "integrity": "sha512-ZCkIjSYNDyGn0R6ewHDtXgns/Zre/NT6Agvq1/WobF7JXgFff4SeDroKiCO3fNJreU9YG429Sc81o4w5ok/W5g==",
449
+ "license": "MIT",
450
+ "dependencies": {
451
+ "@types/cors": "^2.8.12",
452
+ "@types/node": ">=10.0.0",
453
+ "accepts": "~1.3.4",
454
+ "base64id": "2.0.0",
455
+ "cookie": "~0.7.2",
456
+ "cors": "~2.8.5",
457
+ "debug": "~4.3.1",
458
+ "engine.io-parser": "~5.2.1",
459
+ "ws": "~8.17.1"
460
+ },
461
+ "engines": {
462
+ "node": ">=10.2.0"
463
+ }
464
+ },
465
+ "node_modules/engine.io-parser": {
466
+ "version": "5.2.3",
467
+ "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.3.tgz",
468
+ "integrity": "sha512-HqD3yTBfnBxIrbnM1DoD6Pcq8NECnh8d4As1Qgh0z5Gg3jRRIqijury0CL3ghu/edArpUYiYqQiDUQBIs4np3Q==",
469
+ "license": "MIT",
470
+ "engines": {
471
+ "node": ">=10.0.0"
472
+ }
473
+ },
474
+ "node_modules/engine.io/node_modules/cookie": {
475
+ "version": "0.7.2",
476
+ "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
477
+ "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
478
+ "license": "MIT",
479
+ "engines": {
480
+ "node": ">= 0.6"
481
+ }
482
+ },
483
+ "node_modules/engine.io/node_modules/debug": {
484
+ "version": "4.3.7",
485
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
486
+ "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
487
+ "license": "MIT",
488
+ "dependencies": {
489
+ "ms": "^2.1.3"
490
+ },
491
+ "engines": {
492
+ "node": ">=6.0"
493
+ },
494
+ "peerDependenciesMeta": {
495
+ "supports-color": {
496
+ "optional": true
497
+ }
498
+ }
499
+ },
500
+ "node_modules/engine.io/node_modules/ms": {
501
+ "version": "2.1.3",
502
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
503
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
504
+ "license": "MIT"
505
+ },
506
+ "node_modules/es-define-property": {
507
+ "version": "1.0.1",
508
+ "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
509
+ "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
510
+ "license": "MIT",
511
+ "engines": {
512
+ "node": ">= 0.4"
513
+ }
514
+ },
515
+ "node_modules/es-errors": {
516
+ "version": "1.3.0",
517
+ "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
518
+ "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
519
+ "license": "MIT",
520
+ "engines": {
521
+ "node": ">= 0.4"
522
+ }
523
+ },
524
+ "node_modules/es-object-atoms": {
525
+ "version": "1.1.1",
526
+ "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
527
+ "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
528
+ "license": "MIT",
529
+ "dependencies": {
530
+ "es-errors": "^1.3.0"
531
+ },
532
+ "engines": {
533
+ "node": ">= 0.4"
534
+ }
535
+ },
536
+ "node_modules/escape-html": {
537
+ "version": "1.0.3",
538
+ "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
539
+ "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
540
+ "license": "MIT"
541
+ },
542
+ "node_modules/etag": {
543
+ "version": "1.8.1",
544
+ "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
545
+ "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
546
+ "license": "MIT",
547
+ "engines": {
548
+ "node": ">= 0.6"
549
+ }
550
+ },
551
+ "node_modules/express": {
552
+ "version": "4.21.2",
553
+ "resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz",
554
+ "integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==",
555
+ "license": "MIT",
556
+ "peer": true,
557
+ "dependencies": {
558
+ "accepts": "~1.3.8",
559
+ "array-flatten": "1.1.1",
560
+ "body-parser": "1.20.3",
561
+ "content-disposition": "0.5.4",
562
+ "content-type": "~1.0.4",
563
+ "cookie": "0.7.1",
564
+ "cookie-signature": "1.0.6",
565
+ "debug": "2.6.9",
566
+ "depd": "2.0.0",
567
+ "encodeurl": "~2.0.0",
568
+ "escape-html": "~1.0.3",
569
+ "etag": "~1.8.1",
570
+ "finalhandler": "1.3.1",
571
+ "fresh": "0.5.2",
572
+ "http-errors": "2.0.0",
573
+ "merge-descriptors": "1.0.3",
574
+ "methods": "~1.1.2",
575
+ "on-finished": "2.4.1",
576
+ "parseurl": "~1.3.3",
577
+ "path-to-regexp": "0.1.12",
578
+ "proxy-addr": "~2.0.7",
579
+ "qs": "6.13.0",
580
+ "range-parser": "~1.2.1",
581
+ "safe-buffer": "5.2.1",
582
+ "send": "0.19.0",
583
+ "serve-static": "1.16.2",
584
+ "setprototypeof": "1.2.0",
585
+ "statuses": "2.0.1",
586
+ "type-is": "~1.6.18",
587
+ "utils-merge": "1.0.1",
588
+ "vary": "~1.1.2"
589
+ },
590
+ "engines": {
591
+ "node": ">= 0.10.0"
592
+ },
593
+ "funding": {
594
+ "type": "opencollective",
595
+ "url": "https://opencollective.com/express"
596
+ }
597
+ },
598
+ "node_modules/express-rate-limit": {
599
+ "version": "6.8.1",
600
+ "resolved": "https://registry.npmjs.org/express-rate-limit/-/express-rate-limit-6.8.1.tgz",
601
+ "integrity": "sha512-xJyudsE60CsDShK74Ni1MxsldYaIoivmG3ieK2tAckMsYCBewEuGalss6p/jHmFFnqM9xd5ojE0W2VlanxcOKg==",
602
+ "license": "MIT",
603
+ "engines": {
604
+ "node": ">= 14.0.0"
605
+ },
606
+ "peerDependencies": {
607
+ "express": "^4 || ^5"
608
+ }
609
+ },
610
+ "node_modules/fill-range": {
611
+ "version": "7.1.1",
612
+ "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
613
+ "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
614
+ "dev": true,
615
+ "license": "MIT",
616
+ "dependencies": {
617
+ "to-regex-range": "^5.0.1"
618
+ },
619
+ "engines": {
620
+ "node": ">=8"
621
+ }
622
+ },
623
+ "node_modules/finalhandler": {
624
+ "version": "1.3.1",
625
+ "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz",
626
+ "integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==",
627
+ "license": "MIT",
628
+ "dependencies": {
629
+ "debug": "2.6.9",
630
+ "encodeurl": "~2.0.0",
631
+ "escape-html": "~1.0.3",
632
+ "on-finished": "2.4.1",
633
+ "parseurl": "~1.3.3",
634
+ "statuses": "2.0.1",
635
+ "unpipe": "~1.0.0"
636
+ },
637
+ "engines": {
638
+ "node": ">= 0.8"
639
+ }
640
+ },
641
+ "node_modules/forwarded": {
642
+ "version": "0.2.0",
643
+ "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
644
+ "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
645
+ "license": "MIT",
646
+ "engines": {
647
+ "node": ">= 0.6"
648
+ }
649
+ },
650
+ "node_modules/fresh": {
651
+ "version": "0.5.2",
652
+ "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
653
+ "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
654
+ "license": "MIT",
655
+ "engines": {
656
+ "node": ">= 0.6"
657
+ }
658
+ },
659
+ "node_modules/fsevents": {
660
+ "version": "2.3.3",
661
+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
662
+ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
663
+ "dev": true,
664
+ "hasInstallScript": true,
665
+ "license": "MIT",
666
+ "optional": true,
667
+ "os": [
668
+ "darwin"
669
+ ],
670
+ "engines": {
671
+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
672
+ }
673
+ },
674
+ "node_modules/function-bind": {
675
+ "version": "1.1.2",
676
+ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
677
+ "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
678
+ "license": "MIT",
679
+ "funding": {
680
+ "url": "https://github.com/sponsors/ljharb"
681
+ }
682
+ },
683
+ "node_modules/get-intrinsic": {
684
+ "version": "1.3.0",
685
+ "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
686
+ "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
687
+ "license": "MIT",
688
+ "dependencies": {
689
+ "call-bind-apply-helpers": "^1.0.2",
690
+ "es-define-property": "^1.0.1",
691
+ "es-errors": "^1.3.0",
692
+ "es-object-atoms": "^1.1.1",
693
+ "function-bind": "^1.1.2",
694
+ "get-proto": "^1.0.1",
695
+ "gopd": "^1.2.0",
696
+ "has-symbols": "^1.1.0",
697
+ "hasown": "^2.0.2",
698
+ "math-intrinsics": "^1.1.0"
699
+ },
700
+ "engines": {
701
+ "node": ">= 0.4"
702
+ },
703
+ "funding": {
704
+ "url": "https://github.com/sponsors/ljharb"
705
+ }
706
+ },
707
+ "node_modules/get-proto": {
708
+ "version": "1.0.1",
709
+ "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
710
+ "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
711
+ "license": "MIT",
712
+ "dependencies": {
713
+ "dunder-proto": "^1.0.1",
714
+ "es-object-atoms": "^1.0.0"
715
+ },
716
+ "engines": {
717
+ "node": ">= 0.4"
718
+ }
719
+ },
720
+ "node_modules/glob-parent": {
721
+ "version": "5.1.2",
722
+ "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
723
+ "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
724
+ "dev": true,
725
+ "license": "ISC",
726
+ "dependencies": {
727
+ "is-glob": "^4.0.1"
728
+ },
729
+ "engines": {
730
+ "node": ">= 6"
731
+ }
732
+ },
733
+ "node_modules/gopd": {
734
+ "version": "1.2.0",
735
+ "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
736
+ "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
737
+ "license": "MIT",
738
+ "engines": {
739
+ "node": ">= 0.4"
740
+ },
741
+ "funding": {
742
+ "url": "https://github.com/sponsors/ljharb"
743
+ }
744
+ },
745
+ "node_modules/has-flag": {
746
+ "version": "3.0.0",
747
+ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
748
+ "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
749
+ "dev": true,
750
+ "license": "MIT",
751
+ "engines": {
752
+ "node": ">=4"
753
+ }
754
+ },
755
+ "node_modules/has-symbols": {
756
+ "version": "1.1.0",
757
+ "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
758
+ "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
759
+ "license": "MIT",
760
+ "engines": {
761
+ "node": ">= 0.4"
762
+ },
763
+ "funding": {
764
+ "url": "https://github.com/sponsors/ljharb"
765
+ }
766
+ },
767
+ "node_modules/hasown": {
768
+ "version": "2.0.2",
769
+ "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
770
+ "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
771
+ "license": "MIT",
772
+ "dependencies": {
773
+ "function-bind": "^1.1.2"
774
+ },
775
+ "engines": {
776
+ "node": ">= 0.4"
777
+ }
778
+ },
779
+ "node_modules/helmet": {
780
+ "version": "7.0.0",
781
+ "resolved": "https://registry.npmjs.org/helmet/-/helmet-7.0.0.tgz",
782
+ "integrity": "sha512-MsIgYmdBh460ZZ8cJC81q4XJknjG567wzEmv46WOBblDb6TUd3z8/GhgmsM9pn8g2B80tAJ4m5/d3Bi1KrSUBQ==",
783
+ "license": "MIT",
784
+ "engines": {
785
+ "node": ">=16.0.0"
786
+ }
787
+ },
788
+ "node_modules/http-errors": {
789
+ "version": "2.0.0",
790
+ "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
791
+ "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==",
792
+ "license": "MIT",
793
+ "dependencies": {
794
+ "depd": "2.0.0",
795
+ "inherits": "2.0.4",
796
+ "setprototypeof": "1.2.0",
797
+ "statuses": "2.0.1",
798
+ "toidentifier": "1.0.1"
799
+ },
800
+ "engines": {
801
+ "node": ">= 0.8"
802
+ }
803
+ },
804
+ "node_modules/iconv-lite": {
805
+ "version": "0.4.24",
806
+ "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
807
+ "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
808
+ "license": "MIT",
809
+ "dependencies": {
810
+ "safer-buffer": ">= 2.1.2 < 3"
811
+ },
812
+ "engines": {
813
+ "node": ">=0.10.0"
814
+ }
815
+ },
816
+ "node_modules/ignore-by-default": {
817
+ "version": "1.0.1",
818
+ "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz",
819
+ "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==",
820
+ "dev": true,
821
+ "license": "ISC"
822
+ },
823
+ "node_modules/inherits": {
824
+ "version": "2.0.4",
825
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
826
+ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
827
+ "license": "ISC"
828
+ },
829
+ "node_modules/ip-address": {
830
+ "version": "10.1.0",
831
+ "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-10.1.0.tgz",
832
+ "integrity": "sha512-XXADHxXmvT9+CRxhXg56LJovE+bmWnEWB78LB83VZTprKTmaC5QfruXocxzTZ2Kl0DNwKuBdlIhjL8LeY8Sf8Q==",
833
+ "license": "MIT",
834
+ "engines": {
835
+ "node": ">= 12"
836
+ }
837
+ },
838
+ "node_modules/ipaddr.js": {
839
+ "version": "1.9.1",
840
+ "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
841
+ "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
842
+ "license": "MIT",
843
+ "engines": {
844
+ "node": ">= 0.10"
845
+ }
846
+ },
847
+ "node_modules/is-binary-path": {
848
+ "version": "2.1.0",
849
+ "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
850
+ "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
851
+ "dev": true,
852
+ "license": "MIT",
853
+ "dependencies": {
854
+ "binary-extensions": "^2.0.0"
855
+ },
856
+ "engines": {
857
+ "node": ">=8"
858
+ }
859
+ },
860
+ "node_modules/is-extglob": {
861
+ "version": "2.1.1",
862
+ "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
863
+ "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
864
+ "dev": true,
865
+ "license": "MIT",
866
+ "engines": {
867
+ "node": ">=0.10.0"
868
+ }
869
+ },
870
+ "node_modules/is-glob": {
871
+ "version": "4.0.3",
872
+ "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
873
+ "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
874
+ "dev": true,
875
+ "license": "MIT",
876
+ "dependencies": {
877
+ "is-extglob": "^2.1.1"
878
+ },
879
+ "engines": {
880
+ "node": ">=0.10.0"
881
+ }
882
+ },
883
+ "node_modules/is-number": {
884
+ "version": "7.0.0",
885
+ "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
886
+ "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
887
+ "dev": true,
888
+ "license": "MIT",
889
+ "engines": {
890
+ "node": ">=0.12.0"
891
+ }
892
+ },
893
+ "node_modules/jsonwebtoken": {
894
+ "version": "9.0.1",
895
+ "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.1.tgz",
896
+ "integrity": "sha512-K8wx7eJ5TPvEjuiVSkv167EVboBDv9PZdDoF7BgeQnBLVvZWW9clr2PsQHVJDTKaEIH5JBIwHujGcHp7GgI2eg==",
897
+ "license": "MIT",
898
+ "dependencies": {
899
+ "jws": "^3.2.2",
900
+ "lodash": "^4.17.21",
901
+ "ms": "^2.1.1",
902
+ "semver": "^7.3.8"
903
+ },
904
+ "engines": {
905
+ "node": ">=12",
906
+ "npm": ">=6"
907
+ }
908
+ },
909
+ "node_modules/jsonwebtoken/node_modules/ms": {
910
+ "version": "2.1.3",
911
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
912
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
913
+ "license": "MIT"
914
+ },
915
+ "node_modules/jwa": {
916
+ "version": "1.4.2",
917
+ "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.2.tgz",
918
+ "integrity": "sha512-eeH5JO+21J78qMvTIDdBXidBd6nG2kZjg5Ohz/1fpa28Z4CcsWUzJ1ZZyFq/3z3N17aZy+ZuBoHljASbL1WfOw==",
919
+ "license": "MIT",
920
+ "dependencies": {
921
+ "buffer-equal-constant-time": "^1.0.1",
922
+ "ecdsa-sig-formatter": "1.0.11",
923
+ "safe-buffer": "^5.0.1"
924
+ }
925
+ },
926
+ "node_modules/jws": {
927
+ "version": "3.2.2",
928
+ "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz",
929
+ "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==",
930
+ "license": "MIT",
931
+ "dependencies": {
932
+ "jwa": "^1.4.1",
933
+ "safe-buffer": "^5.0.1"
934
+ }
935
+ },
936
+ "node_modules/kareem": {
937
+ "version": "2.5.1",
938
+ "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.5.1.tgz",
939
+ "integrity": "sha512-7jFxRVm+jD+rkq3kY0iZDJfsO2/t4BBPeEb2qKn2lR/9KhuksYk5hxzfRYWMPV8P/x2d0kHD306YyWLzjjH+uA==",
940
+ "license": "Apache-2.0",
941
+ "engines": {
942
+ "node": ">=12.0.0"
943
+ }
944
+ },
945
+ "node_modules/lodash": {
946
+ "version": "4.17.21",
947
+ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
948
+ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
949
+ "license": "MIT"
950
+ },
951
+ "node_modules/math-intrinsics": {
952
+ "version": "1.1.0",
953
+ "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
954
+ "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
955
+ "license": "MIT",
956
+ "engines": {
957
+ "node": ">= 0.4"
958
+ }
959
+ },
960
+ "node_modules/media-typer": {
961
+ "version": "0.3.0",
962
+ "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
963
+ "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
964
+ "license": "MIT",
965
+ "engines": {
966
+ "node": ">= 0.6"
967
+ }
968
+ },
969
+ "node_modules/memory-pager": {
970
+ "version": "1.5.0",
971
+ "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz",
972
+ "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==",
973
+ "license": "MIT",
974
+ "optional": true
975
+ },
976
+ "node_modules/merge-descriptors": {
977
+ "version": "1.0.3",
978
+ "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
979
+ "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
980
+ "license": "MIT",
981
+ "funding": {
982
+ "url": "https://github.com/sponsors/sindresorhus"
983
+ }
984
+ },
985
+ "node_modules/methods": {
986
+ "version": "1.1.2",
987
+ "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
988
+ "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
989
+ "license": "MIT",
990
+ "engines": {
991
+ "node": ">= 0.6"
992
+ }
993
+ },
994
+ "node_modules/mime": {
995
+ "version": "1.6.0",
996
+ "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
997
+ "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
998
+ "license": "MIT",
999
+ "bin": {
1000
+ "mime": "cli.js"
1001
+ },
1002
+ "engines": {
1003
+ "node": ">=4"
1004
+ }
1005
+ },
1006
+ "node_modules/mime-db": {
1007
+ "version": "1.52.0",
1008
+ "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
1009
+ "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
1010
+ "license": "MIT",
1011
+ "engines": {
1012
+ "node": ">= 0.6"
1013
+ }
1014
+ },
1015
+ "node_modules/mime-types": {
1016
+ "version": "2.1.35",
1017
+ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
1018
+ "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
1019
+ "license": "MIT",
1020
+ "dependencies": {
1021
+ "mime-db": "1.52.0"
1022
+ },
1023
+ "engines": {
1024
+ "node": ">= 0.6"
1025
+ }
1026
+ },
1027
+ "node_modules/minimatch": {
1028
+ "version": "3.1.2",
1029
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
1030
+ "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
1031
+ "dev": true,
1032
+ "license": "ISC",
1033
+ "dependencies": {
1034
+ "brace-expansion": "^1.1.7"
1035
+ },
1036
+ "engines": {
1037
+ "node": "*"
1038
+ }
1039
+ },
1040
+ "node_modules/minimist": {
1041
+ "version": "1.2.8",
1042
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
1043
+ "integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
1044
+ "license": "MIT",
1045
+ "funding": {
1046
+ "url": "https://github.com/sponsors/ljharb"
1047
+ }
1048
+ },
1049
+ "node_modules/mkdirp": {
1050
+ "version": "0.5.6",
1051
+ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
1052
+ "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
1053
+ "license": "MIT",
1054
+ "dependencies": {
1055
+ "minimist": "^1.2.6"
1056
+ },
1057
+ "bin": {
1058
+ "mkdirp": "bin/cmd.js"
1059
+ }
1060
+ },
1061
+ "node_modules/mongodb": {
1062
+ "version": "5.9.2",
1063
+ "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-5.9.2.tgz",
1064
+ "integrity": "sha512-H60HecKO4Bc+7dhOv4sJlgvenK4fQNqqUIlXxZYQNbfEWSALGAwGoyJd/0Qwk4TttFXUOHJ2ZJQe/52ScaUwtQ==",
1065
+ "license": "Apache-2.0",
1066
+ "dependencies": {
1067
+ "bson": "^5.5.0",
1068
+ "mongodb-connection-string-url": "^2.6.0",
1069
+ "socks": "^2.7.1"
1070
+ },
1071
+ "engines": {
1072
+ "node": ">=14.20.1"
1073
+ },
1074
+ "optionalDependencies": {
1075
+ "@mongodb-js/saslprep": "^1.1.0"
1076
+ },
1077
+ "peerDependencies": {
1078
+ "@aws-sdk/credential-providers": "^3.188.0",
1079
+ "@mongodb-js/zstd": "^1.0.0",
1080
+ "kerberos": "^1.0.0 || ^2.0.0",
1081
+ "mongodb-client-encryption": ">=2.3.0 <3",
1082
+ "snappy": "^7.2.2"
1083
+ },
1084
+ "peerDependenciesMeta": {
1085
+ "@aws-sdk/credential-providers": {
1086
+ "optional": true
1087
+ },
1088
+ "@mongodb-js/zstd": {
1089
+ "optional": true
1090
+ },
1091
+ "kerberos": {
1092
+ "optional": true
1093
+ },
1094
+ "mongodb-client-encryption": {
1095
+ "optional": true
1096
+ },
1097
+ "snappy": {
1098
+ "optional": true
1099
+ }
1100
+ }
1101
+ },
1102
+ "node_modules/mongodb-connection-string-url": {
1103
+ "version": "2.6.0",
1104
+ "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-2.6.0.tgz",
1105
+ "integrity": "sha512-WvTZlI9ab0QYtTYnuMLgobULWhokRjtC7db9LtcVfJ+Hsnyr5eo6ZtNAt3Ly24XZScGMelOcGtm7lSn0332tPQ==",
1106
+ "license": "Apache-2.0",
1107
+ "dependencies": {
1108
+ "@types/whatwg-url": "^8.2.1",
1109
+ "whatwg-url": "^11.0.0"
1110
+ }
1111
+ },
1112
+ "node_modules/mongoose": {
1113
+ "version": "7.8.7",
1114
+ "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-7.8.7.tgz",
1115
+ "integrity": "sha512-5Bo4CrUxrPITrhMKsqUTOkXXo2CoRC5tXxVQhnddCzqDMwRXfyStrxj1oY865g8gaekSBhxAeNkYyUSJvGm9Hw==",
1116
+ "license": "MIT",
1117
+ "dependencies": {
1118
+ "bson": "^5.5.0",
1119
+ "kareem": "2.5.1",
1120
+ "mongodb": "5.9.2",
1121
+ "mpath": "0.9.0",
1122
+ "mquery": "5.0.0",
1123
+ "ms": "2.1.3",
1124
+ "sift": "16.0.1"
1125
+ },
1126
+ "engines": {
1127
+ "node": ">=14.20.1"
1128
+ },
1129
+ "funding": {
1130
+ "type": "opencollective",
1131
+ "url": "https://opencollective.com/mongoose"
1132
+ }
1133
+ },
1134
+ "node_modules/mongoose/node_modules/ms": {
1135
+ "version": "2.1.3",
1136
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
1137
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
1138
+ "license": "MIT"
1139
+ },
1140
+ "node_modules/mpath": {
1141
+ "version": "0.9.0",
1142
+ "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.9.0.tgz",
1143
+ "integrity": "sha512-ikJRQTk8hw5DEoFVxHG1Gn9T/xcjtdnOKIU1JTmGjZZlg9LST2mBLmcX3/ICIbgJydT2GOc15RnNy5mHmzfSew==",
1144
+ "license": "MIT",
1145
+ "engines": {
1146
+ "node": ">=4.0.0"
1147
+ }
1148
+ },
1149
+ "node_modules/mquery": {
1150
+ "version": "5.0.0",
1151
+ "resolved": "https://registry.npmjs.org/mquery/-/mquery-5.0.0.tgz",
1152
+ "integrity": "sha512-iQMncpmEK8R8ncT8HJGsGc9Dsp8xcgYMVSbs5jgnm1lFHTZqMJTUWTDx1LBO8+mK3tPNZWFLBghQEIOULSTHZg==",
1153
+ "license": "MIT",
1154
+ "dependencies": {
1155
+ "debug": "4.x"
1156
+ },
1157
+ "engines": {
1158
+ "node": ">=14.0.0"
1159
+ }
1160
+ },
1161
+ "node_modules/mquery/node_modules/debug": {
1162
+ "version": "4.4.3",
1163
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
1164
+ "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
1165
+ "license": "MIT",
1166
+ "dependencies": {
1167
+ "ms": "^2.1.3"
1168
+ },
1169
+ "engines": {
1170
+ "node": ">=6.0"
1171
+ },
1172
+ "peerDependenciesMeta": {
1173
+ "supports-color": {
1174
+ "optional": true
1175
+ }
1176
+ }
1177
+ },
1178
+ "node_modules/mquery/node_modules/ms": {
1179
+ "version": "2.1.3",
1180
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
1181
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
1182
+ "license": "MIT"
1183
+ },
1184
+ "node_modules/ms": {
1185
+ "version": "2.0.0",
1186
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
1187
+ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
1188
+ "license": "MIT"
1189
+ },
1190
+ "node_modules/multer": {
1191
+ "version": "2.0.2",
1192
+ "resolved": "https://registry.npmjs.org/multer/-/multer-2.0.2.tgz",
1193
+ "integrity": "sha512-u7f2xaZ/UG8oLXHvtF/oWTRvT44p9ecwBBqTwgJVq0+4BW1g8OW01TyMEGWBHbyMOYVHXslaut7qEQ1meATXgw==",
1194
+ "license": "MIT",
1195
+ "dependencies": {
1196
+ "append-field": "^1.0.0",
1197
+ "busboy": "^1.6.0",
1198
+ "concat-stream": "^2.0.0",
1199
+ "mkdirp": "^0.5.6",
1200
+ "object-assign": "^4.1.1",
1201
+ "type-is": "^1.6.18",
1202
+ "xtend": "^4.0.2"
1203
+ },
1204
+ "engines": {
1205
+ "node": ">= 10.16.0"
1206
+ }
1207
+ },
1208
+ "node_modules/negotiator": {
1209
+ "version": "0.6.3",
1210
+ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
1211
+ "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
1212
+ "license": "MIT",
1213
+ "engines": {
1214
+ "node": ">= 0.6"
1215
+ }
1216
+ },
1217
+ "node_modules/nodemon": {
1218
+ "version": "3.0.1",
1219
+ "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-3.0.1.tgz",
1220
+ "integrity": "sha512-g9AZ7HmkhQkqXkRc20w+ZfQ73cHLbE8hnPbtaFbFtCumZsjyMhKk9LajQ07U5Ux28lvFjZ5X7HvWR1xzU8jHVw==",
1221
+ "dev": true,
1222
+ "license": "MIT",
1223
+ "dependencies": {
1224
+ "chokidar": "^3.5.2",
1225
+ "debug": "^3.2.7",
1226
+ "ignore-by-default": "^1.0.1",
1227
+ "minimatch": "^3.1.2",
1228
+ "pstree.remy": "^1.1.8",
1229
+ "semver": "^7.5.3",
1230
+ "simple-update-notifier": "^2.0.0",
1231
+ "supports-color": "^5.5.0",
1232
+ "touch": "^3.1.0",
1233
+ "undefsafe": "^2.0.5"
1234
+ },
1235
+ "bin": {
1236
+ "nodemon": "bin/nodemon.js"
1237
+ },
1238
+ "engines": {
1239
+ "node": ">=10"
1240
+ },
1241
+ "funding": {
1242
+ "type": "opencollective",
1243
+ "url": "https://opencollective.com/nodemon"
1244
+ }
1245
+ },
1246
+ "node_modules/nodemon/node_modules/debug": {
1247
+ "version": "3.2.7",
1248
+ "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz",
1249
+ "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==",
1250
+ "dev": true,
1251
+ "license": "MIT",
1252
+ "dependencies": {
1253
+ "ms": "^2.1.1"
1254
+ }
1255
+ },
1256
+ "node_modules/nodemon/node_modules/ms": {
1257
+ "version": "2.1.3",
1258
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
1259
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
1260
+ "dev": true,
1261
+ "license": "MIT"
1262
+ },
1263
+ "node_modules/normalize-path": {
1264
+ "version": "3.0.0",
1265
+ "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
1266
+ "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
1267
+ "dev": true,
1268
+ "license": "MIT",
1269
+ "engines": {
1270
+ "node": ">=0.10.0"
1271
+ }
1272
+ },
1273
+ "node_modules/object-assign": {
1274
+ "version": "4.1.1",
1275
+ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
1276
+ "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
1277
+ "license": "MIT",
1278
+ "engines": {
1279
+ "node": ">=0.10.0"
1280
+ }
1281
+ },
1282
+ "node_modules/object-inspect": {
1283
+ "version": "1.13.4",
1284
+ "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
1285
+ "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
1286
+ "license": "MIT",
1287
+ "engines": {
1288
+ "node": ">= 0.4"
1289
+ },
1290
+ "funding": {
1291
+ "url": "https://github.com/sponsors/ljharb"
1292
+ }
1293
+ },
1294
+ "node_modules/on-finished": {
1295
+ "version": "2.4.1",
1296
+ "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
1297
+ "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
1298
+ "license": "MIT",
1299
+ "dependencies": {
1300
+ "ee-first": "1.1.1"
1301
+ },
1302
+ "engines": {
1303
+ "node": ">= 0.8"
1304
+ }
1305
+ },
1306
+ "node_modules/parseurl": {
1307
+ "version": "1.3.3",
1308
+ "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
1309
+ "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
1310
+ "license": "MIT",
1311
+ "engines": {
1312
+ "node": ">= 0.8"
1313
+ }
1314
+ },
1315
+ "node_modules/path-to-regexp": {
1316
+ "version": "0.1.12",
1317
+ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz",
1318
+ "integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==",
1319
+ "license": "MIT"
1320
+ },
1321
+ "node_modules/picomatch": {
1322
+ "version": "2.3.1",
1323
+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
1324
+ "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
1325
+ "dev": true,
1326
+ "license": "MIT",
1327
+ "engines": {
1328
+ "node": ">=8.6"
1329
+ },
1330
+ "funding": {
1331
+ "url": "https://github.com/sponsors/jonschlinkert"
1332
+ }
1333
+ },
1334
+ "node_modules/proxy-addr": {
1335
+ "version": "2.0.7",
1336
+ "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
1337
+ "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
1338
+ "license": "MIT",
1339
+ "dependencies": {
1340
+ "forwarded": "0.2.0",
1341
+ "ipaddr.js": "1.9.1"
1342
+ },
1343
+ "engines": {
1344
+ "node": ">= 0.10"
1345
+ }
1346
+ },
1347
+ "node_modules/pstree.remy": {
1348
+ "version": "1.1.8",
1349
+ "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz",
1350
+ "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==",
1351
+ "dev": true,
1352
+ "license": "MIT"
1353
+ },
1354
+ "node_modules/punycode": {
1355
+ "version": "2.3.1",
1356
+ "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
1357
+ "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
1358
+ "license": "MIT",
1359
+ "engines": {
1360
+ "node": ">=6"
1361
+ }
1362
+ },
1363
+ "node_modules/qs": {
1364
+ "version": "6.13.0",
1365
+ "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz",
1366
+ "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==",
1367
+ "license": "BSD-3-Clause",
1368
+ "dependencies": {
1369
+ "side-channel": "^1.0.6"
1370
+ },
1371
+ "engines": {
1372
+ "node": ">=0.6"
1373
+ },
1374
+ "funding": {
1375
+ "url": "https://github.com/sponsors/ljharb"
1376
+ }
1377
+ },
1378
+ "node_modules/range-parser": {
1379
+ "version": "1.2.1",
1380
+ "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
1381
+ "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
1382
+ "license": "MIT",
1383
+ "engines": {
1384
+ "node": ">= 0.6"
1385
+ }
1386
+ },
1387
+ "node_modules/raw-body": {
1388
+ "version": "2.5.2",
1389
+ "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz",
1390
+ "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==",
1391
+ "license": "MIT",
1392
+ "dependencies": {
1393
+ "bytes": "3.1.2",
1394
+ "http-errors": "2.0.0",
1395
+ "iconv-lite": "0.4.24",
1396
+ "unpipe": "1.0.0"
1397
+ },
1398
+ "engines": {
1399
+ "node": ">= 0.8"
1400
+ }
1401
+ },
1402
+ "node_modules/readable-stream": {
1403
+ "version": "3.6.2",
1404
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz",
1405
+ "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==",
1406
+ "license": "MIT",
1407
+ "dependencies": {
1408
+ "inherits": "^2.0.3",
1409
+ "string_decoder": "^1.1.1",
1410
+ "util-deprecate": "^1.0.1"
1411
+ },
1412
+ "engines": {
1413
+ "node": ">= 6"
1414
+ }
1415
+ },
1416
+ "node_modules/readdirp": {
1417
+ "version": "3.6.0",
1418
+ "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz",
1419
+ "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==",
1420
+ "dev": true,
1421
+ "license": "MIT",
1422
+ "dependencies": {
1423
+ "picomatch": "^2.2.1"
1424
+ },
1425
+ "engines": {
1426
+ "node": ">=8.10.0"
1427
+ }
1428
+ },
1429
+ "node_modules/safe-buffer": {
1430
+ "version": "5.2.1",
1431
+ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
1432
+ "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
1433
+ "funding": [
1434
+ {
1435
+ "type": "github",
1436
+ "url": "https://github.com/sponsors/feross"
1437
+ },
1438
+ {
1439
+ "type": "patreon",
1440
+ "url": "https://www.patreon.com/feross"
1441
+ },
1442
+ {
1443
+ "type": "consulting",
1444
+ "url": "https://feross.org/support"
1445
+ }
1446
+ ],
1447
+ "license": "MIT"
1448
+ },
1449
+ "node_modules/safer-buffer": {
1450
+ "version": "2.1.2",
1451
+ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
1452
+ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
1453
+ "license": "MIT"
1454
+ },
1455
+ "node_modules/semver": {
1456
+ "version": "7.7.3",
1457
+ "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.3.tgz",
1458
+ "integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==",
1459
+ "license": "ISC",
1460
+ "bin": {
1461
+ "semver": "bin/semver.js"
1462
+ },
1463
+ "engines": {
1464
+ "node": ">=10"
1465
+ }
1466
+ },
1467
+ "node_modules/send": {
1468
+ "version": "0.19.0",
1469
+ "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz",
1470
+ "integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==",
1471
+ "license": "MIT",
1472
+ "dependencies": {
1473
+ "debug": "2.6.9",
1474
+ "depd": "2.0.0",
1475
+ "destroy": "1.2.0",
1476
+ "encodeurl": "~1.0.2",
1477
+ "escape-html": "~1.0.3",
1478
+ "etag": "~1.8.1",
1479
+ "fresh": "0.5.2",
1480
+ "http-errors": "2.0.0",
1481
+ "mime": "1.6.0",
1482
+ "ms": "2.1.3",
1483
+ "on-finished": "2.4.1",
1484
+ "range-parser": "~1.2.1",
1485
+ "statuses": "2.0.1"
1486
+ },
1487
+ "engines": {
1488
+ "node": ">= 0.8.0"
1489
+ }
1490
+ },
1491
+ "node_modules/send/node_modules/encodeurl": {
1492
+ "version": "1.0.2",
1493
+ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
1494
+ "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==",
1495
+ "license": "MIT",
1496
+ "engines": {
1497
+ "node": ">= 0.8"
1498
+ }
1499
+ },
1500
+ "node_modules/send/node_modules/ms": {
1501
+ "version": "2.1.3",
1502
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
1503
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
1504
+ "license": "MIT"
1505
+ },
1506
+ "node_modules/serve-static": {
1507
+ "version": "1.16.2",
1508
+ "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz",
1509
+ "integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==",
1510
+ "license": "MIT",
1511
+ "dependencies": {
1512
+ "encodeurl": "~2.0.0",
1513
+ "escape-html": "~1.0.3",
1514
+ "parseurl": "~1.3.3",
1515
+ "send": "0.19.0"
1516
+ },
1517
+ "engines": {
1518
+ "node": ">= 0.8.0"
1519
+ }
1520
+ },
1521
+ "node_modules/setprototypeof": {
1522
+ "version": "1.2.0",
1523
+ "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
1524
+ "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
1525
+ "license": "ISC"
1526
+ },
1527
+ "node_modules/side-channel": {
1528
+ "version": "1.1.0",
1529
+ "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz",
1530
+ "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==",
1531
+ "license": "MIT",
1532
+ "dependencies": {
1533
+ "es-errors": "^1.3.0",
1534
+ "object-inspect": "^1.13.3",
1535
+ "side-channel-list": "^1.0.0",
1536
+ "side-channel-map": "^1.0.1",
1537
+ "side-channel-weakmap": "^1.0.2"
1538
+ },
1539
+ "engines": {
1540
+ "node": ">= 0.4"
1541
+ },
1542
+ "funding": {
1543
+ "url": "https://github.com/sponsors/ljharb"
1544
+ }
1545
+ },
1546
+ "node_modules/side-channel-list": {
1547
+ "version": "1.0.0",
1548
+ "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz",
1549
+ "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==",
1550
+ "license": "MIT",
1551
+ "dependencies": {
1552
+ "es-errors": "^1.3.0",
1553
+ "object-inspect": "^1.13.3"
1554
+ },
1555
+ "engines": {
1556
+ "node": ">= 0.4"
1557
+ },
1558
+ "funding": {
1559
+ "url": "https://github.com/sponsors/ljharb"
1560
+ }
1561
+ },
1562
+ "node_modules/side-channel-map": {
1563
+ "version": "1.0.1",
1564
+ "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
1565
+ "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
1566
+ "license": "MIT",
1567
+ "dependencies": {
1568
+ "call-bound": "^1.0.2",
1569
+ "es-errors": "^1.3.0",
1570
+ "get-intrinsic": "^1.2.5",
1571
+ "object-inspect": "^1.13.3"
1572
+ },
1573
+ "engines": {
1574
+ "node": ">= 0.4"
1575
+ },
1576
+ "funding": {
1577
+ "url": "https://github.com/sponsors/ljharb"
1578
+ }
1579
+ },
1580
+ "node_modules/side-channel-weakmap": {
1581
+ "version": "1.0.2",
1582
+ "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
1583
+ "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
1584
+ "license": "MIT",
1585
+ "dependencies": {
1586
+ "call-bound": "^1.0.2",
1587
+ "es-errors": "^1.3.0",
1588
+ "get-intrinsic": "^1.2.5",
1589
+ "object-inspect": "^1.13.3",
1590
+ "side-channel-map": "^1.0.1"
1591
+ },
1592
+ "engines": {
1593
+ "node": ">= 0.4"
1594
+ },
1595
+ "funding": {
1596
+ "url": "https://github.com/sponsors/ljharb"
1597
+ }
1598
+ },
1599
+ "node_modules/sift": {
1600
+ "version": "16.0.1",
1601
+ "resolved": "https://registry.npmjs.org/sift/-/sift-16.0.1.tgz",
1602
+ "integrity": "sha512-Wv6BjQ5zbhW7VFefWusVP33T/EM0vYikCaQ2qR8yULbsilAT8/wQaXvuQ3ptGLpoKx+lihJE3y2UTgKDyyNHZQ==",
1603
+ "license": "MIT"
1604
+ },
1605
+ "node_modules/simple-update-notifier": {
1606
+ "version": "2.0.0",
1607
+ "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-2.0.0.tgz",
1608
+ "integrity": "sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==",
1609
+ "dev": true,
1610
+ "license": "MIT",
1611
+ "dependencies": {
1612
+ "semver": "^7.5.3"
1613
+ },
1614
+ "engines": {
1615
+ "node": ">=10"
1616
+ }
1617
+ },
1618
+ "node_modules/smart-buffer": {
1619
+ "version": "4.2.0",
1620
+ "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz",
1621
+ "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==",
1622
+ "license": "MIT",
1623
+ "engines": {
1624
+ "node": ">= 6.0.0",
1625
+ "npm": ">= 3.0.0"
1626
+ }
1627
+ },
1628
+ "node_modules/socket.io": {
1629
+ "version": "4.8.1",
1630
+ "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.8.1.tgz",
1631
+ "integrity": "sha512-oZ7iUCxph8WYRHHcjBEc9unw3adt5CmSNlppj/5Q4k2RIrhl8Z5yY2Xr4j9zj0+wzVZ0bxmYoGSzKJnRl6A4yg==",
1632
+ "license": "MIT",
1633
+ "dependencies": {
1634
+ "accepts": "~1.3.4",
1635
+ "base64id": "~2.0.0",
1636
+ "cors": "~2.8.5",
1637
+ "debug": "~4.3.2",
1638
+ "engine.io": "~6.6.0",
1639
+ "socket.io-adapter": "~2.5.2",
1640
+ "socket.io-parser": "~4.2.4"
1641
+ },
1642
+ "engines": {
1643
+ "node": ">=10.2.0"
1644
+ }
1645
+ },
1646
+ "node_modules/socket.io-adapter": {
1647
+ "version": "2.5.5",
1648
+ "resolved": "https://registry.npmjs.org/socket.io-adapter/-/socket.io-adapter-2.5.5.tgz",
1649
+ "integrity": "sha512-eLDQas5dzPgOWCk9GuuJC2lBqItuhKI4uxGgo9aIV7MYbk2h9Q6uULEh8WBzThoI7l+qU9Ast9fVUmkqPP9wYg==",
1650
+ "license": "MIT",
1651
+ "dependencies": {
1652
+ "debug": "~4.3.4",
1653
+ "ws": "~8.17.1"
1654
+ }
1655
+ },
1656
+ "node_modules/socket.io-adapter/node_modules/debug": {
1657
+ "version": "4.3.7",
1658
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
1659
+ "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
1660
+ "license": "MIT",
1661
+ "dependencies": {
1662
+ "ms": "^2.1.3"
1663
+ },
1664
+ "engines": {
1665
+ "node": ">=6.0"
1666
+ },
1667
+ "peerDependenciesMeta": {
1668
+ "supports-color": {
1669
+ "optional": true
1670
+ }
1671
+ }
1672
+ },
1673
+ "node_modules/socket.io-adapter/node_modules/ms": {
1674
+ "version": "2.1.3",
1675
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
1676
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
1677
+ "license": "MIT"
1678
+ },
1679
+ "node_modules/socket.io-parser": {
1680
+ "version": "4.2.4",
1681
+ "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.4.tgz",
1682
+ "integrity": "sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew==",
1683
+ "license": "MIT",
1684
+ "dependencies": {
1685
+ "@socket.io/component-emitter": "~3.1.0",
1686
+ "debug": "~4.3.1"
1687
+ },
1688
+ "engines": {
1689
+ "node": ">=10.0.0"
1690
+ }
1691
+ },
1692
+ "node_modules/socket.io-parser/node_modules/debug": {
1693
+ "version": "4.3.7",
1694
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
1695
+ "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
1696
+ "license": "MIT",
1697
+ "dependencies": {
1698
+ "ms": "^2.1.3"
1699
+ },
1700
+ "engines": {
1701
+ "node": ">=6.0"
1702
+ },
1703
+ "peerDependenciesMeta": {
1704
+ "supports-color": {
1705
+ "optional": true
1706
+ }
1707
+ }
1708
+ },
1709
+ "node_modules/socket.io-parser/node_modules/ms": {
1710
+ "version": "2.1.3",
1711
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
1712
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
1713
+ "license": "MIT"
1714
+ },
1715
+ "node_modules/socket.io/node_modules/debug": {
1716
+ "version": "4.3.7",
1717
+ "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz",
1718
+ "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==",
1719
+ "license": "MIT",
1720
+ "dependencies": {
1721
+ "ms": "^2.1.3"
1722
+ },
1723
+ "engines": {
1724
+ "node": ">=6.0"
1725
+ },
1726
+ "peerDependenciesMeta": {
1727
+ "supports-color": {
1728
+ "optional": true
1729
+ }
1730
+ }
1731
+ },
1732
+ "node_modules/socket.io/node_modules/ms": {
1733
+ "version": "2.1.3",
1734
+ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
1735
+ "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
1736
+ "license": "MIT"
1737
+ },
1738
+ "node_modules/socks": {
1739
+ "version": "2.8.7",
1740
+ "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.7.tgz",
1741
+ "integrity": "sha512-HLpt+uLy/pxB+bum/9DzAgiKS8CX1EvbWxI4zlmgGCExImLdiad2iCwXT5Z4c9c3Eq8rP2318mPW2c+QbtjK8A==",
1742
+ "license": "MIT",
1743
+ "dependencies": {
1744
+ "ip-address": "^10.0.1",
1745
+ "smart-buffer": "^4.2.0"
1746
+ },
1747
+ "engines": {
1748
+ "node": ">= 10.0.0",
1749
+ "npm": ">= 3.0.0"
1750
+ }
1751
+ },
1752
+ "node_modules/sparse-bitfield": {
1753
+ "version": "3.0.3",
1754
+ "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz",
1755
+ "integrity": "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ==",
1756
+ "license": "MIT",
1757
+ "optional": true,
1758
+ "dependencies": {
1759
+ "memory-pager": "^1.0.2"
1760
+ }
1761
+ },
1762
+ "node_modules/statuses": {
1763
+ "version": "2.0.1",
1764
+ "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz",
1765
+ "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==",
1766
+ "license": "MIT",
1767
+ "engines": {
1768
+ "node": ">= 0.8"
1769
+ }
1770
+ },
1771
+ "node_modules/streamsearch": {
1772
+ "version": "1.1.0",
1773
+ "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz",
1774
+ "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==",
1775
+ "engines": {
1776
+ "node": ">=10.0.0"
1777
+ }
1778
+ },
1779
+ "node_modules/string_decoder": {
1780
+ "version": "1.3.0",
1781
+ "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz",
1782
+ "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==",
1783
+ "license": "MIT",
1784
+ "dependencies": {
1785
+ "safe-buffer": "~5.2.0"
1786
+ }
1787
+ },
1788
+ "node_modules/supports-color": {
1789
+ "version": "5.5.0",
1790
+ "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
1791
+ "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
1792
+ "dev": true,
1793
+ "license": "MIT",
1794
+ "dependencies": {
1795
+ "has-flag": "^3.0.0"
1796
+ },
1797
+ "engines": {
1798
+ "node": ">=4"
1799
+ }
1800
+ },
1801
+ "node_modules/to-regex-range": {
1802
+ "version": "5.0.1",
1803
+ "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
1804
+ "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
1805
+ "dev": true,
1806
+ "license": "MIT",
1807
+ "dependencies": {
1808
+ "is-number": "^7.0.0"
1809
+ },
1810
+ "engines": {
1811
+ "node": ">=8.0"
1812
+ }
1813
+ },
1814
+ "node_modules/toidentifier": {
1815
+ "version": "1.0.1",
1816
+ "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
1817
+ "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
1818
+ "license": "MIT",
1819
+ "engines": {
1820
+ "node": ">=0.6"
1821
+ }
1822
+ },
1823
+ "node_modules/touch": {
1824
+ "version": "3.1.1",
1825
+ "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz",
1826
+ "integrity": "sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==",
1827
+ "dev": true,
1828
+ "license": "ISC",
1829
+ "bin": {
1830
+ "nodetouch": "bin/nodetouch.js"
1831
+ }
1832
+ },
1833
+ "node_modules/tr46": {
1834
+ "version": "3.0.0",
1835
+ "resolved": "https://registry.npmjs.org/tr46/-/tr46-3.0.0.tgz",
1836
+ "integrity": "sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==",
1837
+ "license": "MIT",
1838
+ "dependencies": {
1839
+ "punycode": "^2.1.1"
1840
+ },
1841
+ "engines": {
1842
+ "node": ">=12"
1843
+ }
1844
+ },
1845
+ "node_modules/type-is": {
1846
+ "version": "1.6.18",
1847
+ "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
1848
+ "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
1849
+ "license": "MIT",
1850
+ "dependencies": {
1851
+ "media-typer": "0.3.0",
1852
+ "mime-types": "~2.1.24"
1853
+ },
1854
+ "engines": {
1855
+ "node": ">= 0.6"
1856
+ }
1857
+ },
1858
+ "node_modules/typedarray": {
1859
+ "version": "0.0.6",
1860
+ "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz",
1861
+ "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==",
1862
+ "license": "MIT"
1863
+ },
1864
+ "node_modules/undefsafe": {
1865
+ "version": "2.0.5",
1866
+ "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz",
1867
+ "integrity": "sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==",
1868
+ "dev": true,
1869
+ "license": "MIT"
1870
+ },
1871
+ "node_modules/undici-types": {
1872
+ "version": "7.16.0",
1873
+ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz",
1874
+ "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==",
1875
+ "license": "MIT"
1876
+ },
1877
+ "node_modules/unpipe": {
1878
+ "version": "1.0.0",
1879
+ "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
1880
+ "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
1881
+ "license": "MIT",
1882
+ "engines": {
1883
+ "node": ">= 0.8"
1884
+ }
1885
+ },
1886
+ "node_modules/util-deprecate": {
1887
+ "version": "1.0.2",
1888
+ "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
1889
+ "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==",
1890
+ "license": "MIT"
1891
+ },
1892
+ "node_modules/utils-merge": {
1893
+ "version": "1.0.1",
1894
+ "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
1895
+ "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
1896
+ "license": "MIT",
1897
+ "engines": {
1898
+ "node": ">= 0.4.0"
1899
+ }
1900
+ },
1901
+ "node_modules/uuid": {
1902
+ "version": "9.0.0",
1903
+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.0.tgz",
1904
+ "integrity": "sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==",
1905
+ "license": "MIT",
1906
+ "bin": {
1907
+ "uuid": "dist/bin/uuid"
1908
+ }
1909
+ },
1910
+ "node_modules/validator": {
1911
+ "version": "13.15.23",
1912
+ "resolved": "https://registry.npmjs.org/validator/-/validator-13.15.23.tgz",
1913
+ "integrity": "sha512-4yoz1kEWqUjzi5zsPbAS/903QXSYp0UOtHsPpp7p9rHAw/W+dkInskAE386Fat3oKRROwO98d9ZB0G4cObgUyw==",
1914
+ "license": "MIT",
1915
+ "engines": {
1916
+ "node": ">= 0.10"
1917
+ }
1918
+ },
1919
+ "node_modules/vary": {
1920
+ "version": "1.1.2",
1921
+ "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
1922
+ "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
1923
+ "license": "MIT",
1924
+ "engines": {
1925
+ "node": ">= 0.8"
1926
+ }
1927
+ },
1928
+ "node_modules/webidl-conversions": {
1929
+ "version": "7.0.0",
1930
+ "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz",
1931
+ "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==",
1932
+ "license": "BSD-2-Clause",
1933
+ "engines": {
1934
+ "node": ">=12"
1935
+ }
1936
+ },
1937
+ "node_modules/whatwg-url": {
1938
+ "version": "11.0.0",
1939
+ "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-11.0.0.tgz",
1940
+ "integrity": "sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ==",
1941
+ "license": "MIT",
1942
+ "dependencies": {
1943
+ "tr46": "^3.0.0",
1944
+ "webidl-conversions": "^7.0.0"
1945
+ },
1946
+ "engines": {
1947
+ "node": ">=12"
1948
+ }
1949
+ },
1950
+ "node_modules/ws": {
1951
+ "version": "8.17.1",
1952
+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz",
1953
+ "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==",
1954
+ "license": "MIT",
1955
+ "engines": {
1956
+ "node": ">=10.0.0"
1957
+ },
1958
+ "peerDependencies": {
1959
+ "bufferutil": "^4.0.1",
1960
+ "utf-8-validate": ">=5.0.2"
1961
+ },
1962
+ "peerDependenciesMeta": {
1963
+ "bufferutil": {
1964
+ "optional": true
1965
+ },
1966
+ "utf-8-validate": {
1967
+ "optional": true
1968
+ }
1969
+ }
1970
+ },
1971
+ "node_modules/xtend": {
1972
+ "version": "4.0.2",
1973
+ "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz",
1974
+ "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==",
1975
+ "license": "MIT",
1976
+ "engines": {
1977
+ "node": ">=0.4"
1978
+ }
1979
+ }
1980
+ }
1981
+ }
ysnrfd_messenger/BACKUP/backend/package.json ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "ysnrfd-messenger-backend",
3
+ "version": "1.0.0",
4
+ "description": "Real-time messaging backend for YSNRFD Messenger",
5
+ "main": "server.js",
6
+ "type": "commonjs",
7
+ "scripts": {
8
+ "start": "node server.js",
9
+ "dev": "nodemon server.js",
10
+ "test": "jest"
11
+ },
12
+ "dependencies": {
13
+ "bcryptjs": "2.4.3",
14
+ "cors": "2.8.5",
15
+ "dotenv": "16.3.1",
16
+ "express": "^4.21.2",
17
+ "express-rate-limit": "6.8.1",
18
+ "helmet": "7.0.0",
19
+ "jsonwebtoken": "9.0.1",
20
+ "mongoose": "^7.8.7",
21
+ "multer": "2.0.2",
22
+ "socket.io": "^4.8.1",
23
+ "uuid": "9.0.0",
24
+ "validator": "^13.15.23"
25
+ },
26
+ "devDependencies": {
27
+ "nodemon": "3.0.1"
28
+ },
29
+ "keywords": [
30
+ "messenger",
31
+ "real-time",
32
+ "websocket",
33
+ "chat"
34
+ ],
35
+ "author": "YSNRFD Team",
36
+ "license": "MIT"
37
+ }
ysnrfd_messenger/BACKUP/backend/server.js ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const express = require('express');
2
+ const http = require('http');
3
+ const socketIo = require('socket.io');
4
+ const mongoose = require('mongoose');
5
+ const cors = require('cors');
6
+ const bcrypt = require('bcryptjs');
7
+ const jwt = require('jsonwebtoken');
8
+ const path = require('path');
9
+ require('dotenv').config();
10
+
11
+ const app = express();
12
+ const server = http.createServer(app);
13
+
14
+ // Fix CORS configuration
15
+ const io = socketIo(server, {
16
+ cors: {
17
+ origin: "http://localhost:3000",
18
+ methods: ["GET", "POST", "PUT", "DELETE"],
19
+ credentials: false
20
+ }
21
+ });
22
+
23
+ // CORS middleware - fix this part
24
+ app.use(cors({
25
+ origin: "http://localhost:3000",
26
+ credentials: false,
27
+ methods: ["GET", "POST", "PUT", "DELETE"],
28
+ allowedHeaders: ["Content-Type", "Authorization"]
29
+ }));
30
+
31
+ app.use(express.json());
32
+ app.use('/uploads', express.static(path.join(__dirname, 'uploads')));
33
+
34
+ // Simple User Model (in-memory for now)
35
+ const users = [];
36
+
37
+ // Auth Routes
38
+ app.post('/api/auth/register', async (req, res) => {
39
+ try {
40
+ const { username, email, password, displayName } = req.body;
41
+
42
+ console.log('Registration attempt:', { username, email, displayName });
43
+
44
+ // Validation
45
+ if (!username || !email || !password || !displayName) {
46
+ return res.status(400).json({ error: 'All fields are required' });
47
+ }
48
+
49
+ // Check if user exists
50
+ const existingUser = users.find(u => u.email === email || u.username === username);
51
+ if (existingUser) {
52
+ return res.status(400).json({ error: 'User already exists' });
53
+ }
54
+
55
+ // Hash password
56
+ const hashedPassword = await bcrypt.hash(password, 12);
57
+
58
+ // Create user
59
+ const user = {
60
+ id: Date.now().toString(),
61
+ username,
62
+ email,
63
+ displayName,
64
+ password: hashedPassword,
65
+ avatar: null,
66
+ status: 'online',
67
+ lastSeen: new Date(),
68
+ createdAt: new Date()
69
+ };
70
+
71
+ users.push(user);
72
+
73
+ // Generate token
74
+ const token = jwt.sign({ userId: user.id }, process.env.JWT_SECRET || 'fallback-secret', { expiresIn: '30d' });
75
+
76
+ // Remove password from response
77
+ const { password: _, ...userWithoutPassword } = user;
78
+
79
+ console.log('User registered successfully:', userWithoutPassword.username);
80
+
81
+ res.status(201).json({
82
+ message: 'User registered successfully',
83
+ user: userWithoutPassword,
84
+ token
85
+ });
86
+
87
+ } catch (error) {
88
+ console.error('Registration error:', error);
89
+ res.status(500).json({ error: 'Server error during registration' });
90
+ }
91
+ });
92
+
93
+ app.post('/api/auth/login', async (req, res) => {
94
+ try {
95
+ const { email, password } = req.body;
96
+
97
+ console.log('Login attempt:', { email });
98
+
99
+ if (!email || !password) {
100
+ return res.status(400).json({ error: 'Email and password are required' });
101
+ }
102
+
103
+ // Find user
104
+ const user = users.find(u => u.email === email);
105
+ if (!user) {
106
+ return res.status(401).json({ error: 'Invalid credentials' });
107
+ }
108
+
109
+ // Check password
110
+ const isPasswordValid = await bcrypt.compare(password, user.password);
111
+ if (!isPasswordValid) {
112
+ return res.status(401).json({ error: 'Invalid credentials' });
113
+ }
114
+
115
+ // Update user status
116
+ user.status = 'online';
117
+ user.lastSeen = new Date();
118
+
119
+ // Generate token
120
+ const token = jwt.sign({ userId: user.id }, process.env.JWT_SECRET || 'fallback-secret', { expiresIn: '30d' });
121
+
122
+ // Remove password from response
123
+ const { password: _, ...userWithoutPassword } = user;
124
+
125
+ console.log('User logged in:', userWithoutPassword.username);
126
+
127
+ res.json({
128
+ message: 'Login successful',
129
+ user: userWithoutPassword,
130
+ token
131
+ });
132
+
133
+ } catch (error) {
134
+ console.error('Login error:', error);
135
+ res.status(500).json({ error: 'Server error during login' });
136
+ }
137
+ });
138
+
139
+ app.get('/api/auth/me', (req, res) => {
140
+ const token = req.headers.authorization?.split(' ')[1];
141
+
142
+ if (!token) {
143
+ return res.status(401).json({ error: 'No token provided' });
144
+ }
145
+
146
+ try {
147
+ const decoded = jwt.verify(token, process.env.JWT_SECRET || 'fallback-secret');
148
+ const user = users.find(u => u.id === decoded.userId);
149
+
150
+ if (!user) {
151
+ return res.status(404).json({ error: 'User not found' });
152
+ }
153
+
154
+ const { password: _, ...userWithoutPassword } = user;
155
+ res.json({ user: userWithoutPassword });
156
+
157
+ } catch (error) {
158
+ res.status(401).json({ error: 'Invalid token' });
159
+ }
160
+ });
161
+
162
+ // Health check
163
+ app.get('/api/health', (req, res) => {
164
+ res.json({
165
+ status: 'OK',
166
+ message: 'YSNRFD Messenger Backend is running!',
167
+ usersCount: users.length,
168
+ timestamp: new Date().toISOString()
169
+ });
170
+ });
171
+
172
+ // Test route to verify CORS is working
173
+ app.get('/api/test-cors', (req, res) => {
174
+ res.json({
175
+ message: 'CORS is working!',
176
+ corsConfig: {
177
+ origin: 'http://localhost:3000',
178
+ credentials: false
179
+ }
180
+ });
181
+ });
182
+
183
+ // Socket.io connection
184
+ io.on('connection', (socket) => {
185
+ console.log('User connected:', socket.id);
186
+
187
+ socket.on('disconnect', () => {
188
+ console.log('User disconnected:', socket.id);
189
+ });
190
+ });
191
+
192
+ const PORT = process.env.PORT || 5000;
193
+ server.listen(PORT, () => {
194
+ console.log(`🚀 YSNRFD Messenger backend running on port ${PORT}`);
195
+ console.log(`🔧 Environment: ${process.env.NODE_ENV || 'development'}`);
196
+ console.log(`🌍 Frontend URL: http://localhost:3000`);
197
+ console.log(`🔍 Health check: http://localhost:${PORT}/api/health`);
198
+ console.log(`🔍 CORS test: http://localhost:${PORT}/api/test-cors`);
199
+ console.log(`👥 Registered users: ${users.length}`);
200
+ });
ysnrfd_messenger/BACKUP/backend/src/config/database.js ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const mongoose = require('mongoose');
2
+
3
+ const connectDB = async () => {
4
+ try {
5
+ const conn = await mongoose.connect(process.env.MONGODB_URI, {
6
+ useNewUrlParser: true,
7
+ useUnifiedTopology: true,
8
+ });
9
+
10
+ console.log(`MongoDB Connected: ${conn.connection.host}`);
11
+ } catch (error) {
12
+ console.error('Database connection error:', error);
13
+ process.exit(1);
14
+ }
15
+ };
16
+
17
+ module.exports = connectDB;
ysnrfd_messenger/BACKUP/backend/src/controllers/authController.js ADDED
@@ -0,0 +1,208 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const User = require('../models/User');
2
+ const jwt = require('jsonwebtoken');
3
+ const validator = require('validator');
4
+
5
+ const generateToken = (userId) => {
6
+ return jwt.sign({ userId }, process.env.JWT_SECRET, { expiresIn: process.env.JWT_EXPIRES_IN || '30d' });
7
+ };
8
+
9
+ exports.register = async (req, res) => {
10
+ try {
11
+ const { username, email, password, displayName } = req.body;
12
+
13
+ // Validation
14
+ if (!username || !email || !password || !displayName) {
15
+ return res.status(400).json({ error: 'All fields are required' });
16
+ }
17
+
18
+ if (!validator.isEmail(email)) {
19
+ return res.status(400).json({ error: 'Invalid email format' });
20
+ }
21
+
22
+ if (password.length < 6) {
23
+ return res.status(400).json({ error: 'Password must be at least 6 characters' });
24
+ }
25
+
26
+ if (username.length < 3 || username.length > 30) {
27
+ return res.status(400).json({ error: 'Username must be between 3 and 30 characters' });
28
+ }
29
+
30
+ // Check if user exists
31
+ const existingUser = await User.findOne({
32
+ $or: [{ email }, { username }]
33
+ });
34
+
35
+ if (existingUser) {
36
+ const field = existingUser.email === email ? 'email' : 'username';
37
+ return res.status(400).json({ error: `User already exists with this ${field}` });
38
+ }
39
+
40
+ // Create user
41
+ const user = await User.create({
42
+ username,
43
+ email,
44
+ password,
45
+ displayName
46
+ });
47
+
48
+ // Generate token
49
+ const token = generateToken(user._id);
50
+
51
+ // Set cookie
52
+ res.cookie('token', token, {
53
+ httpOnly: true,
54
+ secure: process.env.NODE_ENV === 'production',
55
+ sameSite: 'strict',
56
+ maxAge: 30 * 24 * 60 * 60 * 1000 // 30 days
57
+ });
58
+
59
+ res.status(201).json({
60
+ message: 'User registered successfully',
61
+ user: {
62
+ id: user._id,
63
+ username: user.username,
64
+ email: user.email,
65
+ displayName: user.displayName,
66
+ avatar: user.avatar,
67
+ status: user.status,
68
+ bio: user.bio
69
+ },
70
+ token
71
+ });
72
+ } catch (error) {
73
+ console.error('Registration error:', error);
74
+ res.status(500).json({ error: 'Server error during registration' });
75
+ }
76
+ };
77
+
78
+ exports.login = async (req, res) => {
79
+ try {
80
+ const { email, password } = req.body;
81
+
82
+ if (!email || !password) {
83
+ return res.status(400).json({ error: 'Email and password are required' });
84
+ }
85
+
86
+ // Find user and include password for comparison
87
+ const user = await User.findOne({ email }).select('+password');
88
+
89
+ if (!user) {
90
+ return res.status(401).json({ error: 'Invalid credentials' });
91
+ }
92
+
93
+ // Check password
94
+ const isPasswordValid = await user.comparePassword(password);
95
+ if (!isPasswordValid) {
96
+ return res.status(401).json({ error: 'Invalid credentials' });
97
+ }
98
+
99
+ // Update status to online
100
+ user.status = 'online';
101
+ user.lastSeen = new Date();
102
+ await user.save();
103
+
104
+ const token = generateToken(user._id);
105
+
106
+ res.cookie('token', token, {
107
+ httpOnly: true,
108
+ secure: process.env.NODE_ENV === 'production',
109
+ sameSite: 'strict',
110
+ maxAge: 30 * 24 * 60 * 60 * 1000
111
+ });
112
+
113
+ res.json({
114
+ message: 'Login successful',
115
+ user: {
116
+ id: user._id,
117
+ username: user.username,
118
+ email: user.email,
119
+ displayName: user.displayName,
120
+ avatar: user.avatar,
121
+ status: user.status,
122
+ bio: user.bio,
123
+ lastSeen: user.lastSeen
124
+ },
125
+ token
126
+ });
127
+ } catch (error) {
128
+ console.error('Login error:', error);
129
+ res.status(500).json({ error: 'Server error during login' });
130
+ }
131
+ };
132
+
133
+ exports.logout = async (req, res) => {
134
+ try {
135
+ // Update user status to offline
136
+ if (req.user) {
137
+ await User.findByIdAndUpdate(req.user.userId, {
138
+ status: 'offline',
139
+ lastSeen: new Date()
140
+ });
141
+ }
142
+
143
+ res.clearCookie('token');
144
+ res.json({ message: 'Logged out successfully' });
145
+ } catch (error) {
146
+ console.error('Logout error:', error);
147
+ res.status(500).json({ error: 'Server error during logout' });
148
+ }
149
+ };
150
+
151
+ exports.getMe = async (req, res) => {
152
+ try {
153
+ const user = await User.findById(req.user.userId);
154
+ if (!user) {
155
+ return res.status(404).json({ error: 'User not found' });
156
+ }
157
+
158
+ res.json({
159
+ user: {
160
+ id: user._id,
161
+ username: user.username,
162
+ email: user.email,
163
+ displayName: user.displayName,
164
+ avatar: user.avatar,
165
+ status: user.status,
166
+ bio: user.bio,
167
+ lastSeen: user.lastSeen,
168
+ settings: user.settings
169
+ }
170
+ });
171
+ } catch (error) {
172
+ console.error('Get me error:', error);
173
+ res.status(500).json({ error: 'Server error' });
174
+ }
175
+ };
176
+
177
+ exports.updateProfile = async (req, res) => {
178
+ try {
179
+ const { displayName, bio, status } = req.body;
180
+ const updateData = {};
181
+
182
+ if (displayName) updateData.displayName = displayName;
183
+ if (bio !== undefined) updateData.bio = bio;
184
+ if (status) updateData.status = status;
185
+
186
+ const user = await User.findByIdAndUpdate(
187
+ req.user.userId,
188
+ updateData,
189
+ { new: true, runValidators: true }
190
+ );
191
+
192
+ res.json({
193
+ message: 'Profile updated successfully',
194
+ user: {
195
+ id: user._id,
196
+ username: user.username,
197
+ email: user.email,
198
+ displayName: user.displayName,
199
+ avatar: user.avatar,
200
+ status: user.status,
201
+ bio: user.bio
202
+ }
203
+ });
204
+ } catch (error) {
205
+ console.error('Update profile error:', error);
206
+ res.status(500).json({ error: 'Server error during profile update' });
207
+ }
208
+ };
ysnrfd_messenger/BACKUP/backend/src/controllers/conversationController.js ADDED
@@ -0,0 +1,232 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const Conversation = require('../models/Conversation');
2
+ const Message = require('../models/Message');
3
+ const User = require('../models/User');
4
+ const { generateInviteCode } = require('../utils/helpers');
5
+
6
+ exports.createConversation = async (req, res) => {
7
+ try {
8
+ const { type, name, description, participantIds } = req.body;
9
+ const userId = req.user.userId;
10
+
11
+ // Validate conversation type
12
+ if (!['direct', 'group'].includes(type)) {
13
+ return res.status(400).json({ error: 'Invalid conversation type' });
14
+ }
15
+
16
+ // For direct messages, check if conversation already exists
17
+ if (type === 'direct') {
18
+ if (!participantIds || participantIds.length !== 1) {
19
+ return res.status(400).json({ error: 'Direct message requires exactly one participant' });
20
+ }
21
+
22
+ const existingConversation = await Conversation.findOne({
23
+ type: 'direct',
24
+ participants: {
25
+ $all: [
26
+ { $elemMatch: { user: userId } },
27
+ { $elemMatch: { user: participantIds[0] } }
28
+ ]
29
+ }
30
+ }).populate('participants.user', 'username displayName avatar status');
31
+
32
+ if (existingConversation) {
33
+ return res.json({
34
+ message: 'Conversation already exists',
35
+ conversation: existingConversation
36
+ });
37
+ }
38
+ }
39
+
40
+ // Create conversation
41
+ const participants = [
42
+ { user: userId, role: 'owner' },
43
+ ...participantIds.map(pid => ({ user: pid, role: 'member' }))
44
+ ];
45
+
46
+ const conversation = new Conversation({
47
+ type,
48
+ name: type === 'direct' ? null : name,
49
+ description: type === 'direct' ? null : description,
50
+ createdBy: userId,
51
+ participants
52
+ });
53
+
54
+ await conversation.save();
55
+ await conversation.populate('participants.user', 'username displayName avatar status');
56
+
57
+ res.status(201).json({
58
+ message: 'Conversation created successfully',
59
+ conversation
60
+ });
61
+ } catch (error) {
62
+ console.error('Create conversation error:', error);
63
+ res.status(500).json({ error: 'Server error creating conversation' });
64
+ }
65
+ };
66
+
67
+ exports.getUserConversations = async (req, res) => {
68
+ try {
69
+ const userId = req.user.userId;
70
+
71
+ const conversations = await Conversation.find({
72
+ 'participants.user': userId
73
+ })
74
+ .populate('participants.user', 'username displayName avatar status')
75
+ .populate('lastMessage')
76
+ .sort({ updatedAt: -1 });
77
+
78
+ res.json({ conversations });
79
+ } catch (error) {
80
+ console.error('Get conversations error:', error);
81
+ res.status(500).json({ error: 'Server error fetching conversations' });
82
+ }
83
+ };
84
+
85
+ exports.getConversation = async (req, res) => {
86
+ try {
87
+ const { conversationId } = req.params;
88
+ const userId = req.user.userId;
89
+
90
+ const conversation = await Conversation.findOne({
91
+ _id: conversationId,
92
+ 'participants.user': userId
93
+ })
94
+ .populate('participants.user', 'username displayName avatar status')
95
+ .populate('createdBy', 'username displayName');
96
+
97
+ if (!conversation) {
98
+ return res.status(404).json({ error: 'Conversation not found' });
99
+ }
100
+
101
+ res.json({ conversation });
102
+ } catch (error) {
103
+ console.error('Get conversation error:', error);
104
+ res.status(500).json({ error: 'Server error fetching conversation' });
105
+ }
106
+ };
107
+
108
+ exports.getConversationMessages = async (req, res) => {
109
+ try {
110
+ const { conversationId } = req.params;
111
+ const { page = 1, limit = 50 } = req.query;
112
+ const userId = req.user.userId;
113
+
114
+ // Check if user is part of conversation
115
+ const conversation = await Conversation.findOne({
116
+ _id: conversationId,
117
+ 'participants.user': userId
118
+ });
119
+
120
+ if (!conversation) {
121
+ return res.status(404).json({ error: 'Conversation not found' });
122
+ }
123
+
124
+ const messages = await Message.find({ conversation: conversationId })
125
+ .populate('sender', 'username displayName avatar')
126
+ .populate('replyTo')
127
+ .sort({ createdAt: -1 })
128
+ .limit(limit * 1)
129
+ .skip((page - 1) * limit);
130
+
131
+ // Reverse to get chronological order
132
+ const sortedMessages = messages.reverse();
133
+
134
+ res.json({
135
+ messages: sortedMessages,
136
+ pagination: {
137
+ page: parseInt(page),
138
+ limit: parseInt(limit),
139
+ total: await Message.countDocuments({ conversation: conversationId })
140
+ }
141
+ });
142
+ } catch (error) {
143
+ console.error('Get messages error:', error);
144
+ res.status(500).json({ error: 'Server error fetching messages' });
145
+ }
146
+ };
147
+
148
+ exports.updateConversation = async (req, res) => {
149
+ try {
150
+ const { conversationId } = req.params;
151
+ const { name, description, settings } = req.body;
152
+ const userId = req.user.userId;
153
+
154
+ // Check if user is admin/owner of conversation
155
+ const conversation = await Conversation.findOne({
156
+ _id: conversationId,
157
+ 'participants.user': userId,
158
+ 'participants.role': { $in: ['admin', 'owner'] }
159
+ });
160
+
161
+ if (!conversation) {
162
+ return res.status(404).json({ error: 'Conversation not found or insufficient permissions' });
163
+ }
164
+
165
+ const updateData = {};
166
+ if (name) updateData.name = name;
167
+ if (description !== undefined) updateData.description = description;
168
+ if (settings) updateData.settings = { ...conversation.settings, ...settings };
169
+
170
+ const updatedConversation = await Conversation.findByIdAndUpdate(
171
+ conversationId,
172
+ updateData,
173
+ { new: true }
174
+ ).populate('participants.user', 'username displayName avatar status');
175
+
176
+ res.json({
177
+ message: 'Conversation updated successfully',
178
+ conversation: updatedConversation
179
+ });
180
+ } catch (error) {
181
+ console.error('Update conversation error:', error);
182
+ res.status(500).json({ error: 'Server error updating conversation' });
183
+ }
184
+ };
185
+
186
+ exports.generateInviteLink = async (req, res) => {
187
+ try {
188
+ const { conversationId } = req.params;
189
+ const { expiresIn = '7d', maxUses = null } = req.body;
190
+ const userId = req.user.userId;
191
+
192
+ // Check if user is admin/owner
193
+ const conversation = await Conversation.findOne({
194
+ _id: conversationId,
195
+ 'participants.user': userId,
196
+ 'participants.role': { $in: ['admin', 'owner'] }
197
+ });
198
+
199
+ if (!conversation) {
200
+ return res.status(404).json({ error: 'Conversation not found or insufficient permissions' });
201
+ }
202
+
203
+ const inviteCode = generateInviteCode();
204
+ const expiresAt = new Date();
205
+ expiresAt.setDate(expiresAt.getDate() + 7); // Default 7 days
206
+
207
+ const inviteLink = {
208
+ code: inviteCode,
209
+ createdBy: userId,
210
+ expiresAt,
211
+ maxUses: maxUses || null,
212
+ uses: 0,
213
+ isActive: true
214
+ };
215
+
216
+ conversation.inviteLinks.push(inviteLink);
217
+ await conversation.save();
218
+
219
+ res.json({
220
+ message: 'Invite link generated successfully',
221
+ inviteLink: {
222
+ code: inviteCode,
223
+ url: `${process.env.CLIENT_URL}/join/${inviteCode}`,
224
+ expiresAt,
225
+ maxUses
226
+ }
227
+ });
228
+ } catch (error) {
229
+ console.error('Generate invite link error:', error);
230
+ res.status(500).json({ error: 'Server error generating invite link' });
231
+ }
232
+ };
ysnrfd_messenger/BACKUP/backend/src/controllers/messageController.js ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const Message = require('../models/Message');
2
+ const Conversation = require('../models/Conversation');
3
+
4
+ exports.sendMessage = async (req, res) => {
5
+ try {
6
+ const { conversationId, content, type = 'text', attachment, replyTo } = req.body;
7
+ const userId = req.user.userId;
8
+
9
+ // Check if user is part of conversation
10
+ const conversation = await Conversation.findOne({
11
+ _id: conversationId,
12
+ 'participants.user': userId
13
+ });
14
+
15
+ if (!conversation) {
16
+ return res.status(404).json({ error: 'Conversation not found' });
17
+ }
18
+
19
+ // Create message
20
+ const message = new Message({
21
+ conversation: conversationId,
22
+ sender: userId,
23
+ content,
24
+ type,
25
+ attachment,
26
+ replyTo,
27
+ status: 'sent'
28
+ });
29
+
30
+ await message.save();
31
+ await message.populate('sender', 'username displayName avatar status');
32
+ if (replyTo) {
33
+ await message.populate('replyTo');
34
+ }
35
+
36
+ // Update conversation's updatedAt
37
+ conversation.updatedAt = new Date();
38
+ await conversation.save();
39
+
40
+ res.status(201).json({
41
+ message: 'Message sent successfully',
42
+ message: message
43
+ });
44
+ } catch (error) {
45
+ console.error('Send message error:', error);
46
+ res.status(500).json({ error: 'Server error sending message' });
47
+ }
48
+ };
49
+
50
+ exports.editMessage = async (req, res) => {
51
+ try {
52
+ const { messageId } = req.params;
53
+ const { content } = req.body;
54
+ const userId = req.user.userId;
55
+
56
+ const message = await Message.findOne({
57
+ _id: messageId,
58
+ sender: userId
59
+ });
60
+
61
+ if (!message) {
62
+ return res.status(404).json({ error: 'Message not found' });
63
+ }
64
+
65
+ // Prevent editing messages older than 15 minutes
66
+ const fifteenMinutesAgo = new Date(Date.now() - 15 * 60 * 1000);
67
+ if (message.createdAt < fifteenMinutesAgo) {
68
+ return res.status(400).json({ error: 'Messages can only be edited within 15 minutes of sending' });
69
+ }
70
+
71
+ // Save edit history
72
+ message.edits.push({
73
+ content: message.content,
74
+ editedAt: new Date()
75
+ });
76
+
77
+ message.content = content;
78
+ message.isEdited = true;
79
+ message.updatedAt = new Date();
80
+
81
+ await message.save();
82
+ await message.populate('sender', 'username displayName avatar status');
83
+
84
+ res.json({
85
+ message: 'Message updated successfully',
86
+ message: message
87
+ });
88
+ } catch (error) {
89
+ console.error('Edit message error:', error);
90
+ res.status(500).json({ error: 'Server error editing message' });
91
+ }
92
+ };
93
+
94
+ exports.deleteMessage = async (req, res) => {
95
+ try {
96
+ const { messageId } = req.params;
97
+ const userId = req.user.userId;
98
+
99
+ const message = await Message.findOne({
100
+ _id: messageId,
101
+ sender: userId
102
+ });
103
+
104
+ if (!message) {
105
+ return res.status(404).json({ error: 'Message not found' });
106
+ }
107
+
108
+ // Soft delete
109
+ message.isDeleted = true;
110
+ message.deletedAt = new Date();
111
+ message.content = 'This message was deleted';
112
+ message.attachment = null;
113
+
114
+ await message.save();
115
+
116
+ res.json({ message: 'Message deleted successfully' });
117
+ } catch (error) {
118
+ console.error('Delete message error:', error);
119
+ res.status(500).json({ error: 'Server error deleting message' });
120
+ }
121
+ };
122
+
123
+ exports.reactToMessage = async (req, res) => {
124
+ try {
125
+ const { messageId } = req.params;
126
+ const { emoji } = req.body;
127
+ const userId = req.user.userId;
128
+
129
+ const message = await Message.findById(messageId);
130
+ if (!message) {
131
+ return res.status(404).json({ error: 'Message not found' });
132
+ }
133
+
134
+ // Check if user already reacted with this emoji
135
+ const existingReactionIndex = message.reactions.findIndex(
136
+ reaction => reaction.user.toString() === userId && reaction.emoji === emoji
137
+ );
138
+
139
+ if (existingReactionIndex > -1) {
140
+ // Remove reaction
141
+ message.reactions.splice(existingReactionIndex, 1);
142
+ } else {
143
+ // Add reaction
144
+ message.reactions.push({
145
+ user: userId,
146
+ emoji,
147
+ createdAt: new Date()
148
+ });
149
+ }
150
+
151
+ await message.save();
152
+ await message.populate('reactions.user', 'username displayName');
153
+
154
+ res.json({
155
+ message: 'Reaction updated successfully',
156
+ reactions: message.reactions
157
+ });
158
+ } catch (error) {
159
+ console.error('React to message error:', error);
160
+ res.status(500).json({ error: 'Server error updating reaction' });
161
+ }
162
+ };
163
+
164
+ exports.markAsRead = async (req, res) => {
165
+ try {
166
+ const { messageId } = req.params;
167
+ const userId = req.user.userId;
168
+
169
+ const message = await Message.findByIdAndUpdate(
170
+ messageId,
171
+ {
172
+ $addToSet: { readBy: { user: userId, readAt: new Date() } }
173
+ },
174
+ { new: true }
175
+ );
176
+
177
+ if (!message) {
178
+ return res.status(404).json({ error: 'Message not found' });
179
+ }
180
+
181
+ // Update user's last read in conversation
182
+ await Conversation.updateOne(
183
+ {
184
+ _id: message.conversation,
185
+ 'participants.user': userId
186
+ },
187
+ {
188
+ $set: {
189
+ 'participants.$.lastRead': new Date()
190
+ }
191
+ }
192
+ );
193
+
194
+ res.json({ message: 'Message marked as read' });
195
+ } catch (error) {
196
+ console.error('Mark as read error:', error);
197
+ res.status(500).json({ error: 'Server error marking message as read' });
198
+ }
199
+ };
ysnrfd_messenger/BACKUP/backend/src/controllers/uploadController.js ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const { v4: uuidv4 } = require('uuid');
4
+ const { validateFile, getFileType } = require('../utils/fileValidation');
5
+ const { formatFileSize } = require('../utils/helpers');
6
+
7
+ exports.uploadFile = async (req, res) => {
8
+ try {
9
+ if (!req.file) {
10
+ return res.status(400).json({ error: 'No file provided' });
11
+ }
12
+
13
+ const file = req.file;
14
+
15
+ // Validate file
16
+ const fileCategory = validateFile(file);
17
+
18
+ // Generate file metadata
19
+ const fileData = {
20
+ id: uuidv4(),
21
+ originalName: file.originalname,
22
+ fileName: file.filename,
23
+ fileSize: file.size,
24
+ mimeType: file.mimetype,
25
+ url: `/uploads/${file.filename}`,
26
+ uploaderId: req.user.userId,
27
+ uploadedAt: new Date()
28
+ };
29
+
30
+ // Generate thumbnail for images (simplified - in production use sharp/gm)
31
+ if (fileCategory === 'image') {
32
+ fileData.thumbnail = `/uploads/${file.filename}`; // Same file for demo
33
+ }
34
+
35
+ res.json({
36
+ message: 'File uploaded successfully',
37
+ file: fileData
38
+ });
39
+ } catch (error) {
40
+ console.error('File upload error:', error);
41
+ res.status(400).json({ error: error.message });
42
+ }
43
+ };
44
+
45
+ exports.getFile = async (req, res) => {
46
+ try {
47
+ const { filename } = req.params;
48
+ const filePath = path.join(__dirname, '../../uploads', filename);
49
+
50
+ // Check if file exists
51
+ if (!fs.existsSync(filePath)) {
52
+ return res.status(404).json({ error: 'File not found' });
53
+ }
54
+
55
+ // Set appropriate headers
56
+ const ext = path.extname(filename).toLowerCase();
57
+ const mimeTypes = {
58
+ '.jpg': 'image/jpeg',
59
+ '.jpeg': 'image/jpeg',
60
+ '.png': 'image/png',
61
+ '.gif': 'image/gif',
62
+ '.webp': 'image/webp',
63
+ '.pdf': 'application/pdf',
64
+ '.txt': 'text/plain',
65
+ '.mp3': 'audio/mpeg',
66
+ '.wav': 'audio/wav',
67
+ '.ogg': 'audio/ogg'
68
+ };
69
+
70
+ res.setHeader('Content-Type', mimeTypes[ext] || 'application/octet-stream');
71
+ res.setHeader('Content-Disposition', `inline; filename="${filename}"`);
72
+
73
+ // Stream file
74
+ const fileStream = fs.createReadStream(filePath);
75
+ fileStream.pipe(res);
76
+ } catch (error) {
77
+ console.error('Get file error:', error);
78
+ res.status(500).json({ error: 'Server error retrieving file' });
79
+ }
80
+ };
81
+
82
+ exports.cleanupOrphanedFiles = async (req, res) => {
83
+ try {
84
+ // This would typically be a cron job
85
+ const uploadsDir = path.join(__dirname, '../../uploads');
86
+ const files = fs.readdirSync(uploadsDir);
87
+
88
+ const orphanedFiles = [];
89
+ const oneWeekAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
90
+
91
+ for (const file of files) {
92
+ const filePath = path.join(uploadsDir, file);
93
+ const stats = fs.statSync(filePath);
94
+
95
+ // Check if file is older than 1 week and not referenced in any message
96
+ if (stats.mtime < oneWeekAgo) {
97
+ const messageWithFile = await Message.findOne({ 'attachment.fileName': file });
98
+ if (!messageWithFile) {
99
+ orphanedFiles.push(file);
100
+ fs.unlinkSync(filePath);
101
+ }
102
+ }
103
+ }
104
+
105
+ res.json({
106
+ message: `Cleaned up ${orphanedFiles.length} orphaned files`,
107
+ orphanedFiles
108
+ });
109
+ } catch (error) {
110
+ console.error('Cleanup error:', error);
111
+ res.status(500).json({ error: 'Server error during cleanup' });
112
+ }
113
+ };
ysnrfd_messenger/BACKUP/backend/src/controllers/userController.js ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const User = require('../models/User');
2
+
3
+ exports.searchUsers = async (req, res) => {
4
+ try {
5
+ const { username, email } = req.query;
6
+
7
+ if (!username && !email) {
8
+ return res.status(400).json({ error: 'Username or email is required for search' });
9
+ }
10
+
11
+ const searchQuery = {};
12
+ if (username) {
13
+ searchQuery.username = { $regex: username, $options: 'i' };
14
+ }
15
+ if (email) {
16
+ searchQuery.email = { $regex: email, $options: 'i' };
17
+ }
18
+
19
+ // Exclude current user from results
20
+ searchQuery._id = { $ne: req.user.userId };
21
+
22
+ const users = await User.find(searchQuery)
23
+ .select('username displayName avatar status lastSeen bio')
24
+ .limit(20);
25
+
26
+ res.json({ users });
27
+ } catch (error) {
28
+ console.error('User search error:', error);
29
+ res.status(500).json({ error: 'Server error during user search' });
30
+ }
31
+ };
32
+
33
+ exports.getUserProfile = async (req, res) => {
34
+ try {
35
+ const { userId } = req.params;
36
+
37
+ const user = await User.findById(userId)
38
+ .select('username displayName avatar status lastSeen bio createdAt');
39
+
40
+ if (!user) {
41
+ return res.status(404).json({ error: 'User not found' });
42
+ }
43
+
44
+ res.json({ user });
45
+ } catch (error) {
46
+ console.error('Get user profile error:', error);
47
+ res.status(500).json({ error: 'Server error' });
48
+ }
49
+ };
50
+
51
+ exports.updateSettings = async (req, res) => {
52
+ try {
53
+ const { theme, notifications } = req.body;
54
+
55
+ const updateData = {};
56
+ if (theme) updateData['settings.theme'] = theme;
57
+ if (notifications) {
58
+ if (typeof notifications.enabled !== 'undefined') {
59
+ updateData['settings.notifications.enabled'] = notifications.enabled;
60
+ }
61
+ if (typeof notifications.sound !== 'undefined') {
62
+ updateData['settings.notifications.sound'] = notifications.sound;
63
+ }
64
+ if (typeof notifications.preview !== 'undefined') {
65
+ updateData['settings.notifications.preview'] = notifications.preview;
66
+ }
67
+ }
68
+
69
+ const user = await User.findByIdAndUpdate(
70
+ req.user.userId,
71
+ { $set: updateData },
72
+ { new: true, runValidators: true }
73
+ );
74
+
75
+ res.json({
76
+ message: 'Settings updated successfully',
77
+ settings: user.settings
78
+ });
79
+ } catch (error) {
80
+ console.error('Update settings error:', error);
81
+ res.status(500).json({ error: 'Server error during settings update' });
82
+ }
83
+ };
84
+
85
+ exports.deleteAccount = async (req, res) => {
86
+ try {
87
+ const { confirmation } = req.body;
88
+
89
+ if (confirmation !== 'DELETE MY ACCOUNT') {
90
+ return res.status(400).json({
91
+ error: 'Please type "DELETE MY ACCOUNT" to confirm account deletion'
92
+ });
93
+ }
94
+
95
+ await User.findByIdAndDelete(req.user.userId);
96
+
97
+ res.clearCookie('token');
98
+ res.json({ message: 'Account deleted successfully' });
99
+ } catch (error) {
100
+ console.error('Delete account error:', error);
101
+ res.status(500).json({ error: 'Server error during account deletion' });
102
+ }
103
+ };
ysnrfd_messenger/BACKUP/backend/src/middleware/auth.js ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const jwt = require('jsonwebtoken');
2
+ const User = require('../models/User');
3
+
4
+ const auth = async (req, res, next) => {
5
+ try {
6
+ let token;
7
+
8
+ // Check for token in headers
9
+ if (req.headers.authorization && req.headers.authorization.startsWith('Bearer')) {
10
+ token = req.headers.authorization.split(' ')[1];
11
+ }
12
+ // Check for token in cookies
13
+ else if (req.cookies?.token) {
14
+ token = req.cookies.token;
15
+ }
16
+
17
+ if (!token) {
18
+ return res.status(401).json({ error: 'No token provided, authorization denied' });
19
+ }
20
+
21
+ // Verify token
22
+ const decoded = jwt.verify(token, process.env.JWT_SECRET);
23
+
24
+ // Check if user still exists
25
+ const user = await User.findById(decoded.userId).select('-password');
26
+ if (!user) {
27
+ return res.status(401).json({ error: 'User no longer exists' });
28
+ }
29
+
30
+ req.user = decoded;
31
+ next();
32
+ } catch (error) {
33
+ console.error('Auth middleware error:', error);
34
+ res.status(401).json({ error: 'Token is not valid' });
35
+ }
36
+ };
37
+
38
+ module.exports = auth;
ysnrfd_messenger/BACKUP/backend/src/middleware/upload.js ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const multer = require('multer');
2
+ const path = require('path');
3
+ const { v4: uuidv4 } = require('uuid');
4
+
5
+ // Configure storage
6
+ const storage = multer.diskStorage({
7
+ destination: (req, file, cb) => {
8
+ cb(null, 'uploads/');
9
+ },
10
+ filename: (req, file, cb) => {
11
+ const uniqueName = `${uuidv4()}${path.extname(file.originalname)}`;
12
+ cb(null, uniqueName);
13
+ }
14
+ });
15
+
16
+ // File filter
17
+ const fileFilter = (req, file, cb) => {
18
+ const allowedTypes = {
19
+ 'image/jpeg': true,
20
+ 'image/jpg': true,
21
+ 'image/png': true,
22
+ 'image/gif': true,
23
+ 'image/webp': true,
24
+ 'audio/mpeg': true,
25
+ 'audio/wav': true,
26
+ 'audio/ogg': true,
27
+ 'audio/mp4': true,
28
+ 'application/pdf': true,
29
+ 'text/plain': true,
30
+ 'text/markdown': true
31
+ };
32
+
33
+ if (allowedTypes[file.mimetype]) {
34
+ cb(null, true);
35
+ } else {
36
+ cb(new Error(`File type ${file.mimetype} is not supported`), false);
37
+ }
38
+ };
39
+
40
+ const upload = multer({
41
+ storage,
42
+ fileFilter,
43
+ limits: {
44
+ fileSize: 50 * 1024 * 1024 // 50MB max file size
45
+ }
46
+ });
47
+
48
+ // Error handling middleware for multer
49
+ const handleUploadError = (error, req, res, next) => {
50
+ if (error instanceof multer.MulterError) {
51
+ if (error.code === 'LIMIT_FILE_SIZE') {
52
+ return res.status(400).json({ error: 'File too large. Maximum size is 50MB.' });
53
+ }
54
+ return res.status(400).json({ error: `Upload error: ${error.message}` });
55
+ }
56
+
57
+ if (error) {
58
+ return res.status(400).json({ error: error.message });
59
+ }
60
+
61
+ next();
62
+ };
63
+
64
+ module.exports = { upload, handleUploadError };
ysnrfd_messenger/BACKUP/backend/src/models/Conversation.js ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const mongoose = require('mongoose');
2
+
3
+ const conversationSchema = new mongoose.Schema({
4
+ type: {
5
+ type: String,
6
+ enum: ['direct', 'group', 'channel'],
7
+ required: true
8
+ },
9
+ name: {
10
+ type: String,
11
+ required: function() { return this.type !== 'direct'; }
12
+ },
13
+ description: {
14
+ type: String,
15
+ maxlength: 500
16
+ },
17
+ avatar: {
18
+ type: String
19
+ },
20
+ createdBy: {
21
+ type: mongoose.Schema.Types.ObjectId,
22
+ ref: 'User',
23
+ required: true
24
+ },
25
+ participants: [{
26
+ user: {
27
+ type: mongoose.Schema.Types.ObjectId,
28
+ ref: 'User',
29
+ required: true
30
+ },
31
+ role: {
32
+ type: String,
33
+ enum: ['member', 'admin', 'owner'],
34
+ default: 'member'
35
+ },
36
+ joinedAt: {
37
+ type: Date,
38
+ default: Date.now
39
+ },
40
+ lastRead: {
41
+ type: Date,
42
+ default: Date.now
43
+ }
44
+ }],
45
+ settings: {
46
+ isPublic: {
47
+ type: Boolean,
48
+ default: false
49
+ },
50
+ allowInvites: {
51
+ type: Boolean,
52
+ default: true
53
+ },
54
+ adminOnlyMessages: {
55
+ type: Boolean,
56
+ default: false
57
+ }
58
+ },
59
+ inviteLinks: [{
60
+ code: String,
61
+ createdBy: mongoose.Schema.Types.ObjectId,
62
+ expiresAt: Date,
63
+ maxUses: Number,
64
+ uses: { type: Number, default: 0 },
65
+ isActive: { type: Boolean, default: true }
66
+ }]
67
+ }, {
68
+ timestamps: true
69
+ });
70
+
71
+ conversationSchema.index({ 'participants.user': 1 });
72
+ conversationSchema.index({ type: 1, updatedAt: -1 });
73
+
74
+ module.exports = mongoose.model('Conversation', conversationSchema);
ysnrfd_messenger/BACKUP/backend/src/models/Message.js ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const mongoose = require('mongoose');
2
+
3
+ const messageSchema = new mongoose.Schema({
4
+ conversation: {
5
+ type: mongoose.Schema.Types.ObjectId,
6
+ ref: 'Conversation',
7
+ required: true
8
+ },
9
+ sender: {
10
+ type: mongoose.Schema.Types.ObjectId,
11
+ ref: 'User',
12
+ required: true
13
+ },
14
+ content: {
15
+ type: String,
16
+ required: function() { return !this.attachment; }
17
+ },
18
+ type: {
19
+ type: String,
20
+ enum: ['text', 'image', 'audio', 'file', 'system'],
21
+ default: 'text'
22
+ },
23
+ attachment: {
24
+ url: String,
25
+ filename: String,
26
+ originalName: String,
27
+ mimeType: String,
28
+ size: Number,
29
+ thumbnail: String,
30
+ duration: Number
31
+ },
32
+ replyTo: {
33
+ type: mongoose.Schema.Types.ObjectId,
34
+ ref: 'Message'
35
+ },
36
+ reactions: [{
37
+ user: mongoose.Schema.Types.ObjectId,
38
+ emoji: String,
39
+ createdAt: { type: Date, default: Date.now }
40
+ }],
41
+ edits: [{
42
+ content: String,
43
+ editedAt: { type: Date, default: Date.now }
44
+ }],
45
+ isEdited: {
46
+ type: Boolean,
47
+ default: false
48
+ },
49
+ isDeleted: {
50
+ type: Boolean,
51
+ default: false
52
+ },
53
+ deletedAt: Date,
54
+ readBy: [{
55
+ user: mongoose.Schema.Types.ObjectId,
56
+ readAt: { type: Date, default: Date.now }
57
+ }],
58
+ status: {
59
+ type: String,
60
+ enum: ['sending', 'sent', 'delivered', 'read'],
61
+ default: 'sent'
62
+ }
63
+ }, {
64
+ timestamps: true
65
+ });
66
+
67
+ messageSchema.index({ conversation: 1, createdAt: -1 });
68
+ messageSchema.index({ sender: 1 });
69
+ messageSchema.index({ 'readBy.user': 1 });
70
+
71
+ module.exports = mongoose.model('Message', messageSchema);
ysnrfd_messenger/BACKUP/backend/src/models/User.js ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const mongoose = require('mongoose');
2
+ const bcrypt = require('bcryptjs');
3
+
4
+ const userSchema = new mongoose.Schema({
5
+ username: {
6
+ type: String,
7
+ required: true,
8
+ unique: true,
9
+ trim: true,
10
+ minlength: 3,
11
+ maxlength: 30
12
+ },
13
+ email: {
14
+ type: String,
15
+ required: true,
16
+ unique: true,
17
+ trim: true,
18
+ lowercase: true
19
+ },
20
+ password: {
21
+ type: String,
22
+ required: true,
23
+ minlength: 6
24
+ },
25
+ displayName: {
26
+ type: String,
27
+ required: true,
28
+ trim: true,
29
+ maxlength: 50
30
+ },
31
+ avatar: {
32
+ type: String,
33
+ default: null
34
+ },
35
+ bio: {
36
+ type: String,
37
+ maxlength: 500,
38
+ default: ''
39
+ },
40
+ status: {
41
+ type: String,
42
+ enum: ['online', 'offline', 'away', 'busy'],
43
+ default: 'offline'
44
+ },
45
+ lastSeen: {
46
+ type: Date,
47
+ default: Date.now
48
+ },
49
+ settings: {
50
+ theme: {
51
+ type: String,
52
+ enum: ['light', 'dark', 'auto'],
53
+ default: 'auto'
54
+ },
55
+ notifications: {
56
+ enabled: { type: Boolean, default: true },
57
+ sound: { type: Boolean, default: true },
58
+ preview: { type: Boolean, default: true }
59
+ }
60
+ }
61
+ }, {
62
+ timestamps: true
63
+ });
64
+
65
+ userSchema.pre('save', async function(next) {
66
+ if (!this.isModified('password')) return next();
67
+ this.password = await bcrypt.hash(this.password, 12);
68
+ next();
69
+ });
70
+
71
+ userSchema.methods.comparePassword = async function(candidatePassword) {
72
+ return await bcrypt.compare(candidatePassword, this.password);
73
+ };
74
+
75
+ userSchema.methods.toJSON = function() {
76
+ const user = this.toObject();
77
+ delete user.password;
78
+ return user;
79
+ };
80
+
81
+ module.exports = mongoose.model('User', userSchema);
ysnrfd_messenger/BACKUP/backend/src/routes/auth.js ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const express = require('express');
2
+ const {
3
+ register,
4
+ login,
5
+ logout,
6
+ getMe,
7
+ updateProfile
8
+ } = require('../controllers/authController');
9
+ const auth = require('../middleware/auth');
10
+
11
+ const router = express.Router();
12
+
13
+ router.post('/register', register);
14
+ router.post('/login', login);
15
+ router.post('/logout', auth, logout);
16
+ router.get('/me', auth, getMe);
17
+ router.put('/profile', auth, updateProfile);
18
+
19
+ module.exports = router;
ysnrfd_messenger/BACKUP/backend/src/routes/conversations.js ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const express = require('express');
2
+ const {
3
+ createConversation,
4
+ getUserConversations,
5
+ getConversation,
6
+ getConversationMessages,
7
+ updateConversation,
8
+ generateInviteLink
9
+ } = require('../controllers/conversationController');
10
+ const auth = require('../middleware/auth');
11
+
12
+ const router = express.Router();
13
+
14
+ router.post('/', auth, createConversation);
15
+ router.get('/', auth, getUserConversations);
16
+ router.get('/:conversationId', auth, getConversation);
17
+ router.get('/:conversationId/messages', auth, getConversationMessages);
18
+ router.put('/:conversationId', auth, updateConversation);
19
+ router.post('/:conversationId/invite', auth, generateInviteLink);
20
+
21
+ module.exports = router;
ysnrfd_messenger/BACKUP/backend/src/routes/messages.js ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const express = require('express');
2
+ const {
3
+ sendMessage,
4
+ editMessage,
5
+ deleteMessage,
6
+ reactToMessage,
7
+ markAsRead
8
+ } = require('../controllers/messageController');
9
+ const auth = require('../middleware/auth');
10
+
11
+ const router = express.Router();
12
+
13
+ router.post('/', auth, sendMessage);
14
+ router.put('/:messageId', auth, editMessage);
15
+ router.delete('/:messageId', auth, deleteMessage);
16
+ router.post('/:messageId/react', auth, reactToMessage);
17
+ router.post('/:messageId/read', auth, markAsRead);
18
+
19
+ module.exports = router;
ysnrfd_messenger/BACKUP/backend/src/routes/upload.js ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const express = require('express');
2
+ const {
3
+ uploadFile,
4
+ getFile,
5
+ cleanupOrphanedFiles
6
+ } = require('../controllers/uploadController');
7
+ const { upload, handleUploadError } = require('../middleware/upload');
8
+ const auth = require('../middleware/auth');
9
+
10
+ const router = express.Router();
11
+
12
+ router.post('/', auth, upload.single('file'), handleUploadError, uploadFile);
13
+ router.get('/:filename', getFile);
14
+ router.delete('/cleanup', auth, cleanupOrphanedFiles);
15
+
16
+ module.exports = router;
ysnrfd_messenger/BACKUP/backend/src/routes/users.js ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const express = require('express');
2
+ const {
3
+ searchUsers,
4
+ getUserProfile,
5
+ updateSettings,
6
+ deleteAccount
7
+ } = require('../controllers/userController');
8
+ const auth = require('../middleware/auth');
9
+
10
+ const router = express.Router();
11
+
12
+ router.get('/search', auth, searchUsers);
13
+ router.get('/:userId', auth, getUserProfile);
14
+ router.put('/settings', auth, updateSettings);
15
+ router.delete('/account', auth, deleteAccount);
16
+
17
+ module.exports = router;
ysnrfd_messenger/BACKUP/backend/src/sockets/socketHandlers.js ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const User = require('../models/User');
2
+ const Conversation = require('../models/Conversation');
3
+ const Message = require('../models/Message');
4
+
5
+ module.exports = (io, socket) => {
6
+ const userId = socket.userId;
7
+
8
+ console.log(`User ${userId} connected via WebSocket`);
9
+
10
+ // Join user to their conversation rooms
11
+ const joinConversationRooms = async () => {
12
+ try {
13
+ const conversations = await Conversation.find({
14
+ 'participants.user': userId
15
+ });
16
+
17
+ conversations.forEach(conversation => {
18
+ socket.join(conversation._id.toString());
19
+ console.log(`User ${userId} joined room ${conversation._id}`);
20
+ });
21
+
22
+ // Update user status to online
23
+ await User.findByIdAndUpdate(userId, {
24
+ status: 'online',
25
+ lastSeen: new Date()
26
+ });
27
+
28
+ // Notify others that user is online
29
+ socket.broadcast.emit('user:status', {
30
+ userId,
31
+ status: 'online',
32
+ lastSeen: new Date()
33
+ });
34
+ } catch (error) {
35
+ console.error('Error joining conversation rooms:', error);
36
+ }
37
+ };
38
+
39
+ // Handle new message
40
+ const handleMessageSend = async (data) => {
41
+ try {
42
+ const { conversationId, content, type, attachment, replyTo } = data;
43
+
44
+ // Validate conversation membership
45
+ const conversation = await Conversation.findOne({
46
+ _id: conversationId,
47
+ 'participants.user': userId
48
+ });
49
+
50
+ if (!conversation) {
51
+ socket.emit('message:error', { error: 'Not a member of this conversation' });
52
+ return;
53
+ }
54
+
55
+ // Create message
56
+ const message = new Message({
57
+ conversation: conversationId,
58
+ sender: userId,
59
+ content,
60
+ type: type || 'text',
61
+ attachment,
62
+ replyTo,
63
+ status: 'sent'
64
+ });
65
+
66
+ await message.save();
67
+
68
+ // Populate message with sender info
69
+ await message.populate('sender', 'username displayName avatar status');
70
+ if (message.replyTo) {
71
+ await message.populate('replyTo');
72
+ }
73
+
74
+ // Update conversation last activity
75
+ conversation.updatedAt = new Date();
76
+ await conversation.save();
77
+
78
+ // Emit to all users in conversation
79
+ io.to(conversationId).emit('message:receive', message);
80
+
81
+ // Emit conversation update
82
+ io.to(conversationId).emit('conversation:updated', {
83
+ conversationId,
84
+ lastMessage: message,
85
+ updatedAt: conversation.updatedAt
86
+ });
87
+
88
+ console.log(`Message sent in conversation ${conversationId} by user ${userId}`);
89
+
90
+ } catch (error) {
91
+ console.error('Error sending message:', error);
92
+ socket.emit('message:error', { error: 'Failed to send message' });
93
+ }
94
+ };
95
+
96
+ // Handle typing indicators
97
+ const handleTypingStart = (data) => {
98
+ const { conversationId } = data;
99
+ socket.to(conversationId).emit('typing:start', {
100
+ userId,
101
+ conversationId
102
+ });
103
+ };
104
+
105
+ const handleTypingStop = (data) => {
106
+ const { conversationId } = data;
107
+ socket.to(conversationId).emit('typing:stop', {
108
+ userId,
109
+ conversationId
110
+ });
111
+ };
112
+
113
+ // Handle message read receipts
114
+ const handleMessageRead = async (data) => {
115
+ try {
116
+ const { messageId, conversationId } = data;
117
+
118
+ const message = await Message.findByIdAndUpdate(
119
+ messageId,
120
+ {
121
+ $addToSet: {
122
+ readBy: {
123
+ user: userId,
124
+ readAt: new Date()
125
+ }
126
+ }
127
+ },
128
+ { new: true }
129
+ );
130
+
131
+ if (!message) {
132
+ return;
133
+ }
134
+
135
+ // Update user's last read in conversation
136
+ await Conversation.updateOne(
137
+ {
138
+ _id: conversationId,
139
+ 'participants.user': userId
140
+ },
141
+ {
142
+ $set: {
143
+ 'participants.$.lastRead': new Date()
144
+ }
145
+ }
146
+ );
147
+
148
+ // Notify others in conversation
149
+ socket.to(conversationId).emit('message:read', {
150
+ messageId,
151
+ userId,
152
+ readAt: new Date()
153
+ });
154
+
155
+ } catch (error) {
156
+ console.error('Error updating read receipt:', error);
157
+ }
158
+ };
159
+
160
+ // Handle message reactions
161
+ const handleMessageReaction = async (data) => {
162
+ try {
163
+ const { messageId, emoji } = data;
164
+
165
+ const message = await Message.findById(messageId);
166
+ if (!message) {
167
+ return;
168
+ }
169
+
170
+ // Check if user already reacted with this emoji
171
+ const existingReactionIndex = message.reactions.findIndex(
172
+ reaction => reaction.user.toString() === userId && reaction.emoji === emoji
173
+ );
174
+
175
+ if (existingReactionIndex > -1) {
176
+ // Remove reaction
177
+ message.reactions.splice(existingReactionIndex, 1);
178
+ } else {
179
+ // Add reaction
180
+ message.reactions.push({
181
+ user: userId,
182
+ emoji,
183
+ createdAt: new Date()
184
+ });
185
+ }
186
+
187
+ await message.save();
188
+ await message.populate('reactions.user', 'username displayName');
189
+
190
+ // Broadcast reaction update
191
+ io.to(message.conversation.toString()).emit('message:reaction', {
192
+ messageId,
193
+ reactions: message.reactions
194
+ });
195
+
196
+ } catch (error) {
197
+ console.error('Error handling message reaction:', error);
198
+ }
199
+ };
200
+
201
+ // Handle disconnect
202
+ const handleDisconnect = async () => {
203
+ try {
204
+ console.log(`User ${userId} disconnected`);
205
+
206
+ // Update user status to offline
207
+ await User.findByIdAndUpdate(userId, {
208
+ status: 'offline',
209
+ lastSeen: new Date()
210
+ });
211
+
212
+ // Notify others that user is offline
213
+ socket.broadcast.emit('user:status', {
214
+ userId,
215
+ status: 'offline',
216
+ lastSeen: new Date()
217
+ });
218
+ } catch (error) {
219
+ console.error('Error handling disconnect:', error);
220
+ }
221
+ };
222
+
223
+ // Register event handlers
224
+ socket.on('message:send', handleMessageSend);
225
+ socket.on('typing:start', handleTypingStart);
226
+ socket.on('typing:stop', handleTypingStop);
227
+ socket.on('message:read', handleMessageRead);
228
+ socket.on('message:react', handleMessageReaction);
229
+ socket.on('disconnect', handleDisconnect);
230
+
231
+ // Initialize socket connection
232
+ joinConversationRooms();
233
+ };
ysnrfd_messenger/BACKUP/backend/src/utils/fileValidation.js ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const allowedFileTypes = {
2
+ image: ['image/jpeg', 'image/jpg', 'image/png', 'image/gif', 'image/webp'],
3
+ audio: ['audio/mpeg', 'audio/wav', 'audio/ogg', 'audio/mp4', 'audio/x-m4a'],
4
+ document: ['application/pdf', 'text/plain', 'text/markdown']
5
+ };
6
+
7
+ const maxFileSizes = {
8
+ image: 10 * 1024 * 1024, // 10MB
9
+ audio: 25 * 1024 * 1024, // 25MB
10
+ document: 50 * 1024 * 1024 // 50MB
11
+ };
12
+
13
+ const validateFile = (file) => {
14
+ const { mimetype, size } = file;
15
+
16
+ // Check file type
17
+ let fileCategory = null;
18
+ for (const [category, types] of Object.entries(allowedFileTypes)) {
19
+ if (types.includes(mimetype)) {
20
+ fileCategory = category;
21
+ break;
22
+ }
23
+ }
24
+
25
+ if (!fileCategory) {
26
+ throw new Error(`File type ${mimetype} is not supported`);
27
+ }
28
+
29
+ // Check file size
30
+ if (size > maxFileSizes[fileCategory]) {
31
+ throw new Error(`File too large. Maximum size for ${fileCategory} is ${maxFileSizes[fileCategory] / 1024 / 1024}MB`);
32
+ }
33
+
34
+ return fileCategory;
35
+ };
36
+
37
+ const getFileType = (mimetype) => {
38
+ if (mimetype.startsWith('image/')) return 'image';
39
+ if (mimetype.startsWith('audio/')) return 'audio';
40
+ if (mimetype.startsWith('text/') || mimetype === 'application/pdf') return 'document';
41
+ return 'file';
42
+ };
43
+
44
+ module.exports = {
45
+ validateFile,
46
+ getFileType,
47
+ allowedFileTypes,
48
+ maxFileSizes
49
+ };
ysnrfd_messenger/BACKUP/backend/src/utils/helpers.js ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const formatFileSize = (bytes) => {
2
+ if (bytes === 0) return '0 Bytes';
3
+
4
+ const k = 1024;
5
+ const sizes = ['Bytes', 'KB', 'MB', 'GB'];
6
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
7
+
8
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
9
+ };
10
+
11
+ const generateInviteCode = () => {
12
+ return Math.random().toString(36).substring(2, 8).toUpperCase();
13
+ };
14
+
15
+ const sanitizeUser = (user) => {
16
+ const userObj = user.toObject ? user.toObject() : user;
17
+ const { password, __v, ...sanitized } = userObj;
18
+ return sanitized;
19
+ };
20
+
21
+ const paginate = (query, page = 1, limit = 20) => {
22
+ const skip = (page - 1) * limit;
23
+ return query.skip(skip).limit(limit);
24
+ };
25
+
26
+ module.exports = {
27
+ formatFileSize,
28
+ generateInviteCode,
29
+ sanitizeUser,
30
+ paginate
31
+ };
ysnrfd_messenger/BACKUP/frontend/.env ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ VITE_API_URL=http://localhost:5000/api
2
+ VITE_WS_URL=http://localhost:5000
3
+ VITE_APP_NAME=YSNRFD Messenger
ysnrfd_messenger/BACKUP/frontend/.env.example ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ VITE_API_URL=http://localhost:5000/api
2
+ VITE_WS_URL=http://localhost:5000
3
+ VITE_APP_NAME=YSNRFD Messenger
ysnrfd_messenger/BACKUP/frontend/.gitignore ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ node_modules/
2
+ dist/
3
+ .env
4
+ .DS_Store
5
+ *.log
6
+ .vscode/
7
+ .idea/
ysnrfd_messenger/BACKUP/frontend/index.html ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>YSNRFD Messenger</title>
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ <script type="module" src="/src/main.jsx"></script>
12
+ </body>
13
+ </html>
ysnrfd_messenger/BACKUP/frontend/package-lock.json ADDED
The diff for this file is too large to render. See raw diff
 
ysnrfd_messenger/BACKUP/frontend/package.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "ysnrfd-messenger-frontend",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "scripts": {
6
+ "dev": "vite",
7
+ "build": "vite build",
8
+ "preview": "vite preview",
9
+ "preview:production": "vite preview --port 4173 --host"
10
+ },
11
+ "dependencies": {
12
+ "react": "^18.2.0",
13
+ "react-dom": "^18.2.0",
14
+ "react-router-dom": "^6.14.1",
15
+ "socket.io-client": "^4.7.2",
16
+ "axios": "^1.4.0",
17
+ "lucide-react": "^0.263.1",
18
+ "date-fns": "^2.30.0",
19
+ "react-dropzone": "^14.2.3",
20
+ "emoji-picker-react": "^4.4.9",
21
+ "react-tooltip": "^5.21.0"
22
+ },
23
+ "devDependencies": {
24
+ "@types/react": "^18.2.15",
25
+ "@types/react-dom": "^18.2.7",
26
+ "@vitejs/plugin-react": "^4.0.3",
27
+ "autoprefixer": "^10.4.14",
28
+ "postcss": "^8.4.27",
29
+ "tailwindcss": "^3.3.3",
30
+ "vite": "^4.4.5",
31
+ "vite-plugin-pwa": "^0.16.4"
32
+ }
33
+ }
ysnrfd_messenger/BACKUP/frontend/postcss.config.js ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ export default {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ }
ysnrfd_messenger/BACKUP/frontend/public/index.html ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en" class="h-full">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <meta name="description" content="YSNRFD Messenger - A modern real-time messaging application">
8
+ <meta name="theme-color" content="#3b82f6">
9
+ <title>YSNRFD Messenger</title>
10
+ </head>
11
+ <body class="h-full bg-gray-50 dark:bg-gray-900">
12
+ <div id="root"></div>
13
+ <script type="module" src="/src/main.jsx"></script>
14
+ </body>
15
+ </html>
ysnrfd_messenger/BACKUP/frontend/public/manifest.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "YSNRFD Messenger",
3
+ "short_name": "YSNRFD",
4
+ "description": "A modern real-time messaging application with file sharing capabilities",
5
+ "start_url": "/",
6
+ "display": "standalone",
7
+ "background_color": "#ffffff",
8
+ "theme_color": "#3b82f6",
9
+ "orientation": "portrait-primary",
10
+ "icons": [
11
+ {
12
+ "src": "/icon-192.png",
13
+ "sizes": "192x192",
14
+ "type": "image/png"
15
+ },
16
+ {
17
+ "src": "/icon-512.png",
18
+ "sizes": "512x512",
19
+ "type": "image/png"
20
+ }
21
+ ],
22
+ "categories": ["social", "communication"],
23
+ "lang": "en"
24
+ }
ysnrfd_messenger/BACKUP/frontend/public/sw.js ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const CACHE_NAME = 'ysnrfd-messenger-v1';
2
+ const urlsToCache = [
3
+ '/',
4
+ '/static/js/bundle.js',
5
+ '/static/css/main.css',
6
+ '/manifest.json',
7
+ '/icon-192.png',
8
+ '/icon-512.png'
9
+ ];
10
+
11
+ self.addEventListener('install', (event) => {
12
+ event.waitUntil(
13
+ caches.open(CACHE_NAME)
14
+ .then((cache) => cache.addAll(urlsToCache))
15
+ );
16
+ });
17
+
18
+ self.addEventListener('fetch', (event) => {
19
+ event.respondWith(
20
+ caches.match(event.request)
21
+ .then((response) => {
22
+ if (response) {
23
+ return response;
24
+ }
25
+ return fetch(event.request);
26
+ }
27
+ )
28
+ );
29
+ });
30
+
31
+ self.addEventListener('activate', (event) => {
32
+ event.waitUntil(
33
+ caches.keys().then((cacheNames) => {
34
+ return Promise.all(
35
+ cacheNames.map((cacheName) => {
36
+ if (cacheName !== CACHE_NAME) {
37
+ return caches.delete(cacheName);
38
+ }
39
+ })
40
+ );
41
+ })
42
+ );
43
+ });
ysnrfd_messenger/BACKUP/frontend/src/App.css ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Additional custom styles for the app */
2
+
3
+ /* Smooth transitions for theme switching */
4
+ * {
5
+ transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
6
+ }
7
+
8
+ /* Custom focus styles */
9
+ .focus-ring:focus {
10
+ outline: 2px solid #3b82f6;
11
+ outline-offset: 2px;
12
+ }
13
+
14
+ /* Mobile optimizations */
15
+ @media (max-width: 768px) {
16
+ .mobile-hidden {
17
+ display: none;
18
+ }
19
+
20
+ .mobile-full {
21
+ width: 100vw;
22
+ height: 100vh;
23
+ }
24
+ }
25
+
26
+ /* Print styles */
27
+ @media print {
28
+ .no-print {
29
+ display: none !important;
30
+ }
31
+ }
32
+
33
+ /* High contrast mode support */
34
+ @media (prefers-contrast: high) {
35
+ .btn-primary {
36
+ border: 2px solid currentColor;
37
+ }
38
+ }
39
+
40
+ /* Reduced motion support */
41
+ @media (prefers-reduced-motion: reduce) {
42
+ * {
43
+ animation-duration: 0.01ms !important;
44
+ animation-iteration-count: 1 !important;
45
+ transition-duration: 0.01ms !important;
46
+ }
47
+ }
ysnrfd_messenger/BACKUP/frontend/src/App.jsx ADDED
@@ -0,0 +1,259 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState, useEffect } from 'react';
2
+ import { authService, testCors } from './services/api';
3
+ import Dashboard from './components/Dashboard/Dashboard';
4
+
5
+ function App() {
6
+ const [user, setUser] = useState(null);
7
+ const [isLogin, setIsLogin] = useState(true);
8
+ const [formData, setFormData] = useState({
9
+ username: '',
10
+ email: '',
11
+ password: '',
12
+ displayName: ''
13
+ });
14
+ const [loading, setLoading] = useState(false);
15
+ const [error, setError] = useState('');
16
+ const [corsWorking, setCorsWorking] = useState(false);
17
+
18
+ // Check if user is already logged in (from localStorage)
19
+ useEffect(() => {
20
+ testCorsConnection();
21
+ checkExistingAuth();
22
+ }, []);
23
+
24
+ const checkExistingAuth = async () => {
25
+ const token = localStorage.getItem('token');
26
+ const userData = localStorage.getItem('user');
27
+
28
+ if (token && userData) {
29
+ try {
30
+ // Verify token is still valid by calling /api/auth/me
31
+ const response = await authService.getMe();
32
+ setUser(response.user);
33
+ } catch (error) {
34
+ // Token is invalid, clear storage
35
+ localStorage.removeItem('token');
36
+ localStorage.removeItem('user');
37
+ console.log('Session expired, please login again');
38
+ }
39
+ }
40
+ };
41
+
42
+ const testCorsConnection = async () => {
43
+ try {
44
+ const result = await testCors();
45
+ setCorsWorking(true);
46
+ console.log('CORS test passed:', result);
47
+ } catch (error) {
48
+ setCorsWorking(false);
49
+ console.error('CORS test failed:', error);
50
+ }
51
+ };
52
+
53
+ const handleSubmit = async (e) => {
54
+ e.preventDefault();
55
+ setLoading(true);
56
+ setError('');
57
+
58
+ try {
59
+ let response;
60
+ if (isLogin) {
61
+ // Login
62
+ response = await authService.login({
63
+ email: formData.email,
64
+ password: formData.password
65
+ });
66
+ } else {
67
+ // Register
68
+ response = await authService.register(formData);
69
+ }
70
+
71
+ // Set the user state and store in localStorage
72
+ setUser(response.user);
73
+ localStorage.setItem('token', response.token);
74
+ localStorage.setItem('user', JSON.stringify(response.user));
75
+
76
+ // Clear form
77
+ setFormData({
78
+ username: '',
79
+ email: '',
80
+ password: '',
81
+ displayName: ''
82
+ });
83
+
84
+ } catch (error) {
85
+ console.error('Auth error details:', error);
86
+ setError(error.error || 'Something went wrong! Please check the console for details.');
87
+ } finally {
88
+ setLoading(false);
89
+ }
90
+ };
91
+
92
+ const handleLogout = () => {
93
+ setUser(null);
94
+ localStorage.removeItem('token');
95
+ localStorage.removeItem('user');
96
+ };
97
+
98
+ const handleChange = (e) => {
99
+ setFormData(prev => ({
100
+ ...prev,
101
+ [e.target.name]: e.target.value
102
+ }));
103
+ setError('');
104
+ };
105
+
106
+ // If user is logged in, show the Dashboard
107
+ if (user) {
108
+ return <Dashboard user={user} onLogout={handleLogout} />;
109
+ }
110
+
111
+ // Otherwise, show the login/signup form
112
+ return (
113
+ <div className="min-h-screen bg-gradient-to-br from-blue-50 to-indigo-100 flex items-center justify-center p-4">
114
+ <div className="max-w-md w-full bg-white rounded-2xl shadow-xl overflow-hidden">
115
+ {/* Header */}
116
+ <div className="bg-gradient-to-r from-blue-600 to-indigo-700 p-8 text-center">
117
+ <h1 className="text-3xl font-bold text-white mb-2">YSNRFD Messenger</h1>
118
+ <p className="text-blue-100">Connect with anyone, anywhere</p>
119
+ </div>
120
+
121
+ {/* Form */}
122
+ <div className="p-8">
123
+ {/* Connection Status */}
124
+ <div className={`mb-4 p-3 rounded-lg text-center text-sm ${
125
+ corsWorking
126
+ ? 'bg-green-50 text-green-700 border border-green-200'
127
+ : 'bg-yellow-50 text-yellow-700 border border-yellow-200'
128
+ }`}>
129
+ {corsWorking ? (
130
+ <span>✅ Backend connection working!</span>
131
+ ) : (
132
+ <span>⚠️ Checking backend connection...</span>
133
+ )}
134
+ </div>
135
+
136
+ {/* Toggle */}
137
+ <div className="flex mb-6 bg-gray-100 rounded-lg p-1">
138
+ <button
139
+ type="button"
140
+ onClick={() => setIsLogin(true)}
141
+ className={`flex-1 py-2 px-4 rounded-md transition-colors ${
142
+ isLogin ? 'bg-white shadow-sm text-blue-600' : 'text-gray-600'
143
+ }`}
144
+ >
145
+ Sign In
146
+ </button>
147
+ <button
148
+ type="button"
149
+ onClick={() => setIsLogin(false)}
150
+ className={`flex-1 py-2 px-4 rounded-md transition-colors ${
151
+ !isLogin ? 'bg-white shadow-sm text-blue-600' : 'text-gray-600'
152
+ }`}
153
+ >
154
+ Sign Up
155
+ </button>
156
+ </div>
157
+
158
+ {/* Error Message */}
159
+ {error && (
160
+ <div className="mb-4 p-3 bg-red-50 border border-red-200 rounded-lg">
161
+ <p className="text-red-600 text-sm font-medium">Error: {error}</p>
162
+ </div>
163
+ )}
164
+
165
+ <form onSubmit={handleSubmit} className="space-y-4">
166
+ {!isLogin && (
167
+ <>
168
+ <div>
169
+ <label className="block text-sm font-medium text-gray-700 mb-1">
170
+ Username
171
+ </label>
172
+ <input
173
+ type="text"
174
+ name="username"
175
+ value={formData.username}
176
+ onChange={handleChange}
177
+ required
178
+ className="w-full px-4 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
179
+ placeholder="Choose a username"
180
+ />
181
+ </div>
182
+ <div>
183
+ <label className="block text-sm font-medium text-gray-700 mb-1">
184
+ Display Name
185
+ </label>
186
+ <input
187
+ type="text"
188
+ name="displayName"
189
+ value={formData.displayName}
190
+ onChange={handleChange}
191
+ required
192
+ className="w-full px-4 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
193
+ placeholder="Your display name"
194
+ />
195
+ </div>
196
+ </>
197
+ )}
198
+
199
+ <div>
200
+ <label className="block text-sm font-medium text-gray-700 mb-1">
201
+ Email
202
+ </label>
203
+ <input
204
+ type="email"
205
+ name="email"
206
+ value={formData.email}
207
+ onChange={handleChange}
208
+ required
209
+ className="w-full px-4 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
210
+ placeholder="Enter your email"
211
+ />
212
+ </div>
213
+
214
+ <div>
215
+ <label className="block text-sm font-medium text-gray-700 mb-1">
216
+ Password
217
+ </label>
218
+ <input
219
+ type="password"
220
+ name="password"
221
+ value={formData.password}
222
+ onChange={handleChange}
223
+ required
224
+ minLength="6"
225
+ className="w-full px-4 py-3 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent"
226
+ placeholder="Enter your password"
227
+ />
228
+ </div>
229
+
230
+ <button
231
+ type="submit"
232
+ disabled={loading || !corsWorking}
233
+ className="w-full bg-blue-600 text-white py-3 px-4 rounded-lg hover:bg-blue-700 transition-colors font-medium disabled:opacity-50 disabled:cursor-not-allowed"
234
+ >
235
+ {loading ? (
236
+ <div className="flex items-center justify-center">
237
+ <div className="animate-spin rounded-full h-5 w-5 border-b-2 border-white mr-2"></div>
238
+ {isLogin ? 'Signing In...' : 'Creating Account...'}
239
+ </div>
240
+ ) : (
241
+ isLogin ? 'Sign In' : 'Create Account'
242
+ )}
243
+ </button>
244
+ </form>
245
+
246
+ {/* Demo Note */}
247
+ <div className="mt-6 p-4 bg-blue-50 rounded-lg">
248
+ <p className="text-sm text-blue-700 text-center">
249
+ <strong>Welcome to YSNRFD Messenger!</strong><br />
250
+ After login, you'll see the full messaging interface
251
+ </p>
252
+ </div>
253
+ </div>
254
+ </div>
255
+ </div>
256
+ );
257
+ }
258
+
259
+ export default App;
ysnrfd_messenger/BACKUP/frontend/src/components/Auth/Login.jsx ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState, useEffect } from 'react';
2
+ import { Link, useNavigate } from 'react-router-dom';
3
+ import { Eye, EyeOff, Mail, Lock, MessageCircle } from 'lucide-react';
4
+ import { useAuth } from '../../contexts/AuthContext';
5
+ import { useTheme } from '../../contexts/ThemeContext';
6
+
7
+ const Login = () => {
8
+ const [formData, setFormData] = useState({
9
+ email: '',
10
+ password: ''
11
+ });
12
+ const [showPassword, setShowPassword] = useState(false);
13
+ const [isLoading, setIsLoading] = useState(false);
14
+
15
+ const { login, error, clearError } = useAuth();
16
+ const { theme, toggleTheme } = useTheme();
17
+ const navigate = useNavigate();
18
+
19
+ useEffect(() => {
20
+ clearError();
21
+ }, []);
22
+
23
+ const handleChange = (e) => {
24
+ const { name, value } = e.target;
25
+ setFormData(prev => ({
26
+ ...prev,
27
+ [name]: value
28
+ }));
29
+ if (error) clearError();
30
+ };
31
+
32
+ const handleSubmit = async (e) => {
33
+ e.preventDefault();
34
+ setIsLoading(true);
35
+
36
+ try {
37
+ await login(formData.email, formData.password);
38
+ navigate('/');
39
+ } catch (error) {
40
+ console.error('Login error:', error);
41
+ } finally {
42
+ setIsLoading(false);
43
+ }
44
+ };
45
+
46
+ return (
47
+ <div className="min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900 py-12 px-4 sm:px-6 lg:px-8">
48
+ <div className="max-w-md w-full space-y-8">
49
+ {/* Header */}
50
+ <div className="text-center">
51
+ <div className="flex items-center justify-center space-x-3 mb-6">
52
+ <MessageCircle className="h-12 w-12 text-primary-500" />
53
+ <div>
54
+ <h1 className="text-3xl font-bold text-gray-900 dark:text-white">YSNRFD</h1>
55
+ <p className="text-sm text-gray-600 dark:text-gray-400">Messenger</p>
56
+ </div>
57
+ </div>
58
+ <h2 className="text-2xl font-bold text-gray-900 dark:text-white">
59
+ Sign in to your account
60
+ </h2>
61
+ <p className="mt-2 text-sm text-gray-600 dark:text-gray-400">
62
+ Or{' '}
63
+ <Link
64
+ to="/register"
65
+ className="font-medium text-primary-500 hover:text-primary-600 transition-colors"
66
+ >
67
+ create a new account
68
+ </Link>
69
+ </p>
70
+ </div>
71
+
72
+ {/* Theme Toggle */}
73
+ <div className="flex justify-center">
74
+ <button
75
+ onClick={toggleTheme}
76
+ className="p-2 rounded-lg bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors"
77
+ >
78
+ {theme === 'dark' ? '🌙' : '☀️'}
79
+ </button>
80
+ </div>
81
+
82
+ {/* Error Message */}
83
+ {error && (
84
+ <div className="bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4">
85
+ <p className="text-sm text-red-600 dark:text-red-400">{error}</p>
86
+ </div>
87
+ )}
88
+
89
+ {/* Login Form */}
90
+ <form className="mt-8 space-y-6" onSubmit={handleSubmit}>
91
+ <div className="space-y-4">
92
+ {/* Email Field */}
93
+ <div>
94
+ <label htmlFor="email" className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">
95
+ Email Address
96
+ </label>
97
+ <div className="relative">
98
+ <div className="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
99
+ <Mail className="h-5 w-5 text-gray-400" />
100
+ </div>
101
+ <input
102
+ id="email"
103
+ name="email"
104
+ type="email"
105
+ autoComplete="email"
106
+ required
107
+ value={formData.email}
108
+ onChange={handleChange}
109
+ className="input-field pl-10"
110
+ placeholder="Enter your email"
111
+ />
112
+ </div>
113
+ </div>
114
+
115
+ {/* Password Field */}
116
+ <div>
117
+ <label htmlFor="password" className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">
118
+ Password
119
+ </label>
120
+ <div className="relative">
121
+ <div className="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
122
+ <Lock className="h-5 w-5 text-gray-400" />
123
+ </div>
124
+ <input
125
+ id="password"
126
+ name="password"
127
+ type={showPassword ? 'text' : 'password'}
128
+ autoComplete="current-password"
129
+ required
130
+ value={formData.password}
131
+ onChange={handleChange}
132
+ className="input-field pl-10 pr-10"
133
+ placeholder="Enter your password"
134
+ />
135
+ <button
136
+ type="button"
137
+ className="absolute inset-y-0 right-0 pr-3 flex items-center"
138
+ onClick={() => setShowPassword(!showPassword)}
139
+ >
140
+ {showPassword ? (
141
+ <EyeOff className="h-5 w-5 text-gray-400 hover:text-gray-600" />
142
+ ) : (
143
+ <Eye className="h-5 w-5 text-gray-400 hover:text-gray-600" />
144
+ )}
145
+ </button>
146
+ </div>
147
+ </div>
148
+ </div>
149
+
150
+ {/* Submit Button */}
151
+ <button
152
+ type="submit"
153
+ disabled={isLoading}
154
+ className="w-full btn-primary py-3 px-4 text-base font-medium disabled:opacity-50 disabled:cursor-not-allowed"
155
+ >
156
+ {isLoading ? (
157
+ <div className="flex items-center justify-center">
158
+ <div className="animate-spin rounded-full h-5 w-5 border-b-2 border-white mr-2"></div>
159
+ Signing in...
160
+ </div>
161
+ ) : (
162
+ 'Sign in'
163
+ )}
164
+ </button>
165
+
166
+ {/* Demo Info */}
167
+ <div className="text-center">
168
+ <p className="text-xs text-gray-500 dark:text-gray-400">
169
+ Demo: Use any email and password to test
170
+ </p>
171
+ </div>
172
+ </form>
173
+ </div>
174
+ </div>
175
+ );
176
+ };
177
+
178
+ export default Login;
ysnrfd_messenger/BACKUP/frontend/src/components/Auth/Register.jsx ADDED
@@ -0,0 +1,315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState, useEffect } from 'react';
2
+ import { Link, useNavigate } from 'react-router-dom';
3
+ import { Eye, EyeOff, Mail, Lock, User, MessageCircle } from 'lucide-react';
4
+ import { useAuth } from '../../contexts/AuthContext';
5
+ import { useTheme } from '../../contexts/ThemeContext';
6
+
7
+ const Register = () => {
8
+ const [formData, setFormData] = useState({
9
+ username: '',
10
+ email: '',
11
+ password: '',
12
+ displayName: '',
13
+ confirmPassword: ''
14
+ });
15
+ const [showPassword, setShowPassword] = useState(false);
16
+ const [showConfirmPassword, setShowConfirmPassword] = useState(false);
17
+ const [isLoading, setIsLoading] = useState(false);
18
+ const [validationErrors, setValidationErrors] = useState({});
19
+
20
+ const { register, error, clearError } = useAuth();
21
+ const { theme, toggleTheme } = useTheme();
22
+ const navigate = useNavigate();
23
+
24
+ useEffect(() => {
25
+ clearError();
26
+ }, []);
27
+
28
+ const validateForm = () => {
29
+ const errors = {};
30
+
31
+ if (formData.username.length < 3) {
32
+ errors.username = 'Username must be at least 3 characters';
33
+ }
34
+
35
+ if (!formData.email.match(/^\S+@\S+\.\S+$/)) {
36
+ errors.email = 'Please enter a valid email address';
37
+ }
38
+
39
+ if (formData.password.length < 6) {
40
+ errors.password = 'Password must be at least 6 characters';
41
+ }
42
+
43
+ if (formData.password !== formData.confirmPassword) {
44
+ errors.confirmPassword = 'Passwords do not match';
45
+ }
46
+
47
+ if (!formData.displayName.trim()) {
48
+ errors.displayName = 'Display name is required';
49
+ }
50
+
51
+ setValidationErrors(errors);
52
+ return Object.keys(errors).length === 0;
53
+ };
54
+
55
+ const handleChange = (e) => {
56
+ const { name, value } = e.target;
57
+ setFormData(prev => ({
58
+ ...prev,
59
+ [name]: value
60
+ }));
61
+
62
+ // Clear validation error for this field
63
+ if (validationErrors[name]) {
64
+ setValidationErrors(prev => ({
65
+ ...prev,
66
+ [name]: ''
67
+ }));
68
+ }
69
+
70
+ if (error) clearError();
71
+ };
72
+
73
+ const handleSubmit = async (e) => {
74
+ e.preventDefault();
75
+
76
+ if (!validateForm()) {
77
+ return;
78
+ }
79
+
80
+ setIsLoading(true);
81
+
82
+ try {
83
+ const { confirmPassword, ...registerData } = formData;
84
+ await register(registerData);
85
+ navigate('/');
86
+ } catch (error) {
87
+ console.error('Registration error:', error);
88
+ } finally {
89
+ setIsLoading(false);
90
+ }
91
+ };
92
+
93
+ return (
94
+ <div className="min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900 py-12 px-4 sm:px-6 lg:px-8">
95
+ <div className="max-w-md w-full space-y-8">
96
+ {/* Header */}
97
+ <div className="text-center">
98
+ <div className="flex items-center justify-center space-x-3 mb-6">
99
+ <MessageCircle className="h-12 w-12 text-primary-500" />
100
+ <div>
101
+ <h1 className="text-3xl font-bold text-gray-900 dark:text-white">YSNRFD</h1>
102
+ <p className="text-sm text-gray-600 dark:text-gray-400">Messenger</p>
103
+ </div>
104
+ </div>
105
+ <h2 className="text-2xl font-bold text-gray-900 dark:text-white">
106
+ Create your account
107
+ </h2>
108
+ <p className="mt-2 text-sm text-gray-600 dark:text-gray-400">
109
+ Or{' '}
110
+ <Link
111
+ to="/login"
112
+ className="font-medium text-primary-500 hover:text-primary-600 transition-colors"
113
+ >
114
+ sign in to existing account
115
+ </Link>
116
+ </p>
117
+ </div>
118
+
119
+ {/* Theme Toggle */}
120
+ <div className="flex justify-center">
121
+ <button
122
+ onClick={toggleTheme}
123
+ className="p-2 rounded-lg bg-gray-200 dark:bg-gray-700 text-gray-600 dark:text-gray-300 hover:bg-gray-300 dark:hover:bg-gray-600 transition-colors"
124
+ >
125
+ {theme === 'dark' ? '🌙' : '☀️'}
126
+ </button>
127
+ </div>
128
+
129
+ {/* Error Message */}
130
+ {error && (
131
+ <div className="bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4">
132
+ <p className="text-sm text-red-600 dark:text-red-400">{error}</p>
133
+ </div>
134
+ )}
135
+
136
+ {/* Registration Form */}
137
+ <form className="mt-8 space-y-6" onSubmit={handleSubmit}>
138
+ <div className="space-y-4">
139
+ {/* Username Field */}
140
+ <div>
141
+ <label htmlFor="username" className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">
142
+ Username
143
+ </label>
144
+ <div className="relative">
145
+ <div className="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
146
+ <User className="h-5 w-5 text-gray-400" />
147
+ </div>
148
+ <input
149
+ id="username"
150
+ name="username"
151
+ type="text"
152
+ autoComplete="username"
153
+ required
154
+ value={formData.username}
155
+ onChange={handleChange}
156
+ className={`input-field pl-10 ${validationErrors.username ? 'border-red-500' : ''}`}
157
+ placeholder="Choose a username"
158
+ />
159
+ </div>
160
+ {validationErrors.username && (
161
+ <p className="mt-1 text-sm text-red-600 dark:text-red-400">{validationErrors.username}</p>
162
+ )}
163
+ </div>
164
+
165
+ {/* Display Name Field */}
166
+ <div>
167
+ <label htmlFor="displayName" className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">
168
+ Display Name
169
+ </label>
170
+ <input
171
+ id="displayName"
172
+ name="displayName"
173
+ type="text"
174
+ autoComplete="name"
175
+ required
176
+ value={formData.displayName}
177
+ onChange={handleChange}
178
+ className={`input-field ${validationErrors.displayName ? 'border-red-500' : ''}`}
179
+ placeholder="Enter your display name"
180
+ />
181
+ {validationErrors.displayName && (
182
+ <p className="mt-1 text-sm text-red-600 dark:text-red-400">{validationErrors.displayName}</p>
183
+ )}
184
+ </div>
185
+
186
+ {/* Email Field */}
187
+ <div>
188
+ <label htmlFor="email" className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">
189
+ Email Address
190
+ </label>
191
+ <div className="relative">
192
+ <div className="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
193
+ <Mail className="h-5 w-5 text-gray-400" />
194
+ </div>
195
+ <input
196
+ id="email"
197
+ name="email"
198
+ type="email"
199
+ autoComplete="email"
200
+ required
201
+ value={formData.email}
202
+ onChange={handleChange}
203
+ className={`input-field pl-10 ${validationErrors.email ? 'border-red-500' : ''}`}
204
+ placeholder="Enter your email"
205
+ />
206
+ </div>
207
+ {validationErrors.email && (
208
+ <p className="mt-1 text-sm text-red-600 dark:text-red-400">{validationErrors.email}</p>
209
+ )}
210
+ </div>
211
+
212
+ {/* Password Field */}
213
+ <div>
214
+ <label htmlFor="password" className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">
215
+ Password
216
+ </label>
217
+ <div className="relative">
218
+ <div className="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
219
+ <Lock className="h-5 w-5 text-gray-400" />
220
+ </div>
221
+ <input
222
+ id="password"
223
+ name="password"
224
+ type={showPassword ? 'text' : 'password'}
225
+ autoComplete="new-password"
226
+ required
227
+ value={formData.password}
228
+ onChange={handleChange}
229
+ className={`input-field pl-10 pr-10 ${validationErrors.password ? 'border-red-500' : ''}`}
230
+ placeholder="Create a password"
231
+ />
232
+ <button
233
+ type="button"
234
+ className="absolute inset-y-0 right-0 pr-3 flex items-center"
235
+ onClick={() => setShowPassword(!showPassword)}
236
+ >
237
+ {showPassword ? (
238
+ <EyeOff className="h-5 w-5 text-gray-400 hover:text-gray-600" />
239
+ ) : (
240
+ <Eye className="h-5 w-5 text-gray-400 hover:text-gray-600" />
241
+ )}
242
+ </button>
243
+ </div>
244
+ {validationErrors.password && (
245
+ <p className="mt-1 text-sm text-red-600 dark:text-red-400">{validationErrors.password}</p>
246
+ )}
247
+ </div>
248
+
249
+ {/* Confirm Password Field */}
250
+ <div>
251
+ <label htmlFor="confirmPassword" className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">
252
+ Confirm Password
253
+ </label>
254
+ <div className="relative">
255
+ <div className="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
256
+ <Lock className="h-5 w-5 text-gray-400" />
257
+ </div>
258
+ <input
259
+ id="confirmPassword"
260
+ name="confirmPassword"
261
+ type={showConfirmPassword ? 'text' : 'password'}
262
+ autoComplete="new-password"
263
+ required
264
+ value={formData.confirmPassword}
265
+ onChange={handleChange}
266
+ className={`input-field pl-10 pr-10 ${validationErrors.confirmPassword ? 'border-red-500' : ''}`}
267
+ placeholder="Confirm your password"
268
+ />
269
+ <button
270
+ type="button"
271
+ className="absolute inset-y-0 right-0 pr-3 flex items-center"
272
+ onClick={() => setShowConfirmPassword(!showConfirmPassword)}
273
+ >
274
+ {showConfirmPassword ? (
275
+ <EyeOff className="h-5 w-5 text-gray-400 hover:text-gray-600" />
276
+ ) : (
277
+ <Eye className="h-5 w-5 text-gray-400 hover:text-gray-600" />
278
+ )}
279
+ </button>
280
+ </div>
281
+ {validationErrors.confirmPassword && (
282
+ <p className="mt-1 text-sm text-red-600 dark:text-red-400">{validationErrors.confirmPassword}</p>
283
+ )}
284
+ </div>
285
+ </div>
286
+
287
+ {/* Submit Button */}
288
+ <button
289
+ type="submit"
290
+ disabled={isLoading}
291
+ className="w-full btn-primary py-3 px-4 text-base font-medium disabled:opacity-50 disabled:cursor-not-allowed"
292
+ >
293
+ {isLoading ? (
294
+ <div className="flex items-center justify-center">
295
+ <div className="animate-spin rounded-full h-5 w-5 border-b-2 border-white mr-2"></div>
296
+ Creating account...
297
+ </div>
298
+ ) : (
299
+ 'Create Account'
300
+ )}
301
+ </button>
302
+
303
+ {/* Terms Notice */}
304
+ <div className="text-center">
305
+ <p className="text-xs text-gray-500 dark:text-gray-400">
306
+ By creating an account, you agree to our Terms of Service and Privacy Policy
307
+ </p>
308
+ </div>
309
+ </form>
310
+ </div>
311
+ </div>
312
+ );
313
+ };
314
+
315
+ export default Register;
ysnrfd_messenger/BACKUP/frontend/src/components/Chat/ChatArea.jsx ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState, useEffect, useRef } from 'react';
2
+ import { ArrowLeft, Users, MoreVertical } from 'lucide-react';
3
+ import { useScreenSize } from '../../utils/responsive';
4
+ import { useAuth } from '../../contexts/AuthContext';
5
+ import MessageList from './MessageList';
6
+ import MessageInput from './MessageInput';
7
+ import TypingIndicator from './TypingIndicator';
8
+
9
+ const ChatArea = ({ conversation, messages, onNewMessage, onConversationUpdate }) => {
10
+ const { user } = useAuth();
11
+ const { isMobile } = useScreenSize();
12
+ const [showSidebar, setShowSidebar] = useState(!isMobile);
13
+ const [typingUsers, setTypingUsers] = useState([]);
14
+
15
+ const getConversationTitle = () => {
16
+ if (conversation.type === 'direct') {
17
+ const otherParticipant = conversation.participants.find(p => p.user._id !== user.id);
18
+ return otherParticipant?.user.displayName || 'Unknown User';
19
+ } else {
20
+ return conversation.name;
21
+ }
22
+ };
23
+
24
+ const getParticipantCount = () => {
25
+ if (conversation.type === 'direct') {
26
+ return '1 member';
27
+ } else {
28
+ return `${conversation.participants.length} members`;
29
+ }
30
+ };
31
+
32
+ const handleNewMessage = (message) => {
33
+ onNewMessage(message);
34
+ onConversationUpdate(conversation._id, message);
35
+ };
36
+
37
+ const handleTypingStart = (data) => {
38
+ if (data.userId !== user.id) {
39
+ setTypingUsers(prev => [...prev.filter(id => id !== data.userId), data.userId]);
40
+ }
41
+ };
42
+
43
+ const handleTypingStop = (data) => {
44
+ setTypingUsers(prev => prev.filter(id => id !== data.userId));
45
+ };
46
+
47
+ return (
48
+ <div className="flex flex-col h-full bg-white dark:bg-gray-800">
49
+ {/* Chat Header */}
50
+ <div className="flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700">
51
+ <div className="flex items-center space-x-3">
52
+ {isMobile && (
53
+ <button
54
+ onClick={() => setShowSidebar(true)}
55
+ className="p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors"
56
+ >
57
+ <ArrowLeft className="w-5 h-5 text-gray-600 dark:text-gray-400" />
58
+ </button>
59
+ )}
60
+
61
+ <div className="flex items-center space-x-3">
62
+ <div className="w-10 h-10 bg-gradient-to-br from-primary-400 to-primary-600 rounded-full flex items-center justify-center text-white font-medium text-sm">
63
+ {conversation.type === 'direct' ? (
64
+ getConversationTitle().charAt(0).toUpperCase()
65
+ ) : (
66
+ <Users className="w-5 h-5" />
67
+ )}
68
+ </div>
69
+ <div>
70
+ <h2 className="text-lg font-semibold text-gray-900 dark:text-white">
71
+ {getConversationTitle()}
72
+ </h2>
73
+ <div className="flex items-center space-x-2 text-sm text-gray-500 dark:text-gray-400">
74
+ <span>{getParticipantCount()}</span>
75
+ {typingUsers.length > 0 && (
76
+ <>
77
+ <span>•</span>
78
+ <TypingIndicator userIds={typingUsers} />
79
+ </>
80
+ )}
81
+ </div>
82
+ </div>
83
+ </div>
84
+ </div>
85
+
86
+ <div className="flex items-center space-x-2">
87
+ <button className="p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors">
88
+ <MoreVertical className="w-5 h-5 text-gray-600 dark:text-gray-400" />
89
+ </button>
90
+ </div>
91
+ </div>
92
+
93
+ {/* Messages Area */}
94
+ <div className="flex-1 overflow-hidden">
95
+ <MessageList
96
+ messages={messages}
97
+ conversation={conversation}
98
+ onTypingStart={handleTypingStart}
99
+ onTypingStop={handleTypingStop}
100
+ />
101
+ </div>
102
+
103
+ {/* Message Input */}
104
+ <MessageInput
105
+ conversation={conversation}
106
+ onSendMessage={handleNewMessage}
107
+ onTypingStart={handleTypingStart}
108
+ onTypingStop={handleTypingStop}
109
+ />
110
+
111
+ {/* Mobile Sidebar Overlay */}
112
+ {isMobile && showSidebar && (
113
+ <div className="fixed inset-0 z-40 lg:hidden">
114
+ <div className="absolute inset-0 bg-black bg-opacity-50" onClick={() => setShowSidebar(false)}></div>
115
+ </div>
116
+ )}
117
+ </div>
118
+ );
119
+ };
120
+
121
+ export default ChatArea;
ysnrfd_messenger/BACKUP/frontend/src/components/Chat/MessageBubble.jsx ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState } from 'react';
2
+ import { Check, CheckCheck, Download, Eye, Play, FileText, Image, Music } from 'lucide-react';
3
+ import { formatMessageTime } from '../../utils/dateFormatter';
4
+ import { formatFileSize } from '../../utils/fileValidation';
5
+ import { useAuth } from '../../contexts/AuthContext';
6
+
7
+ const MessageBubble = ({ message, isOwn, showAvatar, onRead }) => {
8
+ const [imageError, setImageError] = useState(false);
9
+ const [showImagePreview, setShowImagePreview] = useState(false);
10
+ const { user } = useAuth();
11
+
12
+ const handleDownload = (url, filename) => {
13
+ // Create a temporary link to trigger download
14
+ const link = document.createElement('a');
15
+ link.href = url;
16
+ link.download = filename;
17
+ document.body.appendChild(link);
18
+ link.click();
19
+ document.body.removeChild(link);
20
+ };
21
+
22
+ const getReadStatus = () => {
23
+ if (!isOwn) return null;
24
+
25
+ const readByCount = message.readBy?.length || 0;
26
+ const participantCount = message.conversation?.participants?.length || 1;
27
+
28
+ if (readByCount >= participantCount - 1) {
29
+ return <CheckCheck className="w-4 h-4 text-blue-500" />;
30
+ } else if (message.status === 'delivered') {
31
+ return <CheckCheck className="w-4 h-4 text-gray-400" />;
32
+ } else {
33
+ return <Check className="w-4 h-4 text-gray-400" />;
34
+ }
35
+ };
36
+
37
+ const renderAttachment = () => {
38
+ if (!message.attachment) return null;
39
+
40
+ const { url, originalName, mimeType, size, thumbnail } = message.attachment;
41
+
42
+ // Image files
43
+ if (mimeType.startsWith('image/')) {
44
+ return (
45
+ <div className="mt-2">
46
+ <div className="relative group">
47
+ <img
48
+ src={imageError ? '/placeholder-image.jpg' : (thumbnail || url)}
49
+ alt={originalName}
50
+ className="max-w-xs rounded-lg cursor-pointer hover:opacity-90 transition-opacity border border-gray-200 dark:border-gray-600"
51
+ onError={() => setImageError(true)}
52
+ onClick={() => setShowImagePreview(true)}
53
+ />
54
+ <div className="absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity flex space-x-1">
55
+ <button
56
+ onClick={(e) => {
57
+ e.stopPropagation();
58
+ handleDownload(url, originalName);
59
+ }}
60
+ className="bg-black bg-opacity-50 text-white p-1.5 rounded-lg hover:bg-opacity-70 transition-colors"
61
+ title="Download"
62
+ >
63
+ <Download size={16} />
64
+ </button>
65
+ <button
66
+ onClick={(e) => {
67
+ e.stopPropagation();
68
+ setShowImagePreview(true);
69
+ }}
70
+ className="bg-black bg-opacity-50 text-white p-1.5 rounded-lg hover:bg-opacity-70 transition-colors"
71
+ title="Preview"
72
+ >
73
+ <Eye size={16} />
74
+ </button>
75
+ </div>
76
+ </div>
77
+ <div className="flex justify-between items-center mt-2 text-sm">
78
+ <span className="text-gray-600 dark:text-gray-400">{originalName}</span>
79
+ <span className="text-gray-500 dark:text-gray-500">{formatFileSize(size)}</span>
80
+ </div>
81
+ </div>
82
+ );
83
+ }
84
+
85
+ // Audio files
86
+ if (mimeType.startsWith('audio/')) {
87
+ return (
88
+ <div className="mt-2">
89
+ <div className="flex items-center space-x-3 p-4 bg-gray-50 dark:bg-gray-700 rounded-lg border border-gray-200 dark:border-gray-600">
90
+ <div className="flex-shrink-0">
91
+ <Music className="w-8 h-8 text-primary-500" />
92
+ </div>
93
+ <div className="flex-1 min-w-0">
94
+ <p className="text-sm font-medium text-gray-900 dark:text-white truncate">
95
+ {originalName}
96
+ </p>
97
+ <p className="text-sm text-gray-500 dark:text-gray-400">
98
+ {formatFileSize(size)} • Audio
99
+ </p>
100
+ </div>
101
+ <button
102
+ onClick={() => handleDownload(url, originalName)}
103
+ className="flex-shrink-0 p-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-600 rounded-lg transition-colors"
104
+ title="Download"
105
+ >
106
+ <Download size={18} />
107
+ </button>
108
+ </div>
109
+ </div>
110
+ );
111
+ }
112
+
113
+ // Document files (PDF, TXT)
114
+ return (
115
+ <div className="mt-2">
116
+ <div className="flex items-center space-x-3 p-4 bg-gray-50 dark:bg-gray-700 rounded-lg border border-gray-200 dark:border-gray-600">
117
+ <div className="flex-shrink-0">
118
+ <FileText className="w-8 h-8 text-primary-500" />
119
+ </div>
120
+ <div className="flex-1 min-w-0">
121
+ <p className="text-sm font-medium text-gray-900 dark:text-white truncate">
122
+ {originalName}
123
+ </p>
124
+ <p className="text-sm text-gray-500 dark:text-gray-400">
125
+ {formatFileSize(size)} • {mimeType.split('/')[1].toUpperCase()}
126
+ </p>
127
+ </div>
128
+ <button
129
+ onClick={() => handleDownload(url, originalName)}
130
+ className="flex-shrink-0 p-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-600 rounded-lg transition-colors"
131
+ title="Download"
132
+ >
133
+ <Download size={18} />
134
+ </button>
135
+ </div>
136
+ </div>
137
+ );
138
+ };
139
+
140
+ // Image Preview Modal
141
+ if (showImagePreview && message.attachment) {
142
+ return (
143
+ <>
144
+ <div className={`flex ${isOwn ? 'justify-end' : 'justify-start'} mb-4`}>
145
+ <div className={`max-w-xs lg:max-w-md px-4 py-2 rounded-2xl ${
146
+ isOwn
147
+ ? 'bg-primary-500 text-white rounded-br-none'
148
+ : 'bg-gray-200 dark:bg-gray-700 text-gray-900 dark:text-white rounded-bl-none'
149
+ }`}>
150
+ {message.content && <p className="whitespace-pre-wrap">{message.content}</p>}
151
+ {renderAttachment()}
152
+ <div className={`flex items-center justify-between text-xs mt-1 ${isOwn ? 'text-primary-100' : 'text-gray-500'}`}>
153
+ <span>{formatMessageTime(message.createdAt)}</span>
154
+ {getReadStatus()}
155
+ </div>
156
+ </div>
157
+ </div>
158
+
159
+ {/* Image Preview Overlay */}
160
+ <div
161
+ className="fixed inset-0 bg-black bg-opacity-90 z-50 flex items-center justify-center p-4"
162
+ onClick={() => setShowImagePreview(false)}
163
+ >
164
+ <div
165
+ className="relative max-w-4xl max-h-full"
166
+ onClick={(e) => e.stopPropagation()}
167
+ >
168
+ <img
169
+ src={message.attachment.url}
170
+ alt={message.attachment.originalName}
171
+ className="max-w-full max-h-full object-contain rounded-lg"
172
+ />
173
+ <div className="absolute top-4 right-4 flex space-x-2">
174
+ <button
175
+ onClick={() => handleDownload(message.attachment.url, message.attachment.originalName)}
176
+ className="bg-white bg-opacity-20 text-white p-3 rounded-lg hover:bg-opacity-30 transition-colors backdrop-blur-sm"
177
+ title="Download"
178
+ >
179
+ <Download size={20} />
180
+ </button>
181
+ <button
182
+ onClick={() => setShowImagePreview(false)}
183
+ className="bg-white bg-opacity-20 text-white p-3 rounded-lg hover:bg-opacity-30 transition-colors backdrop-blur-sm"
184
+ title="Close"
185
+ >
186
+ <svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
187
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
188
+ </svg>
189
+ </button>
190
+ </div>
191
+ <div className="absolute bottom-4 left-4 right-4 bg-black bg-opacity-50 text-white p-3 rounded-lg backdrop-blur-sm">
192
+ <p className="text-sm truncate">{message.attachment.originalName}</p>
193
+ <p className="text-xs text-gray-300">{formatFileSize(message.attachment.size)}</p>
194
+ </div>
195
+ </div>
196
+ </div>
197
+ </>
198
+ );
199
+ }
200
+
201
+ return (
202
+ <div className={`flex ${isOwn ? 'justify-end' : 'justify-start'} mb-4`}>
203
+ {!isOwn && showAvatar && (
204
+ <div className="flex-shrink-0 mr-2 self-end">
205
+ <div className="w-8 h-8 bg-gradient-to-br from-primary-400 to-primary-600 rounded-full flex items-center justify-center text-white text-xs font-medium">
206
+ {message.sender?.displayName?.charAt(0).toUpperCase() || 'U'}
207
+ </div>
208
+ </div>
209
+ )}
210
+
211
+ <div className={`max-w-xs lg:max-w-md px-4 py-2 rounded-2xl ${
212
+ isOwn
213
+ ? 'message-bubble-own'
214
+ : 'message-bubble-other'
215
+ }`}>
216
+ {!isOwn && (
217
+ <div className="text-xs font-medium text-gray-700 dark:text-gray-300 mb-1">
218
+ {message.sender?.displayName}
219
+ </div>
220
+ )}
221
+
222
+ {message.content && (
223
+ <p className="whitespace-pre-wrap break-words">{message.content}</p>
224
+ )}
225
+
226
+ {renderAttachment()}
227
+
228
+ <div className={`flex items-center justify-between text-xs mt-1 ${
229
+ isOwn ? 'text-primary-100' : 'text-gray-500 dark:text-gray-400'
230
+ }`}>
231
+ <span>{formatMessageTime(message.createdAt)}</span>
232
+ <div className="flex items-center space-x-1">
233
+ {message.isEdited && <span className="italic">edited</span>}
234
+ {getReadStatus()}
235
+ </div>
236
+ </div>
237
+ </div>
238
+ </div>
239
+ );
240
+ };
241
+
242
+ export default MessageBubble;
ysnrfd_messenger/BACKUP/frontend/src/components/Chat/MessageInput.jsx ADDED
@@ -0,0 +1,280 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState, useRef, useCallback } from 'react';
2
+ import { Send, Paperclip, Smile, X, Image, Music, FileText } from 'lucide-react';
3
+ import { useWebSocket } from '../../hooks/useWebSocket';
4
+ import { useFileUpload } from '../../hooks/useFileUpload';
5
+ import { validateFile, formatFileSize } from '../../utils/fileValidation';
6
+
7
+ const MessageInput = ({ conversation, onSendMessage, onTypingStart, onTypingStop }) => {
8
+ const [message, setMessage] = useState('');
9
+ const [isTyping, setIsTyping] = useState(false);
10
+ const [fileUpload, setFileUpload] = useState(null);
11
+ const fileInputRef = useRef();
12
+ const textareaRef = useRef();
13
+
14
+ const { sendMessage } = useWebSocket();
15
+ const { uploadFile, uploading, progress, error: uploadError, reset: resetUpload } = useFileUpload();
16
+
17
+ const typingTimeoutRef = useRef();
18
+
19
+ const handleSubmit = async (e) => {
20
+ e.preventDefault();
21
+
22
+ if (!message.trim() && !fileUpload) return;
23
+
24
+ // Reset typing
25
+ stopTyping();
26
+
27
+ if (fileUpload) {
28
+ // Send file message
29
+ await sendFileMessage();
30
+ } else {
31
+ // Send text message
32
+ sendTextMessage();
33
+ }
34
+
35
+ setMessage('');
36
+ setFileUpload(null);
37
+ resetUpload();
38
+ };
39
+
40
+ const sendTextMessage = () => {
41
+ if (!message.trim()) return;
42
+
43
+ const messageData = {
44
+ conversationId: conversation._id,
45
+ content: message.trim(),
46
+ type: 'text'
47
+ };
48
+
49
+ sendMessage('message:send', messageData);
50
+ onSendMessage({
51
+ ...messageData,
52
+ _id: `temp-${Date.now()}`,
53
+ sender: { _id: 'current-user' },
54
+ createdAt: new Date(),
55
+ status: 'sending'
56
+ });
57
+ };
58
+
59
+ const sendFileMessage = async () => {
60
+ if (!fileUpload) return;
61
+
62
+ try {
63
+ const response = await uploadFile(fileUpload.file);
64
+
65
+ const messageData = {
66
+ conversationId: conversation._id,
67
+ content: message.trim() || `Sent ${getFileTypeDescription(fileUpload.file.type)}`,
68
+ type: getMessageType(fileUpload.file.type),
69
+ attachment: {
70
+ url: response.file.url,
71
+ filename: response.file.fileName,
72
+ originalName: fileUpload.file.name,
73
+ mimeType: fileUpload.file.type,
74
+ size: fileUpload.file.size,
75
+ thumbnail: response.file.thumbnail
76
+ }
77
+ };
78
+
79
+ sendMessage('message:send', messageData);
80
+ onSendMessage({
81
+ ...messageData,
82
+ _id: `temp-${Date.now()}`,
83
+ sender: { _id: 'current-user' },
84
+ createdAt: new Date(),
85
+ status: 'sending'
86
+ });
87
+ } catch (error) {
88
+ console.error('Failed to send file message:', error);
89
+ }
90
+ };
91
+
92
+ const handleInputChange = (e) => {
93
+ setMessage(e.target.value);
94
+
95
+ if (!isTyping) {
96
+ startTyping();
97
+ }
98
+
99
+ // Reset typing timeout
100
+ clearTimeout(typingTimeoutRef.current);
101
+ typingTimeoutRef.current = setTimeout(stopTyping, 1000);
102
+ };
103
+
104
+ const startTyping = () => {
105
+ if (!isTyping) {
106
+ setIsTyping(true);
107
+ sendMessage('typing:start', { conversationId: conversation._id });
108
+ }
109
+ };
110
+
111
+ const stopTyping = () => {
112
+ if (isTyping) {
113
+ setIsTyping(false);
114
+ sendMessage('typing:stop', { conversationId: conversation._id });
115
+ }
116
+ };
117
+
118
+ const handleFileSelect = async (e) => {
119
+ const file = e.target.files[0];
120
+ if (!file) return;
121
+
122
+ try {
123
+ validateFile(file);
124
+
125
+ setFileUpload({
126
+ file,
127
+ name: file.name,
128
+ size: file.size,
129
+ type: file.type
130
+ });
131
+
132
+ // Reset file input
133
+ fileInputRef.current.value = '';
134
+ } catch (error) {
135
+ alert(error.message);
136
+ }
137
+ };
138
+
139
+ const removeFile = () => {
140
+ setFileUpload(null);
141
+ resetUpload();
142
+ };
143
+
144
+ const getFileTypeDescription = (mimeType) => {
145
+ if (mimeType.startsWith('image/')) return 'an image';
146
+ if (mimeType.startsWith('audio/')) return 'an audio file';
147
+ if (mimeType === 'application/pdf') return 'a PDF';
148
+ if (mimeType.startsWith('text/')) return 'a text file';
149
+ return 'a file';
150
+ };
151
+
152
+ const getMessageType = (mimeType) => {
153
+ if (mimeType.startsWith('image/')) return 'image';
154
+ if (mimeType.startsWith('audio/')) return 'audio';
155
+ return 'file';
156
+ };
157
+
158
+ const getFileIcon = (mimeType) => {
159
+ if (mimeType.startsWith('image/')) return <Image className="w-4 h-4" />;
160
+ if (mimeType.startsWith('audio/')) return <Music className="w-4 h-4" />;
161
+ return <FileText className="w-4 h-4" />;
162
+ };
163
+
164
+ const handleKeyPress = (e) => {
165
+ if (e.key === 'Enter' && !e.shiftKey) {
166
+ e.preventDefault();
167
+ handleSubmit(e);
168
+ }
169
+ };
170
+
171
+ const adjustTextareaHeight = () => {
172
+ const textarea = textareaRef.current;
173
+ if (textarea) {
174
+ textarea.style.height = 'auto';
175
+ textarea.style.height = Math.min(textarea.scrollHeight, 120) + 'px';
176
+ }
177
+ };
178
+
179
+ return (
180
+ <div className="border-t border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 p-4">
181
+ {/* File Upload Preview */}
182
+ {fileUpload && (
183
+ <div className="mb-4 p-3 bg-gray-50 dark:bg-gray-700 rounded-lg border border-gray-200 dark:border-gray-600">
184
+ <div className="flex items-center justify-between mb-2">
185
+ <div className="flex items-center space-x-2">
186
+ {getFileIcon(fileUpload.type)}
187
+ <span className="text-sm font-medium text-gray-900 dark:text-white truncate">
188
+ {fileUpload.name}
189
+ </span>
190
+ </div>
191
+ <button
192
+ onClick={removeFile}
193
+ className="p-1 hover:bg-gray-200 dark:hover:bg-gray-600 rounded transition-colors"
194
+ >
195
+ <X className="w-4 h-4 text-gray-500" />
196
+ </button>
197
+ </div>
198
+
199
+ <div className="flex items-center justify-between text-sm text-gray-500 dark:text-gray-400">
200
+ <span>{formatFileSize(fileUpload.size)}</span>
201
+
202
+ {uploading && (
203
+ <div className="flex items-center space-x-2">
204
+ <div className="w-20 bg-gray-200 dark:bg-gray-600 rounded-full h-2">
205
+ <div
206
+ className="bg-primary-500 h-2 rounded-full transition-all duration-300"
207
+ style={{ width: `${progress}%` }}
208
+ ></div>
209
+ </div>
210
+ <span>{progress}%</span>
211
+ </div>
212
+ )}
213
+ </div>
214
+
215
+ {uploadError && (
216
+ <p className="text-sm text-red-600 dark:text-red-400 mt-1">{uploadError}</p>
217
+ )}
218
+ </div>
219
+ )}
220
+
221
+ {/* Hidden File Input */}
222
+ <input
223
+ type="file"
224
+ ref={fileInputRef}
225
+ onChange={handleFileSelect}
226
+ accept="image/*,audio/*,.pdf,.txt,.md"
227
+ className="hidden"
228
+ />
229
+
230
+ <form onSubmit={handleSubmit} className="flex items-end space-x-2">
231
+ {/* File Attachment Button */}
232
+ <button
233
+ type="button"
234
+ onClick={() => fileInputRef.current?.click()}
235
+ disabled={uploading}
236
+ className="p-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors disabled:opacity-50"
237
+ title="Attach file"
238
+ >
239
+ <Paperclip size={20} />
240
+ </button>
241
+
242
+ {/* Message Input */}
243
+ <div className="flex-1 relative">
244
+ <textarea
245
+ ref={textareaRef}
246
+ value={message}
247
+ onChange={(e) => {
248
+ handleInputChange(e);
249
+ adjustTextareaHeight();
250
+ }}
251
+ onKeyPress={handleKeyPress}
252
+ placeholder="Type a message..."
253
+ className="w-full px-4 py-3 border border-gray-300 dark:border-gray-600 rounded-2xl focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 resize-none max-h-32"
254
+ rows={1}
255
+ disabled={uploading}
256
+ />
257
+ </div>
258
+
259
+ {/* Send Button */}
260
+ <button
261
+ type="submit"
262
+ disabled={(!message.trim() && !fileUpload) || uploading}
263
+ className="p-3 bg-primary-500 text-white rounded-full hover:bg-primary-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex-shrink-0"
264
+ title="Send message"
265
+ >
266
+ <Send size={20} />
267
+ </button>
268
+ </form>
269
+
270
+ {/* Typing Indicator */}
271
+ {isTyping && (
272
+ <div className="text-xs text-gray-500 dark:text-gray-400 mt-2">
273
+ Typing...
274
+ </div>
275
+ )}
276
+ </div>
277
+ );
278
+ };
279
+
280
+ export default MessageInput;
ysnrfd_messenger/BACKUP/frontend/src/components/Chat/MessageList.jsx ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+ import { format, isToday, isYesterday, isThisWeek, isThisYear } from 'date-fns';
3
+ import MessageBubble from './MessageBubble';
4
+ import { useAuth } from '../../contexts/AuthContext';
5
+ import { useWebSocket } from '../../hooks/useWebSocket';
6
+
7
+ const MessageList = ({ messages, conversation, onTypingStart, onTypingStop }) => {
8
+ const { user } = useAuth();
9
+ const messagesEndRef = useRef(null);
10
+ const listRef = useRef(null);
11
+ const [isNearBottom, setIsNearBottom] = useState(true);
12
+ const typingTimeoutRef = useRef();
13
+
14
+ const { sendMessage } = useWebSocket();
15
+
16
+ // Auto-scroll to bottom when new messages arrive
17
+ useEffect(() => {
18
+ if (isNearBottom) {
19
+ scrollToBottom();
20
+ }
21
+ }, [messages, isNearBottom]);
22
+
23
+ const scrollToBottom = () => {
24
+ messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
25
+ };
26
+
27
+ const handleScroll = () => {
28
+ if (!listRef.current) return;
29
+
30
+ const { scrollTop, scrollHeight, clientHeight } = listRef.current;
31
+ const distanceFromBottom = scrollHeight - scrollTop - clientHeight;
32
+ setIsNearBottom(distanceFromBottom < 100);
33
+ };
34
+
35
+ const groupMessagesByDate = (messages) => {
36
+ const groups = [];
37
+ let currentGroup = [];
38
+ let currentDate = null;
39
+
40
+ messages.forEach((message, index) => {
41
+ const messageDate = new Date(message.createdAt).toDateString();
42
+
43
+ if (messageDate !== currentDate) {
44
+ if (currentGroup.length > 0) {
45
+ groups.push({
46
+ date: currentDate,
47
+ messages: currentGroup
48
+ });
49
+ }
50
+ currentGroup = [message];
51
+ currentDate = messageDate;
52
+ } else {
53
+ currentGroup.push(message);
54
+ }
55
+
56
+ // Last message
57
+ if (index === messages.length - 1) {
58
+ groups.push({
59
+ date: currentDate,
60
+ messages: currentGroup
61
+ });
62
+ }
63
+ });
64
+
65
+ return groups;
66
+ };
67
+
68
+ const formatDateHeader = (dateString) => {
69
+ const date = new Date(dateString);
70
+
71
+ if (isToday(date)) {
72
+ return 'Today';
73
+ } else if (isYesterday(date)) {
74
+ return 'Yesterday';
75
+ } else if (isThisWeek(date)) {
76
+ return format(date, 'EEEE');
77
+ } else if (isThisYear(date)) {
78
+ return format(date, 'MMMM d');
79
+ } else {
80
+ return format(date, 'MMMM d, yyyy');
81
+ }
82
+ };
83
+
84
+ const handleMessageRead = (messageId) => {
85
+ if (conversation) {
86
+ sendMessage('message:read', {
87
+ messageId,
88
+ conversationId: conversation._id
89
+ });
90
+ }
91
+ };
92
+
93
+ const messageGroups = groupMessagesByDate(messages);
94
+
95
+ return (
96
+ <div
97
+ ref={listRef}
98
+ onScroll={handleScroll}
99
+ className="h-full overflow-y-auto chat-scrollbar p-4 space-y-6"
100
+ >
101
+ {messageGroups.length === 0 ? (
102
+ <div className="flex flex-col items-center justify-center h-full text-center">
103
+ <div className="w-24 h-24 bg-gray-100 dark:bg-gray-700 rounded-full flex items-center justify-center mb-4">
104
+ <svg className="w-12 h-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
105
+ <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={1} d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z" />
106
+ </svg>
107
+ </div>
108
+ <h3 className="text-lg font-medium text-gray-900 dark:text-white mb-2">
109
+ No messages yet
110
+ </h3>
111
+ <p className="text-gray-500 dark:text-gray-400 max-w-sm">
112
+ Send a message to start the conversation. This is the beginning of your direct message history with {conversation.type === 'direct' ? 'this user' : 'the group'}.
113
+ </p>
114
+ </div>
115
+ ) : (
116
+ messageGroups.map((group, groupIndex) => (
117
+ <div key={group.date} className="space-y-4">
118
+ {/* Date Header */}
119
+ <div className="flex items-center justify-center">
120
+ <div className="bg-gray-100 dark:bg-gray-700 px-3 py-1 rounded-full">
121
+ <span className="text-xs font-medium text-gray-600 dark:text-gray-300">
122
+ {formatDateHeader(group.date)}
123
+ </span>
124
+ </div>
125
+ </div>
126
+
127
+ {/* Messages */}
128
+ {group.messages.map((message, messageIndex) => {
129
+ const isOwn = message.sender?._id === user.id;
130
+ const showAvatar = !isOwn && (
131
+ messageIndex === group.messages.length - 1 ||
132
+ group.messages[messageIndex + 1]?.sender?._id !== message.sender?._id
133
+ );
134
+
135
+ return (
136
+ <MessageBubble
137
+ key={message._id}
138
+ message={message}
139
+ isOwn={isOwn}
140
+ showAvatar={showAvatar}
141
+ onRead={handleMessageRead}
142
+ />
143
+ );
144
+ })}
145
+ </div>
146
+ ))
147
+ )}
148
+
149
+ {/* Scroll anchor */}
150
+ <div ref={messagesEndRef} />
151
+ </div>
152
+ );
153
+ };
154
+
155
+ export default MessageList;
ysnrfd_messenger/BACKUP/frontend/src/components/Chat/TypingIndicator.jsx ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+
3
+ const TypingIndicator = ({ userIds = [] }) => {
4
+ if (userIds.length === 0) return null;
5
+
6
+ return (
7
+ <div className="flex items-center space-x-1 text-sm text-gray-500 dark:text-gray-400">
8
+ <span>Typing</span>
9
+ <div className="typing-indicator">
10
+ <div className="typing-dot"></div>
11
+ <div className="typing-dot"></div>
12
+ <div className="typing-dot"></div>
13
+ </div>
14
+ </div>
15
+ );
16
+ };
17
+
18
+ export default TypingIndicator;
ysnrfd_messenger/BACKUP/frontend/src/components/Dashboard/Dashboard.jsx ADDED
@@ -0,0 +1,254 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState } from 'react';
2
+ import { LogOut, MessageCircle, Users, Search, Image, Music } from 'lucide-react';
3
+ import MessageInput from '/Users/ysnrfd/Desktop/ysnrfd_messenger2/frontend/src/components/Chat/MessageInput';
4
+
5
+ const Dashboard = ({ user, onLogout }) => {
6
+ const [selectedConversation, setSelectedConversation] = useState(null);
7
+ const [messages, setMessages] = useState([]);
8
+
9
+ // Mock conversations data
10
+ const conversations = [
11
+ {
12
+ id: 1,
13
+ name: 'John Doe',
14
+ lastMessage: 'Hey, how are you?',
15
+ unread: 2,
16
+ online: true
17
+ },
18
+ {
19
+ id: 2,
20
+ name: 'Sarah Smith',
21
+ lastMessage: 'Meeting at 3 PM',
22
+ unread: 0,
23
+ online: false
24
+ },
25
+ {
26
+ id: 3,
27
+ name: 'Work Group',
28
+ lastMessage: 'Mike: Project update ready',
29
+ unread: 5,
30
+ online: true,
31
+ isGroup: true
32
+ }
33
+ ];
34
+
35
+ // Mock messages data
36
+ const mockMessages = [
37
+ { id: 1, text: 'Hello there!', sender: 'other', time: '10:30 AM' },
38
+ { id: 2, text: 'Hi! How are you doing?', sender: 'me', time: '10:31 AM' },
39
+ { id: 3, text: 'I\'m good, thanks! Working on the new project.', sender: 'other', time: '10:32 AM' },
40
+ { id: 4, text: 'That sounds great! Let me know if you need any help.', sender: 'me', time: '10:33 AM' }
41
+ ];
42
+
43
+ const handleSendMessage = (messageData) => {
44
+ const message = {
45
+ id: Date.now(),
46
+ text: messageData.content,
47
+ sender: 'me',
48
+ time: new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }),
49
+ type: messageData.type,
50
+ attachment: messageData.attachment
51
+ };
52
+
53
+ setMessages([...messages, message]);
54
+ };
55
+
56
+ const handleSelectConversation = (conversation) => {
57
+ setSelectedConversation(conversation);
58
+ setMessages(mockMessages); // Load mock messages
59
+ };
60
+
61
+ // Render message with attachment
62
+ const renderMessage = (message) => {
63
+ if (message.attachment) {
64
+ return (
65
+ <div className="space-y-2">
66
+ <p className="text-sm">{message.text}</p>
67
+ <div className="p-3 bg-blue-50 rounded-lg border border-blue-200">
68
+ <div className="flex items-center space-x-2 text-sm text-blue-700">
69
+ {message.attachment.mimeType.startsWith('image/') && <Image className="w-4 h-4" />}
70
+ {message.attachment.mimeType.startsWith('audio/') && <Music className="w-4 h-4" />}
71
+ <span className="font-medium">{message.attachment.originalName}</span>
72
+ <span className="text-blue-600">({formatFileSize(message.attachment.size)})</span>
73
+ </div>
74
+ </div>
75
+ </div>
76
+ );
77
+ }
78
+
79
+ return <p className="text-sm">{message.text}</p>;
80
+ };
81
+
82
+ const formatFileSize = (bytes) => {
83
+ if (bytes === 0) return '0 Bytes';
84
+ const k = 1024;
85
+ const sizes = ['Bytes', 'KB', 'MB', 'GB'];
86
+ const i = Math.floor(Math.log(bytes) / Math.log(k));
87
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
88
+ };
89
+
90
+ return (
91
+ <div className="flex h-screen bg-gray-50">
92
+ {/* Sidebar */}
93
+ <div className="w-80 bg-white border-r border-gray-200 flex flex-col">
94
+ {/* Header */}
95
+ <div className="p-4 border-b border-gray-200">
96
+ <div className="flex items-center justify-between">
97
+ <div className="flex items-center space-x-3">
98
+ <div className="w-10 h-10 bg-gradient-to-br from-blue-500 to-purple-600 rounded-full flex items-center justify-center">
99
+ <MessageCircle className="w-6 h-6 text-white" />
100
+ </div>
101
+ <div>
102
+ <h1 className="text-lg font-bold text-gray-900">YSNRFD Messenger</h1>
103
+ <p className="text-xs text-gray-500">Welcome, {user.displayName}</p>
104
+ </div>
105
+ </div>
106
+ <button
107
+ onClick={onLogout}
108
+ className="p-2 hover:bg-gray-100 rounded-lg transition-colors"
109
+ title="Logout"
110
+ >
111
+ <LogOut className="w-5 h-5 text-gray-600" />
112
+ </button>
113
+ </div>
114
+
115
+ {/* Search */}
116
+ <div className="mt-4 relative">
117
+ <Search className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4" />
118
+ <input
119
+ type="text"
120
+ placeholder="Search conversations..."
121
+ className="w-full pl-10 pr-4 py-2 bg-gray-100 border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm"
122
+ />
123
+ </div>
124
+ </div>
125
+
126
+ {/* Conversations List */}
127
+ <div className="flex-1 overflow-y-auto">
128
+ {conversations.map((conversation) => (
129
+ <div
130
+ key={conversation.id}
131
+ onClick={() => handleSelectConversation(conversation)}
132
+ className={`p-4 border-b border-gray-100 hover:bg-gray-50 cursor-pointer transition-colors ${
133
+ selectedConversation?.id === conversation.id ? 'bg-blue-50 border-blue-200' : ''
134
+ }`}
135
+ >
136
+ <div className="flex items-center space-x-3">
137
+ <div className="relative">
138
+ <div className="w-12 h-12 bg-gradient-to-br from-blue-400 to-blue-600 rounded-full flex items-center justify-center text-white font-medium">
139
+ {conversation.isGroup ? (
140
+ <Users className="w-6 h-6" />
141
+ ) : (
142
+ conversation.name.charAt(0)
143
+ )}
144
+ </div>
145
+ {conversation.online && (
146
+ <div className="absolute bottom-0 right-0 w-3 h-3 bg-green-500 border-2 border-white rounded-full"></div>
147
+ )}
148
+ </div>
149
+ <div className="flex-1 min-w-0">
150
+ <div className="flex items-center justify-between">
151
+ <h3 className="text-sm font-semibold text-gray-900 truncate">
152
+ {conversation.name}
153
+ </h3>
154
+ <span className="text-xs text-gray-500">10:30 AM</span>
155
+ </div>
156
+ <p className="text-sm text-gray-600 truncate">
157
+ {conversation.lastMessage}
158
+ </p>
159
+ </div>
160
+ {conversation.unread > 0 && (
161
+ <div className="bg-blue-500 text-white text-xs rounded-full w-5 h-5 flex items-center justify-center">
162
+ {conversation.unread}
163
+ </div>
164
+ )}
165
+ </div>
166
+ </div>
167
+ ))}
168
+ </div>
169
+ </div>
170
+
171
+ {/* Main Chat Area */}
172
+ <div className="flex-1 flex flex-col">
173
+ {selectedConversation ? (
174
+ <>
175
+ {/* Chat Header */}
176
+ <div className="bg-white border-b border-gray-200 p-4">
177
+ <div className="flex items-center justify-between">
178
+ <div className="flex items-center space-x-3">
179
+ <div className="w-10 h-10 bg-gradient-to-br from-blue-400 to-blue-600 rounded-full flex items-center justify-center text-white font-medium">
180
+ {selectedConversation.isGroup ? (
181
+ <Users className="w-6 h-6" />
182
+ ) : (
183
+ selectedConversation.name.charAt(0)
184
+ )}
185
+ </div>
186
+ <div>
187
+ <h2 className="text-lg font-semibold text-gray-900">
188
+ {selectedConversation.name}
189
+ </h2>
190
+ <p className="text-sm text-gray-500">
191
+ {selectedConversation.online ? 'Online' : 'Last seen recently'}
192
+ </p>
193
+ </div>
194
+ </div>
195
+ </div>
196
+ </div>
197
+
198
+ {/* Messages Area */}
199
+ <div className="flex-1 overflow-y-auto p-4 space-y-4 bg-gray-50">
200
+ {messages.map((message) => (
201
+ <div
202
+ key={message.id}
203
+ className={`flex ${message.sender === 'me' ? 'justify-end' : 'justify-start'}`}
204
+ >
205
+ <div
206
+ className={`max-w-xs lg:max-w-md px-4 py-2 rounded-2xl ${
207
+ message.sender === 'me'
208
+ ? 'bg-blue-500 text-white rounded-br-none'
209
+ : 'bg-white text-gray-900 rounded-bl-none shadow-sm'
210
+ }`}
211
+ >
212
+ {renderMessage(message)}
213
+ <p
214
+ className={`text-xs mt-1 ${
215
+ message.sender === 'me' ? 'text-blue-100' : 'text-gray-500'
216
+ }`}
217
+ >
218
+ {message.time}
219
+ </p>
220
+ </div>
221
+ </div>
222
+ ))}
223
+ </div>
224
+
225
+ {/* Message Input */}
226
+ <MessageInput onSendMessage={handleSendMessage} />
227
+ </>
228
+ ) : (
229
+ <div className="flex-1 flex items-center justify-center bg-gray-50">
230
+ <div className="text-center p-8">
231
+ <div className="w-24 h-24 mx-auto mb-6 bg-gradient-to-br from-blue-100 to-blue-200 rounded-full flex items-center justify-center">
232
+ <MessageCircle className="w-12 h-12 text-blue-500" />
233
+ </div>
234
+ <h3 className="text-2xl font-bold text-gray-900 mb-2">
235
+ Welcome to YSNRFD Messenger
236
+ </h3>
237
+ <p className="text-gray-600 mb-6 max-w-md">
238
+ Select a conversation from the sidebar to start messaging, or create a new one to begin connecting.
239
+ </p>
240
+ <div className="space-y-3 text-sm text-gray-500">
241
+ <p>✅ Real-time messaging</p>
242
+ <p>✅ File sharing</p>
243
+ <p>✅ Group chats</p>
244
+ <p>✅ Read receipts</p>
245
+ </div>
246
+ </div>
247
+ </div>
248
+ )}
249
+ </div>
250
+ </div>
251
+ );
252
+ };
253
+
254
+ export default Dashboard;
ysnrfd_messenger/BACKUP/frontend/src/components/Dashboard/Sidebar.jsx ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState, useMemo } from 'react';
2
+ import { Search, LogOut, Settings, UserPlus, MessageCircle, Users } from 'lucide-react';
3
+ import { useAuth } from '../../contexts/AuthContext';
4
+ import { formatConversationTime } from '../../utils/dateFormatter';
5
+
6
+ const Sidebar = ({
7
+ conversations,
8
+ selectedConversation,
9
+ onSelectConversation,
10
+ onNewConversation,
11
+ onlineUsers
12
+ }) => {
13
+ const { user, logout } = useAuth();
14
+ const [searchTerm, setSearchTerm] = useState('');
15
+
16
+ const filteredConversations = useMemo(() => {
17
+ if (!searchTerm) return conversations;
18
+
19
+ return conversations.filter(conv => {
20
+ if (conv.type === 'direct') {
21
+ const otherParticipant = conv.participants.find(p => p.user._id !== user.id);
22
+ return otherParticipant?.user.displayName.toLowerCase().includes(searchTerm.toLowerCase()) ||
23
+ otherParticipant?.user.username.toLowerCase().includes(searchTerm.toLowerCase());
24
+ } else {
25
+ return conv.name.toLowerCase().includes(searchTerm.toLowerCase());
26
+ }
27
+ });
28
+ }, [conversations, searchTerm, user.id]);
29
+
30
+ const getConversationDisplay = (conversation) => {
31
+ if (conversation.type === 'direct') {
32
+ const otherParticipant = conversation.participants.find(p => p.user._id !== user.id);
33
+ return {
34
+ name: otherParticipant?.user.displayName || 'Unknown User',
35
+ avatar: otherParticipant?.user.avatar,
36
+ status: otherParticipant?.user.status,
37
+ isOnline: onlineUsers.has(otherParticipant?.user._id)
38
+ };
39
+ } else {
40
+ return {
41
+ name: conversation.name,
42
+ avatar: conversation.avatar,
43
+ isGroup: true
44
+ };
45
+ }
46
+ };
47
+
48
+ const getLastMessagePreview = (conversation) => {
49
+ if (!conversation.lastMessage) return 'No messages yet';
50
+
51
+ const lastMessage = conversation.lastMessage;
52
+ if (lastMessage.type === 'image') return '📷 Image';
53
+ if (lastMessage.type === 'audio') return '🎵 Audio';
54
+ if (lastMessage.type === 'file') return '📎 File';
55
+
56
+ return lastMessage.content.length > 30
57
+ ? lastMessage.content.substring(0, 30) + '...'
58
+ : lastMessage.content;
59
+ };
60
+
61
+ const handleLogout = async () => {
62
+ if (window.confirm('Are you sure you want to logout?')) {
63
+ await logout();
64
+ }
65
+ };
66
+
67
+ return (
68
+ <div className="flex flex-col h-full bg-white dark:bg-gray-800">
69
+ {/* Header */}
70
+ <div className="p-4 border-b border-gray-200 dark:border-gray-700">
71
+ <div className="flex items-center justify-between mb-4">
72
+ <div className="flex items-center space-x-3">
73
+ <div className="w-10 h-10 bg-primary-500 rounded-full flex items-center justify-center">
74
+ <MessageCircle className="w-6 h-6 text-white" />
75
+ </div>
76
+ <div>
77
+ <h1 className="text-lg font-bold text-gray-900 dark:text-white">YSNRFD</h1>
78
+ <p className="text-xs text-gray-500 dark:text-gray-400">Messenger</p>
79
+ </div>
80
+ </div>
81
+
82
+ <div className="flex items-center space-x-2">
83
+ <button
84
+ onClick={onNewConversation}
85
+ className="p-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors"
86
+ title="New conversation"
87
+ >
88
+ <UserPlus size={20} />
89
+ </button>
90
+ <button
91
+ onClick={handleLogout}
92
+ className="p-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors"
93
+ title="Logout"
94
+ >
95
+ <LogOut size={20} />
96
+ </button>
97
+ </div>
98
+ </div>
99
+
100
+ {/* Search Bar */}
101
+ <div className="relative">
102
+ <Search className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4" />
103
+ <input
104
+ type="text"
105
+ placeholder="Search conversations..."
106
+ value={searchTerm}
107
+ onChange={(e) => setSearchTerm(e.target.value)}
108
+ className="w-full pl-10 pr-4 py-2 bg-gray-100 dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent text-sm text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400"
109
+ />
110
+ </div>
111
+ </div>
112
+
113
+ {/* Conversations List */}
114
+ <div className="flex-1 overflow-y-auto scrollbar-thin">
115
+ {filteredConversations.length === 0 ? (
116
+ <div className="flex flex-col items-center justify-center h-full p-8 text-center">
117
+ <Users className="w-16 h-16 text-gray-300 dark:text-gray-600 mb-4" />
118
+ <h3 className="text-lg font-medium text-gray-900 dark:text-white mb-2">
119
+ {searchTerm ? 'No conversations found' : 'No conversations yet'}
120
+ </h3>
121
+ <p className="text-gray-500 dark:text-gray-400 mb-4">
122
+ {searchTerm
123
+ ? 'Try adjusting your search terms'
124
+ : 'Start a new conversation to begin messaging'
125
+ }
126
+ </p>
127
+ {!searchTerm && (
128
+ <button
129
+ onClick={onNewConversation}
130
+ className="btn-primary"
131
+ >
132
+ Start Conversation
133
+ </button>
134
+ )}
135
+ </div>
136
+ ) : (
137
+ <div className="p-2">
138
+ {filteredConversations.map((conversation) => {
139
+ const display = getConversationDisplay(conversation);
140
+ const isSelected = selectedConversation?._id === conversation._id;
141
+
142
+ return (
143
+ <div
144
+ key={conversation._id}
145
+ onClick={() => onSelectConversation(conversation)}
146
+ className={`sidebar-item ${isSelected ? 'sidebar-item-active' : ''}`}
147
+ >
148
+ {/* Avatar */}
149
+ <div className="relative flex-shrink-0">
150
+ <div className="w-12 h-12 bg-gradient-to-br from-primary-400 to-primary-600 rounded-full flex items-center justify-center text-white font-medium text-sm">
151
+ {display.avatar ? (
152
+ <img
153
+ src={display.avatar}
154
+ alt={display.name}
155
+ className="w-12 h-12 rounded-full object-cover"
156
+ />
157
+ ) : (
158
+ display.name.charAt(0).toUpperCase()
159
+ )}
160
+ </div>
161
+
162
+ {/* Online Status Indicator */}
163
+ {display.isOnline && (
164
+ <div className="absolute bottom-0 right-0 w-3 h-3 bg-green-500 border-2 border-white dark:border-gray-800 rounded-full"></div>
165
+ )}
166
+
167
+ {/* Group Indicator */}
168
+ {display.isGroup && (
169
+ <div className="absolute bottom-0 right-0 w-3 h-3 bg-blue-500 border-2 border-white dark:border-gray-800 rounded-full flex items-center justify-center">
170
+ <Users className="w-2 h-2 text-white" />
171
+ </div>
172
+ )}
173
+ </div>
174
+
175
+ {/* Conversation Info */}
176
+ <div className="flex-1 min-w-0">
177
+ <div className="flex items-center justify-between">
178
+ <h3 className="text-sm font-semibold text-gray-900 dark:text-white truncate">
179
+ {display.name}
180
+ </h3>
181
+ {conversation.lastMessage && (
182
+ <span className="text-xs text-gray-500 dark:text-gray-400 whitespace-nowrap">
183
+ {formatConversationTime(conversation.lastMessage.createdAt)}
184
+ </span>
185
+ )}
186
+ </div>
187
+
188
+ <div className="flex items-center justify-between">
189
+ <p className="text-sm text-gray-500 dark:text-gray-400 truncate">
190
+ {getLastMessagePreview(conversation)}
191
+ </p>
192
+
193
+ {/* Unread message indicator */}
194
+ {conversation.unreadCount > 0 && (
195
+ <span className="bg-primary-500 text-white text-xs rounded-full w-5 h-5 flex items-center justify-center flex-shrink-0">
196
+ {conversation.unreadCount}
197
+ </span>
198
+ )}
199
+ </div>
200
+ </div>
201
+ </div>
202
+ );
203
+ })}
204
+ </div>
205
+ )}
206
+ </div>
207
+
208
+ {/* User Profile Footer */}
209
+ <div className="p-4 border-t border-gray-200 dark:border-gray-700">
210
+ <div className="flex items-center space-x-3">
211
+ <div className="w-10 h-10 bg-gradient-to-br from-primary-400 to-primary-600 rounded-full flex items-center justify-center text-white font-medium text-sm">
212
+ {user.avatar ? (
213
+ <img
214
+ src={user.avatar}
215
+ alt={user.displayName}
216
+ className="w-10 h-10 rounded-full object-cover"
217
+ />
218
+ ) : (
219
+ user.displayName.charAt(0).toUpperCase()
220
+ )}
221
+ </div>
222
+ <div className="flex-1 min-w-0">
223
+ <h3 className="text-sm font-semibold text-gray-900 dark:text-white truncate">
224
+ {user.displayName}
225
+ </h3>
226
+ <p className="text-xs text-gray-500 dark:text-gray-400 truncate">
227
+ @{user.username}
228
+ </p>
229
+ </div>
230
+ <div className="w-2 h-2 bg-green-500 rounded-full" title="Online"></div>
231
+ </div>
232
+ </div>
233
+ </div>
234
+ );
235
+ };
236
+
237
+ export default Sidebar;
ysnrfd_messenger/BACKUP/frontend/src/components/Dashboard/UserSearch.jsx ADDED
@@ -0,0 +1,256 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState, useEffect } from 'react';
2
+ import { Search, X, User, UserPlus, MessageCircle } from 'lucide-react';
3
+ import { userService, conversationService } from '../../services/api';
4
+ import { useAuth } from '../../contexts/AuthContext';
5
+
6
+ const UserSearch = ({ onClose, onConversationCreated }) => {
7
+ const [searchTerm, setSearchTerm] = useState('');
8
+ const [searchResults, setSearchResults] = useState([]);
9
+ const [loading, setLoading] = useState(false);
10
+ const [selectedUsers, setSelectedUsers] = useState(new Set());
11
+ const [conversationName, setConversationName] = useState('');
12
+ const [creating, setCreating] = useState(false);
13
+ const { user } = useAuth();
14
+
15
+ useEffect(() => {
16
+ const searchUsers = async () => {
17
+ if (!searchTerm.trim()) {
18
+ setSearchResults([]);
19
+ return;
20
+ }
21
+
22
+ setLoading(true);
23
+ try {
24
+ const response = await userService.search(searchTerm);
25
+ // Filter out current user and already selected users
26
+ const filteredResults = response.users.filter(
27
+ u => u._id !== user.id && !selectedUsers.has(u._id)
28
+ );
29
+ setSearchResults(filteredResults);
30
+ } catch (error) {
31
+ console.error('Search error:', error);
32
+ setSearchResults([]);
33
+ } finally {
34
+ setLoading(false);
35
+ }
36
+ };
37
+
38
+ const timeoutId = setTimeout(searchUsers, 300);
39
+ return () => clearTimeout(timeoutId);
40
+ }, [searchTerm, selectedUsers, user.id]);
41
+
42
+ const handleUserSelect = (user) => {
43
+ setSelectedUsers(prev => {
44
+ const newSet = new Set(prev);
45
+ if (newSet.has(user._id)) {
46
+ newSet.delete(user._id);
47
+ } else {
48
+ newSet.add(user._id);
49
+ }
50
+ return newSet;
51
+ });
52
+ setSearchTerm('');
53
+ setSearchResults([]);
54
+ };
55
+
56
+ const handleRemoveUser = (userId) => {
57
+ setSelectedUsers(prev => {
58
+ const newSet = new Set(prev);
59
+ newSet.delete(userId);
60
+ return newSet;
61
+ });
62
+ };
63
+
64
+ const createConversation = async () => {
65
+ if (selectedUsers.size === 0) return;
66
+
67
+ setCreating(true);
68
+ try {
69
+ const participantIds = Array.from(selectedUsers);
70
+
71
+ let conversationData;
72
+ if (participantIds.length === 1) {
73
+ // Direct message
74
+ conversationData = {
75
+ type: 'direct',
76
+ participantIds
77
+ };
78
+ } else {
79
+ // Group chat
80
+ conversationData = {
81
+ type: 'group',
82
+ name: conversationName || `Group with ${participantIds.length + 1} people`,
83
+ participantIds
84
+ };
85
+ }
86
+
87
+ const response = await conversationService.create(conversationData);
88
+ onConversationCreated(response.conversation);
89
+ } catch (error) {
90
+ console.error('Create conversation error:', error);
91
+ alert(error.error || 'Failed to create conversation');
92
+ } finally {
93
+ setCreating(false);
94
+ }
95
+ };
96
+
97
+ const getSelectedUsersInfo = () => {
98
+ return Array.from(selectedUsers).map(userId => {
99
+ // In a real app, you'd have the user objects cached
100
+ return { _id: userId, displayName: 'User', username: 'user' };
101
+ });
102
+ };
103
+
104
+ return (
105
+ <div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4">
106
+ <div className="bg-white dark:bg-gray-800 rounded-xl w-full max-w-md max-h-[90vh] overflow-hidden">
107
+ {/* Header */}
108
+ <div className="flex items-center justify-between p-6 border-b border-gray-200 dark:border-gray-700">
109
+ <div className="flex items-center space-x-3">
110
+ <MessageCircle className="w-6 h-6 text-primary-500" />
111
+ <h2 className="text-xl font-bold text-gray-900 dark:text-white">
112
+ New Conversation
113
+ </h2>
114
+ </div>
115
+ <button
116
+ onClick={onClose}
117
+ className="p-2 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors"
118
+ >
119
+ <X className="w-5 h-5 text-gray-500 dark:text-gray-400" />
120
+ </button>
121
+ </div>
122
+
123
+ <div className="p-6 space-y-4">
124
+ {/* Search Input */}
125
+ <div className="relative">
126
+ <Search className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4" />
127
+ <input
128
+ type="text"
129
+ placeholder="Search users by username..."
130
+ value={searchTerm}
131
+ onChange={(e) => setSearchTerm(e.target.value)}
132
+ className="w-full pl-10 pr-4 py-3 bg-gray-50 dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400"
133
+ />
134
+ </div>
135
+
136
+ {/* Selected Users */}
137
+ {selectedUsers.size > 0 && (
138
+ <div className="space-y-2">
139
+ <h3 className="text-sm font-medium text-gray-700 dark:text-gray-300">
140
+ Selected Users ({selectedUsers.size})
141
+ </h3>
142
+ <div className="flex flex-wrap gap-2">
143
+ {getSelectedUsersInfo().map(user => (
144
+ <div
145
+ key={user._id}
146
+ className="flex items-center space-x-2 bg-primary-100 dark:bg-primary-900 px-3 py-1 rounded-full"
147
+ >
148
+ <span className="text-sm text-primary-700 dark:text-primary-300">
149
+ {user.displayName}
150
+ </span>
151
+ <button
152
+ onClick={() => handleRemoveUser(user._id)}
153
+ className="text-primary-500 hover:text-primary-700"
154
+ >
155
+ <X className="w-3 h-3" />
156
+ </button>
157
+ </div>
158
+ ))}
159
+ </div>
160
+ </div>
161
+ )}
162
+
163
+ {/* Group Name Input (for groups) */}
164
+ {selectedUsers.size > 1 && (
165
+ <div>
166
+ <label className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
167
+ Group Name
168
+ </label>
169
+ <input
170
+ type="text"
171
+ placeholder="Enter group name..."
172
+ value={conversationName}
173
+ onChange={(e) => setConversationName(e.target.value)}
174
+ className="w-full px-4 py-3 bg-gray-50 dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400"
175
+ />
176
+ </div>
177
+ )}
178
+
179
+ {/* Search Results */}
180
+ <div className="max-h-60 overflow-y-auto">
181
+ {loading ? (
182
+ <div className="flex items-center justify-center py-8">
183
+ <div className="animate-spin rounded-full h-6 w-6 border-b-2 border-primary-500"></div>
184
+ </div>
185
+ ) : searchResults.length > 0 ? (
186
+ <div className="space-y-2">
187
+ <h3 className="text-sm font-medium text-gray-700 dark:text-gray-300">
188
+ Search Results
189
+ </h3>
190
+ {searchResults.map(user => (
191
+ <div
192
+ key={user._id}
193
+ onClick={() => handleUserSelect(user)}
194
+ className="flex items-center space-x-3 p-3 hover:bg-gray-50 dark:hover:bg-gray-700 rounded-lg cursor-pointer transition-colors"
195
+ >
196
+ <div className="w-10 h-10 bg-gradient-to-br from-primary-400 to-primary-600 rounded-full flex items-center justify-center text-white font-medium text-sm">
197
+ {user.avatar ? (
198
+ <img
199
+ src={user.avatar}
200
+ alt={user.displayName}
201
+ className="w-10 h-10 rounded-full object-cover"
202
+ />
203
+ ) : (
204
+ user.displayName.charAt(0).toUpperCase()
205
+ )}
206
+ </div>
207
+ <div className="flex-1 min-w-0">
208
+ <h4 className="text-sm font-medium text-gray-900 dark:text-white truncate">
209
+ {user.displayName}
210
+ </h4>
211
+ <p className="text-sm text-gray-500 dark:text-gray-400 truncate">
212
+ @{user.username}
213
+ </p>
214
+ </div>
215
+ <UserPlus className="w-4 h-4 text-gray-400" />
216
+ </div>
217
+ ))}
218
+ </div>
219
+ ) : searchTerm && !loading ? (
220
+ <div className="text-center py-8 text-gray-500 dark:text-gray-400">
221
+ <User className="w-12 h-12 mx-auto mb-2 opacity-50" />
222
+ <p>No users found</p>
223
+ </div>
224
+ ) : null}
225
+ </div>
226
+ </div>
227
+
228
+ {/* Footer */}
229
+ <div className="flex items-center justify-end space-x-3 p-6 border-t border-gray-200 dark:border-gray-700">
230
+ <button
231
+ onClick={onClose}
232
+ className="btn-secondary"
233
+ >
234
+ Cancel
235
+ </button>
236
+ <button
237
+ onClick={createConversation}
238
+ disabled={selectedUsers.size === 0 || creating}
239
+ className="btn-primary disabled:opacity-50 disabled:cursor-not-allowed"
240
+ >
241
+ {creating ? (
242
+ <div className="flex items-center space-x-2">
243
+ <div className="animate-spin rounded-full h-4 w-4 border-b-2 border-white"></div>
244
+ <span>Creating...</span>
245
+ </div>
246
+ ) : (
247
+ `Start ${selectedUsers.size === 1 ? 'Chat' : 'Group'}`
248
+ )}
249
+ </button>
250
+ </div>
251
+ </div>
252
+ </div>
253
+ );
254
+ };
255
+
256
+ export default UserSearch;
ysnrfd_messenger/BACKUP/frontend/src/components/Files/AudioPlayer.jsx ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React, { useState, useRef, useEffect } from 'react';
2
+ import { Play, Pause, Volume2, Download } from 'lucide-react';
3
+
4
+ const AudioPlayer = ({ src, title, onDownload }) => {
5
+ const [isPlaying, setIsPlaying] = useState(false);
6
+ const [currentTime, setCurrentTime] = useState(0);
7
+ const [duration, setDuration] = useState(0);
8
+ const [volume, setVolume] = useState(1);
9
+ const audioRef = useRef();
10
+
11
+ useEffect(() => {
12
+ const audio = audioRef.current;
13
+
14
+ const updateTime = () => setCurrentTime(audio.currentTime);
15
+ const updateDuration = () => setDuration(audio.duration);
16
+ const handleEnded = () => setIsPlaying(false);
17
+
18
+ audio.addEventListener('timeupdate', updateTime);
19
+ audio.addEventListener('loadedmetadata', updateDuration);
20
+ audio.addEventListener('ended', handleEnded);
21
+
22
+ return () => {
23
+ audio.removeEventListener('timeupdate', updateTime);
24
+ audio.removeEventListener('loadedmetadata', updateDuration);
25
+ audio.removeEventListener('ended', handleEnded);
26
+ };
27
+ }, []);
28
+
29
+ const togglePlay = () => {
30
+ if (isPlaying) {
31
+ audioRef.current.pause();
32
+ } else {
33
+ audioRef.current.play();
34
+ }
35
+ setIsPlaying(!isPlaying);
36
+ };
37
+
38
+ const handleSeek = (e) => {
39
+ const newTime = e.target.value;
40
+ audioRef.current.currentTime = newTime;
41
+ setCurrentTime(newTime);
42
+ };
43
+
44
+ const handleVolumeChange = (e) => {
45
+ const newVolume = e.target.value;
46
+ audioRef.current.volume = newVolume;
47
+ setVolume(newVolume);
48
+ };
49
+
50
+ const formatTime = (time) => {
51
+ const minutes = Math.floor(time / 60);
52
+ const seconds = Math.floor(time % 60);
53
+ return `${minutes}:${seconds.toString().padStart(2, '0')}`;
54
+ };
55
+
56
+ return (
57
+ <div className="bg-gray-50 dark:bg-gray-700 rounded-lg p-4 border border-gray-200 dark:border-gray-600">
58
+ {/* Hidden audio element */}
59
+ <audio ref={audioRef} src={src} preload="metadata" />
60
+
61
+ {/* Title and Download */}
62
+ <div className="flex items-center justify-between mb-3">
63
+ <h4 className="text-sm font-medium text-gray-900 dark:text-white truncate flex-1 mr-2">
64
+ {title}
65
+ </h4>
66
+ {onDownload && (
67
+ <button
68
+ onClick={onDownload}
69
+ className="p-1.5 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-200 dark:hover:bg-gray-600 rounded transition-colors flex-shrink-0"
70
+ title="Download"
71
+ >
72
+ <Download size={16} />
73
+ </button>
74
+ )}
75
+ </div>
76
+
77
+ {/* Controls */}
78
+ <div className="flex items-center space-x-3">
79
+ <button
80
+ onClick={togglePlay}
81
+ className="p-2 bg-primary-500 text-white rounded-full hover:bg-primary-600 transition-colors flex-shrink-0"
82
+ >
83
+ {isPlaying ? <Pause size={16} /> : <Play size={16} />}
84
+ </button>
85
+
86
+ {/* Progress */}
87
+ <div className="flex-1 space-y-1">
88
+ <input
89
+ type="range"
90
+ min="0"
91
+ max={duration || 0}
92
+ value={currentTime}
93
+ onChange={handleSeek}
94
+ className="w-full h-1.5 bg-gray-200 dark:bg-gray-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-primary-500"
95
+ />
96
+ <div className="flex justify-between text-xs text-gray-500 dark:text-gray-400">
97
+ <span>{formatTime(currentTime)}</span>
98
+ <span>{formatTime(duration)}</span>
99
+ </div>
100
+ </div>
101
+
102
+ {/* Volume */}
103
+ <div className="flex items-center space-x-2 w-20">
104
+ <Volume2 size={16} className="text-gray-500 dark:text-gray-400 flex-shrink-0" />
105
+ <input
106
+ type="range"
107
+ min="0"
108
+ max="1"
109
+ step="0.1"
110
+ value={volume}
111
+ onChange={handleVolumeChange}
112
+ className="w-full h-1.5 bg-gray-200 dark:bg-gray-600 rounded-lg appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:h-3 [&::-webkit-slider-thumb]:w-3 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-primary-500"
113
+ />
114
+ </div>
115
+ </div>
116
+ </div>
117
+ );
118
+ };
119
+
120
+ export default AudioPlayer;
ysnrfd_messenger/BACKUP/frontend/src/components/Files/FilePreview.jsx ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from 'react';
2
+ import { Download, X, FileText, Image, Music } from 'lucide-react';
3
+ import { formatFileSize } from '../../utils/fileValidation';
4
+
5
+ const FilePreview = ({ file, onRemove, onDownload }) => {
6
+ const getFileIcon = () => {
7
+ if (file.type.startsWith('image/')) return <Image className="w-6 h-6" />;
8
+ if (file.type.startsWith('audio/')) return <Music className="w-6 h-6" />;
9
+ return <FileText className="w-6 h-6" />;
10
+ };
11
+
12
+ const getFileType = () => {
13
+ if (file.type.startsWith('image/')) return 'Image';
14
+ if (file.type.startsWith('audio/')) return 'Audio';
15
+ if (file.type === 'application/pdf') return 'PDF';
16
+ if (file.type.startsWith('text/')) return 'Text';
17
+ return 'File';
18
+ };
19
+
20
+ return (
21
+ <div className="flex items-center justify-between p-3 bg-gray-50 dark:bg-gray-700 rounded-lg border border-gray-200 dark:border-gray-600">
22
+ <div className="flex items-center space-x-3">
23
+ <div className="text-primary-500">
24
+ {getFileIcon()}
25
+ </div>
26
+ <div className="flex-1 min-w-0">
27
+ <p className="text-sm font-medium text-gray-900 dark:text-white truncate">
28
+ {file.name}
29
+ </p>
30
+ <p className="text-xs text-gray-500 dark:text-gray-400">
31
+ {getFileType()} • {formatFileSize(file.size)}
32
+ </p>
33
+ </div>
34
+ </div>
35
+
36
+ <div className="flex items-center space-x-2">
37
+ {onDownload && (
38
+ <button
39
+ onClick={() => onDownload(file)}
40
+ className="p-1.5 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 hover:bg-gray-200 dark:hover:bg-gray-600 rounded transition-colors"
41
+ title="Download"
42
+ >
43
+ <Download size={16} />
44
+ </button>
45
+ )}
46
+
47
+ {onRemove && (
48
+ <button
49
+ onClick={() => onRemove(file)}
50
+ className="p-1.5 text-gray-500 hover:text-red-600 dark:text-gray-400 dark:hover:text-red-400 hover:bg-gray-200 dark:hover:bg-gray-600 rounded transition-colors"
51
+ title="Remove"
52
+ >
53
+ <X size={16} />
54
+ </button>
55
+ )}
56
+ </div>
57
+ </div>
58
+ );
59
+ };
60
+
61
+ export default FilePreview;