summaryrefslogtreecommitdiffstats
path: root/src/auth/types.rs
diff options
context:
space:
mode:
authorLibravatar bigfoot547 <[email protected]>2025-01-31 02:32:19 -0600
committerLibravatar bigfoot547 <[email protected]>2025-01-31 02:32:19 -0600
commitcdeee17c2be5b8b9a333b977b3e2d373b94dfe0a (patch)
tree58ec48b5bfa9afe03ebbd9716f1f90841af914e9 /src/auth/types.rs
parentRemove some unused imports but not all of them (diff)
do clippy stuff and change line endings
Diffstat (limited to 'src/auth/types.rs')
-rw-r--r--src/auth/types.rs256
1 files changed, 128 insertions, 128 deletions
diff --git a/src/auth/types.rs b/src/auth/types.rs
index 348bdf8..79b89c9 100644
--- a/src/auth/types.rs
+++ b/src/auth/types.rs
@@ -1,128 +1,128 @@
-pub mod property_map;
-pub use property_map::PropertyMap;
-
-use std::fmt::{Debug, Formatter};
-use chrono::{DateTime, Utc};
-use multimap::MultiMap;
-use oauth2::RefreshToken;
-use serde::{Deserialize, Serialize};
-use uuid::Uuid;
-
-#[derive(Debug, Serialize, Deserialize)]
-pub struct Property {
- pub name: String,
- pub value: String,
- pub signature: Option<String>
-}
-
-#[derive(Debug, Serialize, Deserialize)]
-pub struct PlayerProfile {
- #[serde(with = "uuid::serde::simple")]
- pub id: Uuid,
- pub name: String,
-
- #[serde(default, skip_serializing_if = "MultiMap::is_empty", with = "property_map")]
- pub properties: MultiMap<String, Property>
-}
-
-#[derive(Serialize, Deserialize)]
-pub(super) struct Token {
- pub value: String,
-
- #[serde(skip_serializing_if = "Option::is_none")]
- pub expire: Option<DateTime<Utc>>
-}
-
-struct RedactedValue;
-impl Debug for RedactedValue {
- fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
- f.write_str("[redacted]")
- }
-}
-
-impl Debug for Token {
- fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
- f.debug_struct("Token")
- .field("value", &RedactedValue)
- .field("expire", &self.expire)
- .finish()
- }
-}
-
-#[derive(Debug, Deserialize)]
-#[serde(rename_all = "UPPERCASE")]
-pub enum SkinState {
- Active,
- Inactive
-}
-
-#[derive(Debug, Deserialize)]
-#[serde(rename_all = "UPPERCASE")]
-pub enum SkinVariant {
- Classic,
- Slim
-}
-
-#[derive(Debug, Deserialize)]
-#[serde(rename_all = "camelCase")]
-pub struct SkinInfo {
- pub id: Uuid,
- pub state: SkinState,
- pub url: String,
- pub texture_key: Option<String>,
- pub variant: Option<SkinVariant>,
- pub alias: Option<String>
-}
-
-#[derive(Debug, Deserialize)]
-#[serde(rename_all = "camelCase")]
-pub struct MinecraftPlayerInfo {
- #[serde(with = "uuid::serde::simple")]
- pub id: Uuid,
- pub name: String,
-
- #[serde(default)]
- pub skins: Vec<SkinInfo>,
- #[serde(default)]
- pub capes: Vec<SkinInfo>,
-
- #[serde(default)]
- pub demo: bool,
-
- #[serde(default)]
- pub legacy: bool,
-
- // todo: profile actions (idk the format)
-}
-
-#[derive(Debug, Serialize, Deserialize)]
-pub struct MsaUser {
- #[serde(skip_serializing_if = "Option::is_none")]
- pub player_profile: Option<PlayerProfile>,
- pub xuid: Option<Uuid>,
- pub gamertag: Option<String>,
-
- #[serde(skip)] // this information is transient
- pub player_info: Option<MinecraftPlayerInfo>,
-
- pub(super) client_id: oauth2::ClientId,
-
- #[serde(default, skip_serializing_if = "std::ops::Not::not")]
- pub(super) is_azure_client_id: bool,
-
- pub(super) mc_token: Option<Token>,
- pub(super) xbl_token: Option<Token>,
- pub(super) refresh_token: Option<RefreshToken>
-}
-
-#[derive(Debug, Serialize, Deserialize)]
-#[serde(tag = "type")]
-pub enum User {
- Dummy(PlayerProfile),
- MSA(MsaUser)
-}
-
-#[derive(Debug, Serialize, Deserialize)]
-pub struct AuthenticationDatabase {
- pub users: Vec<User>
-}
+pub mod property_map;
+pub use property_map::PropertyMap;
+
+use std::fmt::{Debug, Formatter};
+use chrono::{DateTime, Utc};
+use multimap::MultiMap;
+use oauth2::RefreshToken;
+use serde::{Deserialize, Serialize};
+use uuid::Uuid;
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct Property {
+ pub name: String,
+ pub value: String,
+ pub signature: Option<String>
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct PlayerProfile {
+ #[serde(with = "uuid::serde::simple")]
+ pub id: Uuid,
+ pub name: String,
+
+ #[serde(default, skip_serializing_if = "MultiMap::is_empty", with = "property_map")]
+ pub properties: PropertyMap
+}
+
+#[derive(Serialize, Deserialize)]
+pub(super) struct Token {
+ pub value: String,
+
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub expire: Option<DateTime<Utc>>
+}
+
+struct RedactedValue;
+impl Debug for RedactedValue {
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+ f.write_str("[redacted]")
+ }
+}
+
+impl Debug for Token {
+ fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
+ f.debug_struct("Token")
+ .field("value", &RedactedValue)
+ .field("expire", &self.expire)
+ .finish()
+ }
+}
+
+#[derive(Debug, Deserialize)]
+#[serde(rename_all = "UPPERCASE")]
+pub enum SkinState {
+ Active,
+ Inactive
+}
+
+#[derive(Debug, Deserialize)]
+#[serde(rename_all = "UPPERCASE")]
+pub enum SkinVariant {
+ Classic,
+ Slim
+}
+
+#[derive(Debug, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct SkinInfo {
+ pub id: Uuid,
+ pub state: SkinState,
+ pub url: String,
+ pub texture_key: Option<String>,
+ pub variant: Option<SkinVariant>,
+ pub alias: Option<String>
+}
+
+#[derive(Debug, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct MinecraftPlayerInfo {
+ #[serde(with = "uuid::serde::simple")]
+ pub id: Uuid,
+ pub name: String,
+
+ #[serde(default)]
+ pub skins: Vec<SkinInfo>,
+ #[serde(default)]
+ pub capes: Vec<SkinInfo>,
+
+ #[serde(default)]
+ pub demo: bool,
+
+ #[serde(default)]
+ pub legacy: bool,
+
+ // todo: profile actions (idk the format)
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct MsaUser {
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub player_profile: Option<PlayerProfile>,
+ pub xuid: Option<Uuid>,
+ pub gamertag: Option<String>,
+
+ #[serde(skip)] // this information is transient
+ pub player_info: Option<MinecraftPlayerInfo>,
+
+ pub(super) client_id: oauth2::ClientId,
+
+ #[serde(default, skip_serializing_if = "std::ops::Not::not")]
+ pub(super) is_azure_client_id: bool,
+
+ pub(super) mc_token: Option<Token>,
+ pub(super) xbl_token: Option<Token>,
+ pub(super) refresh_token: Option<RefreshToken>
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(tag = "type", rename_all = "lowercase")]
+pub enum User {
+ Dummy(PlayerProfile),
+ MSA(Box<MsaUser>)
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct AuthenticationDatabase {
+ pub users: Vec<User>
+}