/** * Base communication layer for the SharePoint Framework * * @remarks * This package defines the base communication layer for * the SharePoint Framework. For REST calls, it handles authentication, * logging, diagnostics, and batching. It also simplifies requests by * adding default headers that follow the recommended best practices. * * @packagedocumentation */ import { Guid } from '@microsoft/sp-core-library'; import type { IDisposable } from '@microsoft/sp-core-library'; import type { IOAuthToken } from '@msinternal/sp-client-shared'; import type { IOAuthUtilityInteractionHandlerInfo } from '@msinternal/sp-client-shared'; import type { OAuthTokenType } from '@msinternal/sp-client-shared'; import { ServiceKey } from '@microsoft/sp-core-library'; import { ServiceScope } from '@microsoft/sp-core-library'; import { SPEvent } from '@microsoft/sp-core-library'; import { SPEventArgs } from '@microsoft/sp-core-library'; /* Excluded from this release type: _AadConstants */ /** * 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 declare class AadHttpClient { /** * The standard predefined AadHttpClientConfiguration objects for use with * the AadHttpClient class. */ static readonly configurations: IAadHttpClientConfigurations; private static readonly _className; /* Excluded from this release type: _aadTokenProvider */ 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; /* Excluded from this release type: fetch */ /* Excluded from this release type: fetch */ /** * 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; /* Excluded from this release type: get */ /* Excluded from this release type: get */ /** * 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; } /** * Configuration for HttpClient. * * @remarks * The HttpClientConfiguration object provides a set of switches for enabling/disabling * various features of the HttpClient class. Normally these switches are set * (e.g. when calling HttpClient.fetch()) by providing one of the predefined defaults * from HttpClientConfigurations, however switches can also be changed via the * HttpClientConfiguration.overrideWith() method. * * @public */ export declare class AadHttpClientConfiguration extends HttpClientConfiguration implements IAadHttpClientConfiguration { protected flags: IAadHttpClientConfiguration; /** * Constructs a new instance of HttpClientConfiguration with the specified flags. * The default values will be used for any flags that are missing or undefined. * If overrideFlags is specified, it takes precedence over flags. */ constructor(flags: IAadHttpClientConfiguration, overrideFlags?: IAadHttpClientConfiguration); /** * @override */ overrideWith(sourceFlags: IAadHttpClientConfiguration): AadHttpClientConfiguration; } /** * Returns a preinitialized version of the AadHttpClient for a given resource url. * For more information: {@link https://docs.microsoft.com/en-us/sharepoint/dev/spfx/use-aadhttpclient} * * @public */ export declare class AadHttpClientFactory { /** * The service key for AadHttpClientFactory. */ static readonly serviceKey: ServiceKey; private _serviceScope; /* Excluded from this release type: __constructor */ /** * Returns an instance of the AadHttpClient that communicates with the current tenant's configurable * Service Principal. * @param resourceEndpoint - The target AAD application's resource endpoint. */ getClient(resourceEndpoint: string): Promise; /* Excluded from this release type: _getStandardClient */ } /** * The Response subclass returned by methods such as `AadHttpClient.fetch()`. * Class that extends HttpClientResponse adding additional functionality specific * to the AadHttpClient. * @public */ export declare class AadHttpClientResponse extends HttpClientResponse { /* Excluded from this release type: _tokenFetchRequestTime */ constructor(response: Response, tokenFetchRequestTime: number); } /** * This class allows a developer to obtain OAuth2 tokens from Azure AD. * * OAuth2 tokens are used to authenticate the user from the SharePoint page * to other services such as PowerBI, Sway, Exchange, Yammer, etc. * * @privateRemarks * AadTokenProvider is replacing the /_api.SP.OAuth.Token/Acquire endpoint * for authentication with ADAL.js. At some point in the near future, when Azure AD v2.0 * can support the same scenarios as the original version, we will switch to MSAL. * * @public * @sealed */ export declare class AadTokenProvider { /* Excluded from this release type: _tokenAcquisitionEventId */ /* Excluded from this release type: _onBeforeRedirectEventId */ /* Excluded from this release type: _popupEventId */ /** * Notifies the developer before a full page redirect occurs. * * **⚠️ STRONGLY DISCOURAGED**: Using this event is strongly discouraged due to race condition issues. * When multiple callers use the same provider instance (recommended pattern), event handlers from * one token fetch may inadvertently respond to token fetches from different callers, causing * unpredictable behavior. This event is maintained only for backward compatibility with existing * 3rd party code. * * @eventproperty */ readonly onBeforeRedirectEvent: SPEvent; /** * Notifies the developer if the logic flow would like to request a popup flow for user interaction. * * **⚠️ STRONGLY DISCOURAGED**: Using this event is strongly discouraged due to race condition issues. * When multiple callers use the same provider instance (recommended pattern), event handlers from * one token fetch may inadvertently respond to token fetches from different callers, causing * unpredictable behavior. This event is maintained only for backward compatibility with existing * 3rd party code. * * @eventproperty */ readonly popupEvent: SPEvent; /* Excluded from this release type: _oboFirstPartyTokenCallback */ /* Excluded from this release type: _oboThirdPartyTokenCallback */ private readonly _logSource; private _tokenAcquisitionEvent; private _aadTokenProvider; private _aadConfiguration; private _oboConfiguration; private static _getLastEnsureStateRedirectTime; private static _setLastEnsureStateRedirectTime; private static _isUsingLocalStorage; /* Excluded from this release type: __constructor */ /** * Fetches an OAuth2 access token for the specified resource endpoint. * * **Authentication Flow**: * This method automatically handles the authentication flow based on tenant configuration and host environment: * 1. **Silent Token Acquisition** - Always attempts to get token silently using cached credentials or SSO * 2. **NAA (Nested App Authentication)** - If in Teams/Outlook and silent fails: * - Uses host application's native broker for seamless authentication * - **Does NOT raise {@link PopupEventArgs} or {@link BeforeRedirectEventArgs}** (bypasses event system) * - Shows native account picker UI (not browser popup) * - Cannot be cancelled or controlled via event handlers * 3. **Popup Authentication** (Optional, tenant-configurable) - If NAA unavailable, popup enabled, and silent fails: * - Raises {@link PopupEventArgs} event before opening popup * - Requires tenant admin to enable via: `Set-SPOTenant -IsEnableAppAuthPopupEnabled $true` * - Property mapping: `IsEnableAppAuthPopupEnabled` → `SpfxIsAcquireTokenPopupEnabled` → `isMsalTokenProviderPopupEnabled` * - If disabled (default), skips directly to redirect * 4. **Redirect Authentication** - If popup disabled/unavailable/cancelled, raises {@link BeforeRedirectEventArgs} event * * **Default Flow** (browser): Silent → Redirect * **With Popup Enabled** (browser): Silent → Popup → Redirect * **In Teams/Outlook** (NAA): Silent → Native Broker (no events) * * **Token Caching**: * Tokens are automatically cached by the provider. Do NOT cache tokens returned by this method - * the provider manages caching, expiration, and refresh automatically. * * **State Management**: * On first call, automatically calls `_ensureState()` to establish authentication state with Azure AD. * This may trigger a redirect if the user has never authenticated. To control this timing, applications * can explicitly call `_ensureState()` during initialization. * * **Event Handling**: * Subscribe to events to customize authentication UX: * - {@link AadTokenProvider.popupEvent} - Control popup timing, show loading UI, or prevent popups (only raised if popup enabled) * - {@link AadTokenProvider.onBeforeRedirectEvent} - Save application state before redirect or cancel automatic redirects * * **NAA (Nested App Authentication) Limitation**: * When running in Teams, Outlook, or mobile webviews with NAA support: * - **Events are NOT raised** - {@link AadTokenProvider.popupEvent} and {@link AadTokenProvider.onBeforeRedirectEvent} will not fire * - **Cannot cancel authentication** - No way to prevent native account picker from showing * - **No application control** - Host application manages authentication UI entirely * - **Seamless experience** - Users see native account picker instead of browser popup * - **Error handling only** - Can only catch errors when NAA fails (e.g., user cancels) * - To avoid authentication UI, ensure tokens are valid (silent auth succeeds) * * **Common Error Scenarios**: * - **User cancelled** - User closed popup or cancelled authentication * - **Access denied** - User or admin denied consent for the requested resource * - **Network errors** - Transient network failures (automatically retried once) * - **Interaction required** - Cached credentials expired, user must re-authenticate * * @param resourceEndpoint - The resource URL for which to obtain a token (e.g., `https://graph.microsoft.com`) * @param options - Optional configuration: `{ useCachedToken?, authenticationScheme?, claims? }` * - `useCachedToken`: If false, forces refresh even if valid cached token exists (default: true) * - `authenticationScheme`: Token type - BEARER (default) or POP (Proof of Possession) * - `claims`: CAP (Conditional Access Policy) claims for advanced scenarios * @returns Promise resolving to the access token string * * @example * ```typescript * // Basic token acquisition * const token = await aadTokenProvider.getToken('https://graph.microsoft.com'); * * // Use token with Microsoft Graph * const response = await fetch('https://graph.microsoft.com/v1.0/me', { * headers: { 'Authorization': `Bearer ${token}` } * }); * ``` * * @example * ```typescript * // Handle popup events to show custom UI * aadTokenProvider.popupEvent.add(observer, (args) => { * showLoadingSpinner('Authenticating...'); * args.requestPopup(); * setTimeout(() => args.showPopup(), 100); * }); * * const token = await aadTokenProvider.getToken('https://graph.microsoft.com'); * ``` * * @example * ```typescript * // Prevent popups and handle errors manually * aadTokenProvider.popupEvent.add(observer, (args) => { * args.cancel(new Error('Popups not allowed in this context')); * }); * * try { * const token = await aadTokenProvider.getToken('https://graph.microsoft.com'); * } catch (error) { * // Handle authentication failure - may need to show custom UI * if (error.message.includes('Popups not allowed')) { * showAuthenticationRequiredBanner(); * } * } * ``` * * @example * ```typescript * // Force token refresh * const freshToken = await aadTokenProvider.getToken('https://graph.microsoft.com', { * useCachedToken: false * }); * ``` * * @example * ```typescript * // Handle NAA (Teams/Outlook) - events won't fire, can only handle errors * try { * const token = await aadTokenProvider.getToken('https://graph.microsoft.com'); * // NAA authentication succeeded (or silent auth succeeded) * } catch (error) { * if (error.errorCode === 'user_cancelled') { * // User cancelled NAA native account picker * showMessage('Please sign in to continue'); * } * // Note: Cannot prevent NAA from showing - must handle failure * } * ``` */ getToken(resourceEndpoint: string, options?: IGetTokenOptions): Promise; getToken(resourceEndpoint: string, useCachedToken?: boolean): Promise; /* Excluded from this release type: _setSupportsNestedAppAuth */ /* Excluded from this release type: _ensureState */ /* Excluded from this release type: _getTokenInternal */ /* Excluded from this release type: _getTokenInternal */ /* Excluded from this release type: _getTokenData */ /* Excluded from this release type: _getTokenData */ /** * Notifies the developer when Token Acquisition requires user action. * * **⚠️ STRONGLY DISCOURAGED**: Using this event is strongly discouraged due to race condition issues. * When multiple callers use the same provider instance (recommended pattern), event handlers from * one token fetch may inadvertently respond to token fetches from different callers, causing * unpredictable behavior. This event is maintained only for backward compatibility with existing * 3rd party code. * * @eventproperty */ get tokenAcquisitionEvent(): SPEvent; /* Excluded from this release type: _ensureTelemetry */ private _getAadTokenProvider; } /** * Returns a preinitialized version of the AadTokenProviderFactory. * @public */ export declare class AadTokenProviderFactory { /** * The service key for AadTokenProviderFactory. */ static readonly serviceKey: ServiceKey; private _tokenProvider; /** * Returns an instance of the AadTokenProvider that communicates with the current tenant's configurable * Service Principal. */ getTokenProvider(): Promise; /* Excluded from this release type: _getPreAuthorizedTokenProvider */ } /* Excluded from this release type: _AadTokenProviders */ /** * Arguments for a full page redirect event if interaction is required during the login flow. * * @public */ export declare class BeforeFullPageRedirectEventArgs { /** * The url of the page to redirect to if automatic redirect is cancelled and you want the entire window redirected */ redirectUrl: string; /** * Call this method if the redirect should be cancelled because it is being handled by code in the cancelling class. */ cancel: () => void; constructor(redirectUrl: string, cancel: () => void); } /** * Event arguments raised before performing a full-page redirect for authentication. * * **When raised**: Before initiating a full-page redirect to Azure AD for authentication when: * - Silent token acquisition fails and interaction is required * - Popup authentication is disabled via tenant configuration (default behavior) * - Popup authentication is unavailable (iframe, browser blocks) or fails * - The authentication flow needs to fall back to redirect flow * - `_ensureState()` determines a redirect is needed to establish authentication state * * **Note**: If popup authentication is not enabled by the tenant, this event is raised immediately * after silent authentication fails, without attempting popup first. * * **NAA (Nested App Authentication) Exception**: * This event is **NOT raised** when running in Teams, Outlook, or mobile webviews with NAA support. * NAA uses the host application's native broker and does not perform browser redirects. * * **Use cases**: * - Cancel the automatic redirect and handle authentication manually * - Show custom UI or save application state before navigation * - Implement custom redirect logic or error handling * - Prevent redirect in specific scenarios (e.g., iframe contexts, recent redirect attempts) * * **How to use**: Subscribe to `AadTokenProvider.onBeforeRedirectEvent` and call `cancel()` to prevent * the automatic redirect. The `redirectUrl` property contains the destination URL that would be navigated to. * * @example * ```typescript * aadTokenProvider.onBeforeRedirectEvent.add(observer, (args: BeforeRedirectEventArgs) => { * // Save application state before redirect * saveCurrentState(); * * // Or cancel and handle manually * args.cancel(); * window.location.href = args.redirectUrl; * }); * ``` * * @public */ export declare class BeforeRedirectEventArgs extends SPEventArgs implements IBeforeRedirectEventArgs { /** * The id of the instance generating the event. */ configuration?: IAadTokenProviderConfiguration; /** * The url of the page to redirect to if automatic redirect is cancelled */ redirectUrl: string; /** * Call this method if the redirect should be cancelled because it is being handled by code in the cancelling class. */ cancel: () => void; constructor(redirectUrl: string, cancel: () => void, configuration?: IAadTokenProviderConfiguration | undefined); } /* Excluded from this release type: _CacheDataProviderService */ /* Excluded from this release type: _CacheKeyType */ /* Excluded from this release type: _CacheManager */ /* Excluded from this release type: _CacheStrategy */ /* Excluded from this release type: _DeferredCookieRefresher */ /* Excluded from this release type: _DEPRECATED_DO_NOT_USE_OAuthTokenProvider */ /** * {@inheritDoc IDigestCache} * * @public */ export declare class DigestCache implements IDigestCache { /** * The service key for IDigestCache. */ static readonly serviceKey: ServiceKey; private static REST_EXPIRATION_SLOP_MS; private static _logSource; private _fetchProvider; private _timeProvider; private _digestsByUrl; constructor(serviceScope: ServiceScope); /** * {@inheritDoc IDigestCache.fetchDigest} */ fetchDigest(webUrl: string): Promise; /** * {@inheritDoc IDigestCache.addDigestToCache} */ addDigestToCache(webUrl: string, digestValue: string, expirationTimestamp: number): void; /** * {@inheritDoc IDigestCache.clearDigest} */ clearDigest(webUrl: string): boolean; /** * {@inheritDoc IDigestCache.clearAllDigests} */ clearAllDigests(): void; } /* Excluded from this release type: _fetchProviderServiceKey */ /* Excluded from this release type: _getCacheDataProviderServiceKey */ /* Excluded from this release type: _getPrefetchDataProviderServiceKey */ /* Excluded from this release type: _GraphHttpClientContext */ /** * HttpClient implements a basic set of features for performing REST operations against * a generic service. * * @remarks * For communicating with SharePoint, use the {@link SPHttpClient} class instead. * * @public */ export declare class HttpClient { /** * The standard predefined HttpClientConfiguration objects for use with * the HttpClient class. */ static readonly configurations: IHttpClientConfigurations; /** * The service key for HttpClient. * * @public */ static readonly serviceKey: ServiceKey; private static readonly _className; /* Excluded from this release type: _serviceScope */ private _fetchProvider; private _cacheProvider; /* Excluded from this release type: startTrackingWindow */ constructor(serviceScope: ServiceScope); /** * Performs a REST service call. * * @remarks * Although the SPHttpClient 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 URL to fetch * @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 with behavior similar to WHATWG fetch(). This promise will resolve normally * (with {@link HttpClientResponse.ok} being false) for error status codes such as HTTP 404 * or 500. The promise will only reject for network failures or other errors that prevent communication * with the server. * * @public */ fetch(url: string, configuration: HttpClientConfiguration, options: IHttpClientOptions): Promise; /* Excluded from this release type: fetch */ /* Excluded from this release type: fetch */ /** * Calls fetch(), but sets the method to "GET". * * @param url - the URL to fetch * @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 with behavior similar to WHATWG fetch(). This promise will resolve normally * (with {@link HttpClientResponse.ok} being false) for error status codes such as HTTP 404 * or 500. The promise will only reject for network failures or other errors that prevent communication * with the server. * * @public */ get(url: string, configuration: HttpClientConfiguration, options?: IHttpClientOptions): Promise; /* Excluded from this release type: get */ /* Excluded from this release type: get */ /** * Calls fetch(), but sets the method to "POST". * * @param url - the URL to fetch * @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 with behavior similar to WHATWG fetch(). This promise will resolve normally * (with {@link HttpClientResponse.ok} being false) for error status codes such as HTTP 404 * or 500. The promise will only reject for network failures or other errors that prevent communication * with the server. */ post(url: string, configuration: HttpClientConfiguration, options: IHttpClientOptions): Promise; private _fetch; /** * Gets the cache data provider */ private get _cacheDataProvider(); } /** * Configuration for HttpClient. * * @remarks * The HttpClientConfiguration object provides a set of switches for enabling/disabling * various features of the HttpClient class. Normally these switches are set * (e.g. when calling HttpClient.fetch()) by providing one of the predefined defaults * from HttpClientConfigurations, however switches can also be changed via the * HttpClientConfiguration.overrideWith() method. * * @public */ export declare class HttpClientConfiguration implements IHttpClientConfiguration { protected flags: IHttpClientConfiguration; /** * Constructs a new instance of HttpClientConfiguration with the specified flags. * The default values will be used for any flags that are missing or undefined. * If overrideFlags is specified, it takes precedence over flags. */ constructor(flags: IHttpClientConfiguration, overrideFlags?: IHttpClientConfiguration); /** * Child classes should override this method to construct the child class type, * rather than the base class type. * @virtual */ overrideWith(sourceFlags: IHttpClientConfiguration): HttpClientConfiguration; /** * Child classes should override this method to initialize the flags object. * @virtual */ protected initializeFlags(): void; } /* Excluded from this release type: _HttpClientHelper */ /** * The Response subclass returned by methods such as HttpClient.fetch(). * * @remarks * This is a placeholder. In the future, additional HttpClient-specific functionality * may be added to this class. * * @privateRemarks * This class exposes the same members as our typings for the browser's native * Response and Body classes, which is why we can say that it "implements" them. * It cannot actually inherit from Response because that class does not have a copy * constructor (because it would probably be inefficient to copy the response stream). * * @public */ export declare class HttpClientResponse implements Response, Body { protected nativeResponse: Response; /* Excluded from this release type: __constructor */ /* Excluded from this release type: body */ /** * See documentation for the browser's * {@link https://developer.mozilla.org/en-US/docs/Web/API/Body | Body} API */ get bodyUsed(): boolean; /** * See documentation for the browser's * {@link https://developer.mozilla.org/en-US/docs/Web/API/Body | Body} API */ arrayBuffer(): Promise; /** * See documentation for the browser's * {@link https://developer.mozilla.org/en-US/docs/Web/API/Body | Body} API */ blob(): Promise; /** * See documentation for the browser's * {@link https://developer.mozilla.org/en-US/docs/Web/API/Body | Body} API */ formData(): Promise; /** * See documentation for the browser's * {@link https://developer.mozilla.org/en-US/docs/Web/API/Body | Body} API */ json(): Promise; /** * See documentation for the browser's * {@link https://developer.mozilla.org/en-US/docs/Web/API/Body | Body} API */ text(): Promise; /** * See documentation for the browser's * {@link https://developer.mozilla.org/en-US/docs/Web/API/Response | Response} API */ get type(): ResponseType; /* Excluded from this release type: redirected */ /** * See documentation for the browser's * {@link https://developer.mozilla.org/en-US/docs/Web/API/Response | Response} API */ get url(): string; /** * See documentation for the browser's * {@link https://developer.mozilla.org/en-US/docs/Web/API/Response | Response} API */ get status(): number; /** * See documentation for the browser's * {@link https://developer.mozilla.org/en-US/docs/Web/API/Response | Response} API */ get ok(): boolean; /** * See documentation for the browser's * {@link https://developer.mozilla.org/en-US/docs/Web/API/Response | Response} API */ get statusText(): string; /* Excluded from this release type: trailer */ /** * See documentation for the browser's * {@link https://developer.mozilla.org/en-US/docs/Web/API/Response | Response} API */ get headers(): Headers; /** * @virtual */ clone(): HttpClientResponse; } /** * Flags interface for HttpClientConfiguration. * * @public */ export declare interface IAadHttpClientConfiguration extends IHttpClientConfiguration { } /** * Standard configurations for AadHttpClient. * * @remarks * This interface provides standard predefined AadHttpClientConfiguration objects for use with * the AadHttpClient class. In general, clients should choose the latest available * version number, which enables all the switches that are recommended for typical * scenarios. (If new switches are introduced in the future, a new version number * will be introduced, which ensures that existing code will continue to function the * way it did at the time when it was tested.) * * @public */ export declare interface IAadHttpClientConfigurations { /** * This configuration turns off every feature switch for AadHttpClient. The fetch() * behavior will be essentially identical to the WHATWG standard API that * is documented here: * https://fetch.spec.whatwg.org/ */ readonly v1: AadHttpClientConfiguration; } /** * Interface for overriding the default behavior of AadHttpClient. * * @public */ export declare 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; } /** * This class allows a developer to obtain OAuth2 tokens from Azure AD. * * OAuth2 tokens are used to authenticate the user from the SharePoint page * to other services such as PowerBI, Sway, Exchange, Yammer, etc. * * @remarks * AadTokenProvider is replacing the /_api.SP.OAuth.Token/Acquire endpoint * for authentication with ADAL.js. At some point in the near future, when Azure AD v2.0 * can support the same scenarios as the original version, we will switch to MSAL. * * @public */ export declare interface IAadTokenProvider { /** * Notifies the developer when Token Acquistion requires user action. * @eventproperty */ readonly tokenAcquisitionEvent: SPEvent; /** * Notifies the developer before a full page redirect occurs. * @eventproperty */ readonly onBeforeRedirectEvent: SPEvent; /** * Notifies the developer before a full page redirect occurs. * @eventproperty */ readonly popupEvent: SPEvent; /** * Fetches the AAD OAuth2 token for a resource if the user that's currently logged in has * access to that resource. * * The OAuth2 token SHOULD NOT be cached by the caller since it is already cached by the method * itself. * * An example of a resourceEndpoint would be https://sdfpilot.outlook.com * * @param resourceEndpoint - the resource for which the token should be obtained * @returns A promise that will be fulfilled with the token or that will reject * with an error message */ getToken(resourceEndpoint: string, options?: IGetTokenOptions): Promise; getToken(resourceEndpoint: string, useCachedToken?: boolean): Promise; } /** * Required strings for constructing an AadTokenProvider. * * @public */ export declare interface IAadTokenProviderConfiguration { /** * The sign in page used to authenticate with Azure Active Directory. Trailing slashes are forbidden. */ aadInstanceUrl: string; /** * The Azure Active Directory's tenant id. */ aadTenantId: string; /** * The current Azure Active Directory's session id. * @beta */ aadSessionId: string; /** * The page used to retrieve tokens from Azure Active Directory. This url must be listed in * the developer's application redirect uris. */ redirectUri: string; /** * The client ID of the developer's Azure Active Directory application. */ servicePrincipalId: string; /** * The user's Azure Active Directory id. This will be used to ensure that a valid cached token is for * the current user. */ aadUserId?: string; /* Excluded from this release type: spRequestGuid */ /** * The user's email address. This will be used to ensure that the current user's identity is used for * fetching auth tokens. * * @deprecated This parameter will be ignored. Use userPrincipalName instead */ userEmail?: string; /** * The user's principal name. This will be used to ensure that the current user's identity is used for * fetching auth tokens. This parameter will avoid the "Request is ambiguous: multiple user identities * are avaliable for the current request" error. */ userPrincipalName?: string; /** * Whether or not to enable an auth flow with support for claim challenges. */ enableClaimChallenges?: boolean; /* Excluded from this release type: enableMetaOS */ /* Excluded from this release type: isMsalTokenProviderPopupEnabled */ /* Excluded from this release type: thirdPartyReplyUrisUpdated */ /* Excluded from this release type: isAnonymousGuestUser */ /* Excluded from this release type: isEmailAuthenticationGuestUser */ /* Excluded from this release type: isNaaSupported */ /* Excluded from this release type: isPairwiseBrokerEnabled */ /* Excluded from this release type: eventNamespace */ /* Excluded from this release type: msGraphEndpointUrl */ } /* Excluded from this release type: _IAsyncPrefetchData */ /** * Options for Authentication Scheme * * @public */ export declare enum IAuthenticationScheme { BEARER = "Bearer", POP = "pop" } /** * Represents arguments used before redirecting event. * * @public */ export declare interface IBeforeRedirectEventArgs extends SPEventArgs { /** * The url of the page to redirect to if automatic redirect is cancelled */ redirectUrl: string; /** * Call this method if the redirect should be cancelled because it is being handled by code in the cancelling class. */ cancel: () => void; } /* Excluded from this release type: _ICacheData */ /* Excluded from this release type: _ICacheDataProvider */ /* Excluded from this release type: _ICacheDataStat */ /* Excluded from this release type: _ICacheKey */ /* Excluded from this release type: _IClientCachableResponse */ /** * IDigestCache is an internal service used by SPHttpClient to maintain a cache of request digests * for each SPWeb URL. A request digest is a security token that the SharePoint server requires for * for any REST write operation, specified via the "X-RequestDigest" HTTP header. It is obtained * by calling the "/_api/contextinfo" REST endpoint, and expires after a server configurable amount * of time. * * For more information, see the MSDN article * {@link https://msdn.microsoft.com/en-us/library/office/jj164022.aspx * | "Complete basic operations using SharePoint 2013 REST endpoints" } * * @public */ export declare interface IDigestCache { /** * Returns a digest string for the specified SPWeb URL. If the cache already contains a usable value, * the promise is fulfilled immediately. Otherwise, the promise will be pending and resolve after * an HTTP request obtains the digest, which will be added to the cache. * @param webUrl - The URL of the SPWeb that the API call will be issued to. * This may be a server-relative or absolute URL. * @returns A promise that is fulfilled with the digest value. */ fetchDigest(webUrl: string): Promise; /** * Inserts a specific request digest value into the cache. Normally this is unnecessary because * the framework will automatically issue a REST request to fetch the digest when necessary; * however, in advanced scenarios addDigestToCache() can be used to avoid the overhead of the * REST call. * * @param webUrl - The URL of the SPWeb that the API call will be issued to. * This may be a server-relative or absolute URL. * @param digestValue - The digest value, which is an opaque that must be generated by the SharePoint server. * The syntax will look something like this: "0x0B85...2EAC,29 Jan 2016 01:23:45 -0000" * @param expirationTimestamp - A future point in time, as measured by performance.now(), * after which the digest value will no longer be valid. * NOTE: The expirationTime is a DOMHighResTimeStamp value whose units are * fractional milliseconds; for example, to specify an expiration * "5 seconds from right now", use performance.now()+5000. */ addDigestToCache(webUrl: string, digestValue: string, expirationTimestamp: number): void; /** * Clears the cached digest for the specified SPWeb URL. This operation is useful * e.g. if an error indicates that a digest was invalidated prior to its expiration time. * * @param webUrl - The URL of the SPWeb whose digest should be cleared. This may be * a server-relative or absolute URL. * @returns Returns true if a cache entry was found and deleted; false otherwise. */ clearDigest(webUrl: string): boolean; /** * Clears all values from the cache. */ clearAllDigests(): void; } /* Excluded from this release type: IFetchProvider */ /** * @public */ export declare interface IGetTokenDataOptions { useCachedToken: boolean; skipLoggingAndDisableRedirects: boolean; claims: string | undefined; authenticationScheme?: IAuthenticationScheme; resourceRequestMethod?: string; shrClaims?: string; scopes?: string[]; callersQosName?: string; } /* Excluded from this release type: _IGetTokenDataOptions_ITokenProvider */ /** * @public */ export declare interface IGetTokenOptions { useCachedToken?: boolean; claims?: string; /* Excluded from this release type: scopes */ /** * Indicates whether acquire a Bearer or PoP * By default authenticationScheme is Bearer. */ authenticationScheme?: IAuthenticationScheme; /** * The all-caps name of the HTTP method of the request */ resourceRequestMethod?: string; /** * A stringified JSON object containing custom client claims */ shrClaims?: string; /* Excluded from this release type: callersQosName */ /* Excluded from this release type: cancelRedirect */ } /* Excluded from this release type: _IGetTokenOptions_ITokenProvider */ /** * Flags interface for HttpClientConfiguration. * * @public */ export declare interface IHttpClientConfiguration { } /** * Standard configurations for HttpClient. * * @remarks * This interface provides standard predefined HttpClientConfiguration objects for use with * the HttpClient class. In general, clients should choose the latest available * version number, which enables all the switches that are recommended for typical * scenarios. (If new switches are introduced in the future, a new version number * will be introduced, which ensures that existing code will continue to function the * way it did at the time when it was tested.) * * @public */ export declare interface IHttpClientConfigurations { /** * This configuration turns off every feature switch for HttpClient. The fetch() * behavior will be essentially identical to the WHATWG standard API that * is documented here: * https://fetch.spec.whatwg.org/ */ readonly v1: HttpClientConfiguration; } /** * Options for HttpClient * * @remarks * This interface defines the options for the HttpClient operations such as * get(), post(), fetch(), etc. It is based on the whatwg API standard * parameters that are documented here: * https://fetch.spec.whatwg.org/ * * @public */ export declare interface IHttpClientOptions extends RequestInit { /* Excluded from this release type: _authenticationScheme */ /* Excluded from this release type: _resourceRequestMethod */ /* Excluded from this release type: _shrClaims */ } /* Excluded from this release type: _IHttpRequestCacheOptions */ /* Excluded from this release type: _IInternalAadTokenProvider */ /* Excluded from this release type: _InternalAadTokenProvider */ /* Excluded from this release type: IOAuthToken */ /* Excluded from this release type: IOAuthUtilityInteractionHandlerInfo */ /** * Represents arguments used before popup event. * * @public */ export declare interface IPopupEventArgs extends SPEventArgs { /** * A handler should call this immediately when handling the event to signal that * it will not permit a popup. */ cancel: (error?: Error) => void; /** * A handler should call this immediately when handling the event to signal that * it intends to show a popup. */ requestPopup: () => void; /** * A handler should call this when ready, to indicate that the login flow should * now continue and launch the popup. */ showPopup: () => Promise | void; /** * The resource being requested. */ resource: string; /** * The options used for the call which is triggering the popup. */ options: IGetTokenDataOptions; } /* Excluded from this release type: _IPrefetchData */ /* Excluded from this release type: _IPrefetchDataProvider */ /* Excluded from this release type: _IPrefetchOptions */ /* Excluded from this release type: _IPrefetchUpdateOptions */ /* Excluded from this release type: _IRequestCacheOptions */ /* Excluded from this release type: _ISPCookieRefresher */ /** * Flags interface for SPHttpClientBatchConfiguration. * * @beta */ export declare interface ISPHttpClientBatchConfiguration extends ISPHttpClientCommonConfiguration { } /** * Standard configurations for SPHttpClient. * * @remarks * This interface provides standard predefined SPHttpClientBatchConfiguration objects for use with * the SPHttpClientBatch class. In general, clients should choose the latest available * version number, which enables all the switches that are recommended for typical * scenarios. (If new switches are introduced in the future, a new version number * will be introduced, which ensures that existing code will continue to function the * way it did at the time when it was tested.) * * @beta */ export declare interface ISPHttpClientBatchConfigurations { /** * Version 1 enables these switches: * consoleLogging = true; * jsonRequest = true; * jsonResponse = true */ readonly v1: SPHttpClientBatchConfiguration; } /** * This interface is passed to the SPHttpClientBatch constructor. It specifies options * that affect the entire batch. * * @beta */ export declare interface ISPHttpClientBatchCreationOptions { /** * SPHttpClientBatch will need to perform its POST to an endpoint such as * "http://example.com/sites/sample/_api/$batch". Typically the SPWeb URL * ("https://example.com/sites/sample" in this example) can be guessed by * looking for a reserved URL segment such as "_api" in the first URL * passed to fetch(), but if not, the webUrl can be explicitly specified * using this option. */ webUrl?: string; } /** * This interface defines the options for an individual REST request that * is part of an SPHttpClientBatch. It is based on the WHATWG API standard * parameters that are documented here: * https://fetch.spec.whatwg.org/ * * @beta */ export declare interface ISPHttpClientBatchOptions extends IHttpClientOptions { } /** * Flags interface for SPHttpClientCommonConfiguration * * @public */ export declare interface ISPHttpClientCommonConfiguration extends IHttpClientConfiguration { /** * Automatically configure the "Content-Type" header for a JSON payload. * * @remarks * When this switch is true: * * If the "Content-Type" header was not explicitly added for the request, * then SPHttpClient will add it if the request is a write operation (i.e. * an HTTP method other than "GET", "HEAD", or "OPTIONS"). * * For OData 3.0, the value is 'application/json;odata=verbose;charset=utf-8'. * * For OData 4.0, the value is 'application/json;charset=utf-8'. */ jsonRequest?: boolean; /** * Automatically configure the "Accept" header for a JSON payload. * * @remarks * When this switch is true: * * If the "Accept" header was not explicitly added for the request, * then SPHttpClient will add it. * * For OData 3.0, the value is 'application/json'. * * For OData 4.0, the value is 'application/json;odata.metadata=minimal'. */ jsonResponse?: boolean; /** * Handle cookie refresh with a popup dialog * * @remarks * When this switch is true popup auth will be used for handling a cookie refresh. * This means the caller must handle the popup events. If it is undefined or false * full page redirect will be defaulted to. */ usePopupForCookieRefresh?: boolean; } /** * Flags interface for SPHttpClientConfiguration. * * @public */ export declare interface ISPHttpClientConfiguration extends ISPHttpClientCommonConfiguration { /** * Automatically configure the RequestInit.credentials. * * @remarks * When this switch is true: * * If RequestInit.credentials is not explicitly specified for the request, * then SPHttpClient will assign it to be "same-origin". Without this switch, * different web browsers may apply different defaults. * * For more information, see the spec: * https://fetch.spec.whatwg.org/#cors-protocol-and-credentials */ defaultSameOriginCredentials?: boolean; /** * Automatically configure the "OData-Version" header. * * @remarks * When this switch is specified (i.e. not undefined): * If the "OData-Version" header was not explicitly added for the request, * then SPHttpClient will add the header to specify the version indicated * by defaultODataVersion. * * NOTE: Without an 'OData-Version' header, the SharePoint server currently * defaults to Version 3.0 in most cases. The recommended version is 4.0. */ defaultODataVersion?: ODataVersion; /** * Automatically provide an "X-RequestDigest" header for authentication. * * @remarks * When this switch is true: * * If the "X-RequestDigest" header was not explicitly added for the request, * then SPHttpClient will add it if the request is a write operation (i.e. * an HTTP method other than "GET", "HEAD", or "OPTIONS"). The request digest * is managed by the DigestCache service. In the case of a cache miss, an * additional network request may be performed. */ requestDigest?: boolean; /** * Handle cookie refresh with a popup dialog * * @remarks * When this switch is true popup auth will be used for handling a cookie refresh. * This means the caller must handle the popup events. If it is undefined or false * full page redirect will be defaulted to. */ usePopupForCookieRefresh?: boolean; } /** * Standard configurations for SPHttpClient. * * @remarks * This interface provides standard predefined SPHttpClientConfiguration objects for use with * the SPHttpClient class. In general, clients should choose the latest available * version number, which enables all the switches that are recommended for typical * scenarios. (If new switches are introduced in the future, a new version number * will be introduced, which ensures that existing code will continue to function the * way it did at the time when it was tested.) * * @public */ export declare interface ISPHttpClientConfigurations { /** * Version 1 enables these switches: * * consoleLogging = true; * jsonRequest = true; * jsonResponse = true; * defaultSameOriginCredentials = true; * defaultODataVersion = ODataVersion.v4; * requestDigest = true */ readonly v1: SPHttpClientConfiguration; } /** * This interface defines the options for the SPHttpClient operations such as * get(), post(), fetch(), etc. It is based on the WHATWG API standard * parameters that are documented here: * https://fetch.spec.whatwg.org/ * * @public */ export declare interface ISPHttpClientOptions extends IHttpClientOptions { /** * Configure the SPWeb URL for authentication. * * @remarks * For a write operation, SPHttpClient will automatically add the * "X-RequestDigest" header, which may need to be fetched using a seperate * request such as "https://example.com/sites/sample/_api/contextinfo". * Typically the SPWeb URL ("https://example.com/sites/sample" in this * example) can be guessed by looking for a reserved URL segment such * as "_api" in the original REST query, however certain REST endpoints * do not contain a reserved URL segment; in this case, the webUrl can * be explicitly specified using this option. */ webUrl?: string; } /* Excluded from this release type: _ISPOBOFlowParameters */ /** * Represents arguments used for raising a token acquisiton failure event. * * @public */ export declare interface ITokenAcquisitionEventArgs extends SPEventArgs { /** * The message returned from ADAL fails to retrieve a token from Azure AD. */ message: string; /** * The url of the page for the end user to interact with Azure AD. */ redirectUrl?: string; } /* Excluded from this release type: _ITokenData */ /* Excluded from this release type: _ITokenProvider */ /* Excluded from this release type: OAuthTokenType */ /* Excluded from this release type: _OBO3PTokenFunction */ /* Excluded from this release type: _OBOTokenFunction */ /** * Represents supported version of the "OData-Version" header, which is part * of the Open Data Protocol standard. * * @public */ export declare class ODataVersion { /** * Represents version 3.0 for the "OData-Version" header */ static v3: ODataVersion; /** * Represents version 4.0 for the "OData-Version" header */ static v4: ODataVersion; private _versionString; /** * Attempt to parse the "OData-Version" header. * * @remarks * If the "OData-Version" header is present, this returns the * corresponding ODataVersion constant. An error is thrown if * the version number is not supported. If the header is missing, * then undefined is returned. */ static tryParseFromHeaders(headers: Headers): ODataVersion | undefined; /** * Returns the "OData-Version" value, for example "4.0". */ toString(): string; private constructor(); } /** * Event arguments raised when attempting popup-based authentication. * * **When Popup Authentication is Enabled**: * This event is raised when popup authentication is enabled, which can be controlled by: * - **Tenant configuration**: `Set-SPOTenant -IsEnableAppAuthPopupEnabled $true` (sp-client areas) * - Property chain: `IsEnableAppAuthPopupEnabled` → `SpfxIsAcquireTokenPopupEnabled` → `IsMsalTokenProviderPopupEnabled` → `isMsalTokenProviderPopupEnabled` * - **Caller/app context**: Application code setting popup preference based on codepath (odsp-next areas) * Without popup enabled (default), authentication skips popup and goes directly to redirect. * * **NAA (Nested App Authentication) Exception**: * This event is **NOT raised** when running in Teams, Outlook, or mobile webviews with NAA support. * NAA uses the host application's native broker and bypasses the event system entirely. * * **When raised**: Before opening an authentication popup when: * - Popup is enabled (via tenant configuration or app context, see above) * - Silent token acquisition fails with interaction_required error * - The token provider needs user consent or authentication * - PoP (Proof of Possession) nonce fetching fails and requires interaction * - CAP (Conditional Access Policy) errors require user interaction * - The authentication flow falls back to popup before trying redirect * * **Use cases**: * - Show custom loading UI or messages while popup is opening * - Prevent popups in specific contexts (e.g., mobile devices, iframe environments) * - Coordinate with application-level popup blockers or modal managers * - Implement custom popup timing or debouncing logic * - Handle popup failures and provide fallback behavior * * **How to use**: * - Call `cancel(error?)` immediately to prevent the popup and optionally provide an error * - Call `requestPopup()` to signal intent to show the popup (reserves popup "slot") * - Call `showPopup()` when ready to actually launch the popup window * - If multiple handlers call `requestPopup()`, only the first wins (popup debouncing) * * **Popup flow**: * 1. Event raised before popup attempt * 2. Handler calls `requestPopup()` to signal intent (or `cancel()` to prevent) * 3. Handler performs any necessary UI updates or validation * 4. Handler calls `showPopup()` when ready to launch the popup * 5. Popup opens and authentication proceeds * * @example * ```typescript * aadTokenProvider.popupEvent.add(observer, (args: PopupEventArgs) => { * // Show custom loading UI * showLoadingIndicator(); * * // Signal intent to show popup * args.requestPopup(); * * // Launch popup after UI updates * setTimeout(() => { * hideLoadingIndicator(); * args.showPopup(); * }, 100); * }); * ``` * * @example * ```typescript * // Cancel popup in mobile environments * aadTokenProvider.popupEvent.add(observer, (args: PopupEventArgs) => { * if (isMobileDevice()) { * args.cancel(new Error('Popups not supported on mobile')); * } * }); * ``` * * @public */ export declare class PopupEventArgs extends SPEventArgs implements IPopupEventArgs { /** * A handler should call this immediately when handling the event to signal that * it will not permit a popup. */ cancel: (error?: Error) => void; /** * A handler should call this immediately when handling the event to signal that * it intends to show a popup. */ requestPopup: () => void; /** * A handler should call this when ready, to indicate that the login flow should * now continue and launch the popup. */ showPopup: () => Promise | void; resource: string; options: IGetTokenDataOptions; constructor(cancel: (error?: Error) => void, requestPopup: () => void, showPopup: () => Promise | void, resource: string, options: IGetTokenDataOptions); } /** * Arguments for a popup event if interaction is required during the login flow. * * @public */ export declare class PopupRequestEventArgs { /** * A handler should call this from user interaction to ensure the browser does not * block the popup window */ showPopup: () => void; constructor(showPopup: () => void); } /* Excluded from this release type: _PrefetchDataProviderService */ /** * SPHttpClient is used to perform REST calls against SharePoint. It adds default * headers, manages the digest needed for writes, and collects telemetry that * helps the service to monitor the performance of an application. * * @remarks * For communicating with other internet services, use the {@link HttpClient} class. * * @public * @sealed */ export declare class SPHttpClient { /** * The standard predefined SPHttpClientConfiguration objects for use with * the SPHttpClient class. */ static readonly configurations: ISPHttpClientConfigurations; /** * The service key for SPHttpClient. */ static readonly serviceKey: ServiceKey; private static _logSource; private static _onBeforeRedirectEventId; private static _onPopupRequestedEventId; readonly onBeforeRedirectEvent: SPEvent; readonly onPopupRequestedEvent: SPEvent; private _digestCache; private _parentSource; private _serviceScope; private _fetchProvider; private _cacheProvider; private _isNavigate; private _prefetchProvider; private _cookieRefresher; /** * Use a heuristic to infer the base URL for authentication. * * @remarks * Attempts to infer the SPWeb URL associated with the provided REST URL, by looking * for common SharePoint path components such as "_api", "_layouts", or "_vit_bin". * This is necessary for operations such as the X-RequestDigest * and ODATA batching, which require POSTing to a separate REST endpoint * in order to complete a request. * * For example, if the requestUrl is "/sites/site/web/_api/service", * the returned URL would be "/sites/site/web". Or if the requestUrl * is "http://example.com/_layouts/service", the returned URL would be * "http://example.com". * * If the URL cannot be determined, an exception is thrown. * * @param requestUrl - The URL for a SharePoint REST service * @returns the inferred SPWeb URL */ static getWebUrlFromRequestUrl(requestUrl: string): string; constructor(serviceScope: ServiceScope); get isNavigate(): boolean; set isNavigate(isNavigate: boolean); /** * Perform a REST service call. * * @remarks * Generally, the parameters and semantics for SPHttpClient.fetch() are essentially * the same as the WHATWG API standard that is documented here: * https://fetch.spec.whatwg.org/ * * The SPHttpClient subclass adds some additional behaviors that are convenient when * working with SharePoint ODATA API's (which can be avoided by using * HttpClient instead): * * - Default "Accept" and "Content-Type" headers are added if not explicitly specified. * * - For write operations, an "X-RequestDigest" header is automatically added * * - The request digest token is automatically fetched and stored in a cache, with * support for preloading * * For a write operation, SPHttpClient will automatically add the "X-RequestDigest" * header, which may need to be obtained by issuing a separate request such as * "https://example.com/sites/sample/_api/contextinfo". Typically the appropriate * SPWeb URL can be guessed by looking for a reserved URL segment such as "_api" * in the original URL passed to fetch(); if not, use ISPHttpClientOptions.webUrl * to specify it explicitly. * * @param url - the URL to fetch * @param configuration - determines the default behavior of SPHttpClient; normally this should * be the latest version number from SPHttpClientConfigurations * @param options - additional options that affect the request * @returns A promise with behavior similar to WHATWG fetch(). This promise will resolve normally * (with {@link HttpClientResponse.ok} being false) for error status codes such as HTTP 404 * or 500. The promise will only reject for network failures or other errors that prevent communication * with the server. * * @public */ fetch(url: string, configuration: SPHttpClientConfiguration, options: ISPHttpClientOptions): Promise; /* Excluded from this release type: fetch */ /* Excluded from this release type: fetch */ /** * Calls fetch(), but sets the method to "GET". * * @param url - the URL to fetch * @param configuration - determines the default behavior of SPHttpClient; normally this should * be the latest version number from SPHttpClientConfigurations * @param options - additional options that affect the request * @returns A promise with behavior similar to WHATWG fetch(). This promise will resolve normally * (with {@link HttpClientResponse.ok} being false) for error status codes such as HTTP 404 * or 500. The promise will only reject for network failures or other errors that prevent communication * with the server. * * @public */ get(url: string, configuration: SPHttpClientConfiguration, options?: ISPHttpClientOptions): Promise; /* Excluded from this release type: get */ /* Excluded from this release type: get */ /** * Calls fetch(), but sets the method to "POST". * * @param url - the URL to fetch * @param configuration - determines the default behavior of SPHttpClient; normally this should * be the latest version number from SPHttpClientConfigurations * @param options - additional options that affect the request * @returns A promise with behavior similar to WHATWG fetch(). This promise will resolve normally * (with {@link HttpClientResponse.ok} being false) for error status codes such as HTTP 404 * or 500. The promise will only reject for network failures or other errors that prevent communication * with the server. */ post(url: string, configuration: SPHttpClientConfiguration, options: ISPHttpClientOptions): Promise; /** * Begins an ODATA batch, which allows multiple REST queries to be bundled into * a single web request. * * @returns An {@link SPHttpClientBatch} object used to manage the batch operation. * * @beta */ beginBatch(batchCreationOptions?: ISPHttpClientBatchCreationOptions): SPHttpClientBatch; protected _fetch(url: string, configuration: SPHttpClientConfiguration, options: ISPHttpClientOptions): Promise; /** * Gets the cache data provider */ private get _cacheDataProvider(); private get _logSourceId(); /** * Gets the prefetch data provider */ private get _prefetchDataProvider(); } /** * The SPHttpClientBatch class accumulates a number of REST service calls and * transmits them as a single ODATA batch. This protocol is documented here: * http://docs.oasis-open.org/odata/odata/v4.0/odata-v4.0-part1-protocol.html * * The usage is to call SPHttpClientBatch.fetch() to queue each individual request, * and then call SPHttpClientBatch.execute() to execute the batch operation. * The execute() method returns a promise that resolves when the real REST * call has completed. Each call to fetch() also returns a promise that will * resolve with an SPHttpClientResponse object for that particular request. * * @privateRemarks * The type signature of SPHttpClientBatch class suggests that it should inherit from * the HttpClient base class. However, the operational semantics are different * (e.g. nothing happens until execute() is called; further operations are * prohibited afterwards; fetch() calls cannot depend on each other). In the * future we might introduce a base class for batches, but it would be separate * from the HttpClient hierarchy. By contrast, the ISPHttpClientBatchOptions * does naturally inherit from IHttpClientOptions. * * @beta */ export declare class SPHttpClientBatch { /** * The standard predefined SPHttpClientBatchConfigurations objects for use with * the SPHttpClientBatch class. */ static readonly configurations: ISPHttpClientBatchConfigurations; private _fetchProvider; private _randomNumberGenerator; private _digestCache; private _batchedRequests; private _correlationId; private _batchResponseBody; private _webUrl; /* Excluded from this release type: __constructor */ /* Excluded from this release type: batchedSize */ /** * Queues a new request, and returns a promise that can be used to access * the server response (after execute() has completed). * * @remarks * The parameters for this function are basically the same as the WHATWG API standard * documented here: * * {@link https://fetch.spec.whatwg.org/ } * * However, be aware that certain REST headers are ignored or not allowed inside * a batch. See the ODATA documentation for details. * * When execute() is called, it will POST to a URL such as * "http://example.com/sites/sample/_api/$batch". Typically SPHttpClientBatch can successfully * guess the appropriate SPWeb URL by looking for a reserved URL segment such as "_api" * in the first URL passed to fetch(). If not, use ISPHttpClientBatchCreationOptions.webUrl to specify it * explicitly. * * @param url - the URL to fetch * @param configuration - determines the default behavior of this request; normally this should * be the latest version number from SPHttpClientBatchConfigurations * @param options - additional options that affect the request * * @returns A promise with behavior similar to WHATWG fetch(). This promise will resolve normally * (with {@link HttpClientResponse.ok} being false) for error status codes such as HTTP 404 * or 500. The promise will only reject for network failures or other errors that prevent communication * with the server. */ fetch(url: string, configuration: SPHttpClientBatchConfiguration, options?: ISPHttpClientBatchOptions): Promise; /** * Calls fetch(), but sets the method to 'GET'. * @param url - the URL to fetch * @param configuration - determines the default behavior of this request; normally this should * be the latest version number from SPHttpClientBatchConfigurations * @param options - additional options that affect the request * @returns A promise with behavior similar to WHATWG fetch(). This promise will resolve normally * (with {@link HttpClientResponse.ok} being false) for error status codes such as HTTP 404 * or 500. The promise will only reject for network failures or other errors that prevent communication * with the server. */ get(url: string, configuration: SPHttpClientBatchConfiguration, options?: ISPHttpClientBatchOptions): Promise; /** * Calls fetch(), but sets the method to 'POST'. * @param url - the URL to fetch * @param configuration - determines the default behavior of this request; normally this should * be the latest version number from SPHttpClientBatchConfigurations * @param options - additional options that affect the request * @returns A promise with behavior similar to WHATWG fetch(). This promise will resolve normally * (with {@link HttpClientResponse.ok} being false) for error status codes such as HTTP 404 * or 500. The promise will only reject for network failures or other errors that prevent communication * with the server. */ post(url: string, configuration: SPHttpClientBatchConfiguration, options: ISPHttpClientBatchOptions): Promise; /** * Executes the batched queries that were queued using SPHttpClientBatch.fetch(). */ execute(): Promise; /* Excluded from this release type: correlationId */ /* Excluded from this release type: batchResponseBody */ private _parseResponsesFromBody; } /** * Configuration for SPHttpClientBatch. * * @remarks * The SPHttpClientBatchConfiguration object provides a set of switches for enabling/disabling * various features of the SPHttpClientBatch class. Normally these switches are set * (e.g. when calling SPHttpClientBatch.fetch()) by providing one of the predefined defaults * from SPHttpClientBatchConfigurations, however switches can also be changed via the * SPHttpClientBatchConfiguration.overrideWith() method. * * @beta */ export declare class SPHttpClientBatchConfiguration extends SPHttpClientCommonConfiguration implements ISPHttpClientBatchConfiguration { protected flags: ISPHttpClientBatchConfiguration; /** * Constructs a new instance of SPHttpClientBatchConfiguration with the specified flags. * The default values will be used for any flags that are missing or undefined. * If overrideFlags is specified, it takes precedence over flags. */ constructor(flags: ISPHttpClientBatchConfiguration, overrideFlags?: ISPHttpClientBatchConfiguration); /** * @override */ overrideWith(sourceFlags: ISPHttpClientBatchConfiguration): SPHttpClientBatchConfiguration; /** * @override */ protected initializeFlags(): void; } /** * Common base class for SPHttpClientConfiguration and SPHttpClientBatchConfiguration. * * @public */ export declare class SPHttpClientCommonConfiguration extends HttpClientConfiguration implements ISPHttpClientCommonConfiguration { protected flags: ISPHttpClientCommonConfiguration; /** * Constructs a new instance of SPHttpClientCommonConfiguration with the specified flags. * * @remarks * The default values will be used for any flags that are missing or undefined. * If overrideFlags is specified, it takes precedence over flags. */ constructor(flags: ISPHttpClientCommonConfiguration, overrideFlags?: ISPHttpClientCommonConfiguration); /** * @override */ overrideWith(sourceFlags: ISPHttpClientCommonConfiguration): SPHttpClientCommonConfiguration; /** * {@inheritDoc ISPHttpClientCommonConfiguration.jsonRequest} */ get jsonRequest(): boolean; /** * {@inheritDoc ISPHttpClientCommonConfiguration.jsonResponse} */ get jsonResponse(): boolean; /** * @override */ protected initializeFlags(): void; } /** * Configuration for {@link SPHttpClient}. * * @remarks * The SPHttpClientConfiguration object provides a set of switches for enabling/disabling * various features of the SPHttpClient class. Normally these switches are set * (e.g. when calling SPHttpClient.fetch()) by providing one of the predefined defaults * from SPHttpClientConfigurations, however switches can also be changed via the * SPHttpClientConfiguration.overrideWith() method. * * @public */ export declare class SPHttpClientConfiguration extends SPHttpClientCommonConfiguration implements ISPHttpClientConfiguration { protected flags: ISPHttpClientConfiguration; /** * Constructs a new instance of SPHttpClientConfiguration with the specified flags. * The default values will be used for any flags that are missing or undefined. * If overrideFlags is specified, it takes precedence over flags. */ constructor(flags: ISPHttpClientConfiguration, overrideFlags?: ISPHttpClientConfiguration); /** * @override */ overrideWith(sourceFlags: ISPHttpClientConfiguration): SPHttpClientConfiguration; /** * {@inheritDoc ISPHttpClientConfiguration.defaultSameOriginCredentials} */ get defaultSameOriginCredentials(): boolean; /** * {@inheritDoc ISPHttpClientConfiguration.defaultODataVersion} */ get defaultODataVersion(): ODataVersion; /** * {@inheritDoc ISPHttpClientConfiguration.requestDigest} */ get requestDigest(): boolean; /** * {@inheritDoc ISPHttpClientConfiguration.usePopupForCookieRefresh} */ get usePopupForCookieRefresh(): boolean; /** * @override */ protected initializeFlags(): void; } /* Excluded from this release type: _SPHttpClientHelper */ /** * The Response subclass returned by methods such as SPHttpClient.fetch(). * * @remarks * This is a placeholder. In the future, additional SPHttpClient-specific functionality * may be added to this class. * * @public * @sealed */ export declare class SPHttpClientResponse extends HttpClientResponse { private _correlationId; constructor(response: Response); /** * @override */ clone(): SPHttpClientResponse; /** * Returns the SharePoint correlation ID. * * @remarks * * The correlation ID is a Guid that can be used to associate log events that * are part of the same overall operation, but may originate from different services * or components. SharePoint REST operations return the server's correlation ID * as the "sprequestguid" header. * * @returns the correlation ID, or undefined if the "sprequestguid" header was not found * * @beta */ get correlationId(): Guid | undefined; /* Excluded from this release type: statusMessage */ } /** * Standard HTTP headers used with {@link SPHttpClient} * * @beta */ export declare enum SPHttpHeader { /** * SharePoint uses the 'SPRequestGuid' header to return the server's correlation ID * for a request. * * Example value: "9417279e-40e1-0000-2465-306ba786bfd7" */ SPRequestGuid = "SPRequestGuid" } /* Excluded from this release type: _SPRequestRateMonitor */ /** * Event arguments for token acquisition failures requiring user interaction. * * **When raised**: This event was originally used with ADAL.js for token acquisition failures. * In the current MSAL-based implementation, most interaction scenarios now use {@link PopupEventArgs} * and {@link BeforeRedirectEventArgs} instead. * * **Use cases** (legacy): * - Notify the application that token acquisition failed * - Provide the user with a redirect URL for manual authentication * - Handle MFA (Multi-Factor Authentication) requirements * * **Note**: This event may be deprecated in future versions. For new code, prefer subscribing to * `popupEvent` and `onBeforeRedirectEvent` which provide more control over the authentication flow. * * @public */ export declare class TokenAcquisitionEventArgs extends SPEventArgs implements ITokenAcquisitionEventArgs { /** * The message returned from ADAL fails to retrieve a token from Azure AD. */ message: string; /** * The url of the page for the end user to perform Multi Factor Authentication */ redirectUrl?: string; constructor(message: string, redirectUrl?: string); } export { }