From e09208b5ae74eaa243da1b6691c17da48db670da Mon Sep 17 00:00:00 2001 From: Frank Dai Date: Tue, 22 Oct 2024 20:20:01 -0400 Subject: [PATCH 1/3] Fixed dependency problems on local machine --- game/ios/Runner/AppDelegate.swift | 2 +- game/pubspec.lock | 44 +++++++++++++++---------------- game/pubspec.yaml | 1 + 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/game/ios/Runner/AppDelegate.swift b/game/ios/Runner/AppDelegate.swift index 1d7f1447..1807eea4 100644 --- a/game/ios/Runner/AppDelegate.swift +++ b/game/ios/Runner/AppDelegate.swift @@ -4,7 +4,7 @@ import Firebase import GoogleMaps import flutter_config -@UIApplicationMain +@main @objc class AppDelegate: FlutterAppDelegate { override func application( _ application: UIApplication, diff --git a/game/pubspec.lock b/game/pubspec.lock index be39b8c3..72746128 100644 --- a/game/pubspec.lock +++ b/game/pubspec.lock @@ -553,10 +553,10 @@ packages: dependency: "direct main" description: name: intl - sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf url: "https://pub.dev" source: hosted - version: "0.18.1" + version: "0.19.0" js: dependency: transitive description: @@ -593,26 +593,26 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05" url: "https://pub.dev" source: hosted - version: "10.0.0" + version: "10.0.5" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.5" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" url: "https://pub.dev" source: hosted - version: "2.0.1" + version: "3.0.1" linkify: dependency: transitive description: @@ -681,18 +681,18 @@ packages: dependency: transitive description: name: material_color_utilities - sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec url: "https://pub.dev" source: hosted - version: "0.8.0" + version: "0.11.1" meta: dependency: transitive description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.15.0" mgrs_dart: dependency: transitive description: @@ -1078,10 +1078,10 @@ packages: dependency: transitive description: name: test_api - sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" url: "https://pub.dev" source: hosted - version: "0.6.1" + version: "0.7.2" tuple: dependency: "direct main" description: @@ -1214,18 +1214,18 @@ packages: dependency: "direct main" description: name: velocity_x - sha256: "38585b8ed87c17ccb42a5c13d55bdafdc65e7cd3f41dceb61c38714c758fa228" + sha256: "99b910c80cc2010b184ef921f0af6894a8d632e13169cf77e6f6cb5a7f310698" url: "https://pub.dev" source: hosted - version: "4.1.2" + version: "4.2.1" vm_service: dependency: transitive description: name: vm_service - sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 + sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d" url: "https://pub.dev" source: hosted - version: "13.0.0" + version: "14.2.5" vxstate: dependency: transitive description: @@ -1243,13 +1243,13 @@ packages: source: hosted version: "0.5.1" win32: - dependency: transitive + dependency: "direct main" description: name: win32 - sha256: "0eaf06e3446824099858367950a813472af675116bf63f008a4c2a75ae13e9cb" + sha256: "2294c64768987ea280b43a3d8357d42d5679f3e2b5b69b602be45b2abbd165b0" url: "https://pub.dev" source: hosted - version: "5.5.0" + version: "5.6.1" win32_registry: dependency: transitive description: @@ -1291,5 +1291,5 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.3.0 <4.0.0" + dart: ">=3.5.0 <4.0.0" flutter: ">=3.19.0" diff --git a/game/pubspec.yaml b/game/pubspec.yaml index 8ceac575..b215f36c 100644 --- a/game/pubspec.yaml +++ b/game/pubspec.yaml @@ -59,6 +59,7 @@ dependencies: carousel_slider: ^5.0.0 tuple: ^2.0.2 sticky_headers: ^0.3.0+2 + win32: ^5.6.1 dev_dependencies: flutter_launcher_icons: From 5fc2f8f915cc479531d2770bc06fc291242b16c1 Mon Sep 17 00:00:00 2001 From: Frank Dai Date: Sat, 26 Oct 2024 00:27:47 -0400 Subject: [PATCH 2/3] Implemented rotating marker/cursor feature --- game/ios/Podfile.lock | 6 ++++++ game/lib/gameplay/gameplay_map.dart | 24 ++++++++++++++++++++++-- game/pubspec.lock | 8 ++++++++ game/pubspec.yaml | 1 + 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/game/ios/Podfile.lock b/game/ios/Podfile.lock index 1a312e2f..57961aaa 100644 --- a/game/ios/Podfile.lock +++ b/game/ios/Podfile.lock @@ -48,6 +48,8 @@ PODS: - GoogleUtilities/UserDefaults (~> 7.8) - PromisesObjC (~> 2.1) - Flutter (1.0.0) + - flutter_compass (0.0.1): + - Flutter - flutter_config (0.0.1): - Flutter - flutter_secure_storage (6.0.0): @@ -162,6 +164,7 @@ DEPENDENCIES: - Firebase - Firebase/Analytics - Flutter (from `Flutter`) + - flutter_compass (from `.symlinks/plugins/flutter_compass/ios`) - flutter_config (from `.symlinks/plugins/flutter_config/ios`) - flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`) - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`) @@ -201,6 +204,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/device_info_plus/ios" Flutter: :path: Flutter + flutter_compass: + :path: ".symlinks/plugins/flutter_compass/ios" flutter_config: :path: ".symlinks/plugins/flutter_config/ios" flutter_secure_storage: @@ -236,6 +241,7 @@ SPEC CHECKSUMS: FirebaseCoreInternal: 910a81992c33715fec9263ca7381d59ab3a750b7 FirebaseInstallations: 91950fe859846fff0fbd296180909dd273103b09 Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 + flutter_compass: cbbd285cea1584c7ac9c4e0c3e1f17cbea55e855 flutter_config: f48f0d47a284f1791aacce2687eabb3309ba7a41 flutter_secure_storage: d33dac7ae2ea08509be337e775f6b59f1ff45f12 fluttertoast: e9a18c7be5413da53898f660530c56f35edfba9c diff --git a/game/lib/gameplay/gameplay_map.dart b/game/lib/gameplay/gameplay_map.dart index ca263edc..3e8cc25b 100644 --- a/game/lib/gameplay/gameplay_map.dart +++ b/game/lib/gameplay/gameplay_map.dart @@ -13,6 +13,7 @@ import 'dart:math'; import 'package:game/gameplay/challenge_completed.dart'; import 'package:game/utils/utility_functions.dart'; import 'dart:ui' as ui; +import 'package:flutter_compass/flutter_compass.dart'; // for backend connection import 'package:provider/provider.dart'; @@ -66,6 +67,8 @@ class _GameplayMapState extends State { GeoPoint? hintCenter; double defaultHintRadius = 200.0; double? hintRadius; + double? compassHeading = 0.0; + // Timer? mockHeadingTimer; // mock compass data // whether the picture is expanded over the map bool isExpanded = false; @@ -76,10 +79,28 @@ class _GameplayMapState extends State { super.initState(); streamStarted = startPositionStream(); setStartingHintCircle(); + compassHeading = 0.0; + + // Listen to compass events + FlutterCompass.events!.listen((event) { + setState(() { + compassHeading = event.heading; + }); + }); + + // Mock compass data for testing + // mockHeadingTimer = Timer.periodic(Duration(milliseconds: 100), (timer) { + // setState(() { + // // Increment by 10 degrees + // compassHeading = (compassHeading! + 10) % 360; + // print('Updated compassHeading: $compassHeading'); + // }); + // }); } @override void dispose() { + // mockHeadingTimer?.cancel(); // mock compass data positionStream.cancel(); _disposeController(); super.dispose(); @@ -374,8 +395,7 @@ class _GameplayMapState extends State { ? _center : LatLng(currentLocation!.lat, currentLocation!.long), anchor: Offset(0.5, 0.5), - rotation: - currentLocation == null ? 0 : currentLocation!.heading, + rotation: compassHeading ?? 0, ), }, circles: { diff --git a/game/pubspec.lock b/game/pubspec.lock index 72746128..d1e004f8 100644 --- a/game/pubspec.lock +++ b/game/pubspec.lock @@ -230,6 +230,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.4.1" + flutter_compass: + dependency: "direct main" + description: + name: flutter_compass + sha256: "1a0121bff32df95193812b4e0f69e95f45fdec042ebd7a326ba087c0f6ec8304" + url: "https://pub.dev" + source: hosted + version: "0.7.0" flutter_config: dependency: "direct main" description: diff --git a/game/pubspec.yaml b/game/pubspec.yaml index b215f36c..d2d71243 100644 --- a/game/pubspec.yaml +++ b/game/pubspec.yaml @@ -60,6 +60,7 @@ dependencies: tuple: ^2.0.2 sticky_headers: ^0.3.0+2 win32: ^5.6.1 + flutter_compass: ^0.7.0 dev_dependencies: flutter_launcher_icons: From 444fb359b5bc74085aaa6b9040d35aef82d11958 Mon Sep 17 00:00:00 2001 From: Frank Dai Date: Sat, 26 Oct 2024 20:44:38 -0400 Subject: [PATCH 3/3] Add documentation for server AuthService and related methods --- server/src/auth/auth.service.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/server/src/auth/auth.service.ts b/server/src/auth/auth.service.ts index a3088fe7..4a667b28 100644 --- a/server/src/auth/auth.service.ts +++ b/server/src/auth/auth.service.ts @@ -14,6 +14,12 @@ interface IntermediatePayload { email: string; } +/** + * The `AuthService` class provides authentication-related functionality for the application, + * including login, token management, and user verification. + * + * Now supports Google and Apple (OAuth), and device login. Only Cornell emails are allowed. + */ @Injectable() export class AuthService { constructor( @@ -37,6 +43,13 @@ export class AuthService { secret: process.env.JWT_ACCESS_SECRET, }; + /** + * Verifies an Apple ID token and extracts the user's ID and email. + * + * @param idToken - The ID token from Apple Sign-In. + * @returns An object containing the user’s `id` and `email` if verification is successful; + * otherwise, `null` if verification fails. + */ async payloadFromApple(idToken: string): Promise { try { const payload = await appleSignin.verifyIdToken( @@ -54,6 +67,14 @@ export class AuthService { } } + /** + * Verifies a Google ID token based on the audience (platform) and extracts the user's ID and email. + * + * @param idToken - The ID token received from Google. + * @param aud - The platform that issued the token: 'android', 'ios', or 'web'. + * @returns An object containing the user's `id` and `email` if verification is successful; + * otherwise, `null` if verification fails. + */ async payloadFromGoogle( idToken: string, aud: 'android' | 'ios' | 'web', @@ -89,6 +110,14 @@ export class AuthService { } } + /** + * Authenticates a user based on the user credentials, issues access and refresh tokens. + * + * @param authType - The type of authentication used. + * @param req - The login DTO containing user credentials. + * @returns A tuple `[accessToken, refreshToken]` if login is successful; + * otherwise, `null` if authentication fails. + */ async login( authType: AuthType, req: LoginDto,