Skip to main content

steam_client/
types.rs

1//! Type definitions for Steam client.
2
3use steam_enums::EResult;
4use steamid::SteamID;
5
6/// Details for logging on to Steam.
7#[derive(Clone, Default)]
8pub struct LogOnDetails {
9    /// Anonymous login (no credentials required).
10    pub anonymous: bool,
11
12    /// Refresh token for authentication.
13    pub refresh_token: Option<String>,
14
15    /// Account name (for password auth).
16    pub account_name: Option<String>,
17
18    /// Password (for password auth).
19    pub password: Option<String>,
20
21    /// Steam Guard email code.
22    pub auth_code: Option<String>,
23
24    /// Two-factor authentication code.
25    pub two_factor_code: Option<String>,
26
27    /// Machine auth token for Steam Guard.
28    pub machine_auth_token: Option<String>,
29
30    /// Logon ID (for avoiding "logged in elsewhere" errors).
31    pub logon_id: Option<u32>,
32
33    /// Machine name to report to Steam.
34    pub machine_name: Option<String>,
35
36    /// Machine ID (binary blob) for Steam Guard.
37    pub machine_id: Option<Vec<u8>>,
38
39    /// Web logon token from /chat/clientjstoken endpoint.
40    /// Used with steam_id for cookie-based authentication.
41    pub web_logon_token: Option<String>,
42
43    /// SteamID for web logon token authentication.
44    /// Required when using web_logon_token.
45    pub steam_id: Option<SteamID>,
46
47    /// Client OS type.
48    pub client_os_type: Option<u32>,
49}
50
51impl std::fmt::Debug for LogOnDetails {
52    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
53        f.debug_struct("LogOnDetails")
54            .field("anonymous", &self.anonymous)
55            .field("account_name", &self.account_name)
56            .field("steam_id", &self.steam_id)
57            .field("logon_id", &self.logon_id)
58            .field("machine_name", &self.machine_name)
59            .field("client_os_type", &self.client_os_type)
60            .field("machine_id", &self.machine_id.as_ref().map(|v| format!("<{} bytes>", v.len())))
61            // Sensitive fields — redacted
62            .field("refresh_token", &self.refresh_token.as_ref().map(|_| "<redacted>"))
63            .field("password", &self.password.as_ref().map(|_| "<redacted>"))
64            .field("auth_code", &self.auth_code.as_ref().map(|_| "<redacted>"))
65            .field("two_factor_code", &self.two_factor_code.as_ref().map(|_| "<redacted>"))
66            .field("machine_auth_token", &self.machine_auth_token.as_ref().map(|_| "<redacted>"))
67            .field("web_logon_token", &self.web_logon_token.as_ref().map(|_| "<redacted>"))
68            .finish()
69    }
70}
71
72/// Response from a successful login.
73#[derive(Debug, Clone)]
74pub struct LogOnResponse {
75    /// The result code.
76    pub eresult: EResult,
77
78    /// The logged-in SteamID.
79    pub steam_id: SteamID,
80
81    /// Public IP address as seen by Steam.
82    pub public_ip: Option<String>,
83
84    /// Cell ID for content servers.
85    pub cell_id: u32,
86
87    /// Vanity URL.
88    pub vanity_url: Option<String>,
89
90    /// Email domain for the account (if any).
91    pub email_domain: Option<String>,
92
93    /// Whether Steam Guard is enabled.
94    pub steam_guard_required: bool,
95
96    /// Heartbeat interval in seconds (for keep-alive).
97    pub heartbeat_seconds: Option<i32>,
98
99    /// Server time as Unix timestamp.
100    pub server_time: Option<u32>,
101
102    /// Account flags bitfield.
103    pub account_flags: Option<u32>,
104
105    /// User's country code.
106    pub user_country: Option<String>,
107
108    /// Country code based on IP address.
109    pub ip_country_code: Option<String>,
110
111    /// Client instance ID.
112    pub client_instance_id: Option<u64>,
113
114    /// Token ID for the session.
115    pub token_id: Option<u64>,
116
117    /// Family group ID (if in a family group).
118    pub family_group_id: Option<u64>,
119
120    /// Extended result code (for more detailed error info).
121    pub eresult_extended: Option<i32>,
122
123    /// Cell ID ping threshold.
124    pub cell_id_ping_threshold: Option<u32>,
125
126    /// Whether a client update check is required.
127    pub force_client_update_check: Option<bool>,
128
129    /// Agreement session URL (if user needs to accept agreements).
130    pub agreement_session_url: Option<String>,
131
132    /// Legacy out-of-game heartbeat interval.
133    pub legacy_out_of_game_heartbeat_seconds: Option<i32>,
134
135    /// Parental settings (serialized protobuf).
136    pub parental_settings: Option<Vec<u8>>,
137
138    /// Parental setting signature.
139    pub parental_setting_signature: Option<Vec<u8>>,
140
141    /// Count of login failures to migrate.
142    pub count_loginfailures_to_migrate: Option<i32>,
143
144    /// Count of disconnects to migrate.
145    pub count_disconnects_to_migrate: Option<i32>,
146
147    /// OGS data report time window.
148    pub ogs_data_report_time_window: Option<i32>,
149
150    /// Steam2 ticket (legacy).
151    pub steam2_ticket: Option<Vec<u8>>,
152}
153
154/// Account information received after login.
155#[derive(Debug, Clone)]
156pub struct AccountInfo {
157    /// Account name.
158    pub name: String,
159
160    /// Country code.
161    pub country: String,
162
163    /// Number of authenticated machines.
164    pub authed_machines: u32,
165
166    /// Account flags.
167    pub flags: u32,
168
169    /// Facebook ID (if linked).
170    pub facebook_id: Option<String>,
171
172    /// Facebook name (if linked).
173    pub facebook_name: Option<String>,
174}
175
176/// Email information for the account.
177#[derive(Debug, Clone)]
178pub struct EmailInfo {
179    /// Email address.
180    pub address: String,
181
182    /// Whether the email is validated.
183    pub validated: bool,
184}
185
186/// Account limitations.
187#[derive(Debug, Clone)]
188pub struct Limitations {
189    /// Whether this is a limited account.
190    pub limited: bool,
191
192    /// Whether the account is community banned.
193    pub community_banned: bool,
194
195    /// Whether the account is locked.
196    pub locked: bool,
197
198    /// Whether the account can invite friends.
199    pub can_invite_friends: bool,
200}
201
202/// VAC ban status.
203#[derive(Debug, Clone)]
204pub struct VacStatus {
205    /// Number of VAC bans.
206    pub num_bans: u32,
207
208    /// App IDs with VAC bans.
209    pub appids: Vec<u32>,
210
211    /// VAC ban ranges.
212    pub ranges: Vec<(u32, u32)>,
213}
214
215/// Wallet information.
216#[derive(Debug, Clone)]
217pub struct WalletInfo {
218    /// Whether the account has a wallet.
219    pub has_wallet: bool,
220
221    /// Currency code.
222    pub currency: u32,
223
224    /// Balance in cents.
225    pub balance: i64,
226}
227
228/// Quick invite link information.
229#[derive(Debug, Clone)]
230pub struct QuickInviteLink {
231    /// The full invite link URL.
232    pub invite_link: String,
233
234    /// The invite token (extracted from link).
235    pub invite_token: String,
236
237    /// Maximum number of times this link can be used.
238    pub invite_limit: Option<u64>,
239
240    /// Duration in seconds that the link is valid.
241    pub invite_duration: Option<u64>,
242
243    /// Unix timestamp when the link was created.
244    pub time_created: Option<u32>,
245
246    /// Whether the link is currently valid.
247    pub valid: bool,
248}
249
250/// Quick invite link validity check result.
251#[derive(Debug, Clone)]
252pub struct QuickInviteLinkValidity {
253    /// Whether the link is valid.
254    pub valid: bool,
255
256    /// The SteamID of the link owner (if valid).
257    pub steam_id: Option<SteamID>,
258
259    /// Duration in seconds that the link is valid for.
260    pub invite_duration: Option<u64>,
261}
262
263/// Persona name history entry.
264#[derive(Debug, Clone)]
265pub struct PersonaNameHistory {
266    /// The persona name.
267    pub name: String,
268    /// Timestamp when this name was used (Unix timestamp).
269    pub name_since: u32,
270}