chore(deps): update dependency steamkit2 to 3.0.1
[ArchiSteamFarm.git] / ArchiSteamFarm.OfficialPlugins.MobileAuthenticator / MaFileData.cs
bloba21e28a56ce0ccbbda085d4dc8c1dfc612da8515
1 // ----------------------------------------------------------------------------------------------
2 // _ _ _ ____ _ _____
3 // / \ _ __ ___ | |__ (_)/ ___| | |_ ___ __ _ _ __ ___ | ___|__ _ _ __ _ __ ___
4 // / _ \ | '__|/ __|| '_ \ | |\___ \ | __|/ _ \ / _` || '_ ` _ \ | |_ / _` || '__|| '_ ` _ \
5 // / ___ \ | | | (__ | | | || | ___) || |_| __/| (_| || | | | | || _|| (_| || | | | | | | |
6 // /_/ \_\|_| \___||_| |_||_||____/ \__|\___| \__,_||_| |_| |_||_| \__,_||_| |_| |_| |_|
7 // ----------------------------------------------------------------------------------------------
8 // |
9 // Copyright 2015-2024 Ɓukasz "JustArchi" Domeradzki
10 // Contact: JustArchi@JustArchi.net
11 // |
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
15 // |
16 // http://www.apache.org/licenses/LICENSE-2.0
17 // |
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.
24 using System;
25 using System.Text.Json.Serialization;
26 using SteamKit2;
27 using SteamKit2.Internal;
29 namespace ArchiSteamFarm.OfficialPlugins.MobileAuthenticator;
31 internal sealed class MaFileData {
32 [JsonInclude]
33 [JsonPropertyName("account_name")]
34 [JsonRequired]
35 internal string AccountName { get; private init; }
37 [JsonInclude]
38 [JsonPropertyName("device_id")]
39 [JsonRequired]
40 internal string DeviceID { get; private init; }
42 [JsonInclude]
43 [JsonPropertyName("identity_secret")]
44 [JsonRequired]
45 internal string IdentitySecret { get; private init; }
47 [JsonInclude]
48 [JsonPropertyName("revocation_code")]
49 [JsonRequired]
50 internal string RevocationCode { get; private init; }
52 [JsonInclude]
53 [JsonPropertyName("secret_1")]
54 [JsonRequired]
55 internal string Secret1 { get; private init; }
57 [JsonInclude]
58 [JsonPropertyName("serial_number")]
59 [JsonRequired]
60 internal ulong SerialNumber { get; private init; }
62 [JsonInclude]
63 [JsonPropertyName("server_time")]
64 [JsonRequired]
65 internal ulong ServerTime { get; private init; }
67 [JsonInclude]
68 [JsonRequired]
69 internal MaFileSessionData Session { get; private init; }
71 [JsonInclude]
72 [JsonPropertyName("shared_secret")]
73 [JsonRequired]
74 internal string SharedSecret { get; private init; }
76 [JsonInclude]
77 [JsonPropertyName("status")]
78 [JsonRequired]
79 internal int Status { get; private init; }
81 [JsonInclude]
82 [JsonPropertyName("token_gid")]
83 [JsonRequired]
84 internal string TokenGid { get; private init; }
86 [JsonInclude]
87 [JsonPropertyName("uri")]
88 [JsonRequired]
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;
101 DeviceID = deviceID;
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;
111 Uri = data.uri;