Skip to content

Commit 1442ae3

Browse files
authored
Rotating Secret Keys V2 Support (#131)
1 parent 325625a commit 1442ae3

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

Thirdweb.Tests/Thirdweb.Client/Thirdweb.Client.Tests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ public void ClientIdAndSecretKeyInitialization()
4949
Assert.NotNull(client.ClientId);
5050
Assert.NotNull(client.SecretKey);
5151
Assert.Null(client.BundleId);
52-
Assert.NotEqual(client.ClientId, clientId);
53-
Assert.Equal(client.ClientId, Utils.ComputeClientIdFromSecretKey(client.SecretKey));
52+
Assert.Equal(client.ClientId, clientId);
53+
Assert.NotEqual(client.ClientId, Utils.ComputeClientIdFromSecretKey(client.SecretKey));
5454
Assert.Equal(client.SecretKey, this.SecretKey);
5555
}
5656

Thirdweb/Thirdweb.Client/ThirdwebClient.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,9 @@ private ThirdwebClient(
4242
throw new InvalidOperationException("ClientId or SecretKey must be provided");
4343
}
4444

45-
if (!string.IsNullOrEmpty(secretKey))
46-
{
47-
this.ClientId = Utils.ComputeClientIdFromSecretKey(secretKey);
48-
this.SecretKey = secretKey;
49-
}
50-
else
51-
{
52-
this.ClientId = clientId;
53-
}
54-
45+
// Respects provided clientId if any, otherwise computes it from secretKey
46+
this.ClientId = !string.IsNullOrEmpty(clientId) ? clientId : (string.IsNullOrEmpty(secretKey) ? null : Utils.ComputeClientIdFromSecretKey(secretKey));
47+
this.SecretKey = secretKey;
5548
this.BundleId = bundleId;
5649

5750
this.FetchTimeoutOptions = fetchTimeoutOptions ?? new TimeoutOptions();

0 commit comments

Comments
 (0)