@@ -27,12 +27,21 @@ export type CoreServiceConfig = {
27
27
* The number of times to retry the auth request. Default = 3.
28
28
*/
29
29
retryCount ?: number ;
30
+ /**
31
+ * Allow staff members to read data from this service for troubleshooting purposes. Default = false.
32
+ */
33
+ allowImpersonation ?: boolean ;
30
34
} ;
31
35
32
36
export type TeamAndProjectResponse = {
33
37
authMethod : "secretKey" | "publishableKey" | "jwt" | "teamId" ;
34
38
team : TeamResponse ;
35
- project ?: ProjectResponse | null ;
39
+ project ?: ProjectResponse ;
40
+ impersonatedBy ?: {
41
+ id : string ;
42
+ email : string ;
43
+ // Omitting the full account details
44
+ } ;
36
45
} ;
37
46
38
47
export type ApiResponse = {
@@ -250,7 +259,7 @@ export async function fetchTeamAndProject(
250
259
authData : AuthorizationInput ,
251
260
config : CoreServiceConfig ,
252
261
) : Promise < ApiResponse > {
253
- const { apiUrl, serviceApiKey } = config ;
262
+ const { apiUrl, serviceApiKey, allowImpersonation } = config ;
254
263
const { teamId, clientId } = authData ;
255
264
256
265
const url = new URL ( "/v2/keys/use" , apiUrl ) ;
@@ -260,6 +269,9 @@ export async function fetchTeamAndProject(
260
269
if ( teamId ) {
261
270
url . searchParams . set ( "teamId" , teamId ) ;
262
271
}
272
+ if ( allowImpersonation ) {
273
+ url . searchParams . set ( "allowImpersonation" , "true" ) ;
274
+ }
263
275
264
276
// compute the appropriate auth headers based on the auth data
265
277
const authHeaders = getAuthHeaders ( authData , serviceApiKey ) ;
0 commit comments