import type { SPEvent, SPEventArgs } from '@microsoft/sp-core-library'; import type { IAuthenticationScheme, ITokenData } from './ITokenProvider'; /** * @public */ export interface IGetTokenOptions { useCachedToken?: boolean; claims?: string; /** * The scopes to request access to for the token. * If not specified, the default scopes will be used. * * @internal */ scopes?: string[]; /** * 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; /** * Qos name passed from caller * @internal */ callersQosName?: string; /** * Full page redirect will be cancelled if this is set to true. * This is useful for scenarios where the developer wants to handle the redirect * themselves, such as a custom redirect flow. * @internal */ cancelRedirect?: 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 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; } /** * 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. * * @internal */ export interface IInternalAadTokenProvider extends IAadTokenProvider { /** * 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 * * @internal * * @param resourceEndpoint - the resource for which the token should be obtained * @param configuration - Allows the developer to specify a custom configuration * for retrieving tokens * @returns A promise that will be fulfilled with the token or that will reject * with an error message */ _getTokenInternal(resourceEndpoint: string, configuration: IAadTokenProviderConfiguration, options?: IGetTokenOptions): Promise; _getTokenInternal(resourceEndpoint: string, configuration: IAadTokenProviderConfiguration, useCachedToken?: boolean): Promise; _ensureState(): Promise; _ensureTelemetry(): Promise; } /** * @public */ export interface IGetTokenDataOptions { useCachedToken: boolean; skipLoggingAndDisableRedirects: boolean; claims: string | undefined; authenticationScheme?: IAuthenticationScheme; resourceRequestMethod?: string; shrClaims?: string; scopes?: string[]; callersQosName?: string; } /** * This class allows a developer to obtain OAuth2 token data from Azure AD. * * @internal */ export interface IInternalAadTokenDataProvider extends IInternalAadTokenProvider { _getTokenData(resourceEndpoint: string, useCachedToken: boolean, skipLoggingAndDisableRedirects: boolean): Promise; _getTokenData(resourceEndpoint: string, options: IGetTokenDataOptions): Promise; } /** * Required strings for constructing an AadTokenProvider. * * @public */ export 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; /** * Guid associated to the loading of the current page * * @internal */ spRequestGuid?: string; /** * 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; /** * Whether or not to enable an auth flow with support for metaOS applications. * * @internal */ enableMetaOS?: boolean; /** * Whether the given tenant has enabled its TenantStore setting to enable the MsalV1 Popup sign in flow * * @internal */ isMsalTokenProviderPopupEnabled?: boolean; /** * Whether the reply URIs have been updated or not. * * @internal */ thirdPartyReplyUrisUpdated?: boolean; /** * Whether the current user an anonymous guest user. * * @internal */ isAnonymousGuestUser?: boolean; /** * Whether the current user an email authentication guest user. * * @internal */ isEmailAuthenticationGuestUser?: boolean; /** * Whether the current instance should support nested app auth * * @internal */ isNaaSupported?: boolean; /** * Whether the current instance should support pairwise brokering * * @internal */ isPairwiseBrokerEnabled?: boolean; /** * The namespace that will isolate events generated by the token provider instances. * * @internal */ eventNamespace?: string; /** * The Microsoft Graph endpoint URL for the current environment. * * @internal */ msGraphEndpointUrl?: string; } /** * Represents arguments used before redirecting event. * * @public */ export 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; } /** * Represents arguments used before popup event. * * @public */ export 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; } /** * Represents arguments used for raising a token acquisiton failure event. * * @public */ export 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; } /** * Represents a basic set of data we send to our QosMonitors for token requests */ export interface IAadTokenProviderBasicData { isInternal: boolean; name?: string; } /** * Represents the set of additional desirable data we send to our QosMonitors for token requests */ export interface IAadTokenProviderExtraData extends IAadTokenProviderBasicData { alias: string; CorrelationId: string; } /** * Represents the set of data we send to our QosMonitors for MSAL token requests */ export interface IMsalTokenProviderExtraData extends IAadTokenProviderExtraData { jsonExtraData: string; msalVersion?: string; shouldTryTokenByPopup?: boolean; } /** * Represents the set of data we send to our QosMonitors for MSAL Browser token requests. * * @Internal */ export interface IMsalBrowserTokenProviderExtraData extends IAadTokenProviderExtraData { aadSessionId?: string; isPageVisibleEnd?: boolean; isPageVisibleStart?: boolean; redirectUri?: string; msalVersion?: string; authenticationScheme?: IAuthenticationScheme; isTriggerFullPageRedirect?: boolean; aadCorrelationId?: string; callersQosName?: string; } /** * Represents the set of data we send to our QosMonitors for MSAL token requests resulting in a full page redirect. * @Internal */ export interface IMsalRedirectExtraData extends IAadTokenProviderExtraData { timeElapsed?: number; } //# sourceMappingURL=IAadTokenProvider.d.ts.map