Skip to main content

steam_auth/
types.rs

1//! Public types and interfaces for Steam session management.
2
3use steam_protos::{EAuthSessionGuardType, EAuthTokenPlatformType, ESessionPersistence};
4
5/// Options for creating a LoginSession.
6#[derive(Debug, Clone, Default)]
7pub struct LoginSessionOptions {
8    /// Custom user-agent string.
9    pub user_agent: Option<String>,
10    /// Machine ID for SteamClient platform.
11    pub machine_id: Option<Vec<u8>>,
12    /// Friendly name for the machine.
13    pub machine_friendly_name: Option<String>,
14}
15
16/// Details for starting a login with credentials.
17#[derive(Debug, Clone)]
18pub struct CredentialsDetails {
19    /// Steam account name.
20    pub account_name: String,
21    /// Steam account password.
22    pub password: String,
23    /// Session persistence type.
24    pub persistence: Option<ESessionPersistence>,
25    /// Steam Guard machine token for bypassing email code.
26    pub steam_guard_machine_token: Option<String>,
27    /// Pre-supplied Steam Guard code (email or TOTP).
28    pub steam_guard_code: Option<String>,
29}
30
31/// Response from starting a login session.
32#[derive(Debug, Clone)]
33pub struct StartSessionResponse {
34    /// Whether action is required from the user.
35    pub action_required: bool,
36    /// Valid actions the user can take.
37    pub valid_actions: Option<Vec<ValidAction>>,
38    /// QR code challenge URL (for QR login).
39    pub qr_challenge_url: Option<String>,
40}
41
42/// A valid action for completing authentication.
43#[derive(Debug, Clone)]
44pub struct ValidAction {
45    /// Type of guard required.
46    pub guard_type: EAuthSessionGuardType,
47    /// Additional details (e.g., email domain).
48    pub detail: Option<String>,
49}
50
51/// Result of a successful poll.
52#[derive(Debug, Clone)]
53pub struct PollResult {
54    /// Account name.
55    pub account_name: String,
56    /// Refresh token.
57    pub refresh_token: String,
58    /// Access token (may be None).
59    pub access_token: Option<String>,
60    /// New Steam Guard machine token (if issued).
61    pub new_guard_data: Option<String>,
62}
63
64/// Request to approve an auth session.
65#[derive(Debug, Clone)]
66pub struct ApproveAuthSessionRequest {
67    /// QR challenge URL.
68    pub qr_challenge_url: String,
69    /// Whether to approve (true) or deny (false).
70    pub approve: bool,
71    /// Session persistence.
72    pub persistence: Option<ESessionPersistence>,
73}
74
75/// Session state from begin auth.
76///
77/// Contains the client ID, request ID, and other information needed to complete
78/// the authentication flow (polling, Steam Guard code submission, etc.).
79#[derive(Debug, Clone)]
80pub struct StartAuthSessionResponse {
81    pub client_id: u64,
82    pub request_id: Vec<u8>,
83    pub poll_interval: f32,
84    pub allowed_confirmations: Vec<AllowedConfirmation>,
85    pub steam_id: Option<u64>,
86    pub weak_token: Option<String>,
87    pub challenge_url: Option<String>,
88    pub version: Option<i32>,
89}
90
91/// An allowed confirmation type.
92#[derive(Debug, Clone, PartialEq)]
93pub struct AllowedConfirmation {
94    pub confirmation_type: EAuthSessionGuardType,
95    pub message: Option<String>,
96}
97
98/// Platform-specific data for requests.
99#[derive(Debug, Clone)]
100pub(crate) struct PlatformData {
101    pub website_id: String,
102    pub headers: std::collections::HashMap<String, String>,
103    pub device_details: DeviceDetails,
104}
105
106/// Device details for authentication.
107#[derive(Debug, Clone)]
108#[allow(dead_code)]
109pub(crate) struct DeviceDetails {
110    pub device_friendly_name: String,
111    pub platform_type: EAuthTokenPlatformType,
112    pub os_type: Option<i32>,
113    pub gaming_device_type: Option<u32>,
114    pub machine_id: Option<Vec<u8>>,
115}