commit 5bb54fdefed2b110835c1f8c8d8c9d18bcfc2a91 Author: 송원형 Date: Tue Apr 7 16:17:03 2026 +0900 오대리ㅣㅣㅣㅣ diff --git a/mobile/.gitignore b/mobile/.gitignore new file mode 100644 index 0000000..3820a95 --- /dev/null +++ b/mobile/.gitignore @@ -0,0 +1,45 @@ +# Miscellaneous +*.class +*.log +*.pyc +*.swp +.DS_Store +.atom/ +.build/ +.buildlog/ +.history +.svn/ +.swiftpm/ +migrate_working_dir/ + +# IntelliJ related +*.iml +*.ipr +*.iws +.idea/ + +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ + +# Flutter/Dart/Pub related +**/doc/api/ +**/ios/Flutter/.last_build_id +.dart_tool/ +.flutter-plugins-dependencies +.pub-cache/ +.pub/ +/build/ +/coverage/ + +# Symbolication related +app.*.symbols + +# Obfuscation related +app.*.map.json + +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/mobile/.metadata b/mobile/.metadata new file mode 100644 index 0000000..9114285 --- /dev/null +++ b/mobile/.metadata @@ -0,0 +1,30 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: "db50e20168db8fee486b9abf32fc912de3bc5b6a" + channel: "stable" + +project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: db50e20168db8fee486b9abf32fc912de3bc5b6a + base_revision: db50e20168db8fee486b9abf32fc912de3bc5b6a + - platform: web + create_revision: db50e20168db8fee486b9abf32fc912de3bc5b6a + base_revision: db50e20168db8fee486b9abf32fc912de3bc5b6a + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/mobile/README.md b/mobile/README.md new file mode 100644 index 0000000..73ec993 --- /dev/null +++ b/mobile/README.md @@ -0,0 +1,87 @@ +# IYKYKA — Flutter 클라이언트 + +멀티 컨텍스트(일상·업무 등) 기반 메신저 **IYKYKA**의 모바일 앱입니다. 서버 REST API + WebSocket과 연동합니다. + +--- + +## 실행 방법 + +프로젝트 루트의 [README.md](../README.md)에 서버 기동 방법이 있습니다. 서버가 떠 있는 상태에서: + +```bash +cd mobile +flutter pub get +flutter run --dart-define=API_BASE=http://127.0.0.1:8787 +``` + +- **Android 에뮬레이터** → `API_BASE=http://10.0.2.2:8787` +- **웹** → `sqflite` 미지원으로 로컬 메시지 캐시 전체는 동작하지 않을 수 있음. **Android / iOS / Windows 데스크톱** 권장 + +--- + +## 기술 스택 (요약) + +| 구분 | 사용 | +|------|------| +| 상태·DI | `flutter_riverpod` | +| 라우팅 | `go_router` | +| HTTP | `dio` (JWT 인터셉터) | +| 소켓 | `web_socket_channel` | +| 로컬 DB | `sqflite` (방별 메시지 캐시) | +| 보안 저장소 | `flutter_secure_storage` (토큰) | +| 설정 | `shared_preferences` (테마·알림 스위치 등) | +| 푸시 | `firebase_core` / `firebase_messaging`, 포그라운드는 `flutter_local_notifications` | +| 앱 정보 | `package_info_plus` (설정 화면 버전 표시) | + +--- + +## 구현된 기능 + +### 인증·세션 +- 회원가입 / 로그인, JWT 저장 및 API 자동 부착 +- 로그아웃 시 소켓 종료 후 로그인 화면으로 이동 + +### 컨텍스트·홈 +- 컨텍스트 목록·선택(일상 / 업무 등), 해당 컨텍스트 기준 방·멤버·내 프로필 +- 이메일 초대, 업무 컨텍스트 생성, 그룹 채팅방 만들기 +- 하단 탭: 대화 / 멤버 / 내 프로필 + +### 채팅 +- WebSocket 실시간 메시지, 방 구독 +- **오프라인/끊김 시** 전송 실패 메시지를 메모리 큐에 쌓았다가 **연결 복구 후 순차 전송** +- 1:1 방: **상대 입력 중** 표시(타이핑 이벤트·디바운스), **읽음** 표시(서버 읽음 상태 + WS 갱신) +- 메시지 읽음 처리(마지막 메시지 기준) API 호출 +- 로컬 `sqflite`에 방별 메시지 캐시(동기화·오프라인 열람 보조) + +### 검색 +- **메시지 / 방 / 친구** 탭으로 구분, **클라이언트 측 필터**(쿼리 문자열) + +### 설정 +- 앱 이름·**버전**(`package_info_plus`) +- **테마**: 시스템 / 라이트 (OS 다크여도 앱은 라이트 토스 스타일 유지) +- **푸시 알림** 스위치(SharedPreferences; 켜진 경우 FCM 초기화·토큰 서버 등록 시도) +- 로그아웃 + +### 푸시(FCM) +- Firebase 초기화 실패 시에도 앱 기동은 계속(미설정·플레이스홀더 `firebase_options` 대비) +- FCM 토큰을 서버 `registerPushToken`으로 등록, 토큰 갱신 시 재등록 +- 포그라운드 수신 시 로컬 알림 표시(설정 가능 범위 내) + +### UI +- 토스 느낌의 라이트 테마(`theme/toss_theme.dart`) + +--- + +## 검증 명령 + +```bash +dart analyze lib +flutter test +``` + +--- + +## 참고 + +- 서버에서 실제 원격 푸시 발송(Firebase Admin 등)은 별도 연동 단계일 수 있으며, 클라이언트는 토큰 등록까지 동작하도록 구성되어 있습니다. +- 실제 배포·스토어 빌드 전에는 `firebase_options.dart` 및 Android/iOS Firebase 설정을 프로젝트에 맞게 교체해야 합니다. diff --git a/mobile/analysis_options.yaml b/mobile/analysis_options.yaml new file mode 100644 index 0000000..c479365 --- /dev/null +++ b/mobile/analysis_options.yaml @@ -0,0 +1,5 @@ +include: package:flutter_lints/flutter.yaml +linter: + rules: + prefer_const_constructors: true + unawaited_futures: true diff --git a/mobile/lib/app/router.dart b/mobile/lib/app/router.dart new file mode 100644 index 0000000..a0fdc9f --- /dev/null +++ b/mobile/lib/app/router.dart @@ -0,0 +1,86 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; + +import '../core/session_controller.dart'; +import '../features/auth/login_page.dart'; +import '../features/auth/register_page.dart'; +import '../features/chat/chat_page.dart'; +import '../features/home/home_page.dart'; +import '../features/search/search_page.dart'; +import '../features/settings/settings_page.dart'; +import '../core/app_settings.dart'; +import '../theme/toss_theme.dart'; + +final goRouterProvider = Provider((ref) { + ref.watch(sessionProvider); + ref.watch(themeModeProvider); + + return GoRouter( + initialLocation: '/splash', + redirect: (context, state) { + final async = ref.read(sessionProvider); + final loc = state.matchedLocation; + + if (async.isLoading) { + return loc == '/splash' ? null : '/splash'; + } + if (async.hasError) { + return loc == '/login' ? null : '/login'; + } + final s = async.value; + if (s == null) { + if (loc == '/login' || loc == '/register') return null; + return '/login'; + } + if (loc == '/splash' || loc == '/login' || loc == '/register') { + return '/'; + } + return null; + }, + routes: [ + GoRoute( + path: '/splash', + builder: (context, state) => const Scaffold( + backgroundColor: TossColors.bg, + body: Center(child: CircularProgressIndicator(color: TossColors.blue)), + ), + ), + GoRoute( + path: '/login', + builder: (context, state) => const LoginPage(), + ), + GoRoute( + path: '/register', + builder: (context, state) => const RegisterPage(), + ), + GoRoute( + path: '/', + builder: (context, state) => const HomePage(), + ), + GoRoute( + path: '/chat', + builder: (context, state) { + final q = state.uri.queryParameters; + final roomId = q['roomId']; + final contextId = q['contextId']; + if (roomId == null || contextId == null) { + return const Scaffold(body: Center(child: Text('Invalid link'))); + } + return ChatPage(roomId: roomId, contextId: contextId); + }, + ), + GoRoute( + path: '/search', + builder: (context, state) { + final cid = state.uri.queryParameters['contextId'] ?? ''; + return SearchPage(contextId: cid); + }, + ), + GoRoute( + path: '/settings', + builder: (context, state) => const SettingsPage(), + ), + ], + ); +}); diff --git a/mobile/lib/core/api_client.dart b/mobile/lib/core/api_client.dart new file mode 100644 index 0000000..2ccd520 --- /dev/null +++ b/mobile/lib/core/api_client.dart @@ -0,0 +1,31 @@ +import 'package:dio/dio.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +import 'api_config.dart'; +import 'token_storage.dart'; + +final tokenStorageProvider = Provider((ref) => TokenStorage()); + +final dioProvider = Provider((ref) { + final storage = ref.watch(tokenStorageProvider); + final dio = Dio( + BaseOptions( + baseUrl: ApiConfig.baseUrl, + connectTimeout: const Duration(seconds: 15), + receiveTimeout: const Duration(seconds: 30), + headers: {'Content-Type': 'application/json'}, + ), + ); + dio.interceptors.add( + InterceptorsWrapper( + onRequest: (options, handler) async { + final t = await storage.readToken(); + if (t != null && t.isNotEmpty) { + options.headers['Authorization'] = 'Bearer $t'; + } + handler.next(options); + }, + ), + ); + return dio; +}); diff --git a/mobile/lib/core/api_config.dart b/mobile/lib/core/api_config.dart new file mode 100644 index 0000000..cb3d3fc --- /dev/null +++ b/mobile/lib/core/api_config.dart @@ -0,0 +1,8 @@ +/// Backend base URL. Override at build time: +/// `flutter run --dart-define=API_BASE=http://10.0.2.2:8787` +class ApiConfig { + static const String baseUrl = String.fromEnvironment( + 'API_BASE', + defaultValue: 'http://127.0.0.1:8787', + ); +} diff --git a/mobile/lib/core/app_settings.dart b/mobile/lib/core/app_settings.dart new file mode 100644 index 0000000..a0408d1 --- /dev/null +++ b/mobile/lib/core/app_settings.dart @@ -0,0 +1,77 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +const _kThemeMode = 'app_theme_mode'; +const _kNotificationsEnabled = 'app_notifications_enabled'; + +String _themeToStr(ThemeMode m) { + return switch (m) { + ThemeMode.light => 'light', + _ => 'system', + }; +} + +ThemeMode _themeFromStr(String? s) { + return switch (s) { + 'light' => ThemeMode.light, + // Legacy: app no longer offers dark; map old saves to light. + 'dark' => ThemeMode.light, + _ => ThemeMode.system, + }; +} + +final themeModeProvider = NotifierProvider(ThemeModeNotifier.new); + +class ThemeModeNotifier extends Notifier { + @override + ThemeMode build() { + Future.microtask(_load); + return ThemeMode.system; + } + + Future _load() async { + final p = await SharedPreferences.getInstance(); + final s = p.getString(_kThemeMode); + if (s != null) { + state = _themeFromStr(s); + } + } + + Future setThemeMode(ThemeMode mode) async { + state = mode; + final p = await SharedPreferences.getInstance(); + await p.setString(_kThemeMode, _themeToStr(mode)); + } +} + +final notificationsEnabledProvider = + NotifierProvider(NotificationsEnabledNotifier.new); + +class NotificationsEnabledNotifier extends Notifier { + @override + bool build() { + Future.microtask(_load); + return true; + } + + Future _load() async { + final p = await SharedPreferences.getInstance(); + if (p.containsKey(_kNotificationsEnabled)) { + state = p.getBool(_kNotificationsEnabled) ?? true; + } + } + + Future setEnabled(bool value) async { + state = value; + final p = await SharedPreferences.getInstance(); + await p.setBool(_kNotificationsEnabled, value); + } +} + +/// Reads persisted value (default true if never set). Use before first notifier tick if needed. +Future readNotificationsEnabledFromPrefs() async { + final p = await SharedPreferences.getInstance(); + if (!p.containsKey(_kNotificationsEnabled)) return true; + return p.getBool(_kNotificationsEnabled) ?? true; +} diff --git a/mobile/lib/core/auth_repository.dart b/mobile/lib/core/auth_repository.dart new file mode 100644 index 0000000..9c42b30 --- /dev/null +++ b/mobile/lib/core/auth_repository.dart @@ -0,0 +1,64 @@ +import 'package:dio/dio.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +import 'api_client.dart'; +import 'token_storage.dart'; + +final authRepositoryProvider = Provider((ref) { + return AuthRepository(ref.watch(dioProvider), ref.watch(tokenStorageProvider)); +}); + +class AuthRepository { + AuthRepository(this._dio, this._storage); + + final Dio _dio; + final TokenStorage _storage; + + Future<({String token, String userId, String? defaultContextId})> register({ + required String email, + required String password, + String? displayName, + }) async { + final res = await _dio.post>( + '/api/auth/register', + data: { + 'email': email, + 'password': password, + if (displayName != null) 'displayName': displayName, + }, + ); + final d = res.data!; + final token = d['token'] as String; + await _storage.writeToken(token); + return ( + token: token, + userId: (d['user'] as Map)['id'] as String, + defaultContextId: d['defaultContextId'] as String?, + ); + } + + Future<({String token, String userId, String? defaultContextId})> login({ + required String email, + required String password, + }) async { + final res = await _dio.post>( + '/api/auth/login', + data: {'email': email, 'password': password}, + ); + final d = res.data!; + final token = d['token'] as String; + await _storage.writeToken(token); + return ( + token: token, + userId: (d['user'] as Map)['id'] as String, + defaultContextId: d['defaultContextId'] as String?, + ); + } + + Future logout() => _storage.clear(); + + Future hasSession() async { + final t = await _storage.readToken(); + return t != null && t.isNotEmpty; + } +} diff --git a/mobile/lib/core/chat_socket.dart b/mobile/lib/core/chat_socket.dart new file mode 100644 index 0000000..d67df9c --- /dev/null +++ b/mobile/lib/core/chat_socket.dart @@ -0,0 +1,187 @@ +import 'dart:async'; +import 'dart:convert'; +import 'dart:math'; + +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:web_socket_channel/web_socket_channel.dart'; + +import '../models/message_model.dart'; +import '../models/ws_chat_side_event.dart'; +import 'api_client.dart'; +import 'api_config.dart'; +import 'token_storage.dart'; + +final chatSocketProvider = Provider((ref) { + final svc = ChatSocketService(ref.watch(tokenStorageProvider)); + ref.onDispose(svc.dispose); + return svc; +}); + +class _PendingSend { + _PendingSend(this.roomId, this.body); + final String roomId; + final String body; +} + +class ChatSocketService { + ChatSocketService(this._storage); + + final TokenStorage _storage; + WebSocketChannel? _channel; + final _incoming = StreamController.broadcast(); + final _side = StreamController.broadcast(); + final Set _subscribedRooms = {}; + final List<_PendingSend> _pendingSends = []; + Timer? _reconnectTimer; + int _reconnectAttempt = 0; + bool _disposed = false; + + int get pendingSendCount => _pendingSends.length; + + Stream get messages => _incoming.stream; + + /// [WsTypingEvent] and [WsReadEvent] from server. + Stream get sideEvents => _side.stream; + + Uri _wsUri(String token) { + final base = ApiConfig.baseUrl.replaceFirst(RegExp(r'^http'), 'ws'); + return Uri.parse('$base/ws').replace(queryParameters: {'token': token}); + } + + Future _closeChannelOnly() async { + await _channel?.sink.close(); + _channel = null; + } + + Future connect() async { + if (_disposed) return; + _reconnectTimer?.cancel(); + _reconnectTimer = null; + await _closeChannelOnly(); + final token = await _storage.readToken(); + if (token == null || token.isEmpty) return; + try { + _channel = WebSocketChannel.connect(_wsUri(token)); + } catch (_) { + _scheduleReconnect(); + return; + } + _reconnectAttempt = 0; + _channel!.stream.listen( + (raw) { + try { + final map = jsonDecode(raw as String) as Map; + final t = map['type'] as String?; + if (t == 'message' && map['message'] != null) { + final m = map['message'] as Map; + _incoming.add(MessageModel.fromWs(m)); + } else if (t == 'typing') { + _side.add( + WsTypingEvent( + roomId: map['roomId'] as String, + userId: map['userId'] as String, + active: map['active'] as bool? ?? false, + ), + ); + } else if (t == 'read') { + _side.add( + WsReadEvent( + roomId: map['roomId'] as String, + userId: map['userId'] as String, + upToMessageId: map['upToMessageId'] as String, + ), + ); + } + } catch (_) {} + }, + onError: (_) => _onConnectionLost(), + onDone: _onConnectionLost, + cancelOnError: false, + ); + for (final id in _subscribedRooms) { + _channel?.sink.add(jsonEncode({'type': 'subscribe', 'roomId': id})); + } + _flushPendingSends(); + } + + void _flushPendingSends() { + if (_channel == null || _pendingSends.isEmpty) return; + final batch = List<_PendingSend>.from(_pendingSends); + _pendingSends.clear(); + for (final p in batch) { + try { + _channel?.sink.add( + jsonEncode({'type': 'send', 'roomId': p.roomId, 'body': p.body}), + ); + } catch (_) { + _pendingSends.add(p); + } + } + } + + void _onConnectionLost() { + if (_disposed) return; + _scheduleReconnect(); + } + + void _scheduleReconnect() { + if (_disposed) return; + _reconnectTimer?.cancel(); + final ms = min(30000, 500 * (1 << min(_reconnectAttempt, 6))); + _reconnectAttempt++; + _reconnectTimer = Timer(Duration(milliseconds: ms), () { + if (_disposed) return; + unawaited(connect()); + }); + } + + /// Logout: cancel reconnect, clear room subscriptions, close socket. + Future disconnect() async { + _reconnectTimer?.cancel(); + _reconnectTimer = null; + _subscribedRooms.clear(); + _pendingSends.clear(); + _reconnectAttempt = 0; + await _closeChannelOnly(); + } + + void subscribeRoom(String roomId) { + _subscribedRooms.add(roomId); + _channel?.sink.add(jsonEncode({'type': 'subscribe', 'roomId': roomId})); + } + + /// Returns false if the message was queued (no socket); true if written to socket. + void sendTyping(String roomId, bool active) { + if (_channel == null) return; + try { + _channel!.sink.add( + jsonEncode({'type': 'typing', 'roomId': roomId, 'active': active}), + ); + } catch (_) {} + } + + bool sendMessage(String roomId, String body) { + if (_channel == null) { + _pendingSends.add(_PendingSend(roomId, body)); + return false; + } + try { + _channel!.sink.add( + jsonEncode({'type': 'send', 'roomId': roomId, 'body': body}), + ); + return true; + } catch (_) { + _pendingSends.add(_PendingSend(roomId, body)); + return false; + } + } + + void dispose() { + _disposed = true; + _reconnectTimer?.cancel(); + _reconnectTimer = null; + unawaited(_closeChannelOnly()); + _incoming.close(); + _side.close(); + } +} diff --git a/mobile/lib/core/demo_accounts.dart b/mobile/lib/core/demo_accounts.dart new file mode 100644 index 0000000..95fac7d --- /dev/null +++ b/mobile/lib/core/demo_accounts.dart @@ -0,0 +1,5 @@ +/// Pre-seeded demo users (see server [seed.ts]). Use only for login UX helpers. +abstract final class DemoAccounts { + static const aliceEmail = 'alice@demo.msn'; + static const password = 'demo1234'; +} diff --git a/mobile/lib/core/fcm_service.dart b/mobile/lib/core/fcm_service.dart new file mode 100644 index 0000000..c4852c2 --- /dev/null +++ b/mobile/lib/core/fcm_service.dart @@ -0,0 +1,79 @@ +import 'package:firebase_core/firebase_core.dart'; +import 'package:firebase_messaging/firebase_messaging.dart'; +import 'package:flutter/foundation.dart'; +import 'package:flutter_local_notifications/flutter_local_notifications.dart'; + +import '../firebase_options.dart'; +import 'msn_api.dart'; + +/// Background handler must be a top-level function. +@pragma('vm:entry-point') +Future firebaseMessagingBackgroundHandler(RemoteMessage message) async { + await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); + debugPrint('FCM background: ${message.messageId}'); +} + +final FlutterLocalNotificationsPlugin _localNotifications = FlutterLocalNotificationsPlugin(); + +bool _fcmInitialized = false; + +/// Call after Firebase.initializeApp. Registers token with [registerPushToken] if API available. +Future initializeFcmAndLocalNotifications(MsnApi api) async { + if (_fcmInitialized) return; + _fcmInitialized = true; + + FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler); + + const androidInit = AndroidInitializationSettings('@mipmap/ic_launcher'); + const iosInit = DarwinInitializationSettings(); + await _localNotifications.initialize( + const InitializationSettings(android: androidInit, iOS: iosInit), + ); + + final messaging = FirebaseMessaging.instance; + await messaging.setForegroundNotificationPresentationOptions( + alert: true, + badge: true, + sound: true, + ); + + await messaging.requestPermission(alert: true, badge: true, sound: true); + + FirebaseMessaging.onMessage.listen((RemoteMessage msg) async { + final n = msg.notification; + final title = n?.title ?? 'IYKYKA'; + final body = n?.body ?? msg.data['body'] as String? ?? ''; + const androidDetails = AndroidNotificationDetails( + 'iykyka_chat', + '채팅', + channelDescription: '새 메시지', + importance: Importance.defaultImportance, + priority: Priority.defaultPriority, + ); + const details = NotificationDetails(android: androidDetails); + await _localNotifications.show( + msg.hashCode, + title, + body, + details, + ); + }); + + try { + final token = await messaging.getToken(); + if (token != null && token.isNotEmpty) { + await api.registerPushToken(token); + debugPrint('FCM token registered with server'); + } + } catch (e) { + debugPrint('FCM getToken/register skipped: $e'); + } + + FirebaseMessaging.instance.onTokenRefresh.listen((token) async { + try { + await api.registerPushToken(token); + } catch (e) { + debugPrint('FCM token refresh register failed: $e'); + } + }); +} diff --git a/mobile/lib/core/msn_api.dart b/mobile/lib/core/msn_api.dart new file mode 100644 index 0000000..aaa3c46 --- /dev/null +++ b/mobile/lib/core/msn_api.dart @@ -0,0 +1,137 @@ +import 'package:dio/dio.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +import '../models/context_member_model.dart'; +import '../models/context_model.dart'; +import '../models/message_model.dart'; +import '../models/profile_model.dart'; +import '../models/room_model.dart'; +import 'api_client.dart'; + +final msnApiProvider = Provider((ref) => MsnApi(ref.watch(dioProvider))); + +class MsnApi { + MsnApi(this._dio); + + final Dio _dio; + + Future> listContexts() async { + final res = await _dio.get>('/api/contexts'); + final list = res.data!['contexts'] as List; + return list.map((e) => ContextModel.fromJson(e as Map)).toList(); + } + + Future createContext({required String name, String kind = 'work'}) async { + final res = await _dio.post>( + '/api/contexts', + data: {'name': name, 'kind': kind}, + ); + final d = res.data!; + return ContextModel( + id: d['id'] as String, + name: d['name'] as String, + kind: d['kind'] as String, + ); + } + + Future inviteToContext(String contextId, String email) async { + await _dio.post('/api/contexts/$contextId/members', data: {'email': email}); + } + + Future> listContextMembers(String contextId) async { + final res = await _dio.get>('/api/contexts/$contextId/members'); + final list = res.data!['members'] as List? ?? []; + return list.map((e) => ContextMember.fromJson(e as Map)).toList(); + } + + Future getMyProfile(String contextId) async { + final res = await _dio.get>( + '/api/profiles/me', + queryParameters: {'contextId': contextId}, + ); + return ProfileModel.fromJson(res.data!); + } + + Future getUserProfile(String contextId, String userId) async { + final res = await _dio.get>( + '/api/profiles/user/$userId', + queryParameters: {'contextId': contextId}, + ); + return ProfileModel.fromJson(res.data!); + } + + Future updateMyProfile( + String contextId, { + String? displayName, + String? statusMessage, + }) async { + await _dio.patch( + '/api/profiles/me', + queryParameters: {'contextId': contextId}, + data: { + if (displayName != null) 'displayName': displayName, + if (statusMessage != null) 'statusMessage': statusMessage, + }, + ); + } + + Future> listRooms(String contextId) async { + final res = await _dio.get>( + '/api/rooms', + queryParameters: {'contextId': contextId}, + ); + final list = res.data!['rooms'] as List? ?? []; + return list.map((e) => RoomModel.fromJson(e as Map)).toList(); + } + + Future openDirectRoom(String contextId, String otherUserId) async { + final res = await _dio.post>( + '/api/rooms/direct', + data: {'contextId': contextId, 'otherUserId': otherUserId}, + ); + return res.data!['roomId'] as String; + } + + Future> fetchMessages(String roomId, {String? before}) async { + final res = await _dio.get>( + '/api/messages', + queryParameters: { + 'roomId': roomId, + 'limit': 50, + if (before != null) 'before': before, + }, + ); + final list = res.data!['messages'] as List? ?? []; + return list.map((e) => MessageModel.fromJson(e as Map)).toList(); + } + + Future registerPushToken(String token, {String platform = 'fcm'}) async { + await _dio.post('/api/push/register', data: {'token': token, 'platform': platform}); + } + + Future createGroupRoom(String contextId, String name, List memberIds) async { + final res = await _dio.post>( + '/api/rooms/group', + data: {'contextId': contextId, 'name': name, 'memberIds': memberIds}, + ); + return res.data!['roomId'] as String; + } + + Future>> searchMessages(String contextId, String q) async { + final res = await _dio.get>( + '/api/messages/search', + queryParameters: {'contextId': contextId, 'q': q}, + ); + final list = res.data!['results'] as List? ?? []; + return list.cast>(); + } + + /// Latest message id read by the other participant in a 1:1 room (null if none / group). + Future getReadState(String roomId) async { + final res = await _dio.get>( + '/api/messages/read-state', + queryParameters: {'roomId': roomId}, + ); + return res.data!['lastReadMessageId'] as String?; + } +} diff --git a/mobile/lib/core/push_routing.dart b/mobile/lib/core/push_routing.dart new file mode 100644 index 0000000..f9a0d0a --- /dev/null +++ b/mobile/lib/core/push_routing.dart @@ -0,0 +1,23 @@ +import 'package:go_router/go_router.dart'; + +/// Parses FCM / notification payloads so the app opens the correct chat. +/// Expected keys: `contextId`, `roomId` (and optional `type`). +class PushRouting { + const PushRouting(); + + /// Build location for go_router, e.g. `/chat?roomId=...&contextId=...` + String? locationFromPayload(Map data) { + final roomId = data['roomId'] as String? ?? data['room_id'] as String?; + final contextId = data['contextId'] as String? ?? data['context_id'] as String?; + if (roomId == null || contextId == null) return null; + return Uri( + path: '/chat', + queryParameters: {'roomId': roomId, 'contextId': contextId}, + ).toString(); + } + + void navigateFromPayload(GoRouter router, Map data) { + final loc = locationFromPayload(data); + if (loc != null) router.go(loc); + } +} diff --git a/mobile/lib/core/session_controller.dart b/mobile/lib/core/session_controller.dart new file mode 100644 index 0000000..ddcf195 --- /dev/null +++ b/mobile/lib/core/session_controller.dart @@ -0,0 +1,104 @@ +import 'package:dio/dio.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +import 'api_client.dart'; + +final sessionProvider = AsyncNotifierProvider( + SessionNotifier.new, +); + +class SessionData { + const SessionData({ + required this.userId, + required this.email, + this.defaultContextId, + this.selectedContextId, + }); + + final String userId; + final String email; + final String? defaultContextId; + final String? selectedContextId; + + String? get effectiveContextId => selectedContextId ?? defaultContextId; +} + +class SessionNotifier extends AsyncNotifier { + static const _kContext = 'msn_selected_context_id'; + + @override + Future build() async { + final storage = ref.read(tokenStorageProvider); + final token = await storage.readToken(); + if (token == null || token.isEmpty) return null; + + final dio = ref.read(dioProvider); + try { + final res = await dio.get>('/api/auth/me'); + final id = res.data!['id'] as String; + final email = res.data!['email'] as String; + final prefs = await SharedPreferences.getInstance(); + final saved = prefs.getString(_kContext); + final ctxRes = await dio.get>('/api/contexts'); + final list = ctxRes.data!['contexts'] as List? ?? []; + String? personalId; + for (final c in list) { + final m = c as Map; + if (m['kind'] == 'personal') { + personalId = m['id'] as String; + break; + } + } + final def = personalId ?? (list.isNotEmpty ? (list.first as Map)['id'] as String : null); + return SessionData( + userId: id, + email: email, + defaultContextId: def, + selectedContextId: saved ?? def, + ); + } on DioException { + await storage.clear(); + return null; + } + } + + Future applyLogin({ + required String userId, + required String email, + String? defaultContextId, + }) async { + final prefs = await SharedPreferences.getInstance(); + final saved = prefs.getString(_kContext); + state = AsyncData( + SessionData( + userId: userId, + email: email, + defaultContextId: defaultContextId, + selectedContextId: saved ?? defaultContextId, + ), + ); + } + + Future setSelectedContext(String contextId) async { + final cur = state.value; + if (cur == null) return; + final prefs = await SharedPreferences.getInstance(); + await prefs.setString(_kContext, contextId); + state = AsyncData( + SessionData( + userId: cur.userId, + email: cur.email, + defaultContextId: cur.defaultContextId, + selectedContextId: contextId, + ), + ); + } + + Future logout() async { + await ref.read(tokenStorageProvider).clear(); + final prefs = await SharedPreferences.getInstance(); + await prefs.remove(_kContext); + state = const AsyncData(null); + } +} diff --git a/mobile/lib/core/token_storage.dart b/mobile/lib/core/token_storage.dart new file mode 100644 index 0000000..8b7a798 --- /dev/null +++ b/mobile/lib/core/token_storage.dart @@ -0,0 +1,16 @@ +import 'package:flutter_secure_storage/flutter_secure_storage.dart'; + +const _kToken = 'msn_jwt'; + +class TokenStorage { + TokenStorage({FlutterSecureStorage? storage}) + : _storage = storage ?? const FlutterSecureStorage(); + + final FlutterSecureStorage _storage; + + Future readToken() => _storage.read(key: _kToken); + + Future writeToken(String token) => _storage.write(key: _kToken, value: token); + + Future clear() => _storage.delete(key: _kToken); +} diff --git a/mobile/lib/data/message_local_store.dart b/mobile/lib/data/message_local_store.dart new file mode 100644 index 0000000..0738d64 --- /dev/null +++ b/mobile/lib/data/message_local_store.dart @@ -0,0 +1,119 @@ +import 'package:flutter/foundation.dart'; +import 'package:path/path.dart' as p; +import 'package:path_provider/path_provider.dart'; +import 'package:sqflite/sqflite.dart'; + +import '../models/message_model.dart'; + +/// Local cache of messages keyed by context + room (plan: 맥락 ID 반영). +/// On **web**, uses in-memory storage only (`sqflite` is not supported). +class MessageLocalStore { + MessageLocalStore(); + + Database? _db; + + /// Web-only: key = "contextId::roomId" + final Map> _memory = {}; + + static String _memKey(String contextId, String roomId) => '$contextId::$roomId'; + + Future get database async { + if (kIsWeb) { + throw UnsupportedError('database getter should not be used on web'); + } + if (_db != null) return _db!; + final dir = await getApplicationDocumentsDirectory(); + final path = p.join(dir.path, 'msn_messages.db'); + _db = await openDatabase( + path, + version: 1, + onCreate: (db, v) async { + await db.execute(''' +CREATE TABLE messages ( + id TEXT NOT NULL, + context_id TEXT NOT NULL, + room_id TEXT NOT NULL, + sender_id TEXT NOT NULL, + body TEXT NOT NULL, + created_at TEXT NOT NULL, + kind TEXT NOT NULL DEFAULT 'text', + PRIMARY KEY (id, context_id) +); +'''); + await db.execute( + 'CREATE INDEX idx_room_ctx ON messages(room_id, context_id, created_at);', + ); + }, + ); + return _db!; + } + + /// [roomId] required so empty API results can clear the web cache. + Future upsertMessages( + String contextId, + String roomId, + List list, + ) async { + if (kIsWeb) { + final key = _memKey(contextId, roomId); + if (list.isEmpty) { + _memory[key] = []; + return; + } + final byId = { + for (final m in _memory[key] ?? []) m.id: m, + }; + for (final m in list) { + byId[m.id] = m; + } + final merged = byId.values.toList() + ..sort((a, b) => a.createdAt.compareTo(b.createdAt)); + _memory[key] = merged; + return; + } + + final db = await database; + final batch = db.batch(); + for (final m in list) { + batch.insert( + 'messages', + { + 'id': m.id, + 'context_id': contextId, + 'room_id': m.roomId, + 'sender_id': m.senderId, + 'body': m.body, + 'created_at': m.createdAt, + 'kind': m.kind, + }, + conflictAlgorithm: ConflictAlgorithm.replace, + ); + } + await batch.commit(noResult: true); + } + + Future> listForRoom(String contextId, String roomId) async { + if (kIsWeb) { + return List.from(_memory[_memKey(contextId, roomId)] ?? []); + } + final db = await database; + final rows = await db.query( + 'messages', + where: 'context_id = ? AND room_id = ?', + whereArgs: [contextId, roomId], + orderBy: 'created_at ASC', + ); + return rows + .map( + (r) => MessageModel( + id: r['id']! as String, + roomId: r['room_id']! as String, + senderId: r['sender_id']! as String, + body: r['body']! as String, + createdAt: r['created_at']! as String, + kind: r['kind'] as String? ?? 'text', + ), + ) + .toList(); + } +} diff --git a/mobile/lib/features/auth/login_page.dart b/mobile/lib/features/auth/login_page.dart new file mode 100644 index 0000000..494b7f7 --- /dev/null +++ b/mobile/lib/features/auth/login_page.dart @@ -0,0 +1,204 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; + +import '../../core/auth_repository.dart'; +import '../../core/demo_accounts.dart'; +import '../../core/session_controller.dart'; +import '../../theme/toss_theme.dart'; + +class LoginPage extends ConsumerStatefulWidget { + const LoginPage({super.key}); + + @override + ConsumerState createState() => _LoginPageState(); +} + +class _LoginPageState extends ConsumerState { + final _email = TextEditingController(); + final _password = TextEditingController(); + String? _error; + bool _busy = false; + + @override + void dispose() { + _email.dispose(); + _password.dispose(); + super.dispose(); + } + + void _fillDemo() { + setState(() { + _email.text = DemoAccounts.aliceEmail; + _password.text = DemoAccounts.password; + _error = null; + }); + } + + Future _submit() async { + setState(() { + _busy = true; + _error = null; + }); + try { + final r = await ref.read(authRepositoryProvider).login( + email: _email.text.trim(), + password: _password.text, + ); + await ref.read(sessionProvider.notifier).applyLogin( + userId: r.userId, + email: _email.text.trim(), + defaultContextId: r.defaultContextId, + ); + if (!mounted) return; + context.go('/'); + } catch (e) { + setState(() => _error = e.toString()); + } finally { + if (mounted) setState(() => _busy = false); + } + } + + @override + Widget build(BuildContext context) { + final tt = Theme.of(context).textTheme; + + return Scaffold( + body: SafeArea( + child: SingleChildScrollView( + padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + const SizedBox(height: 32), + Center( + child: Container( + width: 72, + height: 72, + decoration: BoxDecoration( + color: TossColors.surface, + borderRadius: BorderRadius.circular(22), + boxShadow: [ + BoxShadow( + color: TossColors.blue.withValues(alpha: 0.15), + blurRadius: 24, + offset: const Offset(0, 8), + ), + ], + ), + child: const Icon(Icons.chat_bubble_rounded, size: 36, color: TossColors.blue), + ), + ), + const SizedBox(height: 28), + Text( + 'IYKYKA', + textAlign: TextAlign.center, + style: tt.headlineLarge?.copyWith( + letterSpacing: 0.5, + fontWeight: FontWeight.w800, + ), + ), + const SizedBox(height: 6), + Text( + 'If you know, you know.', + textAlign: TextAlign.center, + style: tt.bodySmall?.copyWith(color: TossColors.textSecondary), + ), + const SizedBox(height: 12), + Text( + '일상과 직장, 한 앱에서 나눠 쓰기', + textAlign: TextAlign.center, + style: tt.bodyMedium, + ), + const SizedBox(height: 40), + Container( + decoration: BoxDecoration( + color: TossColors.surface, + borderRadius: BorderRadius.circular(16), + boxShadow: [ + BoxShadow( + color: Colors.black.withValues(alpha: 0.04), + blurRadius: 16, + offset: const Offset(0, 4), + ), + ], + ), + padding: const EdgeInsets.all(20), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('데모로 시작하기', style: tt.titleMedium), + const SizedBox(height: 8), + Text( + '서버 실행 후 아래를 누르면 필드가 채워집니다. ' + '홈에서 「데모 회사」를 고르면 직장 샘플 대화를 볼 수 있어요.', + style: tt.bodySmall?.copyWith(height: 1.4), + ), + const SizedBox(height: 16), + SizedBox( + width: double.infinity, + child: OutlinedButton( + onPressed: _busy ? null : _fillDemo, + child: const Text('데모 계정으로 채우기'), + ), + ), + ], + ), + ), + const SizedBox(height: 28), + TextField( + controller: _email, + decoration: const InputDecoration( + labelText: '이메일', + prefixIcon: Icon(Icons.mail_outline_rounded, color: TossColors.textSecondary), + ), + keyboardType: TextInputType.emailAddress, + autofillHints: const [AutofillHints.email], + ), + const SizedBox(height: 12), + TextField( + controller: _password, + decoration: const InputDecoration( + labelText: '비밀번호', + prefixIcon: Icon(Icons.lock_outline_rounded, color: TossColors.textSecondary), + ), + obscureText: true, + autofillHints: const [AutofillHints.password], + ), + if (_error != null) ...[ + const SizedBox(height: 12), + Text( + _error!, + style: TextStyle(color: Theme.of(context).colorScheme.error, fontSize: 13), + ), + ], + const SizedBox(height: 28), + SizedBox( + width: double.infinity, + height: 54, + child: FilledButton( + onPressed: _busy ? null : _submit, + child: _busy + ? const SizedBox( + height: 22, + width: 22, + child: CircularProgressIndicator( + strokeWidth: 2, + color: Colors.white, + ), + ) + : const Text('로그인'), + ), + ), + const SizedBox(height: 8), + TextButton( + onPressed: _busy ? null : () => context.go('/register'), + child: const Text('계정이 없어요'), + ), + ], + ), + ), + ), + ); + } +} diff --git a/mobile/lib/features/auth/register_page.dart b/mobile/lib/features/auth/register_page.dart new file mode 100644 index 0000000..cd0d395 --- /dev/null +++ b/mobile/lib/features/auth/register_page.dart @@ -0,0 +1,133 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; + +import '../../core/auth_repository.dart'; +import '../../core/session_controller.dart'; +import '../../theme/toss_theme.dart'; + +/// New accounts only. Pre-seeded demo users (`alice@demo.msn`) are for sign-in, not registration. +class RegisterPage extends ConsumerStatefulWidget { + const RegisterPage({super.key}); + + @override + ConsumerState createState() => _RegisterPageState(); +} + +class _RegisterPageState extends ConsumerState { + final _email = TextEditingController(); + final _password = TextEditingController(); + final _name = TextEditingController(); + String? _error; + bool _busy = false; + + @override + void dispose() { + _email.dispose(); + _password.dispose(); + _name.dispose(); + super.dispose(); + } + + Future _submit() async { + setState(() { + _busy = true; + _error = null; + }); + try { + final r = await ref.read(authRepositoryProvider).register( + email: _email.text.trim(), + password: _password.text, + displayName: _name.text.trim().isEmpty ? null : _name.text.trim(), + ); + await ref.read(sessionProvider.notifier).applyLogin( + userId: r.userId, + email: _email.text.trim(), + defaultContextId: r.defaultContextId, + ); + if (!mounted) return; + context.go('/'); + } catch (e) { + setState(() => _error = e.toString()); + } finally { + if (mounted) setState(() => _busy = false); + } + } + + @override + Widget build(BuildContext context) { + final tt = Theme.of(context).textTheme; + + return Scaffold( + backgroundColor: TossColors.bg, + appBar: AppBar(title: const Text('회원가입')), + body: SafeArea( + child: SingleChildScrollView( + padding: const EdgeInsets.all(24), + child: Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Text('새 계정 만들기', style: tt.headlineMedium), + const SizedBox(height: 8), + Text( + '데모 계정은 로그인 화면에서 이용해 주세요.', + style: tt.bodySmall, + ), + const SizedBox(height: 28), + TextField( + controller: _email, + decoration: const InputDecoration( + labelText: '이메일', + prefixIcon: Icon(Icons.mail_outline_rounded, color: TossColors.textSecondary), + ), + keyboardType: TextInputType.emailAddress, + ), + const SizedBox(height: 12), + TextField( + controller: _password, + decoration: const InputDecoration( + labelText: '비밀번호', + prefixIcon: Icon(Icons.lock_outline_rounded, color: TossColors.textSecondary), + ), + obscureText: true, + ), + const SizedBox(height: 12), + TextField( + controller: _name, + decoration: const InputDecoration( + labelText: '표시 이름 (선택)', + prefixIcon: Icon(Icons.badge_outlined, color: TossColors.textSecondary), + ), + ), + if (_error != null) ...[ + const SizedBox(height: 12), + Text( + _error!, + style: TextStyle(color: Theme.of(context).colorScheme.error, fontSize: 13), + ), + ], + const SizedBox(height: 28), + SizedBox( + height: 52, + child: FilledButton( + onPressed: _busy ? null : _submit, + child: _busy + ? const SizedBox( + height: 22, + width: 22, + child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white), + ) + : const Text('가입하기'), + ), + ), + TextButton( + onPressed: _busy ? null : () => context.go('/login'), + child: const Text('로그인으로 돌아가기'), + ), + ], + ), + ), + ), + ); + } +} diff --git a/mobile/lib/features/chat/chat_page.dart b/mobile/lib/features/chat/chat_page.dart new file mode 100644 index 0000000..228bd68 --- /dev/null +++ b/mobile/lib/features/chat/chat_page.dart @@ -0,0 +1,510 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +import '../../core/api_client.dart'; +import '../../core/chat_socket.dart'; +import '../../core/msn_api.dart'; +import '../../core/session_controller.dart'; +import '../../data/message_local_store.dart'; +import '../../models/message_model.dart'; +import '../../models/room_model.dart'; +import '../../models/ws_chat_side_event.dart'; +import '../../theme/toss_theme.dart'; +import '../profile/user_profile_sheet.dart'; + +final messageLocalStoreProvider = Provider((ref) => MessageLocalStore()); + +class ChatPage extends ConsumerStatefulWidget { + const ChatPage({super.key, required this.roomId, required this.contextId}); + + final String roomId; + final String contextId; + + @override + ConsumerState createState() => _ChatPageState(); +} + +class _ChatPageState extends ConsumerState { + final _controller = TextEditingController(); + final _scroll = ScrollController(); + final List _items = []; + StreamSubscription? _sub; + bool _loading = true; + String? _contextName; + String? _bootstrapError; + /// From room list; null until loaded. + bool? _roomIsGroup; + String? _roomName; + String? _lastReadByOther; + StreamSubscription? _sideSub; + Timer? _typingDebounce; + Timer? _typingClear; + String? _typingUserId; + + @override + void initState() { + super.initState(); + _bootstrap(); + } + + Future _bootstrap() async { + setState(() { + _bootstrapError = null; + _loading = true; + }); + + final api = ref.read(msnApiProvider); + final store = ref.read(messageLocalStoreProvider); + + try { + try { + final contexts = await api.listContexts(); + final match = contexts.where((c) => c.id == widget.contextId).toList(); + if (match.isNotEmpty && mounted) { + setState(() => _contextName = match.first.name); + } + } catch (_) {} + + RoomModel? roomMeta; + try { + final rooms = await api.listRooms(widget.contextId); + for (final r in rooms) { + if (r.id == widget.roomId) { + roomMeta = r; + break; + } + } + } catch (_) {} + + await ref.read(chatSocketProvider).connect(); + final list = await api.fetchMessages(widget.roomId); + await store.upsertMessages(widget.contextId, widget.roomId, list); + final local = await store.listForRoom(widget.contextId, widget.roomId); + if (!mounted) return; + + setState(() { + _items + ..clear() + ..addAll(local.isNotEmpty ? local : list); + _loading = false; + _roomIsGroup = roomMeta?.isGroup; + _roomName = roomMeta?.name; + }); + + if (roomMeta?.isGroup == false) { + unawaited(_refreshReadState()); + } + + ref.read(chatSocketProvider).subscribeRoom(widget.roomId); + _sub = ref.read(chatSocketProvider).messages.listen((m) { + if (m.roomId != widget.roomId) return; + setState(() { + _items.add(m); + }); + unawaited(store.upsertMessages(widget.contextId, widget.roomId, [m])); + unawaited(_markRead(m)); + if (_roomIsGroup == false) { + unawaited(_refreshReadState()); + } + }); + + _sideSub = ref.read(chatSocketProvider).sideEvents.listen((ev) { + if (ev is WsTypingEvent) { + if (ev.roomId != widget.roomId) return; + final myId = ref.read(sessionProvider).value?.userId; + if (myId == null || ev.userId == myId) return; + _typingClear?.cancel(); + if (ev.active) { + setState(() => _typingUserId = ev.userId); + _typingClear = Timer(const Duration(seconds: 3), () { + if (mounted) setState(() => _typingUserId = null); + }); + } else { + setState(() => _typingUserId = null); + } + } else if (ev is WsReadEvent) { + if (ev.roomId != widget.roomId) return; + unawaited(_refreshReadState()); + } + }); + + if (_items.isNotEmpty) { + unawaited(_markRead(_items.last)); + } + } catch (e, st) { + debugPrint('ChatPage _bootstrap: $e\n$st'); + if (!mounted) return; + setState(() { + _loading = false; + _bootstrapError = e.toString(); + }); + } + } + + Future _refreshReadState() async { + if (_roomIsGroup == true) return; + try { + final id = await ref.read(msnApiProvider).getReadState(widget.roomId); + if (!mounted) return; + setState(() => _lastReadByOther = id); + } catch (_) {} + } + + Future _markRead(MessageModel last) async { + try { + await ref.read(dioProvider).post( + '/api/messages/read', + data: {'roomId': widget.roomId, 'upToMessageId': last.id}, + ); + } catch (_) {} + } + + @override + void dispose() { + _sub?.cancel(); + _sideSub?.cancel(); + _typingDebounce?.cancel(); + _typingClear?.cancel(); + ref.read(chatSocketProvider).sendTyping(widget.roomId, false); + _controller.dispose(); + _scroll.dispose(); + super.dispose(); + } + + void _onInputChanged(String text) { + if (_roomIsGroup == true) return; + _typingDebounce?.cancel(); + final socket = ref.read(chatSocketProvider); + if (text.trim().isEmpty) { + socket.sendTyping(widget.roomId, false); + return; + } + _typingDebounce = Timer(const Duration(milliseconds: 400), () { + socket.sendTyping(widget.roomId, true); + }); + } + + int? _lastMyMessageIndex(String me) { + for (var i = _items.length - 1; i >= 0; i--) { + if (_items[i].senderId == me) return i; + } + return null; + } + + bool _showReadReceipt(String me) { + if (_roomIsGroup == true || _lastReadByOther == null) return false; + final myIdx = _lastMyMessageIndex(me); + if (myIdx == null) return false; + final readIdx = _items.indexWhere((m) => m.id == _lastReadByOther); + if (readIdx < 0) return false; + return readIdx >= myIdx; + } + + void _send() { + final text = _controller.text.trim(); + if (text.isEmpty) return; + ref.read(chatSocketProvider).sendTyping(widget.roomId, false); + final sent = ref.read(chatSocketProvider).sendMessage(widget.roomId, text); + _controller.clear(); + if (!sent && mounted) { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('연결을 기다리는 중입니다. 복구되면 자동으로 전송됩니다.')), + ); + } + } + + @override + Widget build(BuildContext context) { + final me = ref.watch(sessionProvider).value?.userId ?? ''; + final theme = Theme.of(context); + + return Scaffold( + backgroundColor: TossColors.bg, + appBar: AppBar( + title: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + _roomIsGroup == true ? (_roomName ?? '그룹 채팅') : '채팅', + style: theme.textTheme.titleLarge, + ), + if (_typingUserId != null) + Padding( + padding: const EdgeInsets.only(top: 4), + child: Text( + '상대가 입력 중…', + style: theme.textTheme.labelSmall?.copyWith( + color: TossColors.blue, + fontWeight: FontWeight.w600, + ), + ), + ), + if (_contextName != null) + Padding( + padding: const EdgeInsets.only(top: 2), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Container( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2), + decoration: BoxDecoration( + color: TossColors.blue.withValues(alpha: 0.12), + borderRadius: BorderRadius.circular(6), + ), + child: Text( + _contextName!, + style: theme.textTheme.labelSmall?.copyWith( + color: TossColors.blueDark, + fontWeight: FontWeight.w600, + ), + ), + ), + ], + ), + ), + ], + ), + actions: [ + if (_roomIsGroup == true) + IconButton( + tooltip: '그룹 정보', + icon: const Icon(Icons.groups_outlined), + onPressed: _showGroupRoomSheet, + ) + else if (_roomIsGroup == false) + IconButton( + tooltip: '프로필', + icon: const Icon(Icons.person_outline_rounded), + onPressed: () async { + final other = await _resolveOtherUserId(); + if (!context.mounted || other == null) return; + await showUserProfileSheet( + context, + ref, + contextId: widget.contextId, + userId: other, + ); + }, + ), + ], + ), + body: Column( + children: [ + Expanded( + child: _loading + ? const Center(child: CircularProgressIndicator(color: TossColors.blue)) + : _bootstrapError != null && _items.isEmpty + ? Center( + child: Padding( + padding: const EdgeInsets.all(24), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Icon(Icons.wifi_off_rounded, size: 48, color: theme.colorScheme.error), + const SizedBox(height: 16), + Text( + '불러오지 못했어요', + style: theme.textTheme.titleMedium, + ), + const SizedBox(height: 8), + Text( + _bootstrapError!, + textAlign: TextAlign.center, + style: theme.textTheme.bodySmall, + ), + const SizedBox(height: 20), + FilledButton( + onPressed: () { + _sub?.cancel(); + _sub = null; + _bootstrap(); + }, + child: const Text('다시 시도'), + ), + ], + ), + ), + ) + : ListView.builder( + controller: _scroll, + padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 8), + itemCount: _items.length, + itemBuilder: (context, i) { + final m = _items[i]; + final mine = m.senderId == me; + final lastMy = _lastMyMessageIndex(me); + final showRead = mine && + lastMy == i && + _showReadReceipt(me); + return Align( + alignment: mine ? Alignment.centerRight : Alignment.centerLeft, + child: Column( + crossAxisAlignment: + mine ? CrossAxisAlignment.end : CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Container( + margin: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), + constraints: BoxConstraints( + maxWidth: MediaQuery.sizeOf(context).width * 0.78, + ), + decoration: BoxDecoration( + color: mine ? TossColors.blue : TossColors.surface, + borderRadius: BorderRadius.only( + topLeft: const Radius.circular(20), + topRight: const Radius.circular(20), + bottomLeft: Radius.circular(mine ? 20 : 6), + bottomRight: Radius.circular(mine ? 6 : 20), + ), + border: mine ? null : Border.all(color: TossColors.line), + boxShadow: [ + BoxShadow( + color: Colors.black.withValues(alpha: 0.05), + blurRadius: 8, + offset: const Offset(0, 2), + ), + ], + ), + child: Text( + m.body, + style: theme.textTheme.bodyLarge?.copyWith( + color: mine ? Colors.white : TossColors.textPrimary, + height: 1.35, + ), + ), + ), + if (showRead) + Padding( + padding: const EdgeInsets.only(right: 12, bottom: 4), + child: Text( + '읽음', + style: theme.textTheme.labelSmall?.copyWith( + color: TossColors.textSecondary, + ), + ), + ), + ], + ), + ); + }, + ), + ), + Container( + color: TossColors.surface, + padding: EdgeInsets.fromLTRB( + 12, + 8, + 12, + 8 + MediaQuery.paddingOf(context).bottom, + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded( + child: TextField( + controller: _controller, + decoration: InputDecoration( + hintText: '메시지를 입력하세요', + hintStyle: theme.textTheme.bodyMedium, + filled: true, + fillColor: TossColors.bg, + contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(22), + borderSide: BorderSide.none, + ), + ), + minLines: 1, + maxLines: 4, + onChanged: _onInputChanged, + onSubmitted: (_) => _send(), + ), + ), + const SizedBox(width: 8), + Material( + color: TossColors.blue, + borderRadius: BorderRadius.circular(22), + child: InkWell( + onTap: _send, + borderRadius: BorderRadius.circular(22), + child: const Padding( + padding: EdgeInsets.all(12), + child: Icon(Icons.arrow_upward_rounded, color: Colors.white, size: 22), + ), + ), + ), + ], + ), + ), + ], + ), + ); + } + + Future _showGroupRoomSheet() async { + try { + final res = await ref.read(dioProvider).get>( + '/api/rooms/${widget.roomId}/participants', + ); + final ids = (res.data!['userIds'] as List).cast(); + if (!mounted) return; + await showModalBottomSheet( + context: context, + showDragHandle: true, + backgroundColor: TossColors.surface, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical(top: Radius.circular(20)), + ), + builder: (ctx) { + final tt = Theme.of(ctx).textTheme; + return SafeArea( + child: Padding( + padding: const EdgeInsets.fromLTRB(24, 8, 24, 24), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Text( + _roomName ?? '그룹 채팅', + style: tt.titleLarge, + ), + const SizedBox(height: 8), + Text( + '참여자 ${ids.length}명', + style: tt.bodyLarge, + ), + const SizedBox(height: 12), + Text( + '이 맥락에서만 보이는 그룹 대화입니다.', + style: tt.bodySmall, + ), + ], + ), + ), + ); + }, + ); + } catch (_) {} + } + + Future _resolveOtherUserId() async { + try { + final res = await ref.read(dioProvider).get>( + '/api/rooms/${widget.roomId}/participants', + ); + final ids = (res.data!['userIds'] as List).cast(); + final session = ref.read(sessionProvider).value; + final meId = session?.userId; + for (final id in ids) { + if (id != meId) return id; + } + return ids.isNotEmpty ? ids.first : null; + } catch (_) { + return null; + } + } +} diff --git a/mobile/lib/features/home/context_members_tab.dart b/mobile/lib/features/home/context_members_tab.dart new file mode 100644 index 0000000..980e4d7 --- /dev/null +++ b/mobile/lib/features/home/context_members_tab.dart @@ -0,0 +1,189 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; + +import '../../core/msn_api.dart'; +import '../../core/session_controller.dart'; +import '../../theme/toss_theme.dart'; +import '../profile/user_profile_sheet.dart'; +import 'home_providers.dart'; + +/// Members of the selected messenger space: row tap opens DM; profile icon opens sheet. +class ContextMembersTab extends ConsumerWidget { + const ContextMembersTab({super.key, required this.contextId}); + + final String contextId; + + @override + Widget build(BuildContext context, WidgetRef ref) { + final session = ref.watch(sessionProvider).value; + final myId = session?.userId; + final async = ref.watch(membersForContextProvider(contextId)); + + return async.when( + loading: () => const Center(child: CircularProgressIndicator(color: TossColors.blue)), + error: (e, _) => Center(child: Text('$e')), + data: (members) { + if (members.isEmpty) { + return ListView( + physics: const AlwaysScrollableScrollPhysics(), + children: const [ + SizedBox(height: 120), + Center(child: Text('친구가 없습니다')), + ], + ); + } + return RefreshIndicator( + color: TossColors.blue, + onRefresh: () async { + ref.invalidate(membersForContextProvider(contextId)); + await ref.read(membersForContextProvider(contextId).future); + }, + child: ListView.separated( + physics: const AlwaysScrollableScrollPhysics(), + padding: const EdgeInsets.fromLTRB(16, 8, 16, 100), + itemCount: members.length, + separatorBuilder: (_, __) => const SizedBox(height: 10), + itemBuilder: (context, i) { + final m = members[i]; + final isSelf = myId != null && m.userId == myId; + + Future openChat() async { + final roomId = + await ref.read(msnApiProvider).openDirectRoom(contextId, m.userId); + if (!context.mounted) return; + await context.push('/chat?roomId=$roomId&contextId=$contextId'); + } + + Future openProfile() async { + await showUserProfileSheet( + context, + ref, + contextId: contextId, + userId: m.userId, + ); + } + + return Material( + color: TossColors.surface, + borderRadius: BorderRadius.circular(16), + child: Ink( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16), + border: Border.all(color: TossColors.line), + ), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 6), + child: Row( + children: [ + Expanded( + child: InkWell( + borderRadius: BorderRadius.circular(12), + onTap: () async { + if (isSelf) { + await openProfile(); + } else { + await openChat(); + } + }, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 8), + child: Row( + children: [ + CircleAvatar( + radius: 22, + backgroundColor: TossColors.blue.withValues(alpha: 0.1), + backgroundImage: + m.avatarUrl != null && m.avatarUrl!.isNotEmpty + ? NetworkImage(m.avatarUrl!) + : null, + child: m.avatarUrl == null || m.avatarUrl!.isEmpty + ? Text( + m.displayName.isNotEmpty + ? m.displayName[0].toUpperCase() + : '?', + style: const TextStyle( + color: TossColors.blue, + fontWeight: FontWeight.w600, + ), + ) + : null, + ), + const SizedBox(width: 14), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + children: [ + Expanded( + child: Text( + m.displayName.isNotEmpty + ? m.displayName + : m.userId, + style: Theme.of(context).textTheme.titleMedium, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + ), + if (isSelf) + Padding( + padding: const EdgeInsets.only(left: 8), + child: Text( + '나', + style: Theme.of(context) + .textTheme + .labelSmall + ?.copyWith( + color: TossColors.textSecondary, + ), + ), + ), + ], + ), + if (m.statusMessage != null && + m.statusMessage!.isNotEmpty) ...[ + const SizedBox(height: 4), + Text( + m.statusMessage!, + style: Theme.of(context).textTheme.bodySmall, + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + ], + ], + ), + ), + if (!isSelf) + Icon( + Icons.chat_bubble_outline, + size: 20, + color: TossColors.blue.withValues(alpha: 0.7), + ), + ], + ), + ), + ), + ), + IconButton( + tooltip: '프로필', + icon: Icon( + Icons.person_outline_rounded, + color: Theme.of(context).colorScheme.onSurfaceVariant, + ), + onPressed: () async { + await openProfile(); + }, + ), + ], + ), + ), + ), + ); + }, + ), + ); + }, + ); + } +} diff --git a/mobile/lib/features/home/home_page.dart b/mobile/lib/features/home/home_page.dart new file mode 100644 index 0000000..158fd54 --- /dev/null +++ b/mobile/lib/features/home/home_page.dart @@ -0,0 +1,512 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; + +import '../../core/app_settings.dart'; +import '../../core/chat_socket.dart'; +import '../../core/fcm_service.dart'; +import '../../core/msn_api.dart'; +import '../../core/session_controller.dart'; +import '../../theme/toss_theme.dart'; +import 'context_members_tab.dart'; +import 'home_providers.dart'; +import 'my_profile_tab.dart'; + +class HomePage extends ConsumerStatefulWidget { + const HomePage({super.key}); + + @override + ConsumerState createState() => _HomePageState(); +} + +class _HomePageState extends ConsumerState { + int _tabIndex = 0; + + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addPostFrameCallback((_) async { + await ref.read(chatSocketProvider).connect(); + if (await readNotificationsEnabledFromPrefs()) { + try { + await initializeFcmAndLocalNotifications(ref.read(msnApiProvider)); + } catch (e, st) { + debugPrint('FCM init: $e\n$st'); + } + } + }); + } + + Future _onRefresh() async { + ref.invalidate(contextsListProvider); + final cid = ref.read(sessionProvider).value?.effectiveContextId; + if (cid != null) { + ref.invalidate(roomsForContextProvider(cid)); + ref.invalidate(membersForContextProvider(cid)); + ref.invalidate(myProfileForContextProvider(cid)); + } + await ref.read(contextsListProvider.future); + if (cid != null) { + await ref.read(roomsForContextProvider(cid).future); + } + } + + Future _pickContext(String? id) async { + if (id == null) return; + await ref.read(sessionProvider.notifier).setSelectedContext(id); + setState(() {}); + } + + IconData _iconForKind(String kind) { + switch (kind) { + case 'work': + return Icons.business_outlined; + case 'personal': + return Icons.home_outlined; + default: + return Icons.folder_outlined; + } + } + + Future _addWorkContext() async { + final name = TextEditingController(); + final ok = await showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: const Text('New work context'), + content: TextField( + controller: name, + decoration: const InputDecoration(labelText: 'Name'), + ), + actions: [ + TextButton(onPressed: () => Navigator.pop(ctx, false), child: const Text('Cancel')), + FilledButton(onPressed: () => Navigator.pop(ctx, true), child: const Text('Create')), + ], + ), + ); + if (ok == true && name.text.trim().isNotEmpty) { + await ref.read(msnApiProvider).createContext(name: name.text.trim(), kind: 'work'); + ref.invalidate(contextsListProvider); + } + name.dispose(); + } + + Future _inviteEmail() async { + final session = ref.read(sessionProvider).value; + final cid = session?.effectiveContextId; + if (cid == null) return; + final email = TextEditingController(); + final ok = await showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: const Text('Invite by email'), + content: TextField( + controller: email, + decoration: const InputDecoration(labelText: 'Email'), + ), + actions: [ + TextButton(onPressed: () => Navigator.pop(ctx, false), child: const Text('Cancel')), + FilledButton(onPressed: () => Navigator.pop(ctx, true), child: const Text('Invite')), + ], + ), + ); + if (ok == true && email.text.trim().isNotEmpty) { + try { + await ref.read(msnApiProvider).inviteToContext(cid, email.text.trim()); + ref.invalidate(membersForContextProvider(cid)); + if (!mounted) return; + ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('Invited'))); + } catch (e) { + if (!mounted) return; + ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('$e'))); + } + } + email.dispose(); + } + + Future _openDirect() async { + final session = ref.read(sessionProvider).value; + final cid = session?.effectiveContextId; + if (cid == null) return; + final uid = TextEditingController(); + final ok = await showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: const Text('Open direct chat'), + content: TextField( + controller: uid, + decoration: const InputDecoration(labelText: 'Other user ID (UUID)'), + ), + actions: [ + TextButton(onPressed: () => Navigator.pop(ctx, false), child: const Text('Cancel')), + FilledButton(onPressed: () => Navigator.pop(ctx, true), child: const Text('Open')), + ], + ), + ); + if (ok == true && uid.text.trim().isNotEmpty) { + final roomId = await ref.read(msnApiProvider).openDirectRoom(cid, uid.text.trim()); + if (!mounted) return; + await context.push('/chat?roomId=$roomId&contextId=$cid'); + } + uid.dispose(); + } + + Future _createGroup() async { + final session = ref.read(sessionProvider).value; + final cid = session?.effectiveContextId; + if (cid == null) return; + final name = TextEditingController(); + final ok = await showDialog( + context: context, + builder: (ctx) => AlertDialog( + title: const Text('New group'), + content: TextField( + controller: name, + decoration: const InputDecoration(labelText: 'Group name'), + ), + actions: [ + TextButton(onPressed: () => Navigator.pop(ctx, false), child: const Text('Cancel')), + FilledButton(onPressed: () => Navigator.pop(ctx, true), child: const Text('Create')), + ], + ), + ); + if (ok == true && name.text.trim().isNotEmpty) { + await ref.read(msnApiProvider).createGroupRoom(cid, name.text.trim(), []); + ref.invalidate(roomsForContextProvider(cid)); + } + name.dispose(); + } + + @override + Widget build(BuildContext context) { + final session = ref.watch(sessionProvider).value; + final cid = session?.effectiveContextId; + final contextsAsync = ref.watch(contextsListProvider); + + const tabTitles = ['채팅', '친구', '내 정보']; + + return Scaffold( + backgroundColor: TossColors.bg, + appBar: AppBar( + title: Text(tabTitles[_tabIndex.clamp(0, tabTitles.length - 1)]), + actions: [ + IconButton( + icon: const Icon(Icons.search), + onPressed: cid == null ? null : () => context.push('/search?contextId=$cid'), + ), + PopupMenuButton( + onSelected: (v) async { + if (v == 'settings') await context.push('/settings'); + if (v == 'logout') { + await ref.read(chatSocketProvider).disconnect(); + await ref.read(sessionProvider.notifier).logout(); + } + if (v == 'work') await _addWorkContext(); + if (v == 'invite') await _inviteEmail(); + if (v == 'group') await _createGroup(); + }, + itemBuilder: (context) => const [ + PopupMenuItem(value: 'settings', child: Text('설정')), + PopupMenuItem(value: 'work', child: Text('직장 맥락 추가')), + PopupMenuItem(value: 'invite', child: Text('이 맥락에 초대')), + PopupMenuItem(value: 'group', child: Text('그룹 만들기')), + PopupMenuItem(value: 'logout', child: Text('로그아웃')), + ], + ), + ], + ), + body: contextsAsync.when( + loading: () => const Center(child: CircularProgressIndicator(color: TossColors.blue)), + error: (e, _) => Center(child: Text('Contexts: $e')), + data: (list) { + final effective = cid != null && list.any((c) => c.id == cid) + ? cid + : (list.isNotEmpty ? list.first.id : null); + + return Column( + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Padding( + padding: const EdgeInsets.fromLTRB(16, 12, 16, 8), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + '메신저 공간', + style: Theme.of(context).textTheme.titleMedium, + ), + const SizedBox(height: 4), + Text( + '선택한 공간의 대화·친구·프로필이에요. 탭해서 일상 · 직장을 전환하세요', + style: Theme.of(context).textTheme.bodySmall, + ), + const SizedBox(height: 14), + SizedBox( + height: 46, + child: ListView.separated( + scrollDirection: Axis.horizontal, + itemCount: list.length, + separatorBuilder: (_, __) => const SizedBox(width: 8), + itemBuilder: (context, i) { + final c = list[i]; + final selected = effective == c.id; + return _TossContextChip( + label: c.name, + icon: _iconForKind(c.kind), + selected: selected, + onTap: () => _pickContext(c.id), + ); + }, + ), + ), + ], + ), + ), + Expanded( + child: effective == null + ? const Center(child: Text('맥락이 없습니다')) + : IndexedStack( + index: _tabIndex, + children: [ + RefreshIndicator( + onRefresh: _onRefresh, + child: CustomScrollView( + physics: const AlwaysScrollableScrollPhysics(), + slivers: _roomSlivers(context, effective), + ), + ), + ContextMembersTab(contextId: effective), + const MyProfileTab(), + ], + ), + ), + ], + ); + }, + ), + bottomNavigationBar: NavigationBar( + selectedIndex: _tabIndex, + onDestinationSelected: (i) => setState(() => _tabIndex = i), + destinations: const [ + NavigationDestination( + icon: Icon(Icons.chat_bubble_outline), + selectedIcon: Icon(Icons.chat_bubble), + label: '채팅', + ), + NavigationDestination( + icon: Icon(Icons.people_outline), + selectedIcon: Icon(Icons.people), + label: '친구', + ), + NavigationDestination( + icon: Icon(Icons.person_outline), + selectedIcon: Icon(Icons.person), + label: '내 정보', + ), + ], + ), + floatingActionButton: _tabIndex == 0 + ? FloatingActionButton( + onPressed: _openDirect, + child: const Icon(Icons.chat_bubble_outline), + ) + : null, + ); + } + + List _roomSlivers(BuildContext context, String effectiveContextId) { + final asyncRooms = ref.watch(roomsForContextProvider(effectiveContextId)); + + return asyncRooms.when( + loading: () => [ + const SliverFillRemaining( + hasScrollBody: false, + child: Center(child: CircularProgressIndicator(color: TossColors.blue)), + ), + ], + error: (e, _) => [ + SliverFillRemaining( + hasScrollBody: false, + child: Center(child: Text('$e')), + ), + ], + data: (rooms) { + if (rooms.isEmpty) { + return [ + SliverFillRemaining( + hasScrollBody: false, + child: Center( + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Icon(Icons.chat_outlined, size: 48, color: Theme.of(context).disabledColor), + const SizedBox(height: 12), + Text( + '대화가 없습니다', + style: Theme.of(context).textTheme.titleSmall, + ), + const SizedBox(height: 4), + Text( + '+ 버튼으로 직접 대화를 열 수 있습니다', + style: Theme.of(context).textTheme.bodySmall, + ), + ], + ), + ), + ), + ]; + } + return [ + SliverPadding( + padding: const EdgeInsets.fromLTRB(16, 0, 16, 100), + sliver: SliverList( + delegate: SliverChildBuilderDelegate( + (context, i) { + final r = rooms[i]; + final subtitle = r.lastBody ?? '메시지 없음'; + final time = r.lastAt; + return Padding( + padding: const EdgeInsets.only(bottom: 10), + child: Material( + color: TossColors.surface, + borderRadius: BorderRadius.circular(16), + elevation: 0, + shadowColor: Colors.black.withValues(alpha: 0.06), + child: InkWell( + borderRadius: BorderRadius.circular(16), + onTap: () => context.push( + '/chat?roomId=${r.id}&contextId=$effectiveContextId', + ), + child: Ink( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16), + border: Border.all(color: TossColors.line), + ), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 14), + child: Row( + children: [ + CircleAvatar( + radius: 22, + backgroundColor: TossColors.blue.withValues(alpha: 0.1), + child: Icon( + r.isGroup ? Icons.groups_rounded : Icons.person_rounded, + color: TossColors.blue, + size: 24, + ), + ), + const SizedBox(width: 14), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + r.name ?? (r.isGroup ? '그룹 채팅' : '1:1 채팅'), + style: Theme.of(context).textTheme.titleMedium, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), + const SizedBox(height: 4), + Text( + subtitle, + style: Theme.of(context).textTheme.bodySmall, + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), + ], + ), + ), + if (time != null && time.isNotEmpty) + Text( + _shortTime(time), + style: Theme.of(context).textTheme.bodySmall?.copyWith( + fontWeight: FontWeight.w500, + ), + ), + ], + ), + ), + ), + ), + ), + ); + }, + childCount: rooms.length, + ), + ), + ), + ]; + }, + ); + } + + String _shortTime(String iso) { + try { + final d = DateTime.tryParse(iso); + if (d == null) return ''; + final now = DateTime.now(); + if (d.year == now.year && d.month == now.month && d.day == now.day) { + return '${d.hour.toString().padLeft(2, '0')}:${d.minute.toString().padLeft(2, '0')}'; + } + return '${d.month}/${d.day}'; + } catch (_) { + return ''; + } + } +} + +/// Pill chip: Toss blue when selected, white + border otherwise. +class _TossContextChip extends StatelessWidget { + const _TossContextChip({ + required this.label, + required this.icon, + required this.selected, + required this.onTap, + }); + + final String label; + final IconData icon; + final bool selected; + final VoidCallback onTap; + + @override + Widget build(BuildContext context) { + return Material( + color: selected ? TossColors.blue : TossColors.surface, + borderRadius: BorderRadius.circular(24), + child: InkWell( + onTap: onTap, + borderRadius: BorderRadius.circular(24), + child: Container( + padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(24), + border: Border.all( + color: selected ? TossColors.blue : TossColors.line, + width: selected ? 0 : 1, + ), + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + Icon( + icon, + size: 18, + color: selected ? Colors.white : TossColors.textSecondary, + ), + const SizedBox(width: 6), + Text( + label, + style: TextStyle( + fontWeight: FontWeight.w600, + fontSize: 14, + color: selected ? Colors.white : TossColors.textPrimary, + ), + ), + ], + ), + ), + ), + ); + } +} diff --git a/mobile/lib/features/home/home_providers.dart b/mobile/lib/features/home/home_providers.dart new file mode 100644 index 0000000..25ae037 --- /dev/null +++ b/mobile/lib/features/home/home_providers.dart @@ -0,0 +1,20 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +import '../../core/msn_api.dart'; +import '../../models/context_member_model.dart'; +import '../../models/context_model.dart'; +import '../../models/room_model.dart'; + +final contextsListProvider = FutureProvider.autoDispose>((ref) async { + return ref.watch(msnApiProvider).listContexts(); +}); + +final roomsForContextProvider = + FutureProvider.autoDispose.family, String>((ref, contextId) async { + return ref.watch(msnApiProvider).listRooms(contextId); +}); + +final membersForContextProvider = + FutureProvider.autoDispose.family, String>((ref, contextId) async { + return ref.watch(msnApiProvider).listContextMembers(contextId); +}); diff --git a/mobile/lib/features/home/my_profile_tab.dart b/mobile/lib/features/home/my_profile_tab.dart new file mode 100644 index 0000000..20c138b --- /dev/null +++ b/mobile/lib/features/home/my_profile_tab.dart @@ -0,0 +1,190 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +import '../../core/msn_api.dart'; +import '../../core/session_controller.dart'; +import '../../models/context_model.dart'; +import '../../models/profile_model.dart'; +import '../../theme/toss_theme.dart'; +import 'home_providers.dart'; + +final myProfileForContextProvider = + FutureProvider.autoDispose.family((ref, contextId) async { + return ref.watch(msnApiProvider).getMyProfile(contextId); +}); + +/// Edit display name and status per messenger space, with 일상 / 직장 segment synced to top chips. +class MyProfileTab extends ConsumerStatefulWidget { + const MyProfileTab({super.key}); + + @override + ConsumerState createState() => _MyProfileTabState(); +} + +class _MyProfileTabState extends ConsumerState { + final _nameCtrl = TextEditingController(); + final _statusCtrl = TextEditingController(); + bool _dirty = false; + bool _saving = false; + + @override + void dispose() { + _nameCtrl.dispose(); + _statusCtrl.dispose(); + super.dispose(); + } + + Future _save(String contextId) async { + setState(() => _saving = true); + try { + await ref.read(msnApiProvider).updateMyProfile( + contextId, + displayName: _nameCtrl.text.trim(), + statusMessage: _statusCtrl.text.trim(), + ); + ref.invalidate(myProfileForContextProvider(contextId)); + ref.invalidate(membersForContextProvider(contextId)); + if (!mounted) return; + setState(() { + _dirty = false; + _saving = false; + }); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('저장했습니다')), + ); + } catch (e) { + if (!mounted) return; + setState(() => _saving = false); + ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('$e'))); + } + } + + Future _onSegmentChanged(String contextId) async { + await ref.read(sessionProvider.notifier).setSelectedContext(contextId); + setState(() => _dirty = false); + } + + @override + Widget build(BuildContext context) { + final session = ref.watch(sessionProvider).value; + final cid = session?.effectiveContextId; + final contextsAsync = ref.watch(contextsListProvider); + + return contextsAsync.when( + loading: () => const Center(child: CircularProgressIndicator(color: TossColors.blue)), + error: (e, _) => Center(child: Text('$e')), + data: (contexts) { + final personal = _firstOfKind(contexts, 'personal'); + final work = _firstOfKind(contexts, 'work'); + + if (cid == null) { + return const Center(child: Text('맥락이 없습니다')); + } + + final async = ref.watch(myProfileForContextProvider(cid)); + + ref.listen>(myProfileForContextProvider(cid), (prev, next) { + next.whenData((p) { + if (!_dirty && mounted) { + _nameCtrl.text = p.displayName; + _statusCtrl.text = p.statusMessage ?? ''; + } + }); + }); + + return async.when( + loading: () => const Center(child: CircularProgressIndicator(color: TossColors.blue)), + error: (e, _) => Center(child: Text('$e')), + data: (_) => RefreshIndicator( + color: TossColors.blue, + onRefresh: () async { + ref.invalidate(myProfileForContextProvider(cid)); + await ref.read(myProfileForContextProvider(cid).future); + }, + child: ListView( + physics: const AlwaysScrollableScrollPhysics(), + padding: const EdgeInsets.fromLTRB(16, 8, 16, 100), + children: [ + if (personal != null && work != null) ...[ + SegmentedButton( + segments: [ + ButtonSegment( + value: personal.id, + label: Text(personal.name), + icon: const Icon(Icons.home_outlined, size: 18), + ), + ButtonSegment( + value: work.id, + label: Text(work.name), + icon: const Icon(Icons.business_outlined, size: 18), + ), + ], + selected: {cid}, + onSelectionChanged: (s) { + if (s.isEmpty) return; + _onSegmentChanged(s.first); + }, + ), + const SizedBox(height: 12), + ], + Text( + '지금 편집: ${_contextName(contexts, cid)}', + style: Theme.of(context).textTheme.titleSmall, + ), + const SizedBox(height: 8), + Text( + '이 맥락에서만 보이는 이름과 상태입니다.', + style: Theme.of(context).textTheme.bodySmall, + ), + const SizedBox(height: 20), + TextField( + controller: _nameCtrl, + decoration: const InputDecoration( + labelText: '표시 이름', + border: OutlineInputBorder(), + ), + onChanged: (_) => setState(() => _dirty = true), + ), + const SizedBox(height: 16), + TextField( + controller: _statusCtrl, + decoration: const InputDecoration( + labelText: '상태 메시지', + border: OutlineInputBorder(), + ), + maxLines: 3, + onChanged: (_) => setState(() => _dirty = true), + ), + const SizedBox(height: 24), + FilledButton( + onPressed: _saving ? null : () => _save(cid), + child: _saving + ? const SizedBox( + height: 20, + width: 20, + child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white), + ) + : const Text('저장'), + ), + ], + ), + ), + ); + }, + ); + } + + ContextModel? _firstOfKind(List list, String kind) { + for (final c in list) { + if (c.kind == kind) return c; + } + return null; + } + + String _contextName(List list, String id) { + for (final c in list) { + if (c.id == id) return c.name; + } + return id; + } +} diff --git a/mobile/lib/features/profile/user_profile_sheet.dart b/mobile/lib/features/profile/user_profile_sheet.dart new file mode 100644 index 0000000..b38c9e4 --- /dev/null +++ b/mobile/lib/features/profile/user_profile_sheet.dart @@ -0,0 +1,178 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; + +import '../../core/msn_api.dart'; +import '../../core/session_controller.dart'; +import '../../models/profile_model.dart'; +import '../../theme/toss_theme.dart'; + +/// Kakao-style profile sheet: large avatar, name, status, optional 1:1 chat. +Future showUserProfileSheet( + BuildContext parentContext, + WidgetRef ref, { + required String contextId, + required String userId, +}) async { + await showModalBottomSheet( + context: parentContext, + isScrollControlled: true, + showDragHandle: true, + backgroundColor: TossColors.surface, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.vertical(top: Radius.circular(20)), + ), + builder: (sheetContext) => _UserProfileSheetBody( + parentContext: parentContext, + contextId: contextId, + userId: userId, + ), + ); +} + +class _UserProfileSheetBody extends ConsumerStatefulWidget { + const _UserProfileSheetBody({ + required this.parentContext, + required this.contextId, + required this.userId, + }); + + final BuildContext parentContext; + final String contextId; + final String userId; + + @override + ConsumerState<_UserProfileSheetBody> createState() => _UserProfileSheetBodyState(); +} + +class _UserProfileSheetBodyState extends ConsumerState<_UserProfileSheetBody> { + late Future _future; + + @override + void initState() { + super.initState(); + final myId = ref.read(sessionProvider).value?.userId; + final isSelf = myId != null && widget.userId == myId; + _future = isSelf + ? ref.read(msnApiProvider).getMyProfile(widget.contextId) + : ref.read(msnApiProvider).getUserProfile(widget.contextId, widget.userId); + } + + Future _openDirect() async { + final roomId = + await ref.read(msnApiProvider).openDirectRoom(widget.contextId, widget.userId); + if (!mounted) return; + Navigator.of(context).pop(); + if (widget.parentContext.mounted) { + await widget.parentContext.push('/chat?roomId=$roomId&contextId=${widget.contextId}'); + } + } + + @override + Widget build(BuildContext context) { + final theme = Theme.of(context); + final myId = ref.watch(sessionProvider).value?.userId; + final isSelf = myId != null && widget.userId == myId; + + return SafeArea( + child: Padding( + padding: EdgeInsets.only( + left: 24, + right: 24, + top: 8, + bottom: 24 + MediaQuery.paddingOf(context).bottom, + ), + child: FutureBuilder( + future: _future, + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const SizedBox( + height: 220, + child: Center(child: CircularProgressIndicator(color: TossColors.blue)), + ); + } + if (snapshot.hasError) { + return SizedBox( + height: 120, + child: Center(child: Text('${snapshot.error}')), + ); + } + final p = snapshot.data!; + return SingleChildScrollView( + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Center( + child: _LargeAvatar( + displayName: p.displayName, + avatarUrl: p.avatarUrl, + ), + ), + const SizedBox(height: 20), + Text( + p.displayName, + style: theme.textTheme.headlineSmall?.copyWith(fontWeight: FontWeight.w700), + textAlign: TextAlign.center, + ), + if (p.statusMessage != null && p.statusMessage!.isNotEmpty) ...[ + const SizedBox(height: 12), + Text( + p.statusMessage!, + style: theme.textTheme.bodyLarge, + textAlign: TextAlign.center, + ), + ], + const SizedBox(height: 16), + Text( + '이 맥락에서만 보이는 프로필이에요.', + style: theme.textTheme.bodySmall, + textAlign: TextAlign.center, + ), + if (!isSelf) ...[ + const SizedBox(height: 24), + FilledButton.icon( + onPressed: _openDirect, + icon: const Icon(Icons.chat_bubble_outline), + label: const Text('1:1 채팅'), + ), + ], + ], + ), + ); + }, + ), + ), + ); + } +} + +class _LargeAvatar extends StatelessWidget { + const _LargeAvatar({ + required this.displayName, + this.avatarUrl, + }); + + final String displayName; + final String? avatarUrl; + + @override + Widget build(BuildContext context) { + final hasUrl = avatarUrl != null && avatarUrl!.isNotEmpty; + return CircleAvatar( + radius: 56, + backgroundColor: TossColors.blue.withValues(alpha: 0.12), + backgroundImage: hasUrl ? NetworkImage(avatarUrl!) : null, + child: hasUrl + ? null + : Text( + displayName.isNotEmpty ? displayName[0].toUpperCase() : '?', + style: const TextStyle( + fontSize: 40, + fontWeight: FontWeight.w600, + color: TossColors.blue, + ), + ), + ); + } +} diff --git a/mobile/lib/features/search/search_page.dart b/mobile/lib/features/search/search_page.dart new file mode 100644 index 0000000..1f1d34c --- /dev/null +++ b/mobile/lib/features/search/search_page.dart @@ -0,0 +1,338 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; + +import '../../core/msn_api.dart'; +import '../../core/session_controller.dart'; +import '../../models/context_member_model.dart'; +import '../../models/room_model.dart'; +import '../../theme/toss_theme.dart'; +import '../profile/user_profile_sheet.dart'; + +class SearchPage extends ConsumerStatefulWidget { + const SearchPage({super.key, required this.contextId}); + + final String contextId; + + @override + ConsumerState createState() => _SearchPageState(); +} + +class _SearchPageState extends ConsumerState { + final _q = TextEditingController(); + List> _messageResults = []; + List _rooms = []; + List _friends = []; + bool _busy = false; + bool _loadedLists = false; + int _segment = 0; + + @override + void initState() { + super.initState(); + WidgetsBinding.instance.addPostFrameCallback((_) => _ensureLists()); + } + + @override + void dispose() { + _q.dispose(); + super.dispose(); + } + + Future _ensureLists() async { + if (_loadedLists || widget.contextId.isEmpty) return; + setState(() => _busy = true); + try { + final api = ref.read(msnApiProvider); + final rooms = await api.listRooms(widget.contextId); + final members = await api.listContextMembers(widget.contextId); + if (!mounted) return; + setState(() { + _rooms = rooms; + _friends = members; + _loadedLists = true; + }); + } finally { + if (mounted) setState(() => _busy = false); + } + } + + Future _runMessageSearch() async { + if (widget.contextId.isEmpty) return; + setState(() => _busy = true); + try { + final r = await ref.read(msnApiProvider).searchMessages(widget.contextId, _q.text); + if (!mounted) return; + setState(() => _messageResults = r); + } finally { + if (mounted) setState(() => _busy = false); + } + } + + String get _needle => _q.text.trim().toLowerCase(); + + List get _filteredRooms { + if (_needle.isEmpty) return _rooms; + return _rooms.where((r) { + final name = (r.name ?? (r.isGroup ? '그룹' : '1:1')).toLowerCase(); + final last = (r.lastBody ?? '').toLowerCase(); + return name.contains(_needle) || last.contains(_needle); + }).toList(); + } + + List get _filteredFriends { + if (_needle.isEmpty) return _friends; + return _friends.where((m) { + final name = m.displayName.toLowerCase(); + final st = (m.statusMessage ?? '').toLowerCase(); + return name.contains(_needle) || + m.userId.toLowerCase().contains(_needle) || + st.contains(_needle); + }).toList(); + } + + @override + Widget build(BuildContext context) { + final tt = Theme.of(context).textTheme; + final myId = ref.watch(sessionProvider).value?.userId; + + return Scaffold( + backgroundColor: TossColors.bg, + appBar: AppBar(title: const Text('검색')), + body: Column( + children: [ + Padding( + padding: const EdgeInsets.fromLTRB(16, 12, 16, 8), + child: SegmentedButton( + segments: const [ + ButtonSegment(value: 0, label: Text('메시지'), icon: Icon(Icons.search, size: 18)), + ButtonSegment(value: 1, label: Text('방'), icon: Icon(Icons.chat_bubble_outline, size: 18)), + ButtonSegment(value: 2, label: Text('친구'), icon: Icon(Icons.people_outline, size: 18)), + ], + selected: {_segment}, + onSelectionChanged: (s) { + if (s.isEmpty) return; + setState(() => _segment = s.first); + }, + ), + ), + Padding( + padding: const EdgeInsets.fromLTRB(16, 0, 16, 8), + child: Row( + children: [ + Expanded( + child: TextField( + controller: _q, + decoration: InputDecoration( + hintText: _segment == 0 + ? '이 맥락에서 메시지 검색' + : _segment == 1 + ? '방 이름 또는 미리보기로 필터' + : '이름·상태로 친구 필터', + prefixIcon: const Icon(Icons.search_rounded, color: TossColors.textSecondary), + ), + onChanged: (_) { + if (_segment != 0) setState(() {}); + }, + onSubmitted: (_) { + if (_segment == 0) unawaited(_runMessageSearch()); + }, + ), + ), + const SizedBox(width: 8), + if (_segment == 0) + Material( + color: TossColors.blue, + borderRadius: BorderRadius.circular(12), + child: IconButton( + onPressed: _busy ? null : () => unawaited(_runMessageSearch()), + icon: _busy + ? const SizedBox( + width: 22, + height: 22, + child: CircularProgressIndicator(strokeWidth: 2, color: Colors.white), + ) + : const Icon(Icons.arrow_forward_rounded, color: Colors.white), + ), + ), + ], + ), + ), + Expanded( + child: _busy && !_loadedLists && _segment != 0 + ? const Center(child: CircularProgressIndicator(color: TossColors.blue)) + : _segment == 0 + ? _buildMessageList(tt) + : _segment == 1 + ? _buildRoomList(tt) + : _buildFriendList(tt, myId), + ), + ], + ), + ); + } + + Widget _buildMessageList(TextTheme tt) { + return ListView.separated( + padding: const EdgeInsets.fromLTRB(16, 0, 16, 24), + itemCount: _messageResults.length, + separatorBuilder: (_, __) => const SizedBox(height: 8), + itemBuilder: (context, i) { + final r = _messageResults[i]; + return Material( + color: TossColors.surface, + borderRadius: BorderRadius.circular(14), + child: InkWell( + borderRadius: BorderRadius.circular(14), + onTap: () { + final roomId = r['roomId'] as String?; + if (roomId == null) return; + context.push('/chat?roomId=$roomId&contextId=${widget.contextId}'); + }, + child: Ink( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(14), + border: Border.all(color: TossColors.line), + ), + child: Padding( + padding: const EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(r['body'] as String? ?? '', style: tt.bodyLarge), + const SizedBox(height: 6), + Text('방 ${r['roomId']}', style: tt.bodySmall), + ], + ), + ), + ), + ), + ); + }, + ); + } + + Widget _buildRoomList(TextTheme tt) { + final list = _filteredRooms; + if (list.isEmpty) { + return Center(child: Text(_emptyHint('방'))); + } + return ListView.separated( + padding: const EdgeInsets.fromLTRB(16, 0, 16, 24), + itemCount: list.length, + separatorBuilder: (_, __) => const SizedBox(height: 8), + itemBuilder: (context, i) { + final r = list[i]; + final title = r.name ?? (r.isGroup ? '그룹 채팅' : '1:1 채팅'); + final sub = r.lastBody ?? '메시지 없음'; + return Material( + color: TossColors.surface, + borderRadius: BorderRadius.circular(14), + child: InkWell( + borderRadius: BorderRadius.circular(14), + onTap: () => context.push('/chat?roomId=${r.id}&contextId=${widget.contextId}'), + child: Ink( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(14), + border: Border.all(color: TossColors.line), + ), + child: Padding( + padding: const EdgeInsets.all(16), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(title, style: tt.titleMedium), + const SizedBox(height: 4), + Text(sub, style: tt.bodySmall, maxLines: 2, overflow: TextOverflow.ellipsis), + ], + ), + ), + ), + ), + ); + }, + ); + } + + Widget _buildFriendList(TextTheme tt, String? myId) { + final list = _filteredFriends; + if (list.isEmpty) { + return Center(child: Text(_emptyHint('친구'))); + } + return ListView.separated( + padding: const EdgeInsets.fromLTRB(16, 0, 16, 24), + itemCount: list.length, + separatorBuilder: (_, __) => const SizedBox(height: 8), + itemBuilder: (context, i) { + final m = list[i]; + final isSelf = myId != null && m.userId == myId; + return Material( + color: TossColors.surface, + borderRadius: BorderRadius.circular(14), + child: InkWell( + borderRadius: BorderRadius.circular(14), + onTap: () async { + if (isSelf) { + await showUserProfileSheet( + context, + ref, + contextId: widget.contextId, + userId: m.userId, + ); + } else { + final roomId = + await ref.read(msnApiProvider).openDirectRoom(widget.contextId, m.userId); + if (!context.mounted) return; + await context.push('/chat?roomId=$roomId&contextId=${widget.contextId}'); + } + }, + child: Ink( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(14), + border: Border.all(color: TossColors.line), + ), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14), + child: Row( + children: [ + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + m.displayName.isNotEmpty ? m.displayName : m.userId, + style: tt.titleMedium, + ), + if (m.statusMessage != null && m.statusMessage!.isNotEmpty) + Text(m.statusMessage!, style: tt.bodySmall, maxLines: 1), + ], + ), + ), + IconButton( + icon: const Icon(Icons.person_outline_rounded), + onPressed: () async { + await showUserProfileSheet( + context, + ref, + contextId: widget.contextId, + userId: m.userId, + ); + }, + ), + ], + ), + ), + ), + ), + ); + }, + ); + } + + String _emptyHint(String kind) { + if (_needle.isEmpty) return '목록을 불러오는 중이거나 $kind가 없습니다'; + return '검색어와 일치하는 $kind가 없습니다'; + } +} diff --git a/mobile/lib/features/settings/settings_page.dart b/mobile/lib/features/settings/settings_page.dart new file mode 100644 index 0000000..41c3809 --- /dev/null +++ b/mobile/lib/features/settings/settings_page.dart @@ -0,0 +1,93 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:go_router/go_router.dart'; +import 'package:package_info_plus/package_info_plus.dart'; + +import '../../core/app_settings.dart'; +import '../../core/chat_socket.dart'; +import '../../core/fcm_service.dart'; +import '../../core/msn_api.dart'; +import '../../core/session_controller.dart'; +class SettingsPage extends ConsumerStatefulWidget { + const SettingsPage({super.key}); + + @override + ConsumerState createState() => _SettingsPageState(); +} + +class _SettingsPageState extends ConsumerState { + String _version = ''; + + @override + void initState() { + super.initState(); + PackageInfo.fromPlatform().then((p) { + if (mounted) setState(() => _version = '${p.version} (${p.buildNumber})'); + }); + } + + Future _logout() async { + await ref.read(chatSocketProvider).disconnect(); + await ref.read(sessionProvider.notifier).logout(); + if (!mounted) return; + context.go('/login'); + } + + @override + Widget build(BuildContext context) { + final themeMode = ref.watch(themeModeProvider); + final notifOn = ref.watch(notificationsEnabledProvider); + final tt = Theme.of(context).textTheme; + + return Scaffold( + backgroundColor: Theme.of(context).scaffoldBackgroundColor, + appBar: AppBar(title: const Text('설정')), + body: ListView( + padding: const EdgeInsets.fromLTRB(16, 16, 16, 32), + children: [ + Text('IYKYKA', style: tt.titleLarge), + if (_version.isNotEmpty) + Padding( + padding: const EdgeInsets.only(top: 4, bottom: 16), + child: Text('버전 $_version', style: tt.bodySmall), + ), + const Divider(), + const SizedBox(height: 8), + Text('화면', style: tt.titleSmall), + const SizedBox(height: 8), + SegmentedButton( + segments: const [ + ButtonSegment(value: ThemeMode.system, label: Text('시스템')), + ButtonSegment(value: ThemeMode.light, label: Text('라이트')), + ], + selected: {themeMode}, + onSelectionChanged: (s) { + if (s.isEmpty) return; + ref.read(themeModeProvider.notifier).setThemeMode(s.first); + }, + ), + const SizedBox(height: 24), + Text('알림', style: tt.titleSmall), + SwitchListTile( + title: const Text('푸시 알림 허용'), + subtitle: const Text('기기에서 알림을 허용한 경우에 적용됩니다'), + value: notifOn, + onChanged: (v) async { + await ref.read(notificationsEnabledProvider.notifier).setEnabled(v); + if (v) { + try { + await initializeFcmAndLocalNotifications(ref.read(msnApiProvider)); + } catch (_) {} + } + }, + ), + const SizedBox(height: 24), + FilledButton.tonal( + onPressed: _logout, + child: const Text('로그아웃'), + ), + ], + ), + ); + } +} diff --git a/mobile/lib/firebase_options.dart b/mobile/lib/firebase_options.dart new file mode 100644 index 0000000..21407b1 --- /dev/null +++ b/mobile/lib/firebase_options.dart @@ -0,0 +1,49 @@ +// File generated for build without `flutterfire configure`. +// Replace with `dart pub global run flutterfire_cli:flutterfire configure` for production. +import 'package:firebase_core/firebase_core.dart' show FirebaseOptions; +import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb, TargetPlatform; + +class DefaultFirebaseOptions { + static FirebaseOptions get currentPlatform { + if (kIsWeb) { + return web; + } + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return android; + case TargetPlatform.iOS: + return ios; + case TargetPlatform.macOS: + return macos; + default: + return android; + } + } + + static const FirebaseOptions android = FirebaseOptions( + apiKey: 'AIzaSyPlaceholderReplaceViaFlutterfireConfigure', + appId: '1:000000000000:android:0000000000000000000000', + messagingSenderId: '000000000000', + projectId: 'iykyka-placeholder', + storageBucket: 'iykyka-placeholder.appspot.com', + ); + + static const FirebaseOptions ios = FirebaseOptions( + apiKey: 'AIzaSyPlaceholderReplaceViaFlutterfireConfigure', + appId: '1:000000000000:ios:0000000000000000000000', + messagingSenderId: '000000000000', + projectId: 'iykyka-placeholder', + storageBucket: 'iykyka-placeholder.appspot.com', + iosBundleId: 'com.example.msnMobile', + ); + + static const FirebaseOptions macos = ios; + + static const FirebaseOptions web = FirebaseOptions( + apiKey: 'AIzaSyPlaceholderReplaceViaFlutterfireConfigure', + appId: '1:000000000000:web:0000000000000000000000', + messagingSenderId: '000000000000', + projectId: 'iykyka-placeholder', + storageBucket: 'iykyka-placeholder.appspot.com', + ); +} diff --git a/mobile/lib/main.dart b/mobile/lib/main.dart new file mode 100644 index 0000000..30da014 --- /dev/null +++ b/mobile/lib/main.dart @@ -0,0 +1,36 @@ +import 'package:firebase_core/firebase_core.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; + +import 'app/router.dart'; +import 'core/app_settings.dart'; +import 'firebase_options.dart'; +import 'theme/toss_theme.dart'; + +Future main() async { + WidgetsFlutterBinding.ensureInitialized(); + try { + await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform); + } catch (e) { + debugPrint('Firebase.initializeApp skipped (configure firebase_options / google-services): $e'); + } + runApp(const ProviderScope(child: MsnApp())); +} + +class MsnApp extends ConsumerWidget { + const MsnApp({super.key}); + + @override + Widget build(BuildContext context, WidgetRef ref) { + final router = ref.watch(goRouterProvider); + final themeMode = ref.watch(themeModeProvider); + return MaterialApp.router( + title: 'IYKYKA', + theme: buildTossTheme(), + // Match light theme so OS dark mode does not switch to a separate dark palette. + darkTheme: buildTossTheme(), + themeMode: themeMode, + routerConfig: router, + ); + } +} diff --git a/mobile/lib/models/context_member_model.dart b/mobile/lib/models/context_member_model.dart new file mode 100644 index 0000000..95c8759 --- /dev/null +++ b/mobile/lib/models/context_member_model.dart @@ -0,0 +1,25 @@ +class ContextMember { + ContextMember({ + required this.userId, + required this.role, + required this.displayName, + this.avatarUrl, + this.statusMessage, + }); + + final String userId; + final String role; + final String displayName; + final String? avatarUrl; + final String? statusMessage; + + factory ContextMember.fromJson(Map j) { + return ContextMember( + userId: j['userId'] as String, + role: j['role'] as String? ?? 'member', + displayName: j['displayName'] as String? ?? '', + avatarUrl: j['avatarUrl'] as String?, + statusMessage: j['statusMessage'] as String?, + ); + } +} diff --git a/mobile/lib/models/context_model.dart b/mobile/lib/models/context_model.dart new file mode 100644 index 0000000..ef4709d --- /dev/null +++ b/mobile/lib/models/context_model.dart @@ -0,0 +1,26 @@ +class ContextModel { + ContextModel({ + required this.id, + required this.name, + required this.kind, + this.retentionDays, + this.screenshotBlocked = false, + }); + + final String id; + final String name; + final String kind; + final int? retentionDays; + final bool screenshotBlocked; + + factory ContextModel.fromJson(Map j) { + final policy = j['policy'] as Map?; + return ContextModel( + id: j['id'] as String, + name: j['name'] as String, + kind: j['kind'] as String, + retentionDays: policy?['retentionDays'] as int?, + screenshotBlocked: policy?['screenshotBlocked'] == true, + ); + } +} diff --git a/mobile/lib/models/message_model.dart b/mobile/lib/models/message_model.dart new file mode 100644 index 0000000..5f2b2df --- /dev/null +++ b/mobile/lib/models/message_model.dart @@ -0,0 +1,39 @@ +class MessageModel { + MessageModel({ + required this.id, + required this.roomId, + required this.senderId, + required this.body, + required this.createdAt, + this.kind = 'text', + }); + + final String id; + final String roomId; + final String senderId; + final String body; + final String createdAt; + final String kind; + + factory MessageModel.fromJson(Map j) { + return MessageModel( + id: j['id'] as String, + roomId: j['roomId'] as String, + senderId: j['senderId'] as String, + body: j['body'] as String, + createdAt: j['createdAt'] as String, + kind: j['kind'] as String? ?? 'text', + ); + } + + factory MessageModel.fromWs(Map j) { + return MessageModel( + id: j['id'] as String, + roomId: j['roomId'] as String, + senderId: j['senderId'] as String, + body: j['body'] as String, + createdAt: j['createdAt'] as String, + kind: j['kind'] as String? ?? 'text', + ); + } +} diff --git a/mobile/lib/models/profile_model.dart b/mobile/lib/models/profile_model.dart new file mode 100644 index 0000000..73e71a3 --- /dev/null +++ b/mobile/lib/models/profile_model.dart @@ -0,0 +1,28 @@ +class ProfileModel { + ProfileModel({ + required this.userId, + required this.contextId, + required this.displayName, + this.avatarUrl, + this.statusMessage, + this.updatedAt, + }); + + final String userId; + final String contextId; + final String displayName; + final String? avatarUrl; + final String? statusMessage; + final String? updatedAt; + + factory ProfileModel.fromJson(Map j) { + return ProfileModel( + userId: j['userId'] as String, + contextId: j['contextId'] as String, + displayName: j['displayName'] as String, + avatarUrl: j['avatarUrl'] as String?, + statusMessage: j['statusMessage'] as String?, + updatedAt: j['updatedAt'] as String?, + ); + } +} diff --git a/mobile/lib/models/room_model.dart b/mobile/lib/models/room_model.dart new file mode 100644 index 0000000..73f0dc1 --- /dev/null +++ b/mobile/lib/models/room_model.dart @@ -0,0 +1,25 @@ +class RoomModel { + RoomModel({ + required this.id, + required this.isGroup, + this.name, + this.lastBody, + this.lastAt, + }); + + final String id; + final bool isGroup; + final String? name; + final String? lastBody; + final String? lastAt; + + factory RoomModel.fromJson(Map j) { + return RoomModel( + id: j['id'] as String, + isGroup: (j['is_group'] as int? ?? 0) == 1, + name: j['name'] as String?, + lastBody: j['last_body'] as String?, + lastAt: j['last_at'] as String?, + ); + } +} diff --git a/mobile/lib/models/ws_chat_side_event.dart b/mobile/lib/models/ws_chat_side_event.dart new file mode 100644 index 0000000..634f4c7 --- /dev/null +++ b/mobile/lib/models/ws_chat_side_event.dart @@ -0,0 +1,23 @@ +class WsTypingEvent { + WsTypingEvent({ + required this.roomId, + required this.userId, + required this.active, + }); + + final String roomId; + final String userId; + final bool active; +} + +class WsReadEvent { + WsReadEvent({ + required this.roomId, + required this.userId, + required this.upToMessageId, + }); + + final String roomId; + final String userId; + final String upToMessageId; +} diff --git a/mobile/lib/theme/toss_theme.dart b/mobile/lib/theme/toss_theme.dart new file mode 100644 index 0000000..434df3b --- /dev/null +++ b/mobile/lib/theme/toss_theme.dart @@ -0,0 +1,164 @@ +import 'package:flutter/material.dart'; + +/// Toss-inspired palette (unofficial — evokes clean fintech / super-app UI). +abstract final class TossColors { + static const Color blue = Color(0xFF3182F6); + static const Color blueDark = Color(0xFF1B64DA); + static const Color bg = Color(0xFFF2F4F6); + static const Color surface = Color(0xFFFFFFFF); + static const Color textPrimary = Color(0xFF191F28); + static const Color textSecondary = Color(0xFF8B95A1); + static const Color line = Color(0xFFE5E8EB); + static const Color inputFill = Color(0xFFF2F4F6); +} + +/// Global theme: light, high whitespace, blue CTAs. +ThemeData buildTossTheme() { + const primary = TossColors.blue; + const colorScheme = ColorScheme.light( + primary: primary, + onPrimary: Colors.white, + primaryContainer: Color(0xFFE8F3FF), + onPrimaryContainer: TossColors.blueDark, + surface: TossColors.surface, + onSurface: TossColors.textPrimary, + onSurfaceVariant: TossColors.textSecondary, + outline: TossColors.line, + error: Color(0xFFF04452), + onError: Colors.white, + ); + + final base = ThemeData.light(); + return ThemeData( + useMaterial3: true, + colorScheme: colorScheme, + scaffoldBackgroundColor: TossColors.bg, + splashFactory: InkRipple.splashFactory, + textTheme: base.textTheme.copyWith( + headlineLarge: const TextStyle( + fontSize: 28, + fontWeight: FontWeight.w700, + height: 1.25, + letterSpacing: -0.5, + color: TossColors.textPrimary, + ), + headlineMedium: const TextStyle( + fontSize: 22, + fontWeight: FontWeight.w700, + height: 1.3, + color: TossColors.textPrimary, + ), + titleLarge: const TextStyle( + fontSize: 20, + fontWeight: FontWeight.w700, + color: TossColors.textPrimary, + ), + titleMedium: const TextStyle( + fontSize: 17, + fontWeight: FontWeight.w600, + color: TossColors.textPrimary, + ), + titleSmall: const TextStyle( + fontSize: 15, + fontWeight: FontWeight.w600, + color: TossColors.textPrimary, + ), + bodyLarge: const TextStyle( + fontSize: 16, + height: 1.45, + color: TossColors.textPrimary, + ), + bodyMedium: const TextStyle( + fontSize: 15, + height: 1.45, + color: TossColors.textSecondary, + ), + bodySmall: const TextStyle( + fontSize: 13, + height: 1.4, + color: TossColors.textSecondary, + ), + labelLarge: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w600, + color: TossColors.textPrimary, + ), + ), + appBarTheme: const AppBarTheme( + elevation: 0, + scrolledUnderElevation: 0, + centerTitle: false, + backgroundColor: TossColors.surface, + foregroundColor: TossColors.textPrimary, + titleTextStyle: TextStyle( + fontSize: 20, + fontWeight: FontWeight.w700, + color: TossColors.textPrimary, + ), + iconTheme: IconThemeData(color: TossColors.textPrimary, size: 22), + ), + cardTheme: CardThemeData( + color: TossColors.surface, + elevation: 0, + shadowColor: Colors.black.withValues(alpha: 0.06), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), + margin: EdgeInsets.zero, + ), + inputDecorationTheme: InputDecorationTheme( + filled: true, + fillColor: TossColors.inputFill, + contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16), + hintStyle: const TextStyle(color: TossColors.textSecondary, fontSize: 16), + labelStyle: const TextStyle(color: TossColors.textSecondary, fontSize: 14), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(14), + borderSide: BorderSide.none, + ), + enabledBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(14), + borderSide: BorderSide.none, + ), + focusedBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(14), + borderSide: const BorderSide(color: TossColors.blue, width: 1.5), + ), + errorBorder: OutlineInputBorder( + borderRadius: BorderRadius.circular(14), + borderSide: BorderSide(color: colorScheme.error.withValues(alpha: 0.8)), + ), + ), + filledButtonTheme: FilledButtonThemeData( + style: FilledButton.styleFrom( + backgroundColor: primary, + foregroundColor: Colors.white, + disabledBackgroundColor: TossColors.line, + disabledForegroundColor: TossColors.textSecondary, + padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 24), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), + textStyle: const TextStyle(fontSize: 17, fontWeight: FontWeight.w600), + elevation: 0, + ), + ), + outlinedButtonTheme: OutlinedButtonThemeData( + style: OutlinedButton.styleFrom( + foregroundColor: primary, + side: const BorderSide(color: TossColors.line), + padding: const EdgeInsets.symmetric(vertical: 14, horizontal: 20), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)), + ), + ), + textButtonTheme: TextButtonThemeData( + style: TextButton.styleFrom( + foregroundColor: TossColors.textSecondary, + textStyle: const TextStyle(fontSize: 15, fontWeight: FontWeight.w500), + ), + ), + floatingActionButtonTheme: const FloatingActionButtonThemeData( + backgroundColor: TossColors.blue, + foregroundColor: Colors.white, + elevation: 2, + shape: CircleBorder(), + ), + dividerTheme: const DividerThemeData(color: TossColors.line, thickness: 1), + ); +} diff --git a/mobile/pubspec.lock b/mobile/pubspec.lock new file mode 100644 index 0000000..72b0ca4 --- /dev/null +++ b/mobile/pubspec.lock @@ -0,0 +1,810 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _flutterfire_internals: + dependency: transitive + description: + name: _flutterfire_internals + sha256: ff0a84a2734d9e1089f8aedd5c0af0061b82fb94e95260d943404e0ef2134b11 + url: "https://pub.dev" + source: hosted + version: "1.3.59" + args: + dependency: transitive + description: + name: args + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 + url: "https://pub.dev" + source: hosted + version: "2.7.0" + async: + dependency: transitive + description: + name: async + sha256: e2eb0491ba5ddb6177742d2da23904574082139b07c1e33b8503b9f46f3e1a37 + url: "https://pub.dev" + source: hosted + version: "2.13.1" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + characters: + dependency: transitive + description: + name: characters + sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b + url: "https://pub.dev" + source: hosted + version: "1.4.1" + clock: + dependency: transitive + description: + name: clock + sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b + url: "https://pub.dev" + source: hosted + version: "1.1.2" + code_assets: + dependency: transitive + description: + name: code_assets + sha256: "83ccdaa064c980b5596c35dd64a8d3ecc68620174ab9b90b6343b753aa721687" + url: "https://pub.dev" + source: hosted + version: "1.0.0" + collection: + dependency: transitive + description: + name: collection + sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" + url: "https://pub.dev" + source: hosted + version: "1.19.1" + crypto: + dependency: transitive + description: + name: crypto + sha256: c8ea0233063ba03258fbcf2ca4d6dadfefe14f02fab57702265467a19f27fadf + url: "https://pub.dev" + source: hosted + version: "3.0.7" + cupertino_icons: + dependency: "direct main" + description: + name: cupertino_icons + sha256: "41e005c33bd814be4d3096aff55b1908d419fde52ca656c8c47719ec745873cd" + url: "https://pub.dev" + source: hosted + version: "1.0.9" + dbus: + dependency: transitive + description: + name: dbus + sha256: d0c98dcd4f5169878b6cf8f6e0a52403a9dff371a3e2f019697accbf6f44a270 + url: "https://pub.dev" + source: hosted + version: "0.7.12" + dio: + dependency: "direct main" + description: + name: dio + sha256: aff32c08f92787a557dd5c0145ac91536481831a01b4648136373cddb0e64f8c + url: "https://pub.dev" + source: hosted + version: "5.9.2" + dio_web_adapter: + dependency: transitive + description: + name: dio_web_adapter + sha256: "2f9e64323a7c3c7ef69567d5c800424a11f8337b8b228bad02524c9fb3c1f340" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + fake_async: + dependency: transitive + description: + name: fake_async + sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" + url: "https://pub.dev" + source: hosted + version: "1.3.3" + ffi: + dependency: transitive + description: + name: ffi + sha256: "6d7fd89431262d8f3125e81b50d3847a091d846eafcd4fdb88dd06f36d705a45" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + file: + dependency: transitive + description: + name: file + sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4 + url: "https://pub.dev" + source: hosted + version: "7.0.1" + firebase_core: + dependency: "direct main" + description: + name: firebase_core + sha256: "7be63a3f841fc9663342f7f3a011a42aef6a61066943c90b1c434d79d5c995c5" + url: "https://pub.dev" + source: hosted + version: "3.15.2" + firebase_core_platform_interface: + dependency: transitive + description: + name: firebase_core_platform_interface + sha256: "0ecda14c1bfc9ed8cac303dd0f8d04a320811b479362a9a4efb14fd331a473ce" + url: "https://pub.dev" + source: hosted + version: "6.0.3" + firebase_core_web: + dependency: transitive + description: + name: firebase_core_web + sha256: "0ed0dc292e8f9ac50992e2394e9d336a0275b6ae400d64163fdf0a8a8b556c37" + url: "https://pub.dev" + source: hosted + version: "2.24.1" + firebase_messaging: + dependency: "direct main" + description: + name: firebase_messaging + sha256: "60be38574f8b5658e2f22b7e311ff2064bea835c248424a383783464e8e02fcc" + url: "https://pub.dev" + source: hosted + version: "15.2.10" + firebase_messaging_platform_interface: + dependency: transitive + description: + name: firebase_messaging_platform_interface + sha256: "685e1771b3d1f9c8502771ccc9f91485b376ffe16d553533f335b9183ea99754" + url: "https://pub.dev" + source: hosted + version: "4.6.10" + firebase_messaging_web: + dependency: transitive + description: + name: firebase_messaging_web + sha256: "0d1be17bc89ed3ff5001789c92df678b2e963a51b6fa2bdb467532cc9dbed390" + url: "https://pub.dev" + source: hosted + version: "3.10.10" + flutter: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1" + url: "https://pub.dev" + source: hosted + version: "5.0.0" + flutter_local_notifications: + dependency: "direct main" + description: + name: flutter_local_notifications + sha256: ef41ae901e7529e52934feba19ed82827b11baa67336829564aeab3129460610 + url: "https://pub.dev" + source: hosted + version: "18.0.1" + flutter_local_notifications_linux: + dependency: transitive + description: + name: flutter_local_notifications_linux + sha256: "8f685642876742c941b29c32030f6f4f6dacd0e4eaecb3efbb187d6a3812ca01" + url: "https://pub.dev" + source: hosted + version: "5.0.0" + flutter_local_notifications_platform_interface: + dependency: transitive + description: + name: flutter_local_notifications_platform_interface + sha256: "6c5b83c86bf819cdb177a9247a3722067dd8cc6313827ce7c77a4b238a26fd52" + url: "https://pub.dev" + source: hosted + version: "8.0.0" + flutter_riverpod: + dependency: "direct main" + description: + name: flutter_riverpod + sha256: "9532ee6db4a943a1ed8383072a2e3eeda041db5657cdf6d2acecf3c21ecbe7e1" + url: "https://pub.dev" + source: hosted + version: "2.6.1" + flutter_secure_storage: + dependency: "direct main" + description: + name: flutter_secure_storage + sha256: "9cad52d75ebc511adfae3d447d5d13da15a55a92c9410e50f67335b6d21d16ea" + url: "https://pub.dev" + source: hosted + version: "9.2.4" + flutter_secure_storage_linux: + dependency: transitive + description: + name: flutter_secure_storage_linux + sha256: be76c1d24a97d0b98f8b54bce6b481a380a6590df992d0098f868ad54dc8f688 + url: "https://pub.dev" + source: hosted + version: "1.2.3" + flutter_secure_storage_macos: + dependency: transitive + description: + name: flutter_secure_storage_macos + sha256: "6c0a2795a2d1de26ae202a0d78527d163f4acbb11cde4c75c670f3a0fc064247" + url: "https://pub.dev" + source: hosted + version: "3.1.3" + flutter_secure_storage_platform_interface: + dependency: transitive + description: + name: flutter_secure_storage_platform_interface + sha256: cf91ad32ce5adef6fba4d736a542baca9daf3beac4db2d04be350b87f69ac4a8 + url: "https://pub.dev" + source: hosted + version: "1.1.2" + flutter_secure_storage_web: + dependency: transitive + description: + name: flutter_secure_storage_web + sha256: f4ebff989b4f07b2656fb16b47852c0aab9fed9b4ec1c70103368337bc1886a9 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + flutter_secure_storage_windows: + dependency: transitive + description: + name: flutter_secure_storage_windows + sha256: b20b07cb5ed4ed74fc567b78a72936203f587eba460af1df11281c9326cd3709 + url: "https://pub.dev" + source: hosted + version: "3.1.2" + flutter_test: + dependency: "direct dev" + description: flutter + source: sdk + version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + glob: + dependency: transitive + description: + name: glob + sha256: c3f1ee72c96f8f78935e18aa8cecced9ab132419e8625dc187e1c2408efc20de + url: "https://pub.dev" + source: hosted + version: "2.1.3" + go_router: + dependency: "direct main" + description: + name: go_router + sha256: f02fd7d2a4dc512fec615529824fdd217fecb3a3d3de68360293a551f21634b3 + url: "https://pub.dev" + source: hosted + version: "14.8.1" + hooks: + dependency: transitive + description: + name: hooks + sha256: e79ed1e8e1929bc6ecb6ec85f0cb519c887aa5b423705ded0d0f2d9226def388 + url: "https://pub.dev" + source: hosted + version: "1.0.2" + http: + dependency: transitive + description: + name: http + sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412" + url: "https://pub.dev" + source: hosted + version: "1.6.0" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571" + url: "https://pub.dev" + source: hosted + version: "4.1.2" + jni: + dependency: transitive + description: + name: jni + sha256: c2230682d5bc2362c1c9e8d3c7f406d9cbba23ab3f2e203a025dd47e0fb2e68f + url: "https://pub.dev" + source: hosted + version: "1.0.0" + jni_flutter: + dependency: transitive + description: + name: jni_flutter + sha256: "8b59e590786050b1cd866677dddaf76b1ade5e7bc751abe04b86e84d379d3ba6" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" + url: "https://pub.dev" + source: hosted + version: "11.0.2" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" + url: "https://pub.dev" + source: hosted + version: "3.0.10" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + lints: + dependency: transitive + description: + name: lints + sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7 + url: "https://pub.dev" + source: hosted + version: "5.1.1" + logging: + dependency: transitive + description: + name: logging + sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61 + url: "https://pub.dev" + source: hosted + version: "1.3.0" + matcher: + dependency: transitive + description: + name: matcher + sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861 + url: "https://pub.dev" + source: hosted + version: "0.12.19" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b" + url: "https://pub.dev" + source: hosted + version: "0.13.0" + meta: + dependency: transitive + description: + name: meta + sha256: "23f08335362185a5ea2ad3a4e597f1375e78bce8a040df5c600c8d3552ef2394" + url: "https://pub.dev" + source: hosted + version: "1.17.0" + mime: + dependency: transitive + description: + name: mime + sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6" + url: "https://pub.dev" + source: hosted + version: "2.0.0" + native_toolchain_c: + dependency: transitive + description: + name: native_toolchain_c + sha256: "6ba77bb18063eebe9de401f5e6437e95e1438af0a87a3a39084fbd37c90df572" + url: "https://pub.dev" + source: hosted + version: "0.17.6" + objective_c: + dependency: transitive + description: + name: objective_c + sha256: "100a1c87616ab6ed41ec263b083c0ef3261ee6cd1dc3b0f35f8ddfa4f996fe52" + url: "https://pub.dev" + source: hosted + version: "9.3.0" + package_config: + dependency: transitive + description: + name: package_config + sha256: f096c55ebb7deb7e384101542bfba8c52696c1b56fca2eb62827989ef2353bbc + url: "https://pub.dev" + source: hosted + version: "2.2.0" + package_info_plus: + dependency: "direct main" + description: + name: package_info_plus + sha256: "16eee997588c60225bda0488b6dcfac69280a6b7a3cf02c741895dd370a02968" + url: "https://pub.dev" + source: hosted + version: "8.3.1" + package_info_plus_platform_interface: + dependency: transitive + description: + name: package_info_plus_platform_interface + sha256: "202a487f08836a592a6bd4f901ac69b3a8f146af552bbd14407b6b41e1c3f086" + url: "https://pub.dev" + source: hosted + version: "3.2.1" + path: + dependency: "direct main" + description: + name: path + sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" + url: "https://pub.dev" + source: hosted + version: "1.9.1" + path_provider: + dependency: "direct main" + description: + name: path_provider + sha256: "50c5dd5b6e1aaf6fb3a78b33f6aa3afca52bf903a8a5298f53101fdaee55bbcd" + url: "https://pub.dev" + source: hosted + version: "2.1.5" + path_provider_android: + dependency: transitive + description: + name: path_provider_android + sha256: "914a07484c4380e572998d30486e77e0d9cd2faec72fee268086d07bf7f302c9" + url: "https://pub.dev" + source: hosted + version: "2.3.0" + path_provider_foundation: + dependency: transitive + description: + name: path_provider_foundation + sha256: "2a376b7d6392d80cd3705782d2caa734ca4727776db0b6ec36ef3f1855197699" + url: "https://pub.dev" + source: hosted + version: "2.6.0" + path_provider_linux: + dependency: transitive + description: + name: path_provider_linux + sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279 + url: "https://pub.dev" + source: hosted + version: "2.2.1" + path_provider_platform_interface: + dependency: transitive + description: + name: path_provider_platform_interface + sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + path_provider_windows: + dependency: transitive + description: + name: path_provider_windows + sha256: bd6f00dbd873bfb70d0761682da2b3a2c2fccc2b9e84c495821639601d81afe7 + url: "https://pub.dev" + source: hosted + version: "2.3.0" + petitparser: + dependency: transitive + description: + name: petitparser + sha256: "91bd59303e9f769f108f8df05e371341b15d59e995e6806aefab827b58336675" + url: "https://pub.dev" + source: hosted + version: "7.0.2" + platform: + dependency: transitive + description: + name: platform + sha256: "5d6b1b0036a5f331ebc77c850ebc8506cbc1e9416c27e59b439f917a902a4984" + url: "https://pub.dev" + source: hosted + version: "3.1.6" + plugin_platform_interface: + dependency: transitive + description: + name: plugin_platform_interface + sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" + url: "https://pub.dev" + source: hosted + version: "2.1.8" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585" + url: "https://pub.dev" + source: hosted + version: "2.2.0" + riverpod: + dependency: transitive + description: + name: riverpod + sha256: "59062512288d3056b2321804332a13ffdd1bf16df70dcc8e506e411280a72959" + url: "https://pub.dev" + source: hosted + version: "2.6.1" + shared_preferences: + dependency: "direct main" + description: + name: shared_preferences + sha256: c3025c5534b01739267eb7d76959bbc25a6d10f6988e1c2a3036940133dd10bf + url: "https://pub.dev" + source: hosted + version: "2.5.5" + shared_preferences_android: + dependency: transitive + description: + name: shared_preferences_android + sha256: e8d4762b1e2e8578fc4d0fd548cebf24afd24f49719c08974df92834565e2c53 + url: "https://pub.dev" + source: hosted + version: "2.4.23" + shared_preferences_foundation: + dependency: transitive + description: + name: shared_preferences_foundation + sha256: "4e7eaffc2b17ba398759f1151415869a34771ba11ebbccd1b0145472a619a64f" + url: "https://pub.dev" + source: hosted + version: "2.5.6" + shared_preferences_linux: + dependency: transitive + description: + name: shared_preferences_linux + sha256: "580abfd40f415611503cae30adf626e6656dfb2f0cee8f465ece7b6defb40f2f" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + shared_preferences_platform_interface: + dependency: transitive + description: + name: shared_preferences_platform_interface + sha256: "649dc798a33931919ea356c4305c2d1f81619ea6e92244070b520187b5140ef9" + url: "https://pub.dev" + source: hosted + version: "2.4.2" + shared_preferences_web: + dependency: transitive + description: + name: shared_preferences_web + sha256: c49bd060261c9a3f0ff445892695d6212ff603ef3115edbb448509d407600019 + url: "https://pub.dev" + source: hosted + version: "2.4.3" + shared_preferences_windows: + dependency: transitive + description: + name: shared_preferences_windows + sha256: "94ef0f72b2d71bc3e700e025db3710911bd51a71cefb65cc609dd0d9a982e3c1" + url: "https://pub.dev" + source: hosted + version: "2.4.1" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + source_span: + dependency: transitive + description: + name: source_span + sha256: "56a02f1f4cd1a2d96303c0144c93bd6d909eea6bee6bf5a0e0b685edbd4c47ab" + url: "https://pub.dev" + source: hosted + version: "1.10.2" + sqflite: + dependency: "direct main" + description: + name: sqflite + sha256: e2297b1da52f127bc7a3da11439985d9b536f75070f3325e62ada69a5c585d03 + url: "https://pub.dev" + source: hosted + version: "2.4.2" + sqflite_android: + dependency: transitive + description: + name: sqflite_android + sha256: "881e28efdcc9950fd8e9bb42713dcf1103e62a2e7168f23c9338d82db13dec40" + url: "https://pub.dev" + source: hosted + version: "2.4.2+3" + sqflite_common: + dependency: transitive + description: + name: sqflite_common + sha256: "6ef422a4525ecc601db6c0a2233ff448c731307906e92cabc9ba292afaae16a6" + url: "https://pub.dev" + source: hosted + version: "2.5.6" + sqflite_darwin: + dependency: transitive + description: + name: sqflite_darwin + sha256: "279832e5cde3fe99e8571879498c9211f3ca6391b0d818df4e17d9fff5c6ccb3" + url: "https://pub.dev" + source: hosted + version: "2.4.2" + sqflite_platform_interface: + dependency: transitive + description: + name: sqflite_platform_interface + sha256: "8dd4515c7bdcae0a785b0062859336de775e8c65db81ae33dd5445f35be61920" + url: "https://pub.dev" + source: hosted + version: "2.4.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" + url: "https://pub.dev" + source: hosted + version: "1.12.1" + state_notifier: + dependency: transitive + description: + name: state_notifier + sha256: b8677376aa54f2d7c58280d5a007f9e8774f1968d1fb1c096adcb4792fba29bb + url: "https://pub.dev" + source: hosted + version: "1.0.0" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" + url: "https://pub.dev" + source: hosted + version: "1.4.1" + synchronized: + dependency: transitive + description: + name: synchronized + sha256: c254ade258ec8282947a0acbbc90b9575b4f19673533ee46f2f6e9b3aeefd7c0 + url: "https://pub.dev" + source: hosted + version: "3.4.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" + url: "https://pub.dev" + source: hosted + version: "1.2.2" + test_api: + dependency: transitive + description: + name: test_api + sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a" + url: "https://pub.dev" + source: hosted + version: "0.7.10" + timezone: + dependency: transitive + description: + name: timezone + sha256: dd14a3b83cfd7cb19e7888f1cbc20f258b8d71b54c06f79ac585f14093a287d1 + url: "https://pub.dev" + source: hosted + version: "0.10.1" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006 + url: "https://pub.dev" + source: hosted + version: "1.4.0" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b + url: "https://pub.dev" + source: hosted + version: "2.2.0" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: "45caa6c5917fa127b5dbcfbd1fa60b14e583afdc08bfc96dda38886ca252eb60" + url: "https://pub.dev" + source: hosted + version: "15.0.2" + web: + dependency: transitive + description: + name: web + sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" + url: "https://pub.dev" + source: hosted + version: "1.1.1" + web_socket: + dependency: transitive + description: + name: web_socket + sha256: "34d64019aa8e36bf9842ac014bb5d2f5586ca73df5e4d9bf5c936975cae6982c" + url: "https://pub.dev" + source: hosted + version: "1.0.1" + web_socket_channel: + dependency: "direct main" + description: + name: web_socket_channel + sha256: d645757fb0f4773d602444000a8131ff5d48c9e47adfe9772652dd1a4f2d45c8 + url: "https://pub.dev" + source: hosted + version: "3.0.3" + win32: + dependency: transitive + description: + name: win32 + sha256: d7cb55e04cd34096cd3a79b3330245f54cb96a370a1c27adb3c84b917de8b08e + url: "https://pub.dev" + source: hosted + version: "5.15.0" + xdg_directories: + dependency: transitive + description: + name: xdg_directories + sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + xml: + dependency: transitive + description: + name: xml + sha256: "971043b3a0d3da28727e40ed3e0b5d18b742fa5a68665cca88e74b7876d5e025" + url: "https://pub.dev" + source: hosted + version: "6.6.1" + yaml: + dependency: transitive + description: + name: yaml + sha256: b9da305ac7c39faa3f030eccd175340f968459dae4af175130b3fc47e40d76ce + url: "https://pub.dev" + source: hosted + version: "3.1.3" +sdks: + dart: ">=3.10.3 <4.0.0" + flutter: ">=3.38.4" diff --git a/mobile/pubspec.yaml b/mobile/pubspec.yaml new file mode 100644 index 0000000..d686689 --- /dev/null +++ b/mobile/pubspec.yaml @@ -0,0 +1,33 @@ +name: msn_mobile +description: IYKYKA — multi-context messenger (Flutter client). +publish_to: "none" +version: 0.1.0+1 + +environment: + sdk: ">=3.5.0 <4.0.0" + +dependencies: + flutter: + sdk: flutter + cupertino_icons: ^1.0.8 + flutter_riverpod: ^2.6.1 + dio: ^5.7.0 + flutter_secure_storage: ^9.2.2 + web_socket_channel: ^3.0.1 + go_router: ^14.6.2 + shared_preferences: ^2.3.3 + sqflite: ^2.4.1 + path: ^1.9.0 + path_provider: ^2.1.4 + package_info_plus: ^8.1.2 + firebase_core: ^3.8.1 + firebase_messaging: ^15.1.6 + flutter_local_notifications: ^18.0.1 + +dev_dependencies: + flutter_test: + sdk: flutter + flutter_lints: ^5.0.0 + +flutter: + uses-material-design: true diff --git a/mobile/test/widget_test.dart b/mobile/test/widget_test.dart new file mode 100644 index 0000000..7dba85f --- /dev/null +++ b/mobile/test/widget_test.dart @@ -0,0 +1,18 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:msn_mobile/features/auth/login_page.dart'; + +void main() { + testWidgets('Login screen shows IYKYKA branding', (WidgetTester tester) async { + await tester.pumpWidget( + const ProviderScope( + child: MaterialApp( + home: LoginPage(), + ), + ), + ); + expect(find.text('IYKYKA'), findsOneWidget); + }); +} diff --git a/mobile/web/favicon.png b/mobile/web/favicon.png new file mode 100644 index 0000000..8aaa46a Binary files /dev/null and b/mobile/web/favicon.png differ diff --git a/mobile/web/icons/Icon-192.png b/mobile/web/icons/Icon-192.png new file mode 100644 index 0000000..b749bfe Binary files /dev/null and b/mobile/web/icons/Icon-192.png differ diff --git a/mobile/web/icons/Icon-512.png b/mobile/web/icons/Icon-512.png new file mode 100644 index 0000000..88cfd48 Binary files /dev/null and b/mobile/web/icons/Icon-512.png differ diff --git a/mobile/web/icons/Icon-maskable-192.png b/mobile/web/icons/Icon-maskable-192.png new file mode 100644 index 0000000..eb9b4d7 Binary files /dev/null and b/mobile/web/icons/Icon-maskable-192.png differ diff --git a/mobile/web/icons/Icon-maskable-512.png b/mobile/web/icons/Icon-maskable-512.png new file mode 100644 index 0000000..d69c566 Binary files /dev/null and b/mobile/web/icons/Icon-maskable-512.png differ diff --git a/mobile/web/index.html b/mobile/web/index.html new file mode 100644 index 0000000..5ba5c49 --- /dev/null +++ b/mobile/web/index.html @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + msn_mobile + + + + + + + diff --git a/mobile/web/manifest.json b/mobile/web/manifest.json new file mode 100644 index 0000000..75920ef --- /dev/null +++ b/mobile/web/manifest.json @@ -0,0 +1,35 @@ +{ + "name": "msn_mobile", + "short_name": "msn_mobile", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "A new Flutter project.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + }, + { + "src": "icons/Icon-maskable-192.png", + "sizes": "192x192", + "type": "image/png", + "purpose": "maskable" + }, + { + "src": "icons/Icon-maskable-512.png", + "sizes": "512x512", + "type": "image/png", + "purpose": "maskable" + } + ] +} diff --git a/server/data/msn.db b/server/data/msn.db new file mode 100644 index 0000000..07771dc Binary files /dev/null and b/server/data/msn.db differ diff --git a/server/package-lock.json b/server/package-lock.json new file mode 100644 index 0000000..8a43b68 --- /dev/null +++ b/server/package-lock.json @@ -0,0 +1,1738 @@ +{ + "name": "msn-server", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "msn-server", + "version": "1.0.0", + "dependencies": { + "bcryptjs": "^2.4.3", + "cors": "^2.8.5", + "express": "^4.21.0", + "jsonwebtoken": "^9.0.2", + "ws": "^8.18.0" + }, + "devDependencies": { + "@types/bcryptjs": "^2.4.6", + "@types/cors": "^2.8.17", + "@types/express": "^4.17.21", + "@types/jsonwebtoken": "^9.0.7", + "@types/node": "^22.10.0", + "@types/ws": "^8.5.13", + "tsx": "^4.19.2", + "typescript": "^5.7.2" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.7.tgz", + "integrity": "sha512-EKX3Qwmhz1eMdEJokhALr0YiD0lhQNwDqkPYyPhiSwKrh7/4KRjQc04sZ8db+5DVVnZ1LmbNDI1uAMPEUBnQPg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.7.tgz", + "integrity": "sha512-jbPXvB4Yj2yBV7HUfE2KHe4GJX51QplCN1pGbYjvsyCZbQmies29EoJbkEc+vYuU5o45AfQn37vZlyXy4YJ8RQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.7.tgz", + "integrity": "sha512-62dPZHpIXzvChfvfLJow3q5dDtiNMkwiRzPylSCfriLvZeq0a1bWChrGx/BbUbPwOrsWKMn8idSllklzBy+dgQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.7.tgz", + "integrity": "sha512-x5VpMODneVDb70PYV2VQOmIUUiBtY3D3mPBG8NxVk5CogneYhkR7MmM3yR/uMdITLrC1ml/NV1rj4bMJuy9MCg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.7.tgz", + "integrity": "sha512-5lckdqeuBPlKUwvoCXIgI2D9/ABmPq3Rdp7IfL70393YgaASt7tbju3Ac+ePVi3KDH6N2RqePfHnXkaDtY9fkw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.7.tgz", + "integrity": "sha512-rYnXrKcXuT7Z+WL5K980jVFdvVKhCHhUwid+dDYQpH+qu+TefcomiMAJpIiC2EM3Rjtq0sO3StMV/+3w3MyyqQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.7.tgz", + "integrity": "sha512-B48PqeCsEgOtzME2GbNM2roU29AMTuOIN91dsMO30t+Ydis3z/3Ngoj5hhnsOSSwNzS+6JppqWsuhTp6E82l2w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.7.tgz", + "integrity": "sha512-jOBDK5XEjA4m5IJK3bpAQF9/Lelu/Z9ZcdhTRLf4cajlB+8VEhFFRjWgfy3M1O4rO2GQ/b2dLwCUGpiF/eATNQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.7.tgz", + "integrity": "sha512-RkT/YXYBTSULo3+af8Ib0ykH8u2MBh57o7q/DAs3lTJlyVQkgQvlrPTnjIzzRPQyavxtPtfg0EopvDyIt0j1rA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.7.tgz", + "integrity": "sha512-RZPHBoxXuNnPQO9rvjh5jdkRmVizktkT7TCDkDmQ0W2SwHInKCAV95GRuvdSvA7w4VMwfCjUiPwDi0ZO6Nfe9A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.7.tgz", + "integrity": "sha512-GA48aKNkyQDbd3KtkplYWT102C5sn/EZTY4XROkxONgruHPU72l+gW+FfF8tf2cFjeHaRbWpOYa/uRBz/Xq1Pg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.7.tgz", + "integrity": "sha512-a4POruNM2oWsD4WKvBSEKGIiWQF8fZOAsycHOt6JBpZ+JN2n2JH9WAv56SOyu9X5IqAjqSIPTaJkqN8F7XOQ5Q==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.7.tgz", + "integrity": "sha512-KabT5I6StirGfIz0FMgl1I+R1H73Gp0ofL9A3nG3i/cYFJzKHhouBV5VWK1CSgKvVaG4q1RNpCTR2LuTVB3fIw==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.7.tgz", + "integrity": "sha512-gRsL4x6wsGHGRqhtI+ifpN/vpOFTQtnbsupUF5R5YTAg+y/lKelYR1hXbnBdzDjGbMYjVJLJTd2OFmMewAgwlQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.7.tgz", + "integrity": "sha512-hL25LbxO1QOngGzu2U5xeXtxXcW+/GvMN3ejANqXkxZ/opySAZMrc+9LY/WyjAan41unrR3YrmtTsUpwT66InQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.7.tgz", + "integrity": "sha512-2k8go8Ycu1Kb46vEelhu1vqEP+UeRVj2zY1pSuPdgvbd5ykAw82Lrro28vXUrRmzEsUV0NzCf54yARIK8r0fdw==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.7.tgz", + "integrity": "sha512-hzznmADPt+OmsYzw1EE33ccA+HPdIqiCRq7cQeL1Jlq2gb1+OyWBkMCrYGBJ+sxVzve2ZJEVeePbLM2iEIZSxA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.7.tgz", + "integrity": "sha512-b6pqtrQdigZBwZxAn1UpazEisvwaIDvdbMbmrly7cDTMFnw/+3lVxxCTGOrkPVnsYIosJJXAsILG9XcQS+Yu6w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.7.tgz", + "integrity": "sha512-OfatkLojr6U+WN5EDYuoQhtM+1xco+/6FSzJJnuWiUw5eVcicbyK3dq5EeV/QHT1uy6GoDhGbFpprUiHUYggrw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.7.tgz", + "integrity": "sha512-AFuojMQTxAz75Fo8idVcqoQWEHIXFRbOc1TrVcFSgCZtQfSdc1RXgB3tjOn/krRHENUB4j00bfGjyl2mJrU37A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.7.tgz", + "integrity": "sha512-+A1NJmfM8WNDv5CLVQYJ5PshuRm/4cI6WMZRg1by1GwPIQPCTs1GLEUHwiiQGT5zDdyLiRM/l1G0Pv54gvtKIg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.7.tgz", + "integrity": "sha512-+KrvYb/C8zA9CU/g0sR6w2RBw7IGc5J2BPnc3dYc5VJxHCSF1yNMxTV5LQ7GuKteQXZtspjFbiuW5/dOj7H4Yw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.7.tgz", + "integrity": "sha512-ikktIhFBzQNt/QDyOL580ti9+5mL/YZeUPKU2ivGtGjdTYoqz6jObj6nOMfhASpS4GU4Q/Clh1QtxWAvcYKamA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.7.tgz", + "integrity": "sha512-7yRhbHvPqSpRUV7Q20VuDwbjW5kIMwTHpptuUzV+AA46kiPze5Z7qgt6CLCK3pWFrHeNfDd1VKgyP4O+ng17CA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.7.tgz", + "integrity": "sha512-SmwKXe6VHIyZYbBLJrhOoCJRB/Z1tckzmgTLfFYOfpMAx63BJEaL9ExI8x7v0oAO3Zh6D/Oi1gVxEYr5oUCFhw==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.7.tgz", + "integrity": "sha512-56hiAJPhwQ1R4i+21FVF7V8kSD5zZTdHcVuRFMW0hn753vVfQN8xlx4uOPT4xoGH0Z/oVATuR82AiqSTDIpaHg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@types/bcryptjs": { + "version": "2.4.6", + "resolved": "https://registry.npmjs.org/@types/bcryptjs/-/bcryptjs-2.4.6.tgz", + "integrity": "sha512-9xlo6R2qDs5uixm0bcIqCeMCE6HiQsIyel9KQySStiyqNl2tnj2mP3DX1Nf56MD6KMenNNlBBsy3LJ7gUEQPXQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/body-parser": { + "version": "1.19.6", + "resolved": "https://registry.npmjs.org/@types/body-parser/-/body-parser-1.19.6.tgz", + "integrity": "sha512-HLFeCYgz89uk22N5Qg3dvGvsv46B8GLvKKo1zKG4NybA8U2DiEO3w9lqGg29t/tfLRJpJ6iQxnVw4OnB7MoM9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/connect": "*", + "@types/node": "*" + } + }, + "node_modules/@types/connect": { + "version": "3.4.38", + "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.38.tgz", + "integrity": "sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/cors": { + "version": "2.8.19", + "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.19.tgz", + "integrity": "sha512-mFNylyeyqN93lfe/9CSxOGREz8cpzAhH+E93xJ4xWQf62V8sQ/24reV2nyzUWM6H6Xji+GGHpkbLe7pVoUEskg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/express": { + "version": "4.17.25", + "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.25.tgz", + "integrity": "sha512-dVd04UKsfpINUnK0yBoYHDF3xu7xVH4BuDotC/xGuycx4CgbP48X/KF/586bcObxT0HENHXEU8Nqtu6NR+eKhw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/body-parser": "*", + "@types/express-serve-static-core": "^4.17.33", + "@types/qs": "*", + "@types/serve-static": "^1" + } + }, + "node_modules/@types/express-serve-static-core": { + "version": "4.19.8", + "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.19.8.tgz", + "integrity": "sha512-02S5fmqeoKzVZCHPZid4b8JH2eM5HzQLZWN2FohQEy/0eXTq8VXZfSN6Pcr3F6N9R/vNrj7cpgbhjie6m/1tCA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*", + "@types/qs": "*", + "@types/range-parser": "*", + "@types/send": "*" + } + }, + "node_modules/@types/http-errors": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.5.tgz", + "integrity": "sha512-r8Tayk8HJnX0FztbZN7oVqGccWgw98T/0neJphO91KkmOzug1KkofZURD4UaD5uH8AqcFLfdPErnBod0u71/qg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/jsonwebtoken": { + "version": "9.0.10", + "resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-9.0.10.tgz", + "integrity": "sha512-asx5hIG9Qmf/1oStypjanR7iKTv0gXQ1Ov/jfrX6kS/EO0OFni8orbmGCn0672NHR3kXHwpAwR+B368ZGN/2rA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/ms": "*", + "@types/node": "*" + } + }, + "node_modules/@types/mime": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz", + "integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/ms": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/@types/ms/-/ms-2.1.0.tgz", + "integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "22.19.17", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.17.tgz", + "integrity": "sha512-wGdMcf+vPYM6jikpS/qhg6WiqSV/OhG+jeeHT/KlVqxYfD40iYJf9/AE1uQxVWFvU7MipKRkRv8NSHiCGgPr8Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/@types/qs": { + "version": "6.15.0", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.15.0.tgz", + "integrity": "sha512-JawvT8iBVWpzTrz3EGw9BTQFg3BQNmwERdKE22vlTxawwtbyUSlMppvZYKLZzB5zgACXdXxbD3m1bXaMqP/9ow==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/range-parser": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/@types/range-parser/-/range-parser-1.2.7.tgz", + "integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/send": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@types/send/-/send-1.2.1.tgz", + "integrity": "sha512-arsCikDvlU99zl1g69TcAB3mzZPpxgw0UQnaHeC1Nwb015xp8bknZv5rIfri9xTOcMuaVgvabfIRA7PSZVuZIQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/serve-static": { + "version": "1.15.10", + "resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.10.tgz", + "integrity": "sha512-tRs1dB+g8Itk72rlSI2ZrW6vZg0YrLI81iQSTkMmOqnqCaNr/8Ek4VwWcN5vZgCYWbg/JJSGBlUaYGAOP73qBw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/http-errors": "*", + "@types/node": "*", + "@types/send": "<1" + } + }, + "node_modules/@types/serve-static/node_modules/@types/send": { + "version": "0.17.6", + "resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.6.tgz", + "integrity": "sha512-Uqt8rPBE8SY0RK8JB1EzVOIZ32uqy8HwdxCnoCOsYrvnswqmFZ/k+9Ikidlk/ImhsdvBsloHbAlewb2IEBV/Og==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/mime": "^1", + "@types/node": "*" + } + }, + "node_modules/@types/ws": { + "version": "8.18.1", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.18.1.tgz", + "integrity": "sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "license": "MIT", + "dependencies": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==", + "license": "MIT" + }, + "node_modules/bcryptjs": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-2.4.3.tgz", + "integrity": "sha512-V/Hy/X9Vt7f3BbPJEi8BdVFMByHi+jNXrYkW3huaybV/kQ0KJg0Y6PkEMbn+zeT+i+SiKZ/HMqJGIIt4LZDqNQ==", + "license": "MIT" + }, + "node_modules/body-parser": { + "version": "1.20.4", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.4.tgz", + "integrity": "sha512-ZTgYYLMOXY9qKU/57FAo8F+HA2dGX7bqGc71txDRC1rS4frdFI5R7NhluHxH6M0YItAP0sHB4uqAOcYKxO6uGA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "content-type": "~1.0.5", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "~1.2.0", + "http-errors": "~2.0.1", + "iconv-lite": "~0.4.24", + "on-finished": "~2.4.1", + "qs": "~6.14.0", + "raw-body": "~2.5.3", + "type-is": "~1.6.18", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", + "license": "BSD-3-Clause" + }, + "node_modules/bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/call-bound": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz", + "integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "get-intrinsic": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "license": "MIT", + "dependencies": { + "safe-buffer": "5.2.1" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/content-type": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz", + "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie": { + "version": "0.7.2", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz", + "integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/cookie-signature": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz", + "integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==", + "license": "MIT" + }, + "node_modules/cors": { + "version": "2.8.6", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz", + "integrity": "sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw==", + "license": "MIT", + "dependencies": { + "object-assign": "^4", + "vary": "^1" + }, + "engines": { + "node": ">= 0.10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "license": "MIT", + "dependencies": { + "ms": "2.0.0" + } + }, + "node_modules/depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==", + "license": "MIT", + "engines": { + "node": ">= 0.8", + "npm": "1.2.8000 || >= 1.4.16" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "license": "Apache-2.0", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, + "node_modules/ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==", + "license": "MIT" + }, + "node_modules/encodeurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/esbuild": { + "version": "0.27.7", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.7.tgz", + "integrity": "sha512-IxpibTjyVnmrIQo5aqNpCgoACA/dTKLTlhMHihVHhdkxKyPO1uBBthumT0rdHmcsk9uMonIWS0m4FljWzILh3w==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.27.7", + "@esbuild/android-arm": "0.27.7", + "@esbuild/android-arm64": "0.27.7", + "@esbuild/android-x64": "0.27.7", + "@esbuild/darwin-arm64": "0.27.7", + "@esbuild/darwin-x64": "0.27.7", + "@esbuild/freebsd-arm64": "0.27.7", + "@esbuild/freebsd-x64": "0.27.7", + "@esbuild/linux-arm": "0.27.7", + "@esbuild/linux-arm64": "0.27.7", + "@esbuild/linux-ia32": "0.27.7", + "@esbuild/linux-loong64": "0.27.7", + "@esbuild/linux-mips64el": "0.27.7", + "@esbuild/linux-ppc64": "0.27.7", + "@esbuild/linux-riscv64": "0.27.7", + "@esbuild/linux-s390x": "0.27.7", + "@esbuild/linux-x64": "0.27.7", + "@esbuild/netbsd-arm64": "0.27.7", + "@esbuild/netbsd-x64": "0.27.7", + "@esbuild/openbsd-arm64": "0.27.7", + "@esbuild/openbsd-x64": "0.27.7", + "@esbuild/openharmony-arm64": "0.27.7", + "@esbuild/sunos-x64": "0.27.7", + "@esbuild/win32-arm64": "0.27.7", + "@esbuild/win32-ia32": "0.27.7", + "@esbuild/win32-x64": "0.27.7" + } + }, + "node_modules/escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", + "license": "MIT" + }, + "node_modules/etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/express": { + "version": "4.22.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.22.1.tgz", + "integrity": "sha512-F2X8g9P1X7uCPZMA3MVf9wcTqlyNp7IhH5qPCI0izhaOIYXaW9L535tGA3qmjRzpH+bZczqq7hVKxTR4NWnu+g==", + "license": "MIT", + "dependencies": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "~1.20.3", + "content-disposition": "~0.5.4", + "content-type": "~1.0.4", + "cookie": "~0.7.1", + "cookie-signature": "~1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "~1.3.1", + "fresh": "~0.5.2", + "http-errors": "~2.0.0", + "merge-descriptors": "1.0.3", + "methods": "~1.1.2", + "on-finished": "~2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "~0.1.12", + "proxy-addr": "~2.0.7", + "qs": "~6.14.0", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "~0.19.0", + "serve-static": "~1.16.2", + "setprototypeof": "1.2.0", + "statuses": "~2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "engines": { + "node": ">= 0.10.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/finalhandler": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz", + "integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "on-finished": "~2.4.1", + "parseurl": "~1.3.3", + "statuses": "~2.0.2", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/get-tsconfig": { + "version": "4.13.7", + "resolved": "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.13.7.tgz", + "integrity": "sha512-7tN6rFgBlMgpBML5j8typ92BKFi2sFQvIdpAqLA2beia5avZDrMs0FLZiM5etShWq5irVyGcGMEA1jcDaK7A/Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "resolve-pkg-maps": "^1.0.0" + }, + "funding": { + "url": "https://github.com/privatenumber/get-tsconfig?sponsor=1" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/http-errors": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz", + "integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==", + "license": "MIT", + "dependencies": { + "depd": "~2.0.0", + "inherits": "~2.0.4", + "setprototypeof": "~1.2.0", + "statuses": "~2.0.2", + "toidentifier": "~1.0.1" + }, + "engines": { + "node": ">= 0.8" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/express" + } + }, + "node_modules/iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "license": "MIT", + "dependencies": { + "safer-buffer": ">= 2.1.2 < 3" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==", + "license": "MIT", + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/jsonwebtoken": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.3.tgz", + "integrity": "sha512-MT/xP0CrubFRNLNKvxJ2BYfy53Zkm++5bX9dtuPbqAeQpTVe0MQTFhao8+Cp//EmJp244xt6Drw/GVEGCUj40g==", + "license": "MIT", + "dependencies": { + "jws": "^4.0.1", + "lodash.includes": "^4.3.0", + "lodash.isboolean": "^3.0.3", + "lodash.isinteger": "^4.0.4", + "lodash.isnumber": "^3.0.3", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.once": "^4.0.0", + "ms": "^2.1.1", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=12", + "npm": ">=6" + } + }, + "node_modules/jsonwebtoken/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/jwa": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-2.0.1.tgz", + "integrity": "sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg==", + "license": "MIT", + "dependencies": { + "buffer-equal-constant-time": "^1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jws": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/jws/-/jws-4.0.1.tgz", + "integrity": "sha512-EKI/M/yqPncGUUh44xz0PxSidXFr/+r0pA70+gIYhjv+et7yxM+s29Y+VGDkovRofQem0fs7Uvf4+YmAdyRduA==", + "license": "MIT", + "dependencies": { + "jwa": "^2.0.1", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/lodash.includes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", + "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==", + "license": "MIT" + }, + "node_modules/lodash.isboolean": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", + "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==", + "license": "MIT" + }, + "node_modules/lodash.isinteger": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", + "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==", + "license": "MIT" + }, + "node_modules/lodash.isnumber": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", + "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==", + "license": "MIT" + }, + "node_modules/lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", + "license": "MIT" + }, + "node_modules/lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==", + "license": "MIT" + }, + "node_modules/lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==", + "license": "MIT" + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/merge-descriptors": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "license": "MIT", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", + "license": "MIT" + }, + "node_modules/negotiator": { + "version": "0.6.3", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/object-inspect": { + "version": "1.13.4", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", + "integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "license": "MIT", + "dependencies": { + "ee-first": "1.1.1" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/path-to-regexp": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.13.tgz", + "integrity": "sha512-A/AGNMFN3c8bOlvV9RreMdrv7jsmF9XIfDeCd87+I8RNg6s78BhJxMu69NEMHBSJFxKidViTEdruRwEk/WIKqA==", + "license": "MIT" + }, + "node_modules/proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "license": "MIT", + "dependencies": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/qs": { + "version": "6.14.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.14.2.tgz", + "integrity": "sha512-V/yCWTTF7VJ9hIh18Ugr2zhJMP01MY7c5kh4J870L7imm6/DIzBsNLTXzMwUA3yZ5b/KBqLx8Kp3uRvd7xSe3Q==", + "license": "BSD-3-Clause", + "dependencies": { + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/raw-body": { + "version": "2.5.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz", + "integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==", + "license": "MIT", + "dependencies": { + "bytes": "~3.1.2", + "http-errors": "~2.0.1", + "iconv-lite": "~0.4.24", + "unpipe": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/resolve-pkg-maps": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/resolve-pkg-maps/-/resolve-pkg-maps-1.0.0.tgz", + "integrity": "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/privatenumber/resolve-pkg-maps?sponsor=1" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "license": "MIT" + }, + "node_modules/semver": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz", + "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/send": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.19.2.tgz", + "integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==", + "license": "MIT", + "dependencies": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "~0.5.2", + "http-errors": "~2.0.1", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "~2.4.1", + "range-parser": "~1.2.1", + "statuses": "~2.0.2" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/send/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/serve-static": { + "version": "1.16.3", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz", + "integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==", + "license": "MIT", + "dependencies": { + "encodeurl": "~2.0.0", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "~0.19.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", + "license": "ISC" + }, + "node_modules/side-channel": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", + "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3", + "side-channel-list": "^1.0.0", + "side-channel-map": "^1.0.1", + "side-channel-weakmap": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-list": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz", + "integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-map": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz", + "integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/side-channel-weakmap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz", + "integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==", + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.5", + "object-inspect": "^1.13.3", + "side-channel-map": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/statuses": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz", + "integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==", + "license": "MIT", + "engines": { + "node": ">=0.6" + } + }, + "node_modules/tsx": { + "version": "4.21.0", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.21.0.tgz", + "integrity": "sha512-5C1sg4USs1lfG0GFb2RLXsdpXqBSEhAaA/0kPL01wxzpMqLILNxIxIOKiILz+cdg/pLnOUxFYOR5yhHU666wbw==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "~0.27.0", + "get-tsconfig": "^4.7.5" + }, + "bin": { + "tsx": "dist/cli.mjs" + }, + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + }, + "node_modules/type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "license": "MIT", + "dependencies": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==", + "license": "MIT", + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==", + "license": "MIT", + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/ws": { + "version": "8.20.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.20.0.tgz", + "integrity": "sha512-sAt8BhgNbzCtgGbt2OxmpuryO63ZoDk/sqaB/znQm94T4fCEsy/yV+7CdC1kJhOU9lboAEU7R3kquuycDoibVA==", + "license": "MIT", + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + } + } +} diff --git a/server/package.json b/server/package.json new file mode 100644 index 0000000..04cc5f3 --- /dev/null +++ b/server/package.json @@ -0,0 +1,28 @@ +{ + "name": "msn-server", + "version": "1.0.0", + "private": true, + "type": "module", + "scripts": { + "dev": "tsx watch src/index.ts", + "build": "tsc", + "start": "node dist/index.js" + }, + "dependencies": { + "bcryptjs": "^2.4.3", + "cors": "^2.8.5", + "express": "^4.21.0", + "jsonwebtoken": "^9.0.2", + "ws": "^8.18.0" + }, + "devDependencies": { + "@types/bcryptjs": "^2.4.6", + "@types/cors": "^2.8.17", + "@types/express": "^4.17.21", + "@types/jsonwebtoken": "^9.0.7", + "@types/node": "^22.10.0", + "@types/ws": "^8.5.13", + "tsx": "^4.19.2", + "typescript": "^5.7.2" + } +} diff --git a/server/src/auth.ts b/server/src/auth.ts new file mode 100644 index 0000000..c7b4070 --- /dev/null +++ b/server/src/auth.ts @@ -0,0 +1,14 @@ +import jwt from "jsonwebtoken"; + +const JWT_SECRET = process.env.JWT_SECRET ?? "msn-dev-secret-change-me"; + +export type JwtPayload = { sub: string; email: string }; + +export function signToken(userId: string, email: string): string { + return jwt.sign({ sub: userId, email }, JWT_SECRET, { expiresIn: "30d" }); +} + +export function verifyToken(token: string): JwtPayload { + const decoded = jwt.verify(token, JWT_SECRET) as JwtPayload; + return decoded; +} diff --git a/server/src/contextAccess.ts b/server/src/contextAccess.ts new file mode 100644 index 0000000..65b17f4 --- /dev/null +++ b/server/src/contextAccess.ts @@ -0,0 +1,17 @@ +import { db } from "./db.js"; + +export function isMemberOfContext(userId: string, contextId: string): boolean { + const row = db + .prepare( + `SELECT 1 FROM context_members WHERE user_id = ? AND context_id = ?` + ) + .get(userId, contextId) as { 1: number } | undefined; + return !!row; +} + +export function requireContextMember( + userId: string, + contextId: string +): boolean { + return isMemberOfContext(userId, contextId); +} diff --git a/server/src/db.ts b/server/src/db.ts new file mode 100644 index 0000000..c1079f2 --- /dev/null +++ b/server/src/db.ts @@ -0,0 +1,89 @@ +import { DatabaseSync } from "node:sqlite"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; +import fs from "node:fs"; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const dataDir = path.join(__dirname, "..", "data"); +fs.mkdirSync(dataDir, { recursive: true }); +const dbPath = process.env.SQLITE_PATH ?? path.join(dataDir, "msn.db"); + +export const db = new DatabaseSync(dbPath); +db.exec("PRAGMA foreign_keys = ON"); + +db.exec(` +CREATE TABLE IF NOT EXISTS users ( + id TEXT PRIMARY KEY, + email TEXT NOT NULL UNIQUE, + password_hash TEXT NOT NULL, + created_at TEXT NOT NULL DEFAULT (datetime('now')) +); + +CREATE TABLE IF NOT EXISTS contexts ( + id TEXT PRIMARY KEY, + name TEXT NOT NULL, + kind TEXT NOT NULL CHECK (kind IN ('personal','work','other')), + created_at TEXT NOT NULL DEFAULT (datetime('now')), + retention_days INTEGER, + screenshot_blocked INTEGER NOT NULL DEFAULT 0 +); + +CREATE TABLE IF NOT EXISTS context_members ( + context_id TEXT NOT NULL REFERENCES contexts(id) ON DELETE CASCADE, + user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE, + role TEXT NOT NULL DEFAULT 'member', + joined_at TEXT NOT NULL DEFAULT (datetime('now')), + PRIMARY KEY (context_id, user_id) +); + +CREATE TABLE IF NOT EXISTS profiles ( + user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE, + context_id TEXT NOT NULL REFERENCES contexts(id) ON DELETE CASCADE, + display_name TEXT NOT NULL, + avatar_url TEXT, + status_message TEXT, + updated_at TEXT NOT NULL DEFAULT (datetime('now')), + PRIMARY KEY (user_id, context_id) +); + +CREATE TABLE IF NOT EXISTS rooms ( + id TEXT PRIMARY KEY, + context_id TEXT NOT NULL REFERENCES contexts(id) ON DELETE CASCADE, + is_group INTEGER NOT NULL DEFAULT 0, + name TEXT, + created_at TEXT NOT NULL DEFAULT (datetime('now')) +); + +CREATE TABLE IF NOT EXISTS room_members ( + room_id TEXT NOT NULL REFERENCES rooms(id) ON DELETE CASCADE, + user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE, + PRIMARY KEY (room_id, user_id) +); + +CREATE TABLE IF NOT EXISTS messages ( + id TEXT PRIMARY KEY, + room_id TEXT NOT NULL REFERENCES rooms(id) ON DELETE CASCADE, + sender_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE, + body TEXT NOT NULL, + created_at TEXT NOT NULL DEFAULT (datetime('now')), + kind TEXT NOT NULL DEFAULT 'text' +); + +CREATE TABLE IF NOT EXISTS message_reads ( + message_id TEXT NOT NULL REFERENCES messages(id) ON DELETE CASCADE, + user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE, + read_at TEXT NOT NULL DEFAULT (datetime('now')), + PRIMARY KEY (message_id, user_id) +); + +CREATE TABLE IF NOT EXISTS push_tokens ( + user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE, + token TEXT NOT NULL, + platform TEXT, + updated_at TEXT NOT NULL DEFAULT (datetime('now')), + PRIMARY KEY (user_id, token) +); + +CREATE INDEX IF NOT EXISTS idx_messages_room ON messages(room_id, created_at); +CREATE INDEX IF NOT EXISTS idx_rooms_context ON rooms(context_id); +`); diff --git a/server/src/index.ts b/server/src/index.ts new file mode 100644 index 0000000..63ae49a --- /dev/null +++ b/server/src/index.ts @@ -0,0 +1,42 @@ +import express from "express"; +import cors from "cors"; +import http from "node:http"; +import { authRouter } from "./routes/authRoutes.js"; +import { contextRouter } from "./routes/contextRoutes.js"; +import { profileRouter } from "./routes/profileRoutes.js"; +import { roomRouter } from "./routes/roomRoutes.js"; +import { messageRouter } from "./routes/messageRoutes.js"; +import { pushRouter } from "./routes/pushRoutes.js"; +import "./db.js"; +import { + backfillDemoAvatarsIfNeeded, + extendDemoDataIfNeeded, + seedDemoIfNeeded, +} from "./seed.js"; +import { attachWebSocket } from "./realtime.js"; + +seedDemoIfNeeded(); +backfillDemoAvatarsIfNeeded(); +extendDemoDataIfNeeded(); + +const app = express(); +app.use(cors()); +app.use(express.json()); + +app.get("/health", (_req, res) => res.json({ ok: true })); + +app.use("/api/auth", authRouter); +app.use("/api/contexts", contextRouter); +app.use("/api/profiles", profileRouter); +app.use("/api/rooms", roomRouter); +app.use("/api/messages", messageRouter); +app.use("/api/push", pushRouter); + +const port = Number(process.env.PORT ?? 8787); +const server = http.createServer(app); +attachWebSocket(server); + +server.listen(port, () => { + console.log(`msn-server listening on http://localhost:${port}`); + console.log(`WebSocket: ws://localhost:${port}/ws?token=JWT`); +}); diff --git a/server/src/middleware.ts b/server/src/middleware.ts new file mode 100644 index 0000000..534eaac --- /dev/null +++ b/server/src/middleware.ts @@ -0,0 +1,21 @@ +import type { Request, Response, NextFunction } from "express"; +import { verifyToken } from "./auth.js"; + +export type AuthedRequest = Request & { userId?: string; userEmail?: string }; + +export function requireAuth(req: AuthedRequest, res: Response, next: NextFunction) { + const header = req.headers.authorization; + const token = header?.startsWith("Bearer ") ? header.slice(7) : undefined; + if (!token) { + res.status(401).json({ error: "Unauthorized" }); + return; + } + try { + const p = verifyToken(token); + req.userId = p.sub; + req.userEmail = p.email; + next(); + } catch { + res.status(401).json({ error: "Invalid token" }); + } +} diff --git a/server/src/realtime.ts b/server/src/realtime.ts new file mode 100644 index 0000000..c3ed439 --- /dev/null +++ b/server/src/realtime.ts @@ -0,0 +1,197 @@ +import type { Server } from "node:http"; +import { WebSocketServer, WebSocket } from "ws"; +import { randomUUID } from "node:crypto"; +import { verifyToken } from "./auth.js"; +import { db } from "./db.js"; + +export type ClientMessage = + | { type: "subscribe"; roomId: string } + | { type: "send"; roomId: string; body: string; kind?: string } + | { type: "typing"; roomId: string; active: boolean }; + +export type ServerMessage = + | { type: "message"; message: OutMessage } + | { type: "error"; message: string } + | { type: "typing"; roomId: string; userId: string; active: boolean } + | { type: "read"; roomId: string; userId: string; upToMessageId: string }; + +export type OutMessage = { + id: string; + roomId: string; + contextId: string; + senderId: string; + body: string; + createdAt: string; + kind: string; +}; + +const roomSubscribers = new Map>(); + +function userInRoom(userId: string, roomId: string): boolean { + const r = db + .prepare(`SELECT 1 FROM room_members WHERE user_id = ? AND room_id = ?`) + .get(userId, roomId) as { 1: number } | undefined; + return !!r; +} + +function getRoomContext(roomId: string): string | null { + const row = db + .prepare(`SELECT context_id FROM rooms WHERE id = ?`) + .get(roomId) as { context_id: string } | undefined; + return row?.context_id ?? null; +} + +function broadcast(roomId: string, payload: ServerMessage) { + const set = roomSubscribers.get(roomId); + if (!set) return; + const data = JSON.stringify(payload); + for (const ws of set) { + if (ws.readyState === WebSocket.OPEN) ws.send(data); + } +} + +export function broadcastToRoom(roomId: string, payload: ServerMessage) { + broadcast(roomId, payload); +} + +/** Stub: log push payload shape for FCM (contextId + roomId for deep link). */ +function notifyPushStub( + targetUserIds: string[], + contextId: string, + roomId: string, + preview: string +) { + for (const uid of targetUserIds) { + console.log( + `[push stub] to=${uid} contextId=${contextId} roomId=${roomId} preview=${preview.slice(0, 40)}` + ); + } +} + +export function attachWebSocket(httpServer: Server) { + const wss = new WebSocketServer({ server: httpServer, path: "/ws" }); + + wss.on("connection", (ws, req) => { + const url = new URL(req.url ?? "", "http://localhost"); + const token = url.searchParams.get("token"); + if (!token) { + ws.close(4001, "token required"); + return; + } + let userId: string; + try { + userId = verifyToken(token).sub; + } catch { + ws.close(4002, "invalid token"); + return; + } + + const subscribed = new Set(); + + ws.on("message", (raw) => { + let msg: ClientMessage; + try { + msg = JSON.parse(String(raw)) as ClientMessage; + } catch { + ws.send(JSON.stringify({ type: "error", message: "invalid json" } satisfies ServerMessage)); + return; + } + if (msg.type === "typing") { + if (!userInRoom(userId, msg.roomId)) { + ws.send( + JSON.stringify({ type: "error", message: "forbidden" } satisfies ServerMessage) + ); + return; + } + const payload: ServerMessage = { + type: "typing", + roomId: msg.roomId, + userId, + active: !!msg.active, + }; + const set = roomSubscribers.get(msg.roomId); + if (!set) return; + const data = JSON.stringify(payload); + for (const client of set) { + if (client === ws) continue; + if (client.readyState === WebSocket.OPEN) client.send(data); + } + return; + } + if (msg.type === "subscribe") { + if (!userInRoom(userId, msg.roomId)) { + ws.send( + JSON.stringify({ type: "error", message: "forbidden" } satisfies ServerMessage) + ); + return; + } + subscribed.add(msg.roomId); + let set = roomSubscribers.get(msg.roomId); + if (!set) { + set = new Set(); + roomSubscribers.set(msg.roomId, set); + } + set.add(ws); + return; + } + if (msg.type === "send") { + if (!userInRoom(userId, msg.roomId)) { + ws.send( + JSON.stringify({ type: "error", message: "forbidden" } satisfies ServerMessage) + ); + return; + } + const id = randomUUID(); + const kind = msg.kind && msg.kind !== "text" ? msg.kind : "text"; + db.prepare( + `INSERT INTO messages (id, room_id, sender_id, body, kind) VALUES (?, ?, ?, ?, ?)` + ).run(id, msg.roomId, userId, msg.body, kind); + const row = db + .prepare( + `SELECT id, room_id, sender_id, body, created_at, kind FROM messages WHERE id = ?` + ) + .get(id) as { + id: string; + room_id: string; + sender_id: string; + body: string; + created_at: string; + kind: string; + }; + const contextId = getRoomContext(msg.roomId); + if (!contextId) return; + const out: OutMessage = { + id: row.id, + roomId: row.room_id, + contextId, + senderId: row.sender_id, + body: row.body, + createdAt: row.created_at, + kind: row.kind, + }; + broadcast(msg.roomId, { type: "message", message: out }); + + const others = db + .prepare(`SELECT user_id FROM room_members WHERE room_id = ? AND user_id != ?`) + .all(msg.roomId, userId) as { user_id: string }[]; + notifyPushStub( + others.map((o) => o.user_id), + contextId, + msg.roomId, + msg.body + ); + return; + } + }); + + ws.on("close", () => { + for (const roomId of subscribed) { + const set = roomSubscribers.get(roomId); + if (set) { + set.delete(ws); + if (set.size === 0) roomSubscribers.delete(roomId); + } + } + }); + }); +} diff --git a/server/src/routes/authRoutes.ts b/server/src/routes/authRoutes.ts new file mode 100644 index 0000000..1fed7c6 --- /dev/null +++ b/server/src/routes/authRoutes.ts @@ -0,0 +1,85 @@ +import { Router } from "express"; +import bcrypt from "bcryptjs"; +import { randomUUID } from "node:crypto"; +import { db } from "../db.js"; +import { signToken } from "../auth.js"; +import type { AuthedRequest } from "../middleware.js"; +import { requireAuth } from "../middleware.js"; + +export const authRouter = Router(); + +authRouter.post("/register", (req, res) => { + const { email, password, displayName } = req.body as { + email?: string; + password?: string; + displayName?: string; + }; + if (!email || !password) { + res.status(400).json({ error: "email and password required" }); + return; + } + const existing = db.prepare(`SELECT id FROM users WHERE email = ?`).get(email) as + | { id: string } + | undefined; + if (existing) { + res.status(409).json({ error: "Email already registered" }); + return; + } + const userId = randomUUID(); + const hash = bcrypt.hashSync(password, 10); + db.prepare(`INSERT INTO users (id, email, password_hash) VALUES (?, ?, ?)`).run( + userId, + email, + hash + ); + + const personalContextId = randomUUID(); + db.prepare( + `INSERT INTO contexts (id, name, kind) VALUES (?, ?, 'personal')` + ).run(personalContextId, "일상"); + db.prepare( + `INSERT INTO context_members (context_id, user_id, role) VALUES (?, ?, 'owner')` + ).run(personalContextId, userId); + db.prepare( + `INSERT INTO profiles (user_id, context_id, display_name) VALUES (?, ?, ?)` + ).run(userId, personalContextId, displayName ?? email.split("@")[0]); + + const token = signToken(userId, email); + res.status(201).json({ + token, + user: { id: userId, email }, + defaultContextId: personalContextId, + }); +}); + +authRouter.post("/login", (req, res) => { + const { email, password } = req.body as { email?: string; password?: string }; + if (!email || !password) { + res.status(400).json({ error: "email and password required" }); + return; + } + const row = db + .prepare(`SELECT id, email, password_hash FROM users WHERE email = ?`) + .get(email) as { id: string; email: string; password_hash: string } | undefined; + if (!row || !bcrypt.compareSync(password, row.password_hash)) { + res.status(401).json({ error: "Invalid credentials" }); + return; + } + const token = signToken(row.id, row.email); + const personal = db + .prepare( + `SELECT c.id FROM contexts c + JOIN context_members m ON m.context_id = c.id + WHERE m.user_id = ? AND c.kind = 'personal' LIMIT 1` + ) + .get(row.id) as { id: string } | undefined; + res.json({ + token, + user: { id: row.id, email: row.email }, + defaultContextId: personal?.id ?? null, + }); +}); + +authRouter.get("/me", requireAuth, (req: AuthedRequest, res) => { + res.json({ id: req.userId, email: req.userEmail }); +}); diff --git a/server/src/routes/contextRoutes.ts b/server/src/routes/contextRoutes.ts new file mode 100644 index 0000000..3265774 --- /dev/null +++ b/server/src/routes/contextRoutes.ts @@ -0,0 +1,125 @@ +import { Router } from "express"; +import { randomUUID } from "node:crypto"; +import { db } from "../db.js"; +import type { AuthedRequest } from "../middleware.js"; +import { requireAuth } from "../middleware.js"; +import { isMemberOfContext } from "../contextAccess.js"; + +export const contextRouter = Router(); +contextRouter.use(requireAuth); + +contextRouter.get("/", (req: AuthedRequest, res) => { + const rows = db + .prepare( + `SELECT c.id, c.name, c.kind, c.retention_days, c.screenshot_blocked + FROM contexts c + JOIN context_members m ON m.context_id = c.id + WHERE m.user_id = ? + ORDER BY c.kind = 'personal' DESC, c.name` + ) + .all(req.userId!) as Array<{ + id: string; + name: string; + kind: string; + retention_days: number | null; + screenshot_blocked: number; + }>; + res.json({ + contexts: rows.map((r) => ({ + id: r.id, + name: r.name, + kind: r.kind, + policy: { + retentionDays: r.retention_days, + screenshotBlocked: !!r.screenshot_blocked, + }, + })), + }); +}); + +contextRouter.post("/", (req: AuthedRequest, res) => { + const { name, kind } = req.body as { name?: string; kind?: string }; + if (!name) { + res.status(400).json({ error: "name required" }); + return; + } + const k = kind === "work" || kind === "other" ? kind : "work"; + const id = randomUUID(); + db.prepare(`INSERT INTO contexts (id, name, kind) VALUES (?, ?, ?)`).run(id, name, k); + db.prepare( + `INSERT INTO context_members (context_id, user_id, role) VALUES (?, ?, 'owner')` + ).run(id, req.userId!); + const email = req.userEmail!; + const display = email.split("@")[0]; + db.prepare( + `INSERT INTO profiles (user_id, context_id, display_name) VALUES (?, ?, ?)` + ).run(req.userId!, id, display); + res.status(201).json({ id, name, kind: k }); +}); + +/** List members of a context with profile fields for this context only. */ +contextRouter.get("/:contextId/members", (req: AuthedRequest, res) => { + const { contextId } = req.params; + if (!isMemberOfContext(req.userId!, contextId)) { + res.status(403).json({ error: "Forbidden" }); + return; + } + const rows = db + .prepare( + `SELECT m.user_id, m.role, p.display_name, p.avatar_url, p.status_message + FROM context_members m + JOIN profiles p ON p.user_id = m.user_id AND p.context_id = m.context_id + WHERE m.context_id = ? + ORDER BY p.display_name COLLATE NOCASE` + ) + .all(contextId) as Array<{ + user_id: string; + role: string; + display_name: string; + avatar_url: string | null; + status_message: string | null; + }>; + res.json({ + members: rows.map((r) => ({ + userId: r.user_id, + role: r.role, + displayName: r.display_name, + avatarUrl: r.avatar_url, + statusMessage: r.status_message, + })), + }); +}); + +/** Add an existing user to this context by email (workplace registration). */ +contextRouter.post("/:contextId/members", (req: AuthedRequest, res) => { + const { contextId } = req.params; + const { email } = req.body as { email?: string }; + if (!email) { + res.status(400).json({ error: "email required" }); + return; + } + if (!isMemberOfContext(req.userId!, contextId)) { + res.status(403).json({ error: "Forbidden" }); + return; + } + const target = db.prepare(`SELECT id FROM users WHERE email = ?`).get(email) as + | { id: string } + | undefined; + if (!target) { + res.status(404).json({ error: "User not found" }); + return; + } + try { + db.prepare( + `INSERT INTO context_members (context_id, user_id, role) VALUES (?, ?, 'member')` + ).run(contextId, target.id); + } catch { + res.status(409).json({ error: "Already a member" }); + return; + } + const display = email.split("@")[0]; + db.prepare( + `INSERT OR IGNORE INTO profiles (user_id, context_id, display_name) VALUES (?, ?, ?)` + ).run(target.id, contextId, display); + res.status(201).json({ userId: target.id }); +}); diff --git a/server/src/routes/messageRoutes.ts b/server/src/routes/messageRoutes.ts new file mode 100644 index 0000000..0f5c34a --- /dev/null +++ b/server/src/routes/messageRoutes.ts @@ -0,0 +1,162 @@ +import { Router } from "express"; +import { db } from "../db.js"; +import type { AuthedRequest } from "../middleware.js"; +import { requireAuth } from "../middleware.js"; +import { broadcastToRoom } from "../realtime.js"; + +export const messageRouter = Router(); +messageRouter.use(requireAuth); + +function userInRoom(userId: string, roomId: string): boolean { + const r = db + .prepare(`SELECT 1 FROM room_members WHERE user_id = ? AND room_id = ?`) + .get(userId, roomId) as { 1: number } | undefined; + return !!r; +} + +/** Latest message id read by the other member in a 1:1 room (null if not 1:1 or none read). */ +messageRouter.get("/read-state", (req: AuthedRequest, res) => { + const roomId = req.query.roomId as string | undefined; + if (!roomId) { + res.status(400).json({ error: "roomId required" }); + return; + } + if (!userInRoom(req.userId!, roomId)) { + res.status(403).json({ error: "Forbidden" }); + return; + } + const members = db + .prepare(`SELECT user_id FROM room_members WHERE room_id = ?`) + .all(roomId) as { user_id: string }[]; + const others = members.map((m) => m.user_id).filter((id) => id !== req.userId); + if (others.length !== 1) { + res.json({ lastReadMessageId: null }); + return; + } + const other = others[0]; + const row = db + .prepare( + `SELECT m.id FROM messages m + INNER JOIN message_reads mr ON mr.message_id = m.id AND mr.user_id = ? + WHERE m.room_id = ? + ORDER BY m.created_at DESC LIMIT 1` + ) + .get(other, roomId) as { id: string } | undefined; + res.json({ lastReadMessageId: row?.id ?? null }); +}); + +messageRouter.get("/", (req: AuthedRequest, res) => { + const roomId = req.query.roomId as string | undefined; + const limit = Math.min(100, Math.max(1, parseInt(String(req.query.limit ?? "50"), 10))); + const before = req.query.before as string | undefined; + if (!roomId) { + res.status(400).json({ error: "roomId required" }); + return; + } + if (!userInRoom(req.userId!, roomId)) { + res.status(403).json({ error: "Forbidden" }); + return; + } + const rows = before + ? (db + .prepare( + `SELECT id, room_id, sender_id, body, created_at, kind + FROM messages WHERE room_id = ? AND created_at < ? + ORDER BY created_at DESC LIMIT ?` + ) + .all(roomId, before, limit) as Array>) + : (db + .prepare( + `SELECT id, room_id, sender_id, body, created_at, kind + FROM messages WHERE room_id = ? + ORDER BY created_at DESC LIMIT ?` + ) + .all(roomId, limit) as Array>); + const messages = rows.reverse().map((m) => ({ + id: m.id, + roomId: m.room_id, + senderId: m.sender_id, + body: m.body, + createdAt: m.created_at, + kind: m.kind, + })); + res.json({ messages }); +}); + +/** Mark messages as read (extended). */ +messageRouter.post("/read", (req: AuthedRequest, res) => { + const { roomId, upToMessageId } = req.body as { + roomId?: string; + upToMessageId?: string; + }; + if (!roomId || !upToMessageId) { + res.status(400).json({ error: "roomId and upToMessageId required" }); + return; + } + if (!userInRoom(req.userId!, roomId)) { + res.status(403).json({ error: "Forbidden" }); + return; + } + const msgs = db + .prepare( + `SELECT id FROM messages WHERE room_id = ? AND created_at <= + (SELECT created_at FROM messages WHERE id = ? AND room_id = ?)` + ) + .all(roomId, upToMessageId, roomId) as { id: string }[]; + const ins = db.prepare( + `INSERT OR IGNORE INTO message_reads (message_id, user_id) VALUES (?, ?)` + ); + for (const m of msgs) { + ins.run(m.id, req.userId!); + } + broadcastToRoom(roomId, { + type: "read", + roomId, + userId: req.userId!, + upToMessageId, + }); + res.json({ ok: true, count: msgs.length }); +}); + +/** Search within a context (messages in user's rooms). */ +messageRouter.get("/search", (req: AuthedRequest, res) => { + const contextId = req.query.contextId as string | undefined; + const q = (req.query.q as string | undefined)?.trim(); + if (!contextId || !q) { + res.status(400).json({ error: "contextId and q required" }); + return; + } + const member = db + .prepare(`SELECT 1 FROM context_members WHERE user_id = ? AND context_id = ?`) + .get(req.userId!, contextId); + if (!member) { + res.status(403).json({ error: "Forbidden" }); + return; + } + const needle = `%${q.replace(/%/g, "")}%`; + const hits = db + .prepare( + `SELECT m.id, m.room_id, m.body, m.created_at, m.sender_id + FROM messages m + JOIN rooms r ON r.id = m.room_id + JOIN room_members rm ON rm.room_id = m.room_id AND rm.user_id = ? + WHERE r.context_id = ? AND m.body LIKE ? + ORDER BY m.created_at DESC LIMIT 30` + ) + .all(req.userId!, contextId, needle) as Array<{ + id: string; + room_id: string; + body: string; + created_at: string; + sender_id: string; + }>; + res.json({ + results: hits.map((h) => ({ + messageId: h.id, + roomId: h.room_id, + body: h.body, + createdAt: h.created_at, + senderId: h.sender_id, + })), + }); +}); diff --git a/server/src/routes/profileRoutes.ts b/server/src/routes/profileRoutes.ts new file mode 100644 index 0000000..861f943 --- /dev/null +++ b/server/src/routes/profileRoutes.ts @@ -0,0 +1,146 @@ +import { Router } from "express"; +import { db } from "../db.js"; +import type { AuthedRequest } from "../middleware.js"; +import { requireAuth } from "../middleware.js"; +import { isMemberOfContext } from "../contextAccess.js"; + +export const profileRouter = Router(); +profileRouter.use(requireAuth); + +function parseContextId(req: AuthedRequest): string | null { + const q = req.query.contextId as string | undefined; + return q ?? null; +} + +/** Own profile in a context — only if member. */ +profileRouter.get("/me", (req: AuthedRequest, res) => { + const contextId = parseContextId(req); + if (!contextId) { + res.status(400).json({ error: "contextId query required" }); + return; + } + if (!isMemberOfContext(req.userId!, contextId)) { + res.status(403).json({ error: "Forbidden" }); + return; + } + const row = db + .prepare( + `SELECT display_name, avatar_url, status_message, updated_at + FROM profiles WHERE user_id = ? AND context_id = ?` + ) + .get(req.userId!, contextId) as + | { + display_name: string; + avatar_url: string | null; + status_message: string | null; + updated_at: string; + } + | undefined; + if (!row) { + res.status(404).json({ error: "Profile not found" }); + return; + } + res.json({ + userId: req.userId, + contextId, + displayName: row.display_name, + avatarUrl: row.avatar_url, + statusMessage: row.status_message, + updatedAt: row.updated_at, + }); +}); + +profileRouter.patch("/me", (req: AuthedRequest, res) => { + const contextId = parseContextId(req); + if (!contextId) { + res.status(400).json({ error: "contextId query required" }); + return; + } + if (!isMemberOfContext(req.userId!, contextId)) { + res.status(403).json({ error: "Forbidden" }); + return; + } + const { displayName, avatarUrl, statusMessage } = req.body as { + displayName?: string; + avatarUrl?: string | null; + statusMessage?: string | null; + }; + const cur = db + .prepare(`SELECT display_name FROM profiles WHERE user_id = ? AND context_id = ?`) + .get(req.userId!, contextId) as { display_name: string } | undefined; + if (!cur) { + res.status(404).json({ error: "Profile not found" }); + return; + } + const sets: string[] = []; + const vals: unknown[] = []; + if (displayName !== undefined) { + sets.push("display_name = ?"); + vals.push(displayName); + } + if (avatarUrl !== undefined) { + sets.push("avatar_url = ?"); + vals.push(avatarUrl); + } + if (statusMessage !== undefined) { + sets.push("status_message = ?"); + vals.push(statusMessage); + } + if (sets.length === 0) { + res.json({ ok: true }); + return; + } + sets.push("updated_at = datetime('now')"); + vals.push(req.userId!, contextId); + const params = vals as string[]; + db.prepare( + `UPDATE profiles SET ${sets.join(", ")} WHERE user_id = ? AND context_id = ?` + ).run(...params); + res.json({ ok: true }); +}); + +/** + * Other user's profile — only visible when both share the same context. + * No cross-context leakage: contextId is mandatory. + */ +profileRouter.get("/user/:targetUserId", (req: AuthedRequest, res) => { + const contextId = parseContextId(req); + const { targetUserId } = req.params; + if (!contextId) { + res.status(400).json({ error: "contextId query required" }); + return; + } + if (!isMemberOfContext(req.userId!, contextId)) { + res.status(403).json({ error: "Forbidden" }); + return; + } + if (!isMemberOfContext(targetUserId, contextId)) { + res.status(404).json({ error: "Not found" }); + return; + } + const row = db + .prepare( + `SELECT display_name, avatar_url, status_message, updated_at + FROM profiles WHERE user_id = ? AND context_id = ?` + ) + .get(targetUserId, contextId) as + | { + display_name: string; + avatar_url: string | null; + status_message: string | null; + updated_at: string; + } + | undefined; + if (!row) { + res.status(404).json({ error: "Not found" }); + return; + } + res.json({ + userId: targetUserId, + contextId, + displayName: row.display_name, + avatarUrl: row.avatar_url, + statusMessage: row.status_message, + updatedAt: row.updated_at, + }); +}); diff --git a/server/src/routes/pushRoutes.ts b/server/src/routes/pushRoutes.ts new file mode 100644 index 0000000..619726a --- /dev/null +++ b/server/src/routes/pushRoutes.ts @@ -0,0 +1,24 @@ +import { Router } from "express"; +import { db } from "../db.js"; +import type { AuthedRequest } from "../middleware.js"; +import { requireAuth } from "../middleware.js"; + +export const pushRouter = Router(); +pushRouter.use(requireAuth); + +/** Register FCM token for this user (payload routing uses contextId + roomId in app). */ +pushRouter.post("/register", (req: AuthedRequest, res) => { + const { token, platform } = req.body as { token?: string; platform?: string }; + if (!token) { + res.status(400).json({ error: "token required" }); + return; + } + db.prepare( + `INSERT INTO push_tokens (user_id, token, platform, updated_at) + VALUES (?, ?, ?, datetime('now')) + ON CONFLICT(user_id, token) DO UPDATE SET + platform = excluded.platform, + updated_at = datetime('now')` + ).run(req.userId!, token, platform ?? "unknown"); + res.json({ ok: true }); +}); diff --git a/server/src/routes/roomRoutes.ts b/server/src/routes/roomRoutes.ts new file mode 100644 index 0000000..2db5a95 --- /dev/null +++ b/server/src/routes/roomRoutes.ts @@ -0,0 +1,139 @@ +import { Router } from "express"; +import { randomUUID } from "node:crypto"; +import { db } from "../db.js"; +import type { AuthedRequest } from "../middleware.js"; +import { requireAuth } from "../middleware.js"; +import { isMemberOfContext } from "../contextAccess.js"; + +export const roomRouter = Router(); +roomRouter.use(requireAuth); + +function userInRoom(userId: string, roomId: string): boolean { + const r = db + .prepare(`SELECT 1 FROM room_members WHERE user_id = ? AND room_id = ?`) + .get(userId, roomId) as { 1: number } | undefined; + return !!r; +} + +/** List rooms in a context the user belongs to. */ +roomRouter.get("/", (req: AuthedRequest, res) => { + const contextId = req.query.contextId as string | undefined; + if (!contextId) { + res.status(400).json({ error: "contextId required" }); + return; + } + if (!isMemberOfContext(req.userId!, contextId)) { + res.status(403).json({ error: "Forbidden" }); + return; + } + const rooms = db + .prepare( + `SELECT r.id, r.is_group, r.name, r.created_at, + (SELECT body FROM messages m WHERE m.room_id = r.id ORDER BY m.created_at DESC LIMIT 1) AS last_body, + (SELECT created_at FROM messages m WHERE m.room_id = r.id ORDER BY m.created_at DESC LIMIT 1) AS last_at + FROM rooms r + JOIN room_members rm ON rm.room_id = r.id AND rm.user_id = ? + WHERE r.context_id = ? + ORDER BY last_at IS NULL, last_at DESC` + ) + .all(req.userId!, contextId) as Array<{ + id: string; + is_group: number; + name: string | null; + created_at: string; + last_body: string | null; + last_at: string | null; + }>; + res.json({ rooms }); +}); + +/** Open or create a 1:1 room in context. */ +roomRouter.post("/direct", (req: AuthedRequest, res) => { + const { contextId, otherUserId } = req.body as { + contextId?: string; + otherUserId?: string; + }; + if (!contextId || !otherUserId) { + res.status(400).json({ error: "contextId and otherUserId required" }); + return; + } + if (!isMemberOfContext(req.userId!, contextId)) { + res.status(403).json({ error: "Forbidden" }); + return; + } + if (!isMemberOfContext(otherUserId, contextId)) { + res.status(400).json({ error: "Other user is not in this context" }); + return; + } + const u1 = req.userId!; + const u2 = otherUserId; + const pair = [u1, u2].sort(); + const existing = db + .prepare( + `SELECT r.id FROM rooms r + JOIN room_members a ON a.room_id = r.id AND a.user_id = ? + JOIN room_members b ON b.room_id = r.id AND b.user_id = ? + WHERE r.context_id = ? AND r.is_group = 0` + ) + .get(pair[0], pair[1], contextId) as { id: string } | undefined; + if (existing) { + res.json({ roomId: existing.id, created: false }); + return; + } + const roomId = randomUUID(); + db.prepare( + `INSERT INTO rooms (id, context_id, is_group, name) VALUES (?, ?, 0, NULL)` + ).run(roomId, contextId); + db.prepare(`INSERT INTO room_members (room_id, user_id) VALUES (?, ?)`).run(roomId, u1); + db.prepare(`INSERT INTO room_members (room_id, user_id) VALUES (?, ?)`).run(roomId, u2); + res.status(201).json({ roomId, created: true }); +}); + +/** Create group room (extended feature). */ +roomRouter.post("/group", (req: AuthedRequest, res) => { + const { contextId, name, memberIds } = req.body as { + contextId?: string; + name?: string; + memberIds?: string[]; + }; + if (!contextId || !name) { + res.status(400).json({ error: "contextId and name required" }); + return; + } + if (!isMemberOfContext(req.userId!, contextId)) { + res.status(403).json({ error: "Forbidden" }); + return; + } + const roomId = randomUUID(); + db.prepare( + `INSERT INTO rooms (id, context_id, is_group, name) VALUES (?, ?, 1, ?)` + ).run(roomId, contextId, name); + const members = new Set([req.userId!, ...(memberIds ?? [])]); + for (const uid of members) { + if (!isMemberOfContext(uid, contextId)) continue; + db.prepare(`INSERT INTO room_members (room_id, user_id) VALUES (?, ?)`).run( + roomId, + uid + ); + } + res.status(201).json({ roomId }); +}); + +roomRouter.get("/:roomId/participants", (req: AuthedRequest, res) => { + const { roomId } = req.params; + if (!userInRoom(req.userId!, roomId)) { + res.status(403).json({ error: "Forbidden" }); + return; + } + const ctx = db + .prepare(`SELECT context_id FROM rooms WHERE id = ?`) + .get(roomId) as { context_id: string } | undefined; + if (!ctx) { + res.status(404).json({ error: "Not found" }); + return; + } + const userIds = db + .prepare(`SELECT user_id FROM room_members WHERE room_id = ?`) + .all(roomId) as { user_id: string }[]; + res.json({ contextId: ctx.context_id, userIds: userIds.map((u) => u.user_id) }); +}); diff --git a/server/src/seed.ts b/server/src/seed.ts new file mode 100644 index 0000000..488d61c --- /dev/null +++ b/server/src/seed.ts @@ -0,0 +1,230 @@ +import bcrypt from "bcryptjs"; +import { randomUUID } from "node:crypto"; +import { db } from "./db.js"; + +const DEMO_EMAIL_ALICE = "alice@demo.msn"; +const DEMO_EMAIL_BOB = "bob@demo.msn"; +const DEMO_PASSWORD = "demo1234"; + +/** Stable UUIDs for docs and debugging. */ +export const DemoIds = { + alice: "a1111111-1111-4111-8111-111111111111", + bob: "b2222222-2222-4222-8222-222222222222", + ctxAlicePersonal: "c1111111-1111-4111-8111-111111111111", + ctxBobPersonal: "c2222222-2222-4222-8222-222222222222", + ctxWork: "d3333333-3333-4333-8333-333333333333", + roomWorkDm: "e4444444-4444-4444-8444-444444444444", + /** Alice–Bob DM in Alice's personal context */ + roomPersonalDm: "f1111111-1111-4111-8111-111111111111", + /** Group room in work context */ + roomWorkGroup: "g1111111-1111-4111-8111-111111111111", +} as const; + +/** Stable portrait URLs for Flutter NetworkImage (HTTPS, JPG). */ +const DEMO_AVATAR_ALICE_PERSONAL = "https://i.pravatar.cc/400?img=47"; +const DEMO_AVATAR_BOB_PERSONAL = "https://i.pravatar.cc/400?img=33"; +const DEMO_AVATAR_ALICE_WORK = "https://i.pravatar.cc/400?img=12"; +const DEMO_AVATAR_BOB_WORK = "https://i.pravatar.cc/400?img=59"; + +/** + * Demo users, personal + work contexts, profiles, DM + sample messages. + * Skips if alice@demo.msn already exists (idempotent). + */ +export function seedDemoIfNeeded(): void { + const exists = db.prepare(`SELECT id FROM users WHERE email = ?`).get(DEMO_EMAIL_ALICE) as + | { id: string } + | undefined; + if (exists) { + return; + } + + const hash = bcrypt.hashSync(DEMO_PASSWORD, 10); + const { alice, bob, ctxAlicePersonal, ctxBobPersonal, ctxWork, roomWorkDm } = DemoIds; + + db.prepare(`INSERT INTO users (id, email, password_hash) VALUES (?, ?, ?)`).run( + alice, + DEMO_EMAIL_ALICE, + hash + ); + db.prepare(`INSERT INTO users (id, email, password_hash) VALUES (?, ?, ?)`).run( + bob, + DEMO_EMAIL_BOB, + hash + ); + + db.prepare(`INSERT INTO contexts (id, name, kind) VALUES (?, ?, 'personal')`).run( + ctxAlicePersonal, + "일상" + ); + db.prepare(`INSERT INTO contexts (id, name, kind) VALUES (?, ?, 'personal')`).run( + ctxBobPersonal, + "일상" + ); + db.prepare( + `INSERT INTO contexts (id, name, kind, retention_days, screenshot_blocked) VALUES (?, ?, 'work', 365, 0)` + ).run(ctxWork, "데모 회사"); + + db.prepare( + `INSERT INTO context_members (context_id, user_id, role) VALUES (?, ?, 'owner')` + ).run(ctxAlicePersonal, alice); + db.prepare( + `INSERT INTO context_members (context_id, user_id, role) VALUES (?, ?, 'owner')` + ).run(ctxBobPersonal, bob); + db.prepare( + `INSERT INTO context_members (context_id, user_id, role) VALUES (?, ?, 'owner')` + ).run(ctxWork, alice); + db.prepare( + `INSERT INTO context_members (context_id, user_id, role) VALUES (?, ?, 'member')` + ).run(ctxWork, bob); + + db.prepare( + `INSERT INTO profiles (user_id, context_id, display_name, avatar_url, status_message) VALUES (?, ?, ?, ?, ?)` + ).run( + alice, + ctxAlicePersonal, + "앨리스", + DEMO_AVATAR_ALICE_PERSONAL, + "일상 프로필 · 친구들과 수다" + ); + db.prepare( + `INSERT INTO profiles (user_id, context_id, display_name, avatar_url, status_message) VALUES (?, ?, ?, ?, ?)` + ).run(bob, ctxBobPersonal, "밥", DEMO_AVATAR_BOB_PERSONAL, "일상 상태 메시지"); + + db.prepare( + `INSERT INTO profiles (user_id, context_id, display_name, avatar_url, status_message) VALUES (?, ?, ?, ?, ?)` + ).run(alice, ctxWork, "김앨리스 (기획)", DEMO_AVATAR_ALICE_WORK, "회사 맥락 전용 표시명"); + db.prepare( + `INSERT INTO profiles (user_id, context_id, display_name, avatar_url, status_message) VALUES (?, ?, ?, ?, ?)` + ).run(bob, ctxWork, "박밥 (백엔드)", DEMO_AVATAR_BOB_WORK, "동료에게만 보이는 이름"); + + db.prepare( + `INSERT INTO rooms (id, context_id, is_group, name) VALUES (?, ?, 0, NULL)` + ).run(roomWorkDm, ctxWork); + db.prepare(`INSERT INTO room_members (room_id, user_id) VALUES (?, ?)`).run(roomWorkDm, alice); + db.prepare(`INSERT INTO room_members (room_id, user_id) VALUES (?, ?)`).run(roomWorkDm, bob); + + const m1 = randomUUID(); + const m2 = randomUUID(); + const m3 = randomUUID(); + db.prepare( + `INSERT INTO messages (id, room_id, sender_id, body, kind) VALUES (?, ?, ?, ?, 'text')` + ).run(m1, roomWorkDm, bob, "안녕하세요, 회의 자료 공유드립니다."); + db.prepare( + `INSERT INTO messages (id, room_id, sender_id, body, kind) VALUES (?, ?, ?, ?, 'text')` + ).run(m2, roomWorkDm, alice, "확인했습니다. 오후에 뵐게요."); + db.prepare( + `INSERT INTO messages (id, room_id, sender_id, body, kind) VALUES (?, ?, ?, ?, 'text')` + ).run(m3, roomWorkDm, bob, "네, 감사합니다."); + + console.log(""); + console.log("========== DEMO DATA SEEDED =========="); + console.log(` ${DEMO_EMAIL_ALICE} / ${DEMO_PASSWORD} (Alice — switch to \"데모 회사\")`); + console.log(` ${DEMO_EMAIL_BOB} / ${DEMO_PASSWORD} (Bob — second account)`); + console.log("======================================"); + console.log(""); +} + +/** + * Fills demo avatar_url for existing DBs seeded before avatars were added. + * Safe to run on every startup (only updates NULL/empty for known demo rows). + */ +export function backfillDemoAvatarsIfNeeded(): void { + const { alice, bob, ctxAlicePersonal, ctxBobPersonal, ctxWork } = DemoIds; + const rows: Array<[string, string, string]> = [ + [alice, ctxAlicePersonal, DEMO_AVATAR_ALICE_PERSONAL], + [bob, ctxBobPersonal, DEMO_AVATAR_BOB_PERSONAL], + [alice, ctxWork, DEMO_AVATAR_ALICE_WORK], + [bob, ctxWork, DEMO_AVATAR_BOB_WORK], + ]; + const stmt = db.prepare( + `UPDATE profiles SET avatar_url = ? WHERE user_id = ? AND context_id = ? AND (avatar_url IS NULL OR avatar_url = '')` + ); + for (const [uid, cid, url] of rows) { + stmt.run(url, uid, cid); + } +} + +/** + * Extra demo: Bob in Alice's personal context, personal DM, work group room + messages. + * Idempotent — safe on every startup (uses INSERT OR IGNORE / message count checks). + */ +export function extendDemoDataIfNeeded(): void { + const exists = db.prepare(`SELECT id FROM users WHERE email = ?`).get(DEMO_EMAIL_ALICE) as + | { id: string } + | undefined; + if (!exists) { + return; + } + + const { alice, bob, ctxAlicePersonal, ctxWork, roomPersonalDm, roomWorkGroup } = DemoIds; + + db.prepare( + `INSERT OR IGNORE INTO context_members (context_id, user_id, role) VALUES (?, ?, 'member')` + ).run(ctxAlicePersonal, bob); + + db.prepare( + `INSERT OR IGNORE INTO profiles (user_id, context_id, display_name, avatar_url, status_message) VALUES (?, ?, ?, ?, ?)` + ).run( + bob, + ctxAlicePersonal, + "밥", + DEMO_AVATAR_BOB_PERSONAL, + "앨리스 일상에서 보이는 상태" + ); + + db.prepare( + `INSERT OR IGNORE INTO rooms (id, context_id, is_group, name) VALUES (?, ?, 0, NULL)` + ).run(roomPersonalDm, ctxAlicePersonal); + db.prepare(`INSERT OR IGNORE INTO room_members (room_id, user_id) VALUES (?, ?)`).run( + roomPersonalDm, + alice + ); + db.prepare(`INSERT OR IGNORE INTO room_members (room_id, user_id) VALUES (?, ?)`).run( + roomPersonalDm, + bob + ); + + const personalMsgN = db + .prepare(`SELECT COUNT(*) as n FROM messages WHERE room_id = ?`) + .get(roomPersonalDm) as { n: number }; + if (personalMsgN.n === 0) { + const a = randomUUID(); + const b = randomUUID(); + const c = randomUUID(); + db.prepare( + `INSERT INTO messages (id, room_id, sender_id, body, kind) VALUES (?, ?, ?, ?, 'text')` + ).run(a, roomPersonalDm, alice, "주말에 카페 갈래?"); + db.prepare( + `INSERT INTO messages (id, room_id, sender_id, body, kind) VALUES (?, ?, ?, ?, 'text')` + ).run(b, roomPersonalDm, bob, "좋아, 몇 시에 볼까?"); + db.prepare( + `INSERT INTO messages (id, room_id, sender_id, body, kind) VALUES (?, ?, ?, ?, 'text')` + ).run(c, roomPersonalDm, alice, "2시 어때?"); + } + + db.prepare( + `INSERT OR IGNORE INTO rooms (id, context_id, is_group, name) VALUES (?, ?, 1, ?)` + ).run(roomWorkGroup, ctxWork, "프로젝트 A"); + db.prepare(`INSERT OR IGNORE INTO room_members (room_id, user_id) VALUES (?, ?)`).run( + roomWorkGroup, + alice + ); + db.prepare(`INSERT OR IGNORE INTO room_members (room_id, user_id) VALUES (?, ?)`).run( + roomWorkGroup, + bob + ); + + const groupMsgN = db + .prepare(`SELECT COUNT(*) as n FROM messages WHERE room_id = ?`) + .get(roomWorkGroup) as { n: number }; + if (groupMsgN.n === 0) { + const m1 = randomUUID(); + const m2 = randomUUID(); + db.prepare( + `INSERT INTO messages (id, room_id, sender_id, body, kind) VALUES (?, ?, ?, ?, 'text')` + ).run(m1, roomWorkGroup, alice, "[프로젝트 A] 킥오프 슬라이드 올려뒀어요."); + db.prepare( + `INSERT INTO messages (id, room_id, sender_id, body, kind) VALUES (?, ?, ?, ?, 'text')` + ).run(m2, roomWorkGroup, bob, "확인했습니다. 내일 정리해서 공유할게요."); + } +} diff --git a/server/tsconfig.json b/server/tsconfig.json new file mode 100644 index 0000000..830fe6b --- /dev/null +++ b/server/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "outDir": "dist", + "rootDir": "src", + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true + }, + "include": ["src/**/*"] +}