export declare const CURRENT_REDIRECT_START_TIME_SESSION_STORAGE_KEY: string; export declare const CORRELATION_ID_SESSION_STORAGE_KEY: string; /** * This class is used to manage session storage states needed for redirects when using MSAL.js. * * Each MSAL.js client, v1 or v2, should create an instance of MsalRedirectManager and: * - Check the result of isAllowedToRedirect() to see if you are allowed to redirect. * - Call prepareForRedirect() before redirecting. * - Call cancelRedirect() if the redirect will be cancelled and prepareRedirect() has already been called. * Note that a maximum of 2 redirect attempts may be tried in 1 minute. * * The session storage information written by this class is expected by spfxsinglesignon.aspx. * Any changes to keys or behaviour here should be accompanied with changes to spfxsinglesignon.aspx. * * @internal */ export declare class MsalRedirectManager { static _ALLOWED_REDIRECT_ATTEMPTS: number; private static _MAX_REDIRECT_TIME_IN_MIN; private static _isRedirectInProgress; private readonly _STORAGE_KEYS; private readonly _authority; private readonly _clientId; private readonly _shouldUseMsalBrowser; /** * Creates an MsalRedirectManager to manage the necessary state for redirects. * * @param authority - The authority string to be used on spfxsinglesignon.aspx when instantiating msal. * @param clientId - The client id string to be used on spfxsignlesignon.aspx when instantiating msal. * @param shouldUseMsalBrowser - Whether or not spfxsinglesignon.aspx should use msal-browser. */ constructor(authority: string, clientId: string, shouldUseMsalBrowser: boolean); /** * Determines if the caller may attempt a redirect and invoke prepareForRedirect(). Redirects can * be attempted if: * - There have not been more than ALLOWED_REDIRECT_ATTEMPTS in the last 60 seconds. * - There is no redirect currently in progress. * * @returns True if the caller can call prepareForRedirect(). */ isAllowedToRedirect(): boolean; /** * This method determines whether or not there are any redirect attempts left. * There can be a maximum of ALLOWED_REDIRECT_ATTEMPTS in 60 seconds. * * @returns True if thre are any redirect attempts left. */ hasRedirectAttemptsLeft(): boolean; /** * Determines whether or not a redirect is already in progress. The caller should not attempt * to redirect if there is a redirect in progress. * * @returns True if there is currently a redirect in progress. */ isRedirectInProgress(): boolean; /** * Should be called before attempting to redirect. This method prepares the browser for a redirect by * saving necessary state data in session storage. * * The items saved are: * - authority: Used to configure MSAL on spfxsinglesignon.aspx * - clientId: Used to configure MSAL on spfxsinglesignon.aspx * - redirectUri: Used to determine where to redirect back to on spfxsinglesignon.aspx * - shouldUseMsalBrowser: Used to determine whether to instantiate MSAL.js v1 or v2 on * spfxsinglesignon.aspx * - isRedirectInProgress: Indicates whether or not a redirect is in progress for either MSAL.js v1 or v2. * We will not proceed with a redirect if one is in progress. * - isSsoSilent: Used to determine whether or not to instantiate MSAL.js on spfxsinglesignon.aspx. * This is different than shouldUseMsalBrowser as no instances of MSAL.js v1 or v2 are * created. * * These items are deleted from session storage on spfxsinglesignon.aspx before returning to the current * page. * * This method also updates the first redirect time and current redirect attempt count in session storage. */ prepareForRedirect(correlationId?: string): void; /** * Should be called to cancel a redirect after prepareForRedirect() has already been called. * This method clears all the states saved by prepareForRedirect(). */ cancelRedirect(): void; /** * Determines the number of redirect attempts in the last 2 minutes using storage states. * * @returns The number of redirects in the 2 minutes. */ getCurrentNumberOfRedirectAttempts(): number; /** * Increments the number of redirect attempts in session storage. If this is the first redirect attempt, * this method will also write to the first redirect key. */ private _incrementRedirectAttempts; /** * This method gets the current number of previous redirect attempts saved in session storage. * This does not account for how old the previous redirect attempts are. * * @returns The current number of previous redirect attempts saved in session storage. */ private _getRedirectAttemptNumberFromSessionStorage; /** * Given an attempt number, this method will update the current redirect attempt number in session storage. * The number is saved as a string. * * @param attempt - Current attempt number to write to session storage. */ private _setRedirectAttemptNumberInSessionStorage; /** * Returns the first time a redirect was attempted as a date string. This string can be used in the * constructor of a Date object, but only if it is not null. * * @returns The first attempted redirect time or null if the key is not found. */ private _getFirstRedirectTimeFromSessionStorage; /** * Creates a date object capturing the current time and saves it to session storage as the first redirect * time. */ private _setFirstRedirectTimeInSessionStorage; /** * Creates a date object capturing the current time while on the current redirect attempt and saves it to session storage as the start time * of the current redirect attempt. */ private _setCurrentRedirectTimeInSessionStorage; } //# sourceMappingURL=MsalRedirectManager.d.ts.map