1 // ----------------------------------------------------------------------------------------------
3 // / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
4 // / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
5 // / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
6 // /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
7 // ----------------------------------------------------------------------------------------------
9 // Copyright 2015-2024 Ćukasz "JustArchi" Domeradzki
10 // Contact: JustArchi@JustArchi.net
12 // Licensed under the Apache License, Version 2.0 (the "License");
13 // you may not use this file except in compliance with the License.
14 // You may obtain a copy of the License at
16 // http://www.apache.org/licenses/LICENSE-2.0
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the License is distributed on an "AS IS" BASIS,
20 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 // See the License for the specific language governing permissions and
22 // limitations under the License.
25 using System
.Text
.Json
.Serialization
;
27 using SteamKit2
.Internal
;
29 namespace ArchiSteamFarm
.OfficialPlugins
.MobileAuthenticator
;
31 internal sealed class MaFileData
{
33 [JsonPropertyName("account_name")]
35 internal string AccountName { get; private init; }
38 [JsonPropertyName("device_id")]
40 internal string DeviceID { get; private init; }
43 [JsonPropertyName("identity_secret")]
45 internal string IdentitySecret { get; private init; }
48 [JsonPropertyName("revocation_code")]
50 internal string RevocationCode { get; private init; }
53 [JsonPropertyName("secret_1")]
55 internal string Secret1 { get; private init; }
58 [JsonPropertyName("serial_number")]
60 internal ulong SerialNumber { get; private init; }
63 [JsonPropertyName("server_time")]
65 internal ulong ServerTime { get; private init; }
69 internal MaFileSessionData Session { get; private init; }
72 [JsonPropertyName("shared_secret")]
74 internal string SharedSecret { get; private init; }
77 [JsonPropertyName("status")]
79 internal int Status { get; private init; }
82 [JsonPropertyName("token_gid")]
84 internal string TokenGid { get; private init; }
87 [JsonPropertyName("uri")]
89 internal string Uri { get; private init; }
91 internal MaFileData(CTwoFactor_AddAuthenticator_Response data
, ulong steamID
, string deviceID
) {
92 ArgumentNullException
.ThrowIfNull(data
);
94 if ((steamID
== 0) || !new SteamID(steamID
).IsIndividualAccount
) {
95 throw new ArgumentOutOfRangeException(nameof(steamID
));
98 ArgumentException
.ThrowIfNullOrEmpty(deviceID
);
100 AccountName
= data
.account_name
;
102 IdentitySecret
= Convert
.ToBase64String(data
.identity_secret
);
103 RevocationCode
= data
.revocation_code
;
104 Secret1
= Convert
.ToBase64String(data
.secret_1
);
105 SerialNumber
= data
.serial_number
;
106 ServerTime
= data
.server_time
;
107 Session
= new MaFileSessionData(steamID
);
108 SharedSecret
= Convert
.ToBase64String(data
.shared_secret
);
109 Status
= data
.status
;
110 TokenGid
= data
.token_gid
;