Skip to content

armgit / ente

Public Imported from GitHub
0

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

feat: implement AccountDeletionHost and AccountDeletionSettings classes

AmanRajSinghMourya235647a5c476
diff --git a/mobile/packages/account_deletion/lib/src/account_deletion_host.dart b/mobile/packages/account_deletion/lib/src/account_deletion_host.dart
new file mode 100644
index 0000000000..85bae3239b
--- /dev/null
+++ b/mobile/packages/account_deletion/lib/src/account_deletion_host.dart
@@ -0,0 +1,7 @@
+abstract class AccountDeletionHost {
+ /// Decrypts the account deletion challenge using the host's keypair and
+ /// returns the decoded challenge that is sent back to the server.
+ String decryptDeleteChallenge(String encryptedChallenge);
+
+ Future<void> logout();
+}
diff --git a/mobile/packages/account_deletion/lib/src/account_deletion_settings.dart b/mobile/packages/account_deletion/lib/src/account_deletion_settings.dart
new file mode 100644
index 0000000000..b7231fcaed
--- /dev/null
+++ b/mobile/packages/account_deletion/lib/src/account_deletion_settings.dart
@@ -0,0 +1,37 @@
+import 'package:dio/dio.dart';
+import 'package:ente_account_deletion/src/account_deletion_host.dart';
+import 'package:ente_account_deletion/src/services/account_deletion_service.dart';
+
+class AccountDeletionSettings {
+ AccountDeletionSettings._privateConstructor();
+
+ static final AccountDeletionSettings instance =
+ AccountDeletionSettings._privateConstructor();
+
+ AccountDeletionHost? _host;
+ AccountDeletionService? _service;
+
+ void init({
+ required AccountDeletionHost host,
+ required Dio enteDio,
+ }) {
+ _host = host;
+ _service = AccountDeletionService(enteDio);
+ }
+
+ AccountDeletionHost get host {
+ final host = _host;
+ if (host == null) {
+ throw StateError('AccountDeletionSettings.init must be called first');
+ }
+ return host;
+ }
+
+ AccountDeletionService get service {
+ final service = _service;
+ if (service == null) {
+ throw StateError('AccountDeletionSettings.init must be called first');
+ }
+ return service;
+ }
+}