mirror of
https://ghfast.top/https://github.com/StarCitizenToolBox/app.git
synced 2025-06-28 10:14:45 +08:00
fix: 因 RSI 官网变更,移除自动填充功能 (不再支持)
This commit is contained in:
@ -3,17 +3,14 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:cryptography/cryptography.dart';
|
||||
import 'package:desktop_webview_window/desktop_webview_window.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:local_auth/local_auth.dart';
|
||||
import 'package:starcitizen_doctor/common/conf/url_conf.dart';
|
||||
import 'package:starcitizen_doctor/common/io/rs_http.dart';
|
||||
import 'package:starcitizen_doctor/common/utils/base_utils.dart';
|
||||
import 'package:starcitizen_doctor/common/utils/log.dart';
|
||||
import 'package:starcitizen_doctor/common/win32/credentials.dart';
|
||||
import 'package:starcitizen_doctor/data/app_version_data.dart';
|
||||
import 'package:starcitizen_doctor/data/app_web_localization_versions_data.dart';
|
||||
|
||||
@ -188,7 +185,6 @@ class WebViewModel {
|
||||
final message = json.decode(messageString);
|
||||
if (message["action"] == "webview_rsi_login_show_window") {
|
||||
webview.setWebviewWindowVisibility(true);
|
||||
_checkAutoLogin(webview);
|
||||
} else if (message["action"] == "webview_rsi_login_success") {
|
||||
_loginModeSuccess = true;
|
||||
loginCallback?.call(message, true);
|
||||
@ -302,39 +298,4 @@ class WebViewModel {
|
||||
}
|
||||
_isClosed = true;
|
||||
}
|
||||
|
||||
Future<void> _checkAutoLogin(Webview webview) async {
|
||||
final LocalAuthentication localAuth = LocalAuthentication();
|
||||
if (!await localAuth.isDeviceSupported()) return;
|
||||
|
||||
final userBox = await Hive.openBox("rsi_account_data");
|
||||
final email = await userBox.get("account_email", defaultValue: "");
|
||||
|
||||
final pwdE = await userBox.get("account_pwd_encrypted", defaultValue: "");
|
||||
final nonceStr = await userBox.get("nonce", defaultValue: "");
|
||||
final macStr = await userBox.get("mac", defaultValue: "");
|
||||
if (email == "") return;
|
||||
webview.evaluateJavaScript("RSIAutoLogin(\"$email\",\"\")");
|
||||
if (pwdE != "" && nonceStr != "" && macStr != "") {
|
||||
// send toast
|
||||
final toastMsg =
|
||||
S.current.webview_localization_device_windows_hello_toast;
|
||||
webview.evaluateJavaScript("SCTShowToast(\"$toastMsg\")");
|
||||
// decrypt
|
||||
if (await localAuth.authenticate(
|
||||
localizedReason:
|
||||
S.current.webview_localization_enter_device_pin) !=
|
||||
true) return;
|
||||
final kv = Win32Credentials.read("SCToolbox_RSI_Account_secret");
|
||||
if (kv == null || kv.key != email) return;
|
||||
|
||||
final algorithm = AesGcm.with256bits();
|
||||
final r = await algorithm.decrypt(
|
||||
SecretBox(base64.decode(pwdE),
|
||||
nonce: base64.decode(nonceStr), mac: Mac(base64.decode(macStr))),
|
||||
secretKey: SecretKey(base64.decode(kv.value)));
|
||||
final decryptedPwd = utf8.decode(r);
|
||||
webview.evaluateJavaScript("RSIAutoLogin(\"$email\",\"$decryptedPwd\")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user