summaryrefslogtreecommitdiff
path: root/protocols/Steam/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-12-12 18:09:39 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-12-12 18:09:44 +0300
commitf761cffcda21c5fcb1500e992ba0f03ead3a690f (patch)
tree255074a1b27034e1d3cd9377cae33a877d75263b /protocols/Steam/src
parent5d8202ec614342edcf1bab65ae9781f2092834a8 (diff)
Steam: code cleaning
Diffstat (limited to 'protocols/Steam/src')
-rw-r--r--protocols/Steam/src/proto.h148
-rw-r--r--protocols/Steam/src/resource.h5
-rw-r--r--protocols/Steam/src/steam_dialogs.cpp146
-rw-r--r--protocols/Steam/src/steam_dialogs.h70
-rw-r--r--protocols/Steam/src/steam_login.cpp211
-rw-r--r--protocols/Steam/src/steam_proto.h13
-rw-r--r--protocols/Steam/src/steam_server.cpp1
7 files changed, 247 insertions, 347 deletions
diff --git a/protocols/Steam/src/proto.h b/protocols/Steam/src/proto.h
index 2d1f07bf6a..b6d0fc9315 100644
--- a/protocols/Steam/src/proto.h
+++ b/protocols/Steam/src/proto.h
@@ -1,6 +1,6 @@
#pragma once
-enum EMsg
+enum class EMsg
{
Invalid = 0,
Multi = 1,
@@ -1962,6 +1962,151 @@ enum EMsg
ServerSecretChanged = 12100,
};
+enum class EResult
+{
+ Invalid = 0,
+ OK = 1,
+ Fail = 2,
+ NoConnection = 3,
+ InvalidPassword = 5,
+ LoggedInElsewhere = 6,
+ InvalidProtocolVer = 7,
+ InvalidParam = 8,
+ FileNotFound = 9,
+ Busy = 10,
+ InvalidState = 11,
+ InvalidName = 12,
+ InvalidEmail = 13,
+ DuplicateName = 14,
+ AccessDenied = 15,
+ Timeout = 16,
+ Banned = 17,
+ AccountNotFound = 18,
+ InvalidSteamID = 19,
+ ServiceUnavailable = 20,
+ NotLoggedOn = 21,
+ Pending = 22,
+ EncryptionFailure = 23,
+ InsufficientPrivilege = 24,
+ LimitExceeded = 25,
+ Revoked = 26,
+ Expired = 27,
+ AlreadyRedeemed = 28,
+ DuplicateRequest = 29,
+ AlreadyOwned = 30,
+ IPNotFound = 31,
+ PersistFailed = 32,
+ LockingFailed = 33,
+ LogonSessionReplaced = 34,
+ ConnectFailed = 35,
+ HandshakeFailed = 36,
+ IOFailure = 37,
+ RemoteDisconnect = 38,
+ ShoppingCartNotFound = 39,
+ Blocked = 40,
+ Ignored = 41,
+ NoMatch = 42,
+ AccountDisabled = 43,
+ ServiceReadOnly = 44,
+ AccountNotFeatured = 45,
+ AdministratorOK = 46,
+ ContentVersion = 47,
+ TryAnotherCM = 48,
+ PasswordRequiredToKickSession = 49,
+ AlreadyLoggedInElsewhere = 50,
+ Suspended = 51,
+ Cancelled = 52,
+ DataCorruption = 53,
+ DiskFull = 54,
+ RemoteCallFailed = 55,
+ PasswordNotSet = 56,
+ PasswordUnset = 56,
+ ExternalAccountUnlinked = 57,
+ PSNTicketInvalid = 58,
+ ExternalAccountAlreadyLinked = 59,
+ RemoteFileConflict = 60,
+ IllegalPassword = 61,
+ SameAsPreviousValue = 62,
+ AccountLogonDenied = 63,
+ CannotUseOldPassword = 64,
+ InvalidLoginAuthCode = 65,
+ AccountLogonDeniedNoMailSent = 66,
+ AccountLogonDeniedNoMail = 66,
+ HardwareNotCapableOfIPT = 67,
+ IPTInitError = 68,
+ ParentalControlRestricted = 69,
+ FacebookQueryError = 70,
+ ExpiredLoginAuthCode = 71,
+ IPLoginRestrictionFailed = 72,
+ AccountLocked = 73,
+ AccountLockedDown = 73,
+ AccountLogonDeniedVerifiedEmailRequired = 74,
+ NoMatchingURL = 75,
+ BadResponse = 76,
+ RequirePasswordReEntry = 77,
+ ValueOutOfRange = 78,
+ UnexpectedError = 79,
+ Disabled = 80,
+ InvalidCEGSubmission = 81,
+ RestrictedDevice = 82,
+ RegionLocked = 83,
+ RateLimitExceeded = 84,
+ AccountLogonDeniedNeedTwoFactorCode = 85,
+ AccountLoginDeniedNeedTwoFactor = 85,
+ ItemOrEntryHasBeenDeleted = 86,
+ ItemDeleted = 86,
+ AccountLoginDeniedThrottle = 87,
+ TwoFactorCodeMismatch = 88,
+ TwoFactorActivationCodeMismatch = 89,
+ AccountAssociatedToMultiplePlayers = 90,
+ AccountAssociatedToMultiplePartners = 90,
+ NotModified = 91,
+ NoMobileDeviceAvailable = 92,
+ NoMobileDevice = 92,
+ TimeIsOutOfSync = 93,
+ TimeNotSynced = 93,
+ SMSCodeFailed = 94,
+ TooManyAccountsAccessThisResource = 95,
+ AccountLimitExceeded = 95,
+ AccountActivityLimitExceeded = 96,
+ PhoneActivityLimitExceeded = 97,
+ RefundToWallet = 98,
+ EmailSendFailure = 99,
+ NotSettled = 100,
+ NeedCaptcha = 101,
+ GSLTDenied = 102,
+ GSOwnerDenied = 103,
+ InvalidItemType = 104,
+ IPBanned = 105,
+ GSLTExpired = 106,
+ InsufficientFunds = 107,
+ TooManyPending = 108,
+ NoSiteLicensesFound = 109,
+ WGNetworkSendExceeded = 110,
+ AccountNotFriends = 111,
+ LimitedUserAccount = 112,
+ CantRemoveItem = 113,
+ AccountHasBeenDeleted = 114,
+ AccountDeleted = 114,
+ AccountHasAnExistingUserCancelledLicense = 115,
+ ExistingUserCancelledLicense = 115,
+ DeniedDueToCommunityCooldown = 116,
+ CommunityCooldown = 116,
+ NoLauncherSpecified = 117,
+ MustAgreeToSSA = 118,
+ ClientNoLongerSupported = 119,
+ LauncherMigrated = 119,
+ CurrentSteamRealmDoesNotMatch = 120,
+ SteamRealmMismatch = 120,
+ InvalidSignature = 121,
+ ParseFailure = 122,
+ NoVerifiedPhone = 123,
+ InsufficientBattery = 124,
+ ChargerRequired = 125,
+ CachedCredentialInvalid = 126,
+ PhoneNumberIsVOIP = 127
+};
+
namespace proto
{
#define PROTOBUF_PTR(T,D) \
@@ -1982,4 +2127,5 @@ namespace proto
PROTOBUF_PTR(AuthenticationGetPasswordRSAPublicKeyResponse, cauthentication__get_password_rsapublic_key__response__descriptor);
PROTOBUF_PTR(AuthenticationBeginAuthSessionViaCredentialsResponse, cauthentication__begin_auth_session_via_credentials__response__descriptor);
PROTOBUF_PTR(AuthenticationPollAuthSessionStatusResponse, cauthentication__poll_auth_session_status__response__descriptor);
+ PROTOBUF_PTR(AuthenticationUpdateAuthSessionWithSteamGuardCodeResponse, cauthentication__update_auth_session_with_steam_guard_code__response__descriptor);
};
diff --git a/protocols/Steam/src/resource.h b/protocols/Steam/src/resource.h
index 639b4f013f..d165d518bf 100644
--- a/protocols/Steam/src/resource.h
+++ b/protocols/Steam/src/resource.h
@@ -11,9 +11,6 @@
#define IDI_GAMING 101
#define IDD_PASSWORD_EDITOR 107
#define IDC_SAVEPERMANENTLY 108
-#define IDD_CAPTCHA 118
-#define IDD_GUARD 119
-#define IDD_TWOFACTOR 120
#define IDC_SN 1001
#define IDC_PW 1002
#define IDC_PASSWORD 1002
@@ -32,11 +29,9 @@
#define IDC_BLOCK 1059
#define IDC_BM_LIST 1064
#define IDC_LIST 1065
-#define IDC_TEXT 1082
#define IDC_POLLINGERRORLIMIT 1085
#define IDC_POLLINGERRORLIMITSPIN 1086
#define IDC_OPENDOMAIN 1200
-#define IDC_GETDOMAIN 1200
// Next default values for new objects
//
diff --git a/protocols/Steam/src/steam_dialogs.cpp b/protocols/Steam/src/steam_dialogs.cpp
index c8599784e9..95cc2df8df 100644
--- a/protocols/Steam/src/steam_dialogs.cpp
+++ b/protocols/Steam/src/steam_dialogs.cpp
@@ -33,149 +33,3 @@ void CSteamPasswordEditor::OnDestroy()
{
Utils_SaveWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "PasswordWindow");
}
-
-/////////////////////////////////////////////////////////////////////////////////
-
-CSteamGuardDialog::CSteamGuardDialog(CSteamProto *proto, const char *domain) :
- CSteamDlgBase(proto, IDD_GUARD),
- m_text(this, IDC_TEXT),
- m_link(this, IDC_GETDOMAIN, domain)
-{
- memset(m_guardCode, 0, sizeof(m_guardCode));
- mir_strcpy(m_domain, domain);
-}
-
-bool CSteamGuardDialog::OnInitDialog()
-{
- m_proto->m_hwndGuard = m_hwnd;
-
- char iconName[100];
- mir_snprintf(iconName, "%s_%s", MODULE, "main");
- Window_SetIcon_IcoLib(m_hwnd, IcoLib_GetIconHandle(iconName));
-
- SendMessage(m_text.GetHwnd(), EM_LIMITTEXT, 5, 0);
-
- Utils_RestoreWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "GuardWindow");
- return true;
-}
-
-bool CSteamGuardDialog::OnApply()
-{
- mir_strncpy(m_guardCode, ptrA(m_text.GetTextA()), _countof(m_guardCode));
- EndModal(DIALOG_RESULT_OK);
- return true;
-}
-
-void CSteamGuardDialog::OnDestroy()
-{
- m_proto->m_hwndGuard = nullptr;
- Utils_SaveWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "GuardWindow");
-}
-
-/////////////////////////////////////////////////////////////////////////////////
-
-CSteamTwoFactorDialog::CSteamTwoFactorDialog(CSteamProto *proto) :
- CSteamDlgBase(proto, IDD_TWOFACTOR),
- m_text(this, IDC_TEXT)
-{
- memset(m_twoFactorCode, 0, sizeof(m_twoFactorCode));
-}
-
-bool CSteamTwoFactorDialog::OnInitDialog()
-{
- char iconName[100];
- mir_snprintf(iconName, "%s_%s", MODULE, "main");
- Window_SetIcon_IcoLib(m_hwnd, IcoLib_GetIconHandle(iconName));
-
- SendMessage(m_text.GetHwnd(), EM_LIMITTEXT, 5, 0);
-
- Utils_RestoreWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "TwoFactorWindow");
- return true;
-}
-
-bool CSteamTwoFactorDialog::OnApply()
-{
- mir_strncpy(m_twoFactorCode, ptrA(m_text.GetTextA()), _countof(m_twoFactorCode));
- EndModal(DIALOG_RESULT_OK);
- return true;
-}
-
-void CSteamTwoFactorDialog::OnDestroy()
-{
- Utils_SaveWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "TwoFactorWindow");
-}
-
-/////////////////////////////////////////////////////////////////////////////////
-
-CSteamCaptchaDialog::CSteamCaptchaDialog(CSteamProto *proto, const uint8_t *captchaImage, size_t captchaImageSize) :
- CSteamDlgBase(proto, IDD_CAPTCHA),
- m_text(this, IDC_TEXT),
- m_captchaImage(nullptr)
-{
- memset(m_captchaText, 0, sizeof(m_captchaText));
- m_captchaImageSize = captchaImageSize;
- m_captchaImage = (uint8_t*)mir_alloc(captchaImageSize);
- memcpy(m_captchaImage, captchaImage, captchaImageSize);
-}
-
-CSteamCaptchaDialog::~CSteamCaptchaDialog()
-{
- if (m_captchaImage)
- mir_free(m_captchaImage);
-}
-
-bool CSteamCaptchaDialog::OnInitDialog()
-{
- char iconName[100];
- mir_snprintf(iconName, "%s_%s", MODULE, "main");
- Window_SetIcon_IcoLib(m_hwnd, IcoLib_GetIconHandle(iconName));
-
- SendMessage(m_text.GetHwnd(), EM_LIMITTEXT, 6, 0);
-
- Utils_RestoreWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "CaptchaWindow");
- return true;
-}
-
-bool CSteamCaptchaDialog::OnApply()
-{
- mir_strncpy(m_captchaText, ptrA(m_text.GetTextA()), _countof(m_captchaText));
- return true;
-}
-
-void CSteamCaptchaDialog::OnDestroy()
-{
- Utils_SaveWindowPosition(m_hwnd, NULL, m_proto->m_szModuleName, "CaptchaWindow");
-}
-
-INT_PTR CSteamCaptchaDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
-{
- if (msg == WM_PAINT) {
- FIMEMORY *stream = FreeImage_OpenMemory(m_captchaImage, (uint32_t)m_captchaImageSize);
- FREE_IMAGE_FORMAT fif = FreeImage_GetFileTypeFromMemory(stream, 0);
- FIBITMAP *bitmap = FreeImage_LoadFromMemory(fif, stream, 0);
- FreeImage_CloseMemory(stream);
-
- PAINTSTRUCT ps;
- HDC hDC = BeginPaint(m_hwnd, &ps);
-
- StretchDIBits(
- hDC,
- 11, 11,
- FreeImage_GetWidth(bitmap) - 13,
- FreeImage_GetHeight(bitmap),
- 0, 0,
- FreeImage_GetWidth(bitmap),
- FreeImage_GetHeight(bitmap),
- FreeImage_GetBits(bitmap),
- FreeImage_GetInfo(bitmap),
- DIB_RGB_COLORS, SRCCOPY);
-
- FreeImage_Unload(bitmap);
-
- EndPaint(m_hwnd, &ps);
-
- return FALSE;
- }
- CSteamDlgBase::DlgProc(msg, wParam, lParam);
- return FALSE;
-}
diff --git a/protocols/Steam/src/steam_dialogs.h b/protocols/Steam/src/steam_dialogs.h
index 0322056230..b188ca6bb0 100644
--- a/protocols/Steam/src/steam_dialogs.h
+++ b/protocols/Steam/src/steam_dialogs.h
@@ -21,74 +21,4 @@ public:
CSteamPasswordEditor(CSteamProto *proto);
};
-/////////////////////////////////////////////////////////////////////////////////
-
-class CSteamGuardDialog : public CSteamDlgBase
-{
- char m_domain[32];
- char m_guardCode[6];
-
- CCtrlEdit m_text;
- CCtrlHyperlink m_link;
-
-protected:
- bool OnInitDialog() override;
- bool OnApply() override;
- void OnDestroy() override;
-
-public:
- CSteamGuardDialog(CSteamProto *proto, const char *domain);
-
- const char *GetGuardCode() {
- return m_guardCode;
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////////
-
-class CSteamTwoFactorDialog : public CSteamDlgBase
-{
- char m_twoFactorCode[6];
-
- CCtrlEdit m_text;
-
-protected:
- bool OnInitDialog() override;
- bool OnApply() override;
- void OnDestroy() override;
-
-public:
- CSteamTwoFactorDialog(CSteamProto *proto);
-
- const char *GetTwoFactorCode() {
- return m_twoFactorCode;
- }
-};
-
-/////////////////////////////////////////////////////////////////////////////////
-
-class CSteamCaptchaDialog : public CSteamDlgBase
-{
- char m_captchaText[7];
-
- uint8_t *m_captchaImage;
- size_t m_captchaImageSize;
-
- CCtrlEdit m_text;
-
-protected:
- bool OnInitDialog() override;
- bool OnApply() override;
- void OnDestroy() override;
- INT_PTR DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) override;
-
-public:
- CSteamCaptchaDialog(CSteamProto *proto, const uint8_t *captchaImage, size_t captchaImageSize);
- ~CSteamCaptchaDialog();
-
- const char* GetCaptchaText() {
- return m_captchaText;
- }
-};
-
#endif //_STEAM_DIALOGS_H_
diff --git a/protocols/Steam/src/steam_login.cpp b/protocols/Steam/src/steam_login.cpp
index e7a583dac1..7b4af8c2eb 100644
--- a/protocols/Steam/src/steam_login.cpp
+++ b/protocols/Steam/src/steam_login.cpp
@@ -1,119 +1,8 @@
#include "stdafx.h"
-/*
-void CSteamProto::OnGotCaptcha(const HttpResponse &response, void *arg)
-{
- ptrA captchaId((char *)arg);
-
- if (!response.IsSuccess()) {
- debugLogA(__FUNCTION__ ": failed to get captcha");
- return;
- }
-
- CSteamCaptchaDialog captchaDialog(this, (const uint8_t *)response.data(), response.length());
- if (!captchaDialog.DoModal()) {
- DeleteAuthSettings();
- SetStatus(ID_STATUS_OFFLINE);
- return;
- }
-
- setString("CaptchaId", captchaId);
- setString("CaptchaText", captchaDialog.GetCaptchaText());
-
- ptrA username(getUStringA("Username"));
- // SendRequest(new GetRsaKeyRequest(username), &CSteamProto::OnGotRsaKey);
-}
-
-void CSteamProto::OnAuthorizationError(const JSONNode &root)
-{
- CMStringW message = root["message"].as_mstring();
- if (message == L"Incorrect login.") {
- // We can't continue with incorrect login/password
- debugLogA(__FUNCTION__ ": incorrect login");
- DeleteAuthSettings();
- SetStatus(ID_STATUS_OFFLINE);
- ShowNotification(message);
- return;
- }
-
- if (root["clear_password_field"].as_bool()) {
- // describes if the password field was cleared. This can also be true if the twofactor code was wrong
- debugLogA(__FUNCTION__ ": clear password field");
- delSetting("Passowrd"); // experiment
- delSetting("TwoFactorCode");
- SetStatus(ID_STATUS_OFFLINE);
- ShowNotification(message);
- }
-
- T2Utf username(getWStringA("Username"));
-
- if (root["requires_twofactor"].as_bool()) {
- debugLogA(__FUNCTION__ ": requires twofactor");
- delSetting("TwoFactorCode");
-
- CSteamTwoFactorDialog twoFactorDialog(this);
- if (!twoFactorDialog.DoModal()) {
- DeleteAuthSettings();
- SetStatus(ID_STATUS_OFFLINE);
- return;
- }
-
- setString("TwoFactorCode", twoFactorDialog.GetTwoFactorCode());
-
- // SendRequest(new GetRsaKeyRequest(username), &CSteamProto::OnGotRsaKey);
- }
-
- if (root["emailauth_needed"].as_bool()) {
- debugLogA(__FUNCTION__ ": emailauth needed");
-
- std::string guardId = root["emailsteamid"].as_string();
- ptrA oldGuardId(getStringA("GuardId"));
- if (mir_strcmp(guardId.c_str(), oldGuardId) == 0) {
- delSetting("GuardId");
- delSetting("GuardCode");
- }
-
- json_string domain = root["emaildomain"].as_string();
-
- // Make absolute link
- if (domain.find("://") == std::string::npos)
- domain = "http://" + domain;
-
- if (m_hwndGuard != nullptr)
- return;
-
- CSteamGuardDialog guardDialog(this, domain.c_str());
- if (!guardDialog.DoModal()) {
- DeleteAuthSettings();
- SetStatus(ID_STATUS_OFFLINE);
- return;
- }
-
- setString("GuardId", guardId.c_str());
- setString("GuardCode", guardDialog.GetGuardCode());
-
- // SendRequest(new GetRsaKeyRequest(username), &CSteamProto::OnGotRsaKey);
- return;
- }
-
- if (root["captcha_needed"].as_bool()) {
- debugLogA(__FUNCTION__ ": captcha needed");
- delSetting("CaptchaId");
- delSetting("CaptchaText");
- json_string captchaId = root["captcha_gid"].as_string();
- SendRequest(new GetCaptchaRequest(captchaId.c_str()), &CSteamProto::OnGotCaptcha, mir_strdup(captchaId.c_str()));
- return;
- }
-
- // unhadled error
- DeleteAuthSettings();
- SetStatus(ID_STATUS_OFFLINE);
- ShowNotification(message);
-}
-*/
-
void CSteamProto::DeleteAuthSettings()
{
+ m_requestId = MBinBuffer();
delSetting("TwoFactorCode");
delSetting("GuardId");
delSetting("GuardCode");
@@ -128,8 +17,7 @@ bool CSteamProto::IsOnline()
bool CSteamProto::IsMe(const char *steamId)
{
- ptrA mySteamId(getStringA(DBKEY_STEAM_ID));
- return mir_strcmp(steamId, mySteamId) == 0;
+ return m_iSteamId == _atoi64(steamId);
}
void CSteamProto::Login()
@@ -218,6 +106,61 @@ void CSteamProto::OnGotRsaKey(const uint8_t *buf, size_t cbLen)
WSSendService("Authentication.BeginAuthSessionViaCredentials#1", request, &CSteamProto::OnAuthorization);
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+INT_PTR CALLBACK CSteamProto::EnterEmailCode(void *param)
+{
+ auto *ppro = (CSteamProto *)param;
+
+ ENTER_STRING es = {};
+ es.szModuleName = ppro->m_szModuleName;
+ es.caption = TranslateT("Enter email confimation code");
+ if (EnterString(&es)) {
+ ppro->SendConfirmationCode(true, T2Utf(es.ptszResult));
+ mir_free(es.ptszResult);
+ }
+ else ppro->LoginFailed();
+ return 0;
+}
+
+INT_PTR CALLBACK CSteamProto::EnterTotpCode(void *param)
+{
+ auto *ppro = (CSteamProto *)param;
+
+ ENTER_STRING es = {};
+ es.szModuleName = ppro->m_szModuleName;
+ es.caption = TranslateT("Enter email confimation code");
+ if (EnterString(&es)) {
+ ppro->SendConfirmationCode(false, T2Utf(es.ptszResult));
+ mir_free(es.ptszResult);
+ }
+ else ppro->LoginFailed();
+ return 0;
+}
+
+void CSteamProto::OnGotConfirmationCode(const uint8_t *buf, size_t cbLen)
+{
+ proto::AuthenticationUpdateAuthSessionWithSteamGuardCodeResponse reply(buf, cbLen);
+ if (reply == nullptr)
+ LoginFailed();
+ else
+ SendPollRequest();
+}
+
+void CSteamProto::SendConfirmationCode(bool isEmail, const char *pszCode)
+{
+ CAuthenticationUpdateAuthSessionWithSteamGuardCodeRequest request;
+ request.steamid = GetId(DBKEY_STEAM_ID); request.has_steamid = true;
+ request.client_id = GetId(DBKEY_CLIENT_ID); request.has_client_id = true;
+ if (isEmail)
+ request.code_type = EAUTH_SESSION_GUARD_TYPE__k_EAuthSessionGuardType_EmailCode;
+ else
+ request.code_type = EAUTH_SESSION_GUARD_TYPE__k_EAuthSessionGuardType_DeviceCode;
+ request.has_code_type = true;
+ request.code = (char*)pszCode;
+ WSSendService("Authentication.UpdateAuthSessionWithSteamGuardCode#1", request, &CSteamProto::OnGotConfirmationCode);
+}
+
void CSteamProto::OnAuthorization(const uint8_t *buf, size_t cbLen)
{
proto::AuthenticationBeginAuthSessionViaCredentialsResponse reply(buf, cbLen);
@@ -229,13 +172,33 @@ void CSteamProto::OnAuthorization(const uint8_t *buf, size_t cbLen)
// Success
if (reply->has_client_id && reply->has_steamid) {
DeleteAuthSettings();
- SetId(DBKEY_STEAM_ID, reply->steamid);
- SetId(DBKEY_CLIENT_ID, reply->client_id);
+ SetId(DBKEY_STEAM_ID, m_iSteamId = reply->steamid);
+ SetId(DBKEY_CLIENT_ID, m_iClientId = reply->client_id);
+ m_requestId.append(reply->request_id.data, reply->request_id.len);
+
+ for (int i = 0; i < reply->n_allowed_confirmations; i++) {
+ auto &conf = reply->allowed_confirmations[i];
+ debugLogA("Confirmation required %d (%s)", conf->confirmation_type, conf->associated_message);
+ switch (conf->confirmation_type) {
+ case EAUTH_SESSION_GUARD_TYPE__k_EAuthSessionGuardType_None: // nothing to do
+ SendPollRequest();
+ return;
+
+ case EAUTH_SESSION_GUARD_TYPE__k_EAuthSessionGuardType_EmailCode: // email confirmation
+ CallFunctionSync(EnterEmailCode, this);
+ return;
+
+ case EAUTH_SESSION_GUARD_TYPE__k_EAuthSessionGuardType_DeviceCode: // totp confirmation
+ CallFunctionSync(EnterTotpCode, this);
+ return;
+ }
+
+ debugLogA("Unsupported confirmation code: %i", conf->confirmation_type);
+ LoginFailed();
+ }
- CAuthenticationPollAuthSessionStatusRequest request;
- request.client_id = reply->client_id; request.has_client_id = true;
- request.request_id = reply->request_id; request.has_request_id = true;
- WSSendService("Authentication.PollAuthSessionStatus#1", request, &CSteamProto::OnPollSession);
+ // no confirmation needed - we've done
+ SendPollRequest();
}
else {
debugLogA("Something went wrong: %s", reply->extended_error_message);
@@ -243,6 +206,14 @@ void CSteamProto::OnAuthorization(const uint8_t *buf, size_t cbLen)
}
}
+void CSteamProto::SendPollRequest()
+{
+ CAuthenticationPollAuthSessionStatusRequest request;
+ request.client_id = GetId(DBKEY_CLIENT_ID); request.has_client_id = true;
+ request.request_id.data = m_requestId.data(); request.request_id.len = m_requestId.length();
+ WSSendService("Authentication.PollAuthSessionStatus#1", request, &CSteamProto::OnPollSession);
+}
+
void CSteamProto::OnPollSession(const uint8_t *buf, size_t cbLen)
{
proto::AuthenticationPollAuthSessionStatusResponse reply(buf, cbLen);
diff --git a/protocols/Steam/src/steam_proto.h b/protocols/Steam/src/steam_proto.h
index 18c077e5ae..b32ee0953b 100644
--- a/protocols/Steam/src/steam_proto.h
+++ b/protocols/Steam/src/steam_proto.h
@@ -70,8 +70,9 @@ class CSteamProto : public PROTO<CSteamProto>
ptrW m_password;
bool m_bTerminated;
- HWND m_hwndGuard;
time_t m_idleTS;
+ int64_t m_iSteamId, m_iClientId;
+ MBinBuffer m_requestId;
int64_t GetId(const char *pszSetting);
void SetId(const char *pszSetting, int64_t id);
@@ -116,18 +117,20 @@ class CSteamProto : public PROTO<CSteamProto>
void LoginFailed();
void Logout();
+ static INT_PTR CALLBACK EnterTotpCode(void *param);
+ static INT_PTR CALLBACK EnterEmailCode(void *param);
+
void OnAuthorization(const uint8_t *buf, size_t cbLen);
void OnGotRsaKey(const uint8_t *buf, size_t cbLen);
+ void OnGotConfirmationCode(const uint8_t *buf, size_t cbLen);
void OnLoggedOn(const uint8_t *buf, size_t cbLen);
void OnPollSession(const uint8_t *buf, size_t cbLen);
- void OnGotCaptcha(const HttpResponse &response, void *arg);
-
- void OnAuthorizationError(const JSONNode &root);
-
void OnGotHosts(const JSONNode &root, void *);
void DeleteAuthSettings();
+ void SendConfirmationCode(bool, const char *pszCode);
+ void SendPollRequest();
// contacts
void SetAllContactStatuses(int status);
diff --git a/protocols/Steam/src/steam_server.cpp b/protocols/Steam/src/steam_server.cpp
index 8dc8274240..b632695e7e 100644
--- a/protocols/Steam/src/steam_server.cpp
+++ b/protocols/Steam/src/steam_server.cpp
@@ -112,6 +112,7 @@ void CSteamProto::ProcessMulti(const uint8_t *buf, size_t cbLen)
while ((int)cbLen > 0) {
uint32_t cbPacketLen = *(uint32_t *)buf; buf += sizeof(uint32_t); cbLen -= sizeof(uint32_t);
+ Netlib_Dump(m_ws->getConn(), buf, cbLen, false, 0);
ProcessMessage(buf, cbPacketLen);
buf += cbPacketLen; cbLen -= cbPacketLen;
}