Skip to content

Commit

Permalink
revert auth breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
alecananian committed May 21, 2024
1 parent 9fdcb74 commit 193d9b4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
25 changes: 13 additions & 12 deletions Assets/Treasure/TDK/Runtime/API/Auth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,13 @@ public struct GetAuthPayloadResponse
[Serializable]
public struct LogInBody
{
public AuthPayload payload;
public string signature;
public struct Payload
{
public AuthPayload payload;
public string signature;
}

public Payload payload;
}

[Serializable]
Expand Down Expand Up @@ -73,7 +78,6 @@ public struct Signer

public partial class API
{
[Obsolete("GetAuthPayload is deprecated. Use GetLoginPayload.")]
public async Task<AuthPayload> GetAuthPayload(string address, string chainId)
{
var response = await Post("/auth/payload", JsonConvert.SerializeObject(new GetAuthPayloadBody()
Expand All @@ -84,18 +88,15 @@ public async Task<AuthPayload> GetAuthPayload(string address, string chainId)
return JsonConvert.DeserializeObject<GetAuthPayloadResponse>(response).payload;
}

public async Task<AuthPayload> GetLoginPayload(string address)
{
var response = await Get($"/login/payload?address={address}");
return JsonConvert.DeserializeObject<AuthPayload>(response);
}

public async Task<string> LogIn(AuthPayload payload, string signature)
{
var response = await Post("/login", JsonConvert.SerializeObject(new LogInBody()
var response = await Post("/auth/login", JsonConvert.SerializeObject(new LogInBody()
{
payload = payload,
signature = signature,
payload = new LogInBody.Payload()
{
payload = payload,
signature = signature,
}
}));
return JsonConvert.DeserializeObject<LogInResponse>(response).token;
}
Expand Down
3 changes: 2 additions & 1 deletion Assets/Treasure/TDK/Runtime/Identity/TDK.Identity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ public async Task<string> StartUserSession(Project project)

// Create auth token
TDKLogger.Log("Fetching login payload");
var payload = await TDK.API.GetLoginPayload(address);
var chainId = (int)await GetChainId();
var payload = await TDK.API.GetAuthPayload(address, chainId.ToString());

TDKLogger.Log("Signing login payload");
var signature = await GenerateSignature(payload);
Expand Down
2 changes: 1 addition & 1 deletion Assets/Treasure/TDK/Runtime/TDKVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
public static class TDKVersion
{
public static string name = "tdk-unity";
public static string version = "0.3.2";
public static string version = "0.3.3";
}
}

0 comments on commit 193d9b4

Please sign in to comment.