aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src-tauri/src/core/auth.rs
diff options
context:
space:
mode:
author苏向夜 <46275354+fu050409@users.noreply.github.com>2026-02-25 02:06:07 +0800
committerGitHub <noreply@github.com>2026-02-25 02:06:07 +0800
commit78ac61904d78d558d092eff08c9f261cbdb187e8 (patch)
tree96f68d1f1554ee3a0532793afaaa52b0c73dcbec /src-tauri/src/core/auth.rs
parent8ff3af6cb908fd824b512379dd21ed4f595ab6bb (diff)
parent329734b23957b84cde2af459fa61c7385fb5b5f1 (diff)
downloadDropOut-78ac61904d78d558d092eff08c9f261cbdb187e8.tar.gz
DropOut-78ac61904d78d558d092eff08c9f261cbdb187e8.zip
feat(ui): partial react rewrite (#77)
## Summary by Sourcery Export backend data structures to TypeScript for the new React-based UI and update CI to build additional targets. New Features: - Generate TypeScript definitions for core backend structs and enums used by the UI. - Now use our own Azure app(_DropOut_) to finish the authorize process. Enhancements: - Annotate existing Rust models with ts-rs metadata to control exported TypeScript shapes, including tagged enums and opaque JSON fields. Build: - Add ts-rs as a dependency for generating TypeScript bindings from Rust types. CI: - Extend the Semifold CI workflow to run on the dev branch and build additional Linux musl and Windows GNU targets using cross where needed.
Diffstat (limited to 'src-tauri/src/core/auth.rs')
-rw-r--r--src-tauri/src/core/auth.rs28
1 files changed, 20 insertions, 8 deletions
diff --git a/src-tauri/src/core/auth.rs b/src-tauri/src/core/auth.rs
index d5e6c17..03752fd 100644
--- a/src-tauri/src/core/auth.rs
+++ b/src-tauri/src/core/auth.rs
@@ -1,5 +1,6 @@
use serde::{Deserialize, Serialize};
use std::sync::Mutex;
+use ts_rs::TS;
use uuid::Uuid;
// Helper to create a client with a custom User-Agent
@@ -11,8 +12,10 @@ fn get_client() -> reqwest::Client {
.unwrap_or_else(|_| reqwest::Client::new())
}
-#[derive(Debug, Clone, Serialize, Deserialize)]
+#[derive(Debug, Clone, Serialize, Deserialize, TS)]
#[serde(tag = "type")]
+#[serde(rename_all = "camelCase")]
+#[ts(export, tag = "type", export_to = "auth.ts")]
pub enum Account {
Offline(OfflineAccount),
Microsoft(MicrosoftAccount),
@@ -41,13 +44,17 @@ impl Account {
}
}
-#[derive(Debug, Clone, Serialize, Deserialize)]
+#[derive(Debug, Clone, Serialize, Deserialize, TS)]
+#[serde(rename_all = "camelCase")]
+#[ts(export, export_to = "auth.ts")]
pub struct OfflineAccount {
pub username: String,
pub uuid: String,
}
-#[derive(Debug, Clone, Serialize, Deserialize)]
+#[derive(Debug, Clone, Serialize, Deserialize, TS)]
+#[serde(rename_all = "camelCase")]
+#[ts(export, export_to = "auth.ts")]
pub struct MicrosoftAccount {
pub username: String,
pub uuid: String,
@@ -73,11 +80,12 @@ pub fn generate_offline_uuid(username: &str) -> String {
Uuid::new_v3(&namespace, username.as_bytes()).to_string()
}
-// const CLIENT_ID: &str = "fe165602-5410-4441-92f7-326e10a7cb82";
-const CLIENT_ID: &str = "c36a9fb6-4f2a-41ff-90bd-ae7cc92031eb"; // ATLauncher's Client ID
+const CLIENT_ID: &str = "fe165602-5410-4441-92f7-326e10a7cb82";
const SCOPE: &str = "XboxLive.SignIn XboxLive.offline_access";
-#[derive(Debug, Serialize, Deserialize)]
+#[derive(Debug, Serialize, Deserialize, TS)]
+#[serde(rename_all(serialize = "camelCase"))]
+#[ts(export, export_to = "auth.ts", rename_all = "camelCase")]
pub struct DeviceCodeResponse {
pub user_code: String,
pub device_code: String,
@@ -87,7 +95,9 @@ pub struct DeviceCodeResponse {
pub message: Option<String>,
}
-#[derive(Debug, Serialize, Deserialize)]
+#[derive(Debug, Serialize, Deserialize, TS)]
+#[serde(rename_all(serialize = "camelCase"))]
+#[ts(export, export_to = "auth.ts")]
pub struct TokenResponse {
pub access_token: String,
pub refresh_token: Option<String>,
@@ -209,7 +219,9 @@ pub struct MinecraftAuthResponse {
pub expires_in: u64,
}
-#[derive(Debug, Serialize, Deserialize)]
+#[derive(Debug, Serialize, Deserialize, TS)]
+#[serde(rename_all = "camelCase")]
+#[ts(export, export_to = "auth.ts")]
pub struct MinecraftProfile {
pub id: String,
pub name: String,