Skip to content

Commit 19245fa

Browse files
authored
Merge pull request #41 from Amino-NET-Group/patch/fix-more-issues
Patch/fix more issues
2 parents a59271f + 56d57d6 commit 19245fa

7 files changed

Lines changed: 35 additions & 25 deletions

File tree

.github/workflows/dev-autopublish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626

2727
- name: Determine version
2828
id: version
29-
run: echo "::set-output name=version::0.$((${GITHUB_RUN_NUMBER} / 10)).$((${GITHUB_RUN_NUMBER} % 10))"
29+
run: echo "::set-output name=version::$((GITHUB_RUN_NUMBER / 100)).$(((GITHUB_RUN_NUMBER % 100) / 10)).$((GITHUB_RUN_NUMBER % 10))"
3030

3131
- name: Get Project Version
3232
id: base_version

Amino.NET/Builders/PostBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.IO;
44
using System.Reflection.Metadata.Ecma335;
55

6-
namespace Amino.NET.Builders
6+
namespace Amino.Builders
77
{
88
public class PostBuilder
99
{

Amino.NET/Client.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,8 @@ public Task logout()
363363
public Task login_sid(string sessionId, bool fetchProfile = true, bool connectSocket = true)
364364
{
365365
this.SessionId = sessionId;
366-
366+
this.UserId = helpers.sid_to_uid(sessionId);
367+
headerBuilder();
367368
if (fetchProfile)
368369
{
369370
Objects.UserAccount currentAccount = get_account_info();
@@ -767,10 +768,12 @@ public Objects.UserAccount get_account_info()
767768
RestClient client = new RestClient(helpers.BaseUrl);
768769
RestRequest request = new RestRequest("/g/s/account");
769770
request.AddHeaders(headers);
771+
request.AddHeader("SMDEVICEID", Guid.NewGuid().ToString());
772+
request.AddOrUpdateHeader("Content-Type", "application/x-www-form-urlencoded");
770773
var response = client.ExecuteGet(request);
771774
if ((int)response.StatusCode != 200) { throw new Exception(response.Content); }
772775
if (Debug) { Trace.WriteLine(response.Content); }
773-
return System.Text.Json.JsonSerializer.Deserialize<UserAccount>(JsonDocument.Parse(response.Content).RootElement.GetRawText());
776+
return System.Text.Json.JsonSerializer.Deserialize<UserAccount>(JsonDocument.Parse(response.Content).RootElement.GetProperty("account").GetRawText());
774777

775778
}
776779
/// <summary>
@@ -1802,7 +1805,7 @@ public Objects.WalletInfo get_wallet_info()
18021805
var response = client.ExecuteGet(request);
18031806
if ((int)response.StatusCode != 200) { throw new Exception(response.Content); }
18041807
if (Debug) { Trace.WriteLine(response.Content); }
1805-
return System.Text.Json.JsonSerializer.Deserialize<WalletInfo>(JsonDocument.Parse(response.Content).RootElement.GetRawText());
1808+
return System.Text.Json.JsonSerializer.Deserialize<WalletInfo>(JsonDocument.Parse(response.Content).RootElement.GetProperty("wallet").GetRawText());
18061809
}
18071810

18081811
/// <summary>

Amino.NET/Objects/CommunityThemePack.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public class CommunityThemePack
66
{
77
[JsonPropertyName("themeColor")] public string ThemeColor { get; set; }
88
[JsonPropertyName("themePackHash")] public string ThemePackHash { get; set; }
9-
[JsonPropertyName("themePackRevision")] public string ThemePackRevision { get; set; }
9+
[JsonPropertyName("themePackRevision")] public int ThemePackRevision { get; set; }
1010
[JsonPropertyName("themePackUrl")] public string ThemePackUrl { get; set; }
1111
}
1212
}

Amino.NET/Objects/GenericProfile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Amino.Objects
55
public class GenericProfile // ROOT JSON ELEMENT: userProfile
66
{
77
public string Json { get; set; } // NEEDS TO BE SET AFTER
8-
[JsonPropertyName("status")]public int Status { get; set; }
8+
[JsonPropertyName("status")]public int? Status { get; set; }
99
[JsonPropertyName("isNicknameVerified")]public bool IsNicknameVerified { get; set; }
1010
[JsonPropertyName("uid")]public string UserId { get; set; }
1111
[JsonPropertyName("level")]public int Level { get; set; }

Amino.NET/SubClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Amino.NET.Builders;
2-
using Amino.Objects;
1+
using Amino.Objects;
32
using Newtonsoft.Json;
43
using Newtonsoft.Json.Linq;
54
using RestSharp;
@@ -15,6 +14,7 @@
1514
using System.Text.Json;
1615
using System.Threading;
1716
using System.Threading.Tasks;
17+
using Amino.Builders;
1818

1919
namespace Amino
2020
{

Amino.NET/helpers.cs

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -235,28 +235,35 @@ public static List<Dictionary<string, long>> getTimeData()
235235
/// </summary>
236236
/// <param name="session"></param>
237237
/// <returns></returns>
238-
public static dynamic DecodeSid(string session)
238+
public static Dictionary<string, object> DecodeSid(string sid)
239239
{
240-
// Replace characters and adjust padding
241-
session = session.Replace('-', '_').Replace('+', '/');
242-
int padding = session.Length % 4;
243-
if (padding > 0)
240+
sid = sid.Replace('-', '+').Replace('_', '/');
241+
242+
int padding = 4 - (sid.Length % 4);
243+
if (padding < 4)
244244
{
245-
session = session.PadRight(session.Length + (4 - padding), '=');
245+
sid += new string('=', padding);
246246
}
247247

248-
// Decode base64, remove the first byte, and remove the last 21 bytes
249-
byte[] bytes = Convert.FromBase64String(session);
250-
bytes = bytes.Skip(1).Take(bytes.Length - 21).ToArray();
248+
byte[] decodedBytes = Convert.FromBase64String(sid);
249+
250+
byte[] trimmedBytes = new byte[decodedBytes.Length - 21];
251+
Array.Copy(decodedBytes, 1, trimmedBytes, 0, trimmedBytes.Length);
252+
string jsonString = Encoding.UTF8.GetString(trimmedBytes);
253+
254+
// Deserialize JSON string to dictionary
255+
var options = new JsonSerializerOptions
256+
{
257+
PropertyNameCaseInsensitive = true
258+
};
259+
var dictionary = System.Text.Json.JsonSerializer.Deserialize<Dictionary<string, object>>(jsonString, options);
251260

252-
// Convert bytes to UTF-8 string and parse JSON directly
253-
string jsonString = Encoding.UTF8.GetString(bytes);
254-
return System.Text.Json.JsonSerializer.Deserialize<dynamic>(jsonString);
261+
return dictionary;
255262
}
256263

257-
public static string sid_to_uid(string session) { return DecodeSid(session)["2"]; }
258-
public static string sid_to_ip_address(string session) { return DecodeSid(session)["4"]; }
259-
public static string sid_created_time(string session) { return DecodeSid(session)["5"]; }
260-
public static string sid_to_client_type(string session) { return DecodeSid(session)["6"]; }
264+
public static string sid_to_uid(string session) { return DecodeSid(session)["2"].ToString(); }
265+
public static string sid_to_ip_address(string session) { return DecodeSid(session)["4"].ToString(); }
266+
public static string sid_created_time(string session) { return DecodeSid(session)["5"].ToString(); }
267+
public static string sid_to_client_type(string session) { return DecodeSid(session)["6"].ToString(); }
261268
}
262269
}

0 commit comments

Comments
 (0)