@azure/msal-browser
Version:
Microsoft Authentication Library for js
54 lines (51 loc) • 1.7 kB
JavaScript
/*! @azure/msal-browser v5.30.0 2026-11-18 */
;
import { ProtocolMode } from '@azure/msal-common/browser';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
/**
* Returns true when the supplied user agent is using Safari
*
* @internal
*/
function isSafari(userAgent = typeof navigator !== "undefined"
? navigator.userAgent
: "") {
if (/OPR\/|OPiOS|PhantomJS|SamsungBrowser|Edge|EdgiOS|EdgA/.test(userAgent)) {
return false;
}
const browserNavigator = typeof navigator !== "undefined"
? navigator
: undefined;
if (/Edg/.test(userAgent) ||
browserNavigator?.userAgentData?.brands?.some((brand) => brand?.brand === "Microsoft Edge")) {
return false;
}
if (/Electron|CriOS|Chrome|Trident|FxiOS|Firefox/.test(userAgent)) {
return false;
}
return /Safari/.test(userAgent) || /AppleWebKit/.test(userAgent);
}
/**
* Returns true when EAR should be used for the current request.
*
* Safari cannot complete EAR's cross-origin form POST, so requests configured
* for EAR transparently use authorization code flow instead.
*
* @internal
*/
function shouldUseEar(protocolMode, logger, performanceClient, correlationId, userAgent) {
if (protocolMode !== ProtocolMode.EAR) {
return false;
}
if (!isSafari(userAgent)) {
return true;
}
logger.verbose("0wirye", correlationId);
performanceClient.addFields({ "ext.earFallbackReason": "safari" }, correlationId);
return false;
}
export { isSafari, shouldUseEar };
//# sourceMappingURL=BrowserDetection.mjs.map