π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob] Remove hardcoded url for accounts/passkey
Neeraj Guptaaaa636345c60
diff --git a/mobile/lib/core/constants.dart b/mobile/lib/core/constants.dartindex 9f9a6ac15c..f55c3344ed 100644--- a/mobile/lib/core/constants.dart+++ b/mobile/lib/core/constants.dart@@ -45,6 +45,9 @@ const supportEmail = '[email protected]';const multipartPartSize = 20 * 1024 * 1024;const kDefaultProductionEndpoint = 'https://api.ente.io';+const kAccountsUrl = 'https://accounts.ente.io';+const kCasUrl = 'https://cas.ente.io';+const kFamilyUrl = 'https://family.ente.io';const int intMaxValue = 9223372036854775807;diff --git a/mobile/lib/services/passkey_service.dart b/mobile/lib/services/passkey_service.dartindex ed94af884a..0faa7b5416 100644--- a/mobile/lib/services/passkey_service.dart+++ b/mobile/lib/services/passkey_service.dart@@ -1,6 +1,6 @@import "package:flutter/cupertino.dart";-import "package:flutter/foundation.dart";import "package:logging/logging.dart";+import "package:photos/core/constants.dart";import "package:photos/core/network/network.dart";import "package:photos/utils/dialog_util.dart";import 'package:url_launcher/url_launcher_string.dart';@@ -11,11 +11,13 @@ class PasskeyService {final _enteDio = NetworkClient.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 {@@ -46,8 +48,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/mobile/lib/services/user_service.dart b/mobile/lib/services/user_service.dartindex 2b50748e96..3ec22674a4 100644--- a/mobile/lib/services/user_service.dart+++ b/mobile/lib/services/user_service.dart@@ -399,6 +399,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) {@@ -408,6 +409,7 @@ class UserService {page = PasskeyPage(passkeySessionID,totp2FASessionID: twoFASessionID,+ accountsUrl: accountsUrl,);} else if (twoFASessionID.isNotEmpty) {await setTwoFactor(value: true);@@ -725,10 +727,15 @@ class UserService {twoFASessionID = response.data["twoFactorSessionIDV2"];}final String passkeySessionID = response.data["passkeySessionID"];+ final String accountsUrl = response.data["accountsUrl"] ?? kAccountsUrl;Configuration.instance.setVolatilePassword(userPassword);if (passkeySessionID.isNotEmpty) {- page = PasskeyPage(passkeySessionID, totp2FASessionID: twoFASessionID);+ page = PasskeyPage(+ passkeySessionID,+ totp2FASessionID: twoFASessionID,+ accountsUrl: accountsUrl,+ );} else if (twoFASessionID.isNotEmpty) {await setTwoFactor(value: true);page = TwoFactorAuthenticationPage(twoFASessionID);diff --git a/mobile/lib/ui/account/passkey_page.dart b/mobile/lib/ui/account/passkey_page.dartindex 3d8d088bea..11ca53adea 100644--- a/mobile/lib/ui/account/passkey_page.dart+++ b/mobile/lib/ui/account/passkey_page.dart@@ -1,7 +1,6 @@import "dart:async";import 'dart:convert';-import "package:flutter/foundation.dart";import 'package:flutter/material.dart';import 'package:logging/logging.dart';import 'package:photos/core/configuration.dart';@@ -9,7 +8,6 @@ import "package:photos/core/errors.dart";import "package:photos/generated/l10n.dart";import "package:photos/l10n/l10n.dart";import "package:photos/models/account/two_factor.dart";-import "package:photos/services/passkey_service.dart";import 'package:photos/services/user_service.dart';import "package:photos/ui/account/two_factor_authentication_page.dart";import "package:photos/ui/components/buttons/button_widget.dart";@@ -23,10 +21,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,});@@ -52,9 +52,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=ente://passkey""&clientPackage=io.ente.photos",