Add session data for SDA compatibility

This commit is contained in:
Archi
2023-12-02 17:00:50 +01:00
parent fac8cb2c9a
commit eef66cebf3
3 changed files with 51 additions and 2 deletions

View File

@@ -357,7 +357,7 @@ internal static class Commands {
return bot.Commands.FormatBotResponse(string.Format(CultureInfo.CurrentCulture, Strings.WarningFailedWithError, result));
}
MaFileData maFileData = new(response, deviceID);
MaFileData maFileData = new(response, bot.SteamID, deviceID);
string maFilePendingPath = $"{bot.GetFilePath(Bot.EFileType.MobileAuthenticator)}.PENDING";
string json = JsonConvert.SerializeObject(maFileData, Formatting.Indented);

View File

@@ -21,6 +21,7 @@
using System;
using Newtonsoft.Json;
using SteamKit2;
using SteamKit2.Internal;
namespace ArchiSteamFarm.OfficialPlugins.MobileAuthenticator;
@@ -47,6 +48,9 @@ internal sealed class MaFileData {
[JsonProperty("server_time", Required = Required.Always)]
internal readonly ulong ServerTime;
[JsonProperty(Required = Required.Always)]
internal readonly MaFileSessionData Session;
[JsonProperty("shared_secret", Required = Required.Always)]
internal readonly string SharedSecret;
@@ -59,8 +63,13 @@ internal sealed class MaFileData {
[JsonProperty("uri", Required = Required.Always)]
internal readonly string Uri;
internal MaFileData(CTwoFactor_AddAuthenticator_Response data, string deviceID) {
internal MaFileData(CTwoFactor_AddAuthenticator_Response data, ulong steamID, string deviceID) {
ArgumentNullException.ThrowIfNull(data);
if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) {
throw new ArgumentOutOfRangeException(nameof(steamID));
}
ArgumentException.ThrowIfNullOrEmpty(deviceID);
AccountName = data.account_name;
@@ -70,6 +79,7 @@ internal sealed class MaFileData {
Secret1 = Convert.ToBase64String(data.secret_1);
SerialNumber = data.serial_number;
ServerTime = data.server_time;
Session = new MaFileSessionData(steamID);
SharedSecret = Convert.ToBase64String(data.shared_secret);
Status = data.status;
TokenGid = data.token_gid;

View File

@@ -0,0 +1,39 @@
// _ _ _ ____ _ _____
// / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
// / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
// / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
// /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
// |
// Copyright 2015-2023 Łukasz "JustArchi" Domeradzki
// Contact: JustArchi@JustArchi.net
// |
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// |
// http://www.apache.org/licenses/LICENSE-2.0
// |
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System;
using Newtonsoft.Json;
using SteamKit2;
namespace ArchiSteamFarm.OfficialPlugins.MobileAuthenticator;
internal sealed class MaFileSessionData {
[JsonProperty(Required = Required.Always)]
internal readonly ulong SteamID;
internal MaFileSessionData(ulong steamID) {
if ((steamID == 0) || !new SteamID(steamID).IsIndividualAccount) {
throw new ArgumentOutOfRangeException(nameof(steamID));
}
SteamID = steamID;
}
}