mirror of
https://ghfast.top/https://github.com/StarCitizenToolBox/app.git
synced 2025-06-28 12:34:45 +08:00
fix: 因 RSI 官网变更,移除自动填充功能 (不再支持)
This commit is contained in:
@ -42,13 +42,6 @@ class HomeGameLoginDialogUI extends HookConsumerWidget {
|
||||
Text(S.current.home_title_logging_in),
|
||||
const SizedBox(height: 12),
|
||||
const ProgressRing(),
|
||||
if (loginState.isDeviceSupportWinHello ?? false)
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
S.current.home_info_auto_fill_notice,
|
||||
style: TextStyle(
|
||||
fontSize: 13, color: Colors.white.withOpacity(.6)),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -4,16 +4,13 @@ import 'dart:io';
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:local_auth/local_auth.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:cryptography/cryptography.dart';
|
||||
import 'package:desktop_webview_window/desktop_webview_window.dart';
|
||||
import 'package:jwt_decode/jwt_decode.dart';
|
||||
import 'package:starcitizen_doctor/common/helper/system_helper.dart';
|
||||
import 'package:starcitizen_doctor/common/utils/base_utils.dart';
|
||||
import 'package:starcitizen_doctor/common/utils/log.dart';
|
||||
import 'package:starcitizen_doctor/common/utils/provider.dart';
|
||||
import 'package:starcitizen_doctor/common/win32/credentials.dart';
|
||||
import 'package:starcitizen_doctor/data/rsi_game_library_data.dart';
|
||||
import 'package:starcitizen_doctor/ui/home/home_ui_model.dart';
|
||||
import 'package:starcitizen_doctor/ui/webview/webview.dart';
|
||||
@ -46,25 +43,20 @@ class HomeGameLoginUIModel extends _$HomeGameLoginUIModel {
|
||||
return HomeGameLoginState(loginStatus: 0);
|
||||
}
|
||||
|
||||
final LocalAuthentication _localAuth = LocalAuthentication();
|
||||
|
||||
// ignore: avoid_build_context_in_providers
|
||||
Future<void> launchWebLogin(BuildContext context) async {
|
||||
final homeState = ref.read(homeUIModelProvider);
|
||||
final isDeviceSupportWinHello = await _localAuth.isDeviceSupported();
|
||||
state = state.copyWith(isDeviceSupportWinHello: isDeviceSupportWinHello);
|
||||
|
||||
if (!context.mounted) return;
|
||||
goWebView(context, S.current.home_action_login_rsi_account,
|
||||
"https://robertsspaceindustries.com/connect", loginMode: true,
|
||||
rsiLoginCallback: (message, ok) async {
|
||||
"https://robertsspaceindustries.com/connect?jumpto=/connect",
|
||||
loginMode: true, rsiLoginCallback: (message, ok) async {
|
||||
// dPrint(
|
||||
// "======rsiLoginCallback=== $ok ===== data==\n${json.encode(message)}");
|
||||
if (message == null || !ok) {
|
||||
Navigator.pop(context);
|
||||
return;
|
||||
}
|
||||
dPrint("web message == $message");
|
||||
|
||||
// final emailBox = await Hive.openBox("quick_login_email");
|
||||
final data = message["data"];
|
||||
final authToken = data["authToken"];
|
||||
@ -78,13 +70,6 @@ class HomeGameLoginUIModel extends _$HomeGameLoginUIModel {
|
||||
final Map<String, dynamic> payload = Jwt.parseJwt(authToken!);
|
||||
final nickname = payload["nickname"] ?? "";
|
||||
|
||||
final inputEmail = data["inputEmail"];
|
||||
final inputPassword = data["inputPassword"];
|
||||
|
||||
final userBox = await Hive.openBox("rsi_account_data");
|
||||
if (inputEmail != null && inputEmail != "") {
|
||||
await userBox.put("account_email", inputEmail);
|
||||
}
|
||||
state = state.copyWith(
|
||||
nickname: nickname,
|
||||
avatarUrl: avatarUrl,
|
||||
@ -94,37 +79,11 @@ class HomeGameLoginUIModel extends _$HomeGameLoginUIModel {
|
||||
libraryData: libraryData,
|
||||
);
|
||||
|
||||
if (isDeviceSupportWinHello) {
|
||||
if (await userBox.get("enable", defaultValue: true)) {
|
||||
if (inputEmail != null &&
|
||||
inputEmail != "" &&
|
||||
inputPassword != null &&
|
||||
inputPassword != "") {
|
||||
if (!context.mounted) return;
|
||||
final ok = await showConfirmDialogs(
|
||||
context,
|
||||
S.current.home_action_q_auto_password_fill_prompt,
|
||||
Text(S.current.home_login_info_password_encryption_notice));
|
||||
if (ok == true) {
|
||||
if (await _localAuth.authenticate(
|
||||
localizedReason:
|
||||
S.current.home_login_info_enter_pin_to_encrypt) ==
|
||||
true) {
|
||||
await _savePwd(inputEmail, inputPassword);
|
||||
}
|
||||
} else {
|
||||
await userBox.put("enable", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final buildInfoFile =
|
||||
File("${homeState.scInstalledPath}\\build_manifest.id");
|
||||
if (await buildInfoFile.exists()) {
|
||||
final buildInfo =
|
||||
json.decode(await buildInfoFile.readAsString())["Data"];
|
||||
dPrint("buildInfo ======= $buildInfo");
|
||||
|
||||
if (releaseInfo?["versionLabel"] != null &&
|
||||
buildInfo["RequestedP4ChangeNum"] != null) {
|
||||
@ -265,33 +224,4 @@ class HomeGameLoginUIModel extends _$HomeGameLoginUIModel {
|
||||
}
|
||||
return "PTU";
|
||||
}
|
||||
|
||||
_savePwd(String inputEmail, String inputPassword) async {
|
||||
final algorithm = AesGcm.with256bits();
|
||||
final secretKey = await algorithm.newSecretKey();
|
||||
final nonce = algorithm.newNonce();
|
||||
|
||||
final secretBox = await algorithm.encrypt(utf8.encode(inputPassword),
|
||||
secretKey: secretKey, nonce: nonce);
|
||||
|
||||
await algorithm.decrypt(
|
||||
SecretBox(secretBox.cipherText,
|
||||
nonce: secretBox.nonce, mac: secretBox.mac),
|
||||
secretKey: secretKey);
|
||||
|
||||
final pwdEncrypted = base64.encode(secretBox.cipherText);
|
||||
|
||||
final userBox = await Hive.openBox("rsi_account_data");
|
||||
await userBox.put("account_email", inputEmail);
|
||||
await userBox.put("account_pwd_encrypted", pwdEncrypted);
|
||||
await userBox.put("nonce", base64.encode(secretBox.nonce));
|
||||
await userBox.put("mac", base64.encode(secretBox.mac.bytes));
|
||||
|
||||
final secretKeyStr = base64.encode((await secretKey.extractBytes()));
|
||||
|
||||
Win32Credentials.write(
|
||||
credentialName: "SCToolbox_RSI_Account_secret",
|
||||
userName: inputEmail,
|
||||
password: secretKeyStr);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ part of 'home_game_login_dialog_ui_model.dart';
|
||||
// **************************************************************************
|
||||
|
||||
String _$homeGameLoginUIModelHash() =>
|
||||
r'55ae072fdc222a015661e50f2d8d60e95911ce14';
|
||||
r'862fac9e29e55937e1246542feac75cf55062182';
|
||||
|
||||
/// See also [HomeGameLoginUIModel].
|
||||
@ProviderFor(HomeGameLoginUIModel)
|
||||
|
Reference in New Issue
Block a user