import OAuthClientCredentialsGrant from "../authentication/oauth-client-credentials-grant"; import OAuthPasswordGrant from "../authentication/oauth-password-grant"; import OAuthRefreshTokenGrant from "../authentication/oauth-refreshtoken-grant"; import { MapStringTo } from "../base-types"; import { RequestMessage } from "./request-message"; import { ResponseMessage } from "./response-message"; export type CancelCallback = (cancel: (reason?: string) => void) => void; export interface IInternalClient { /** * Authenticate with the remote server. * * @remarks * Should return true when authentication succeeded. * Should return false or throw an error when authentication failed. * * @returns Promise resolving to a boolean indicating if authentication succeeded. */ authenticateAsync(): Promise; /** * Sends a request to the remote server and returns the server's response. * @param requestGenerator - Function which returns a {@link RequestMessage} * @param cancelCallback - A {@link CancelCallback} that will be placed in an axios {@link CancelToken} if provided */ sendAsync(requestGenerator: () => RequestMessage, cancelCallback?: CancelCallback): Promise>; /** * Set headers which will be send with every request. * @param headers - The headers to send with every request */ setRequestHeaders(headers: MapStringTo): void; /** * Sets the error response handler. * @param onError - The callback function to handle the response error. * * @remarks * Only expected to work when authentication to the endpoint has been established without the use of an OAuth grant. */ setResponseErrorHandler(onError: (error: any) => Promise): void; } export declare class InternalClient implements IInternalClient { private _accessToken; private _passwordGrant; private _refreshTokenGrant; private _clientCredentialsGrant; private _isAuthenticated; private _requestHeaders; private readonly _client; /** * Indicates if we should authenticate with OAuth. */ private get shouldAuthenticateWithOAuth(); constructor(baseUri: URI | string, oauthGrant?: OAuthPasswordGrant | OAuthRefreshTokenGrant | OAuthClientCredentialsGrant); authenticateAsync(): Promise; setRequestHeaders(headers: MapStringTo): void; /** * Sets the provided error handler as an interceptor for the responses. * @param onError - the callback that should be called on error. */ setResponseErrorHandler(onError: (error: any) => Promise): void; private send_onFulfilled; private send_onRejected; sendAsync(requestGenerator: () => RequestMessage, cancelCallback?: CancelCallback): Promise>; }