steamkit/steam/authentication/
credentials_auth_session.rs1use std::sync::Arc;
4use std::time::Duration;
5
6use steamkit_protos::steam::{CAuthenticationAllowedConfirmation, EAuthSessionGuardType};
7use tokio_util::sync::CancellationToken;
8
9use crate::error::SteamError;
10use crate::types::steam_id::SteamID;
11
12use super::auth_poll_result::AuthPollResult;
13use super::auth_session::AuthSession;
14use super::i_authenticator::IAuthenticator;
15
16pub struct CredentialsAuthSession {
18 session: AuthSession,
19}
20
21impl std::fmt::Debug for CredentialsAuthSession {
22 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
23 f.debug_struct("CredentialsAuthSession")
24 .field("session", &self.session)
25 .finish()
26 }
27}
28
29impl CredentialsAuthSession {
30 pub(crate) fn new(session: AuthSession) -> Self {
32 CredentialsAuthSession { session }
33 }
34
35 pub fn steam_id(&self) -> SteamID {
38 self.session.steam_id()
39 }
40
41 pub async fn send_steam_guard_code(
43 &self,
44 code: &str,
45 code_type: EAuthSessionGuardType,
46 ) -> Result<(), SteamError> {
47 self.session.send_steam_guard_code(code, code_type).await?;
48
49 Ok(())
50 }
51
52 pub fn authenticator(&self) -> Option<&Arc<dyn IAuthenticator>> {
54 self.session.authenticator()
55 }
56
57 pub fn client_id(&self) -> u64 {
59 self.session.client_id()
60 }
61
62 pub fn request_id(&self) -> &[u8] {
64 self.session.request_id()
65 }
66
67 pub fn polling_interval(&self) -> Duration {
69 self.session.polling_interval()
70 }
71
72 pub fn allowed_confirmations(&self) -> &[CAuthenticationAllowedConfirmation] {
74 self.session.allowed_confirmations()
75 }
76
77 pub async fn polling_wait_for_result(
80 &self,
81 cancellation: CancellationToken,
82 ) -> Result<AuthPollResult, SteamError> {
83 self.session.polling_wait_for_result(cancellation).await
84 }
85
86 pub async fn poll_auth_session_status(&self) -> Result<Option<AuthPollResult>, SteamError> {
88 self.session.poll_auth_session_status().await
89 }
90}