Skip to content

Commit

Permalink
Rotating Secret Keys V2 Support (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xFirekeeper authored Feb 13, 2025
1 parent 325625a commit 1442ae3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Thirdweb.Tests/Thirdweb.Client/Thirdweb.Client.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public void ClientIdAndSecretKeyInitialization()
Assert.NotNull(client.ClientId);
Assert.NotNull(client.SecretKey);
Assert.Null(client.BundleId);
Assert.NotEqual(client.ClientId, clientId);
Assert.Equal(client.ClientId, Utils.ComputeClientIdFromSecretKey(client.SecretKey));
Assert.Equal(client.ClientId, clientId);
Assert.NotEqual(client.ClientId, Utils.ComputeClientIdFromSecretKey(client.SecretKey));
Assert.Equal(client.SecretKey, this.SecretKey);
}

Expand Down
13 changes: 3 additions & 10 deletions Thirdweb/Thirdweb.Client/ThirdwebClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,9 @@ private ThirdwebClient(
throw new InvalidOperationException("ClientId or SecretKey must be provided");
}

if (!string.IsNullOrEmpty(secretKey))
{
this.ClientId = Utils.ComputeClientIdFromSecretKey(secretKey);
this.SecretKey = secretKey;
}
else
{
this.ClientId = clientId;
}

// Respects provided clientId if any, otherwise computes it from secretKey
this.ClientId = !string.IsNullOrEmpty(clientId) ? clientId : (string.IsNullOrEmpty(secretKey) ? null : Utils.ComputeClientIdFromSecretKey(secretKey));
this.SecretKey = secretKey;
this.BundleId = bundleId;

this.FetchTimeoutOptions = fetchTimeoutOptions ?? new TimeoutOptions();
Expand Down

0 comments on commit 1442ae3

Please sign in to comment.