use serde::{Deserialize, Serialize};
use crate::password::Password;
#[derive(Debug, Deserialize, Serialize, Clone, PartialEq, Eq)]
pub enum AuthMethod {
Offline {
player_name: String,
uuid: String,
},
Mojang {
access_token: Password,
uuid: String,
player_name: String,
head_skin: Vec<u8>,
hat_skin: Vec<u8>,
},
Microsoft {
access_token: Password,
refresh_token: Password,
uuid: String,
xuid: String,
player_name: String,
head_skin: Vec<u8>,
hat_skin: Vec<u8>,
},
AuthlibInjector {
api_location: String,
server_name: String,
server_homepage: String,
server_meta: String,
access_token: Password,
uuid: String,
player_name: String,
head_skin: Vec<u8>,
hat_skin: Vec<u8>,
},
}
pub(crate) mod mojang {
use serde::{Deserialize, Serialize};
use crate::password::Password;
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub(crate) struct AuthenticateBody {
pub agent: AuthenticateAgent,
pub username: String,
pub password: Password,
#[serde(skip_serializing_if = "String::is_empty")]
pub client_token: String,
pub request_user: bool,
}
impl Default for AuthenticateBody {
fn default() -> Self {
Self {
request_user: true,
username: "".into(),
password: "".into(),
client_token: "".into(),
agent: Default::default(),
}
}
}
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]
pub(crate) struct AuthenticateAgent {
pub name: String,
pub version: usize,
}
impl Default for AuthenticateAgent {
fn default() -> Self {
Self {
name: "Minecraft".into(),
version: 1,
}
}
}
#[derive(Debug, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub(crate) struct AuthenticateResponse {
pub access_token: Password,
pub client_token: String,
pub available_profiles: Vec<AvaliableProfile>,
pub selected_profile: Option<AvaliableProfile>,
}
#[derive(Debug, Serialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub(crate) struct ValidateResponse {
pub access_token: Password,
pub client_token: String,
}
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]
pub(crate) struct AvaliableProfile {
pub name: String,
pub id: String,
}
#[derive(Debug, Deserialize, PartialEq, Eq, Clone, Default)]
#[serde(rename_all = "camelCase")]
pub struct ErrorResponse {
pub error: String,
pub error_message: String,
#[serde(default)]
pub cause: String,
}
#[derive(Debug, Deserialize, PartialEq, Eq, Clone)]
pub(crate) struct ProfileResponse {
pub id: String,
pub name: String,
pub properties: Vec<ProfilePropertie>,
}
#[derive(Debug, Deserialize, PartialEq, Eq, Clone)]
pub(crate) struct ProfilePropertie {
pub name: String,
pub value: String,
}
#[derive(Debug, Deserialize, PartialEq, Eq, Clone)]
#[serde(rename_all = "camelCase")]
pub(crate) struct ProfileTexture {
pub timestamp: u64,
pub profile_id: String,
pub profile_name: String,
pub textures: Option<TextureData>,
}
#[derive(Debug, Deserialize, PartialEq, Eq, Clone)]
pub(crate) struct TextureData {
#[serde(rename = "SKIN")]
pub skin: Option<SkinData>,
#[serde(rename = "CAPE")]
pub cape: Option<SkinData>,
}
#[derive(Debug, Deserialize, PartialEq, Eq, Clone)]
pub(crate) struct SkinData {
pub url: String,
}
}