Skip to content

chore: pass allowImpersonation flag to /v2/keys/use #7303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
5 changes: 5 additions & 0 deletions .changeset/whole-ends-like.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@thirdweb-dev/service-utils": patch
---

chore: pass allowImpersonation to auth server
16 changes: 14 additions & 2 deletions packages/service-utils/src/core/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,21 @@ export type CoreServiceConfig = {
* The number of times to retry the auth request. Default = 3.
*/
retryCount?: number;
/**
* Allow staff members to read data from this service for troubleshooting purposes. Default = false.
*/
allowImpersonation?: boolean;
};

export type TeamAndProjectResponse = {
authMethod: "secretKey" | "publishableKey" | "jwt" | "teamId";
team: TeamResponse;
project?: ProjectResponse | null;
project?: ProjectResponse;
impersonatedBy?: {
id: string;
email: string;
// Omitting the full account details
};
};

export type ApiResponse = {
Expand Down Expand Up @@ -250,7 +259,7 @@ export async function fetchTeamAndProject(
authData: AuthorizationInput,
config: CoreServiceConfig,
): Promise<ApiResponse> {
const { apiUrl, serviceApiKey } = config;
const { apiUrl, serviceApiKey, allowImpersonation } = config;
const { teamId, clientId } = authData;

const url = new URL("/v2/keys/use", apiUrl);
Expand All @@ -260,6 +269,9 @@ export async function fetchTeamAndProject(
if (teamId) {
url.searchParams.set("teamId", teamId);
}
if (allowImpersonation) {
url.searchParams.set("allowImpersonation", "true");
}

// compute the appropriate auth headers based on the auth data
const authHeaders = getAuthHeaders(authData, serviceApiKey);
Expand Down
Loading