///
import { AxiosInstance } from 'axios';
import { FlowClient } from './flow-client.js';
import { ExchangeClientCredentialsResult } from './oidc-functions.js';
import { SafeResult } from './safe-result.js';
export declare const DEFAULT_REFRESH_BUFFER_SECONDS = 60;
export declare const DEFAULT_EXPIRATION_BUFFER_SECONDS = 45;
export declare const DEFAULT_DISABLE_BACKGROUND_REFRESH = false;
/**
* Callback for token exchange.
*/
export type ExchangeTokenCallback = (accessToken: ExchangeClientCredentialsResult) => Promise;
/**
* Configuration for the ClientCredentialsFlowClient.
*/
export interface ClientCredentialsFlowClientConfig {
/**
* The domain to use for making requests.
*/
readonly authSureDomain: string;
/**
* The client to use for making requests. If not specified, a new client will be created.
*/
readonly client?: AxiosInstance;
/**
* The client ID to use.
*/
readonly clientId: string | Promise;
/**
* The client secret to use.
*/
readonly clientSecret: string | Promise;
/**
* The number of seconds before the access token expires to refresh the access token. Default is 60 seconds.
*
* @default 60
*/
readonly refreshBufferSeconds?: number;
/**
* The number of seconds to subtract from the token expiration time when calculating if the token is expired.
* Default is 45 seconds. Recommended to be less than the refreshBufferSeconds.
*
* @default 45
*/
readonly expirationBufferSeconds?: number;
/**
* Disable the background refresh of the access token. Default is false.
*
* @default false
*/
readonly disableBackgroundRefresh?: boolean;
/**
* The scopes to use. This can either be a space delimited string or an array of strings.
*/
readonly scope: string | string[];
/**
* Callback for the token exchange.
*/
readonly callback?: ExchangeTokenCallback | ExchangeTokenCallback[];
}
/**
* Client for the Client Credentials flow.
*/
export declare class ClientCredentialsFlowClient extends FlowClient {
protected clientId: string | Promise;
protected clientSecret: string | Promise;
protected scope: string | string[];
protected result?: ExchangeClientCredentialsResult;
protected expiration?: number;
protected refreshBufferSeconds: number;
protected disableBackgroundRefresh: boolean;
protected expirationBufferSeconds: number;
protected intervalId?: NodeJS.Timeout;
protected callbacks: ExchangeTokenCallback[];
constructor(config: ClientCredentialsFlowClientConfig);
/**
* Adds a callback for the token exchange.
*
* @param callback the callback to add
*/
callback(callback: ExchangeTokenCallback): void;
protected executeCallback(callback: ExchangeTokenCallback, response: ExchangeClientCredentialsResult): Promise;
protected executeCallbacks(response: ExchangeClientCredentialsResult): Promise;
/**
* Exchanges the client credentials for an access token which is stored in the client.
*/
exchange(): Promise;
/**
* Exchanges the client credentials for an access token which is stored in the client.
* This method does not throw exceptions and instead returns a SafeResult which can be used to check if the operation was successful.
*/
exchangeSafe(): Promise>;
/**
* Gets the access token. If the access token is expired, it will be refreshed.
*/
getToken(): Promise;
/**
* Gets the access token. If the access token is expired, it will be refreshed.
* This method does not throw exceptions and instead returns a SafeResult which can be used to check if the operation was successful.
*/
getTokenSafe(): Promise>;
/**
* Stops the background refresh of the access and refresh token.
*/
stop(): void;
/**
* Starts the background refresh the token. This is called automatically unless disableBackgroundRefresh is set to true.
*/
start(): Promise;
/**
* Closes the client and stops the background refresh of the access and refresh token.
*/
close(): void;
}
//# sourceMappingURL=client-credentials-flow-client.d.ts.map