import { type ServiceScope } from '@microsoft/sp-core-library'; import type { IHttpClientOptions } from '../httpClient/HttpClient'; import type HttpClientResponse from '../httpClient/HttpClientResponse'; import type { IAadTokenProviderConfiguration } from '../oauthTokenProvider/IAadTokenProvider'; import type { IAadTokenProvider } from '../oauthTokenProvider/IAadTokenProvider'; import type { IAadHttpClientConfigurations } from './AadHttpClientConfiguration'; import type AadHttpClientConfiguration from './AadHttpClientConfiguration'; import type { IHttpRequestCacheOptions, IRequestCacheOptions } from '../caching/IRequestCacheOptions'; import type { IClientCachableResponse } from '../caching/IClientCachableResponse'; /** * AadHttpClient is used to perform REST calls against an Azure AD Application. * * @remarks * For communicating with SharePoint, use the {@link SPHttpClient} class instead. * For communicating with Microsoft Graph, use the {@link @microsoft/sp-http-msgraph#MSGraphClient} class. * * @public * @sealed */ export default class AadHttpClient { /** * The standard predefined AadHttpClientConfiguration objects for use with * the AadHttpClient class. */ static readonly configurations: IAadHttpClientConfigurations; private static readonly _className; /** * Used for mocking the AadHttpClientFactory * @internal */ protected _aadTokenProvider: IAadTokenProvider; private _aadTokenConfiguration; private _resourceUrl; private _serviceScope; private _fetchProvider; private _useCachedToken; private _cacheProvider; private _ERROR_REGEX; /** * * @param serviceScope - The service scope is needed to retrieve some of the class's internal components. * @param resourceEndpoint - The resource for which the token should be obtained. * @param options - Configuration options for the request to get an access token. * */ constructor(serviceScope: ServiceScope, resourceEndpoint: string, options?: IAadHttpClientOptions); /** * Performs a REST service call. * * @remarks * Although the AadHttpClient subclass adds additional enhancements, the parameters and semantics * for HttpClient.fetch() are essentially the same as the WHATWG API standard that is documented here: * https://fetch.spec.whatwg.org/ * * @param url - The endpoint URL that fetch will be called on. * @param configuration - Determines the default behavior of HttpClient; normally this should * be the latest version number from HttpClientConfigurations. * @param options - Additional options that affect the request. * @returns A promise that will return the result. */ fetch(url: string, configuration: AadHttpClientConfiguration, options: IHttpClientOptions): Promise; /** * Performs a REST service call. * * @remarks * Although the AadHttpClient subclass adds additional enhancements, the parameters and semantics * for HttpClient.fetch() are essentially the same as the WHATWG API standard that is documented here: * https://fetch.spec.whatwg.org/ * * @param url - The endpoint URL that fetch will be called on. * @param configuration - Determines the default behavior of HttpClient; normally this should * be the latest version number from HttpClientConfigurations. * @param options - Additional options that affect the request. * @param cacheConfiguration - determines the configuration for cache management of this request. * @returns A promise containing a IClientCachableResponse, which contains a * Promise to the cached data response and a Promise to the server response. * * @internal */ fetch(url: string, configuration: AadHttpClientConfiguration, options: IHttpClientOptions, cacheConfiguration: IRequestCacheOptions): Promise>; /** * Performs a REST service call. * * @remarks * Although the AadHttpClient subclass adds additional enhancements, the parameters and semantics * for HttpClient.fetch() are essentially the same as the WHATWG API standard that is documented here: * https://fetch.spec.whatwg.org/ * * @param url - The endpoint URL that fetch will be called on. * @param configuration - Determines the default behavior of HttpClient; normally this should * be the latest version number from HttpClientConfigurations. * @param options - Additional options that affect the request. * @param cacheConfiguration - determines the configuration for cache management of this request * @returns A Promise to the cached data response or a Promise to the server response. * * @internal */ fetch(url: string, configuration: AadHttpClientConfiguration, options: IHttpClientOptions, cacheConfiguration: IRequestCacheOptions): Promise; /** * Calls fetch(), but sets the method to "GET". * * @param url - The endpoint URL that fetch will be called on. * @param configuration - Determines the default behavior of HttpClient; normally this should * be the latest version number from HttpClientConfigurations. * @param options - Additional options that affect the request. * @returns A promise that will return the result. */ get(url: string, configuration: AadHttpClientConfiguration, options?: IHttpClientOptions): Promise; /** * Calls fetch(), but sets the method to "GET". * * @param url - The endpoint URL that fetch will be called on. * @param configuration - Determines the default behavior of HttpClient; normally this should * be the latest version number from HttpClientConfigurations. * @param options - Additional options that affect the request. * @param cacheConfiguration - determines the configuration for cache management of this request. * @returns A promise containing a IClientCachableResponse, which contains a * Promise to the cached data response and a Promise to the server response. * * @internal */ get(url: string, configuration: AadHttpClientConfiguration, options: IHttpClientOptions | undefined, cacheConfiguration?: IRequestCacheOptions): Promise>; /** * Calls fetch(), but sets the method to "GET". * * @param url - The endpoint URL that fetch will be called on. * @param configuration - Determines the default behavior of HttpClient; normally this should * be the latest version number from HttpClientConfigurations. * @param options - Additional options that affect the request. * @param cacheConfiguration - determines the configuration for cache management of this request. * @returns A Promise to the cached data response or a Promise to the server response. * * @internal */ get(url: string, configuration: AadHttpClientConfiguration, options: IHttpClientOptions | undefined, cacheConfiguration?: IHttpRequestCacheOptions): Promise; /** * Calls fetch(), but sets the method to "POST". * * @param url - The endpoint URL that fetch will be called on. * @param configuration - Determines the default behavior of HttpClient; normally this should * be the latest version number from HttpClientConfigurations. * @param options - Additional options that affect the request. * @returns A promise that will return the result. */ post(url: string, configuration: AadHttpClientConfiguration, options: IHttpClientOptions): Promise; /** * Gets the cache data provider */ private get _cacheDataProvider(); private _fetch; private _getTokenFetchPromise; private _getFetchCorePromise; } /** * Interface for overriding the default behavior of AadHttpClient. * * @public */ export interface IAadHttpClientOptions { /** * @deprecated - AadHttpClient does not support a custom tokenProvider. */ tokenProvider?: IAadTokenProvider; /** * @deprecated - AadHttpClient's configuration cannot be altered */ configuration?: IAadTokenProviderConfiguration; /** * Allows the developer to specify if cached tokens should be use for the current request. * @beta */ useCachedToken?: boolean; } //# sourceMappingURL=AadHttpClient.d.ts.map