π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[auth] Remove hardcoded accounts url
Neeraj Gupta90b45665f5ef
diff --git a/auth/lib/core/constants.dart b/auth/lib/core/constants.dartindex 38066e96ff..b58d7dce61 100644--- a/auth/lib/core/constants.dart+++ b/auth/lib/core/constants.dart@@ -8,6 +8,8 @@ const String sentryDSN =const String sentryTunnel = "https://sentry-reporter.ente.io";const String roadmapURL = "https://roadmap.ente.io";+const String kAccountsUrl = "https://accounts.ente.io";+const String githubFeatureRequestUrl ="https://github.com/ente-io/ente/discussions/categories/feature-requests?discussions_q=is%3Aopen+category%3A%22Feature+requests%22+label%3A%22-+auth%22+sort%3Atop";const int microSecondsInDay = 86400000000;diff --git a/auth/lib/services/passkey_service.dart b/auth/lib/services/passkey_service.dartindex f0bc09893a..dd5a4e5f7a 100644--- a/auth/lib/services/passkey_service.dart+++ b/auth/lib/services/passkey_service.dart@@ -1,6 +1,6 @@+import 'package:ente_auth/core/constants.dart';import 'package:ente_auth/core/network.dart';import 'package:ente_auth/utils/dialog_util.dart';-import 'package:flutter/foundation.dart';import 'package:flutter/widgets.dart';import 'package:logging/logging.dart';import 'package:url_launcher/url_launcher_string.dart';@@ -11,11 +11,13 @@ class PasskeyService {final _enteDio = Network.instance.enteDio;- Future<String> getJwtToken() async {+ Future<String> getAccountsUrl() async {final response = await _enteDio.get("/users/accounts-token",);- return response.data!["accountsToken"] as String;+ final accountsUrl = response.data!["accountsUrl"] ?? kAccountsUrl;+ final jwtToken = response.data!["accountsToken"] as String;+ return "$accountsUrl/passkeys?token=$jwtToken";}Future<bool> isPasskeyRecoveryEnabled() async {@@ -25,10 +27,6 @@ class PasskeyService {return response.data!["isPasskeyRecoveryEnabled"] as bool;}- String get accountsUrl {- return kDebugMode ? "http://localhost:3001" : "https://accounts.ente.io";- }-Future<void> configurePasskeyRecovery(String secret,String userEncryptedSecret,@@ -46,8 +44,7 @@ class PasskeyService {Future<void> openPasskeyPage(BuildContext context) async {try {- final jwtToken = await getJwtToken();- final url = "$accountsUrl/passkeys?token=$jwtToken";+ final url = await getAccountsUrl();await launchUrlString(url,mode: LaunchMode.externalApplication,diff --git a/auth/lib/services/user_service.dart b/auth/lib/services/user_service.dartindex 194b22bf45..7afb7a4c6e 100644--- a/auth/lib/services/user_service.dart+++ b/auth/lib/services/user_service.dart@@ -379,6 +379,7 @@ class UserService {if (response.statusCode == 200) {Widget page;final String passkeySessionID = response.data["passkeySessionID"];+ final String accountsUrl = response.data["accountsUrl"] ?? kAccountsUrl;String twoFASessionID = response.data["twoFactorSessionID"];if (twoFASessionID.isEmpty &&response.data["twoFactorSessionIDV2"] != null) {@@ -388,6 +389,7 @@ class UserService {page = PasskeyPage(passkeySessionID,totp2FASessionID: twoFASessionID,+ accountsUrl: accountsUrl,);} else if (twoFASessionID.isNotEmpty) {page = TwoFactorAuthenticationPage(twoFASessionID);@@ -692,6 +694,7 @@ class UserService {if (response.statusCode == 200) {Widget? page;final String passkeySessionID = response.data["passkeySessionID"];+ final String accountsUrl = response.data["accountsUrl"] ?? kAccountsUrl;String twoFASessionID = response.data["twoFactorSessionID"];if (twoFASessionID.isEmpty &&response.data["twoFactorSessionIDV2"] != null) {@@ -702,6 +705,7 @@ class UserService {page = PasskeyPage(passkeySessionID,totp2FASessionID: twoFASessionID,+ accountsUrl: accountsUrl,);} else if (twoFASessionID.isNotEmpty) {page = TwoFactorAuthenticationPage(twoFASessionID);diff --git a/auth/lib/ui/passkey_page.dart b/auth/lib/ui/passkey_page.dartindex d2c043b3ed..906d2122df 100644--- a/auth/lib/ui/passkey_page.dart+++ b/auth/lib/ui/passkey_page.dart@@ -5,7 +5,6 @@ import 'package:ente_auth/core/configuration.dart';import 'package:ente_auth/core/errors.dart';import 'package:ente_auth/l10n/l10n.dart';import 'package:ente_auth/models/account/two_factor.dart';-import 'package:ente_auth/services/passkey_service.dart';import 'package:ente_auth/services/user_service.dart';import 'package:ente_auth/ui/components/buttons/button_widget.dart';import 'package:ente_auth/ui/components/models/button_type.dart';@@ -20,10 +19,12 @@ import 'package:url_launcher/url_launcher_string.dart';class PasskeyPage extends StatefulWidget {final String sessionID;final String totp2FASessionID;+ final String accountsUrl;const PasskeyPage(this.sessionID, {required this.totp2FASessionID,+ required this.accountsUrl,super.key,});@@ -47,9 +48,8 @@ class _PasskeyPageState extends State<PasskeyPage> {}Future<void> launchPasskey() async {- final String accountsUrl = PasskeyService.instance.accountsUrl;await launchUrlString(- "$accountsUrl/passkeys/verify?"+ "${widget.accountsUrl}/passkeys/verify?""passkeySessionID=${widget.sessionID}""&redirect=enteauth://passkey""&clientPackage=io.ente.auth",diff --git a/auth/macos/Podfile.lock b/auth/macos/Podfile.lockindex 544a8edbec..1a585de2d0 100644--- a/auth/macos/Podfile.lock+++ b/auth/macos/Podfile.lock@@ -174,4 +174,4 @@ SPEC CHECKSUMS:PODFILE CHECKSUM: f401c31c8f7c5571f6f565c78915d54338812dab-COCOAPODS: 1.15.2+COCOAPODS: 1.16.2