diff --git a/.changeset/wicked-chairs-own.md b/.changeset/wicked-chairs-own.md new file mode 100644 index 00000000000..db5b71a1c12 --- /dev/null +++ b/.changeset/wicked-chairs-own.md @@ -0,0 +1,5 @@ +--- +"thirdweb": patch +--- + +when explicitly passing `clientId` to `createThirdwebClient()` prefer it over computing the `clientId` from a passed `secretKey` option diff --git a/packages/thirdweb/src/client/client.test.ts b/packages/thirdweb/src/client/client.test.ts index 9f17c3412bc..fd83d4a1503 100644 --- a/packages/thirdweb/src/client/client.test.ts +++ b/packages/thirdweb/src/client/client.test.ts @@ -13,9 +13,9 @@ describe("client", () => { expect(client.clientId).toBe(computeClientIdFromSecretKey("bar")); expect(client.secretKey).toBe("bar"); }); - it("should ignore clientId if secretKey is provided", () => { + it("should NOT ignore clientId if secretKey is provided", () => { const client = createThirdwebClient({ clientId: "foo", secretKey: "bar" }); - expect(client.clientId).toBe(computeClientIdFromSecretKey("bar")); + expect(client.clientId).toBe("foo"); expect(client.secretKey).toBe("bar"); }); it("should throw an error if neither clientId nor secretKey is provided", () => { diff --git a/packages/thirdweb/src/client/client.ts b/packages/thirdweb/src/client/client.ts index 796a350c5aa..a804210b8ed 100644 --- a/packages/thirdweb/src/client/client.ts +++ b/packages/thirdweb/src/client/client.ts @@ -114,7 +114,8 @@ export function createThirdwebClient( throw new Error("clientId must be provided when using a JWT secretKey"); } } else { - realClientId = computeClientIdFromSecretKey(secretKey); + // always PREFER the clientId if provided, only compute it from the secretKey if we don't have a clientId passed explicitly + realClientId = clientId ?? computeClientIdFromSecretKey(secretKey); } }