import { EventEmitter } from 'events' ; import { GaxiosOptions , GaxiosPromise , GaxiosResponse } from 'gaxios' ; import { DefaultTransporter } from '../transporters' ; import { Credentials } from './credentials' ; import { Headers } from './oauth2client' ; /**
 * Defines the root interface for all clients that generate credentials
 * for calling Google APIs. All clients should implement this interface.
 */ export interface CredentialsClient { /**
     * The project ID corresponding to the current credentials if available.
     */ projectId ? : string | null ; /**
     * The expiration threshold in milliseconds before forcing token refresh.
     */ eagerRefreshThresholdMillis : number ; /**
     * Whether to force refresh on failure when making an authorization request.
     */ forceRefreshOnFailure : boolean ; return getAccessToken ( ) : Promise < { token ? : string | null ; res ? : GaxiosResponse | null ; } > ; param url getRequestHeaders ( url ? ) : Promise < Headers > ; /**
     * Provides an alternative Gaxios request implementation with auth credentials
     */ request < T > ( opts ) : GaxiosPromise < T > ; /**
     * Sets the auth credentials.
     */ setCredentials ( credentials ) : void ; param event param listener return on ( event , listener ) : this ; } export declare interface AuthClient { on ( event , listener ) : this ; } export abstract class AuthClient extends EventEmitter implements CredentialsClient { protected quotaProjectId ? : string ; transporter = new DefaultTransporter ( ) ; credentials : Credentials = { } ; projectId ? : string | null ; eagerRefreshThresholdMillis = 5 * 60 * 1000 ; forceRefreshOnFailure = false ; /**
     * Provides an alternative Gaxios request implementation with auth credentials
     */ abstract request < T > ( opts ) ; param url abstract getRequestHeaders ( url ? ) ; return abstract getAccessToken ( ) ; /**
     * Sets the auth credentials.
     */ setCredentials ( credentials ) { this . credentials = credentials ; } param headers protected addSharedMetadataHeaders ( headers ) { if ( ! headers [ 'x-goog-user-project' ] && this . quotaProjectId ) { headers [ 'x-goog-user-project' ] = this . quotaProjectId ; } return headers ; } }