Skip to content

Commit 6378f37

Browse files
authored
chore: pass allowImpersonation flag to /v2/keys/use (#7303)
1 parent b3e42f7 commit 6378f37

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

.changeset/whole-ends-like.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@thirdweb-dev/service-utils": patch
3+
---
4+
5+
chore: pass allowImpersonation to auth server

packages/service-utils/src/core/api.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,21 @@ export type CoreServiceConfig = {
2727
* The number of times to retry the auth request. Default = 3.
2828
*/
2929
retryCount?: number;
30+
/**
31+
* Allow staff members to read data from this service for troubleshooting purposes. Default = false.
32+
*/
33+
allowImpersonation?: boolean;
3034
};
3135

3236
export type TeamAndProjectResponse = {
3337
authMethod: "secretKey" | "publishableKey" | "jwt" | "teamId";
3438
team: TeamResponse;
35-
project?: ProjectResponse | null;
39+
project?: ProjectResponse;
40+
impersonatedBy?: {
41+
id: string;
42+
email: string;
43+
// Omitting the full account details
44+
};
3645
};
3746

3847
export type ApiResponse = {
@@ -250,7 +259,7 @@ export async function fetchTeamAndProject(
250259
authData: AuthorizationInput,
251260
config: CoreServiceConfig,
252261
): Promise<ApiResponse> {
253-
const { apiUrl, serviceApiKey } = config;
262+
const { apiUrl, serviceApiKey, allowImpersonation } = config;
254263
const { teamId, clientId } = authData;
255264

256265
const url = new URL("/v2/keys/use", apiUrl);
@@ -260,6 +269,9 @@ export async function fetchTeamAndProject(
260269
if (teamId) {
261270
url.searchParams.set("teamId", teamId);
262271
}
272+
if (allowImpersonation) {
273+
url.searchParams.set("allowImpersonation", "true");
274+
}
263275

264276
// compute the appropriate auth headers based on the auth data
265277
const authHeaders = getAuthHeaders(authData, serviceApiKey);

0 commit comments

Comments
 (0)