Skip to content

armgit / ente

Public Imported from GitHub
0

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

Prune Photos gateway comments

Manav Rathibeff9b46e986
diff --git a/mobile/apps/photos/lib/gateways/billing/billing_gateway.dart b/mobile/apps/photos/lib/gateways/billing/billing_gateway.dart
index dbed277630..b3fe5655f9 100644
--- a/mobile/apps/photos/lib/gateways/billing/billing_gateway.dart
+++ b/mobile/apps/photos/lib/gateways/billing/billing_gateway.dart
@@ -3,31 +3,16 @@ import "package:photos/core/errors.dart";
import "package:photos/gateways/billing/models/billing_plan.dart";
import "package:photos/gateways/billing/models/subscription.dart";
-/// Gateway for billing API endpoints.
-///
-/// Handles subscription management, billing plans, and Stripe integration.
class BillingGateway {
final Dio _enteDio;
BillingGateway(this._enteDio);
- /// Gets available billing plans for the user.
- ///
- /// Returns [BillingPlans] containing all available subscription plans.
Future<BillingPlans> getUserPlans() async {
final response = await _enteDio.get("/billing/user-plans");
return BillingPlans.fromMap(response.data);
}
- /// Verifies an in-app purchase subscription.
- ///
- /// [productID] - The product ID from the app store.
- /// [verificationData] - Server verification data from the purchase.
- /// [paymentProvider] - The payment provider ("playstore" or "appstore").
- ///
- /// Returns the verified [Subscription].
- /// Throws [SubscriptionAlreadyClaimedError] if the subscription was already
- /// claimed by another account.
Future<Subscription> verifySubscription({
required String productID,
required String verificationData,
@@ -51,31 +36,16 @@ class BillingGateway {
}
}
- /// Fetches the current subscription for the authenticated user.
- ///
- /// Returns the current [Subscription].
Future<Subscription> getSubscription() async {
final response = await _enteDio.get("/billing/subscription");
return Subscription.fromMap(response.data["subscription"]);
}
- /// Cancels the user's Stripe subscription.
- ///
- /// The subscription will remain active until the end of the current billing
- /// period but will not auto-renew.
- ///
- /// Returns the updated [Subscription].
Future<Subscription> cancelStripeSubscription() async {
final response = await _enteDio.post("/billing/stripe/cancel-subscription");
return Subscription.fromMap(response.data["subscription"]);
}
- /// Reactivates a canceled Stripe subscription.
- ///
- /// This must be called before the subscription period ends to prevent
- /// cancellation.
- ///
- /// Returns the reactivated [Subscription].
Future<Subscription> activateStripeSubscription() async {
final response = await _enteDio.post(
"/billing/stripe/activate-subscription",
@@ -83,12 +53,6 @@ class BillingGateway {
return Subscription.fromMap(response.data["subscription"]);
}
- /// Gets the Stripe customer portal URL.
- ///
- /// [redirectURL] - The URL to redirect to after the user finishes in the
- /// portal.
- ///
- /// Returns the portal URL as a string.
Future<String> getStripeCustomerPortalUrl({
required String redirectURL,
}) async {
diff --git a/mobile/apps/photos/lib/gateways/collections/collection_files_gateway.dart b/mobile/apps/photos/lib/gateways/collections/collection_files_gateway.dart
index 77f9c954c1..0bb70e009f 100644
--- a/mobile/apps/photos/lib/gateways/collections/collection_files_gateway.dart
+++ b/mobile/apps/photos/lib/gateways/collections/collection_files_gateway.dart
@@ -1,19 +1,11 @@
import "package:dio/dio.dart";
import "package:photos/gateways/collections/models/collection_file_item.dart";
-/// Gateway for collection file operations API endpoints.
-///
-/// Handles adding, removing, moving, copying, and restoring files
-/// to/from collections.
class CollectionFilesGateway {
final Dio _enteDio;
CollectionFilesGateway(this._enteDio);
- /// Adds files to a collection.
- ///
- /// [collectionID] - The collection to add files to.
- /// [files] - List of [CollectionFileItem] containing file IDs and encrypted keys.
Future<void> addFiles(
int collectionID,
List<CollectionFileItem> files,
@@ -27,10 +19,6 @@ class CollectionFilesGateway {
);
}
- /// Restores files from trash to a collection.
- ///
- /// [collectionID] - The collection to restore files to.
- /// [files] - List of [CollectionFileItem] containing file IDs and encrypted keys.
Future<void> restoreFiles(
int collectionID,
List<CollectionFileItem> files,
@@ -44,11 +32,6 @@ class CollectionFilesGateway {
);
}
- /// Moves files from one collection to another.
- ///
- /// [toCollectionID] - The destination collection.
- /// [fromCollectionID] - The source collection.
- /// [files] - List of [CollectionFileItem] with encrypted keys for the destination.
Future<void> moveFiles({
required int toCollectionID,
required int fromCollectionID,
@@ -64,10 +47,6 @@ class CollectionFilesGateway {
);
}
- /// Removes files from a collection.
- ///
- /// [collectionID] - The collection to remove files from.
- /// [fileIDs] - List of uploaded file IDs to remove.
Future<void> removeFiles(int collectionID, List<int> fileIDs) async {
final response = await _enteDio.post(
"/collections/v3/remove-files",
@@ -78,13 +57,6 @@ class CollectionFilesGateway {
}
}
- /// Suggests files for deletion in a shared collection.
- ///
- /// This is used when a non-owner wants to suggest deleting files
- /// from a shared collection.
- ///
- /// [collectionID] - The collection containing the files.
- /// [fileIDs] - List of uploaded file IDs to suggest for deletion.
Future<void> suggestDelete(int collectionID, List<int> fileIDs) async {
final response = await _enteDio.post(
"/collections/suggest-delete",
@@ -95,15 +67,6 @@ class CollectionFilesGateway {
}
}
- /// Copies files from one collection to another (for files owned by others).
- ///
- /// This creates new copies of files that are owned by other users.
- ///
- /// [dstCollectionID] - The destination collection (must be owned by current user).
- /// [srcCollectionID] - The source collection.
- /// [files] - List of [CollectionFileItem] with encrypted keys for the destination.
- ///
- /// Returns a map of original file IDs to new copied file IDs.
Future<Map<int, int>> copyFiles({
required int dstCollectionID,
required int srcCollectionID,
diff --git a/mobile/apps/photos/lib/gateways/collections/collection_share_gateway.dart b/mobile/apps/photos/lib/gateways/collections/collection_share_gateway.dart
index 4a6b2ce838..0543de4974 100644
--- a/mobile/apps/photos/lib/gateways/collections/collection_share_gateway.dart
+++ b/mobile/apps/photos/lib/gateways/collections/collection_share_gateway.dart
@@ -5,19 +5,11 @@ import "package:photos/models/api/collection/user.dart";
const _linkDeviceLimitExceededCode = "LINK_DEVICE_LIMIT_EXCEEDED";
-/// Gateway for collection sharing API endpoints.
-///
-/// Handles sharing collections with other users and managing public links.
class CollectionShareGateway {
final Dio _enteDio;
CollectionShareGateway(this._enteDio);
- /// Gets the list of users a collection is shared with.
- ///
- /// [collectionID] - The collection to get sharees for.
- ///
- /// Returns a list of [User] objects representing the sharees.
Future<List<User>> getSharees(int collectionID) async {
final response = await _enteDio.get(
"/collections/sharees",
@@ -30,14 +22,6 @@ class CollectionShareGateway {
return sharees;
}
- /// Shares a collection with another user.
- ///
- /// [collectionID] - The collection to share.
- /// [email] - The email of the user to share with.
- /// [encryptedKey] - The collection key encrypted for the recipient.
- /// [role] - The role to grant (e.g., "VIEWER", "COLLABORATOR").
- ///
- /// Returns the updated list of sharees.
Future<List<User>> share({
required int collectionID,
required String email,
@@ -60,12 +44,6 @@ class CollectionShareGateway {
return sharees;
}
- /// Removes sharing of a collection with a user.
- ///
- /// [collectionID] - The collection to unshare.
- /// [email] - The email of the user to remove sharing for.
- ///
- /// Returns the updated list of sharees.
Future<List<User>> unshare({
required int collectionID,
required String email,
@@ -115,14 +93,6 @@ class CollectionShareGateway {
return _parseBulkResults(response.data);
}
- /// Creates a public share URL for a collection.
- ///
- /// [collectionID] - The collection to create a public link for.
- /// [enableCollect] - Whether to allow others to add files.
- /// [enableJoin] - Whether to allow others to join the album.
- /// [enableComment] - Whether to allow comments.
- ///
- /// Returns the created [PublicURL].
Future<PublicURL> createShareUrl({
required int collectionID,
bool enableCollect = false,
@@ -141,12 +111,6 @@ class CollectionShareGateway {
return PublicURL.fromMap(response.data["result"]);
}
- /// Updates a public share URL for a collection.
- ///
- /// [collectionID] - The collection whose public link to update.
- /// [props] - Map of properties to update on the public URL.
- ///
- /// Returns the updated [PublicURL].
Future<PublicURL> updateShareUrl({
required int collectionID,
required Map<String, dynamic> props,
@@ -157,25 +121,10 @@ class CollectionShareGateway {
return PublicURL.fromMap(response.data["result"]);
}
- /// Deletes a public share URL for a collection.
- ///
- /// [collectionID] - The collection whose public link to delete.
Future<void> deleteShareUrl(int collectionID) async {
await _enteDio.delete("/collections/share-url/$collectionID");
}
- /// Gets information about a public collection.
- ///
- /// [authToken] - The public access token from the share URL.
- ///
- /// Returns the raw response data containing collection information.
- ///
- /// Throws:
- /// - [PublicCollectionInfoUnauthorizedException] when the token is invalid.
- /// - [PublicCollectionInfoExpiredException] when the link has expired/disabled.
- /// - [PublicCollectionDeviceLimitExceededException] when the link device
- /// limit is reached.
- /// - [PublicCollectionRateLimitedException] when API rate limits are hit.
Future<Map<String, dynamic>> getPublicCollectionInfo(String authToken) async {
try {
final response = await _enteDio.get(
@@ -206,12 +155,6 @@ class CollectionShareGateway {
}
}
- /// Verifies the password for a password-protected public collection.
- ///
- /// [authToken] - The public access token from the share URL.
- /// [passwordHash] - The hash of the password to verify.
- ///
- /// Returns the JWT token if verification succeeds.
Future<String> verifyPublicPassword({
required String authToken,
required String passwordHash,
@@ -224,12 +167,6 @@ class CollectionShareGateway {
return response.data["jwtToken"];
}
- /// Gets the diff of files in a public collection.
- ///
- /// [headers] - The authentication headers for the public collection.
- /// [sinceTime] - The timestamp to get changes since.
- ///
- /// Returns the raw response data containing the diff.
Future<Map<String, dynamic>> getPublicDiff({
required Map<String, String> headers,
required int sinceTime,
diff --git a/mobile/apps/photos/lib/gateways/collections/collections_gateway.dart b/mobile/apps/photos/lib/gateways/collections/collections_gateway.dart
index e61d3721b4..1ea4f837ca 100644
--- a/mobile/apps/photos/lib/gateways/collections/collections_gateway.dart
+++ b/mobile/apps/photos/lib/gateways/collections/collections_gateway.dart
@@ -2,20 +2,11 @@ import "package:dio/dio.dart";
import "package:photos/gateways/collections/models/create_request.dart";
import "package:photos/gateways/collections/models/metadata.dart";
-/// Gateway for collection CRUD and metadata API endpoints.
-///
-/// Handles collection creation, retrieval, deletion, renaming, and
-/// metadata updates for the Ente Photos API.
class CollectionsGateway {
final Dio _enteDio;
CollectionsGateway(this._enteDio);
- /// Creates a new collection.
- ///
- /// [createRequest] - The request containing collection details.
- ///
- /// Returns the raw collection data from the API response.
Future<Map<String, dynamic>> createCollection(
CreateRequest createRequest,
) async {
@@ -26,20 +17,11 @@ class CollectionsGateway {
return response.data["collection"];
}
- /// Gets a collection by its ID.
- ///
- /// [collectionID] - The ID of the collection to retrieve.
- ///
- /// Returns the raw collection data from the API response.
Future<Map<String, dynamic>> getCollection(int collectionID) async {
final response = await _enteDio.get("/collections/$collectionID");
return response.data["collection"];
}
- /// Deletes a collection.
- ///
- /// [collectionID] - The ID of the collection to delete.
- /// [keepFiles] - If true, files are kept; if false, files are moved to trash.
Future<void> deleteCollection({
required int collectionID,
required bool keepFiles,
@@ -49,11 +31,6 @@ class CollectionsGateway {
);
}
- /// Renames a collection.
- ///
- /// [collectionID] - The ID of the collection to rename.
- /// [encryptedName] - The new name, encrypted with the collection key.
- /// [nameDecryptionNonce] - The nonce used for encryption.
Future<void> renameCollection({
required int collectionID,
required String encryptedName,
@@ -69,19 +46,10 @@ class CollectionsGateway {
);
}
- /// Leaves a shared collection.
- ///
- /// [collectionID] - The ID of the collection to leave.
Future<void> leaveCollection(int collectionID) async {
await _enteDio.post("/collections/leave/$collectionID");
}
- /// Gets the diff of files in a collection since a given time.
- ///
- /// [collectionID] - The ID of the collection.
- /// [sinceTime] - The timestamp to get changes since.
- ///
- /// Returns the raw response data containing the diff.
Future<Map<String, dynamic>> getDiff({
required int collectionID,
required int sinceTime,
@@ -93,16 +61,10 @@ class CollectionsGateway {
return response.data;
}
- /// Updates the private magic metadata of a collection.
- ///
- /// [request] - The request containing the collection ID and metadata.
Future<void> updateMagicMetadata(UpdateMagicMetadataRequest request) async {
await _enteDio.put("/collections/magic-metadata", data: request.toJson());
}
- /// Updates the public magic metadata of a collection.
- ///
- /// [request] - The request containing the collection ID and metadata.
Future<void> updatePublicMagicMetadata(
UpdateMagicMetadataRequest request,
) async {
@@ -112,9 +74,6 @@ class CollectionsGateway {
);
}
- /// Updates the sharee magic metadata of a collection.
- ///
- /// [request] - The request containing the collection ID and metadata.
Future<void> updateShareeMagicMetadata(
UpdateMagicMetadataRequest request,
) async {
@@ -124,11 +83,6 @@ class CollectionsGateway {
);
}
- /// Joins a collection via a public link.
- ///
- /// [collectionID] - The ID of the collection to join.
- /// [encryptedKey] - The collection key encrypted for the joining user.
- /// [headers] - The public collection authentication headers.
Future<void> joinViaLink({
required int collectionID,
required String encryptedKey,
@@ -141,12 +95,6 @@ class CollectionsGateway {
);
}
- /// Gets all collections for the current user.
- ///
- /// [sinceTime] - The timestamp to get collections updated since.
- /// [source] - The source of the request (e.g., "fg" for foreground).
- ///
- /// Returns the raw response data containing the collections list.
Future<Map<String, dynamic>> getAll({
required int sinceTime,
required String source,
@@ -158,17 +106,11 @@ class CollectionsGateway {
return response.data;
}
- /// Fetches pending removal actions for collections.
- ///
- /// Returns the raw response data containing pending actions.
Future<Map<String, dynamic>> fetchPendingRemovalActions() async {
final response = await _enteDio.get("/collection-actions/pending-remove");
return response.data;
}
- /// Fetches delete suggestion actions for collections.
- ///
- /// Returns the raw response data containing delete suggestion actions.
Future<Map<String, dynamic>> fetchDeleteSuggestions() async {
final response = await _enteDio.get(
"/collection-actions/delete-suggestions",
@@ -176,9 +118,6 @@ class CollectionsGateway {
return response.data;
}
- /// Rejects delete suggestions for specified files.
- ///
- /// [fileIDs] - The list of file IDs to reject delete suggestions for.
Future<void> rejectDeleteSuggestions(List<int> fileIDs) async {
await _enteDio.post(
"/collection-actions/reject-delete-suggestions",
diff --git a/mobile/apps/photos/lib/gateways/emergency/emergency_gateway.dart b/mobile/apps/photos/lib/gateways/emergency/emergency_gateway.dart
index 4a63534579..4b7e5bad9b 100644
--- a/mobile/apps/photos/lib/gateways/emergency/emergency_gateway.dart
+++ b/mobile/apps/photos/lib/gateways/emergency/emergency_gateway.dart
@@ -3,16 +3,11 @@ import "package:photos/emergency/model.dart";
import "package:photos/gateways/users/models/key_attributes.dart";
import "package:photos/gateways/users/models/srp.dart";
-/// Gateway for emergency contact related API endpoints.
class EmergencyGateway {
final Dio _enteDio;
EmergencyGateway(this._enteDio);
- /// Adds an emergency contact.
- ///
- /// [email] is the email address of the contact to add.
- /// [encryptedKey] is the base64 encoded encrypted recovery key.
Future<void> addContact({
required String email,
required String encryptedKey,
@@ -28,17 +23,11 @@ class EmergencyGateway {
);
}
- /// Gets emergency contact information for the current user.
Future<EmergencyInfo> getInfo() async {
final response = await _enteDio.get("/emergency-contacts/info");
return EmergencyInfo.fromJson(response.data);
}
- /// Updates the state of an emergency contact.
- ///
- /// [userID] is the ID of the user who owns the contact.
- /// [emergencyContactID] is the ID of the emergency contact.
- /// [state] is the new state string value.
Future<void> updateState({
required int? userID,
required int? emergencyContactID,
@@ -54,7 +43,6 @@ class EmergencyGateway {
);
}
- /// Updates the recovery notice period for an emergency contact.
Future<void> updateRecoveryNotice({
required int? emergencyContactID,
required int recoveryNoticeInDays,
@@ -68,10 +56,6 @@ class EmergencyGateway {
);
}
- /// Starts a recovery session for the given contact.
- ///
- /// [userID] is the ID of the user to recover.
- /// [emergencyContactID] is the ID of the emergency contact initiating recovery.
Future<void> startRecovery({
required int? userID,
required int? emergencyContactID,
@@ -82,11 +66,6 @@ class EmergencyGateway {
);
}
- /// Stops an ongoing recovery session.
- ///
- /// [userID] is the ID of the user being recovered.
- /// [emergencyContactID] is the ID of the emergency contact.
- /// [sessionID] is the ID of the recovery session.
Future<void> stopRecovery({
required int? userID,
required int? emergencyContactID,
@@ -102,11 +81,6 @@ class EmergencyGateway {
);
}
- /// Rejects a recovery session.
- ///
- /// [userID] is the ID of the user being recovered.
- /// [emergencyContactID] is the ID of the emergency contact.
- /// [sessionID] is the ID of the recovery session to reject.
Future<void> rejectRecovery({
required int? userID,
required int? emergencyContactID,
@@ -122,11 +96,6 @@ class EmergencyGateway {
);
}
- /// Approves a recovery session.
- ///
- /// [userID] is the ID of the user being recovered.
- /// [emergencyContactID] is the ID of the emergency contact.
- /// [sessionID] is the ID of the recovery session to approve.
Future<void> approveRecovery({
required int? userID,
required int? emergencyContactID,
@@ -142,10 +111,6 @@ class EmergencyGateway {
);
}
- /// Gets recovery information for a session.
- ///
- /// [sessionID] is the ID of the recovery session.
- /// Returns a tuple of (encryptedKey, keyAttributes).
Future<(String, KeyAttributes)> getRecoveryInfo(String sessionID) async {
final response = await _enteDio.get(
"/emergency-contacts/recovery-info/$sessionID",
@@ -157,11 +122,6 @@ class EmergencyGateway {
return (encryptedKey, keyAttributes);
}
- /// Initializes a password change for another user during recovery.
- ///
- /// [recoveryID] is the ID of the recovery session.
- /// [setupSRPRequest] is the SRP setup request data.
- /// Returns the SRP setup response.
Future<SetupSRPResponse> initPasswordChange({
required String recoveryID,
required SetupSRPRequest setupSRPRequest,
@@ -176,12 +136,6 @@ class EmergencyGateway {
return SetupSRPResponse.fromJson(response.data);
}
- /// Completes a password change for another user during recovery.
- ///
- /// [recoveryID] is the ID of the recovery session.
- /// [setupID] is the ID from the init password change response.
- /// [srpM1] is the SRP client evidence message.
- /// [updatedKeyAttr] is the updated key attributes map.
Future<void> changePassword({
required String recoveryID,
required String setupID,
diff --git a/mobile/apps/photos/lib/gateways/files/file_data_gateway.dart b/mobile/apps/photos/lib/gateways/files/file_data_gateway.dart
index 681d740aed..77b80b37f3 100644
--- a/mobile/apps/photos/lib/gateways/files/file_data_gateway.dart
+++ b/mobile/apps/photos/lib/gateways/files/file_data_gateway.dart
@@ -1,20 +1,10 @@
import "package:dio/dio.dart";
-/// Gateway for file data API endpoints.
-///
-/// Handles file data operations including ML data storage/retrieval,
-/// video preview data, and public collection file data.
class FileDataGateway {
final Dio _enteDio;
FileDataGateway(this._enteDio);
- /// Stores file data (e.g., ML embeddings) for a file.
- ///
- /// [fileID] - The uploaded file ID.
- /// [type] - The type of data being stored.
- /// [encryptedData] - The encrypted data payload.
- /// [decryptionHeader] - Header required for decryption.
Future<void> putFileData({
required int fileID,
required String type,
@@ -32,13 +22,6 @@ class FileDataGateway {
);
}
- /// Fetches file data for the given file IDs.
- ///
- /// [fileIDs] - List of file IDs to fetch data for.
- /// [type] - The type of data to fetch.
- ///
- /// Returns raw response data containing 'data', 'pendingIndexFileIDs',
- /// and 'errFileIDs'.
Future<Map<String, dynamic>> fetchFileData({
required List<int> fileIDs,
required String type,
@@ -50,11 +33,6 @@ class FileDataGateway {
return response.data as Map<String, dynamic>;
}
- /// Gets the file data status diff since the given timestamp.
- ///
- /// [lastUpdatedAt] - Timestamp to fetch changes from.
- ///
- /// Returns the diff data containing updated file data statuses.
Future<Map<String, dynamic>> getStatusDiff({
required int lastUpdatedAt,
}) async {
@@ -65,14 +43,6 @@ class FileDataGateway {
return response.data as Map<String, dynamic>;
}
- /// Stores video preview data for a file.
- ///
- /// [fileID] - The uploaded file ID.
- /// [objectID] - The object ID of the uploaded preview.
- /// [objectSize] - Size of the preview object.
- /// [playlist] - Encrypted HLS playlist data.
- /// [playlistHeader] - Header required for playlist decryption.
- /// [cancelToken] - Optional token to cancel the request.
Future<void> putVideoData({
required int fileID,
required String objectID,
@@ -94,13 +64,6 @@ class FileDataGateway {
);
}
- /// Gets an upload URL for file preview data.
- ///
- /// [fileID] - The uploaded file ID.
- /// [type] - The type of preview (e.g., "vid_preview", "img_preview").
- /// [cancelToken] - Optional token to cancel the request.
- ///
- /// Returns the upload URL and object ID.
Future<({String url, String objectID})> getPreviewUploadUrl({
required int fileID,
required String type,
@@ -117,12 +80,6 @@ class FileDataGateway {
);
}
- /// Gets the preview URL for a file.
- ///
- /// [fileID] - The uploaded file ID.
- /// [type] - The type of preview (e.g., "vid_preview", "img_preview").
- ///
- /// Returns the preview URL.
Future<String> getPreview({required int fileID, required String type}) async {
final response = await _enteDio.get(
"/files/data/preview",
@@ -131,12 +88,6 @@ class FileDataGateway {
return response.data["url"] as String;
}
- /// Fetches file data for a single file (for video preview playlist).
- ///
- /// [fileID] - The uploaded file ID.
- /// [type] - The type of data to fetch.
- ///
- /// Returns the encrypted data and decryption header.
Future<({String encryptedData, String decryptionHeader})>
fetchSingleFileData({required int fileID, required String type}) async {
final response = await _enteDio.get(
@@ -149,15 +100,6 @@ class FileDataGateway {
);
}
- /// Fetches public collection file data.
- ///
- /// [baseUrl] - The base API URL.
- /// [fileID] - The uploaded file ID.
- /// [type] - The type of data to fetch.
- /// [headers] - Headers for public collection authentication.
- /// [nonEnteDio] - Dio instance for non-authenticated requests.
- ///
- /// Returns the encrypted data and decryption header.
Future<({String encryptedData, String decryptionHeader})>
fetchPublicFileData({
required String baseUrl,
@@ -177,15 +119,6 @@ class FileDataGateway {
);
}
- /// Gets the public preview URL for a file.
- ///
- /// [baseUrl] - The base API URL.
- /// [fileID] - The uploaded file ID.
- /// [type] - The type of preview (e.g., "vid_preview", "img_preview").
- /// [headers] - Headers for public collection authentication.
- /// [nonEnteDio] - Dio instance for non-authenticated requests.
- ///
- /// Returns the preview URL.
Future<String> getPublicPreview({
required String baseUrl,
required int fileID,
diff --git a/mobile/apps/photos/lib/gateways/files/file_magic_gateway.dart b/mobile/apps/photos/lib/gateways/files/file_magic_gateway.dart
index 5541a26902..0c6af00616 100644
--- a/mobile/apps/photos/lib/gateways/files/file_magic_gateway.dart
+++ b/mobile/apps/photos/lib/gateways/files/file_magic_gateway.dart
@@ -1,22 +1,11 @@
import "package:dio/dio.dart";
import "package:photos/gateways/collections/models/metadata.dart";
-/// Gateway for file magic metadata API endpoints.
-///
-/// Magic metadata is encrypted key-value data attached to files.
-/// Private magic metadata is only visible to the file owner.
-/// Public magic metadata is visible to anyone the file is shared with.
class FileMagicGateway {
final Dio _enteDio;
FileMagicGateway(this._enteDio);
- /// Updates private magic metadata for one or more files.
- ///
- /// PUT /files/magic-metadata
- ///
- /// [metadataList] contains the encrypted metadata for each file to update.
- /// Throws [DioException] with status 409 if there's a version conflict.
Future<void> updateMagicMetadata(
List<UpdateMagicMetadataRequest> metadataList,
) async {
@@ -26,13 +15,6 @@ class FileMagicGateway {
);
}
- /// Updates public magic metadata for one or more files.
- ///
- /// PUT /files/public-magic-metadata
- ///
- /// [metadataList] contains the encrypted metadata for each file to update.
- /// Public metadata is visible to users the file is shared with.
- /// Throws [DioException] with status 409 if there's a version conflict.
Future<void> updatePublicMagicMetadata(
List<UpdateMagicMetadataRequest> metadataList,
) async {
diff --git a/mobile/apps/photos/lib/gateways/files/file_upload_gateway.dart b/mobile/apps/photos/lib/gateways/files/file_upload_gateway.dart
index 65ffaf361c..447b323461 100644
--- a/mobile/apps/photos/lib/gateways/files/file_upload_gateway.dart
+++ b/mobile/apps/photos/lib/gateways/files/file_upload_gateway.dart
@@ -2,20 +2,11 @@ import "package:dio/dio.dart";
import "package:photos/module/upload/model/multipart.dart";
import "package:photos/module/upload/model/upload_url.dart";
-/// Gateway for file upload API endpoints.
-///
-/// Handles upload URL generation and file creation/update operations.
class FileUploadGateway {
final Dio _enteDio;
FileUploadGateway(this._enteDio);
- /// Gets a checksum-protected upload URL for a single file.
- ///
- /// [contentLength] - The size of the file in bytes.
- /// [contentMd5] - The MD5 hash of the file content.
- ///
- /// Returns an [UploadURL] containing the presigned URL and object key.
Future<UploadURL> getUploadUrl({
required int contentLength,
required String contentMd5,
@@ -27,16 +18,12 @@ class FileUploadGateway {
return UploadURL.fromMap((response.data as Map).cast<String, dynamic>());
}
- /// Validates that the user can upload without minting an upload URL.
- ///
- /// Throws 402 (no subscription) or 426 (storage exceeded) on failure.
- /// Falls back to the legacy upload-urls endpoint when the eligibility
- /// endpoint is not available on older servers.
Future<void> validateUploadEligibility() async {
try {
await _enteDio.get("/files/upload-eligibility");
} on DioException catch (e) {
if (e.response?.statusCode == 404) {
+ // Fall back for older servers without the eligibility endpoint.
await _enteDio.get("/files/upload-urls", queryParameters: {"count": 1});
return;
}
@@ -44,22 +31,6 @@ class FileUploadGateway {
}
}
- /// Creates a new file entry on the server after upload.
- ///
- /// [collectionID] - The collection to add the file to.
- /// [encryptedKey] - The encrypted file key.
- /// [keyDecryptionNonce] - The nonce for decrypting the file key.
- /// [fileObjectKey] - The S3 object key for the file.
- /// [fileDecryptionHeader] - The header for decrypting the file.
- /// [fileSize] - The size of the encrypted file.
- /// [thumbnailObjectKey] - The S3 object key for the thumbnail.
- /// [thumbnailDecryptionHeader] - The header for decrypting the thumbnail.
- /// [thumbnailSize] - The size of the encrypted thumbnail.
- /// [encryptedMetadata] - The encrypted file metadata.
- /// [metadataDecryptionHeader] - The header for decrypting metadata.
- /// [pubMagicMetadata] - Optional public magic metadata.
- ///
- /// Returns a map containing the file ID, owner ID, and updation time.
Future<Map<String, dynamic>> createFile({
required int collectionID,
required String encryptedKey,
@@ -100,19 +71,6 @@ class FileUploadGateway {
return response.data as Map<String, dynamic>;
}
- /// Updates an existing file entry on the server.
- ///
- /// [fileID] - The uploaded file ID to update.
- /// [fileObjectKey] - The new S3 object key for the file.
- /// [fileDecryptionHeader] - The header for decrypting the file.
- /// [fileSize] - The size of the encrypted file.
- /// [thumbnailObjectKey] - The S3 object key for the thumbnail.
- /// [thumbnailDecryptionHeader] - The header for decrypting the thumbnail.
- /// [thumbnailSize] - The size of the encrypted thumbnail.
- /// [encryptedMetadata] - The encrypted file metadata.
- /// [metadataDecryptionHeader] - The header for decrypting metadata.
- ///
- /// Returns a map containing the file ID and updation time.
Future<Map<String, dynamic>> updateFile({
required int fileID,
required String fileObjectKey,
@@ -145,13 +103,6 @@ class FileUploadGateway {
return response.data as Map<String, dynamic>;
}
- /// Gets a checksum-protected multipart upload URL.
- ///
- /// [contentLength] - The total size of the file in bytes.
- /// [partLength] - The size of each part.
- /// [partMd5s] - List of MD5 hashes for each part.
- ///
- /// Returns a [MultipartUploadURLs] containing URLs for all parts.
Future<MultipartUploadURLs> getMultipartUploadUrl({
required int contentLength,
required int partLength,
diff --git a/mobile/apps/photos/lib/gateways/files/files_gateway.dart b/mobile/apps/photos/lib/gateways/files/files_gateway.dart
index 721f22a78c..36d79bdee6 100644
--- a/mobile/apps/photos/lib/gateways/files/files_gateway.dart
+++ b/mobile/apps/photos/lib/gateways/files/files_gateway.dart
@@ -1,20 +1,11 @@
import "package:dio/dio.dart";
import "package:photos/models/duplicate_files.dart";
-/// Gateway for files API endpoints.
-///
-/// Handles file metadata operations like size queries, file info retrieval,
-/// and duplicate detection.
class FilesGateway {
final Dio _enteDio;
FilesGateway(this._enteDio);
- /// Gets the total size of files by their uploaded file IDs.
- ///
- /// [fileIDs] - List of uploaded file IDs to calculate total size for.
- ///
- /// Returns the total size in bytes.
Future<int> getFilesSize(List<int> fileIDs) async {
final response = await _enteDio.post(
"/files/size",
@@ -23,11 +14,6 @@ class FilesGateway {
return response.data["size"] as int;
}
- /// Gets file info including sizes for the given file IDs.
- ///
- /// [fileIDs] - List of uploaded file IDs to get info for.
- ///
- /// Returns a map of uploadedFileID to file size in bytes.
Future<Map<int, int>> getFilesInfo(List<int> fileIDs) async {
final response = await _enteDio.post(
"/files/info",
@@ -43,10 +29,6 @@ class FilesGateway {
return idToSize;
}
- /// Gets duplicate files from the server.
- ///
- /// Returns a [DuplicateFilesResponse] containing groups of files with the
- /// same size (potential duplicates).
Future<DuplicateFilesResponse> getDuplicates() async {
final response = await _enteDio.get("/files/duplicates");
return DuplicateFilesResponse.fromMap(
diff --git a/mobile/apps/photos/lib/gateways/push/push_gateway.dart b/mobile/apps/photos/lib/gateways/push/push_gateway.dart
index 414864106b..86a7732825 100644
--- a/mobile/apps/photos/lib/gateways/push/push_gateway.dart
+++ b/mobile/apps/photos/lib/gateways/push/push_gateway.dart
@@ -1,15 +1,10 @@
import "package:dio/dio.dart";
-/// Gateway for push notification related API endpoints.
class PushGateway {
final Dio _enteDio;
PushGateway(this._enteDio);
- /// Registers the push token with the server.
- ///
- /// [fcmToken] is the Firebase Cloud Messaging token.
- /// [apnsToken] is the optional Apple Push Notification service token.
Future<void> registerToken({
required String fcmToken,
String? apnsToken,
diff --git a/mobile/apps/photos/lib/gateways/social/social_gateway.dart b/mobile/apps/photos/lib/gateways/social/social_gateway.dart
index d571797657..1e80e297e4 100644
--- a/mobile/apps/photos/lib/gateways/social/social_gateway.dart
+++ b/mobile/apps/photos/lib/gateways/social/social_gateway.dart
@@ -1,24 +1,11 @@
import "package:dio/dio.dart";
import "package:photos/models/social/api_responses.dart";
-/// Gateway for social features API endpoints (comments and reactions).
class SocialGateway {
final Dio _enteDio;
SocialGateway(this._enteDio);
- // ============ Comments API ============
-
- /// Creates a new comment on the server.
- ///
- /// [id] - The comment ID
- /// [collectionID] - The collection this comment belongs to
- /// [cipher] - The encrypted comment text (base64)
- /// [nonce] - The encryption nonce (base64)
- /// [fileID] - Optional file ID if commenting on a file
- /// [parentCommentID] - Optional parent comment ID for replies
- ///
- /// Returns the comment ID from the server response.
Future<String> createComment({
required String id,
required int collectionID,
@@ -45,11 +32,6 @@ class SocialGateway {
return response.data["id"] as String;
}
- /// Updates an existing comment.
- ///
- /// [commentID] - The comment ID to update
- /// [cipher] - The new encrypted comment text (base64)
- /// [nonce] - The new encryption nonce (base64)
Future<void> updateComment({
required String commentID,
required String cipher,
@@ -61,19 +43,10 @@ class SocialGateway {
);
}
- /// Deletes a comment (soft delete on server).
Future<void> deleteComment(String commentID) async {
await _enteDio.delete("/comments/$commentID");
}
- /// Fetches comments diff for a collection.
- ///
- /// [collectionID] - The collection to fetch comments from
- /// [sinceTime] - Only fetch comments updated after this timestamp
- /// [limit] - Maximum number of comments to fetch (default 1000, max 2000)
- /// [fileID] - Optional filter for comments on a specific file
- ///
- /// Returns [CommentsDiffResponse] with comments and hasMore flag.
Future<CommentsDiffResponse> fetchCommentsDiff({
required int collectionID,
int? sinceTime,
@@ -99,18 +72,6 @@ class SocialGateway {
return CommentsDiffResponse.fromJson(response.data as Map<String, dynamic>);
}
- // ============ Reactions API ============
-
- /// Creates or updates a reaction (upsert).
- ///
- /// [id] - The reaction ID
- /// [collectionID] - The collection this reaction belongs to
- /// [cipher] - The encrypted reaction type (base64)
- /// [nonce] - The encryption nonce (base64)
- /// [fileID] - Optional file ID if reacting to a file
- /// [commentID] - Optional comment ID if reacting to a comment
- ///
- /// Returns the reaction ID from the server response.
Future<String> upsertReaction({
required String id,
required int collectionID,
@@ -137,20 +98,10 @@ class SocialGateway {
return response.data["id"] as String;
}
- /// Deletes a reaction (soft delete on server).
Future<void> deleteReaction(String reactionID) async {
await _enteDio.delete("/reactions/$reactionID");
}
- /// Fetches reactions diff for a collection.
- ///
- /// [collectionID] - The collection to fetch reactions from
- /// [sinceTime] - Only fetch reactions updated after this timestamp
- /// [limit] - Maximum number of reactions to fetch (default 1000, max 2000)
- /// [fileID] - Optional filter for reactions on a specific file
- /// [commentID] - Optional filter for reactions on a specific comment
- ///
- /// Returns [ReactionsDiffResponse] with reactions and hasMore flag.
Future<ReactionsDiffResponse> fetchReactionsDiff({
required int collectionID,
int? sinceTime,
@@ -182,13 +133,6 @@ class SocialGateway {
);
}
- // ============ Latest Updates API ============
-
- /// Fetches latest update timestamps for all collections accessible to the
- /// user.
- ///
- /// Returns per-collection timestamps for comments, reactions, and anonymous
- /// profiles. Use this to determine which collections need syncing.
Future<LatestUpdatesResponse> fetchLatestUpdates() async {
final response = await _enteDio.get("/comments-reactions/updated-at");
return LatestUpdatesResponse.fromJson(
@@ -196,10 +140,6 @@ class SocialGateway {
);
}
- /// Fetches anonymous profiles for a collection.
- ///
- /// Returns encrypted profile data that needs to be decrypted with the
- /// collection key.
Future<AnonProfilesResponse> fetchAnonProfiles(int collectionID) async {
final response = await _enteDio.get(
"/social/anon-profiles",
@@ -208,17 +148,6 @@ class SocialGateway {
return AnonProfilesResponse.fromJson(response.data as Map<String, dynamic>);
}
- // ============ Unified/Social API ============
-
- /// Fetches both comments and reactions in a single call.
- ///
- /// [collectionID] - The collection to fetch social data from
- /// [commentsSinceTime] - Only fetch comments updated after this timestamp
- /// [reactionsSinceTime] - Only fetch reactions updated after this timestamp
- /// [limit] - Maximum number of items per type (default 1000, max 2000)
- /// [fileID] - Optional filter for items on a specific file
- ///
- /// Returns [SocialDiffResponse] with comments, reactions, and hasMore flags.
Future<SocialDiffResponse> fetchSocialDiff({
required int collectionID,
int? commentsSinceTime,
@@ -248,9 +177,6 @@ class SocialGateway {
return SocialDiffResponse.fromJson(response.data as Map<String, dynamic>);
}
- /// Fetches comment and reaction counts for all collections.
- ///
- /// Returns a map of collectionID -> count.
Future<Map<int, int>> fetchCounts() async {
final response = await _enteDio.get("/comments-reactions/counts");
final countsData = response.data["counts"] as Map<String, dynamic>?;
diff --git a/mobile/apps/photos/lib/gateways/trash/trash_gateway.dart b/mobile/apps/photos/lib/gateways/trash/trash_gateway.dart
index 4667b83408..5e73eeccb4 100644
--- a/mobile/apps/photos/lib/gateways/trash/trash_gateway.dart
+++ b/mobile/apps/photos/lib/gateways/trash/trash_gateway.dart
@@ -1,19 +1,10 @@
import "package:dio/dio.dart";
-/// Gateway for trash API endpoints.
-///
-/// Handles trash operations like fetching trash diff, moving files to trash,
-/// permanently deleting files, and emptying trash.
class TrashGateway {
final Dio _enteDio;
TrashGateway(this._enteDio);
- /// Gets the trash diff since the given time.
- ///
- /// [sinceTime] - Unix timestamp in microseconds to get changes since.
- ///
- /// Returns the raw response data containing the trash diff.
Future<Map<String, dynamic>> getDiff(int sinceTime) async {
final response = await _enteDio.get(
"/trash/v2/diff",
@@ -22,23 +13,14 @@ class TrashGateway {
return response.data as Map<String, dynamic>;
}
- /// Moves files to trash.
- ///
- /// [items] - List of maps containing fileID and collectionID for each file.
Future<void> trashFiles(List<Map<String, dynamic>> items) async {
await _enteDio.post("/files/trash", data: {"items": items});
}
- /// Permanently deletes files from trash.
- ///
- /// [fileIDs] - List of file IDs to permanently delete.
Future<void> deleteFiles(List<int> fileIDs) async {
await _enteDio.post("/trash/delete", data: {"fileIDs": fileIDs});
}
- /// Empties the trash, permanently deleting all trashed files.
- ///
- /// [lastUpdatedAt] - Last sync timestamp to ensure consistency.
Future<void> emptyTrash(int lastUpdatedAt) async {
await _enteDio.post("/trash/empty", data: {"lastUpdatedAt": lastUpdatedAt});
}
diff --git a/mobile/apps/photos/lib/gateways/users/passkey_gateway.dart b/mobile/apps/photos/lib/gateways/users/passkey_gateway.dart
index 694c043932..287ab9eef6 100644
--- a/mobile/apps/photos/lib/gateways/users/passkey_gateway.dart
+++ b/mobile/apps/photos/lib/gateways/users/passkey_gateway.dart
@@ -1,44 +1,20 @@
import "package:dio/dio.dart";
-/// Gateway for passkey-related API endpoints.
-///
-/// Handles passkey authentication, recovery configuration, and account token
-/// retrieval for the Ente accounts portal.
class PasskeyGateway {
final Dio _enteDio;
PasskeyGateway(this._enteDio);
- /// Get accounts token for passkey management.
- ///
- /// Returns a map containing:
- /// - `accountsUrl`: The base URL for accounts portal (or null to use default)
- /// - `accountsToken`: JWT token for authenticating with the accounts portal
- ///
- /// Endpoint: GET /users/accounts-token
Future<Map<String, dynamic>> getAccountsToken() async {
final response = await _enteDio.get("/users/accounts-token");
return response.data as Map<String, dynamic>;
}
- /// Check if passkey recovery is enabled for the user.
- ///
- /// Returns true if the user has configured passkey recovery, false otherwise.
- ///
- /// Endpoint: GET /users/two-factor/recovery-status
Future<bool> isPasskeyRecoveryEnabled() async {
final response = await _enteDio.get("/users/two-factor/recovery-status");
return response.data["isPasskeyRecoveryEnabled"] as bool;
}
- /// Configure passkey recovery for the user.
- ///
- /// Parameters:
- /// - [secret]: The recovery secret
- /// - [userSecretCipher]: The encrypted user secret
- /// - [userSecretNonce]: The nonce used for encrypting the user secret
- ///
- /// Endpoint: POST /users/two-factor/passkeys/configure-recovery
Future<void> configurePasskeyRecovery({
required String secret,
required String userSecretCipher,
diff --git a/mobile/apps/photos/lib/gateways/users/users_gateway.dart b/mobile/apps/photos/lib/gateways/users/users_gateway.dart
index 3e3862ca58..0ffe754ce2 100644
--- a/mobile/apps/photos/lib/gateways/users/users_gateway.dart
+++ b/mobile/apps/photos/lib/gateways/users/users_gateway.dart
@@ -7,10 +7,6 @@ import "package:photos/gateways/users/models/set_recovery_key_request.dart";
import "package:photos/gateways/users/models/srp.dart";
import "package:photos/models/user_details.dart";
-/// Gateway for user-related API endpoints.
-///
-/// Handles authentication, profile management, two-factor authentication,
-/// SRP protocol, and other user account operations.
class UsersGateway {
final Dio _enteDio;
final Dio _publicDio;
@@ -20,18 +16,6 @@ class UsersGateway {
String get _endpoint => _endpointConfig.endpoint;
- // ============================================================
- // Authentication & Email Verification
- // ============================================================
-
- /// Send a one-time token (OTT) to the specified email.
- ///
- /// Parameters:
- /// - [email]: The email address to send the OTT to
- /// - [isChangeEmail]: Whether this is for changing email (purpose = "change")
- /// - [purpose]: Custom purpose string (used if not changing email)
- ///
- /// Endpoint: POST /users/ott
Future<void> sendOtt({
required String email,
bool isChangeEmail = false,
@@ -48,11 +32,6 @@ class UsersGateway {
);
}
- /// Verify email with the one-time token.
- ///
- /// Returns authentication response data containing session IDs and tokens.
- ///
- /// Endpoint: POST /users/verify-email
Future<Map<String, dynamic>> verifyEmail({
required String email,
required String ott,
@@ -69,9 +48,6 @@ class UsersGateway {
return response.data as Map<String, dynamic>;
}
- /// Change the user's email address.
- ///
- /// Endpoint: POST /users/change-email
Future<void> changeEmail({required String email, required String ott}) async {
await _enteDio.post(
"/users/change-email",
@@ -79,15 +55,6 @@ class UsersGateway {
);
}
- // ============================================================
- // User Profile & Details
- // ============================================================
-
- /// Get the user's public key by email.
- ///
- /// Returns null if the email is not associated with an Ente account.
- ///
- /// Endpoint: GET /users/public-key
Future<String?> getPublicKey(String email) async {
try {
final response = await _enteDio.get(
@@ -103,12 +70,6 @@ class UsersGateway {
}
}
- /// Get detailed user information.
- ///
- /// Parameters:
- /// - [memoryCount]: Whether to include memory count in the response
- ///
- /// Endpoint: GET /users/details/v2
Future<UserDetails> getUserDetails({bool memoryCount = true}) async {
final response = await _enteDio.get(
"/users/details/v2",
@@ -117,70 +78,39 @@ class UsersGateway {
return UserDetails.fromMap(response.data);
}
- /// Get all active sessions for the user.
- ///
- /// Endpoint: GET /users/sessions
Future<Sessions> getActiveSessions() async {
final response = await _enteDio.get("/users/sessions");
return Sessions.fromMap(response.data);
}
- /// Terminate a specific session.
- ///
- /// Endpoint: DELETE /users/session
Future<void> terminateSession(String token) async {
await _enteDio.delete("/users/session", queryParameters: {"token": token});
}
- /// Log out the current session.
- ///
- /// Endpoint: POST /users/logout
Future<void> logout() async {
await _enteDio.post("/users/logout");
}
- // ============================================================
- // Family Plan
- // ============================================================
-
- /// Leave the family plan.
- ///
- /// Endpoint: DELETE /family/leave
Future<void> leaveFamilyPlan() async {
await _enteDio.delete("/family/leave");
}
- /// Create a family with the current user as the admin.
- ///
- /// Endpoint: POST /family/create
Future<void> createFamily() async {
await _enteDio.post("/family/create");
}
- /// Invite a user to join the current user's family.
- ///
- /// Endpoint: POST /family/add-member
Future<void> inviteFamilyMember({required String email}) async {
await _enteDio.post("/family/add-member", data: {"email": email});
}
- /// Remove an active family member.
- ///
- /// Endpoint: DELETE /family/remove-member/:id
Future<void> removeFamilyMember(String id) async {
await _enteDio.delete("/family/remove-member/$id");
}
- /// Revoke a pending family invite.
- ///
- /// Endpoint: DELETE /family/revoke-invite/:id
Future<void> revokeFamilyInvite(String id) async {
await _enteDio.delete("/family/revoke-invite/$id");
}
- /// Update a family member's storage limit.
- ///
- /// Endpoint: POST /family/modify-storage
Future<void> updateFamilyMemberStorage({
required String id,
int? storageLimit,
@@ -191,13 +121,6 @@ class UsersGateway {
);
}
- // ============================================================
- // Key Attributes & Recovery
- // ============================================================
-
- /// Set the user's key attributes.
- ///
- /// Endpoint: PUT /users/attributes
Future<void> setKeyAttributes(KeyAttributes keyAttributes) async {
await _enteDio.put(
"/users/attributes",
@@ -205,22 +128,10 @@ class UsersGateway {
);
}
- /// Set the user's recovery key.
- ///
- /// Endpoint: PUT /users/recovery-key
Future<void> setRecoveryKey(SetRecoveryKeyRequest request) async {
await _enteDio.put("/users/recovery-key", data: request.toMap());
}
- // ============================================================
- // SRP (Secure Remote Password) Protocol
- // ============================================================
-
- /// Get SRP attributes for the given email.
- ///
- /// Throws [SrpSetupNotCompleteError] if SRP is not set up for this user.
- ///
- /// Endpoint: GET /users/srp/attributes
Future<SrpAttributes> getSrpAttributes(String email) async {
try {
final response = await _publicDio.get(
@@ -236,11 +147,6 @@ class UsersGateway {
}
}
- /// Set up SRP for the user.
- ///
- /// Returns the setup response containing setupID and srpB.
- ///
- /// Endpoint: POST /users/srp/setup
Future<SetupSRPResponse> setupSrp(SetupSRPRequest request) async {
final response = await _enteDio.post(
"/users/srp/setup",
@@ -249,9 +155,6 @@ class UsersGateway {
return SetupSRPResponse.fromJson(response.data);
}
- /// Complete the SRP setup.
- ///
- /// Endpoint: POST /users/srp/complete
Future<void> completeSrp({
required String setupID,
required String srpM1,
@@ -262,9 +165,6 @@ class UsersGateway {
);
}
- /// Update SRP with new key attributes.
- ///
- /// Endpoint: POST /users/srp/update
Future<void> updateSrp({
required String setupID,
required String srpM1,
@@ -282,13 +182,6 @@ class UsersGateway {
);
}
- /// Create an SRP session for login.
- ///
- /// Returns a map containing:
- /// - `sessionID`: The session ID for verification
- /// - `srpB`: Server's public value
- ///
- /// Endpoint: POST /users/srp/create-session
Future<Map<String, dynamic>> createSrpSession({
required String srpUserID,
required String srpA,
@@ -300,11 +193,6 @@ class UsersGateway {
return response.data as Map<String, dynamic>;
}
- /// Verify an SRP session.
- ///
- /// Returns authentication response data.
- ///
- /// Endpoint: POST /users/srp/verify-session
Future<Map<String, dynamic>> verifySrpSession({
required String sessionID,
required String srpUserID,
@@ -317,33 +205,16 @@ class UsersGateway {
return response.data as Map<String, dynamic>;
}
- // ============================================================
- // Two-Factor Authentication
- // ============================================================
-
- /// Get the two-factor authentication status.
- ///
- /// Endpoint: GET /users/two-factor/status
Future<bool> getTwoFactorStatus() async {
final response = await _enteDio.get("/users/two-factor/status");
return response.data["status"] as bool;
}
- /// Set up two-factor authentication.
- ///
- /// Returns a map containing:
- /// - `secretCode`: The TOTP secret code
- /// - `qrCode`: QR code data for authenticator apps
- ///
- /// Endpoint: POST /users/two-factor/setup
Future<Map<String, dynamic>> setupTwoFactor() async {
final response = await _enteDio.post("/users/two-factor/setup");
return response.data as Map<String, dynamic>;
}
- /// Enable two-factor authentication.
- ///
- /// Endpoint: POST /users/two-factor/enable
Future<void> enableTwoFactor({
required String code,
required String encryptedTwoFactorSecret,
@@ -359,18 +230,10 @@ class UsersGateway {
);
}
- /// Disable two-factor authentication.
- ///
- /// Endpoint: POST /users/two-factor/disable
Future<void> disableTwoFactor() async {
await _enteDio.post("/users/two-factor/disable");
}
- /// Verify a two-factor authentication code during login.
- ///
- /// Returns authentication response data.
- ///
- /// Endpoint: POST /users/two-factor/verify
Future<Map<String, dynamic>> verifyTwoFactor({
required String sessionID,
required String code,
@@ -382,13 +245,6 @@ class UsersGateway {
return response.data as Map<String, dynamic>;
}
- /// Get two-factor recovery information.
- ///
- /// Returns a map containing:
- /// - `encryptedSecret`: The encrypted 2FA secret
- /// - `secretDecryptionNonce`: The nonce for decrypting the secret
- ///
- /// Endpoint: GET /users/two-factor/recover
Future<Map<String, dynamic>> recoverTwoFactor({
required String sessionID,
required String twoFactorType,
@@ -400,11 +256,6 @@ class UsersGateway {
return response.data as Map<String, dynamic>;
}
- /// Remove two-factor authentication using recovery key.
- ///
- /// Returns authentication response data.
- ///
- /// Endpoint: POST /users/two-factor/remove
Future<Map<String, dynamic>> removeTwoFactor({
required String sessionID,
required String secret,
@@ -421,12 +272,6 @@ class UsersGateway {
return response.data as Map<String, dynamic>;
}
- /// Get token for passkey session during authentication.
- ///
- /// Throws [PassKeySessionExpiredError] if session expired (404/410).
- /// Throws [PassKeySessionNotVerifiedError] if session not verified (400).
- ///
- /// Endpoint: GET /users/two-factor/passkeys/get-token
Future<Map<String, dynamic>> getTokenForPasskeySession(
String sessionID,
) async {
@@ -449,38 +294,15 @@ class UsersGateway {
}
}
- // ============================================================
- // Email MFA
- // ============================================================
-
- /// Update email MFA setting.
- ///
- /// Endpoint: PUT /users/email-mfa
Future<void> updateEmailMFA({required bool isEnabled}) async {
await _enteDio.put("/users/email-mfa", data: {"isEnabled": isEnabled});
}
- // ============================================================
- // Payment & Billing
- // ============================================================
-
- /// Get the payment token for Stripe.
- ///
- /// Returns the payment token string, or null on failure.
- ///
- /// Endpoint: GET /users/payment-token
Future<String?> getPaymentToken() async {
final response = await _enteDio.get("/users/payment-token");
return response.data["paymentToken"] as String?;
}
- // ============================================================
- // Feedback
- // ============================================================
-
- /// Send anonymous feedback.
- ///
- /// Endpoint: POST /anonymous/feedback
Future<void> sendFeedback({
required String feedback,
required String type,