Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Setup common accounts package

vishnukvmd21b3bdf20417
diff --git a/mobile/packages/accounts/analysis_options.yaml b/mobile/packages/accounts/analysis_options.yaml
new file mode 100644
index 0000000000..f9b303465f
--- /dev/null
+++ b/mobile/packages/accounts/analysis_options.yaml
@@ -0,0 +1 @@
+include: package:flutter_lints/flutter.yaml
diff --git a/mobile/packages/accounts/lib/ente_accounts.dart b/mobile/packages/accounts/lib/ente_accounts.dart
new file mode 100644
index 0000000000..e7865b2f1b
--- /dev/null
+++ b/mobile/packages/accounts/lib/ente_accounts.dart
@@ -0,0 +1,33 @@
+/// A Flutter package containing account-related functionality for Ente apps
+library ente_accounts;
+
+// Models
+export 'models/user_details.dart';
+export 'models/sessions.dart';
+export 'models/two_factor.dart';
+export 'models/srp.dart';
+export 'models/delete_account.dart';
+export 'models/set_keys_request.dart';
+export 'models/set_recovery_key_request.dart';
+export 'models/bonus.dart';
+export 'models/subscription.dart';
+
+// Services
+export 'services/user_service.dart';
+
+// Pages
+export 'pages/change_email_dialog.dart';
+export 'pages/delete_account_page.dart';
+export 'pages/email_entry_page.dart';
+export 'pages/login_page.dart';
+export 'pages/login_pwd_verification_page.dart';
+export 'pages/ott_verification_page.dart';
+export 'pages/passkey_page.dart';
+export 'pages/password_entry_page.dart';
+export 'pages/password_reentry_page.dart';
+export 'pages/recovery_key_page.dart';
+export 'pages/recovery_page.dart';
+export 'pages/request_pwd_verification_page.dart';
+export 'pages/sessions_page.dart';
+export 'pages/two_factor_authentication_page.dart';
+export 'pages/two_factor_recovery_page.dart';
diff --git a/mobile/packages/accounts/lib/models/bonus.dart b/mobile/packages/accounts/lib/models/bonus.dart
new file mode 100644
index 0000000000..a41ea62499
--- /dev/null
+++ b/mobile/packages/accounts/lib/models/bonus.dart
@@ -0,0 +1,60 @@
+class Bonus {
+ int storage;
+ String type;
+ int validTill;
+ bool isRevoked;
+
+ Bonus(this.storage, this.type, this.validTill, this.isRevoked);
+
+ factory Bonus.fromJson(Map<String, dynamic> json) {
+ return Bonus(
+ json['storage'],
+ json['type'],
+ json['validTill'],
+ json['isRevoked'],
+ );
+ }
+
+ Map<String, dynamic> toJson() {
+ return {
+ 'storage': storage,
+ 'type': type,
+ 'validTill': validTill,
+ 'isRevoked': isRevoked,
+ };
+ }
+}
+
+class BonusData {
+ static Set<String> signUpBonusTypes = {'SIGN_UP', 'REFERRAL'};
+ final List<Bonus> storageBonuses;
+
+ BonusData(this.storageBonuses);
+
+ List<Bonus> getAddOnBonuses() {
+ return storageBonuses
+ .where((b) => !signUpBonusTypes.contains(b.type))
+ .toList();
+ }
+
+ int totalAddOnBonus() {
+ return getAddOnBonuses().fold(0, (sum, bonus) => sum + bonus.storage);
+ }
+
+ factory BonusData.fromJson(Map<String, dynamic>? json) {
+ if (json == null || json['storageBonuses'] == null) {
+ return BonusData([]);
+ }
+ return BonusData(
+ (json['storageBonuses'] as List)
+ .map((bonus) => Bonus.fromJson(bonus))
+ .toList(),
+ );
+ }
+
+ Map<String, dynamic> toJson() {
+ return {
+ 'storageBonuses': storageBonuses.map((bonus) => bonus.toJson()).toList(),
+ };
+ }
+}
diff --git a/mobile/packages/accounts/lib/models/delete_account.dart b/mobile/packages/accounts/lib/models/delete_account.dart
new file mode 100644
index 0000000000..71ca04e9c3
--- /dev/null
+++ b/mobile/packages/accounts/lib/models/delete_account.dart
@@ -0,0 +1,9 @@
+class DeleteChallengeResponse {
+ final bool allowDelete;
+ final String encryptedChallenge;
+
+ DeleteChallengeResponse({
+ required this.allowDelete,
+ required this.encryptedChallenge,
+ });
+}
diff --git a/mobile/packages/accounts/lib/models/errors.dart b/mobile/packages/accounts/lib/models/errors.dart
new file mode 100644
index 0000000000..dab8c14e1e
--- /dev/null
+++ b/mobile/packages/accounts/lib/models/errors.dart
@@ -0,0 +1,7 @@
+class UnauthorizedError extends Error {}
+
+class PassKeySessionNotVerifiedError extends Error {}
+
+class PassKeySessionExpiredError extends Error {}
+
+class SrpSetupNotCompleteError extends Error {}
diff --git a/mobile/packages/accounts/lib/models/sessions.dart b/mobile/packages/accounts/lib/models/sessions.dart
new file mode 100644
index 0000000000..56ba8a31a1
--- /dev/null
+++ b/mobile/packages/accounts/lib/models/sessions.dart
@@ -0,0 +1,45 @@
+class Sessions {
+ final List<Session> sessions;
+
+ Sessions(
+ this.sessions,
+ );
+
+ factory Sessions.fromMap(Map<String, dynamic> map) {
+ if (map["sessions"] == null) {
+ throw Exception('\'map["sessions"]\' must not be null');
+ }
+ return Sessions(
+ List<Session>.from(map['sessions']?.map((x) => Session.fromMap(x))),
+ );
+ }
+}
+
+class Session {
+ final String token;
+ final int creationTime;
+ final String ip;
+ final String ua;
+ final String prettyUA;
+ final int lastUsedTime;
+
+ Session(
+ this.token,
+ this.creationTime,
+ this.ip,
+ this.ua,
+ this.prettyUA,
+ this.lastUsedTime,
+ );
+
+ factory Session.fromMap(Map<String, dynamic> map) {
+ return Session(
+ map['token'],
+ map['creationTime'],
+ map['ip'],
+ map['ua'],
+ map['prettyUA'],
+ map['lastUsedTime'],
+ );
+ }
+}
diff --git a/mobile/packages/accounts/lib/models/set_keys_request.dart b/mobile/packages/accounts/lib/models/set_keys_request.dart
new file mode 100644
index 0000000000..e782319f50
--- /dev/null
+++ b/mobile/packages/accounts/lib/models/set_keys_request.dart
@@ -0,0 +1,25 @@
+class SetKeysRequest {
+ final String kekSalt;
+ final String encryptedKey;
+ final String keyDecryptionNonce;
+ final int memLimit;
+ final int opsLimit;
+
+ SetKeysRequest({
+ required this.kekSalt,
+ required this.encryptedKey,
+ required this.keyDecryptionNonce,
+ required this.memLimit,
+ required this.opsLimit,
+ });
+
+ Map<String, dynamic> toMap() {
+ return {
+ 'kekSalt': kekSalt,
+ 'encryptedKey': encryptedKey,
+ 'keyDecryptionNonce': keyDecryptionNonce,
+ 'memLimit': memLimit,
+ 'opsLimit': opsLimit,
+ };
+ }
+}
diff --git a/mobile/packages/accounts/lib/models/set_recovery_key_request.dart b/mobile/packages/accounts/lib/models/set_recovery_key_request.dart
new file mode 100644
index 0000000000..1a03e4e36c
--- /dev/null
+++ b/mobile/packages/accounts/lib/models/set_recovery_key_request.dart
@@ -0,0 +1,22 @@
+class SetRecoveryKeyRequest {
+ final String masterKeyEncryptedWithRecoveryKey;
+ final String masterKeyDecryptionNonce;
+ final String recoveryKeyEncryptedWithMasterKey;
+ final String recoveryKeyDecryptionNonce;
+
+ SetRecoveryKeyRequest(
+ this.masterKeyEncryptedWithRecoveryKey,
+ this.masterKeyDecryptionNonce,
+ this.recoveryKeyEncryptedWithMasterKey,
+ this.recoveryKeyDecryptionNonce,
+ );
+
+ Map<String, dynamic> toMap() {
+ return {
+ 'masterKeyEncryptedWithRecoveryKey': masterKeyEncryptedWithRecoveryKey,
+ 'masterKeyDecryptionNonce': masterKeyDecryptionNonce,
+ 'recoveryKeyEncryptedWithMasterKey': recoveryKeyEncryptedWithMasterKey,
+ 'recoveryKeyDecryptionNonce': recoveryKeyDecryptionNonce,
+ };
+ }
+}
diff --git a/mobile/packages/accounts/lib/models/srp.dart b/mobile/packages/accounts/lib/models/srp.dart
new file mode 100644
index 0000000000..56b19c1317
--- /dev/null
+++ b/mobile/packages/accounts/lib/models/srp.dart
@@ -0,0 +1,136 @@
+class SetupSRPRequest {
+ final String srpUserID;
+ final String srpSalt;
+ final String srpVerifier;
+ final String srpA;
+ final bool isUpdate;
+
+ SetupSRPRequest({
+ required this.srpUserID,
+ required this.srpSalt,
+ required this.srpVerifier,
+ required this.srpA,
+ required this.isUpdate,
+ });
+
+ Map<String, dynamic> toMap() {
+ return {
+ 'srpUserID': srpUserID.toString(),
+ 'srpSalt': srpSalt,
+ 'srpVerifier': srpVerifier,
+ 'srpA': srpA,
+ 'isUpdate': isUpdate,
+ };
+ }
+
+ factory SetupSRPRequest.fromJson(Map<String, dynamic> json) {
+ return SetupSRPRequest(
+ srpUserID: json['srpUserID'],
+ srpSalt: json['srpSalt'],
+ srpVerifier: json['srpVerifier'],
+ srpA: json['srpA'],
+ isUpdate: json['isUpdate'],
+ );
+ }
+}
+
+class SetupSRPResponse {
+ final String setupID;
+ final String srpB;
+
+ SetupSRPResponse({
+ required this.setupID,
+ required this.srpB,
+ });
+
+ Map<String, dynamic> toMap() {
+ return {
+ 'setupID': setupID.toString(),
+ 'srpB': srpB,
+ };
+ }
+
+ factory SetupSRPResponse.fromJson(Map<String, dynamic> json) {
+ return SetupSRPResponse(
+ setupID: json['setupID'],
+ srpB: json['srpB'],
+ );
+ }
+}
+
+class CompleteSRPSetupRequest {
+ final String setupID;
+ final String srpM1;
+
+ CompleteSRPSetupRequest({
+ required this.setupID,
+ required this.srpM1,
+ });
+
+ Map<String, dynamic> toMap() {
+ return {
+ 'setupID': setupID.toString(),
+ 'srpM1': srpM1,
+ };
+ }
+
+ factory CompleteSRPSetupRequest.fromJson(Map<String, dynamic> json) {
+ return CompleteSRPSetupRequest(
+ setupID: json['setupID'],
+ srpM1: json['srpM1'],
+ );
+ }
+}
+
+class SrpAttributes {
+ final String srpUserID;
+ final String srpSalt;
+ final int memLimit;
+ final int opsLimit;
+ final String kekSalt;
+ final bool isEmailMFAEnabled;
+
+ SrpAttributes({
+ required this.srpUserID,
+ required this.srpSalt,
+ required this.memLimit,
+ required this.opsLimit,
+ required this.kekSalt,
+ required this.isEmailMFAEnabled,
+ });
+
+ factory SrpAttributes.fromMap(Map<String, dynamic> map) {
+ return SrpAttributes(
+ srpUserID: map['attributes']['srpUserID'],
+ srpSalt: map['attributes']['srpSalt'],
+ memLimit: map['attributes']['memLimit'],
+ opsLimit: map['attributes']['opsLimit'],
+ kekSalt: map['attributes']['kekSalt'],
+ isEmailMFAEnabled: map['attributes']['isEmailMFAEnabled'],
+ );
+ }
+}
+
+class CompleteSRPSetupResponse {
+ final String setupID;
+ final String srpM2;
+
+ CompleteSRPSetupResponse({
+ required this.setupID,
+ required this.srpM2,
+ });
+
+ Map<String, dynamic> toMap() {
+ return {
+ 'setupID': setupID,
+ 'srpM2': srpM2,
+ };
+ }
+
+ factory CompleteSRPSetupResponse.fromJson(Map<String, dynamic> json) {
+ return CompleteSRPSetupResponse(
+ setupID: json['setupID'],
+ srpM2: json['srpM2'],
+ );
+ }
+}
diff --git a/mobile/packages/accounts/lib/models/subscription.dart b/mobile/packages/accounts/lib/models/subscription.dart
new file mode 100644
index 0000000000..50735a7c48
--- /dev/null
+++ b/mobile/packages/accounts/lib/models/subscription.dart
@@ -0,0 +1,117 @@
+import 'dart:convert';
+
+const freeProductID = "free";
+const popularProductIDs = ["200gb_yearly", "200gb_monthly"];
+const stripe = "stripe";
+const appStore = "appstore";
+const playStore = "playstore";
+
+class Subscription {
+ final String productID;
+ final int storage;
+ final String originalTransactionID;
+ final String paymentProvider;
+ final int expiryTime;
+ final String price;
+ final String period;
+ final Attributes? attributes;
+
+ Subscription({
+ required this.productID,
+ required this.storage,
+ required this.originalTransactionID,
+ required this.paymentProvider,
+ required this.expiryTime,
+ required this.price,
+ required this.period,
+ this.attributes,
+ });
+
+ bool isValid() {
+ return expiryTime > DateTime.now().microsecondsSinceEpoch;
+ }
+
+ bool isCancelled() {
+ return attributes?.isCancelled ?? false;
+ }
+
+ bool isPastDue() {
+ return !isCancelled() &&
+ expiryTime < DateTime.now().microsecondsSinceEpoch &&
+ expiryTime >=
+ DateTime.now()
+ .subtract(const Duration(days: 30))
+ .microsecondsSinceEpoch;
+ }
+
+ bool isYearlyPlan() {
+ return 'year' == period;
+ }
+
+ bool isFreePlan() {
+ return productID == freeProductID;
+ }
+
+ static fromMap(Map<String, dynamic>? map) {
+ if (map == null) return null;
+ return Subscription(
+ productID: map['productID'],
+ storage: map['storage'],
+ originalTransactionID: map['originalTransactionID'],
+ paymentProvider: map['paymentProvider'],
+ expiryTime: map['expiryTime'],
+ price: map['price'],
+ period: map['period'],
+ attributes: map["attributes"] != null
+ ? Attributes.fromMap(map["attributes"])
+ : null,
+ );
+ }
+
+ Map<String, dynamic> toMap() {
+ return {
+ 'productID': productID,
+ 'storage': storage,
+ 'originalTransactionID': originalTransactionID,
+ 'paymentProvider': paymentProvider,
+ 'expiryTime': expiryTime,
+ 'price': price,
+ 'period': period,
+ 'attributes': attributes?.toMap(),
+ };
+ }
+
+ String toJson() => json.encode(toMap());
+
+ factory Subscription.fromJson(String source) =>
+ Subscription.fromMap(json.decode(source));
+}
+
+class Attributes {
+ bool? isCancelled;
+ String? customerID;
+
+ Attributes({
+ this.isCancelled,
+ this.customerID,
+ });
+
+ Map<String, dynamic> toMap() {
+ return {
+ 'isCancelled': isCancelled,
+ 'customerID': customerID,
+ };
+ }
+
+ factory Attributes.fromMap(Map<String, dynamic> map) {
+ return Attributes(
+ isCancelled: map['isCancelled'],
+ customerID: map['customerID'],
+ );
+ }
+
+ String toJson() => json.encode(toMap());
+
+ factory Attributes.fromJson(String source) =>
+ Attributes.fromMap(json.decode(source));
+}
diff --git a/mobile/packages/accounts/lib/models/two_factor.dart b/mobile/packages/accounts/lib/models/two_factor.dart
new file mode 100644
index 0000000000..45f7c8fde8
--- /dev/null
+++ b/mobile/packages/accounts/lib/models/two_factor.dart
@@ -0,0 +1,11 @@
+enum TwoFactorType { totp, passkey }
+
+// ToString for TwoFactorType
+String twoFactorTypeToString(TwoFactorType type) {
+ switch (type) {
+ case TwoFactorType.totp:
+ return "totp";
+ case TwoFactorType.passkey:
+ return "passkey";
+ }
+}
diff --git a/mobile/packages/accounts/lib/models/user_details.dart b/mobile/packages/accounts/lib/models/user_details.dart
new file mode 100644
index 0000000000..bae0311a7f
--- /dev/null
+++ b/mobile/packages/accounts/lib/models/user_details.dart
@@ -0,0 +1,249 @@
+import 'dart:convert';
+import 'dart:math';
+
+import 'bonus.dart';
+import 'subscription.dart';
+
+class UserDetails {
+ final String email;
+ final int usage;
+ final int fileCount;
+ final int storageBonus;
+ final int sharedCollectionsCount;
+ final Subscription subscription;
+ final FamilyData? familyData;
+ final ProfileData? profileData;
+ final BonusData? bonusData;
+
+ const UserDetails(
+ this.email,
+ this.usage,
+ this.fileCount,
+ this.storageBonus,
+ this.sharedCollectionsCount,
+ this.subscription,
+ this.familyData,
+ this.profileData,
+ this.bonusData,
+ );
+
+ bool isPartOfFamily() {
+ return familyData?.members?.isNotEmpty ?? false;
+ }
+
+ bool hasPaidAddon() {
+ return bonusData?.getAddOnBonuses().isNotEmpty ?? false;
+ }
+
+ bool isFamilyAdmin() {
+ assert(isPartOfFamily(), "verify user is part of family before calling");
+ final FamilyMember currentUserMember = familyData!.members!
+ .firstWhere((element) => element.email.trim() == email.trim());
+ return currentUserMember.isAdmin;
+ }
+
+ // getFamilyOrPersonalUsage will return total usage for family if user
+ // belong to family group. Otherwise, it will return storage consumed by
+ // current user
+ int getFamilyOrPersonalUsage() {
+ return isPartOfFamily() ? familyData!.getTotalUsage() : usage;
+ }
+
+ int getFreeStorage() {
+ final int? memberLimit = familyMemberStorageLimit();
+ if (memberLimit != null) {
+ return max(memberLimit - usage, 0);
+ }
+ return max(getTotalStorage() - getFamilyOrPersonalUsage(), 0);
+ }
+
+ // getTotalStorage will return total storage available including the
+ // storage bonus
+ int getTotalStorage() {
+ return (isPartOfFamily() ? familyData!.storage : subscription.storage) +
+ storageBonus;
+ }
+
+ // return the member storage limit if user is part of family and the admin
+ // has set the storage limit for the user.
+ int? familyMemberStorageLimit() {
+ if (isPartOfFamily()) {
+ try {
+ final FamilyMember currentUserMember = familyData!.members!
+ .firstWhere((element) => element.email.trim() == email.trim());
+ return currentUserMember.storageLimit;
+ } catch (e) {
+ return null;
+ }
+ }
+ return null;
+ }
+
+ // This is the total storage for which user has paid for.
+ int getPlanPlusAddonStorage() {
+ return (isPartOfFamily() ? familyData!.storage : subscription.storage) +
+ bonusData!.totalAddOnBonus();
+ }
+
+ factory UserDetails.fromMap(Map<String, dynamic> map) {
+ return UserDetails(
+ map['email'] as String,
+ map['usage'] as int,
+ (map['fileCount'] ?? 0) as int,
+ (map['storageBonus'] ?? 0) as int,
+ (map['sharedCollectionsCount'] ?? 0) as int,
+ Subscription.fromMap(map['subscription']),
+ FamilyData.fromMap(map['familyData']),
+ ProfileData.fromJson(map['profileData']),
+ BonusData.fromJson(map['bonusData']),
+ );
+ }
+
+ Map<String, dynamic> toMap() {
+ return {
+ 'email': email,
+ 'usage': usage,
+ 'fileCount': fileCount,
+ 'storageBonus': storageBonus,
+ 'sharedCollectionsCount': sharedCollectionsCount,
+ 'subscription': subscription.toMap(),
+ 'familyData': familyData?.toMap(),
+ 'profileData': profileData?.toJson(),
+ 'bonusData': bonusData?.toJson(),
+ };
+ }
+
+ String toJson() => json.encode(toMap());
+
+ factory UserDetails.fromJson(String source) =>
+ UserDetails.fromMap(json.decode(source));
+}
+
+class FamilyMember {
+ final String email;
+ final int usage;
+ final String id;
+ final bool isAdmin;
+ final int? storageLimit;
+
+ FamilyMember(
+ this.email,
+ this.usage,
+ this.id,
+ this.isAdmin,
+ this.storageLimit,
+ );
+
+ factory FamilyMember.fromMap(Map<String, dynamic> map) {
+ return FamilyMember(
+ (map['email'] ?? '') as String,
+ map['usage'] as int,
+ map['id'] as String,
+ map['isAdmin'] as bool,
+ map['storageLimit'] as int?,
+ );
+ }
+
+ Map<String, dynamic> toMap() {
+ return {
+ 'email': email,
+ 'usage': usage,
+ 'id': id,
+ 'isAdmin': isAdmin,
+ 'storageLimit': storageLimit,
+ };
+ }
+
+ String toJson() => json.encode(toMap());
+
+ factory FamilyMember.fromJson(String source) =>
+ FamilyMember.fromMap(json.decode(source));
+}
+
+class ProfileData {
+ bool canDisableEmailMFA;
+ bool isEmailMFAEnabled;
+ bool isTwoFactorEnabled;
+
+ // Constructor with default values
+ ProfileData({
+ this.canDisableEmailMFA = false,
+ this.isEmailMFAEnabled = false,
+ this.isTwoFactorEnabled = false,
+ });
+
+ // Factory method to create ProfileData instance from JSON
+ factory ProfileData.fromJson(Map<String, dynamic>? json) {
+ return ProfileData(
+ canDisableEmailMFA: json?['canDisableEmailMFA'] ?? false,
+ isEmailMFAEnabled: json?['isEmailMFAEnabled'] ?? false,
+ isTwoFactorEnabled: json?['isTwoFactorEnabled'] ?? false,
+ );
+ }
+
+ // Method to convert ProfileData instance to JSON
+ Map<String, dynamic> toJson() {
+ return {
+ 'canDisableEmailMFA': canDisableEmailMFA,
+ 'isEmailMFAEnabled': isEmailMFAEnabled,
+ 'isTwoFactorEnabled': isTwoFactorEnabled,
+ };
+ }
+
+ String toJsonString() => json.encode(toJson());
+}
+
+class FamilyData {
+ final List<FamilyMember>? members;
+
+ // Storage available based on the family plan
+ final int storage;
+ final int expiryTime;
+
+ FamilyData(
+ this.members,
+ this.storage,
+ this.expiryTime,
+ );
+
+ int getTotalUsage() {
+ return members!
+ .map((e) => e.usage)
+ .toList()
+ .fold(0, (sum, usage) => sum + usage);
+ }
+
+ FamilyMember? getMemberByID(String id) {
+ try {
+ return members!.firstWhere((element) => element.id == id);
+ } catch (e) {
+ return null;
+ }
+ }
+
+ static fromMap(Map<String, dynamic>? map) {
+ if (map == null) return null;
+ assert(map['members'] != null && map['members'].length >= 0);
+ final members = List<FamilyMember>.from(
+ map['members'].map((x) => FamilyMember.fromMap(x)),
+ );
+ return FamilyData(
+ members,
+ map['storage'] as int,
+ map['expiryTime'] as int,
+ );
+ }
+
+ Map<String, dynamic> toMap() {
+ return {
+ 'members': members?.map((x) => x.toMap()).toList(),
+ 'storage': storage,
+ 'expiryTime': expiryTime,
+ };
+ }
+
+ String toJson() => json.encode(toMap());
+
+ factory FamilyData.fromJson(String source) =>
+ FamilyData.fromMap(json.decode(source));
+}
diff --git a/mobile/packages/accounts/lib/pages/change_email_dialog.dart b/mobile/packages/accounts/lib/pages/change_email_dialog.dart
new file mode 100644
index 0000000000..0cc49f25bc
--- /dev/null
+++ b/mobile/packages/accounts/lib/pages/change_email_dialog.dart
@@ -0,0 +1,81 @@
+import 'package:ente_accounts/ente_accounts.dart';
+import 'package:ente_ui/utils/dialog_util.dart';
+import 'package:ente_utils/email_util.dart';
+import 'package:ente_strings/ente_strings.dart';
+import 'package:flutter/material.dart';
+
+class ChangeEmailDialog extends StatefulWidget {
+ const ChangeEmailDialog({super.key});
+
+ @override
+ State<ChangeEmailDialog> createState() => _ChangeEmailDialogState();
+}
+
+class _ChangeEmailDialogState extends State<ChangeEmailDialog> {
+ String _email = "";
+
+ @override
+ Widget build(BuildContext context) {
+ return AlertDialog(
+ title: Text(context.strings.enterNewEmailHint),
+ content: SingleChildScrollView(
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.start,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ TextFormField(
+ decoration: InputDecoration(
+ hintText: context.strings.email,
+ hintStyle: const TextStyle(
+ color: Colors.white30,
+ ),
+ contentPadding: const EdgeInsets.all(12),
+ ),
+ onChanged: (value) {
+ setState(() {
+ _email = value;
+ });
+ },
+ autocorrect: false,
+ keyboardType: TextInputType.emailAddress,
+ initialValue: _email,
+ autofocus: true,
+ ),
+ ],
+ ),
+ ),
+ actions: [
+ TextButton(
+ child: Text(
+ context.strings.cancel,
+ style: const TextStyle(
+ color: Colors.redAccent,
+ ),
+ ),
+ onPressed: () {
+ Navigator.pop(context);
+ },
+ ),
+ TextButton(
+ child: Text(
+ context.strings.verify,
+ style: const TextStyle(
+ color: Colors.purple,
+ ),
+ ),
+ onPressed: () {
+ if (!isValidEmail(_email)) {
+ showErrorDialog(
+ context,
+ context.strings.invalidEmailTitle,
+ context.strings.invalidEmailMessage,
+ );
+ return;
+ }
+ UserService.instance.sendOtt(context, _email, isChangeEmail: true);
+ },
+ ),
+ ],
+ );
+ }
+}
diff --git a/mobile/packages/accounts/lib/pages/delete_account_page.dart b/mobile/packages/accounts/lib/pages/delete_account_page.dart
new file mode 100644
index 0000000000..b06ac5e4d5
--- /dev/null
+++ b/mobile/packages/accounts/lib/pages/delete_account_page.dart
@@ -0,0 +1,251 @@
+import 'dart:convert';
+
+import 'package:ente_accounts/ente_accounts.dart';
+import 'package:ente_configuration/base_configuration.dart';
+import 'package:ente_crypto_dart/ente_crypto_dart.dart';
+import 'package:ente_lock_screen/local_authentication_service.dart';
+import 'package:ente_ui/theme/ente_theme.dart';
+import 'package:ente_utils/email_util.dart';
+import 'package:ente_utils/platform_util.dart';
+import 'package:ente_strings/ente_strings.dart';
+import 'package:flutter/material.dart';
+import 'package:ente_ui/components/buttons/gradient_button.dart';
+import 'package:ente_ui/components/dialogs.dart';
+
+class DeleteAccountPage extends StatelessWidget {
+ final BaseConfiguration configuration;
+
+ const DeleteAccountPage(
+ this.configuration, {
+ super.key,
+ });
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppBar(
+ elevation: 0,
+ title: Text(context.strings.deleteAccount),
+ leading: IconButton(
+ icon: const Icon(Icons.arrow_back),
+ color: Theme.of(context).iconTheme.color,
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
+ ),
+ ),
+ body: Padding(
+ padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 24),
+ child: Center(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ Image.asset(
+ 'assets/broken_heart.png',
+ width: 200,
+ ),
+ const SizedBox(
+ height: 24,
+ ),
+ Center(
+ child: Text(
+ context.strings.deleteAccountQuery,
+ style: Theme.of(context).textTheme.titleMedium,
+ ),
+ ),
+ const SizedBox(
+ height: 12,
+ ),
+ RichText(
+ // textAlign: TextAlign.center,
+ text: TextSpan(
+ children: const [
+ TextSpan(text: "Please write to us at "),
+ TextSpan(
+ style: TextStyle(color: Color.fromRGBO(29, 185, 84, 1)),
+ ),
+ TextSpan(
+ text: ", maybe there is a way we can help.",
+ ),
+ ],
+ style: Theme.of(context).textTheme.titleMedium,
+ ),
+ ),
+ const SizedBox(
+ height: 24,
+ ),
+ GradientButton(
+ text: context.strings.yesSendFeedbackAction,
+ iconData: Icons.check,
+ onTap: () async {
+ await sendEmail(
+ context,
+ subject: '[Feedback]',
+ );
+ },
+ ),
+ const Padding(
+ padding: EdgeInsets.symmetric(vertical: 8),
+ ),
+ InkWell(
+ child: SizedBox(
+ width: double.infinity,
+ child: OutlinedButton.icon(
+ style: OutlinedButton.styleFrom(
+ shape: RoundedRectangleBorder(
+ borderRadius: BorderRadius.circular(8),
+ ),
+ side: const BorderSide(
+ color: Colors.redAccent,
+ ),
+ padding: const EdgeInsets.symmetric(
+ vertical: 18,
+ horizontal: 10,
+ ),
+ backgroundColor: Colors.white,
+ ),
+ label: Text(
+ context.strings.noDeleteAccountAction,
+ style: const TextStyle(
+ color: Colors.redAccent, // same for both themes
+ ),
+ textAlign: TextAlign.center,
+ ),
+ onPressed: () async => {await _initiateDelete(context)},
+ icon: const Icon(
+ Icons.no_accounts,
+ color: Colors.redAccent,
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ }
+
+ Future<void> _initiateDelete(BuildContext context) async {
+ final deleteChallengeResponse =
+ await UserService.instance.getDeleteChallenge(context);
+ if (deleteChallengeResponse == null) {
+ return;
+ }
+ if (deleteChallengeResponse.allowDelete) {
+ await _confirmAndDelete(context, deleteChallengeResponse);
+ } else {
+ await _requestEmailForDeletion(context);
+ }
+ }
+
+ Future<void> _confirmAndDelete(
+ BuildContext context,
+ DeleteChallengeResponse response,
+ ) async {
+ final hasAuthenticated =
+ await LocalAuthenticationService.instance.requestLocalAuthentication(
+ context,
+ context.strings.initiateAccountDeleteTitle,
+ );
+
+ await PlatformUtil.refocusWindows();
+
+ if (hasAuthenticated) {
+ final choice = await showChoiceDialogOld(
+ context,
+ context.strings.confirmAccountDeleteTitle,
+ context.strings.confirmAccountDeleteMessage,
+ firstAction: context.strings.cancel,
+ secondAction: context.strings.delete,
+ firstActionColor: getEnteColorScheme(context).surface,
+ secondActionColor: Colors.red,
+ );
+ if (choice != DialogUserChoice.secondChoice) {
+ return;
+ }
+ final decryptChallenge = CryptoUtil.openSealSync(
+ CryptoUtil.base642bin(response.encryptedChallenge),
+ CryptoUtil.base642bin(
+ configuration.getKeyAttributes()!.publicKey,
+ ),
+ configuration.getSecretKey()!,
+ );
+ final challengeResponseStr = utf8.decode(decryptChallenge);
+ await UserService.instance.deleteAccount(context, challengeResponseStr);
+ }
+ }
+
+ Future<void> _requestEmailForDeletion(BuildContext context) async {
+ final AlertDialog alert = AlertDialog(
+ title: Text(
+ context.strings.deleteAccount,
+ style: const TextStyle(
+ color: Colors.red,
+ ),
+ ),
+ content: RichText(
+ text: TextSpan(
+ children: [
+ const TextSpan(
+ text: "Please send an email to ",
+ ),
+ TextSpan(
+ style: TextStyle(
+ color: Colors.orange[300],
+ ),
+ ),
+ const TextSpan(
+ text:
+ " from your registered email address.\n\nYour request will be processed within 72 hours.",
+ ),
+ ],
+ style: TextStyle(
+ color: getEnteColorScheme(context).surface,
+ height: 1.5,
+ fontSize: 16,
+ ),
+ ),
+ ),
+ actions: [
+ TextButton(
+ child: Text(
+ context.strings.sendEmail,
+ style: const TextStyle(
+ color: Colors.red,
+ ),
+ ),
+ onPressed: () async {
+ Navigator.of(context, rootNavigator: true).pop('dialog');
+ await sendEmail(
+ context,
+ subject: '[Delete account]',
+ );
+ },
+ ),
+ TextButton(
+ child: Text(
+ context.strings.ok,
+ style: TextStyle(
+ color: getEnteColorScheme(context).surface,
+ ),
+ ),
+ onPressed: () {
+ Navigator.of(context, rootNavigator: true).pop('dialog');
+ },
+ ),
+ ],
+ );
+ // ignore: unawaited_futures
+ showDialog(
+ context: context,
+ builder: (BuildContext context) {
+ return alert;
+ },
+ );
+ }
+}
diff --git a/mobile/packages/accounts/lib/pages/email_entry_page.dart b/mobile/packages/accounts/lib/pages/email_entry_page.dart
new file mode 100644
index 0000000000..7c922d793d
--- /dev/null
+++ b/mobile/packages/accounts/lib/pages/email_entry_page.dart
@@ -0,0 +1,509 @@
+import 'package:email_validator/email_validator.dart';
+import 'package:ente_accounts/ente_accounts.dart';
+import 'package:ente_configuration/base_configuration.dart';
+import 'package:ente_strings/ente_strings.dart';
+import 'package:ente_ui/components/buttons/dynamic_fab.dart';
+import 'package:ente_ui/theme/ente_theme.dart';
+import 'package:ente_utils/platform_util.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:password_strength/password_strength.dart';
+import 'package:step_progress_indicator/step_progress_indicator.dart';
+import "package:styled_text/styled_text.dart";
+
+class EmailEntryPage extends StatefulWidget {
+ final BaseConfiguration config;
+
+ const EmailEntryPage(this.config, {super.key});
+
+ @override
+ State<EmailEntryPage> createState() => _EmailEntryPageState();
+}
+
+class _EmailEntryPageState extends State<EmailEntryPage> {
+ static const kMildPasswordStrengthThreshold = 0.4;
+ static const kStrongPasswordStrengthThreshold = 0.7;
+
+ final _passwordController1 = TextEditingController();
+ final _passwordController2 = TextEditingController();
+ Color? _validFieldValueColor;
+
+ String? _email;
+ String? _password;
+ String _cnfPassword = '';
+ String _referralSource = '';
+ double _passwordStrength = 0.0;
+ bool _emailIsValid = false;
+ bool _hasAgreedToTOS = true;
+ bool _hasAgreedToE2E = false;
+ bool _password1Visible = false;
+ bool _password2Visible = false;
+ bool _passwordsMatch = false;
+
+ final _password1FocusNode = FocusNode();
+ final _password2FocusNode = FocusNode();
+ bool _password1InFocus = false;
+ bool _password2InFocus = false;
+ bool _passwordIsValid = false;
+
+ @override
+ void initState() {
+ _email = widget.config.getEmail();
+ _password1FocusNode.addListener(() {
+ setState(() {
+ _password1InFocus = _password1FocusNode.hasFocus;
+ });
+ });
+ _password2FocusNode.addListener(() {
+ setState(() {
+ _password2InFocus = _password2FocusNode.hasFocus;
+ });
+ });
+ super.initState();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
+
+ // Initialize theme-aware color
+ final colorScheme = getEnteColorScheme(context);
+ _validFieldValueColor = colorScheme.primary300.withOpacity(0.2);
+
+ FloatingActionButtonLocation? fabLocation() {
+ if (isKeypadOpen) {
+ return null;
+ } else {
+ return FloatingActionButtonLocation.centerFloat;
+ }
+ }
+
+ final appBar = AppBar(
+ elevation: 0,
+ leading: IconButton(
+ icon: const Icon(Icons.arrow_back),
+ color: Theme.of(context).iconTheme.color,
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
+ ),
+ title: Material(
+ type: MaterialType.transparency,
+ child: StepProgressIndicator(
+ totalSteps: 4,
+ currentStep: 1,
+ selectedColor: getEnteColorScheme(context).alternativeColor,
+ roundedEdges: const Radius.circular(10),
+ unselectedColor:
+ getEnteColorScheme(context).stepProgressUnselectedColor,
+ ),
+ ),
+ );
+ return Scaffold(
+ resizeToAvoidBottomInset: isKeypadOpen,
+ appBar: appBar,
+ body: _getBody(),
+ floatingActionButton: DynamicFAB(
+ isKeypadOpen: isKeypadOpen,
+ isFormValid: _isFormValid(),
+ buttonText: context.strings.createAccount,
+ onPressedFunction: () {
+ UserService.instance.setEmail(_email!);
+ widget.config.setVolatilePassword(_passwordController1.text);
+ UserService.instance.setRefSource(_referralSource);
+ UserService.instance.sendOtt(
+ context,
+ _email!,
+ isCreateAccountScreen: true,
+ purpose: "signup",
+ );
+ FocusScope.of(context).unfocus();
+ },
+ ),
+ floatingActionButtonLocation: fabLocation(),
+ floatingActionButtonAnimator: NoScalingAnimation(),
+ );
+ }
+
+ Widget _getBody() {
+ var passwordStrengthText = context.strings.weakStrength;
+ var passwordStrengthColor = Colors.redAccent;
+ if (_passwordStrength > kStrongPasswordStrengthThreshold) {
+ passwordStrengthText = context.strings.strongStrength;
+ passwordStrengthColor = Colors.greenAccent;
+ } else if (_passwordStrength > kMildPasswordStrengthThreshold) {
+ passwordStrengthText = context.strings.moderateStrength;
+ passwordStrengthColor = Colors.orangeAccent;
+ }
+ return Column(
+ children: [
+ Expanded(
+ child: AutofillGroup(
+ child: ListView(
+ children: [
+ Padding(
+ padding:
+ const EdgeInsets.symmetric(vertical: 30, horizontal: 20),
+ child: Text(
+ context.strings.createNewAccount,
+ style: Theme.of(context).textTheme.headlineMedium,
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
+ child: TextFormField(
+ style: Theme.of(context).textTheme.titleMedium,
+ autofillHints: const [AutofillHints.email],
+ decoration: InputDecoration(
+ fillColor: _emailIsValid ? _validFieldValueColor : null,
+ filled: true,
+ hintText: context.strings.email,
+ contentPadding: const EdgeInsets.symmetric(
+ horizontal: 16,
+ vertical: 14,
+ ),
+ border: UnderlineInputBorder(
+ borderSide: BorderSide.none,
+ borderRadius: BorderRadius.circular(6),
+ ),
+ suffixIcon: _emailIsValid
+ ? Icon(
+ Icons.check,
+ size: 20,
+ color: getEnteColorScheme(context).primary300,
+ )
+ : null,
+ ),
+ onChanged: (value) {
+ _email = value.trim();
+ if (_emailIsValid != EmailValidator.validate(_email!)) {
+ setState(() {
+ _emailIsValid = EmailValidator.validate(_email!);
+ });
+ }
+ },
+ autocorrect: false,
+ keyboardType: TextInputType.emailAddress,
+ //initialValue: _email,
+ textInputAction: TextInputAction.next,
+ ),
+ ),
+ const Padding(padding: EdgeInsets.all(4)),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
+ child: TextFormField(
+ keyboardType: TextInputType.text,
+ textInputAction: TextInputAction.next,
+ controller: _passwordController1,
+ obscureText: !_password1Visible,
+ enableSuggestions: true,
+ autofillHints: const [AutofillHints.newPassword],
+ decoration: InputDecoration(
+ fillColor:
+ _passwordIsValid ? _validFieldValueColor : null,
+ filled: true,
+ hintText: context.strings.password,
+ contentPadding: const EdgeInsets.symmetric(
+ horizontal: 16,
+ vertical: 14,
+ ),
+ suffixIcon: _password1InFocus
+ ? IconButton(
+ icon: Icon(
+ _password1Visible
+ ? Icons.visibility
+ : Icons.visibility_off,
+ color: Theme.of(context).iconTheme.color,
+ size: 20,
+ ),
+ onPressed: () {
+ setState(() {
+ _password1Visible = !_password1Visible;
+ });
+ },
+ )
+ : _passwordIsValid
+ ? Icon(
+ Icons.check,
+ color: getEnteColorScheme(context).primary300,
+ )
+ : null,
+ border: UnderlineInputBorder(
+ borderSide: BorderSide.none,
+ borderRadius: BorderRadius.circular(6),
+ ),
+ ),
+ focusNode: _password1FocusNode,
+ onChanged: (password) {
+ if (password != _password) {
+ setState(() {
+ _password = password;
+ _passwordStrength =
+ estimatePasswordStrength(password);
+ _passwordIsValid = _passwordStrength >=
+ kMildPasswordStrengthThreshold;
+ _passwordsMatch = _password == _cnfPassword;
+ });
+ }
+ },
+ onEditingComplete: () {
+ _password1FocusNode.unfocus();
+ _password2FocusNode.requestFocus();
+ TextInput.finishAutofillContext();
+ },
+ ),
+ ),
+ const SizedBox(height: 8),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
+ child: TextFormField(
+ keyboardType: TextInputType.visiblePassword,
+ controller: _passwordController2,
+ obscureText: !_password2Visible,
+ autofillHints: const [AutofillHints.newPassword],
+ onEditingComplete: () => TextInput.finishAutofillContext(),
+ decoration: InputDecoration(
+ fillColor: _passwordsMatch && _passwordIsValid
+ ? _validFieldValueColor
+ : null,
+ filled: true,
+ hintText: context.strings.confirmPassword,
+ contentPadding: const EdgeInsets.symmetric(
+ horizontal: 16,
+ vertical: 14,
+ ),
+ suffixIcon: _password2InFocus
+ ? IconButton(
+ icon: Icon(
+ _password2Visible
+ ? Icons.visibility
+ : Icons.visibility_off,
+ color: Theme.of(context).iconTheme.color,
+ size: 20,
+ ),
+ onPressed: () {
+ setState(() {
+ _password2Visible = !_password2Visible;
+ });
+ },
+ )
+ : _passwordsMatch
+ ? Icon(
+ Icons.check,
+ color: getEnteColorScheme(context).primary300,
+ )
+ : null,
+ border: UnderlineInputBorder(
+ borderSide: BorderSide.none,
+ borderRadius: BorderRadius.circular(6),
+ ),
+ ),
+ focusNode: _password2FocusNode,
+ onChanged: (cnfPassword) {
+ setState(() {
+ _cnfPassword = cnfPassword;
+ if (_password != null || _password != '') {
+ _passwordsMatch = _password == _cnfPassword;
+ }
+ });
+ },
+ ),
+ ),
+ Opacity(
+ opacity: (_password != '') && _password1InFocus ? 1 : 0,
+ child: Padding(
+ padding:
+ const EdgeInsets.symmetric(horizontal: 24, vertical: 8),
+ child: Text(
+ context.strings.passwordStrength(passwordStrengthText),
+ style: TextStyle(
+ color: passwordStrengthColor,
+ fontWeight: FontWeight.w500,
+ fontSize: 12,
+ ),
+ ),
+ ),
+ ),
+ const SizedBox(height: 4),
+ Padding(
+ padding:
+ const EdgeInsets.symmetric(vertical: 0, horizontal: 20),
+ child: Text(
+ context.strings.hearUsWhereTitle,
+ style: getEnteTextTheme(context).smallFaint,
+ ),
+ ),
+ const SizedBox(height: 4),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
+ child: TextFormField(
+ style: Theme.of(context).textTheme.titleMedium,
+ decoration: InputDecoration(
+ fillColor: null,
+ filled: true,
+ contentPadding: const EdgeInsets.symmetric(
+ horizontal: 16,
+ vertical: 14,
+ ),
+ border: UnderlineInputBorder(
+ borderSide: BorderSide.none,
+ borderRadius: BorderRadius.circular(6),
+ ),
+ suffixIcon: InkWell(
+ onTap: () {
+ showToast(
+ context,
+ context.strings.hearUsExplanation,
+ );
+ },
+ child: Icon(
+ Icons.info_outline_rounded,
+ color: getEnteColorScheme(context).strokeMuted,
+ ),
+ ),
+ ),
+ onChanged: (value) {
+ _referralSource = value.trim();
+ },
+ autocorrect: false,
+ keyboardType: TextInputType.text,
+ textInputAction: TextInputAction.next,
+ ),
+ ),
+ const Divider(thickness: 1),
+ const SizedBox(height: 12),
+ _getAgreement(),
+ const SizedBox(height: 40),
+ ],
+ ),
+ ),
+ ),
+ ],
+ );
+ }
+
+ Container _getAgreement() {
+ return Container(
+ padding: const EdgeInsets.only(left: 20, right: 20, bottom: 20),
+ child: Column(
+ children: [
+ _getTOSAgreement(),
+ _getPasswordAgreement(),
+ ],
+ ),
+ );
+ }
+
+ Widget _getTOSAgreement() {
+ return GestureDetector(
+ onTap: () {
+ setState(() {
+ _hasAgreedToTOS = !_hasAgreedToTOS;
+ });
+ },
+ behavior: HitTestBehavior.translucent,
+ child: Row(
+ children: [
+ Checkbox(
+ value: _hasAgreedToTOS,
+ side: CheckboxTheme.of(context).side,
+ onChanged: (value) {
+ setState(() {
+ _hasAgreedToTOS = value!;
+ });
+ },
+ ),
+ Expanded(
+ child: StyledText(
+ text: context.strings.signUpTerms,
+ style: Theme.of(context)
+ .textTheme
+ .titleMedium!
+ .copyWith(fontSize: 12),
+ tags: {
+ 'u-terms': StyledTextActionTag(
+ (String? text, Map<String?, String?> attrs) =>
+ PlatformUtil.openWebView(
+ context,
+ context.strings.termsOfServicesTitle,
+ "https://ente.io/terms",
+ ),
+ style: const TextStyle(
+ decoration: TextDecoration.underline,
+ ),
+ ),
+ 'u-policy': StyledTextActionTag(
+ (String? text, Map<String?, String?> attrs) =>
+ PlatformUtil.openWebView(
+ context,
+ context.strings.privacyPolicyTitle,
+ "https://ente.io/privacy",
+ ),
+ style: const TextStyle(
+ decoration: TextDecoration.underline,
+ ),
+ ),
+ },
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+
+ Widget _getPasswordAgreement() {
+ return GestureDetector(
+ onTap: () {
+ setState(() {
+ _hasAgreedToE2E = !_hasAgreedToE2E;
+ });
+ },
+ behavior: HitTestBehavior.translucent,
+ child: Row(
+ children: [
+ Checkbox(
+ value: _hasAgreedToE2E,
+ side: CheckboxTheme.of(context).side,
+ onChanged: (value) {
+ setState(() {
+ _hasAgreedToE2E = value!;
+ });
+ },
+ ),
+ Expanded(
+ child: StyledText(
+ text: context.strings.ackPasswordLostWarning,
+ style: Theme.of(context)
+ .textTheme
+ .titleMedium!
+ .copyWith(fontSize: 12),
+ tags: {
+ 'underline': StyledTextActionTag(
+ (String? text, Map<String?, String?> attrs) =>
+ PlatformUtil.openWebView(
+ context,
+ context.strings.encryption,
+ "https://ente.io/architecture",
+ ),
+ style: const TextStyle(
+ decoration: TextDecoration.underline,
+ ),
+ ),
+ },
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+
+ bool _isFormValid() {
+ return _emailIsValid &&
+ _passwordsMatch &&
+ _hasAgreedToTOS &&
+ _hasAgreedToE2E &&
+ _passwordIsValid;
+ }
+
+ void showToast(BuildContext context, String hearUsExplanation) {}
+}
diff --git a/mobile/packages/accounts/lib/pages/login_page.dart b/mobile/packages/accounts/lib/pages/login_page.dart
new file mode 100644
index 0000000000..17737cc0e0
--- /dev/null
+++ b/mobile/packages/accounts/lib/pages/login_page.dart
@@ -0,0 +1,221 @@
+import 'package:email_validator/email_validator.dart';
+import 'package:ente_accounts/ente_accounts.dart';
+import 'package:ente_accounts/models/errors.dart';
+import 'package:ente_configuration/base_configuration.dart';
+import 'package:ente_ui/components/buttons/dynamic_fab.dart';
+import 'package:ente_ui/theme/ente_theme.dart';
+import 'package:ente_utils/platform_util.dart';
+import "package:ente_strings/ente_strings.dart";
+import 'package:flutter/material.dart';
+import 'package:logging/logging.dart';
+import "package:styled_text/styled_text.dart";
+
+class LoginPage extends StatefulWidget {
+ final BaseConfiguration config;
+
+ const LoginPage(this.config, {super.key});
+
+ @override
+ State<LoginPage> createState() => _LoginPageState();
+}
+
+class _LoginPageState extends State<LoginPage> {
+ bool _emailIsValid = false;
+ String? _email;
+ Color? _emailInputFieldColor;
+ final Logger _logger = Logger('_LoginPageState');
+
+ Future<void> onPressed() async {
+ await UserService.instance.setEmail(_email!);
+ widget.config.resetVolatilePassword();
+ SrpAttributes? attr;
+ bool isEmailVerificationEnabled = true;
+ try {
+ attr = await UserService.instance.getSrpAttributes(_email!);
+ isEmailVerificationEnabled = attr.isEmailMFAEnabled;
+ } catch (e) {
+ if (e is! SrpSetupNotCompleteError) {
+ _logger.severe('Error getting SRP attributes', e);
+ }
+ }
+ if (attr != null && !isEmailVerificationEnabled) {
+ await Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return LoginPasswordVerificationPage(
+ widget.config,
+ attr!,
+ );
+ },
+ ),
+ );
+ } else {
+ await UserService.instance.sendOtt(
+ context,
+ _email!,
+ isCreateAccountScreen: false,
+ purpose: 'login',
+ );
+ }
+ FocusScope.of(context).unfocus();
+ }
+
+ @override
+ void initState() {
+ _email = widget.config.getEmail();
+ super.initState();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
+
+ FloatingActionButtonLocation? fabLocation() {
+ if (isKeypadOpen) {
+ return null;
+ } else {
+ return FloatingActionButtonLocation.centerFloat;
+ }
+ }
+
+ return Scaffold(
+ resizeToAvoidBottomInset: isKeypadOpen,
+ appBar: AppBar(
+ elevation: 0,
+ leading: IconButton(
+ icon: const Icon(Icons.arrow_back),
+ color: Theme.of(context).iconTheme.color,
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
+ ),
+ ),
+ body: _getBody(),
+ floatingActionButton: DynamicFAB(
+ isKeypadOpen: isKeypadOpen,
+ isFormValid: _emailIsValid,
+ buttonText: context.strings.logInLabel,
+ onPressedFunction: onPressed,
+ ),
+ floatingActionButtonLocation: fabLocation(),
+ floatingActionButtonAnimator: NoScalingAnimation(),
+ );
+ }
+
+ Widget _getBody() {
+ return Column(
+ children: [
+ Expanded(
+ child: AutofillGroup(
+ child: ListView(
+ children: [
+ Padding(
+ padding:
+ const EdgeInsets.symmetric(vertical: 30, horizontal: 20),
+ child: Text(
+ context.strings.welcomeBack,
+ style: Theme.of(context).textTheme.headlineMedium,
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(20, 24, 20, 0),
+ child: TextFormField(
+ autofillHints: const [AutofillHints.email],
+ onFieldSubmitted:
+ _emailIsValid ? (value) => onPressed() : null,
+ decoration: InputDecoration(
+ fillColor: _emailInputFieldColor,
+ filled: true,
+ hintText: context.strings.email,
+ contentPadding: const EdgeInsets.symmetric(
+ horizontal: 15,
+ vertical: 15,
+ ),
+ border: UnderlineInputBorder(
+ borderSide: BorderSide.none,
+ borderRadius: BorderRadius.circular(6),
+ ),
+ suffixIcon: _emailIsValid
+ ? Icon(
+ Icons.check,
+ size: 20,
+ color: getEnteColorScheme(context).primary300,
+ )
+ : null,
+ ),
+ onChanged: (value) {
+ setState(() {
+ _email = value.trim();
+ _emailIsValid = EmailValidator.validate(_email!);
+ if (_emailIsValid) {
+ _emailInputFieldColor = getEnteColorScheme(context)
+ .primary300
+ .withOpacity(0.2);
+ } else {
+ _emailInputFieldColor = null;
+ }
+ });
+ },
+ autocorrect: false,
+ keyboardType: TextInputType.emailAddress,
+ //initialValue: _email,
+ autofocus: true,
+ ),
+ ),
+ const Padding(
+ padding: EdgeInsets.symmetric(vertical: 18),
+ child: Divider(
+ thickness: 1,
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20),
+ child: Row(
+ children: [
+ Expanded(
+ flex: 5,
+ child: StyledText(
+ text: context.strings.loginTerms,
+ style: getEnteTextTheme(context).small,
+ tags: {
+ 'u-terms': StyledTextActionTag(
+ (String? text, Map<String?, String?> attrs) =>
+ PlatformUtil.openWebView(
+ context,
+ context.strings.termsOfServicesTitle,
+ "https://ente.io/terms",
+ ),
+ style: const TextStyle(
+ decoration: TextDecoration.underline,
+ ),
+ ),
+ 'u-policy': StyledTextActionTag(
+ (String? text, Map<String?, String?> attrs) =>
+ PlatformUtil.openWebView(
+ context,
+ context.strings.privacyPolicyTitle,
+ "https://ente.io/privacy",
+ ),
+ style: const TextStyle(
+ decoration: TextDecoration.underline,
+ ),
+ ),
+ },
+ ),
+ ),
+ Expanded(
+ flex: 2,
+ child: Container(),
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ const Padding(padding: EdgeInsets.all(8)),
+ ],
+ );
+ }
+}
diff --git a/mobile/packages/accounts/lib/pages/login_pwd_verification_page.dart b/mobile/packages/accounts/lib/pages/login_pwd_verification_page.dart
new file mode 100644
index 0000000000..6c0144f3b0
--- /dev/null
+++ b/mobile/packages/accounts/lib/pages/login_pwd_verification_page.dart
@@ -0,0 +1,349 @@
+import "package:dio/dio.dart";
+import "package:ente_accounts/ente_accounts.dart";
+import "package:ente_configuration/base_configuration.dart";
+import "package:ente_ui/components/buttons/button_widget.dart";
+import "package:ente_ui/components/buttons/dynamic_fab.dart";
+import "package:ente_ui/theme/ente_theme.dart";
+import "package:ente_ui/utils/dialog_util.dart";
+import "package:ente_utils/email_util.dart";
+import "package:ente_strings/ente_strings.dart";
+import "package:ente_crypto_dart/ente_crypto_dart.dart";
+import 'package:flutter/material.dart';
+import "package:logging/logging.dart";
+
+// LoginPasswordVerificationPage is a page that allows the user to enter their password to verify their identity.
+// If the password is correct, then the user is either directed to
+// PasswordReentryPage (if the user has not yet set up 2FA) or TwoFactorAuthenticationPage (if the user has set up 2FA).
+// In the PasswordReentryPage, the password is auto-filled based on the
+// volatile password.
+class LoginPasswordVerificationPage extends StatefulWidget {
+ final BaseConfiguration config;
+ final SrpAttributes srpAttributes;
+ const LoginPasswordVerificationPage(
+ this.config,
+ this.srpAttributes, {
+ super.key,
+ });
+
+ @override
+ State<LoginPasswordVerificationPage> createState() =>
+ _LoginPasswordVerificationPageState();
+}
+
+class _LoginPasswordVerificationPageState
+ extends State<LoginPasswordVerificationPage> {
+ final _logger = Logger((_LoginPasswordVerificationPageState).toString());
+ final _passwordController = TextEditingController();
+ final FocusNode _passwordFocusNode = FocusNode();
+ String? email;
+ bool _passwordInFocus = false;
+ bool _passwordVisible = false;
+
+ Future<void> onPressed() async {
+ FocusScope.of(context).unfocus();
+ await verifyPassword(context, _passwordController.text);
+ }
+
+ @override
+ void initState() {
+ super.initState();
+ email = widget.config.getEmail();
+ _passwordFocusNode.addListener(() {
+ setState(() {
+ _passwordInFocus = _passwordFocusNode.hasFocus;
+ });
+ });
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
+
+ FloatingActionButtonLocation? fabLocation() {
+ if (isKeypadOpen) {
+ return null;
+ } else {
+ return FloatingActionButtonLocation.centerFloat;
+ }
+ }
+
+ return Scaffold(
+ resizeToAvoidBottomInset: isKeypadOpen,
+ appBar: AppBar(
+ elevation: 0,
+ leading: IconButton(
+ icon: const Icon(Icons.arrow_back),
+ color: Theme.of(context).iconTheme.color,
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
+ ),
+ ),
+ body: _getBody(),
+ floatingActionButton: DynamicFAB(
+ key: const ValueKey("verifyPasswordButton"),
+ isKeypadOpen: isKeypadOpen,
+ isFormValid: _passwordController.text.isNotEmpty,
+ buttonText: context.strings.logInLabel,
+ onPressedFunction: onPressed,
+ ),
+ floatingActionButtonLocation: fabLocation(),
+ floatingActionButtonAnimator: NoScalingAnimation(),
+ );
+ }
+
+ Future<void> verifyPassword(BuildContext context, String password) async {
+ final dialog = createProgressDialog(
+ context,
+ context.strings.pleaseWait,
+ isDismissible: true,
+ );
+ await dialog.show();
+ try {
+ await UserService.instance.verifyEmailViaPassword(
+ context,
+ widget.srpAttributes,
+ password,
+ dialog,
+ );
+ } on DioException catch (e, s) {
+ await dialog.hide();
+ if (e.response != null && e.response!.statusCode == 401) {
+ _logger.severe('server reject, failed verify SRP login', e, s);
+ await _showContactSupportDialog(
+ context,
+ context.strings.incorrectPasswordTitle,
+ context.strings.pleaseTryAgain,
+ );
+ } else {
+ _logger.severe('API failure during SRP login', e, s);
+ if (e.type == DioExceptionType.connectionError) {
+ await _showContactSupportDialog(
+ context,
+ context.strings.noInternetConnection,
+ context.strings.pleaseCheckYourInternetConnectionAndTryAgain,
+ );
+ } else {
+ await _showContactSupportDialog(
+ context,
+ context.strings.oops,
+ context.strings.verificationFailedPleaseTryAgain,
+ );
+ }
+ }
+ } catch (e, s) {
+ _logger.info('error during loginViaPassword', e);
+ await dialog.hide();
+ if (e is LoginKeyDerivationError) {
+ _logger.severe('loginKey derivation error', e, s);
+ // LoginKey err, perform regular login via ott verification
+ await UserService.instance.sendOtt(
+ context,
+ email!,
+ isCreateAccountScreen: true,
+ );
+ return;
+ } else if (e is KeyDerivationError) {
+ // device is not powerful enough to perform derive key
+ final dialogChoice = await showChoiceDialog(
+ context,
+ title: context.strings.recreatePasswordTitle,
+ body: context.strings.recreatePasswordBody,
+ firstButtonLabel: context.strings.useRecoveryKey,
+ );
+ if (dialogChoice!.action == ButtonAction.first) {
+ await UserService.instance.sendOtt(
+ context,
+ email!,
+ isResetPasswordScreen: true,
+ );
+ }
+ return;
+ } else {
+ _logger.severe('unexpected error while verifying password', e, s);
+ await _showContactSupportDialog(
+ context,
+ context.strings.oops,
+ context.strings.verificationFailedPleaseTryAgain,
+ );
+ }
+ }
+ }
+
+ Future<void> _showContactSupportDialog(
+ BuildContext context,
+ String title,
+ String message,
+ ) async {
+ final dialogChoice = await showChoiceDialog(
+ context,
+ title: title,
+ body: message,
+ firstButtonLabel: context.strings.contactSupport,
+ secondButtonLabel: context.strings.ok,
+ );
+ if (dialogChoice!.action == ButtonAction.first) {
+ await sendLogs(
+ context,
+ context.strings.contactSupport,
+ postShare: () {},
+ );
+ }
+ }
+
+ Widget _getBody() {
+ return Column(
+ children: [
+ Expanded(
+ child: AutofillGroup(
+ child: ListView(
+ children: [
+ Padding(
+ padding: const EdgeInsets.only(top: 30, left: 20, right: 20),
+ child: Text(
+ context.strings.enterPassword,
+ style: Theme.of(context).textTheme.headlineMedium,
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.only(
+ bottom: 30,
+ left: 22,
+ right: 20,
+ ),
+ child: Text(
+ email ?? '',
+ style: getEnteTextTheme(context).smallMuted,
+ ),
+ ),
+ Visibility(
+ // hidden textForm for suggesting auto-fill service for saving
+ // password
+ visible: false,
+ child: TextFormField(
+ autofillHints: const [
+ AutofillHints.email,
+ ],
+ autocorrect: false,
+ keyboardType: TextInputType.emailAddress,
+ initialValue: email,
+ textInputAction: TextInputAction.next,
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(20, 24, 20, 0),
+ child: TextFormField(
+ onFieldSubmitted: _passwordController.text.isNotEmpty
+ ? (_) => onPressed()
+ : null,
+ key: const ValueKey("passwordInputField"),
+ autofillHints: const [AutofillHints.password],
+ decoration: InputDecoration(
+ hintText: context.strings.enterYourPasswordHint,
+ filled: true,
+ contentPadding: const EdgeInsets.all(20),
+ border: UnderlineInputBorder(
+ borderSide: BorderSide.none,
+ borderRadius: BorderRadius.circular(6),
+ ),
+ suffixIcon: _passwordInFocus
+ ? IconButton(
+ icon: Icon(
+ _passwordVisible
+ ? Icons.visibility
+ : Icons.visibility_off,
+ color: Theme.of(context).iconTheme.color,
+ size: 20,
+ ),
+ onPressed: () {
+ setState(() {
+ _passwordVisible = !_passwordVisible;
+ });
+ },
+ )
+ : null,
+ ),
+ style: const TextStyle(
+ fontSize: 14,
+ ),
+ controller: _passwordController,
+ autofocus: true,
+ autocorrect: false,
+ obscureText: !_passwordVisible,
+ keyboardType: TextInputType.visiblePassword,
+ focusNode: _passwordFocusNode,
+ onChanged: (_) {
+ setState(() {});
+ },
+ ),
+ ),
+ const Padding(
+ padding: EdgeInsets.symmetric(vertical: 18),
+ child: Divider(
+ thickness: 1,
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20),
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () async {
+ await UserService.instance.sendOtt(
+ context,
+ email!,
+ isResetPasswordScreen: true,
+ );
+ },
+ child: Center(
+ child: Text(
+ context.strings.forgotPassword,
+ style: Theme.of(context)
+ .textTheme
+ .titleMedium!
+ .copyWith(
+ fontSize: 14,
+ decoration: TextDecoration.underline,
+ ),
+ ),
+ ),
+ ),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () async {
+ final dialog = createProgressDialog(
+ context,
+ context.strings.pleaseWait,
+ );
+ await dialog.show();
+ await widget.config.logout();
+ await dialog.hide();
+ Navigator.of(context)
+ .popUntil((route) => route.isFirst);
+ },
+ child: Center(
+ child: Text(
+ context.strings.changeEmail,
+ style: Theme.of(context)
+ .textTheme
+ .titleMedium!
+ .copyWith(
+ fontSize: 14,
+ decoration: TextDecoration.underline,
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ],
+ );
+ }
+}
diff --git a/mobile/packages/accounts/lib/pages/ott_verification_page.dart b/mobile/packages/accounts/lib/pages/ott_verification_page.dart
new file mode 100644
index 0000000000..442401fbd7
--- /dev/null
+++ b/mobile/packages/accounts/lib/pages/ott_verification_page.dart
@@ -0,0 +1,221 @@
+import 'package:ente_accounts/ente_accounts.dart';
+import 'package:ente_ui/components/buttons/dynamic_fab.dart';
+import 'package:ente_ui/theme/ente_theme.dart';
+import 'package:ente_strings/ente_strings.dart';
+import 'package:flutter/material.dart';
+import 'package:step_progress_indicator/step_progress_indicator.dart';
+import 'package:styled_text/styled_text.dart';
+
+class OTTVerificationPage extends StatefulWidget {
+ final String email;
+ final bool isChangeEmail;
+ final bool isCreateAccountScreen;
+ final bool isResetPasswordScreen;
+
+ const OTTVerificationPage(
+ this.email, {
+ this.isChangeEmail = false,
+ this.isCreateAccountScreen = false,
+ this.isResetPasswordScreen = false,
+ super.key,
+ });
+
+ @override
+ State<OTTVerificationPage> createState() => _OTTVerificationPageState();
+}
+
+class _OTTVerificationPageState extends State<OTTVerificationPage> {
+ final _verificationCodeController = TextEditingController();
+
+ Future<void> onPressed() async {
+ if (widget.isChangeEmail) {
+ await UserService.instance.changeEmail(
+ context,
+ widget.email,
+ _verificationCodeController.text,
+ );
+ } else {
+ await UserService.instance.verifyEmail(
+ context,
+ _verificationCodeController.text,
+ isResettingPasswordScreen: widget.isResetPasswordScreen,
+ );
+ }
+ FocusScope.of(context).unfocus();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
+
+ FloatingActionButtonLocation? fabLocation() {
+ if (isKeypadOpen) {
+ return null;
+ } else {
+ return FloatingActionButtonLocation.centerFloat;
+ }
+ }
+
+ return Scaffold(
+ resizeToAvoidBottomInset: isKeypadOpen,
+ appBar: AppBar(
+ elevation: 0,
+ leading: IconButton(
+ icon: const Icon(Icons.arrow_back),
+ color: Theme.of(context).iconTheme.color,
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
+ ),
+ title: widget.isCreateAccountScreen
+ ? Material(
+ type: MaterialType.transparency,
+ child: StepProgressIndicator(
+ totalSteps: 4,
+ currentStep: 2,
+ selectedColor: getEnteColorScheme(context).alternativeColor,
+ roundedEdges: const Radius.circular(10),
+ unselectedColor:
+ getEnteColorScheme(context).stepProgressUnselectedColor,
+ ),
+ )
+ : null,
+ ),
+ body: _getBody(),
+ floatingActionButton: DynamicFAB(
+ isKeypadOpen: isKeypadOpen,
+ isFormValid: _verificationCodeController.text.isNotEmpty,
+ buttonText: context.strings.verify,
+ onPressedFunction: onPressed,
+ ),
+ floatingActionButtonLocation: fabLocation(),
+ floatingActionButtonAnimator: NoScalingAnimation(),
+ );
+ }
+
+ Widget _getBody() {
+ return ListView(
+ children: [
+ Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Padding(
+ padding: const EdgeInsets.fromLTRB(20, 30, 20, 15),
+ child: Text(
+ context.strings.verifyEmail,
+ style: Theme.of(context).textTheme.headlineMedium,
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
+ child: Row(
+ children: [
+ Expanded(
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ Padding(
+ padding: const EdgeInsets.fromLTRB(0, 0, 0, 12),
+ child: StyledText(
+ text:
+ context.strings.weHaveSendEmailTo(widget.email),
+ style: Theme.of(context)
+ .textTheme
+ .titleMedium!
+ .copyWith(fontSize: 14),
+ tags: {
+ 'green': StyledTextTag(
+ style: TextStyle(
+ color: getEnteColorScheme(context)
+ .alternativeColor,
+ ),
+ ),
+ },
+ ),
+ ),
+ widget.isResetPasswordScreen
+ ? Text(
+ context.strings.toResetVerifyEmail,
+ style: Theme.of(context)
+ .textTheme
+ .titleMedium!
+ .copyWith(fontSize: 14),
+ )
+ : Text(
+ context.strings.checkInboxAndSpamFolder,
+ style: Theme.of(context)
+ .textTheme
+ .titleMedium!
+ .copyWith(fontSize: 14),
+ ),
+ ],
+ ),
+ ),
+ SizedBox(
+ width: MediaQuery.of(context).size.width * 0.2,
+ height: 1,
+ ),
+ ],
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(20, 16, 20, 16),
+ child: TextFormField(
+ style: Theme.of(context).textTheme.titleMedium,
+ onFieldSubmitted: _verificationCodeController.text.isNotEmpty
+ ? (_) => onPressed()
+ : null,
+ decoration: InputDecoration(
+ filled: true,
+ hintText: context.strings.tapToEnterCode,
+ contentPadding: const EdgeInsets.all(15),
+ border: UnderlineInputBorder(
+ borderSide: BorderSide.none,
+ borderRadius: BorderRadius.circular(6),
+ ),
+ ),
+ controller: _verificationCodeController,
+ autofocus: true,
+ autocorrect: false,
+ keyboardType: TextInputType.number,
+ onChanged: (_) {
+ setState(() {});
+ },
+ ),
+ ),
+ const Divider(
+ thickness: 1,
+ ),
+ Padding(
+ padding: const EdgeInsets.all(20),
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.end,
+ children: [
+ TextButton(
+ onPressed: () {
+ UserService.instance.sendOtt(
+ context,
+ widget.email,
+ isCreateAccountScreen: widget.isCreateAccountScreen,
+ isChangeEmail: widget.isChangeEmail,
+ isResetPasswordScreen: widget.isResetPasswordScreen,
+ );
+ },
+ child: Text(
+ context.strings.resendEmail,
+ style: Theme.of(context).textTheme.titleMedium!.copyWith(
+ fontSize: 14,
+ decoration: TextDecoration.underline,
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ ],
+ );
+ // );
+ }
+}
diff --git a/mobile/packages/accounts/lib/pages/passkey_page.dart b/mobile/packages/accounts/lib/pages/passkey_page.dart
new file mode 100644
index 0000000000..584be1bceb
--- /dev/null
+++ b/mobile/packages/accounts/lib/pages/passkey_page.dart
@@ -0,0 +1,234 @@
+import 'dart:convert';
+
+import 'package:app_links/app_links.dart';
+import 'package:ente_accounts/ente_accounts.dart';
+import 'package:ente_accounts/models/errors.dart';
+import 'package:ente_configuration/base_configuration.dart';
+import 'package:ente_ui/components/buttons/button_widget.dart';
+import 'package:ente_ui/components/buttons/models/button_type.dart';
+import 'package:ente_ui/utils/dialog_util.dart';
+import 'package:ente_ui/utils/toast_util.dart';
+import 'package:ente_utils/navigation_util.dart';
+import 'package:ente_strings/ente_strings.dart';
+import 'package:flutter/material.dart';
+import 'package:logging/logging.dart';
+import 'package:url_launcher/url_launcher_string.dart';
+
+class PasskeyPage extends StatefulWidget {
+ final BaseConfiguration config;
+ final String sessionID;
+ final String totp2FASessionID;
+ final String accountsUrl;
+
+ const PasskeyPage(
+ this.config,
+ this.sessionID, {
+ required this.totp2FASessionID,
+ required this.accountsUrl,
+ super.key,
+ });
+
+ @override
+ State<PasskeyPage> createState() => _PasskeyPageState();
+}
+
+class _PasskeyPageState extends State<PasskeyPage> {
+ final Logger _logger = Logger("PasskeyPage");
+
+ @override
+ void initState() {
+ launchPasskey();
+ _initDeepLinks();
+ super.initState();
+ }
+
+ @override
+ void dispose() {
+ super.dispose();
+ }
+
+ Future<void> launchPasskey() async {
+ await launchUrlString(
+ "${widget.accountsUrl}/passkeys/verify?"
+ "passkeySessionID=${widget.sessionID}"
+ "&redirect=enteauth://passkey"
+ "&clientPackage=io.ente.auth",
+ mode: LaunchMode.externalApplication,
+ );
+ }
+
+ Future<void> checkStatus() async {
+ late dynamic response;
+ try {
+ response = await UserService.instance
+ .getTokenForPasskeySession(widget.sessionID);
+ } on PassKeySessionNotVerifiedError {
+ showToast(context, context.strings.passKeyPendingVerification);
+ return;
+ } on PassKeySessionExpiredError {
+ await showErrorDialog(
+ context,
+ context.strings.loginSessionExpired,
+ context.strings.loginSessionExpiredDetails,
+ );
+ Navigator.of(context).pop();
+ return;
+ } catch (e, s) {
+ _logger.severe("failed to check status", e, s);
+ showGenericErrorDialog(context: context, error: e).ignore();
+ return;
+ }
+ await UserService.instance.onPassKeyVerified(context, response);
+ }
+
+ Future<void> _handleDeeplink(String? link) async {
+ if (!context.mounted ||
+ widget.config.hasConfiguredAccount() ||
+ link == null) {
+ _logger.warning(
+ 'ignored deeplink: contextMounted ${context.mounted}',
+ );
+ return;
+ }
+ try {
+ if (mounted && link.toLowerCase().startsWith("enteauth://passkey")) {
+ if (widget.config.isLoggedIn()) {
+ _logger.info('ignored deeplink: already configured');
+ showToast(context, 'Account is already configured.');
+ return;
+ }
+ final parsedUri = Uri.parse(link);
+ final sessionID = parsedUri.queryParameters['passkeySessionID'];
+ if (sessionID != widget.sessionID) {
+ showToast(context, "Session ID mismatch");
+ _logger.warning('ignored deeplink: sessionID mismatch');
+ return;
+ }
+ final String? authResponse = parsedUri.queryParameters['response'];
+ String base64String = authResponse!.toString();
+ while (base64String.length % 4 != 0) {
+ base64String += '=';
+ }
+ final res = utf8.decode(base64.decode(base64String));
+ final json = jsonDecode(res) as Map<String, dynamic>;
+ await UserService.instance.onPassKeyVerified(context, json);
+ } else {
+ _logger.info('ignored deeplink: $link mounted $mounted');
+ }
+ } catch (e, s) {
+ _logger.severe('passKey: failed to handle deeplink', e, s);
+ showGenericErrorDialog(context: context, error: e).ignore();
+ }
+ }
+
+ Future<bool> _initDeepLinks() async {
+ final appLinks = AppLinks();
+ // Attach a listener to the stream
+ appLinks.stringLinkStream.listen(
+ _handleDeeplink,
+ onError: (err) {
+ _logger.severe(err);
+ },
+ );
+ return false;
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppBar(
+ title: Text(
+ context.strings.passkeyAuthTitle,
+ ),
+ ),
+ body: _getBody(),
+ );
+ }
+
+ Widget _getBody() {
+ return Center(
+ child: Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 32),
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ Text(
+ context.strings.waitingForVerification,
+ style: const TextStyle(
+ height: 1.4,
+ fontSize: 16,
+ ),
+ ),
+ const SizedBox(height: 16),
+ ButtonWidget(
+ buttonType: ButtonType.primary,
+ labelText: context.strings.tryAgain,
+ onTap: () => launchPasskey(),
+ ),
+ const SizedBox(height: 16),
+ ButtonWidget(
+ buttonType: ButtonType.secondary,
+ labelText: context.strings.checkStatus,
+ onTap: () async {
+ try {
+ await checkStatus();
+ } catch (e) {
+ debugPrint('failed to check status %e');
+ showGenericErrorDialog(context: context, error: e).ignore();
+ }
+ },
+ shouldSurfaceExecutionStates: true,
+ ),
+ const Padding(padding: EdgeInsets.all(30)),
+ if (widget.totp2FASessionID.isNotEmpty)
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () {
+ routeToPage(
+ context,
+ TwoFactorAuthenticationPage(
+ widget.totp2FASessionID,
+ ),
+ );
+ },
+ child: Container(
+ padding: const EdgeInsets.all(10),
+ child: Center(
+ child: Text(
+ context.strings.loginWithTOTP,
+ style: const TextStyle(
+ decoration: TextDecoration.underline,
+ fontSize: 12,
+ ),
+ ),
+ ),
+ ),
+ ),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () {
+ UserService.instance.recoverTwoFactor(
+ context,
+ widget.sessionID,
+ TwoFactorType.passkey,
+ );
+ },
+ child: Container(
+ padding: const EdgeInsets.all(10),
+ child: Center(
+ child: Text(
+ context.strings.recoverAccount,
+ style: const TextStyle(
+ decoration: TextDecoration.underline,
+ fontSize: 12,
+ ),
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ );
+ }
+}
diff --git a/mobile/packages/accounts/lib/pages/password_entry_page.dart b/mobile/packages/accounts/lib/pages/password_entry_page.dart
new file mode 100644
index 0000000000..bf171e3cc3
--- /dev/null
+++ b/mobile/packages/accounts/lib/pages/password_entry_page.dart
@@ -0,0 +1,520 @@
+import 'package:ente_accounts/ente_accounts.dart';
+import 'package:ente_configuration/base_configuration.dart';
+import 'package:ente_ui/components/buttons/dynamic_fab.dart';
+import 'package:ente_ui/components/buttons/models/button_type.dart';
+import 'package:ente_ui/pages/base_home_page.dart';
+import 'package:ente_ui/theme/ente_theme.dart';
+import 'package:ente_ui/utils/dialog_util.dart';
+import 'package:ente_ui/utils/toast_util.dart';
+import 'package:ente_utils/navigation_util.dart';
+import 'package:ente_utils/platform_util.dart';
+import 'package:ente_strings/ente_strings.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:logging/logging.dart';
+import 'package:password_strength/password_strength.dart';
+import 'package:styled_text/styled_text.dart';
+
+enum PasswordEntryMode {
+ set,
+ update,
+ reset,
+}
+
+class PasswordEntryPage extends StatefulWidget {
+ final BaseConfiguration config;
+ final PasswordEntryMode mode;
+ final BaseHomePage homePage;
+
+ const PasswordEntryPage(
+ this.config,
+ this.mode,
+ this.homePage, {
+ super.key,
+ });
+
+ @override
+ State<PasswordEntryPage> createState() => _PasswordEntryPageState();
+}
+
+class _PasswordEntryPageState extends State<PasswordEntryPage> {
+ static const kMildPasswordStrengthThreshold = 0.4;
+ static const kStrongPasswordStrengthThreshold = 0.7;
+
+ final _logger = Logger((_PasswordEntryPageState).toString());
+ final _passwordController1 = TextEditingController(),
+ _passwordController2 = TextEditingController();
+ Color? _validFieldValueColor;
+ String? _volatilePassword;
+ String _passwordInInputBox = '';
+ String _passwordInInputConfirmationBox = '';
+ double _passwordStrength = 0.0;
+ bool _password1Visible = false;
+ bool _password2Visible = false;
+ final _password1FocusNode = FocusNode();
+ final _password2FocusNode = FocusNode();
+ bool _password1InFocus = false;
+ bool _password2InFocus = false;
+
+ bool _passwordsMatch = false;
+ bool _isPasswordValid = false;
+
+ @override
+ void initState() {
+ super.initState();
+ _volatilePassword = widget.config.getVolatilePassword();
+ if (_volatilePassword != null) {
+ Future.delayed(
+ Duration.zero,
+ () => _showRecoveryCodeDialog(
+ _volatilePassword!,
+ usingVolatilePassword: true,
+ ),
+ );
+ }
+ _password1FocusNode.addListener(() {
+ setState(() {
+ _password1InFocus = _password1FocusNode.hasFocus;
+ });
+ });
+ _password2FocusNode.addListener(() {
+ setState(() {
+ _password2InFocus = _password2FocusNode.hasFocus;
+ });
+ });
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
+
+ // Initialize theme-aware color
+ final colorScheme = getEnteColorScheme(context);
+ _validFieldValueColor = colorScheme.fillFaint.withOpacity(0.5);
+
+ FloatingActionButtonLocation? fabLocation() {
+ if (isKeypadOpen) {
+ return null;
+ } else {
+ return FloatingActionButtonLocation.centerFloat;
+ }
+ }
+
+ String title = context.strings.setPasswordTitle;
+ if (widget.mode == PasswordEntryMode.update) {
+ title = context.strings.changePasswordTitle;
+ } else if (widget.mode == PasswordEntryMode.reset) {
+ title = context.strings.resetPasswordTitle;
+ } else if (_volatilePassword != null) {
+ title = context.strings.encryptionKeys;
+ }
+ return Scaffold(
+ resizeToAvoidBottomInset: isKeypadOpen,
+ appBar: AppBar(
+ leading: widget.mode == PasswordEntryMode.reset
+ ? Container()
+ : IconButton(
+ icon: const Icon(Icons.arrow_back),
+ color: Theme.of(context).iconTheme.color,
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
+ ),
+ elevation: 0,
+ ),
+ body: _getBody(title),
+ floatingActionButton: DynamicFAB(
+ isKeypadOpen: isKeypadOpen,
+ isFormValid: _passwordsMatch && _isPasswordValid,
+ buttonText: title,
+ onPressedFunction: () {
+ if (widget.mode == PasswordEntryMode.set) {
+ _showRecoveryCodeDialog(_passwordController1.text);
+ } else {
+ _updatePassword();
+ }
+ FocusScope.of(context).unfocus();
+ },
+ ),
+ floatingActionButtonLocation: fabLocation(),
+ floatingActionButtonAnimator: NoScalingAnimation(),
+ );
+ }
+
+ Widget _getBody(String buttonTextAndHeading) {
+ final email = widget.config.getEmail();
+ var passwordStrengthText = context.strings.weakStrength;
+ var passwordStrengthColor = Colors.redAccent;
+ if (_passwordStrength > kStrongPasswordStrengthThreshold) {
+ passwordStrengthText = context.strings.strongStrength;
+ passwordStrengthColor = Colors.greenAccent;
+ } else if (_passwordStrength > kMildPasswordStrengthThreshold) {
+ passwordStrengthText = context.strings.moderateStrength;
+ passwordStrengthColor = Colors.orangeAccent;
+ }
+ if (_volatilePassword != null) {
+ return Container();
+ }
+ return Column(
+ children: [
+ Expanded(
+ child: AutofillGroup(
+ child: FocusTraversalGroup(
+ policy: OrderedTraversalPolicy(),
+ child: ListView(
+ children: [
+ Padding(
+ padding: const EdgeInsets.symmetric(
+ vertical: 30,
+ horizontal: 20,
+ ),
+ child: Text(
+ buttonTextAndHeading,
+ style: Theme.of(context).textTheme.headlineMedium,
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20),
+ child: Text(
+ widget.mode == PasswordEntryMode.set
+ ? context.strings.enterPasswordToEncrypt
+ : context.strings.enterNewPasswordToEncrypt,
+ textAlign: TextAlign.start,
+ style: Theme.of(context)
+ .textTheme
+ .titleMedium!
+ .copyWith(fontSize: 14),
+ ),
+ ),
+ const Padding(padding: EdgeInsets.all(8)),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20),
+ child: StyledText(
+ text: context.strings.passwordWarning,
+ style: Theme.of(context)
+ .textTheme
+ .titleMedium!
+ .copyWith(fontSize: 14),
+ tags: {
+ 'underline': StyledTextTag(
+ style:
+ Theme.of(context).textTheme.titleMedium!.copyWith(
+ fontSize: 14,
+ decoration: TextDecoration.underline,
+ ),
+ ),
+ },
+ ),
+ ),
+ const Padding(padding: EdgeInsets.all(12)),
+ Visibility(
+ // hidden textForm for suggesting auto-fill service for saving
+ // password
+ visible: false,
+ child: TextFormField(
+ autofillHints: const [
+ AutofillHints.email,
+ ],
+ autocorrect: false,
+ keyboardType: TextInputType.emailAddress,
+ initialValue: email,
+ textInputAction: TextInputAction.next,
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
+ child: TextFormField(
+ autofillHints: const [AutofillHints.newPassword],
+ onFieldSubmitted: (_) {
+ do {
+ FocusScope.of(context).nextFocus();
+ } while (FocusScope.of(context).focusedChild!.context ==
+ null);
+ },
+ decoration: InputDecoration(
+ fillColor:
+ _isPasswordValid ? _validFieldValueColor : null,
+ filled: true,
+ hintText: context.strings.password,
+ contentPadding: const EdgeInsets.all(20),
+ border: UnderlineInputBorder(
+ borderSide: BorderSide.none,
+ borderRadius: BorderRadius.circular(6),
+ ),
+ suffixIcon: _password1InFocus
+ ? IconButton(
+ icon: Icon(
+ _password1Visible
+ ? Icons.visibility
+ : Icons.visibility_off,
+ color: Theme.of(context).iconTheme.color,
+ size: 20,
+ ),
+ onPressed: () {
+ setState(() {
+ _password1Visible = !_password1Visible;
+ });
+ },
+ )
+ : _isPasswordValid
+ ? Icon(
+ Icons.check,
+ color:
+ getEnteColorScheme(context).primary300,
+ )
+ : null,
+ ),
+ obscureText: !_password1Visible,
+ controller: _passwordController1,
+ autofocus: false,
+ autocorrect: false,
+ keyboardType: TextInputType.visiblePassword,
+ onChanged: (password) {
+ setState(() {
+ _passwordInInputBox = password;
+ _passwordStrength =
+ estimatePasswordStrength(password);
+ _isPasswordValid = _passwordStrength >=
+ kMildPasswordStrengthThreshold;
+ _passwordsMatch = _passwordInInputBox ==
+ _passwordInInputConfirmationBox;
+ });
+ },
+ textInputAction: TextInputAction.next,
+ focusNode: _password1FocusNode,
+ ),
+ ),
+ const SizedBox(height: 8),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
+ child: TextFormField(
+ keyboardType: TextInputType.visiblePassword,
+ controller: _passwordController2,
+ obscureText: !_password2Visible,
+ autofillHints: const [AutofillHints.newPassword],
+ onEditingComplete: () =>
+ TextInput.finishAutofillContext(),
+ decoration: InputDecoration(
+ fillColor:
+ _passwordsMatch ? _validFieldValueColor : null,
+ filled: true,
+ hintText: context.strings.confirmPassword,
+ contentPadding: const EdgeInsets.symmetric(
+ horizontal: 20,
+ vertical: 20,
+ ),
+ suffixIcon: _password2InFocus
+ ? IconButton(
+ icon: Icon(
+ _password2Visible
+ ? Icons.visibility
+ : Icons.visibility_off,
+ color: Theme.of(context).iconTheme.color,
+ size: 20,
+ ),
+ onPressed: () {
+ setState(() {
+ _password2Visible = !_password2Visible;
+ });
+ },
+ )
+ : _passwordsMatch
+ ? Icon(
+ Icons.check,
+ color:
+ getEnteColorScheme(context).primary300,
+ )
+ : null,
+ border: UnderlineInputBorder(
+ borderSide: BorderSide.none,
+ borderRadius: BorderRadius.circular(6),
+ ),
+ ),
+ focusNode: _password2FocusNode,
+ onChanged: (cnfPassword) {
+ setState(() {
+ _passwordInInputConfirmationBox = cnfPassword;
+ if (_passwordInInputBox != '') {
+ _passwordsMatch = _passwordInInputBox ==
+ _passwordInInputConfirmationBox;
+ }
+ });
+ },
+ ),
+ ),
+ Opacity(
+ opacity: (_passwordInInputBox != '') && _password1InFocus
+ ? 1
+ : 0,
+ child: Padding(
+ padding: const EdgeInsets.symmetric(
+ horizontal: 20,
+ vertical: 8,
+ ),
+ child: Text(
+ context.strings.passwordStrength(passwordStrengthText),
+ style: TextStyle(
+ color: passwordStrengthColor,
+ ),
+ ),
+ ),
+ ),
+ const SizedBox(height: 8),
+ GestureDetector(
+ behavior: HitTestBehavior.translucent,
+ onTap: () {
+ PlatformUtil.openWebView(
+ context,
+ context.strings.howItWorks,
+ "https://ente.io/architecture",
+ );
+ },
+ child: Container(
+ padding: const EdgeInsets.symmetric(horizontal: 20),
+ child: RichText(
+ text: TextSpan(
+ text: context.strings.howItWorks,
+ style:
+ Theme.of(context).textTheme.titleMedium!.copyWith(
+ fontSize: 14,
+ decoration: TextDecoration.underline,
+ ),
+ ),
+ ),
+ ),
+ ),
+ const Padding(padding: EdgeInsets.all(20)),
+ ],
+ ),
+ ),
+ ),
+ ),
+ ],
+ );
+ }
+
+ void _updatePassword() async {
+ final logOutFromOthers = await logOutFromOtherDevices(context);
+ final dialog =
+ createProgressDialog(context, context.strings.generatingEncryptionKeys);
+ await dialog.show();
+ try {
+ final result = await widget.config
+ .getAttributesForNewPassword(_passwordController1.text);
+ await UserService.instance.updateKeyAttributes(
+ result.item1,
+ result.item2,
+ logoutOtherDevices: logOutFromOthers,
+ );
+ await dialog.hide();
+ showShortToast(context, context.strings.passwordChangedSuccessfully);
+ Navigator.of(context).pop();
+ if (widget.mode == PasswordEntryMode.reset) {
+ Navigator.of(context).popUntil((route) => route.isFirst);
+ }
+ } catch (e, s) {
+ _logger.severe(e, s);
+ await dialog.hide();
+ // ignore: unawaited_futures
+ showGenericErrorDialog(
+ context: context,
+ error: e,
+ );
+ }
+ }
+
+ Future<bool> logOutFromOtherDevices(BuildContext context) async {
+ bool logOutFromOther = true;
+ await showChoiceDialog(
+ context,
+ title: context.strings.signOutFromOtherDevices,
+ body: context.strings.signOutOtherBody,
+ isDismissible: false,
+ firstButtonLabel: context.strings.signOutOtherDevices,
+ firstButtonType: ButtonType.critical,
+ firstButtonOnTap: () async {
+ logOutFromOther = true;
+ },
+ secondButtonLabel: context.strings.doNotSignOut,
+ secondButtonOnTap: () async {
+ logOutFromOther = false;
+ },
+ );
+ return logOutFromOther;
+ }
+
+ Future<void> _showRecoveryCodeDialog(
+ String password, {
+ bool usingVolatilePassword = false,
+ }) async {
+ final dialog = createProgressDialog(
+ context, context.strings.generatingEncryptionKeysTitle);
+ await dialog.show();
+ try {
+ if (usingVolatilePassword) {
+ _logger.info('Using volatile password');
+ }
+ final result = await widget.config.generateKey(password);
+ widget.config.resetVolatilePassword();
+ await dialog.hide();
+ onDone() async {
+ final dialog =
+ createProgressDialog(context, context.strings.pleaseWait);
+ await dialog.show();
+ try {
+ await UserService.instance.setAttributes(result);
+ await dialog.hide();
+ widget.config.resetVolatilePassword();
+ // ignore: unawaited_futures
+ Navigator.of(context).pushAndRemoveUntil(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return widget.homePage;
+ },
+ ),
+ (route) => route.isFirst,
+ );
+ } catch (e, s) {
+ _logger.severe(e, s);
+ await dialog.hide();
+ // ignore: unawaited_futures
+ showGenericErrorDialog(
+ context: context,
+ error: e,
+ );
+ }
+ }
+
+ // ignore: unawaited_futures
+ routeToPage(
+ context,
+ RecoveryKeyPage(
+ widget.config,
+ result.privateKeyAttributes.recoveryKey,
+ context.strings.continueLabel,
+ showAppBar: false,
+ isDismissible: false,
+ onDone: onDone,
+ showProgressBar: true,
+ ),
+ );
+ } catch (e) {
+ _logger.severe(e);
+ await dialog.hide();
+ if (e is UnsupportedError) {
+ // ignore: unawaited_futures
+ showErrorDialog(
+ context,
+ context.strings.insecureDevice,
+ context.strings.sorryWeCouldNotGenerateSecureKeysOnThisDevicennplease,
+ );
+ } else {
+ // ignore: unawaited_futures
+ showGenericErrorDialog(
+ context: context,
+ error: e,
+ );
+ }
+ }
+ }
+}
diff --git a/mobile/packages/accounts/lib/pages/password_reentry_page.dart b/mobile/packages/accounts/lib/pages/password_reentry_page.dart
new file mode 100644
index 0000000000..0de41c1992
--- /dev/null
+++ b/mobile/packages/accounts/lib/pages/password_reentry_page.dart
@@ -0,0 +1,332 @@
+import 'dart:async';
+import 'dart:typed_data';
+
+import 'package:ente_accounts/ente_accounts.dart';
+import 'package:ente_accounts/models/errors.dart';
+import 'package:ente_configuration/base_configuration.dart';
+import 'package:ente_ui/components/buttons/button_widget.dart';
+import 'package:ente_ui/components/buttons/dynamic_fab.dart';
+import 'package:ente_ui/pages/base_home_page.dart';
+import 'package:ente_ui/utils/dialog_util.dart';
+import 'package:ente_utils/email_util.dart';
+import 'package:flutter/material.dart';
+import 'package:ente_strings/ente_strings.dart';
+import 'package:logging/logging.dart';
+
+import 'package:ente_crypto_dart/ente_crypto_dart.dart';
+
+class PasswordReentryPage extends StatefulWidget {
+ final BaseHomePage homePage;
+ final BaseConfiguration config;
+
+ const PasswordReentryPage(this.homePage, this.config, {super.key});
+
+ @override
+ State<PasswordReentryPage> createState() => _PasswordReentryPageState();
+}
+
+class _PasswordReentryPageState extends State<PasswordReentryPage> {
+ final _logger = Logger((_PasswordReentryPageState).toString());
+ final _passwordController = TextEditingController();
+ final FocusNode _passwordFocusNode = FocusNode();
+ String? email;
+ bool _passwordInFocus = false;
+ bool _passwordVisible = false;
+ String? _volatilePassword;
+
+ @override
+ void initState() {
+ super.initState();
+ email = widget.config.getEmail();
+ _volatilePassword = widget.config.getVolatilePassword();
+ if (_volatilePassword != null) {
+ _passwordController.text = _volatilePassword!;
+ Future.delayed(
+ Duration.zero,
+ () => verifyPassword(_volatilePassword!, usingVolatilePassword: true),
+ );
+ }
+ _passwordFocusNode.addListener(() {
+ setState(() {
+ _passwordInFocus = _passwordFocusNode.hasFocus;
+ });
+ });
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
+
+ FloatingActionButtonLocation? fabLocation() {
+ if (isKeypadOpen) {
+ return null;
+ } else {
+ return FloatingActionButtonLocation.centerFloat;
+ }
+ }
+
+ return Scaffold(
+ resizeToAvoidBottomInset: isKeypadOpen,
+ appBar: AppBar(
+ elevation: 0,
+ leading: IconButton(
+ icon: const Icon(Icons.arrow_back),
+ color: Theme.of(context).iconTheme.color,
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
+ ),
+ ),
+ body: _getBody(),
+ floatingActionButton: DynamicFAB(
+ key: const ValueKey("verifyPasswordButton"),
+ isKeypadOpen: isKeypadOpen,
+ isFormValid: _passwordController.text.isNotEmpty,
+ buttonText: context.strings.verifyPassword,
+ onPressedFunction: () async {
+ FocusScope.of(context).unfocus();
+ await verifyPassword(_passwordController.text);
+ },
+ ),
+ floatingActionButtonLocation: fabLocation(),
+ floatingActionButtonAnimator: NoScalingAnimation(),
+ );
+ }
+
+ Future<void> verifyPassword(
+ String password, {
+ bool usingVolatilePassword = false,
+ }) async {
+ FocusScope.of(context).unfocus();
+ final dialog = createProgressDialog(context, context.strings.pleaseWait);
+ await dialog.show();
+ if (usingVolatilePassword) {
+ _logger.info("Using volatile password");
+ }
+ try {
+ final kek = await widget.config.decryptSecretsAndGetKeyEncKey(
+ password,
+ widget.config.getKeyAttributes()!,
+ );
+ _registerSRPForExistingUsers(kek).ignore();
+ } on KeyDerivationError catch (e, s) {
+ _logger.severe("Password verification failed", e, s);
+ await dialog.hide();
+ final dialogChoice = await showChoiceDialog(
+ context,
+ title: context.strings.recreatePasswordTitle,
+ body: context.strings.recreatePasswordBody,
+ firstButtonLabel: context.strings.useRecoveryKey,
+ );
+ if (dialogChoice!.action == ButtonAction.first) {
+ // ignore: unawaited_futures
+ Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return RecoveryPage(widget.homePage, widget.config);
+ },
+ ),
+ );
+ }
+ return;
+ } catch (e, s) {
+ _logger.severe("Password verification failed", e, s);
+ await dialog.hide();
+ final dialogChoice = await showChoiceDialog(
+ context,
+ title: context.strings.incorrectPasswordTitle,
+ body: context.strings.pleaseTryAgain,
+ firstButtonLabel: context.strings.contactSupport,
+ secondButtonLabel: context.strings.ok,
+ );
+ if (dialogChoice!.action == ButtonAction.first) {
+ await sendLogs(
+ context,
+ context.strings.contactSupport,
+ postShare: () {},
+ );
+ }
+ return;
+ }
+ widget.config.resetVolatilePassword();
+ await dialog.hide();
+ unawaited(
+ Navigator.of(context).pushAndRemoveUntil(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return widget.homePage;
+ },
+ ),
+ (route) => false,
+ ),
+ );
+ }
+
+ Future<void> _registerSRPForExistingUsers(Uint8List key) async {
+ bool shouldSetupSRP = false;
+ try {
+ // ignore: unused_local_variable
+ final attr = await UserService.instance.getSrpAttributes(email!);
+ } on SrpSetupNotCompleteError {
+ shouldSetupSRP = true;
+ } catch (e, s) {
+ _logger.severe("error while fetching attr", e, s);
+ }
+ if (shouldSetupSRP) {
+ try {
+ final Uint8List loginKey = await CryptoUtil.deriveLoginKey(key);
+ await UserService.instance.registerOrUpdateSrp(loginKey);
+ } catch (e, s) {
+ _logger.severe("error while setting up srp for existing users", e, s);
+ }
+ }
+ }
+
+ Widget _getBody() {
+ return Column(
+ children: [
+ Expanded(
+ child: AutofillGroup(
+ child: ListView(
+ children: [
+ Padding(
+ padding:
+ const EdgeInsets.symmetric(vertical: 30, horizontal: 20),
+ child: Text(
+ context.strings.welcomeBack,
+ style: Theme.of(context).textTheme.headlineMedium,
+ ),
+ ),
+ Visibility(
+ // hidden textForm for suggesting auto-fill service for saving
+ // password
+ visible: false,
+ child: TextFormField(
+ autofillHints: const [
+ AutofillHints.email,
+ ],
+ autocorrect: false,
+ keyboardType: TextInputType.emailAddress,
+ initialValue: email,
+ textInputAction: TextInputAction.next,
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(20, 24, 20, 0),
+ child: TextFormField(
+ key: const ValueKey("passwordInputField"),
+ autofillHints: const [AutofillHints.password],
+ decoration: InputDecoration(
+ hintText: context.strings.enterYourPasswordHint,
+ filled: true,
+ contentPadding: const EdgeInsets.all(20),
+ border: UnderlineInputBorder(
+ borderSide: BorderSide.none,
+ borderRadius: BorderRadius.circular(6),
+ ),
+ suffixIcon: _passwordInFocus
+ ? IconButton(
+ icon: Icon(
+ _passwordVisible
+ ? Icons.visibility
+ : Icons.visibility_off,
+ color: Theme.of(context).iconTheme.color,
+ size: 20,
+ ),
+ onPressed: () {
+ setState(() {
+ _passwordVisible = !_passwordVisible;
+ });
+ },
+ )
+ : null,
+ ),
+ style: const TextStyle(
+ fontSize: 14,
+ ),
+ controller: _passwordController,
+ autofocus: true,
+ autocorrect: false,
+ obscureText: !_passwordVisible,
+ keyboardType: TextInputType.visiblePassword,
+ focusNode: _passwordFocusNode,
+ onChanged: (_) {
+ setState(() {});
+ },
+ ),
+ ),
+ const Padding(
+ padding: EdgeInsets.symmetric(vertical: 18),
+ child: Divider(
+ thickness: 1,
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 20),
+ child: Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () {
+ Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return RecoveryPage(
+ widget.homePage,
+ widget.config,
+ );
+ },
+ ),
+ );
+ },
+ child: Center(
+ child: Text(
+ context.strings.forgotPassword,
+ style: Theme.of(context)
+ .textTheme
+ .titleMedium!
+ .copyWith(
+ fontSize: 14,
+ decoration: TextDecoration.underline,
+ ),
+ ),
+ ),
+ ),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () async {
+ final dialog = createProgressDialog(
+ context,
+ context.strings.pleaseWait,
+ );
+ await dialog.show();
+ await widget.config.logout();
+ await dialog.hide();
+ Navigator.of(context)
+ .popUntil((route) => route.isFirst);
+ },
+ child: Center(
+ child: Text(
+ context.strings.changeEmail,
+ style: Theme.of(context)
+ .textTheme
+ .titleMedium!
+ .copyWith(
+ fontSize: 14,
+ decoration: TextDecoration.underline,
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ],
+ );
+ }
+}
diff --git a/mobile/packages/accounts/lib/pages/recovery_key_page.dart b/mobile/packages/accounts/lib/pages/recovery_key_page.dart
new file mode 100644
index 0000000000..20f49b8f52
--- /dev/null
+++ b/mobile/packages/accounts/lib/pages/recovery_key_page.dart
@@ -0,0 +1,364 @@
+import 'dart:convert';
+import 'dart:io' as io;
+
+import 'package:bip39/bip39.dart' as bip39;
+import 'package:dotted_border/dotted_border.dart';
+import 'package:ente_configuration/base_configuration.dart';
+import 'package:ente_configuration/constants.dart';
+import 'package:ente_ui/components/buttons/gradient_button.dart';
+import 'package:ente_ui/theme/ente_theme.dart';
+import 'package:ente_ui/utils/toast_util.dart';
+import 'package:ente_utils/platform_util.dart';
+import 'package:ente_utils/share_utils.dart';
+import 'package:ente_strings/ente_strings.dart';
+import 'package:file_saver/file_saver.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:share_plus/share_plus.dart';
+import 'package:step_progress_indicator/step_progress_indicator.dart';
+
+class RecoveryKeyPage extends StatefulWidget {
+ final BaseConfiguration config;
+ final bool? showAppBar;
+ final String recoveryKey;
+ final String doneText;
+ final Function()? onDone;
+ final bool? isDismissible;
+ final String? title;
+ final String? text;
+ final String? subText;
+ final bool showProgressBar;
+
+ const RecoveryKeyPage(
+ this.config,
+ this.recoveryKey,
+ this.doneText, {
+ super.key,
+ this.showAppBar,
+ this.onDone,
+ this.isDismissible,
+ this.title,
+ this.text,
+ this.subText,
+ this.showProgressBar = false,
+ });
+
+ @override
+ State<RecoveryKeyPage> createState() => _RecoveryKeyPageState();
+}
+
+class _RecoveryKeyPageState extends State<RecoveryKeyPage> {
+ bool _hasTriedToSave = false;
+ late final io.File _recoveryKeyFile;
+
+ @override
+ void initState() {
+ super.initState();
+ _recoveryKeyFile = io.File(
+ "${widget.config.getTempDirectory()}ente-recovery-key.txt",
+ );
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final String recoveryKey = bip39.entropyToMnemonic(widget.recoveryKey);
+ if (recoveryKey.split(' ').length != mnemonicKeyWordCount) {
+ throw AssertionError(
+ 'recovery code should have $mnemonicKeyWordCount words',
+ );
+ }
+ final double topPadding = widget.showAppBar!
+ ? 40
+ : widget.showProgressBar
+ ? 32
+ : 120;
+
+ Future<void> copy() async {
+ await Clipboard.setData(
+ ClipboardData(
+ text: recoveryKey,
+ ),
+ );
+ showShortToast(
+ context,
+ context.strings.recoveryKeyCopiedToClipboard,
+ );
+ setState(() {
+ _hasTriedToSave = true;
+ });
+ }
+
+ return Scaffold(
+ appBar: widget.showProgressBar
+ ? AppBar(
+ automaticallyImplyLeading: false,
+ elevation: 0,
+ title: Hero(
+ tag: "recovery_key",
+ child: StepProgressIndicator(
+ totalSteps: 4,
+ currentStep: 3,
+ selectedColor: getEnteColorScheme(context).alternativeColor,
+ roundedEdges: const Radius.circular(10),
+ unselectedColor:
+ getEnteColorScheme(context).stepProgressUnselectedColor,
+ ),
+ ),
+ )
+ : widget.showAppBar!
+ ? AppBar(
+ elevation: 0,
+ title: Text(widget.title ?? context.strings.recoveryKey),
+ )
+ : null,
+ body: Padding(
+ padding: EdgeInsets.fromLTRB(20, topPadding, 20, 20),
+ child: LayoutBuilder(
+ builder: (context, constraints) {
+ return SingleChildScrollView(
+ child: ConstrainedBox(
+ constraints: BoxConstraints(
+ minWidth: constraints.maxWidth,
+ minHeight: constraints.maxHeight,
+ ),
+ child: IntrinsicHeight(
+ child: Column(
+ mainAxisSize: MainAxisSize.max,
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ widget.showAppBar!
+ ? const SizedBox.shrink()
+ : Text(
+ widget.title ?? context.strings.recoveryKey,
+ style: Theme.of(context).textTheme.headlineMedium,
+ ),
+ Padding(
+ padding: EdgeInsets.all(widget.showAppBar! ? 0 : 12),
+ ),
+ Text(
+ widget.text ??
+ context.strings.recoveryKeyOnForgotPassword,
+ style: Theme.of(context).textTheme.titleMedium,
+ ),
+ const Padding(padding: EdgeInsets.only(top: 24)),
+ Container(
+ padding: const EdgeInsets.all(1),
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(8),
+ gradient: LinearGradient(
+ begin: Alignment.topCenter,
+ end: Alignment.bottomCenter,
+ colors: [
+ getEnteColorScheme(context).primary500,
+ getEnteColorScheme(context).primary300,
+ ],
+ stops: [0.0, 0.9753],
+ ),
+ ),
+ child: DottedBorder(
+ options: const RoundedRectDottedBorderOptions(
+ padding: EdgeInsets.zero,
+ strokeWidth: 1,
+ color: Color(0xFF6B6B6B),
+ dashPattern: [6, 6],
+ radius: Radius.circular(8),
+ ),
+ child: SizedBox(
+ width: double.infinity,
+ child: Stack(
+ children: [
+ Column(
+ children: [
+ Builder(
+ builder: (context) {
+ final content = Container(
+ padding: const EdgeInsets.all(20),
+ width: double.infinity,
+ child: Text(
+ recoveryKey,
+ textAlign: TextAlign.justify,
+ style: Theme.of(context)
+ .textTheme
+ .bodyLarge,
+ ),
+ );
+
+ if (PlatformUtil.isMobile()) {
+ return GestureDetector(
+ onTap: () async => await copy(),
+ child: content,
+ );
+ } else {
+ return SelectableRegion(
+ focusNode: FocusNode(),
+ selectionControls:
+ PlatformUtil.selectionControls,
+ child: content,
+ );
+ }
+ },
+ ),
+ ],
+ ),
+ Positioned(
+ right: 0,
+ top: 0,
+ child: PlatformCopy(
+ onPressed: copy,
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.symmetric(vertical: 20),
+ child: Text(
+ widget.subText ??
+ context.strings.recoveryKeySaveDescription,
+ style: Theme.of(context).textTheme.bodyLarge,
+ ),
+ ),
+ Expanded(
+ child: Container(
+ alignment: Alignment.bottomCenter,
+ width: double.infinity,
+ padding: const EdgeInsets.fromLTRB(10, 10, 10, 42),
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.end,
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ children: _saveOptions(context, recoveryKey),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ );
+ },
+ ),
+ ),
+ );
+ }
+
+ List<Widget> _saveOptions(BuildContext context, String recoveryKey) {
+ final List<Widget> childrens = [];
+ if (!_hasTriedToSave) {
+ childrens.add(
+ SizedBox(
+ height: 56,
+ child: OutlinedButton(
+ onPressed: () async {
+ await _saveKeys();
+ },
+ child: Text(context.strings.doThisLater),
+ ),
+ ),
+ );
+ childrens.add(const SizedBox(height: 10));
+ }
+
+ childrens.add(
+ GradientButton(
+ onTap: () async {
+ await shareDialog(
+ context,
+ context.strings.recoveryKey,
+ saveAction: () async {
+ await _saveRecoveryKey(recoveryKey);
+ },
+ sendAction: () async {
+ await _shareRecoveryKey(recoveryKey);
+ },
+ );
+ },
+ text: context.strings.saveKey,
+ ),
+ );
+
+ if (_hasTriedToSave) {
+ childrens.add(const SizedBox(height: 10));
+ childrens.add(
+ SizedBox(
+ height: 56,
+ child: ElevatedButton(
+ child: Text(widget.doneText),
+ onPressed: () async {
+ await _saveKeys();
+ },
+ ),
+ ),
+ );
+ }
+ childrens.add(const SizedBox(height: 12));
+ return childrens;
+ }
+
+ Future _saveRecoveryKey(String recoveryKey) async {
+ final bytes = utf8.encode(recoveryKey);
+ final time = DateTime.now().millisecondsSinceEpoch;
+
+ await PlatformUtil.shareFile(
+ "ente_recovery_key_$time",
+ "txt",
+ bytes,
+ MimeType.text,
+ );
+
+ if (mounted) {
+ showToast(
+ context,
+ context.strings.recoveryKeySaved,
+ );
+ setState(() {
+ _hasTriedToSave = true;
+ });
+ }
+ }
+
+ Future _shareRecoveryKey(String recoveryKey) async {
+ if (_recoveryKeyFile.existsSync()) {
+ await _recoveryKeyFile.delete();
+ }
+ _recoveryKeyFile.writeAsStringSync(recoveryKey);
+ await Share.shareXFiles([XFile(_recoveryKeyFile.path)]);
+ Future.delayed(const Duration(milliseconds: 500), () {
+ if (mounted) {
+ setState(() {
+ _hasTriedToSave = true;
+ });
+ }
+ });
+ }
+
+ Future<void> _saveKeys() async {
+ Navigator.of(context).pop();
+ if (_recoveryKeyFile.existsSync()) {
+ await _recoveryKeyFile.delete();
+ }
+ widget.onDone!();
+ }
+}
+
+class PlatformCopy extends StatelessWidget {
+ const PlatformCopy({
+ super.key,
+ required this.onPressed,
+ });
+
+ final void Function() onPressed;
+
+ @override
+ Widget build(BuildContext context) {
+ return IconButton(
+ onPressed: () => onPressed(),
+ visualDensity: VisualDensity.compact,
+ icon: const Icon(
+ Icons.copy,
+ size: 16,
+ ),
+ );
+ }
+}
diff --git a/mobile/packages/accounts/lib/pages/recovery_page.dart b/mobile/packages/accounts/lib/pages/recovery_page.dart
new file mode 100644
index 0000000000..0901452a11
--- /dev/null
+++ b/mobile/packages/accounts/lib/pages/recovery_page.dart
@@ -0,0 +1,167 @@
+import 'package:ente_accounts/ente_accounts.dart';
+import 'package:ente_configuration/base_configuration.dart';
+import 'package:ente_ui/components/buttons/dynamic_fab.dart';
+import 'package:ente_ui/pages/base_home_page.dart';
+import 'package:ente_ui/utils/dialog_util.dart';
+import 'package:ente_ui/utils/toast_util.dart';
+import 'package:ente_strings/ente_strings.dart';
+import 'package:flutter/material.dart';
+
+class RecoveryPage extends StatefulWidget {
+ final BaseHomePage homePage;
+ final BaseConfiguration config;
+
+ const RecoveryPage(this.homePage, this.config, {super.key});
+
+ @override
+ State<RecoveryPage> createState() => _RecoveryPageState();
+}
+
+class _RecoveryPageState extends State<RecoveryPage> {
+ final _recoveryKey = TextEditingController();
+
+ Future<void> onPressed() async {
+ FocusScope.of(context).unfocus();
+ final dialog = createProgressDialog(context, "Decrypting...");
+ await dialog.show();
+ try {
+ await widget.config.recover(_recoveryKey.text.trim());
+ await dialog.hide();
+ showToast(context, "Recovery successful!");
+ await Navigator.of(context).pushReplacement(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return PopScope(
+ canPop: false,
+ child: PasswordEntryPage(
+ widget.config,
+ PasswordEntryMode.reset,
+ widget.homePage,
+ ),
+ );
+ },
+ ),
+ );
+ } catch (e) {
+ await dialog.hide();
+ String errMessage = 'The recovery key you entered is incorrect';
+ if (e is AssertionError) {
+ errMessage = '$errMessage : ${e.message}';
+ }
+ await showErrorDialog(context, "Incorrect recovery key", errMessage);
+ }
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
+ FloatingActionButtonLocation? fabLocation() {
+ if (isKeypadOpen) {
+ return null;
+ } else {
+ return FloatingActionButtonLocation.centerFloat;
+ }
+ }
+
+ return Scaffold(
+ resizeToAvoidBottomInset: isKeypadOpen,
+ appBar: AppBar(
+ elevation: 0,
+ leading: IconButton(
+ icon: const Icon(Icons.arrow_back),
+ color: Theme.of(context).iconTheme.color,
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
+ ),
+ ),
+ floatingActionButton: DynamicFAB(
+ isKeypadOpen: isKeypadOpen,
+ isFormValid: _recoveryKey.text.isNotEmpty,
+ buttonText: 'Recover',
+ onPressedFunction: onPressed,
+ ),
+ floatingActionButtonLocation: fabLocation(),
+ floatingActionButtonAnimator: NoScalingAnimation(),
+ body: Column(
+ children: [
+ Expanded(
+ child: ListView(
+ children: [
+ Padding(
+ padding:
+ const EdgeInsets.symmetric(vertical: 30, horizontal: 20),
+ child: Text(
+ context.strings.forgotPassword,
+ style: Theme.of(context).textTheme.headlineMedium,
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(20, 24, 20, 0),
+ child: TextFormField(
+ decoration: InputDecoration(
+ filled: true,
+ hintText: "Enter your recovery key",
+ contentPadding: const EdgeInsets.all(20),
+ border: UnderlineInputBorder(
+ borderSide: BorderSide.none,
+ borderRadius: BorderRadius.circular(6),
+ ),
+ ),
+ style: const TextStyle(
+ fontSize: 14,
+ fontFeatures: [FontFeature.tabularFigures()],
+ ),
+ controller: _recoveryKey,
+ autofocus: false,
+ autocorrect: false,
+ keyboardType: TextInputType.multiline,
+ maxLines: null,
+ onChanged: (_) {
+ setState(() {});
+ },
+ ),
+ ),
+ const Padding(
+ padding: EdgeInsets.symmetric(vertical: 18),
+ child: Divider(
+ thickness: 1,
+ ),
+ ),
+ Row(
+ children: [
+ GestureDetector(
+ behavior: HitTestBehavior.translucent,
+ onTap: () {
+ showErrorDialog(
+ context,
+ "Sorry",
+ "Due to the nature of our end-to-end encryption protocol, your data cannot be decrypted without your password or recovery key",
+ );
+ },
+ child: Container(
+ padding: const EdgeInsets.symmetric(horizontal: 20),
+ child: Center(
+ child: Text(
+ context.strings.noRecoveryKeyTitle,
+ style: Theme.of(context)
+ .textTheme
+ .titleMedium!
+ .copyWith(
+ fontSize: 14,
+ decoration: TextDecoration.underline,
+ ),
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ ],
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
diff --git a/mobile/packages/accounts/lib/pages/request_pwd_verification_page.dart b/mobile/packages/accounts/lib/pages/request_pwd_verification_page.dart
new file mode 100644
index 0000000000..0fa74243ad
--- /dev/null
+++ b/mobile/packages/accounts/lib/pages/request_pwd_verification_page.dart
@@ -0,0 +1,222 @@
+import "dart:convert";
+import "dart:typed_data";
+
+import "package:ente_configuration/base_configuration.dart";
+import "package:ente_ui/components/buttons/dynamic_fab.dart";
+import "package:ente_ui/theme/ente_theme.dart";
+import "package:ente_ui/utils/dialog_util.dart";
+import "package:ente_strings/ente_strings.dart";
+import 'package:ente_crypto_dart/ente_crypto_dart.dart';
+import 'package:flutter/material.dart';
+import "package:logging/logging.dart";
+
+typedef OnPasswordVerifiedFn = Future<void> Function(Uint8List bytes);
+
+class RequestPasswordVerificationPage extends StatefulWidget {
+ final BaseConfiguration config;
+ final OnPasswordVerifiedFn onPasswordVerified;
+ final Function? onPasswordError;
+
+ const RequestPasswordVerificationPage(
+ this.config, {
+ super.key,
+ required this.onPasswordVerified,
+ this.onPasswordError,
+ });
+
+ @override
+ State<RequestPasswordVerificationPage> createState() =>
+ _RequestPasswordVerificationPageState();
+}
+
+class _RequestPasswordVerificationPageState
+ extends State<RequestPasswordVerificationPage> {
+ final _logger = Logger((_RequestPasswordVerificationPageState).toString());
+ final _passwordController = TextEditingController();
+ final FocusNode _passwordFocusNode = FocusNode();
+ String? email;
+ bool _passwordInFocus = false;
+ bool _passwordVisible = false;
+
+ @override
+ void initState() {
+ super.initState();
+ email = widget.config.getEmail();
+ _passwordFocusNode.addListener(() {
+ setState(() {
+ _passwordInFocus = _passwordFocusNode.hasFocus;
+ });
+ });
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final isKeypadOpen = MediaQuery.of(context).viewInsets.bottom > 100;
+
+ FloatingActionButtonLocation? fabLocation() {
+ if (isKeypadOpen) {
+ return null;
+ } else {
+ return FloatingActionButtonLocation.centerFloat;
+ }
+ }
+
+ return Scaffold(
+ resizeToAvoidBottomInset: isKeypadOpen,
+ appBar: AppBar(
+ elevation: 0,
+ leading: IconButton(
+ icon: const Icon(Icons.arrow_back),
+ color: Theme.of(context).iconTheme.color,
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
+ ),
+ ),
+ body: _getBody(),
+ floatingActionButton: DynamicFAB(
+ key: const ValueKey("verifyPasswordButton"),
+ isKeypadOpen: isKeypadOpen,
+ isFormValid: _passwordController.text.isNotEmpty,
+ buttonText: context.strings.verifyPassword,
+ onPressedFunction: () async {
+ FocusScope.of(context).unfocus();
+ final dialog =
+ createProgressDialog(context, context.strings.pleaseWait);
+ await dialog.show();
+ try {
+ final attributes = widget.config.getKeyAttributes()!;
+ final Uint8List keyEncryptionKey = await CryptoUtil.deriveKey(
+ utf8.encode(_passwordController.text),
+ CryptoUtil.base642bin(attributes.kekSalt),
+ attributes.memLimit,
+ attributes.opsLimit,
+ );
+ CryptoUtil.decryptSync(
+ CryptoUtil.base642bin(attributes.encryptedKey),
+ keyEncryptionKey,
+ CryptoUtil.base642bin(attributes.keyDecryptionNonce),
+ );
+ await dialog.show();
+ // pop
+ await widget.onPasswordVerified(keyEncryptionKey);
+ await dialog.hide();
+ Navigator.of(context).pop(true);
+ } catch (e, s) {
+ _logger.severe("Error while verifying password", e, s);
+ await dialog.hide();
+ if (widget.onPasswordError != null) {
+ widget.onPasswordError!();
+ } else {
+ // ignore: unawaited_futures
+ showErrorDialog(
+ context,
+ context.strings.incorrectPasswordTitle,
+ context.strings.pleaseTryAgain,
+ );
+ }
+ }
+ },
+ ),
+ floatingActionButtonLocation: fabLocation(),
+ floatingActionButtonAnimator: NoScalingAnimation(),
+ );
+ }
+
+ Widget _getBody() {
+ return Column(
+ children: [
+ Expanded(
+ child: AutofillGroup(
+ child: ListView(
+ children: [
+ Padding(
+ padding: const EdgeInsets.only(top: 30, left: 20, right: 20),
+ child: Text(
+ context.strings.enterPassword,
+ style: Theme.of(context).textTheme.headlineMedium,
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.only(
+ bottom: 30,
+ left: 22,
+ right: 20,
+ ),
+ child: Text(
+ email ?? '',
+ style: getEnteTextTheme(context).smallMuted,
+ ),
+ ),
+ Visibility(
+ // hidden textForm for suggesting auto-fill service for saving
+ // password
+ visible: false,
+ child: TextFormField(
+ autofillHints: const [
+ AutofillHints.email,
+ ],
+ autocorrect: false,
+ keyboardType: TextInputType.emailAddress,
+ initialValue: email,
+ textInputAction: TextInputAction.next,
+ ),
+ ),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(20, 24, 20, 0),
+ child: TextFormField(
+ key: const ValueKey("passwordInputField"),
+ autofillHints: const [AutofillHints.password],
+ decoration: InputDecoration(
+ hintText: context.strings.enterYourPasswordHint,
+ filled: true,
+ contentPadding: const EdgeInsets.all(20),
+ border: UnderlineInputBorder(
+ borderSide: BorderSide.none,
+ borderRadius: BorderRadius.circular(6),
+ ),
+ suffixIcon: _passwordInFocus
+ ? IconButton(
+ icon: Icon(
+ _passwordVisible
+ ? Icons.visibility
+ : Icons.visibility_off,
+ color: Theme.of(context).iconTheme.color,
+ size: 20,
+ ),
+ onPressed: () {
+ setState(() {
+ _passwordVisible = !_passwordVisible;
+ });
+ },
+ )
+ : null,
+ ),
+ style: const TextStyle(
+ fontSize: 14,
+ ),
+ controller: _passwordController,
+ autofocus: true,
+ autocorrect: false,
+ obscureText: !_passwordVisible,
+ keyboardType: TextInputType.visiblePassword,
+ focusNode: _passwordFocusNode,
+ onChanged: (_) {
+ setState(() {});
+ },
+ ),
+ ),
+ const Padding(
+ padding: EdgeInsets.symmetric(vertical: 18),
+ child: Divider(
+ thickness: 1,
+ ),
+ ),
+ ],
+ ),
+ ),
+ ),
+ ],
+ );
+ }
+}
diff --git a/mobile/packages/accounts/lib/pages/sessions_page.dart b/mobile/packages/accounts/lib/pages/sessions_page.dart
new file mode 100644
index 0000000000..29774497ee
--- /dev/null
+++ b/mobile/packages/accounts/lib/pages/sessions_page.dart
@@ -0,0 +1,231 @@
+import 'package:ente_accounts/ente_accounts.dart';
+import 'package:ente_configuration/base_configuration.dart';
+import 'package:ente_ui/components/loading_widget.dart';
+import 'package:ente_ui/theme/ente_theme.dart';
+import 'package:ente_ui/utils/dialog_util.dart';
+import 'package:ente_ui/utils/toast_util.dart';
+import 'package:ente_strings/ente_strings.dart';
+import 'package:flutter/material.dart';
+import 'package:logging/logging.dart';
+import 'package:ente_utils/date_time_util.dart';
+
+class SessionsPage extends StatefulWidget {
+ final BaseConfiguration config;
+ const SessionsPage(
+ this.config, {
+ super.key,
+ });
+
+ @override
+ State<SessionsPage> createState() => _SessionsPageState();
+}
+
+class _SessionsPageState extends State<SessionsPage> {
+ Sessions? _sessions;
+ final Logger _logger = Logger("SessionsPageState");
+
+ @override
+ void initState() {
+ _fetchActiveSessions().onError((error, stackTrace) {
+ showToast(context, "Failed to fetch active sessions");
+ });
+ super.initState();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppBar(
+ elevation: 0,
+ title: Text(context.strings.activeSessions),
+ ),
+ body: _getBody(),
+ );
+ }
+
+ Widget _getBody() {
+ if (_sessions == null) {
+ return const Center(child: EnteLoadingWidget());
+ }
+ final List<Widget> rows = [];
+ rows.add(const Padding(padding: EdgeInsets.all(4)));
+ for (final session in _sessions!.sessions) {
+ rows.add(_getSessionWidget(session));
+ }
+ return SingleChildScrollView(
+ child: Column(
+ children: rows,
+ ),
+ );
+ }
+
+ Widget _getSessionWidget(Session session) {
+ final lastUsedTime =
+ DateTime.fromMicrosecondsSinceEpoch(session.lastUsedTime);
+ return Column(
+ children: [
+ InkWell(
+ onTap: () async {
+ _showSessionTerminationDialog(session);
+ },
+ child: Padding(
+ padding: const EdgeInsets.all(16),
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ _getUAWidget(session),
+ const Padding(padding: EdgeInsets.all(4)),
+ Row(
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
+ children: [
+ Flexible(
+ child: Text(
+ session.ip,
+ style: TextStyle(
+ color: Theme.of(context)
+ .colorScheme
+ .onSurface
+ .withOpacity(0.8),
+ fontSize: 14,
+ ),
+ ),
+ ),
+ const Padding(padding: EdgeInsets.all(8)),
+ Flexible(
+ child: Text(
+ getFormattedTime(lastUsedTime),
+ style: TextStyle(
+ color: Theme.of(context)
+ .colorScheme
+ .onSurface
+ .withOpacity(0.8),
+ fontSize: 12,
+ ),
+ ),
+ ),
+ ],
+ ),
+ ],
+ ),
+ ),
+ ),
+ const Divider(),
+ ],
+ );
+ }
+
+ Future<void> _terminateSession(Session session) async {
+ final dialog = createProgressDialog(context, context.strings.pleaseWait);
+ await dialog.show();
+ try {
+ await UserService.instance.terminateSession(session.token);
+ await _fetchActiveSessions();
+ await dialog.hide();
+ } catch (e) {
+ await dialog.hide();
+ _logger.severe('failed to terminate');
+ // ignore: unawaited_futures
+ showErrorDialog(
+ context,
+ context.strings.oops,
+ context.strings.somethingWentWrongPleaseTryAgain,
+ );
+ }
+ }
+
+ Future<void> _fetchActiveSessions() async {
+ _sessions = await UserService.instance.getActiveSessions().onError((e, s) {
+ _logger.severe("failed to fetch active sessions", e, s);
+ throw e!;
+ });
+ if (_sessions != null) {
+ _sessions!.sessions.sort((first, second) {
+ return second.lastUsedTime.compareTo(first.lastUsedTime);
+ });
+ if (mounted) {
+ setState(() {});
+ }
+ }
+ }
+
+ void _showSessionTerminationDialog(Session session) {
+ final isLoggingOutFromThisDevice =
+ session.token == widget.config.getToken();
+ Widget text;
+ if (isLoggingOutFromThisDevice) {
+ text = Text(
+ context.strings.thisWillLogYouOutOfThisDevice,
+ );
+ } else {
+ text = SingleChildScrollView(
+ child: Column(
+ children: [
+ Text(
+ context.strings.thisWillLogYouOutOfTheFollowingDevice,
+ ),
+ const Padding(padding: EdgeInsets.all(8)),
+ Text(
+ session.ua,
+ style: Theme.of(context).textTheme.bodySmall,
+ ),
+ ],
+ ),
+ );
+ }
+ final AlertDialog alert = AlertDialog(
+ title: Text(context.strings.terminateSession),
+ content: text,
+ actions: [
+ TextButton(
+ child: Text(
+ context.strings.terminate,
+ style: const TextStyle(
+ color: Colors.red,
+ ),
+ ),
+ onPressed: () async {
+ Navigator.of(context, rootNavigator: true).pop('dialog');
+ if (isLoggingOutFromThisDevice) {
+ await UserService.instance.logout(context);
+ } else {
+ await _terminateSession(session);
+ }
+ },
+ ),
+ TextButton(
+ child: Text(
+ context.strings.cancel,
+ style: TextStyle(
+ color: isLoggingOutFromThisDevice
+ ? getEnteColorScheme(context).alternativeColor
+ : getEnteColorScheme(context).textBase,
+ ),
+ ),
+ onPressed: () {
+ Navigator.of(context, rootNavigator: true).pop('dialog');
+ },
+ ),
+ ],
+ );
+
+ showDialog(
+ context: context,
+ builder: (BuildContext context) {
+ return alert;
+ },
+ );
+ }
+
+ Widget _getUAWidget(Session session) {
+ if (session.token == widget.config.getToken()) {
+ return Text(
+ context.strings.thisDevice,
+ style: TextStyle(
+ fontWeight: FontWeight.bold,
+ color: getEnteColorScheme(context).alternativeColor,
+ ),
+ );
+ }
+ return Text(session.prettyUA);
+ }
+}
diff --git a/mobile/packages/accounts/lib/pages/two_factor_authentication_page.dart b/mobile/packages/accounts/lib/pages/two_factor_authentication_page.dart
new file mode 100644
index 0000000000..58a7312e5a
--- /dev/null
+++ b/mobile/packages/accounts/lib/pages/two_factor_authentication_page.dart
@@ -0,0 +1,163 @@
+import 'package:ente_accounts/ente_accounts.dart';
+import 'package:ente_ui/theme/ente_theme.dart';
+import 'package:ente_strings/ente_strings.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:pinput/pinput.dart';
+import 'package:ente_ui/lifecycle_event_handler.dart';
+
+class TwoFactorAuthenticationPage extends StatefulWidget {
+ final String sessionID;
+
+ const TwoFactorAuthenticationPage(this.sessionID, {super.key});
+
+ @override
+ State<TwoFactorAuthenticationPage> createState() =>
+ _TwoFactorAuthenticationPageState();
+}
+
+class _TwoFactorAuthenticationPageState
+ extends State<TwoFactorAuthenticationPage> {
+ final _pinController = TextEditingController();
+ String _code = "";
+ late LifecycleEventHandler _lifecycleEventHandler;
+
+ @override
+ void initState() {
+ _lifecycleEventHandler = LifecycleEventHandler(
+ resumeCallBack: () async {
+ if (mounted) {
+ final data = await Clipboard.getData(Clipboard.kTextPlain);
+ if (data != null && data.text != null && data.text!.length == 6) {
+ _pinController.text = data.text!;
+ }
+ }
+ },
+ );
+ WidgetsBinding.instance.addObserver(_lifecycleEventHandler);
+ super.initState();
+ }
+
+ @override
+ void dispose() {
+ WidgetsBinding.instance.removeObserver(_lifecycleEventHandler);
+ super.dispose();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ final colorScheme = getEnteColorScheme(context);
+
+ final pinPutDecoration = PinTheme(
+ height: 45,
+ width: 45,
+ decoration: BoxDecoration(
+ border: Border.all(color: colorScheme.primary500),
+ borderRadius: BorderRadius.circular(15.0),
+ ),
+ );
+
+ return Scaffold(
+ appBar: AppBar(
+ title: Text(
+ context.strings.twoFactorAuthTitle,
+ ),
+ ),
+ body: _getBody(pinPutDecoration),
+ );
+ }
+
+ Widget _getBody(PinTheme pinPutDecoration) {
+ final colorScheme = getEnteColorScheme(context);
+ return Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ mainAxisAlignment: MainAxisAlignment.center,
+ mainAxisSize: MainAxisSize.max,
+ children: [
+ Text(
+ context.strings.enterCodeHint,
+ style: const TextStyle(
+ height: 1.4,
+ fontSize: 16,
+ ),
+ textAlign: TextAlign.center,
+ ),
+ const Padding(padding: EdgeInsets.all(32)),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(40, 0, 40, 0),
+ child: Pinput(
+ length: 6,
+ onCompleted: (String code) {
+ _verifyTwoFactorCode(code);
+ },
+ onChanged: (String pin) {
+ setState(() {
+ _code = pin;
+ });
+ },
+ controller: _pinController,
+ submittedPinTheme: pinPutDecoration.copyWith(
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(20.0),
+ border: Border.all(
+ color: colorScheme.primary500.withOpacity(0.5),
+ ),
+ ),
+ ),
+ defaultPinTheme: pinPutDecoration,
+ followingPinTheme: pinPutDecoration.copyWith(
+ decoration: BoxDecoration(
+ borderRadius: BorderRadius.circular(10.0),
+ border: Border.all(
+ color: colorScheme.primary500.withOpacity(0.5),
+ ),
+ ),
+ ),
+ autofocus: true,
+ ),
+ ),
+ const Padding(padding: EdgeInsets.all(24)),
+ Container(
+ padding: const EdgeInsets.fromLTRB(80, 0, 80, 0),
+ width: double.infinity,
+ height: 64,
+ child: OutlinedButton(
+ onPressed: _code.length == 6
+ ? () async {
+ await _verifyTwoFactorCode(_code);
+ }
+ : null,
+ child: Text(context.strings.verify),
+ ),
+ ),
+ const Padding(padding: EdgeInsets.all(30)),
+ GestureDetector(
+ behavior: HitTestBehavior.opaque,
+ onTap: () {
+ UserService.instance.recoverTwoFactor(
+ context,
+ widget.sessionID,
+ TwoFactorType.totp,
+ );
+ },
+ child: Container(
+ padding: const EdgeInsets.all(10),
+ child: Center(
+ child: Text(
+ context.strings.lostDeviceTitle,
+ style: const TextStyle(
+ decoration: TextDecoration.underline,
+ fontSize: 12,
+ ),
+ ),
+ ),
+ ),
+ ),
+ ],
+ );
+ }
+
+ Future<void> _verifyTwoFactorCode(String code) async {
+ await UserService.instance.verifyTwoFactor(context, widget.sessionID, code);
+ }
+}
diff --git a/mobile/packages/accounts/lib/pages/two_factor_recovery_page.dart b/mobile/packages/accounts/lib/pages/two_factor_recovery_page.dart
new file mode 100644
index 0000000000..12c6da59aa
--- /dev/null
+++ b/mobile/packages/accounts/lib/pages/two_factor_recovery_page.dart
@@ -0,0 +1,110 @@
+import 'package:ente_accounts/ente_accounts.dart';
+import 'package:ente_ui/theme/ente_theme.dart';
+import 'package:ente_utils/email_util.dart';
+import 'package:ente_strings/ente_strings.dart';
+import 'package:flutter/material.dart';
+
+class TwoFactorRecoveryPage extends StatefulWidget {
+ final String sessionID;
+ final String encryptedSecret;
+ final String secretDecryptionNonce;
+ final TwoFactorType type;
+
+ const TwoFactorRecoveryPage(
+ this.type,
+ this.sessionID,
+ this.encryptedSecret,
+ this.secretDecryptionNonce, {
+ super.key,
+ });
+
+ @override
+ State<TwoFactorRecoveryPage> createState() => _TwoFactorRecoveryPageState();
+}
+
+class _TwoFactorRecoveryPageState extends State<TwoFactorRecoveryPage> {
+ final _recoveryKey = TextEditingController();
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppBar(
+ title: Text(
+ context.strings.recoverAccount,
+ style: const TextStyle(
+ fontSize: 18,
+ ),
+ ),
+ ),
+ body: Column(
+ crossAxisAlignment: CrossAxisAlignment.stretch,
+ mainAxisAlignment: MainAxisAlignment.center,
+ mainAxisSize: MainAxisSize.max,
+ children: [
+ Padding(
+ padding: const EdgeInsets.fromLTRB(60, 0, 60, 0),
+ child: TextFormField(
+ decoration: InputDecoration(
+ hintText: context.strings.enterRecoveryKeyHint,
+ contentPadding: const EdgeInsets.all(20),
+ ),
+ style: const TextStyle(
+ fontSize: 14,
+ fontFeatures: [FontFeature.tabularFigures()],
+ ),
+ controller: _recoveryKey,
+ autofocus: false,
+ autocorrect: false,
+ keyboardType: TextInputType.multiline,
+ maxLines: null,
+ onChanged: (_) {
+ setState(() {});
+ },
+ ),
+ ),
+ const Padding(padding: EdgeInsets.all(24)),
+ Container(
+ padding: const EdgeInsets.fromLTRB(80, 0, 80, 0),
+ width: double.infinity,
+ height: 64,
+ child: OutlinedButton(
+ onPressed: _recoveryKey.text.isNotEmpty
+ ? () async {
+ await UserService.instance.removeTwoFactor(
+ context,
+ widget.type,
+ widget.sessionID,
+ _recoveryKey.text,
+ widget.encryptedSecret,
+ widget.secretDecryptionNonce,
+ );
+ }
+ : null,
+ child: Text(context.strings.recover),
+ ),
+ ),
+ GestureDetector(
+ behavior: HitTestBehavior.translucent,
+ onTap: () async {
+ await openSupportPage(null, null);
+ },
+ child: Container(
+ padding: const EdgeInsets.all(40),
+ child: Center(
+ child: Text(
+ context.strings.noRecoveryKeyTitle,
+ style: TextStyle(
+ decoration: TextDecoration.underline,
+ fontSize: 12,
+ color:
+ getEnteColorScheme(context).textBase.withOpacity(0.9),
+ ),
+ ),
+ ),
+ ),
+ ),
+ ],
+ ),
+ );
+ }
+}
diff --git a/mobile/packages/accounts/lib/services/passkey_service.dart b/mobile/packages/accounts/lib/services/passkey_service.dart
new file mode 100644
index 0000000000..427272a743
--- /dev/null
+++ b/mobile/packages/accounts/lib/services/passkey_service.dart
@@ -0,0 +1,57 @@
+import 'package:ente_accounts/services/user_service.dart';
+import 'package:ente_network/network.dart';
+import 'package:ente_ui/utils/dialog_util.dart';
+import 'package:flutter/widgets.dart';
+import 'package:logging/logging.dart';
+import 'package:url_launcher/url_launcher_string.dart';
+
+class PasskeyService {
+ PasskeyService._privateConstructor();
+ static final PasskeyService instance = PasskeyService._privateConstructor();
+
+ final _enteDio = Network.instance.enteDio;
+
+ Future<String> getAccountsUrl() async {
+ final response = await _enteDio.get(
+ "/users/accounts-token",
+ );
+ final accountsUrl = response.data!["accountsUrl"] ?? kAccountsUrl;
+ final jwtToken = response.data!["accountsToken"] as String;
+ return "$accountsUrl/passkeys?token=$jwtToken";
+ }
+
+ Future<bool> isPasskeyRecoveryEnabled() async {
+ final response = await _enteDio.get(
+ "/users/two-factor/recovery-status",
+ );
+ return response.data!["isPasskeyRecoveryEnabled"] as bool;
+ }
+
+ Future<void> configurePasskeyRecovery(
+ String secret,
+ String userEncryptedSecret,
+ String userSecretNonce,
+ ) async {
+ await _enteDio.post(
+ "/users/two-factor/passkeys/configure-recovery",
+ data: {
+ "secret": secret,
+ "userSecretCipher": userEncryptedSecret,
+ "userSecretNonce": userSecretNonce,
+ },
+ );
+ }
+
+ Future<void> openPasskeyPage(BuildContext context) async {
+ try {
+ final url = await getAccountsUrl();
+ await launchUrlString(
+ url,
+ mode: LaunchMode.externalApplication,
+ );
+ } catch (e) {
+ Logger('PasskeyService').severe("failed to open passkey page", e);
+ showGenericErrorDialog(context: context, error: e).ignore();
+ }
+ }
+}
diff --git a/mobile/packages/accounts/lib/services/user_service.dart b/mobile/packages/accounts/lib/services/user_service.dart
new file mode 100644
index 0000000000..8af3d55973
--- /dev/null
+++ b/mobile/packages/accounts/lib/services/user_service.dart
@@ -0,0 +1,1091 @@
+import 'dart:async';
+import "dart:convert";
+import "dart:math";
+
+import 'package:bip39/bip39.dart' as bip39;
+import 'package:dio/dio.dart';
+import 'package:ente_accounts/models/delete_account.dart';
+import 'package:ente_accounts/models/errors.dart';
+import 'package:ente_accounts/models/sessions.dart';
+import 'package:ente_accounts/models/set_keys_request.dart';
+import 'package:ente_accounts/models/set_recovery_key_request.dart';
+import 'package:ente_accounts/models/srp.dart';
+import 'package:ente_accounts/models/two_factor.dart';
+import 'package:ente_accounts/models/user_details.dart';
+import 'package:ente_accounts/pages/login_page.dart';
+import 'package:ente_accounts/pages/ott_verification_page.dart';
+import 'package:ente_accounts/pages/passkey_page.dart';
+import 'package:ente_accounts/pages/password_entry_page.dart';
+import 'package:ente_accounts/pages/password_reentry_page.dart';
+import 'package:ente_accounts/pages/recovery_page.dart';
+import 'package:ente_accounts/pages/two_factor_authentication_page.dart';
+import 'package:ente_accounts/pages/two_factor_recovery_page.dart';
+import 'package:ente_configuration/base_configuration.dart';
+import 'package:ente_configuration/constants.dart';
+import 'package:ente_network/network.dart';
+import 'package:ente_ui/components/progress_dialog.dart';
+import 'package:ente_ui/pages/base_home_page.dart';
+import 'package:ente_ui/utils/dialog_util.dart';
+import 'package:ente_ui/utils/toast_util.dart';
+import 'package:ente_base/models/key_attributes.dart';
+import 'package:ente_base/models/key_gen_result.dart';
+import 'package:ente_events/event_bus.dart';
+import 'package:ente_events/models/user_details_changed_event.dart';
+import 'package:ente_strings/ente_strings.dart';
+import 'package:ente_crypto_dart/ente_crypto_dart.dart';
+import "package:flutter/foundation.dart";
+import 'package:flutter/material.dart';
+import 'package:logging/logging.dart';
+import "package:pointycastle/export.dart";
+import "package:pointycastle/srp/srp6_client.dart";
+import "package:pointycastle/srp/srp6_standard_groups.dart";
+import "package:pointycastle/srp/srp6_util.dart";
+import "package:pointycastle/srp/srp6_verifier_generator.dart";
+import 'package:shared_preferences/shared_preferences.dart';
+import "package:uuid/uuid.dart";
+
+const String kAccountsUrl = "https://accounts.ente.io";
+
+class UserService {
+ static const keyHasEnabledTwoFactor = "has_enabled_two_factor";
+ static const keyUserDetails = "user_details";
+ static const kReferralSource = "referral_source";
+ static const kCanDisableEmailMFA = "can_disable_email_mfa";
+ static const kIsEmailMFAEnabled = "is_email_mfa_enabled";
+ final SRP6GroupParameters kDefaultSrpGroup = SRP6StandardGroups.rfc5054_4096;
+ final _dio = Network.instance.getDio();
+ final _enteDio = Network.instance.enteDio;
+ final _logger = Logger((UserService).toString());
+ late SharedPreferences _preferences;
+ late ValueNotifier<String?> emailValueNotifier;
+ late BaseConfiguration _config;
+ late BaseHomePage _homePage;
+
+ UserService._privateConstructor();
+
+ static final UserService instance = UserService._privateConstructor();
+
+ Future<void> init(BaseConfiguration config, BaseHomePage homePage) async {
+ _config = config;
+ _homePage = homePage;
+ emailValueNotifier = ValueNotifier<String?>(config.getEmail());
+ _preferences = await SharedPreferences.getInstance();
+ }
+
+ Future<void> sendOtt(
+ BuildContext context,
+ String email, {
+ bool isChangeEmail = false,
+ bool isCreateAccountScreen = false,
+ bool isResetPasswordScreen = false,
+ String? purpose,
+ }) async {
+ final dialog = createProgressDialog(context, context.strings.pleaseWait);
+ await dialog.show();
+ try {
+ final response = await _dio.post(
+ "${_config.getHttpEndpoint()}/users/ott",
+ data: {
+ "email": email,
+ "purpose": isChangeEmail ? "change" : purpose ?? "",
+ },
+ );
+ await dialog.hide();
+ if (response.statusCode == 200) {
+ unawaited(
+ Navigator.of(context).push(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return OTTVerificationPage(
+ email,
+ isChangeEmail: isChangeEmail,
+ isCreateAccountScreen: isCreateAccountScreen,
+ isResetPasswordScreen: isResetPasswordScreen,
+ );
+ },
+ ),
+ ),
+ );
+ return;
+ }
+ unawaited(showGenericErrorDialog(context: context, error: null));
+ } on DioException catch (e) {
+ await dialog.hide();
+ _logger.info(e);
+ final String? enteErrCode = e.response?.data["code"];
+ if (enteErrCode != null && enteErrCode == "USER_ALREADY_REGISTERED") {
+ unawaited(
+ showErrorDialog(
+ context,
+ context.strings.oops,
+ context.strings.emailAlreadyRegistered,
+ ),
+ );
+ } else if (enteErrCode != null && enteErrCode == "USER_NOT_REGISTERED") {
+ unawaited(
+ showErrorDialog(
+ context,
+ context.strings.oops,
+ context.strings.emailNotRegistered,
+ ),
+ );
+ } else if (e.response != null && e.response!.statusCode == 403) {
+ unawaited(
+ showErrorDialog(
+ context,
+ context.strings.oops,
+ context.strings.thisEmailIsAlreadyInUse,
+ ),
+ );
+ } else {
+ unawaited(showGenericErrorDialog(context: context, error: e));
+ }
+ } catch (e) {
+ await dialog.hide();
+ _logger.severe(e);
+ unawaited(showGenericErrorDialog(context: context, error: e));
+ }
+ }
+
+ Future<void> sendFeedback(
+ BuildContext context,
+ String feedback, {
+ String type = "SubCancellation",
+ }) async {
+ await _dio.post(
+ "${_config.getHttpEndpoint()}/anonymous/feedback",
+ data: {"feedback": feedback, "type": "type"},
+ );
+ }
+
+ Future<UserDetails> getUserDetailsV2({
+ bool memoryCount = false,
+ bool shouldCache = true,
+ }) async {
+ try {
+ final response = await _enteDio.get(
+ "/users/details/v2",
+ queryParameters: {
+ "memoryCount": memoryCount,
+ },
+ );
+ final userDetails = UserDetails.fromMap(response.data);
+ if (shouldCache) {
+ if (userDetails.profileData != null) {
+ await _preferences.setBool(
+ kIsEmailMFAEnabled,
+ userDetails.profileData!.isEmailMFAEnabled,
+ );
+ await _preferences.setBool(
+ kCanDisableEmailMFA,
+ userDetails.profileData!.canDisableEmailMFA,
+ );
+ }
+ // handle email change from different client
+ if (userDetails.email != _config.getEmail()) {
+ await setEmail(userDetails.email);
+ }
+ }
+ return userDetails;
+ } catch (e) {
+ _logger.warning("Failed to fetch", e);
+ if (e is DioException && e.response?.statusCode == 401) {
+ throw UnauthorizedError();
+ } else {
+ rethrow;
+ }
+ }
+ }
+
+ UserDetails? getCachedUserDetails() {
+ if (_preferences.containsKey(keyUserDetails)) {
+ return UserDetails.fromJson(_preferences.getString(keyUserDetails)!);
+ }
+ return null;
+ }
+
+ Future<Sessions> getActiveSessions() async {
+ try {
+ final response = await _enteDio.get("/users/sessions");
+ return Sessions.fromMap(response.data);
+ } on DioException catch (e) {
+ _logger.info(e);
+ rethrow;
+ }
+ }
+
+ Future<void> terminateSession(String token) async {
+ try {
+ await _enteDio.delete(
+ "/users/session",
+ queryParameters: {
+ "token": token,
+ },
+ );
+ } on DioException catch (e) {
+ _logger.info(e);
+ rethrow;
+ }
+ }
+
+ Future<void> leaveFamilyPlan() async {
+ try {
+ await _enteDio.delete("/family/leave");
+ } on DioException catch (e) {
+ _logger.warning('failed to leave family plan', e);
+ rethrow;
+ }
+ }
+
+ Future<void> logout(BuildContext context) async {
+ try {
+ final response = await _enteDio.post("/users/logout");
+ if (response.statusCode == 200) {
+ await _config.logout();
+ Navigator.of(context).popUntil((route) => route.isFirst);
+ } else {
+ throw Exception("Log out action failed");
+ }
+ } catch (e) {
+ _logger.severe(e);
+ // check if token is already invalid
+ if (e is DioException && e.response?.statusCode == 401) {
+ await _config.logout();
+ Navigator.of(context).popUntil((route) => route.isFirst);
+ return;
+ }
+ //This future is for waiting for the dialog from which logout() is called
+ //to close and only then to show the error dialog.
+ Future.delayed(
+ const Duration(milliseconds: 150),
+ () => showGenericErrorDialog(context: context, error: e),
+ );
+ rethrow;
+ }
+ }
+
+ Future<DeleteChallengeResponse?> getDeleteChallenge(
+ BuildContext context,
+ ) async {
+ try {
+ final response = await _enteDio.get("/users/delete-challenge");
+ if (response.statusCode == 200) {
+ return DeleteChallengeResponse(
+ allowDelete: response.data["allowDelete"] as bool,
+ encryptedChallenge: response.data["encryptedChallenge"],
+ );
+ } else {
+ throw Exception("delete action failed");
+ }
+ } catch (e) {
+ _logger.severe(e);
+ await showGenericErrorDialog(
+ context: context,
+ error: e,
+ );
+ return null;
+ }
+ }
+
+ Future<void> deleteAccount(
+ BuildContext context,
+ String challengeResponse,
+ ) async {
+ try {
+ final response = await _enteDio.delete(
+ "/users/delete",
+ data: {
+ "challenge": challengeResponse,
+ },
+ );
+ if (response.statusCode == 200) {
+ // clear data
+ await _config.logout();
+ } else {
+ throw Exception("delete action failed");
+ }
+ } catch (e) {
+ _logger.severe(e);
+ rethrow;
+ }
+ }
+
+ Future<dynamic> getTokenForPasskeySession(String sessionID) async {
+ try {
+ final response = await _dio.get(
+ "${_config.getHttpEndpoint()}/users/two-factor/passkeys/get-token",
+ queryParameters: {
+ "sessionID": sessionID,
+ },
+ );
+ return response.data;
+ } on DioException catch (e) {
+ if (e.response != null) {
+ if (e.response!.statusCode == 404 || e.response!.statusCode == 410) {
+ throw PassKeySessionExpiredError();
+ }
+ if (e.response!.statusCode == 400) {
+ throw PassKeySessionNotVerifiedError();
+ }
+ }
+ rethrow;
+ } catch (e, s) {
+ _logger.severe("unexpected error", e, s);
+ rethrow;
+ }
+ }
+
+ Future<void> onPassKeyVerified(BuildContext context, Map response) async {
+ final ProgressDialog dialog =
+ createProgressDialog(context, context.strings.pleaseWait);
+ await dialog.show();
+ try {
+ final userPassword = _config.getVolatilePassword();
+ await _saveConfiguration(response);
+ if (userPassword == null) {
+ await dialog.hide();
+ // ignore: unawaited_futures
+ Navigator.of(context).pushAndRemoveUntil(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return PasswordReentryPage(_homePage, _config);
+ },
+ ),
+ (route) => route.isFirst,
+ );
+ } else {
+ Widget page;
+ if (_config.getEncryptedToken() != null) {
+ await _config.decryptSecretsAndGetKeyEncKey(
+ userPassword,
+ _config.getKeyAttributes()!,
+ );
+ _config.resetVolatilePassword();
+ page = _homePage;
+ } else {
+ throw Exception("unexpected response during passkey verification");
+ }
+ await dialog.hide();
+
+ // ignore: unawaited_futures
+ Navigator.of(context).pushAndRemoveUntil(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return page;
+ },
+ ),
+ (route) => route.isFirst,
+ );
+ }
+ } catch (e) {
+ _logger.severe(e);
+ await dialog.hide();
+ rethrow;
+ }
+ }
+
+ Future<void> verifyEmail(
+ BuildContext context,
+ String ott, {
+ bool isResettingPasswordScreen = false,
+ }) async {
+ final dialog = createProgressDialog(context, context.strings.pleaseWait);
+ await dialog.show();
+ final verifyData = {
+ "email": _config.getEmail(),
+ "ott": ott,
+ };
+ if (!_config.isLoggedIn()) {
+ verifyData["source"] = 'auth:${_getRefSource()}';
+ }
+ try {
+ final response = await _dio.post(
+ "${_config.getHttpEndpoint()}/users/verify-email",
+ data: verifyData,
+ );
+ await dialog.hide();
+ 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) {
+ twoFASessionID = response.data["twoFactorSessionIDV2"];
+ }
+ if (passkeySessionID.isNotEmpty) {
+ page = PasskeyPage(
+ _config,
+ passkeySessionID,
+ totp2FASessionID: twoFASessionID,
+ accountsUrl: accountsUrl,
+ );
+ } else if (twoFASessionID.isNotEmpty) {
+ page = TwoFactorAuthenticationPage(twoFASessionID);
+ } else {
+ await _saveConfiguration(response);
+ if (_config.getEncryptedToken() != null) {
+ if (isResettingPasswordScreen) {
+ page = RecoveryPage(_homePage, _config);
+ } else {
+ page = PasswordReentryPage(_homePage, _config);
+ }
+ } else {
+ page = PasswordEntryPage(
+ _config,
+ PasswordEntryMode.set,
+ _homePage,
+ );
+ }
+ }
+ // ignore: unawaited_futures
+ Navigator.of(context).pushAndRemoveUntil(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return page;
+ },
+ ),
+ (route) => route.isFirst,
+ );
+ } else {
+ // should never reach here
+ throw Exception("unexpected response during email verification");
+ }
+ } on DioException catch (e) {
+ _logger.info(e);
+ await dialog.hide();
+ if (e.response != null && e.response!.statusCode == 410) {
+ await showErrorDialog(
+ context,
+ context.strings.oops,
+ context.strings.yourVerificationCodeHasExpired,
+ );
+ Navigator.of(context).pop();
+ } else {
+ // ignore: unawaited_futures
+ showErrorDialog(
+ context,
+ context.strings.incorrectCode,
+ context.strings.sorryTheCodeYouveEnteredIsIncorrect,
+ );
+ }
+ } catch (e) {
+ await dialog.hide();
+ _logger.severe(e);
+ // ignore: unawaited_futures
+ showErrorDialog(
+ context,
+ context.strings.oops,
+ context.strings.verificationFailedPleaseTryAgain,
+ );
+ }
+ }
+
+ Future<void> setEmail(String email) async {
+ await _config.setEmail(email);
+ emailValueNotifier.value = email;
+ }
+
+ Future<void> changeEmail(
+ BuildContext context,
+ String email,
+ String ott,
+ ) async {
+ final dialog = createProgressDialog(context, context.strings.pleaseWait);
+ await dialog.show();
+ try {
+ final response = await _enteDio.post(
+ "/users/change-email",
+ data: {
+ "email": email,
+ "ott": ott,
+ },
+ );
+ await dialog.hide();
+ if (response.statusCode == 200) {
+ showShortToast(context, context.strings.emailChangedTo(email));
+ await setEmail(email);
+ Navigator.of(context).popUntil((route) => route.isFirst);
+ Bus.instance.fire(UserDetailsChangedEvent());
+ return;
+ }
+ // ignore: unawaited_futures
+ showErrorDialog(
+ context,
+ context.strings.oops,
+ context.strings.verificationFailedPleaseTryAgain,
+ );
+ } on DioException catch (e) {
+ await dialog.hide();
+ if (e.response != null && e.response!.statusCode == 403) {
+ // ignore: unawaited_futures
+ showErrorDialog(
+ context,
+ context.strings.oops,
+ context.strings.thisEmailIsAlreadyInUse,
+ );
+ } else {
+ // ignore: unawaited_futures
+ showErrorDialog(
+ context,
+ context.strings.incorrectCode,
+ context.strings.authenticationFailedPleaseTryAgain,
+ );
+ }
+ } catch (e) {
+ await dialog.hide();
+ _logger.severe(e);
+ // ignore: unawaited_futures
+ showErrorDialog(
+ context,
+ context.strings.oops,
+ context.strings.verificationFailedPleaseTryAgain,
+ );
+ }
+ }
+
+ Future<void> setAttributes(KeyGenResult result) async {
+ try {
+ await registerOrUpdateSrp(result.loginKey);
+ await _enteDio.put(
+ "/users/attributes",
+ data: {
+ "keyAttributes": result.keyAttributes.toMap(),
+ },
+ );
+ await _config.setKey(result.privateKeyAttributes.key);
+ await _config.setSecretKey(result.privateKeyAttributes.secretKey);
+ await _config.setKeyAttributes(result.keyAttributes);
+ } catch (e) {
+ _logger.severe(e);
+ rethrow;
+ }
+ }
+
+ Future<SrpAttributes> getSrpAttributes(String email) async {
+ try {
+ final response = await _dio.get(
+ "${_config.getHttpEndpoint()}/users/srp/attributes",
+ queryParameters: {
+ "email": email,
+ },
+ );
+ if (response.statusCode == 200) {
+ return SrpAttributes.fromMap(response.data);
+ } else {
+ throw Exception("get-srp-attributes action failed");
+ }
+ } on DioException catch (e) {
+ if (e.response != null && e.response!.statusCode == 404) {
+ throw SrpSetupNotCompleteError();
+ }
+ rethrow;
+ } catch (e) {
+ rethrow;
+ }
+ }
+
+ Future<void> registerOrUpdateSrp(
+ Uint8List loginKey, {
+ SetKeysRequest? setKeysRequest,
+ bool logOutOtherDevices = false,
+ }) async {
+ try {
+ final String username = const Uuid().v4().toString();
+ final SecureRandom random = _getSecureRandom();
+ final Uint8List identity = Uint8List.fromList(utf8.encode(username));
+ final Uint8List password = loginKey;
+ final Uint8List salt = random.nextBytes(16);
+ final gen = SRP6VerifierGenerator(
+ group: kDefaultSrpGroup,
+ digest: Digest('SHA-256'),
+ );
+ final v = gen.generateVerifier(salt, identity, password);
+
+ final client = SRP6Client(
+ group: kDefaultSrpGroup,
+ digest: Digest('SHA-256'),
+ random: random,
+ );
+
+ final A = client.generateClientCredentials(salt, identity, password);
+ final request = SetupSRPRequest(
+ srpUserID: username,
+ srpSalt: base64Encode(salt),
+ srpVerifier: base64Encode(SRP6Util.encodeBigInt(v)),
+ srpA: base64Encode(SRP6Util.encodeBigInt(A!)),
+ isUpdate: false,
+ );
+ final response = await _enteDio.post(
+ "/users/srp/setup",
+ data: request.toMap(),
+ );
+ if (response.statusCode == 200) {
+ final SetupSRPResponse setupSRPResponse =
+ SetupSRPResponse.fromJson(response.data);
+ final serverB =
+ SRP6Util.decodeBigInt(base64Decode(setupSRPResponse.srpB));
+ // ignore: unused_local_variable
+ final clientS = client.calculateSecret(serverB);
+ final clientM = client.calculateClientEvidenceMessage();
+
+ if (setKeysRequest == null) {
+ await _enteDio.post(
+ "/users/srp/complete",
+ data: {
+ 'setupID': setupSRPResponse.setupID,
+ 'srpM1': base64Encode(SRP6Util.encodeBigInt(clientM!)),
+ },
+ );
+ } else {
+ await _enteDio.post(
+ "/users/srp/update",
+ data: {
+ 'setupID': setupSRPResponse.setupID,
+ 'srpM1': base64Encode(SRP6Util.encodeBigInt(clientM!)),
+ 'updatedKeyAttr': setKeysRequest.toMap(),
+ 'logOutOtherDevices': logOutOtherDevices,
+ },
+ );
+ }
+ } else {
+ throw Exception("register-srp action failed");
+ }
+ } catch (e, s) {
+ _logger.severe("failed to register srp", e, s);
+ rethrow;
+ }
+ }
+
+ SecureRandom _getSecureRandom() {
+ final List<int> seeds = [];
+ final random = Random.secure();
+ for (int i = 0; i < 32; i++) {
+ seeds.add(random.nextInt(255));
+ }
+ final secureRandom = FortunaRandom();
+ secureRandom.seed(KeyParameter(Uint8List.fromList(seeds)));
+ return secureRandom;
+ }
+
+ Future<void> verifyEmailViaPassword(
+ BuildContext context,
+ SrpAttributes srpAttributes,
+ String userPassword,
+ ProgressDialog dialog,
+ ) async {
+ late Uint8List keyEncryptionKey;
+ _logger.finest('Start deriving key');
+ keyEncryptionKey = await CryptoUtil.deriveKey(
+ utf8.encode(userPassword),
+ CryptoUtil.base642bin(srpAttributes.kekSalt),
+ srpAttributes.memLimit,
+ srpAttributes.opsLimit,
+ );
+ _logger.finest('keyDerivation done, derive LoginKey');
+ final loginKey = await CryptoUtil.deriveLoginKey(keyEncryptionKey);
+ final Uint8List identity = Uint8List.fromList(
+ utf8.encode(srpAttributes.srpUserID),
+ );
+ _logger.finest('longinKey derivation done');
+ final Uint8List salt = base64Decode(srpAttributes.srpSalt);
+ final Uint8List password = loginKey;
+ final SecureRandom random = _getSecureRandom();
+
+ final client = SRP6Client(
+ group: kDefaultSrpGroup,
+ digest: Digest('SHA-256'),
+ random: random,
+ );
+
+ final A = client.generateClientCredentials(salt, identity, password);
+ final createSessionResponse = await _dio.post(
+ "${_config.getHttpEndpoint()}/users/srp/create-session",
+ data: {
+ "srpUserID": srpAttributes.srpUserID,
+ "srpA": base64Encode(SRP6Util.getPadded(A!, 512)),
+ },
+ );
+ final String sessionID = createSessionResponse.data["sessionID"];
+ final String srpB = createSessionResponse.data["srpB"];
+
+ final serverB = SRP6Util.decodeBigInt(base64Decode(srpB));
+
+ // ignore: unused_local_variable
+ final clientS = client.calculateSecret(serverB);
+ final clientM = client.calculateClientEvidenceMessage();
+ final response = await _dio.post(
+ "${_config.getHttpEndpoint()}/users/srp/verify-session",
+ data: {
+ "sessionID": sessionID,
+ "srpUserID": srpAttributes.srpUserID,
+ "srpM1": base64Encode(SRP6Util.getPadded(clientM!, 32)),
+ },
+ );
+ 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) {
+ twoFASessionID = response.data["twoFactorSessionIDV2"];
+ }
+ _config.setVolatilePassword(userPassword);
+ if (passkeySessionID.isNotEmpty) {
+ page = PasskeyPage(
+ _config,
+ passkeySessionID,
+ totp2FASessionID: twoFASessionID,
+ accountsUrl: accountsUrl,
+ );
+ } else if (twoFASessionID.isNotEmpty) {
+ page = TwoFactorAuthenticationPage(twoFASessionID);
+ } else {
+ await _saveConfiguration(response);
+ if (_config.getEncryptedToken() != null) {
+ await _config.decryptSecretsAndGetKeyEncKey(
+ userPassword,
+ _config.getKeyAttributes()!,
+ keyEncryptionKey: keyEncryptionKey,
+ );
+ page = _homePage;
+ } else {
+ throw Exception("unexpected response during email verification");
+ }
+ }
+ await dialog.hide();
+ // ignore: unawaited_futures
+ Navigator.of(context).pushAndRemoveUntil(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return page!;
+ },
+ ),
+ (route) => route.isFirst,
+ );
+ } else {
+ // should never reach here
+ throw Exception("unexpected response during email verification");
+ }
+ }
+
+ Future<void> updateKeyAttributes(
+ KeyAttributes keyAttributes,
+ Uint8List loginKey, {
+ required bool logoutOtherDevices,
+ }) async {
+ try {
+ final setKeyRequest = SetKeysRequest(
+ kekSalt: keyAttributes.kekSalt,
+ encryptedKey: keyAttributes.encryptedKey,
+ keyDecryptionNonce: keyAttributes.keyDecryptionNonce,
+ memLimit: keyAttributes.memLimit,
+ opsLimit: keyAttributes.opsLimit,
+ );
+ await registerOrUpdateSrp(
+ loginKey,
+ setKeysRequest: setKeyRequest,
+ logOutOtherDevices: logoutOtherDevices,
+ );
+ await _config.setKeyAttributes(keyAttributes);
+ } catch (e) {
+ _logger.severe(e);
+ rethrow;
+ }
+ }
+
+ Future<void> setRecoveryKey(KeyAttributes keyAttributes) async {
+ try {
+ final setRecoveryKeyRequest = SetRecoveryKeyRequest(
+ keyAttributes.masterKeyEncryptedWithRecoveryKey,
+ keyAttributes.masterKeyDecryptionNonce,
+ keyAttributes.recoveryKeyEncryptedWithMasterKey,
+ keyAttributes.recoveryKeyDecryptionNonce,
+ );
+ await _enteDio.put(
+ "/users/recovery-key",
+ data: setRecoveryKeyRequest.toMap(),
+ );
+ await _config.setKeyAttributes(keyAttributes);
+ } catch (e) {
+ _logger.severe(e);
+ rethrow;
+ }
+ }
+
+ Future<void> verifyTwoFactor(
+ BuildContext context,
+ String sessionID,
+ String code,
+ ) async {
+ final dialog = createProgressDialog(context, context.strings.pleaseWait);
+ await dialog.show();
+ try {
+ final response = await _dio.post(
+ "${_config.getHttpEndpoint()}/users/two-factor/verify",
+ data: {
+ "sessionID": sessionID,
+ "code": code,
+ },
+ );
+ await dialog.hide();
+ if (response.statusCode == 200) {
+ showShortToast(context, context.strings.authenticationSuccessful);
+ await _saveConfiguration(response);
+ // ignore: unawaited_futures
+ Navigator.of(context).pushAndRemoveUntil(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return PasswordReentryPage(_homePage, _config);
+ },
+ ),
+ (route) => route.isFirst,
+ );
+ }
+ } on DioException catch (e) {
+ await dialog.hide();
+ _logger.severe(e);
+ if (e.response != null && e.response!.statusCode == 404) {
+ showToast(context, "Session expired");
+ // ignore: unawaited_futures
+ Navigator.of(context).pushAndRemoveUntil(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return LoginPage(_config);
+ },
+ ),
+ (route) => route.isFirst,
+ );
+ } else {
+ // ignore: unawaited_futures
+ showErrorDialog(
+ context,
+ context.strings.incorrectCode,
+ context.strings.authenticationFailedPleaseTryAgain,
+ );
+ }
+ } catch (e) {
+ await dialog.hide();
+ _logger.severe(e);
+ // ignore: unawaited_futures
+ showErrorDialog(
+ context,
+ context.strings.oops,
+ context.strings.authenticationFailedPleaseTryAgain,
+ );
+ }
+ }
+
+ Future<void> recoverTwoFactor(
+ BuildContext context,
+ String sessionID,
+ TwoFactorType type,
+ ) async {
+ final dialog = createProgressDialog(context, context.strings.pleaseWait);
+ await dialog.show();
+ try {
+ final response = await _dio.get(
+ "${_config.getHttpEndpoint()}/users/two-factor/recover",
+ queryParameters: {
+ "sessionID": sessionID,
+ "twoFactorType": twoFactorTypeToString(type),
+ },
+ );
+ await dialog.hide();
+ if (response.statusCode == 200) {
+ // ignore: unawaited_futures
+ Navigator.of(context).pushAndRemoveUntil(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return TwoFactorRecoveryPage(
+ type,
+ sessionID,
+ response.data["encryptedSecret"],
+ response.data["secretDecryptionNonce"],
+ );
+ },
+ ),
+ (route) => route.isFirst,
+ );
+ }
+ } on DioException catch (e) {
+ await dialog.hide();
+ _logger.severe(e);
+ if (e.response != null && e.response!.statusCode == 404) {
+ showToast(context, context.strings.sessionExpired);
+ // ignore: unawaited_futures
+ Navigator.of(context).pushAndRemoveUntil(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return LoginPage(_config);
+ },
+ ),
+ (route) => route.isFirst,
+ );
+ } else {
+ // ignore: unawaited_futures
+ showErrorDialog(
+ context,
+ context.strings.oops,
+ context.strings.somethingWentWrongPleaseTryAgain,
+ );
+ }
+ } catch (e) {
+ await dialog.hide();
+ _logger.severe(e);
+ // ignore: unawaited_futures
+ showErrorDialog(
+ context,
+ context.strings.oops,
+ context.strings.somethingWentWrongPleaseTryAgain,
+ );
+ } finally {
+ await dialog.hide();
+ }
+ }
+
+ Future<void> removeTwoFactor(
+ BuildContext context,
+ TwoFactorType type,
+ String sessionID,
+ String recoveryKey,
+ String encryptedSecret,
+ String secretDecryptionNonce,
+ ) async {
+ final dialog = createProgressDialog(context, context.strings.pleaseWait);
+ await dialog.show();
+ String secret;
+ try {
+ if (recoveryKey.contains(' ')) {
+ if (recoveryKey.split(' ').length != mnemonicKeyWordCount) {
+ throw AssertionError(
+ 'recovery code should have $mnemonicKeyWordCount words',
+ );
+ }
+ recoveryKey = bip39.mnemonicToEntropy(recoveryKey);
+ }
+ secret = CryptoUtil.bin2base64(
+ await CryptoUtil.decrypt(
+ CryptoUtil.base642bin(encryptedSecret),
+ CryptoUtil.hex2bin(recoveryKey.trim()),
+ CryptoUtil.base642bin(secretDecryptionNonce),
+ ),
+ );
+ } catch (e) {
+ await dialog.hide();
+ await showErrorDialog(
+ context,
+ context.strings.incorrectRecoveryKey,
+ context.strings.theRecoveryKeyYouEnteredIsIncorrect,
+ );
+ return;
+ }
+ try {
+ final response = await _dio.post(
+ "${_config.getHttpEndpoint()}/users/two-factor/remove",
+ data: {
+ "sessionID": sessionID,
+ "secret": secret,
+ "twoFactorType": twoFactorTypeToString(type),
+ },
+ );
+ await dialog.hide();
+ if (response.statusCode == 200) {
+ showShortToast(
+ context,
+ context.strings.twofactorAuthenticationSuccessfullyReset,
+ );
+ await _saveConfiguration(response);
+ // ignore: unawaited_futures
+ Navigator.of(context).pushAndRemoveUntil(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return PasswordReentryPage(_homePage, _config);
+ },
+ ),
+ (route) => route.isFirst,
+ );
+ }
+ } on DioException catch (e) {
+ await dialog.hide();
+ _logger.severe(e);
+ if (e.response != null && e.response!.statusCode == 404) {
+ showToast(context, "Session expired");
+ // ignore: unawaited_futures
+ Navigator.of(context).pushAndRemoveUntil(
+ MaterialPageRoute(
+ builder: (BuildContext context) {
+ return LoginPage(_config);
+ },
+ ),
+ (route) => route.isFirst,
+ );
+ } else {
+ // ignore: unawaited_futures
+ showErrorDialog(
+ context,
+ context.strings.oops,
+ context.strings.somethingWentWrongPleaseTryAgain,
+ );
+ }
+ } catch (e) {
+ await dialog.hide();
+ _logger.severe(e);
+ // ignore: unawaited_futures
+ showErrorDialog(
+ context,
+ context.strings.oops,
+ context.strings.somethingWentWrongPleaseTryAgain,
+ );
+ } finally {
+ await dialog.hide();
+ }
+ }
+
+ Future<void> _saveConfiguration(dynamic response) async {
+ final responseData = response is Map ? response : response.data as Map?;
+ if (responseData == null) return;
+
+ await _config.setUserID(responseData["id"]);
+ if (responseData["encryptedToken"] != null) {
+ await _config.setEncryptedToken(responseData["encryptedToken"]);
+ await _config.setKeyAttributes(
+ KeyAttributes.fromMap(responseData["keyAttributes"]),
+ );
+ } else {
+ await _config.setToken(responseData["token"]);
+ }
+ }
+
+ bool? canDisableEmailMFA() {
+ return _preferences.getBool(kCanDisableEmailMFA);
+ }
+
+ bool hasEmailMFAEnabled() {
+ return _preferences.getBool(kIsEmailMFAEnabled) ?? true;
+ }
+
+ Future<void> updateEmailMFA(bool isEnabled) async {
+ try {
+ await _enteDio.put(
+ "/users/email-mfa",
+ data: {
+ "isEnabled": isEnabled,
+ },
+ );
+ await _preferences.setBool(kIsEmailMFAEnabled, isEnabled);
+ } catch (e) {
+ _logger.severe("Failed to update email mfa", e);
+ rethrow;
+ }
+ }
+
+ Future<void> setRefSource(String refSource) async {
+ await _preferences.setString(kReferralSource, refSource);
+ }
+
+ String _getRefSource() {
+ return _preferences.getString(kReferralSource) ?? "";
+ }
+}
diff --git a/mobile/packages/accounts/pubspec.lock b/mobile/packages/accounts/pubspec.lock
new file mode 100644
index 0000000000..8fee60bb47
--- /dev/null
+++ b/mobile/packages/accounts/pubspec.lock
@@ -0,0 +1,1279 @@
+# Generated by pub
+# See https://dart.dev/tools/pub/glossary#lockfile
+packages:
+ app_links:
+ dependency: "direct main"
+ description:
+ name: app_links
+ sha256: "85ed8fc1d25a76475914fff28cc994653bd900bc2c26e4b57a49e097febb54ba"
+ url: "https://pub.dev"
+ source: hosted
+ version: "6.4.0"
+ app_links_linux:
+ dependency: transitive
+ description:
+ name: app_links_linux
+ sha256: f5f7173a78609f3dfd4c2ff2c95bd559ab43c80a87dc6a095921d96c05688c81
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.0.3"
+ app_links_platform_interface:
+ dependency: transitive
+ description:
+ name: app_links_platform_interface
+ sha256: "05f5379577c513b534a29ddea68176a4d4802c46180ee8e2e966257158772a3f"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.0.2"
+ app_links_web:
+ dependency: transitive
+ description:
+ name: app_links_web
+ sha256: af060ed76183f9e2b87510a9480e56a5352b6c249778d07bd2c95fc35632a555
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.0.4"
+ archive:
+ dependency: transitive
+ description:
+ name: archive
+ sha256: "2fde1607386ab523f7a36bb3e7edb43bd58e6edaf2ffb29d8a6d578b297fdbbd"
+ url: "https://pub.dev"
+ source: hosted
+ version: "4.0.7"
+ 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: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.13.0"
+ bip39:
+ dependency: "direct main"
+ description:
+ name: bip39
+ sha256: de1ee27ebe7d96b84bb3a04a4132a0a3007dcdd5ad27dd14aa87a29d97c45edc
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.0.6"
+ 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: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.4.0"
+ clock:
+ dependency: transitive
+ description:
+ name: clock
+ sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.1.2"
+ collection:
+ dependency: "direct main"
+ description:
+ name: collection
+ sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.19.1"
+ convert:
+ dependency: transitive
+ description:
+ name: convert
+ sha256: b30acd5944035672bc15c6b7a8b47d773e41e2f17de064350988c5d02adb1c68
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.1.2"
+ cronet_http:
+ dependency: transitive
+ description:
+ name: cronet_http
+ sha256: df26af0de7c4eff46c53c190b5590e22457bfce6ea679aedb1e6326197f27d6f
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.4.0"
+ cross_file:
+ dependency: transitive
+ description:
+ name: cross_file
+ sha256: "7caf6a750a0c04effbb52a676dce9a4a592e10ad35c34d6d2d0e4811160d5670"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.3.4+2"
+ crypto:
+ dependency: transitive
+ description:
+ name: crypto
+ sha256: "1e445881f28f22d6140f181e07737b22f1e099a5e1ff94b0af2f9e4a463f4855"
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.0.6"
+ csslib:
+ dependency: transitive
+ description:
+ name: csslib
+ sha256: "09bad715f418841f976c77db72d5398dc1253c21fb9c0c7f0b0b985860b2d58e"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.0.2"
+ cupertino_http:
+ dependency: transitive
+ description:
+ name: cupertino_http
+ sha256: "8fb9e2c36d0732d9d96abd76683406b57e78a2514e27c962e0c603dbe6f2e3f8"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.2.0"
+ device_info_plus:
+ dependency: transitive
+ description:
+ name: device_info_plus
+ sha256: "77f757b789ff68e4eaf9c56d1752309bd9f7ad557cb105b938a7f8eb89e59110"
+ url: "https://pub.dev"
+ source: hosted
+ version: "9.1.2"
+ device_info_plus_platform_interface:
+ dependency: transitive
+ description:
+ name: device_info_plus_platform_interface
+ sha256: e1ea89119e34903dca74b883d0dd78eb762814f97fb6c76f35e9ff74d261a18f
+ url: "https://pub.dev"
+ source: hosted
+ version: "7.0.3"
+ dio:
+ dependency: "direct main"
+ description:
+ name: dio
+ sha256: "253a18bbd4851fecba42f7343a1df3a9a4c1d31a2c1b37e221086b4fa8c8dbc9"
+ url: "https://pub.dev"
+ source: hosted
+ version: "5.8.0+1"
+ dio_web_adapter:
+ dependency: transitive
+ description:
+ name: dio_web_adapter
+ sha256: "7586e476d70caecaf1686d21eee7247ea43ef5c345eab9e0cc3583ff13378d78"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.1.1"
+ dotted_border:
+ dependency: "direct main"
+ description:
+ name: dotted_border
+ sha256: "99b091ec6891ba0c5331fdc2b502993c7c108f898995739a73c6845d71dad70c"
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.1.0"
+ email_validator:
+ dependency: "direct main"
+ description:
+ name: email_validator
+ sha256: b19aa5d92fdd76fbc65112060c94d45ba855105a28bb6e462de7ff03b12fa1fb
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.0.0"
+ ente_base:
+ dependency: "direct main"
+ description:
+ path: "../base"
+ relative: true
+ source: path
+ version: "1.0.0"
+ ente_configuration:
+ dependency: "direct main"
+ description:
+ path: "../configuration"
+ relative: true
+ source: path
+ version: "1.0.0"
+ ente_crypto_dart:
+ dependency: "direct main"
+ description:
+ path: "."
+ ref: HEAD
+ resolved-ref: f91e1545f8263df127762240c4da54a0c42835b2
+ url: "https://github.com/ente-io/ente_crypto_dart.git"
+ source: git
+ version: "1.0.0"
+ ente_events:
+ dependency: "direct main"
+ description:
+ path: "../events"
+ relative: true
+ source: path
+ version: "1.0.0"
+ ente_lock_screen:
+ dependency: "direct main"
+ description:
+ path: "../lock_screen"
+ relative: true
+ source: path
+ version: "1.0.0"
+ ente_logging:
+ dependency: transitive
+ description:
+ path: "../logging"
+ relative: true
+ source: path
+ version: "1.0.0"
+ ente_network:
+ dependency: "direct main"
+ description:
+ path: "../network"
+ relative: true
+ source: path
+ version: "1.0.0"
+ ente_strings:
+ dependency: "direct main"
+ description:
+ path: "../strings"
+ relative: true
+ source: path
+ version: "1.0.0"
+ ente_ui:
+ dependency: "direct main"
+ description:
+ path: "../ui"
+ relative: true
+ source: path
+ version: "1.0.0"
+ ente_utils:
+ dependency: "direct main"
+ description:
+ path: "../utils"
+ relative: true
+ source: path
+ version: "1.0.0"
+ event_bus:
+ dependency: transitive
+ description:
+ name: event_bus
+ sha256: "1a55e97923769c286d295240048fc180e7b0768902c3c2e869fe059aafa15304"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.0.1"
+ 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: "289279317b4b16eb2bb7e271abccd4bf84ec9bdcbe999e278a94b804f5630418"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.1.4"
+ file:
+ dependency: transitive
+ description:
+ name: file
+ sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4
+ url: "https://pub.dev"
+ source: hosted
+ version: "7.0.1"
+ file_saver:
+ dependency: "direct main"
+ description:
+ name: file_saver
+ sha256: "9d93db09bd4da9e43238f9dd485360fc51a5c138eea5ef5f407ec56e58079ac0"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.3.1"
+ fixnum:
+ dependency: transitive
+ description:
+ name: fixnum
+ sha256: b6dc7065e46c974bc7c5f143080a6764ec7a4be6da1285ececdc37be96de53be
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.1.1"
+ flutter:
+ dependency: "direct main"
+ description: flutter
+ source: sdk
+ version: "0.0.0"
+ flutter_animate:
+ dependency: transitive
+ description:
+ name: flutter_animate
+ sha256: "7befe2d3252728afb77aecaaea1dec88a89d35b9b1d2eea6d04479e8af9117b5"
+ url: "https://pub.dev"
+ source: hosted
+ version: "4.5.2"
+ flutter_email_sender:
+ dependency: transitive
+ description:
+ name: flutter_email_sender
+ sha256: d39eb5e91358fc19ec4050da69accec21f9d5b2b6bcf188aa246327b6ca2352c
+ url: "https://pub.dev"
+ source: hosted
+ version: "7.0.0"
+ flutter_inappwebview:
+ dependency: transitive
+ description:
+ name: flutter_inappwebview
+ sha256: "80092d13d3e29b6227e25b67973c67c7210bd5e35c4b747ca908e31eb71a46d5"
+ url: "https://pub.dev"
+ source: hosted
+ version: "6.1.5"
+ flutter_inappwebview_android:
+ dependency: transitive
+ description:
+ name: flutter_inappwebview_android
+ sha256: "62557c15a5c2db5d195cb3892aab74fcaec266d7b86d59a6f0027abd672cddba"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.1.3"
+ flutter_inappwebview_internal_annotations:
+ dependency: transitive
+ description:
+ name: flutter_inappwebview_internal_annotations
+ sha256: "787171d43f8af67864740b6f04166c13190aa74a1468a1f1f1e9ee5b90c359cd"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.2.0"
+ flutter_inappwebview_ios:
+ dependency: transitive
+ description:
+ name: flutter_inappwebview_ios
+ sha256: "5818cf9b26cf0cbb0f62ff50772217d41ea8d3d9cc00279c45f8aabaa1b4025d"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.1.2"
+ flutter_inappwebview_macos:
+ dependency: transitive
+ description:
+ name: flutter_inappwebview_macos
+ sha256: c1fbb86af1a3738e3541364d7d1866315ffb0468a1a77e34198c9be571287da1
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.1.2"
+ flutter_inappwebview_platform_interface:
+ dependency: transitive
+ description:
+ name: flutter_inappwebview_platform_interface
+ sha256: cf5323e194096b6ede7a1ca808c3e0a078e4b33cc3f6338977d75b4024ba2500
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.3.0+1"
+ flutter_inappwebview_web:
+ dependency: transitive
+ description:
+ name: flutter_inappwebview_web
+ sha256: "55f89c83b0a0d3b7893306b3bb545ba4770a4df018204917148ebb42dc14a598"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.1.2"
+ flutter_inappwebview_windows:
+ dependency: transitive
+ description:
+ name: flutter_inappwebview_windows
+ sha256: "8b4d3a46078a2cdc636c4a3d10d10f2a16882f6be607962dbfff8874d1642055"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.6.0"
+ flutter_lints:
+ dependency: "direct dev"
+ description:
+ name: flutter_lints
+ sha256: "5398f14efa795ffb7a33e9b6a08798b26a180edac4ad7db3f231e40f82ce11e1"
+ url: "https://pub.dev"
+ source: hosted
+ version: "5.0.0"
+ flutter_local_authentication:
+ dependency: transitive
+ description:
+ name: flutter_local_authentication
+ sha256: eb2e471ba77fbc42b6ce8b358939dc9878dc71fcce5a482a8ddcb045563d87cd
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.2.0"
+ flutter_localizations:
+ dependency: transitive
+ description: flutter
+ source: sdk
+ version: "0.0.0"
+ flutter_plugin_android_lifecycle:
+ dependency: transitive
+ description:
+ name: flutter_plugin_android_lifecycle
+ sha256: f948e346c12f8d5480d2825e03de228d0eb8c3a737e4cdaa122267b89c022b5e
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.0.28"
+ flutter_secure_storage:
+ dependency: transitive
+ 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_shaders:
+ dependency: transitive
+ description:
+ name: flutter_shaders
+ sha256: "34794acadd8275d971e02df03afee3dee0f98dbfb8c4837082ad0034f612a3e2"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.1.3"
+ 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"
+ fluttertoast:
+ dependency: transitive
+ description:
+ name: fluttertoast
+ sha256: "25e51620424d92d3db3832464774a6143b5053f15e382d8ffbfd40b6e795dcf1"
+ url: "https://pub.dev"
+ source: hosted
+ version: "8.2.12"
+ freezed_annotation:
+ dependency: transitive
+ description:
+ name: freezed_annotation
+ sha256: c2e2d632dd9b8a2b7751117abcfc2b4888ecfe181bd9fca7170d9ef02e595fe2
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.4.4"
+ gtk:
+ dependency: transitive
+ description:
+ name: gtk
+ sha256: e8ce9ca4b1df106e4d72dad201d345ea1a036cc12c360f1a7d5a758f78ffa42c
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.1.0"
+ hex:
+ dependency: transitive
+ description:
+ name: hex
+ sha256: "4e7cd54e4b59ba026432a6be2dd9d96e4c5205725194997193bf871703b82c4a"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.2.0"
+ html:
+ dependency: transitive
+ description:
+ name: html
+ sha256: "6d1264f2dffa1b1101c25a91dff0dc2daee4c18e87cd8538729773c073dbf602"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.15.6"
+ http:
+ dependency: transitive
+ description:
+ name: http
+ sha256: "2c11f3f94c687ee9bad77c171151672986360b2b001d109814ee7140b2cf261b"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.4.0"
+ http_parser:
+ dependency: transitive
+ description:
+ name: http_parser
+ sha256: "178d74305e7866013777bab2c3d8726205dc5a4dd935297175b19a23a2e66571"
+ url: "https://pub.dev"
+ source: hosted
+ version: "4.1.2"
+ http_profile:
+ dependency: transitive
+ description:
+ name: http_profile
+ sha256: "7e679e355b09aaee2ab5010915c932cce3f2d1c11c3b2dc177891687014ffa78"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.1.0"
+ intl:
+ dependency: transitive
+ description:
+ name: intl
+ sha256: "3df61194eb431efc39c4ceba583b95633a403f46c9fd341e550ce0bfa50e9aa5"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.20.2"
+ jni:
+ dependency: transitive
+ description:
+ name: jni
+ sha256: d2c361082d554d4593c3012e26f6b188f902acd291330f13d6427641a92b3da1
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.14.2"
+ js:
+ dependency: transitive
+ description:
+ name: js
+ sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.6.7"
+ json_annotation:
+ dependency: transitive
+ description:
+ name: json_annotation
+ sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1"
+ url: "https://pub.dev"
+ source: hosted
+ version: "4.9.0"
+ leak_tracker:
+ dependency: transitive
+ description:
+ name: leak_tracker
+ sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0"
+ url: "https://pub.dev"
+ source: hosted
+ version: "10.0.9"
+ leak_tracker_flutter_testing:
+ dependency: transitive
+ description:
+ name: leak_tracker_flutter_testing
+ sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.0.9"
+ leak_tracker_testing:
+ dependency: transitive
+ description:
+ name: leak_tracker_testing
+ sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.0.1"
+ lints:
+ dependency: transitive
+ description:
+ name: lints
+ sha256: c35bb79562d980e9a453fc715854e1ed39e24e7d0297a880ef54e17f9874a9d7
+ url: "https://pub.dev"
+ source: hosted
+ version: "5.1.1"
+ local_auth:
+ dependency: transitive
+ description:
+ name: local_auth
+ sha256: "434d854cf478f17f12ab29a76a02b3067f86a63a6d6c4eb8fbfdcfe4879c1b7b"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.3.0"
+ local_auth_android:
+ dependency: transitive
+ description:
+ name: local_auth_android
+ sha256: "82b2bdeee2199a510d3b7716121e96a6609da86693bb0863edd8566355406b79"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.0.50"
+ local_auth_darwin:
+ dependency: transitive
+ description:
+ name: local_auth_darwin
+ sha256: "25163ce60a5a6c468cf7a0e3dc8a165f824cabc2aa9e39a5e9fc5c2311b7686f"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.5.0"
+ local_auth_platform_interface:
+ dependency: transitive
+ description:
+ name: local_auth_platform_interface
+ sha256: "1b842ff177a7068442eae093b64abe3592f816afd2a533c0ebcdbe40f9d2075a"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.0.10"
+ local_auth_windows:
+ dependency: transitive
+ description:
+ name: local_auth_windows
+ sha256: bc4e66a29b0fdf751aafbec923b5bed7ad6ed3614875d8151afe2578520b2ab5
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.0.11"
+ logging:
+ dependency: "direct main"
+ description:
+ name: logging
+ sha256: c8245ada5f1717ed44271ed1c26b8ce85ca3228fd2ffdb75468ab01979309d61
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.3.0"
+ matcher:
+ dependency: transitive
+ description:
+ name: matcher
+ sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.12.17"
+ material_color_utilities:
+ dependency: transitive
+ description:
+ name: material_color_utilities
+ sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.11.1"
+ meta:
+ dependency: transitive
+ description:
+ name: meta
+ sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.16.0"
+ mime:
+ dependency: transitive
+ description:
+ name: mime
+ sha256: "41a20518f0cb1256669420fdba0cd90d21561e560ac240f26ef8322e45bb7ed6"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.0.0"
+ modal_bottom_sheet:
+ dependency: transitive
+ description:
+ name: modal_bottom_sheet
+ sha256: eac66ef8cb0461bf069a38c5eb0fa728cee525a531a8304bd3f7b2185407c67e
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.0.0"
+ native_dio_adapter:
+ dependency: transitive
+ description:
+ name: native_dio_adapter
+ sha256: "7420bc9517b2abe09810199a19924617b45690a44ecfb0616ac9babc11875c03"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.4.0"
+ objective_c:
+ dependency: transitive
+ description:
+ name: objective_c
+ sha256: "9f034ba1eeca53ddb339bc8f4813cb07336a849cd735559b60cdc068ecce2dc7"
+ url: "https://pub.dev"
+ source: hosted
+ version: "7.1.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: transitive
+ description:
+ name: package_info_plus
+ sha256: "7976bfe4c583170d6cdc7077e3237560b364149fcd268b5f53d95a991963b191"
+ url: "https://pub.dev"
+ source: hosted
+ version: "8.3.0"
+ package_info_plus_platform_interface:
+ dependency: transitive
+ description:
+ name: package_info_plus_platform_interface
+ sha256: "6c935fb612dff8e3cc9632c2b301720c77450a126114126ffaafe28d2e87956c"
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.2.0"
+ password_strength:
+ dependency: "direct main"
+ description:
+ name: password_strength
+ sha256: "0e51e3d864e37873a1347e658147f88b66e141ee36c58e19828dc5637961e1ce"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.2.0"
+ path:
+ dependency: transitive
+ description:
+ name: path
+ sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.9.1"
+ path_provider:
+ dependency: transitive
+ 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: d0d310befe2c8ab9e7f393288ccbb11b60c019c6b5afc21973eeee4dda2b35e9
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.2.17"
+ path_provider_foundation:
+ dependency: transitive
+ description:
+ name: path_provider_foundation
+ sha256: "4843174df4d288f5e29185bd6e72a6fbdf5a4a4602717eed565497429f179942"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.4.1"
+ 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"
+ pinput:
+ dependency: "direct main"
+ description:
+ name: pinput
+ sha256: "8a73be426a91fefec90a7f130763ca39772d547e92f19a827cf4aa02e323d35a"
+ url: "https://pub.dev"
+ source: hosted
+ version: "5.0.1"
+ 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"
+ pointycastle:
+ dependency: "direct main"
+ description:
+ name: pointycastle
+ sha256: "4be0097fcf3fd3e8449e53730c631200ebc7b88016acecab2b0da2f0149222fe"
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.9.1"
+ posix:
+ dependency: transitive
+ description:
+ name: posix
+ sha256: "6323a5b0fa688b6a010df4905a56b00181479e6d10534cecfecede2aa55add61"
+ url: "https://pub.dev"
+ source: hosted
+ version: "6.0.3"
+ privacy_screen:
+ dependency: transitive
+ description:
+ name: privacy_screen
+ sha256: "2856e3a3ed082061a5cd2a1518f1ce6367c55916fb75e5db72e5983033a1ca54"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.0.8"
+ pub_semver:
+ dependency: transitive
+ description:
+ name: pub_semver
+ sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.2.0"
+ screen_retriever:
+ dependency: transitive
+ description:
+ name: screen_retriever
+ sha256: "570dbc8e4f70bac451e0efc9c9bb19fa2d6799a11e6ef04f946d7886d2e23d0c"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.2.0"
+ screen_retriever_linux:
+ dependency: transitive
+ description:
+ name: screen_retriever_linux
+ sha256: f7f8120c92ef0784e58491ab664d01efda79a922b025ff286e29aa123ea3dd18
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.2.0"
+ screen_retriever_macos:
+ dependency: transitive
+ description:
+ name: screen_retriever_macos
+ sha256: "71f956e65c97315dd661d71f828708bd97b6d358e776f1a30d5aa7d22d78a149"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.2.0"
+ screen_retriever_platform_interface:
+ dependency: transitive
+ description:
+ name: screen_retriever_platform_interface
+ sha256: ee197f4581ff0d5608587819af40490748e1e39e648d7680ecf95c05197240c0
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.2.0"
+ screen_retriever_windows:
+ dependency: transitive
+ description:
+ name: screen_retriever_windows
+ sha256: "449ee257f03ca98a57288ee526a301a430a344a161f9202b4fcc38576716fe13"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.2.0"
+ sentry:
+ dependency: transitive
+ description:
+ name: sentry
+ sha256: "599701ca0693a74da361bc780b0752e1abc98226cf5095f6b069648116c896bb"
+ url: "https://pub.dev"
+ source: hosted
+ version: "8.14.2"
+ sentry_flutter:
+ dependency: transitive
+ description:
+ name: sentry_flutter
+ sha256: "5ba2cf40646a77d113b37a07bd69f61bb3ec8a73cbabe5537b05a7c89d2656f8"
+ url: "https://pub.dev"
+ source: hosted
+ version: "8.14.2"
+ share_plus:
+ dependency: "direct main"
+ description:
+ name: share_plus
+ sha256: b2961506569e28948d75ec346c28775bb111986bb69dc6a20754a457e3d97fa0
+ url: "https://pub.dev"
+ source: hosted
+ version: "11.0.0"
+ share_plus_platform_interface:
+ dependency: transitive
+ description:
+ name: share_plus_platform_interface
+ sha256: "1032d392bc5d2095a77447a805aa3f804d2ae6a4d5eef5e6ebb3bd94c1bc19ef"
+ url: "https://pub.dev"
+ source: hosted
+ version: "6.0.0"
+ shared_preferences:
+ dependency: "direct main"
+ description:
+ name: shared_preferences
+ sha256: "6e8bf70b7fef813df4e9a36f658ac46d107db4b4cfe1048b477d4e453a8159f5"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.5.3"
+ shared_preferences_android:
+ dependency: transitive
+ description:
+ name: shared_preferences_android
+ sha256: "20cbd561f743a342c76c151d6ddb93a9ce6005751e7aa458baad3858bfbfb6ac"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.4.10"
+ shared_preferences_foundation:
+ dependency: transitive
+ description:
+ name: shared_preferences_foundation
+ sha256: "6a52cfcdaeac77cad8c97b539ff688ccfc458c007b4db12be584fbe5c0e49e03"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.5.4"
+ 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: "57cbf196c486bc2cf1f02b85784932c6094376284b3ad5779d1b1c6c6a816b80"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.4.1"
+ 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"
+ sodium:
+ dependency: transitive
+ description:
+ name: sodium
+ sha256: d9830a388e37c82891888e64cfd4c6764fa3ac716bed80ac6eab89ee42c3cd76
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.3.1+1"
+ sodium_libs:
+ dependency: transitive
+ description:
+ name: sodium_libs
+ sha256: aa764acd6ccc6113e119c2d99471aeeb4637a9a501639549b297d3a143ff49b3
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.2.1+6"
+ source_span:
+ dependency: transitive
+ description:
+ name: source_span
+ sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.10.1"
+ sprintf:
+ dependency: transitive
+ description:
+ name: sprintf
+ sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23"
+ url: "https://pub.dev"
+ source: hosted
+ version: "7.0.0"
+ stack_trace:
+ dependency: transitive
+ description:
+ name: stack_trace
+ sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.12.1"
+ step_progress_indicator:
+ dependency: "direct main"
+ description:
+ name: step_progress_indicator
+ sha256: b51bb1fcfc78454359f0658c5a2c21548c3825ebf76e826308e9ca10f383bbb8
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.0.2"
+ 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"
+ styled_text:
+ dependency: "direct main"
+ description:
+ name: styled_text
+ sha256: fd624172cf629751b4f171dd0ecf9acf02a06df3f8a81bb56c0caa4f1df706c3
+ url: "https://pub.dev"
+ source: hosted
+ version: "8.1.0"
+ 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: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.7.4"
+ tuple:
+ dependency: transitive
+ description:
+ name: tuple
+ sha256: a97ce2013f240b2f3807bcbaf218765b6f301c3eff91092bcfa23a039e7dd151
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.0.2"
+ typed_data:
+ dependency: transitive
+ description:
+ name: typed_data
+ sha256: f9049c039ebfeb4cf7a7104a675823cd72dba8297f264b6637062516699fa006
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.4.0"
+ ua_client_hints:
+ dependency: transitive
+ description:
+ name: ua_client_hints
+ sha256: "1b8759a46bfeab355252881df27f2604c01bded86aa2b578869fb1b638b23118"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.4.1"
+ universal_platform:
+ dependency: transitive
+ description:
+ name: universal_platform
+ sha256: "64e16458a0ea9b99260ceb5467a214c1f298d647c659af1bff6d3bf82536b1ec"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.1.0"
+ url_launcher:
+ dependency: "direct main"
+ description:
+ name: url_launcher
+ sha256: f6a7e5c4835bb4e3026a04793a4199ca2d14c739ec378fdfe23fc8075d0439f8
+ url: "https://pub.dev"
+ source: hosted
+ version: "6.3.2"
+ url_launcher_android:
+ dependency: transitive
+ description:
+ name: url_launcher_android
+ sha256: "8582d7f6fe14d2652b4c45c9b6c14c0b678c2af2d083a11b604caeba51930d79"
+ url: "https://pub.dev"
+ source: hosted
+ version: "6.3.16"
+ url_launcher_ios:
+ dependency: "direct main"
+ description:
+ name: url_launcher_ios
+ sha256: "7f2022359d4c099eea7df3fdf739f7d3d3b9faf3166fb1dd390775176e0b76cb"
+ url: "https://pub.dev"
+ source: hosted
+ version: "6.3.3"
+ url_launcher_linux:
+ dependency: transitive
+ description:
+ name: url_launcher_linux
+ sha256: "4e9ba368772369e3e08f231d2301b4ef72b9ff87c31192ef471b380ef29a4935"
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.2.1"
+ url_launcher_macos:
+ dependency: transitive
+ description:
+ name: url_launcher_macos
+ sha256: "17ba2000b847f334f16626a574c702b196723af2a289e7a93ffcb79acff855c2"
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.2.2"
+ url_launcher_platform_interface:
+ dependency: transitive
+ description:
+ name: url_launcher_platform_interface
+ sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.3.2"
+ url_launcher_web:
+ dependency: transitive
+ description:
+ name: url_launcher_web
+ sha256: "4bd2b7b4dc4d4d0b94e5babfffbca8eac1a126c7f3d6ecbc1a11013faa3abba2"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.4.1"
+ url_launcher_windows:
+ dependency: transitive
+ description:
+ name: url_launcher_windows
+ sha256: "3284b6d2ac454cf34f114e1d3319866fdd1e19cdc329999057e44ffe936cfa77"
+ url: "https://pub.dev"
+ source: hosted
+ version: "3.1.4"
+ uuid:
+ dependency: "direct main"
+ description:
+ name: uuid
+ sha256: a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff
+ url: "https://pub.dev"
+ source: hosted
+ version: "4.5.1"
+ vector_math:
+ dependency: transitive
+ description:
+ name: vector_math
+ sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
+ url: "https://pub.dev"
+ source: hosted
+ version: "2.1.4"
+ vm_service:
+ dependency: transitive
+ description:
+ name: vm_service
+ sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02
+ url: "https://pub.dev"
+ source: hosted
+ version: "15.0.0"
+ 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"
+ win32:
+ dependency: transitive
+ description:
+ name: win32
+ sha256: "66814138c3562338d05613a6e368ed8cfb237ad6d64a9e9334be3f309acfca03"
+ url: "https://pub.dev"
+ source: hosted
+ version: "5.14.0"
+ win32_registry:
+ dependency: transitive
+ description:
+ name: win32_registry
+ sha256: "21ec76dfc731550fd3e2ce7a33a9ea90b828fdf19a5c3bcf556fa992cfa99852"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.1.5"
+ window_manager:
+ dependency: transitive
+ description:
+ name: window_manager
+ sha256: "7eb6d6c4164ec08e1bf978d6e733f3cebe792e2a23fb07cbca25c2872bfdbdcd"
+ url: "https://pub.dev"
+ source: hosted
+ version: "0.5.1"
+ xdg_directories:
+ dependency: transitive
+ description:
+ name: xdg_directories
+ sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15"
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.1.0"
+ xmlstream:
+ dependency: transitive
+ description:
+ name: xmlstream
+ sha256: cfc14e3f256997897df9481ae630d94c2d85ada5187ebeb868bb1aabc2c977b4
+ url: "https://pub.dev"
+ source: hosted
+ version: "1.1.1"
+sdks:
+ dart: ">=3.8.0 <4.0.0"
+ flutter: ">=3.29.0"
diff --git a/mobile/packages/accounts/pubspec.yaml b/mobile/packages/accounts/pubspec.yaml
new file mode 100644
index 0000000000..eca03a2a01
--- /dev/null
+++ b/mobile/packages/accounts/pubspec.yaml
@@ -0,0 +1,62 @@
+name: ente_accounts
+description: A Flutter package containing account-related models, pages, and services for Ente apps
+version: 1.0.0
+
+environment:
+ sdk: ">=3.0.0 <4.0.0"
+ flutter: ">=1.17.0"
+
+dependencies:
+ flutter:
+ sdk: flutter
+
+ # Ente packages
+ ente_strings:
+ path: ../strings
+ ente_ui:
+ path: ../ui
+ ente_utils:
+ path: ../utils
+ ente_base:
+ path: ../base
+ ente_configuration:
+ path: ../configuration
+ ente_network:
+ path: ../network
+ ente_events:
+ path: ../events
+ ente_crypto_dart:
+ git:
+ url: https://github.com/ente-io/ente_crypto_dart.git
+ ente_lock_screen:
+ path: ../lock_screen
+
+ # Third-party dependencies
+ bip39: ^1.0.6
+ dio: ^5.4.0
+ logging: ^1.2.0
+ pointycastle: ^3.7.3
+ shared_preferences: ^2.2.2
+ file_saver: ^0.3.0
+ share_plus: ^11.0.0
+ uuid: ^4.2.1
+ collection: ^1.18.0
+ dotted_border: ^3.1.0
+ password_strength: ^0.2.0
+ step_progress_indicator: ^1.0.2
+ styled_text: ^8.1.0
+ email_validator: ^3.0.0
+ pinput: ^5.0.1
+ app_links: ^6.3.3
+ url_launcher: ^6.3.1
+ url_launcher_ios: ^6.3.1
+
+dev_dependencies:
+ flutter_test:
+ sdk: flutter
+ flutter_lints: ^5.0.0
+
+flutter:
+
+# This package is not meant to be published
+publish_to: none