Skip to content

Commit 150581c

Browse files
committed
prefer explicit clientId over secretKey computation
1 parent ee57ded commit 150581c

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

.changeset/wicked-chairs-own.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
when explicitly passing `clientId` to `createThirdwebClient()` prefer it over computing the `clientId` from a passed `secretKey` option

packages/thirdweb/src/client/client.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ describe("client", () => {
1313
expect(client.clientId).toBe(computeClientIdFromSecretKey("bar"));
1414
expect(client.secretKey).toBe("bar");
1515
});
16-
it("should ignore clientId if secretKey is provided", () => {
16+
it("should NOT ignore clientId if secretKey is provided", () => {
1717
const client = createThirdwebClient({ clientId: "foo", secretKey: "bar" });
18-
expect(client.clientId).toBe(computeClientIdFromSecretKey("bar"));
18+
expect(client.clientId).toBe("foo");
1919
expect(client.secretKey).toBe("bar");
2020
});
2121
it("should throw an error if neither clientId nor secretKey is provided", () => {

packages/thirdweb/src/client/client.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ export function createThirdwebClient(
114114
throw new Error("clientId must be provided when using a JWT secretKey");
115115
}
116116
} else {
117-
realClientId = computeClientIdFromSecretKey(secretKey);
117+
// always PREFER the clientId if provided, only compute it from the secretKey if we don't have a clientId passed explicitly
118+
realClientId = clientId ?? computeClientIdFromSecretKey(secretKey);
118119
}
119120
}
120121

0 commit comments

Comments
 (0)