parent
784e5254e2
commit
23046f08a9
8 changed files with 448 additions and 36 deletions
|
|
@ -31,6 +31,7 @@ import "package:nexus/models/requests/get_room_state.dart";
|
|||
import "package:nexus/models/requests/get_space_hierarchy.dart";
|
||||
import "package:nexus/models/requests/join_room.dart";
|
||||
import "package:nexus/models/profile_response.dart";
|
||||
import "package:nexus/models/recovery_key.dart";
|
||||
import "package:nexus/models/requests/oauth/exchange_token.dart";
|
||||
import "package:nexus/models/requests/oauth/get_auth_url.dart";
|
||||
import "package:nexus/models/requests/oauth/register_client.dart";
|
||||
|
|
@ -190,6 +191,33 @@ class ClientController extends AsyncNotifier<int> {
|
|||
}
|
||||
}
|
||||
|
||||
Future<RecoveryKey> generateRecoveryKey({String passphrase = ""}) async =>
|
||||
.fromJson(
|
||||
await _sendCommand("generate_recovery_key", {"passphrase": passphrase}),
|
||||
);
|
||||
|
||||
Future<void> resetEncryption(RecoveryKey key) =>
|
||||
_sendCommand("reset_encryption", key.toJson());
|
||||
|
||||
Future<Uri?> getCrossSigningResetUrl(Uri homeserver) async {
|
||||
const action = "org.matrix.cross_signing_reset";
|
||||
final oauth = (await _sendCommand("get_login_flows", {
|
||||
"homeserver_url": homeserver.toString(),
|
||||
}))["oauth"];
|
||||
|
||||
if (oauth?["account_management_uri"] case final String uri
|
||||
when (oauth["account_management_actions_supported"] as List?)?.contains(
|
||||
action,
|
||||
) ??
|
||||
false) {
|
||||
final parsed = Uri.parse(uri);
|
||||
return parsed.replace(
|
||||
queryParameters: {...parsed.queryParameters, "action": action},
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<String> joinRoom(JoinRoomRequest request) async =>
|
||||
(await _sendCommand("join_room", request.toJson()))["room_id"];
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ import "package:nexus/models/room_order.dart";
|
|||
import "package:nexus/models/settings_category.dart";
|
||||
import "package:nexus/main.dart";
|
||||
import "package:nexus/widgets/settings/dialog_list_tile.dart";
|
||||
import "package:nexus/widgets/reset_encryption_sheet.dart";
|
||||
import "package:nexus/helpers/extensions/show_adaptive_sheet.dart";
|
||||
|
||||
class SettingsSectionsController
|
||||
extends AsyncNotifier<IMap<String, IList<SettingsCategory>>> {
|
||||
|
|
@ -312,6 +314,21 @@ class SettingsSectionsController
|
|||
title: "Other",
|
||||
icon: Icons.key,
|
||||
settings: .new([
|
||||
.new(
|
||||
title: "Reset Encryption Identity",
|
||||
description: "Replace your encryption identity and recovery key with new ones, if you've lost your recovery key or your encryption is broken.",
|
||||
builder: (title, description, icon) => Builder(
|
||||
builder: (context) => M3EButton.icon(
|
||||
onPressed: () => context.showAdaptiveSheet(
|
||||
(_) => const ResetEncryptionSheet(),
|
||||
),
|
||||
label: Text(title),
|
||||
icon: Icon(icon),
|
||||
tooltip: description,
|
||||
),
|
||||
),
|
||||
icon: Icons.key_off,
|
||||
),
|
||||
.new(
|
||||
title: "Log Out",
|
||||
description:
|
||||
|
|
|
|||
Loading…
Reference in a new issue