@@ -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
3236export 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
3847export 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