2021-06-29 15:03:54 +00:00
|
|
|
import 'dart:typed_data';
|
|
|
|
|
2020-04-30 15:09:41 +00:00
|
|
|
import 'package:dio/dio.dart';
|
2020-08-25 06:00:19 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2021-06-27 10:23:53 +00:00
|
|
|
import 'package:flutter_sodium/flutter_sodium.dart';
|
2020-05-02 16:28:54 +00:00
|
|
|
import 'package:logging/logging.dart';
|
2020-05-04 20:08:20 +00:00
|
|
|
import 'package:photos/core/configuration.dart';
|
2021-06-29 09:48:01 +00:00
|
|
|
import 'package:photos/core/event_bus.dart';
|
2020-11-19 18:22:30 +00:00
|
|
|
import 'package:photos/core/network.dart';
|
2020-10-17 18:16:30 +00:00
|
|
|
import 'package:photos/db/public_keys_db.dart';
|
2021-06-29 09:48:01 +00:00
|
|
|
import 'package:photos/events/two_factor_status_change_event.dart';
|
2021-10-30 05:43:56 +00:00
|
|
|
import 'package:photos/events/user_details_changed_event.dart';
|
2022-07-08 08:50:19 +00:00
|
|
|
import 'package:photos/models/delete_account.dart';
|
2020-09-05 08:53:23 +00:00
|
|
|
import 'package:photos/models/key_attributes.dart';
|
2021-03-29 15:09:12 +00:00
|
|
|
import 'package:photos/models/key_gen_result.dart';
|
2020-10-18 21:39:55 +00:00
|
|
|
import 'package:photos/models/public_key.dart';
|
2021-11-23 19:40:33 +00:00
|
|
|
import 'package:photos/models/sessions.dart';
|
2021-03-28 12:43:44 +00:00
|
|
|
import 'package:photos/models/set_keys_request.dart';
|
2021-04-01 17:33:15 +00:00
|
|
|
import 'package:photos/models/set_recovery_key_request.dart';
|
2021-07-28 14:08:27 +00:00
|
|
|
import 'package:photos/models/user_details.dart';
|
2022-07-01 14:18:05 +00:00
|
|
|
import 'package:photos/ui/account/login_page.dart';
|
|
|
|
import 'package:photos/ui/account/ott_verification_page.dart';
|
|
|
|
import 'package:photos/ui/account/password_entry_page.dart';
|
|
|
|
import 'package:photos/ui/account/password_reentry_page.dart';
|
|
|
|
import 'package:photos/ui/account/two_factor_authentication_page.dart';
|
|
|
|
import 'package:photos/ui/account/two_factor_recovery_page.dart';
|
|
|
|
import 'package:photos/ui/account/two_factor_setup_page.dart';
|
2021-06-27 10:23:53 +00:00
|
|
|
import 'package:photos/utils/crypto_util.dart';
|
2020-08-25 06:00:19 +00:00
|
|
|
import 'package:photos/utils/dialog_util.dart';
|
2021-06-29 09:48:01 +00:00
|
|
|
import 'package:photos/utils/navigation_util.dart';
|
2020-08-26 02:34:13 +00:00
|
|
|
import 'package:photos/utils/toast_util.dart';
|
2021-10-30 05:43:56 +00:00
|
|
|
|
2020-10-03 17:56:18 +00:00
|
|
|
class UserService {
|
2020-11-19 18:22:30 +00:00
|
|
|
final _dio = Network.instance.getDio();
|
2022-06-03 01:43:45 +00:00
|
|
|
final _logger = Logger((UserService).toString());
|
2020-10-21 21:29:16 +00:00
|
|
|
final _config = Configuration.instance;
|
2022-06-23 13:10:35 +00:00
|
|
|
ValueNotifier<String> emailValueNotifier;
|
2020-04-30 15:09:41 +00:00
|
|
|
|
2020-10-03 17:56:18 +00:00
|
|
|
UserService._privateConstructor();
|
|
|
|
static final UserService instance = UserService._privateConstructor();
|
2020-04-30 15:09:41 +00:00
|
|
|
|
2022-06-23 13:10:35 +00:00
|
|
|
Future<void> init() async {
|
|
|
|
emailValueNotifier =
|
|
|
|
ValueNotifier<String>(Configuration.instance.getEmail());
|
|
|
|
}
|
|
|
|
|
2022-07-06 16:57:31 +00:00
|
|
|
Future<void> sendOtt(
|
2021-07-28 18:06:30 +00:00
|
|
|
BuildContext context,
|
|
|
|
String email, {
|
|
|
|
bool isChangeEmail = false,
|
2022-06-23 12:12:19 +00:00
|
|
|
bool isCreateAccountScreen = false,
|
2021-07-28 18:06:30 +00:00
|
|
|
}) async {
|
2022-06-03 01:46:29 +00:00
|
|
|
final dialog = createProgressDialog(context, "Please wait...");
|
2020-08-25 06:00:19 +00:00
|
|
|
await dialog.show();
|
2021-07-28 18:41:46 +00:00
|
|
|
try {
|
2022-07-06 16:57:31 +00:00
|
|
|
final response = await _dio.post(
|
2021-07-28 18:41:46 +00:00
|
|
|
_config.getHttpEndpoint() + "/users/ott",
|
2022-07-06 16:57:31 +00:00
|
|
|
data: {"email": email, "purpose": isChangeEmail ? "change" : ""},
|
2021-07-28 18:41:46 +00:00
|
|
|
);
|
2020-08-25 06:00:19 +00:00
|
|
|
await dialog.hide();
|
2021-07-28 18:06:30 +00:00
|
|
|
if (response != null && response.statusCode == 200) {
|
|
|
|
Navigator.of(context).push(
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (BuildContext context) {
|
2022-06-11 08:23:52 +00:00
|
|
|
return OTTVerificationPage(
|
|
|
|
email,
|
|
|
|
isChangeEmail: isChangeEmail,
|
|
|
|
isCreateAccountScreen: isCreateAccountScreen,
|
|
|
|
);
|
2021-07-28 18:06:30 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2021-07-28 18:41:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
showGenericErrorDialog(context);
|
|
|
|
} on DioError catch (e) {
|
|
|
|
await dialog.hide();
|
2022-02-05 16:43:40 +00:00
|
|
|
_logger.info(e);
|
2021-07-28 18:41:46 +00:00
|
|
|
if (e.response != null && e.response.statusCode == 403) {
|
2022-06-10 06:02:48 +00:00
|
|
|
showErrorDialog(context, "Oops", "This email is already in use");
|
2020-08-25 06:00:19 +00:00
|
|
|
} else {
|
|
|
|
showGenericErrorDialog(context);
|
|
|
|
}
|
2021-07-28 18:41:46 +00:00
|
|
|
} catch (e) {
|
|
|
|
await dialog.hide();
|
|
|
|
_logger.severe(e);
|
|
|
|
showGenericErrorDialog(context);
|
|
|
|
}
|
2020-08-25 06:00:19 +00:00
|
|
|
}
|
|
|
|
|
2020-10-17 18:04:41 +00:00
|
|
|
Future<String> getPublicKey(String email) async {
|
2020-10-09 21:45:19 +00:00
|
|
|
try {
|
|
|
|
final response = await _dio.get(
|
2020-10-21 21:29:16 +00:00
|
|
|
_config.getHttpEndpoint() + "/users/public-key",
|
2020-10-17 18:04:41 +00:00
|
|
|
queryParameters: {"email": email},
|
2020-10-09 21:45:19 +00:00
|
|
|
options: Options(
|
|
|
|
headers: {
|
2020-10-21 21:29:16 +00:00
|
|
|
"X-Auth-Token": _config.getToken(),
|
2020-10-09 21:45:19 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2020-10-18 21:39:55 +00:00
|
|
|
final publicKey = response.data["publicKey"];
|
|
|
|
await PublicKeysDB.instance.setKey(PublicKey(email, publicKey));
|
2020-10-17 18:16:30 +00:00
|
|
|
return publicKey;
|
2020-10-09 21:45:19 +00:00
|
|
|
} on DioError catch (e) {
|
|
|
|
_logger.info(e);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-30 09:23:55 +00:00
|
|
|
Future<UserDetails> getUserDetailsV2({bool memoryCount = true}) async {
|
2022-04-14 13:01:24 +00:00
|
|
|
try {
|
|
|
|
final response = await _dio.get(
|
|
|
|
_config.getHttpEndpoint() +
|
2022-05-30 09:23:55 +00:00
|
|
|
"/users/details/v2?memoryCount=$memoryCount",
|
|
|
|
queryParameters: {
|
|
|
|
"memoryCount": memoryCount,
|
|
|
|
},
|
2022-04-14 13:01:24 +00:00
|
|
|
options: Options(
|
|
|
|
headers: {
|
|
|
|
"X-Auth-Token": _config.getToken(),
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
return UserDetails.fromMap(response.data);
|
|
|
|
} on DioError catch (e) {
|
|
|
|
_logger.info(e);
|
|
|
|
rethrow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-23 19:40:33 +00:00
|
|
|
Future<Sessions> getActiveSessions() async {
|
|
|
|
try {
|
|
|
|
final response = await _dio.get(
|
|
|
|
_config.getHttpEndpoint() + "/users/sessions",
|
|
|
|
options: Options(
|
|
|
|
headers: {
|
|
|
|
"X-Auth-Token": _config.getToken(),
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
return Sessions.fromMap(response.data);
|
|
|
|
} on DioError catch (e) {
|
|
|
|
_logger.info(e);
|
|
|
|
rethrow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-23 19:48:24 +00:00
|
|
|
Future<void> terminateSession(String token) async {
|
|
|
|
try {
|
2022-06-11 08:23:52 +00:00
|
|
|
await _dio.delete(
|
|
|
|
_config.getHttpEndpoint() + "/users/session",
|
|
|
|
options: Options(
|
|
|
|
headers: {
|
|
|
|
"X-Auth-Token": _config.getToken(),
|
|
|
|
},
|
|
|
|
),
|
|
|
|
queryParameters: {
|
|
|
|
"token": token,
|
|
|
|
},
|
|
|
|
);
|
2021-11-23 19:48:24 +00:00
|
|
|
} on DioError catch (e) {
|
|
|
|
_logger.info(e);
|
|
|
|
rethrow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-20 19:36:33 +00:00
|
|
|
Future<void> leaveFamilyPlan() async {
|
|
|
|
try {
|
2022-06-11 08:23:52 +00:00
|
|
|
await _dio.delete(
|
|
|
|
_config.getHttpEndpoint() + "/family/leave",
|
|
|
|
options: Options(
|
|
|
|
headers: {
|
|
|
|
"X-Auth-Token": _config.getToken(),
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2022-04-20 19:36:33 +00:00
|
|
|
} on DioError catch (e) {
|
|
|
|
_logger.warning('failed to leave family plan', e);
|
|
|
|
rethrow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-05 13:31:37 +00:00
|
|
|
Future<void> logout(BuildContext context) async {
|
2022-06-03 01:49:05 +00:00
|
|
|
final dialog = createProgressDialog(context, "Logging out...");
|
2021-07-05 13:31:37 +00:00
|
|
|
await dialog.show();
|
2021-07-05 09:31:03 +00:00
|
|
|
try {
|
2022-06-11 08:23:52 +00:00
|
|
|
final response = await _dio.post(
|
|
|
|
_config.getHttpEndpoint() + "/users/logout",
|
|
|
|
options: Options(
|
|
|
|
headers: {
|
|
|
|
"X-Auth-Token": _config.getToken(),
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2021-07-05 13:31:37 +00:00
|
|
|
if (response != null && response.statusCode == 200) {
|
|
|
|
await Configuration.instance.logout();
|
|
|
|
await dialog.hide();
|
|
|
|
Navigator.of(context).popUntil((route) => route.isFirst);
|
|
|
|
} else {
|
2022-06-03 01:49:05 +00:00
|
|
|
throw Exception("Log out action failed");
|
2021-07-05 13:31:37 +00:00
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_logger.severe(e);
|
|
|
|
await dialog.hide();
|
|
|
|
showGenericErrorDialog(context);
|
2021-07-05 09:31:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-08 08:50:19 +00:00
|
|
|
Future<DeleteChallengeResponse> getDeleteChallenge(
|
|
|
|
BuildContext context,
|
|
|
|
) async {
|
|
|
|
final dialog = createProgressDialog(context, "Please wait...");
|
|
|
|
await dialog.show();
|
|
|
|
try {
|
|
|
|
final response = await _dio.get(
|
|
|
|
_config.getHttpEndpoint() + "/users/delete-challenge",
|
|
|
|
options: Options(
|
|
|
|
headers: {
|
|
|
|
"X-Auth-Token": _config.getToken(),
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
if (response != null && response.statusCode == 200) {
|
|
|
|
// clear data
|
|
|
|
await dialog.hide();
|
|
|
|
return DeleteChallengeResponse(
|
|
|
|
allowDelete: response.data["allowDelete"] as bool,
|
|
|
|
encryptedChallenge: response.data["encryptedChallenge"],
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
throw Exception("delete action failed");
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_logger.severe(e);
|
|
|
|
await dialog.hide();
|
|
|
|
await showGenericErrorDialog(context);
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> deleteAccount(
|
|
|
|
BuildContext context,
|
|
|
|
String challengeResponse,
|
|
|
|
) async {
|
2022-07-07 08:09:38 +00:00
|
|
|
final dialog = createProgressDialog(context, "Deleting account...");
|
|
|
|
await dialog.show();
|
|
|
|
try {
|
|
|
|
final response = await _dio.delete(
|
|
|
|
_config.getHttpEndpoint() + "/users/delete",
|
2022-07-08 08:50:19 +00:00
|
|
|
data: {
|
|
|
|
"challenge": challengeResponse,
|
|
|
|
},
|
2022-07-07 08:09:38 +00:00
|
|
|
options: Options(
|
|
|
|
headers: {
|
|
|
|
"X-Auth-Token": _config.getToken(),
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
if (response != null && response.statusCode == 200) {
|
|
|
|
// clear data
|
|
|
|
await Configuration.instance.logout();
|
|
|
|
await dialog.hide();
|
2022-07-08 08:50:19 +00:00
|
|
|
showToast(
|
|
|
|
context,
|
2022-07-08 09:35:09 +00:00
|
|
|
"We have deleted your account and scheduled your uploaded data "
|
|
|
|
"for deletion.",
|
2022-07-08 08:50:19 +00:00
|
|
|
);
|
2022-07-07 08:09:38 +00:00
|
|
|
Navigator.of(context).popUntil((route) => route.isFirst);
|
|
|
|
} else {
|
|
|
|
throw Exception("delete action failed");
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_logger.severe(e);
|
|
|
|
await dialog.hide();
|
|
|
|
showGenericErrorDialog(context);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-12 09:44:00 +00:00
|
|
|
Future<void> verifyEmail(BuildContext context, String ott) async {
|
2022-06-03 01:46:29 +00:00
|
|
|
final dialog = createProgressDialog(context, "Please wait...");
|
2020-08-25 06:00:19 +00:00
|
|
|
await dialog.show();
|
2021-03-21 12:04:57 +00:00
|
|
|
try {
|
2021-06-12 09:44:00 +00:00
|
|
|
final response = await _dio.post(
|
|
|
|
_config.getHttpEndpoint() + "/users/verify-email",
|
|
|
|
data: {
|
2021-03-21 12:04:57 +00:00
|
|
|
"email": _config.getEmail(),
|
|
|
|
"ott": ott,
|
|
|
|
},
|
|
|
|
);
|
2020-08-25 06:00:19 +00:00
|
|
|
await dialog.hide();
|
2020-08-26 00:26:07 +00:00
|
|
|
if (response != null && response.statusCode == 200) {
|
2021-07-22 18:41:58 +00:00
|
|
|
Widget page;
|
2021-06-26 10:37:17 +00:00
|
|
|
final String twoFASessionID = response.data["twoFactorSessionID"];
|
|
|
|
if (twoFASessionID != null && twoFASessionID.isNotEmpty) {
|
|
|
|
page = TwoFactorAuthenticationPage(twoFASessionID);
|
2020-08-26 01:43:10 +00:00
|
|
|
} else {
|
2021-06-26 10:37:17 +00:00
|
|
|
await _saveConfiguration(response);
|
|
|
|
if (Configuration.instance.getEncryptedToken() != null) {
|
2022-07-04 08:43:01 +00:00
|
|
|
page = const PasswordReentryPage();
|
2021-06-26 10:37:17 +00:00
|
|
|
} else {
|
2022-07-04 08:43:01 +00:00
|
|
|
page = const PasswordEntryPage();
|
2021-06-26 10:37:17 +00:00
|
|
|
}
|
2020-08-26 01:43:10 +00:00
|
|
|
}
|
2020-08-26 02:34:13 +00:00
|
|
|
Navigator.of(context).pushAndRemoveUntil(
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return page;
|
|
|
|
},
|
|
|
|
),
|
2021-10-30 05:43:56 +00:00
|
|
|
(route) => route.isFirst,
|
2020-08-26 02:34:13 +00:00
|
|
|
);
|
2020-08-25 06:00:19 +00:00
|
|
|
} else {
|
2021-09-04 10:21:07 +00:00
|
|
|
// should never reach here
|
|
|
|
throw Exception("unexpected response during email verification");
|
2020-08-25 06:00:19 +00:00
|
|
|
}
|
2021-09-04 10:21:07 +00:00
|
|
|
} on DioError catch (e) {
|
2022-02-05 16:43:40 +00:00
|
|
|
_logger.info(e);
|
2021-09-04 10:21:07 +00:00
|
|
|
await dialog.hide();
|
|
|
|
if (e.response != null && e.response.statusCode == 410) {
|
2022-02-04 05:31:07 +00:00
|
|
|
await showErrorDialog(
|
2022-06-11 08:23:52 +00:00
|
|
|
context,
|
|
|
|
"Oops",
|
|
|
|
"Your verification code has expired",
|
|
|
|
);
|
2021-09-04 10:21:07 +00:00
|
|
|
Navigator.of(context).pop();
|
|
|
|
} else {
|
2022-06-11 08:23:52 +00:00
|
|
|
showErrorDialog(
|
|
|
|
context,
|
|
|
|
"Incorrect code",
|
|
|
|
"Sorry, the code you've entered is incorrect",
|
|
|
|
);
|
2021-09-04 10:21:07 +00:00
|
|
|
}
|
2021-09-04 11:32:39 +00:00
|
|
|
} catch (e) {
|
2021-03-21 12:04:57 +00:00
|
|
|
await dialog.hide();
|
|
|
|
_logger.severe(e);
|
2022-05-16 21:01:52 +00:00
|
|
|
showErrorDialog(context, "Oops", "Verification failed, please try again");
|
2021-03-21 12:04:57 +00:00
|
|
|
}
|
2020-08-25 06:00:19 +00:00
|
|
|
}
|
|
|
|
|
2022-06-23 13:06:35 +00:00
|
|
|
Future<void> setEmail(String email) async {
|
|
|
|
await _config.setEmail(email);
|
|
|
|
emailValueNotifier.value = email ?? "";
|
|
|
|
}
|
|
|
|
|
2021-07-28 18:06:30 +00:00
|
|
|
Future<void> changeEmail(
|
|
|
|
BuildContext context,
|
|
|
|
String email,
|
|
|
|
String ott,
|
|
|
|
) async {
|
2022-06-03 01:46:29 +00:00
|
|
|
final dialog = createProgressDialog(context, "Please wait...");
|
2021-07-28 18:06:30 +00:00
|
|
|
await dialog.show();
|
|
|
|
try {
|
|
|
|
final response = await _dio.post(
|
|
|
|
_config.getHttpEndpoint() + "/users/change-email",
|
|
|
|
data: {
|
|
|
|
"email": email,
|
|
|
|
"ott": ott,
|
|
|
|
},
|
|
|
|
options: Options(
|
|
|
|
headers: {
|
|
|
|
"X-Auth-Token": _config.getToken(),
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
await dialog.hide();
|
|
|
|
if (response != null && response.statusCode == 200) {
|
2022-06-10 14:29:56 +00:00
|
|
|
showToast(context, "Email changed to " + email);
|
2022-06-23 13:06:35 +00:00
|
|
|
await setEmail(email);
|
2021-07-28 18:06:30 +00:00
|
|
|
Navigator.of(context).popUntil((route) => route.isFirst);
|
2021-09-15 20:56:05 +00:00
|
|
|
Bus.instance.fire(UserDetailsChangedEvent());
|
2021-07-28 18:06:30 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-06-03 01:46:29 +00:00
|
|
|
showErrorDialog(context, "Oops", "Verification failed, please try again");
|
2021-07-28 18:06:30 +00:00
|
|
|
} on DioError catch (e) {
|
|
|
|
await dialog.hide();
|
|
|
|
if (e.response != null && e.response.statusCode == 403) {
|
2022-06-03 01:46:29 +00:00
|
|
|
showErrorDialog(context, "Oops", "This email is already in use");
|
2021-07-28 18:06:30 +00:00
|
|
|
} else {
|
2022-06-11 08:23:52 +00:00
|
|
|
showErrorDialog(
|
|
|
|
context,
|
|
|
|
"Incorrect code",
|
|
|
|
"Authentication failed, please try again",
|
|
|
|
);
|
2021-07-28 18:06:30 +00:00
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
await dialog.hide();
|
|
|
|
_logger.severe(e);
|
2022-06-03 01:46:29 +00:00
|
|
|
showErrorDialog(context, "Oops", "Verification failed, please try again");
|
2021-07-28 18:06:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-01 14:26:08 +00:00
|
|
|
Future<void> setAttributes(KeyGenResult result) async {
|
2021-03-26 16:13:32 +00:00
|
|
|
try {
|
|
|
|
final name = _config.getName();
|
2021-03-29 18:35:46 +00:00
|
|
|
await _dio.put(
|
2021-03-26 16:13:32 +00:00
|
|
|
_config.getHttpEndpoint() + "/users/attributes",
|
|
|
|
data: {
|
|
|
|
"name": name,
|
|
|
|
"keyAttributes": result.keyAttributes.toMap(),
|
2020-08-26 01:43:10 +00:00
|
|
|
},
|
2021-03-26 16:13:32 +00:00
|
|
|
options: Options(
|
|
|
|
headers: {
|
|
|
|
"X-Auth-Token": _config.getToken(),
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2021-03-29 18:35:46 +00:00
|
|
|
await _config.setKey(result.privateKeyAttributes.key);
|
|
|
|
await _config.setSecretKey(result.privateKeyAttributes.secretKey);
|
|
|
|
await _config.setKeyAttributes(result.keyAttributes);
|
2021-03-26 16:13:32 +00:00
|
|
|
} catch (e) {
|
|
|
|
_logger.severe(e);
|
2021-07-22 18:41:58 +00:00
|
|
|
rethrow;
|
2021-03-26 16:13:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-01 14:26:08 +00:00
|
|
|
Future<void> updateKeyAttributes(KeyAttributes keyAttributes) async {
|
2021-03-26 16:13:32 +00:00
|
|
|
try {
|
2021-03-28 12:43:44 +00:00
|
|
|
final setKeyRequest = SetKeysRequest(
|
|
|
|
kekSalt: keyAttributes.kekSalt,
|
|
|
|
encryptedKey: keyAttributes.encryptedKey,
|
|
|
|
keyDecryptionNonce: keyAttributes.keyDecryptionNonce,
|
|
|
|
memLimit: keyAttributes.memLimit,
|
|
|
|
opsLimit: keyAttributes.opsLimit,
|
|
|
|
);
|
2021-04-01 14:26:08 +00:00
|
|
|
await _dio.put(
|
2021-03-28 12:43:44 +00:00
|
|
|
_config.getHttpEndpoint() + "/users/keys",
|
|
|
|
data: setKeyRequest.toMap(),
|
2021-03-26 16:13:32 +00:00
|
|
|
options: Options(
|
|
|
|
headers: {
|
|
|
|
"X-Auth-Token": _config.getToken(),
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
2021-04-01 14:26:08 +00:00
|
|
|
await _config.setKeyAttributes(keyAttributes);
|
2021-03-26 16:13:32 +00:00
|
|
|
} catch (e) {
|
|
|
|
_logger.severe(e);
|
2021-07-22 18:41:58 +00:00
|
|
|
rethrow;
|
2021-03-26 16:13:32 +00:00
|
|
|
}
|
2020-08-26 01:43:10 +00:00
|
|
|
}
|
|
|
|
|
2021-04-01 17:33:15 +00:00
|
|
|
Future<void> setRecoveryKey(KeyAttributes keyAttributes) async {
|
|
|
|
try {
|
|
|
|
final setRecoveryKeyRequest = SetRecoveryKeyRequest(
|
|
|
|
keyAttributes.masterKeyEncryptedWithRecoveryKey,
|
|
|
|
keyAttributes.masterKeyDecryptionNonce,
|
|
|
|
keyAttributes.recoveryKeyEncryptedWithMasterKey,
|
|
|
|
keyAttributes.recoveryKeyDecryptionNonce,
|
|
|
|
);
|
|
|
|
await _dio.put(
|
|
|
|
_config.getHttpEndpoint() + "/users/recovery-key",
|
|
|
|
data: setRecoveryKeyRequest.toMap(),
|
|
|
|
options: Options(
|
|
|
|
headers: {
|
|
|
|
"X-Auth-Token": _config.getToken(),
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
await _config.setKeyAttributes(keyAttributes);
|
|
|
|
} catch (e) {
|
|
|
|
_logger.severe(e);
|
2021-07-22 18:41:58 +00:00
|
|
|
rethrow;
|
2021-04-01 17:33:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-26 10:37:17 +00:00
|
|
|
Future<void> verifyTwoFactor(
|
2022-06-11 08:23:52 +00:00
|
|
|
BuildContext context,
|
|
|
|
String sessionID,
|
|
|
|
String code,
|
|
|
|
) async {
|
2022-06-03 01:46:29 +00:00
|
|
|
final dialog = createProgressDialog(context, "Authenticating...");
|
2021-06-26 10:37:17 +00:00
|
|
|
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 != null && response.statusCode == 200) {
|
2022-06-10 14:29:56 +00:00
|
|
|
showToast(context, "Authentication successful!");
|
2021-06-26 10:37:17 +00:00
|
|
|
await _saveConfiguration(response);
|
|
|
|
Navigator.of(context).pushAndRemoveUntil(
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (BuildContext context) {
|
2022-07-04 08:43:01 +00:00
|
|
|
return const PasswordReentryPage();
|
2021-06-26 10:37:17 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
(route) => route.isFirst,
|
|
|
|
);
|
|
|
|
}
|
2021-06-26 10:56:52 +00:00
|
|
|
} on DioError catch (e) {
|
|
|
|
await dialog.hide();
|
|
|
|
_logger.severe(e);
|
|
|
|
if (e.response != null && e.response.statusCode == 404) {
|
2022-06-10 14:29:56 +00:00
|
|
|
showToast(context, "Session expired");
|
2021-06-26 10:56:52 +00:00
|
|
|
Navigator.of(context).pushAndRemoveUntil(
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (BuildContext context) {
|
2022-07-04 08:43:01 +00:00
|
|
|
return const LoginPage();
|
2021-06-26 10:56:52 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
(route) => route.isFirst,
|
|
|
|
);
|
|
|
|
} else {
|
2022-06-11 08:23:52 +00:00
|
|
|
showErrorDialog(
|
|
|
|
context,
|
|
|
|
"Incorrect code",
|
|
|
|
"Authentication failed, please try again",
|
|
|
|
);
|
2021-06-26 10:56:52 +00:00
|
|
|
}
|
2021-06-26 10:37:17 +00:00
|
|
|
} catch (e) {
|
|
|
|
await dialog.hide();
|
|
|
|
_logger.severe(e);
|
2022-02-04 05:31:07 +00:00
|
|
|
showErrorDialog(
|
2022-06-11 08:23:52 +00:00
|
|
|
context,
|
|
|
|
"Oops",
|
|
|
|
"Authentication failed, please try again",
|
|
|
|
);
|
2021-06-26 10:37:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-27 10:23:53 +00:00
|
|
|
Future<void> recoverTwoFactor(BuildContext context, String sessionID) async {
|
2022-06-03 01:46:29 +00:00
|
|
|
final dialog = createProgressDialog(context, "Please wait...");
|
2021-06-27 10:23:53 +00:00
|
|
|
await dialog.show();
|
|
|
|
try {
|
|
|
|
final response = await _dio.get(
|
|
|
|
_config.getHttpEndpoint() + "/users/two-factor/recover",
|
|
|
|
queryParameters: {
|
|
|
|
"sessionID": sessionID,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
if (response != null && response.statusCode == 200) {
|
|
|
|
Navigator.of(context).pushAndRemoveUntil(
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return TwoFactorRecoveryPage(
|
2022-06-11 08:23:52 +00:00
|
|
|
sessionID,
|
|
|
|
response.data["encryptedSecret"],
|
|
|
|
response.data["secretDecryptionNonce"],
|
|
|
|
);
|
2021-06-27 10:23:53 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
(route) => route.isFirst,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} on DioError catch (e) {
|
|
|
|
_logger.severe(e);
|
|
|
|
if (e.response != null && e.response.statusCode == 404) {
|
2022-06-10 14:29:56 +00:00
|
|
|
showToast(context, "Session expired");
|
2021-06-27 10:23:53 +00:00
|
|
|
Navigator.of(context).pushAndRemoveUntil(
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (BuildContext context) {
|
2022-07-04 08:43:01 +00:00
|
|
|
return const LoginPage();
|
2021-06-27 10:23:53 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
(route) => route.isFirst,
|
|
|
|
);
|
|
|
|
} else {
|
2022-02-04 05:31:07 +00:00
|
|
|
showErrorDialog(
|
2022-06-11 08:23:52 +00:00
|
|
|
context,
|
|
|
|
"Oops",
|
|
|
|
"Something went wrong, please try again",
|
|
|
|
);
|
2021-06-27 10:23:53 +00:00
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_logger.severe(e);
|
2022-02-04 05:31:07 +00:00
|
|
|
showErrorDialog(
|
2022-06-11 08:23:52 +00:00
|
|
|
context,
|
|
|
|
"Oops",
|
|
|
|
"Something went wrong, please try again",
|
|
|
|
);
|
2021-06-27 10:23:53 +00:00
|
|
|
} finally {
|
|
|
|
await dialog.hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> removeTwoFactor(
|
|
|
|
BuildContext context,
|
|
|
|
String sessionID,
|
|
|
|
String recoveryKey,
|
|
|
|
String encryptedSecret,
|
|
|
|
String secretDecryptionNonce,
|
|
|
|
) async {
|
2022-06-03 01:46:29 +00:00
|
|
|
final dialog = createProgressDialog(context, "Please wait...");
|
2021-06-27 10:23:53 +00:00
|
|
|
await dialog.show();
|
|
|
|
String secret;
|
|
|
|
try {
|
2022-06-11 08:23:52 +00:00
|
|
|
secret = Sodium.bin2base64(
|
|
|
|
await CryptoUtil.decrypt(
|
2021-06-27 10:23:53 +00:00
|
|
|
Sodium.base642bin(encryptedSecret),
|
|
|
|
Sodium.hex2bin(recoveryKey.trim()),
|
2022-06-11 08:23:52 +00:00
|
|
|
Sodium.base642bin(secretDecryptionNonce),
|
|
|
|
),
|
|
|
|
);
|
2021-06-27 10:23:53 +00:00
|
|
|
} catch (e) {
|
|
|
|
await dialog.hide();
|
2022-06-11 08:23:52 +00:00
|
|
|
showErrorDialog(
|
|
|
|
context,
|
|
|
|
"Incorrect recovery key",
|
|
|
|
"The recovery key you entered is incorrect",
|
|
|
|
);
|
2021-06-27 10:23:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
final response = await _dio.post(
|
|
|
|
_config.getHttpEndpoint() + "/users/two-factor/remove",
|
|
|
|
data: {
|
|
|
|
"sessionID": sessionID,
|
|
|
|
"secret": secret,
|
|
|
|
},
|
|
|
|
);
|
|
|
|
if (response != null && response.statusCode == 200) {
|
2022-06-10 14:29:56 +00:00
|
|
|
showShortToast(context, "Two-factor authentication successfully reset");
|
2021-06-27 10:23:53 +00:00
|
|
|
await _saveConfiguration(response);
|
|
|
|
Navigator.of(context).pushAndRemoveUntil(
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (BuildContext context) {
|
2022-07-04 08:43:01 +00:00
|
|
|
return const PasswordReentryPage();
|
2021-06-27 10:23:53 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
(route) => route.isFirst,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} on DioError catch (e) {
|
|
|
|
_logger.severe(e);
|
|
|
|
if (e.response != null && e.response.statusCode == 404) {
|
2022-06-10 14:29:56 +00:00
|
|
|
showToast(context, "Session expired");
|
2021-06-27 10:23:53 +00:00
|
|
|
Navigator.of(context).pushAndRemoveUntil(
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (BuildContext context) {
|
2022-07-04 08:43:01 +00:00
|
|
|
return const LoginPage();
|
2021-06-27 10:23:53 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
(route) => route.isFirst,
|
|
|
|
);
|
|
|
|
} else {
|
2022-02-04 05:31:07 +00:00
|
|
|
showErrorDialog(
|
2022-06-11 08:23:52 +00:00
|
|
|
context,
|
|
|
|
"Oops",
|
|
|
|
"Something went wrong, please try again",
|
|
|
|
);
|
2021-06-27 10:23:53 +00:00
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
_logger.severe(e);
|
2022-02-04 05:31:07 +00:00
|
|
|
showErrorDialog(
|
2022-06-11 08:23:52 +00:00
|
|
|
context,
|
|
|
|
"Oops",
|
|
|
|
"Something went wrong, please try again",
|
|
|
|
);
|
2021-06-27 10:23:53 +00:00
|
|
|
} finally {
|
|
|
|
await dialog.hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-29 09:48:01 +00:00
|
|
|
Future<void> setupTwoFactor(BuildContext context) async {
|
2022-06-03 01:46:29 +00:00
|
|
|
final dialog = createProgressDialog(context, "Please wait...");
|
2021-06-29 09:48:01 +00:00
|
|
|
await dialog.show();
|
|
|
|
try {
|
|
|
|
final response = await _dio.post(
|
|
|
|
_config.getHttpEndpoint() + "/users/two-factor/setup",
|
|
|
|
options: Options(
|
|
|
|
headers: {
|
|
|
|
"X-Auth-Token": _config.getToken(),
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
await dialog.hide();
|
|
|
|
routeToPage(
|
2022-06-11 08:23:52 +00:00
|
|
|
context,
|
|
|
|
TwoFactorSetupPage(
|
|
|
|
response.data["secretCode"],
|
|
|
|
response.data["qrCode"],
|
|
|
|
),
|
|
|
|
);
|
2022-07-13 03:42:37 +00:00
|
|
|
} catch (e) {
|
2021-06-29 09:48:01 +00:00
|
|
|
await dialog.hide();
|
2022-07-13 03:42:37 +00:00
|
|
|
_logger.severe("Failed to setup tfa", e);
|
2021-07-22 18:41:58 +00:00
|
|
|
rethrow;
|
2021-06-29 09:48:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-29 11:13:55 +00:00
|
|
|
Future<bool> enableTwoFactor(
|
2022-06-11 08:23:52 +00:00
|
|
|
BuildContext context,
|
|
|
|
String secret,
|
|
|
|
String code,
|
|
|
|
) async {
|
2021-07-22 18:41:58 +00:00
|
|
|
Uint8List recoveryKey;
|
2021-06-29 09:48:01 +00:00
|
|
|
try {
|
2021-06-29 15:03:54 +00:00
|
|
|
recoveryKey = await getOrCreateRecoveryKey(context);
|
|
|
|
} catch (e) {
|
|
|
|
showGenericErrorDialog(context);
|
|
|
|
return false;
|
2021-06-29 09:48:01 +00:00
|
|
|
}
|
2022-06-03 01:46:29 +00:00
|
|
|
final dialog = createProgressDialog(context, "Verifying...");
|
2021-06-29 15:03:54 +00:00
|
|
|
await dialog.show();
|
|
|
|
final encryptionResult =
|
|
|
|
CryptoUtil.encryptSync(Sodium.base642bin(secret), recoveryKey);
|
2021-06-29 09:48:01 +00:00
|
|
|
try {
|
|
|
|
await _dio.post(
|
|
|
|
_config.getHttpEndpoint() + "/users/two-factor/enable",
|
|
|
|
data: {
|
|
|
|
"code": code,
|
|
|
|
"encryptedTwoFactorSecret":
|
|
|
|
Sodium.bin2base64(encryptionResult.encryptedData),
|
|
|
|
"twoFactorSecretDecryptionNonce":
|
|
|
|
Sodium.bin2base64(encryptionResult.nonce),
|
|
|
|
},
|
|
|
|
options: Options(
|
|
|
|
headers: {
|
|
|
|
"X-Auth-Token": _config.getToken(),
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
await dialog.hide();
|
|
|
|
Navigator.pop(context);
|
|
|
|
Bus.instance.fire(TwoFactorStatusChangeEvent(true));
|
2021-06-29 11:13:55 +00:00
|
|
|
return true;
|
2021-06-29 09:48:01 +00:00
|
|
|
} catch (e, s) {
|
|
|
|
await dialog.hide();
|
|
|
|
_logger.severe(e, s);
|
|
|
|
if (e is DioError) {
|
|
|
|
if (e.response != null && e.response.statusCode == 401) {
|
2022-06-11 08:23:52 +00:00
|
|
|
showErrorDialog(
|
|
|
|
context,
|
|
|
|
"Incorrect code",
|
|
|
|
"Please verify the code you have entered",
|
|
|
|
);
|
2021-06-29 11:13:55 +00:00
|
|
|
return false;
|
2021-06-29 09:48:01 +00:00
|
|
|
}
|
|
|
|
}
|
2022-06-11 08:23:52 +00:00
|
|
|
showErrorDialog(
|
|
|
|
context,
|
|
|
|
"Something went wrong",
|
|
|
|
"Please contact support if the problem persists",
|
|
|
|
);
|
2021-06-29 09:48:01 +00:00
|
|
|
}
|
2021-06-29 11:13:55 +00:00
|
|
|
return false;
|
2021-06-29 09:48:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Future<void> disableTwoFactor(BuildContext context) async {
|
|
|
|
final dialog =
|
2022-06-03 01:46:29 +00:00
|
|
|
createProgressDialog(context, "Disabling two-factor authentication...");
|
2021-06-29 09:48:01 +00:00
|
|
|
await dialog.show();
|
|
|
|
try {
|
|
|
|
await _dio.post(
|
|
|
|
_config.getHttpEndpoint() + "/users/two-factor/disable",
|
|
|
|
options: Options(
|
|
|
|
headers: {
|
|
|
|
"X-Auth-Token": _config.getToken(),
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
Bus.instance.fire(TwoFactorStatusChangeEvent(false));
|
|
|
|
await dialog.hide();
|
2022-06-10 14:29:56 +00:00
|
|
|
showToast(context, "Two-factor authentication has been disabled");
|
2022-07-13 03:42:37 +00:00
|
|
|
} catch (e) {
|
2021-06-29 09:48:01 +00:00
|
|
|
await dialog.hide();
|
2022-07-13 03:42:37 +00:00
|
|
|
_logger.severe("Failed to disabled 2FA", e);
|
2022-06-11 08:23:52 +00:00
|
|
|
showErrorDialog(
|
|
|
|
context,
|
|
|
|
"Something went wrong",
|
|
|
|
"Please contact support if the problem persists",
|
|
|
|
);
|
2021-06-29 09:48:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<bool> fetchTwoFactorStatus() async {
|
|
|
|
try {
|
|
|
|
final response = await _dio.get(
|
|
|
|
_config.getHttpEndpoint() + "/users/two-factor/status",
|
|
|
|
options: Options(
|
|
|
|
headers: {
|
|
|
|
"X-Auth-Token": _config.getToken(),
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
return response.data["status"];
|
2022-07-13 03:42:37 +00:00
|
|
|
} catch (e) {
|
|
|
|
_logger.severe("Failed to fetch 2FA status", e);
|
2021-07-22 18:41:58 +00:00
|
|
|
rethrow;
|
2021-06-29 09:48:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-29 15:03:54 +00:00
|
|
|
Future<Uint8List> getOrCreateRecoveryKey(BuildContext context) async {
|
|
|
|
final encryptedRecoveryKey =
|
|
|
|
_config.getKeyAttributes().recoveryKeyEncryptedWithMasterKey;
|
|
|
|
if (encryptedRecoveryKey == null || encryptedRecoveryKey.isEmpty) {
|
2022-06-03 01:46:29 +00:00
|
|
|
final dialog = createProgressDialog(context, "Please wait...");
|
2021-06-29 15:03:54 +00:00
|
|
|
await dialog.show();
|
|
|
|
try {
|
|
|
|
final keyAttributes = await _config.createNewRecoveryKey();
|
|
|
|
await setRecoveryKey(keyAttributes);
|
|
|
|
await dialog.hide();
|
|
|
|
} catch (e, s) {
|
|
|
|
await dialog.hide();
|
|
|
|
_logger.severe(e, s);
|
2021-07-22 18:41:58 +00:00
|
|
|
rethrow;
|
2021-06-29 15:03:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
final recoveryKey = _config.getRecoveryKey();
|
|
|
|
return recoveryKey;
|
|
|
|
}
|
|
|
|
|
2021-08-17 10:51:12 +00:00
|
|
|
Future<String> getPaymentToken() async {
|
|
|
|
try {
|
2022-08-29 14:43:31 +00:00
|
|
|
final response = await _dio.get(
|
2022-07-03 09:45:00 +00:00
|
|
|
"${_config.getHttpEndpoint()}/users/payment-token",
|
2021-08-17 10:51:12 +00:00
|
|
|
options: Options(
|
|
|
|
headers: {
|
|
|
|
"X-Auth-Token": _config.getToken(),
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
if (response != null && response.statusCode == 200) {
|
|
|
|
return response.data["paymentToken"];
|
|
|
|
} else {
|
|
|
|
throw Exception("non 200 ok response");
|
|
|
|
}
|
2022-07-13 03:42:37 +00:00
|
|
|
} catch (e) {
|
|
|
|
_logger.severe("Failed to get payment token", e);
|
2021-08-17 10:51:12 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-20 10:15:08 +00:00
|
|
|
Future<String> getFamiliesToken() async {
|
|
|
|
try {
|
2022-08-29 14:43:31 +00:00
|
|
|
final response = await _dio.get(
|
2022-07-03 09:45:00 +00:00
|
|
|
"${_config.getHttpEndpoint()}/users/families-token",
|
2022-04-20 10:15:08 +00:00
|
|
|
options: Options(
|
|
|
|
headers: {
|
|
|
|
"X-Auth-Token": _config.getToken(),
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
if (response != null && response.statusCode == 200) {
|
|
|
|
return response.data["familiesToken"];
|
|
|
|
} else {
|
|
|
|
throw Exception("non 200 ok response");
|
|
|
|
}
|
|
|
|
} catch (e, s) {
|
|
|
|
_logger.severe("failed to fetch families token", e, s);
|
|
|
|
rethrow;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-06 06:30:44 +00:00
|
|
|
Future<void> _saveConfiguration(Response response) async {
|
|
|
|
await Configuration.instance.setUserID(response.data["id"]);
|
2021-06-12 09:44:00 +00:00
|
|
|
if (response.data["encryptedToken"] != null) {
|
2020-09-06 06:30:44 +00:00
|
|
|
await Configuration.instance
|
2021-06-12 09:44:00 +00:00
|
|
|
.setEncryptedToken(response.data["encryptedToken"]);
|
|
|
|
await Configuration.instance.setKeyAttributes(
|
2022-06-11 08:23:52 +00:00
|
|
|
KeyAttributes.fromMap(response.data["keyAttributes"]),
|
|
|
|
);
|
2021-06-12 09:44:00 +00:00
|
|
|
} else {
|
|
|
|
await Configuration.instance.setToken(response.data["token"]);
|
2020-08-15 01:22:14 +00:00
|
|
|
}
|
2020-07-31 22:58:30 +00:00
|
|
|
}
|
2020-04-30 15:09:41 +00:00
|
|
|
}
|