Modifier

Partager via


BrowserUtils class

Utility class for browser specific functions

Methods

blockAcquireTokenInPopups()

Block redirectUri loaded in popup from calling AcquireToken APIs

blockNativeBrokerCalledBeforeInitialized(boolean, boolean)

Throws error if native brokering is enabled but initialize hasn't been called

blockNonBrowserEnvironment(boolean)

Throws error if token requests are made in non-browser environment

blockRedirectInIframe(InteractionType, boolean)

Block redirect operations in iframes unless explicitly allowed

blockReloadInHiddenIframes()

Throws error if we have completed an auth and are attempting another auth request inside an iframe.

clearHash(Window)

Clears hash from window url.

detectIEOrEdge()

Returns boolean of whether current browser is an Internet Explorer or Edge browser.

getBrowserNetworkClient()

Returns best compatible network client object.

getCurrentUri()

Returns current window URL as redirect uri

getHomepage()

Gets the homepage url for the current window location.

isInIframe()

Returns boolean of whether the current window is in an iframe or not.

isInPopup()

Returns boolean of whether or not the current window is a popup opened by msal

replaceHash(string)

Replaces current hash with hash from provided url

Method Details

blockAcquireTokenInPopups()

Block redirectUri loaded in popup from calling AcquireToken APIs

static function blockAcquireTokenInPopups()

blockNativeBrokerCalledBeforeInitialized(boolean, boolean)

Throws error if native brokering is enabled but initialize hasn't been called

static function blockNativeBrokerCalledBeforeInitialized(allowNativeBroker: boolean, initialized: boolean)

Parameters

allowNativeBroker

boolean

initialized

boolean

blockNonBrowserEnvironment(boolean)

Throws error if token requests are made in non-browser environment

static function blockNonBrowserEnvironment(isBrowserEnvironment: boolean)

Parameters

isBrowserEnvironment

boolean

Flag indicating if environment is a browser.

blockRedirectInIframe(InteractionType, boolean)

Block redirect operations in iframes unless explicitly allowed

static function blockRedirectInIframe(interactionType: InteractionType, allowRedirectInIframe: boolean)

Parameters

interactionType
InteractionType

Interaction type for the request

allowRedirectInIframe

boolean

Config value to allow redirects when app is inside an iframe

blockReloadInHiddenIframes()

Throws error if we have completed an auth and are attempting another auth request inside an iframe.

static function blockReloadInHiddenIframes()

clearHash(Window)

Clears hash from window url.

static function clearHash(contentWindow: Window)

Parameters

contentWindow

Window

detectIEOrEdge()

Returns boolean of whether current browser is an Internet Explorer or Edge browser.

static function detectIEOrEdge(): boolean

Returns

boolean

getBrowserNetworkClient()

Returns best compatible network client object.

static function getBrowserNetworkClient(): INetworkModule

Returns

INetworkModule

getCurrentUri()

Returns current window URL as redirect uri

static function getCurrentUri(): string

Returns

string

getHomepage()

Gets the homepage url for the current window location.

static function getHomepage(): string

Returns

string

isInIframe()

Returns boolean of whether the current window is in an iframe or not.

static function isInIframe(): boolean

Returns

boolean

isInPopup()

Returns boolean of whether or not the current window is a popup opened by msal

static function isInPopup(): boolean

Returns

boolean

replaceHash(string)

Replaces current hash with hash from provided url

static function replaceHash(url: string)

Parameters

url

string