Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/giant-moons-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@thirdweb-dev/service-utils": patch
"thirdweb": patch
---

allow passing the team id explicitly via request headers
7 changes: 6 additions & 1 deletion packages/service-utils/src/cf-worker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ export async function extractAuthorizationData(
}
}

let teamId: string | null = null;
if (headers.has("x-team-id")) {
teamId = headers.get("x-team-id");
}

return {
incomingServiceApiKey,
incomingServiceApiKeyHash,
Expand All @@ -168,7 +173,7 @@ export async function extractAuthorizationData(
origin,
bundleId,
secretKeyHash,
teamId: authInput.teamId,
teamId: authInput.teamId ?? teamId ?? undefined,
targetAddress: authInput.targetAddress,
};
}
Expand Down
7 changes: 6 additions & 1 deletion packages/service-utils/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ export function extractAuthorizationData(
}
}

let teamId: string | null = null;
if (getHeader(headers, "x-team-id")) {
teamId = getHeader(headers, "x-team-id");
}

return {
incomingServiceApiKey,
incomingServiceApiKeyHash,
Expand All @@ -173,7 +178,7 @@ export function extractAuthorizationData(
origin,
bundleId,
targetAddress: authInput.targetAddress,
teamId: authInput.teamId,
teamId: authInput.teamId ?? teamId ?? undefined,
useWalletAuth,
};
}
Expand Down
6 changes: 6 additions & 0 deletions packages/thirdweb/src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ type ClientOptions = Prettify<{
gatewayUrl?: string;
};
};

/**
* The team ID for thirdweb dashboard usage.
* @hidden
*/
teamId?: string;
}>;

export type CreateThirdwebClientOptions = Prettify<
Expand Down
4 changes: 4 additions & 0 deletions packages/thirdweb/src/utils/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
!isBundlerUrl(urlString)
) {
headers.set("authorization", `Bearer ${authToken}`);
// if we have a specific teamId set, add it to the request headers
if (client.teamId) {
headers.set("x-team-id", client.teamId);
}

Check warning on line 61 in packages/thirdweb/src/utils/fetch.ts

View check run for this annotation

Codecov / codecov/patch

packages/thirdweb/src/utils/fetch.ts#L60-L61

Added lines #L60 - L61 were not covered by tests
} else if (secretKey) {
headers.set("x-secret-key", secretKey);
} else if (clientId) {
Expand Down
Loading