@azure/msal-browser 5.26.0 → 5.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (295) hide show
  1. package/README.md +2 -0
  2. package/dist/app/IPublicClientApplication.mjs +1 -1
  3. package/dist/app/PublicClientApplication.mjs +54 -14
  4. package/dist/app/PublicClientApplication.mjs.map +1 -1
  5. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  6. package/dist/broker/nativeBroker/PlatformAuthDOMHandler.mjs +1 -1
  7. package/dist/broker/nativeBroker/PlatformAuthExtensionHandler.mjs +1 -1
  8. package/dist/broker/nativeBroker/PlatformAuthProvider.mjs +1 -1
  9. package/dist/broker/nativeBroker/PlatformAuthRequest.mjs +1 -1
  10. package/dist/cache/AccountManager.mjs +1 -1
  11. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  12. package/dist/cache/BrowserCacheManager.mjs +1 -1
  13. package/dist/cache/CacheHelpers.mjs +1 -1
  14. package/dist/cache/CacheKeys.mjs +1 -1
  15. package/dist/cache/CookieStorage.mjs +1 -1
  16. package/dist/cache/DatabaseStorage.mjs +1 -1
  17. package/dist/cache/EncryptedData.mjs +1 -1
  18. package/dist/cache/LocalStorage.mjs +1 -1
  19. package/dist/cache/MemoryStorage.mjs +1 -1
  20. package/dist/cache/SessionStorage.mjs +1 -1
  21. package/dist/cache/TokenCache.mjs +1 -1
  22. package/dist/config/Configuration.mjs +32 -4
  23. package/dist/config/Configuration.mjs.map +1 -1
  24. package/dist/controllers/NestedAppAuthController.mjs +1 -1
  25. package/dist/controllers/StandardController.mjs +36 -5
  26. package/dist/controllers/StandardController.mjs.map +1 -1
  27. package/dist/crypto/BrowserCrypto.mjs +1 -1
  28. package/dist/crypto/CryptoOps.mjs +1 -1
  29. package/dist/crypto/PkceGenerator.mjs +1 -1
  30. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  31. package/dist/crypto/TokenBindingKeyManager.mjs +1 -1
  32. package/dist/custom_auth/CustomAuthConstants.mjs +1 -1
  33. package/dist/custom_auth/CustomAuthPublicClientApplication.mjs +1 -1
  34. package/dist/custom_auth/controller/CustomAuthStandardController.mjs +1 -1
  35. package/dist/custom_auth/core/CustomAuthAuthority.mjs +1 -1
  36. package/dist/custom_auth/core/auth_flow/AuthFlowErrorBase.mjs +1 -1
  37. package/dist/custom_auth/core/auth_flow/AuthFlowResultBase.mjs +1 -1
  38. package/dist/custom_auth/core/auth_flow/AuthFlowState.mjs +1 -1
  39. package/dist/custom_auth/core/auth_flow/AuthFlowStateTypes.mjs +1 -1
  40. package/dist/custom_auth/core/auth_flow/jit/error_type/AuthMethodRegistrationError.mjs +1 -1
  41. package/dist/custom_auth/core/auth_flow/jit/result/AuthMethodRegistrationChallengeMethodResult.mjs +1 -1
  42. package/dist/custom_auth/core/auth_flow/jit/result/AuthMethodRegistrationSubmitChallengeResult.mjs +1 -1
  43. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationCompletedState.mjs +1 -1
  44. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationFailedState.mjs +1 -1
  45. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationState.mjs +1 -1
  46. package/dist/custom_auth/core/auth_flow/mfa/error_type/MfaError.mjs +1 -1
  47. package/dist/custom_auth/core/auth_flow/mfa/result/MfaRequestChallengeResult.mjs +1 -1
  48. package/dist/custom_auth/core/auth_flow/mfa/result/MfaSubmitChallengeResult.mjs +1 -1
  49. package/dist/custom_auth/core/auth_flow/mfa/state/MfaCompletedState.mjs +1 -1
  50. package/dist/custom_auth/core/auth_flow/mfa/state/MfaFailedState.mjs +1 -1
  51. package/dist/custom_auth/core/auth_flow/mfa/state/MfaState.mjs +1 -1
  52. package/dist/custom_auth/core/auth_flow/v2/CustomAuthFlowScenarioV2.mjs +1 -1
  53. package/dist/custom_auth/core/auth_flow/v2/CustomAuthResultV2.mjs +1 -1
  54. package/dist/custom_auth/core/auth_flow/v2/error/AuthFlowErrorSubcodesV2.mjs +1 -1
  55. package/dist/custom_auth/core/auth_flow/v2/error/AuthFlowErrorV2.mjs +1 -1
  56. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.mjs +1 -1
  57. package/dist/custom_auth/core/auth_flow/v2/state/ChallengeVerificationStateBaseV2.mjs +1 -1
  58. package/dist/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.mjs +1 -1
  59. package/dist/custom_auth/core/auth_flow/v2/state/CompletedStateV2.mjs +1 -1
  60. package/dist/custom_auth/core/auth_flow/v2/state/FailedStateV2.mjs +1 -1
  61. package/dist/custom_auth/core/auth_flow/v2/state/MFAVerificationRequiredStateV2.mjs +1 -1
  62. package/dist/custom_auth/core/error/CustomAuthApiError.mjs +1 -1
  63. package/dist/custom_auth/core/error/CustomAuthError.mjs +1 -1
  64. package/dist/custom_auth/core/error/HttpError.mjs +1 -1
  65. package/dist/custom_auth/core/error/HttpErrorCodes.mjs +1 -1
  66. package/dist/custom_auth/core/error/InvalidArgumentError.mjs +1 -1
  67. package/dist/custom_auth/core/error/InvalidConfigurationError.mjs +1 -1
  68. package/dist/custom_auth/core/error/InvalidConfigurationErrorCodes.mjs +1 -1
  69. package/dist/custom_auth/core/error/MethodNotImplementedError.mjs +1 -1
  70. package/dist/custom_auth/core/error/MsalCustomAuthError.mjs +1 -1
  71. package/dist/custom_auth/core/error/NoCachedAccountFoundError.mjs +1 -1
  72. package/dist/custom_auth/core/error/ParsedUrlError.mjs +1 -1
  73. package/dist/custom_auth/core/error/ParsedUrlErrorCodes.mjs +1 -1
  74. package/dist/custom_auth/core/error/UnexpectedError.mjs +1 -1
  75. package/dist/custom_auth/core/error/UnsupportedEnvironmentError.mjs +1 -1
  76. package/dist/custom_auth/core/error/UserAccountAttributeError.mjs +1 -1
  77. package/dist/custom_auth/core/error/UserAlreadySignedInError.mjs +1 -1
  78. package/dist/custom_auth/core/interaction_client/CustomAuthInteractionClientBase.mjs +1 -1
  79. package/dist/custom_auth/core/interaction_client/CustomAuthInterationClientFactory.mjs +1 -1
  80. package/dist/custom_auth/core/interaction_client/jit/JitClient.mjs +1 -1
  81. package/dist/custom_auth/core/interaction_client/jit/result/JitActionResult.mjs +1 -1
  82. package/dist/custom_auth/core/interaction_client/mfa/MfaClient.mjs +1 -1
  83. package/dist/custom_auth/core/interaction_client/mfa/result/MfaActionResult.mjs +1 -1
  84. package/dist/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.mjs +1 -1
  85. package/dist/custom_auth/core/interaction_client/v2/InteractionClientBaseV2.mjs +1 -1
  86. package/dist/custom_auth/core/interaction_client/v2/result/FlowActionResultV2.mjs +1 -1
  87. package/dist/custom_auth/core/network_client/custom_auth_api/BaseApiClient.mjs +1 -1
  88. package/dist/custom_auth/core/network_client/custom_auth_api/CustomAuthApiClient.mjs +1 -1
  89. package/dist/custom_auth/core/network_client/custom_auth_api/CustomAuthApiEndpoint.mjs +1 -1
  90. package/dist/custom_auth/core/network_client/custom_auth_api/RegisterApiClient.mjs +1 -1
  91. package/dist/custom_auth/core/network_client/custom_auth_api/ResetPasswordApiClient.mjs +1 -1
  92. package/dist/custom_auth/core/network_client/custom_auth_api/SignInApiClient.mjs +1 -1
  93. package/dist/custom_auth/core/network_client/custom_auth_api/SignupApiClient.mjs +1 -1
  94. package/dist/custom_auth/core/network_client/custom_auth_api/types/ApiErrorCodes.mjs +1 -1
  95. package/dist/custom_auth/core/network_client/custom_auth_api/types/ApiSuberrors.mjs +1 -1
  96. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.mjs +1 -1
  97. package/dist/custom_auth/core/network_client/custom_auth_api/v2/BaseApiClientV2.mjs +1 -1
  98. package/dist/custom_auth/core/network_client/custom_auth_api/v2/CustomAuthApiClientV2.mjs +1 -1
  99. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ErrorCodesV2.mjs +1 -1
  100. package/dist/custom_auth/core/network_client/custom_auth_api/v2/HrefResolverV2.mjs +1 -1
  101. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.mjs +1 -1
  102. package/dist/custom_auth/core/network_client/custom_auth_api/v2/response/ErrorNormalizerV2.mjs +1 -1
  103. package/dist/custom_auth/core/network_client/custom_auth_api/v2/result/BaseResultsV2.mjs +1 -1
  104. package/dist/custom_auth/core/network_client/custom_auth_api/v2/result/SignUpResultsV2.mjs +1 -1
  105. package/dist/custom_auth/core/network_client/http_client/FetchHttpClient.mjs +1 -1
  106. package/dist/custom_auth/core/network_client/http_client/IHttpClient.mjs +1 -1
  107. package/dist/custom_auth/core/telemetry/FlowApiIdHelperV2.mjs +1 -1
  108. package/dist/custom_auth/core/telemetry/PublicApiId.mjs +1 -1
  109. package/dist/custom_auth/core/utils/ArgumentValidator.mjs +1 -1
  110. package/dist/custom_auth/core/utils/CustomHeaderUtils.mjs +1 -1
  111. package/dist/custom_auth/core/utils/UrlUtils.mjs +1 -1
  112. package/dist/custom_auth/get_account/auth_flow/CustomAuthAccountData.mjs +1 -1
  113. package/dist/custom_auth/get_account/auth_flow/error_type/GetAccountError.mjs +1 -1
  114. package/dist/custom_auth/get_account/auth_flow/result/GetAccessTokenResult.mjs +1 -1
  115. package/dist/custom_auth/get_account/auth_flow/result/GetAccountResult.mjs +1 -1
  116. package/dist/custom_auth/get_account/auth_flow/result/SignOutResult.mjs +1 -1
  117. package/dist/custom_auth/get_account/auth_flow/state/GetAccessTokenState.mjs +1 -1
  118. package/dist/custom_auth/get_account/auth_flow/state/GetAccountState.mjs +1 -1
  119. package/dist/custom_auth/get_account/auth_flow/state/SignOutState.mjs +1 -1
  120. package/dist/custom_auth/get_account/interaction_client/CustomAuthSilentCacheClient.mjs +1 -1
  121. package/dist/custom_auth/index.mjs +1 -1
  122. package/dist/custom_auth/operating_context/CustomAuthOperatingContext.mjs +1 -1
  123. package/dist/custom_auth/reset_password/auth_flow/error_type/ResetPasswordError.mjs +1 -1
  124. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordResendCodeResult.mjs +1 -1
  125. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordStartResult.mjs +1 -1
  126. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordSubmitCodeResult.mjs +1 -1
  127. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordSubmitPasswordResult.mjs +1 -1
  128. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordCodeRequiredState.mjs +1 -1
  129. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordCompletedState.mjs +1 -1
  130. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordFailedState.mjs +1 -1
  131. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordPasswordRequiredState.mjs +1 -1
  132. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordState.mjs +1 -1
  133. package/dist/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.mjs +1 -1
  134. package/dist/custom_auth/reset_password/interaction_client/ResetPasswordClient.mjs +1 -1
  135. package/dist/custom_auth/sign_in/auth_flow/SignInScenario.mjs +1 -1
  136. package/dist/custom_auth/sign_in/auth_flow/error_type/SignInError.mjs +1 -1
  137. package/dist/custom_auth/sign_in/auth_flow/result/SignInResendCodeResult.mjs +1 -1
  138. package/dist/custom_auth/sign_in/auth_flow/result/SignInResult.mjs +1 -1
  139. package/dist/custom_auth/sign_in/auth_flow/result/SignInSubmitCodeResult.mjs +1 -1
  140. package/dist/custom_auth/sign_in/auth_flow/result/SignInSubmitPasswordResult.mjs +1 -1
  141. package/dist/custom_auth/sign_in/auth_flow/state/SignInCodeRequiredState.mjs +1 -1
  142. package/dist/custom_auth/sign_in/auth_flow/state/SignInCompletedState.mjs +1 -1
  143. package/dist/custom_auth/sign_in/auth_flow/state/SignInContinuationState.mjs +1 -1
  144. package/dist/custom_auth/sign_in/auth_flow/state/SignInFailedState.mjs +1 -1
  145. package/dist/custom_auth/sign_in/auth_flow/state/SignInPasswordRequiredState.mjs +1 -1
  146. package/dist/custom_auth/sign_in/auth_flow/state/SignInState.mjs +1 -1
  147. package/dist/custom_auth/sign_in/auth_flow/v2/state/PasswordRequiredStateV2.mjs +1 -1
  148. package/dist/custom_auth/sign_in/auth_flow/v2/state/SignInContinuationStateV2.mjs +1 -1
  149. package/dist/custom_auth/sign_in/auth_flow/v2/state/SignInStateTransitionHandlerV2.mjs +1 -1
  150. package/dist/custom_auth/sign_in/interaction_client/SignInClient.mjs +1 -1
  151. package/dist/custom_auth/sign_in/interaction_client/result/SignInActionResult.mjs +1 -1
  152. package/dist/custom_auth/sign_up/auth_flow/error_type/SignUpError.mjs +1 -1
  153. package/dist/custom_auth/sign_up/auth_flow/result/SignUpResendCodeResult.mjs +1 -1
  154. package/dist/custom_auth/sign_up/auth_flow/result/SignUpResult.mjs +1 -1
  155. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitAttributesResult.mjs +1 -1
  156. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitCodeResult.mjs +1 -1
  157. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitPasswordResult.mjs +1 -1
  158. package/dist/custom_auth/sign_up/auth_flow/state/SignUpAttributesRequiredState.mjs +1 -1
  159. package/dist/custom_auth/sign_up/auth_flow/state/SignUpCodeRequiredState.mjs +1 -1
  160. package/dist/custom_auth/sign_up/auth_flow/state/SignUpCompletedState.mjs +1 -1
  161. package/dist/custom_auth/sign_up/auth_flow/state/SignUpFailedState.mjs +1 -1
  162. package/dist/custom_auth/sign_up/auth_flow/state/SignUpPasswordRequiredState.mjs +1 -1
  163. package/dist/custom_auth/sign_up/auth_flow/state/SignUpState.mjs +1 -1
  164. package/dist/custom_auth/sign_up/auth_flow/v2/state/AttributesRequiredStateV2.mjs +1 -1
  165. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpAttributesRequiredStateBaseV2.mjs +1 -1
  166. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpPasswordRequiredStateV2.mjs +1 -1
  167. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpStateTransitionHandlerV2.mjs +1 -1
  168. package/dist/custom_auth/sign_up/interaction_client/SignUpClient.mjs +1 -1
  169. package/dist/custom_auth/sign_up/interaction_client/result/SignUpActionResult.mjs +1 -1
  170. package/dist/encode/Base64Decode.mjs +1 -1
  171. package/dist/encode/Base64Encode.mjs +1 -1
  172. package/dist/error/BrowserAuthError.mjs +1 -1
  173. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  174. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  175. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  176. package/dist/error/NativeAuthError.mjs +1 -1
  177. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  178. package/dist/error/NestedAppAuthError.mjs +1 -1
  179. package/dist/event/EventHandler.mjs +1 -1
  180. package/dist/event/EventMessage.mjs +1 -1
  181. package/dist/event/EventType.mjs +1 -1
  182. package/dist/index.mjs +1 -1
  183. package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
  184. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  185. package/dist/interaction_client/PlatformAuthInteractionClient.mjs +1 -1
  186. package/dist/interaction_client/PopupClient.mjs +28 -1
  187. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  188. package/dist/interaction_client/RedirectClient.mjs +2 -3
  189. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  190. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  191. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  192. package/dist/interaction_client/SilentIframeClient.mjs +1 -1
  193. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  194. package/dist/interaction_client/StandardInteractionClient.mjs +7 -1
  195. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  196. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  197. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  198. package/dist/log-strings-mapping.json +23 -3
  199. package/dist/naa/BridgeError.mjs +1 -1
  200. package/dist/naa/BridgeProxy.mjs +1 -1
  201. package/dist/naa/BridgeStatusCode.mjs +1 -1
  202. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  203. package/dist/navigation/NavigationClient.mjs +1 -1
  204. package/dist/network/FetchClient.mjs +1 -1
  205. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  206. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  207. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  208. package/dist/packageMetadata.mjs +2 -2
  209. package/dist/popup_relay/constants.mjs +1 -1
  210. package/dist/popup_relay/index.mjs +1 -1
  211. package/dist/popup_relay/relayClient.mjs +1 -1
  212. package/dist/protocol/Authorize.mjs +23 -13
  213. package/dist/protocol/Authorize.mjs.map +1 -1
  214. package/dist/redirect_bridge/index.mjs +1 -1
  215. package/dist/request/RequestHelpers.mjs +1 -1
  216. package/dist/request/SilentRequestHelpers.mjs +1 -1
  217. package/dist/response/ResponseHandler.mjs +1 -1
  218. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  219. package/dist/telemetry/BrowserPerformanceEvents.mjs +1 -1
  220. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  221. package/dist/telemetry/BrowserRootPerformanceEvents.mjs +1 -1
  222. package/dist/utils/BrowserConstants.mjs +1 -1
  223. package/dist/utils/BrowserDetection.mjs +1 -1
  224. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  225. package/dist/utils/BrowserUtils.mjs +7 -2
  226. package/dist/utils/BrowserUtils.mjs.map +1 -1
  227. package/dist/utils/Helpers.mjs +1 -1
  228. package/dist/utils/IframeMonitor.mjs +81 -0
  229. package/dist/utils/IframeMonitor.mjs.map +1 -0
  230. package/dist/utils/MsalFrameStatsUtils.mjs +1 -1
  231. package/dist/utils/PopupMonitor.mjs +119 -0
  232. package/dist/utils/PopupMonitor.mjs.map +1 -0
  233. package/dist/utils/PopupOriginCheck.mjs +88 -0
  234. package/dist/utils/PopupOriginCheck.mjs.map +1 -0
  235. package/dist/webBrokerBridge/PendingRequestRegistry.mjs +1 -1
  236. package/dist/webBrokerBridge/PerfEventNames.mjs +1 -1
  237. package/dist/webBrokerBridge/WebBrokerBridgeError.mjs +1 -1
  238. package/dist/webBrokerBridge/WebBrokerBridgeErrorMap.mjs +1 -1
  239. package/dist/webBrokerBridge/adapter/CrossVersionRequestAdapter.mjs +1 -1
  240. package/dist/webBrokerBridge/index.mjs +1 -1
  241. package/lib/custom-auth-path/log-strings-mapping.json +23 -3
  242. package/lib/custom-auth-path/msal-custom-auth.cjs +617 -122
  243. package/lib/custom-auth-path/msal-custom-auth.cjs.map +1 -1
  244. package/lib/custom-auth-path/msal-custom-auth.js +617 -122
  245. package/lib/custom-auth-path/msal-custom-auth.js.map +1 -1
  246. package/lib/log-strings-mapping.json +23 -3
  247. package/lib/msal-browser.cjs +614 -128
  248. package/lib/msal-browser.cjs.map +1 -1
  249. package/lib/msal-browser.js +614 -128
  250. package/lib/msal-browser.js.map +1 -1
  251. package/lib/msal-browser.min.js +2 -2
  252. package/lib/popup-relay/msal-popup-relay.cjs +2 -2
  253. package/lib/popup-relay/msal-popup-relay.cjs.map +1 -1
  254. package/lib/popup-relay/msal-popup-relay.js +2 -2
  255. package/lib/popup-relay/msal-popup-relay.js.map +1 -1
  256. package/lib/popup-relay/msal-popup-relay.min.js +1 -1
  257. package/lib/redirect-bridge/msal-redirect-bridge.cjs +10 -10
  258. package/lib/redirect-bridge/msal-redirect-bridge.cjs.map +1 -1
  259. package/lib/redirect-bridge/msal-redirect-bridge.js +10 -10
  260. package/lib/redirect-bridge/msal-redirect-bridge.js.map +1 -1
  261. package/lib/redirect-bridge/msal-redirect-bridge.min.js +1 -1
  262. package/lib/web-broker-bridge/msal-web-broker-bridge.cjs +1 -1
  263. package/package.json +2 -2
  264. package/src/app/PublicClientApplication.ts +108 -8
  265. package/src/config/Configuration.ts +63 -6
  266. package/src/controllers/StandardController.ts +46 -3
  267. package/src/interaction_client/PopupClient.ts +36 -0
  268. package/src/interaction_client/RedirectClient.ts +0 -1
  269. package/src/interaction_client/StandardInteractionClient.ts +6 -0
  270. package/src/packageMetadata.ts +1 -1
  271. package/src/protocol/Authorize.ts +34 -28
  272. package/src/utils/BrowserUtils.ts +8 -1
  273. package/src/utils/IframeMonitor.ts +98 -0
  274. package/src/utils/PopupMonitor.ts +158 -0
  275. package/src/utils/PopupOriginCheck.ts +94 -0
  276. package/types/app/PublicClientApplication.d.ts +6 -4
  277. package/types/app/PublicClientApplication.d.ts.map +1 -1
  278. package/types/config/Configuration.d.ts +16 -0
  279. package/types/config/Configuration.d.ts.map +1 -1
  280. package/types/controllers/StandardController.d.ts.map +1 -1
  281. package/types/custom_auth/CustomAuthConstants.d.ts +1 -1
  282. package/types/interaction_client/PopupClient.d.ts +12 -0
  283. package/types/interaction_client/PopupClient.d.ts.map +1 -1
  284. package/types/interaction_client/RedirectClient.d.ts.map +1 -1
  285. package/types/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  286. package/types/packageMetadata.d.ts +1 -1
  287. package/types/protocol/Authorize.d.ts.map +1 -1
  288. package/types/utils/BrowserUtils.d.ts +2 -1
  289. package/types/utils/BrowserUtils.d.ts.map +1 -1
  290. package/types/utils/IframeMonitor.d.ts +17 -0
  291. package/types/utils/IframeMonitor.d.ts.map +1 -0
  292. package/types/utils/PopupMonitor.d.ts +37 -0
  293. package/types/utils/PopupMonitor.d.ts.map +1 -0
  294. package/types/utils/PopupOriginCheck.d.ts +27 -0
  295. package/types/utils/PopupOriginCheck.d.ts.map +1 -0
@@ -54,6 +54,7 @@ import {
54
54
  INTERACTION_TYPE,
55
55
  } from "../utils/BrowserConstants.js";
56
56
  import * as BrowserUtils from "../utils/BrowserUtils.js";
57
+ import { cancelPendingPopupPollingResponse } from "../utils/PopupMonitor.js";
57
58
  import { RedirectRequest } from "../request/RedirectRequest.js";
58
59
  import { PopupRequest } from "../request/PopupRequest.js";
59
60
  import { SsoSilentRequest } from "../request/SsoSilentRequest.js";
@@ -473,7 +474,39 @@ export class StandardController implements IController {
473
474
  private async handleRedirectPromiseInternal(
474
475
  options?: HandleRedirectPromiseOptions
475
476
  ): Promise<AuthenticationResult | null> {
476
- if (!this.browserStorage.isInteractionInProgress(true)) {
477
+ // Preserve the response for RedirectClient before removing it from the URL.
478
+ const responseString =
479
+ options?.hash ||
480
+ (this.config.auth.OIDCOptions.responseMode ===
481
+ Constants.ResponseMode.QUERY
482
+ ? window.location.search
483
+ : window.location.hash);
484
+ const anyClientInteractionInProgress =
485
+ this.browserStorage.isInteractionInProgress(false);
486
+ const currentClientInteraction =
487
+ this.browserStorage.isInteractionInProgress(true);
488
+ const isBridgeCallback =
489
+ BrowserUtils.isInPopup() ||
490
+ (BrowserUtils.isInIframe() &&
491
+ !this.config.system.allowRedirectInIframe);
492
+ /*
493
+ * Clear recognized response fragments for:
494
+ * - Stale callbacks with no pending interaction.
495
+ * - This client's login callback, even if request setup or response validation fails.
496
+ * - This client's logout callback containing state, before the SIGNOUT early return.
497
+ * Leave another client's callback untouched. clearHash preserves query strings
498
+ * and application routes, and does nothing when no response fragment is present.
499
+ * Skip popup and non-redirect iframe callbacks: legacy apps may call HRP
500
+ * before their redirect bridge reads and broadcasts the response.
501
+ */
502
+ if (
503
+ !isBridgeCallback &&
504
+ (!anyClientInteractionInProgress || currentClientInteraction)
505
+ ) {
506
+ BrowserUtils.clearHash(window);
507
+ }
508
+
509
+ if (!currentClientInteraction) {
477
510
  this.logger.info(
478
511
  "handleRedirectPromise called but there is no interaction in progress, returning null.",
479
512
  ""
@@ -489,7 +522,7 @@ export class StandardController implements IController {
489
522
  ""
490
523
  );
491
524
  this.browserStorage.setInteractionInProgress(false);
492
- return Promise.resolve(null);
525
+ return null;
493
526
  }
494
527
 
495
528
  const loggedInAccounts = this.getAllAccounts();
@@ -571,7 +604,14 @@ export class StandardController implements IController {
571
604
  this.logger,
572
605
  this.performanceClient,
573
606
  rootMeasurement.event.correlationId
574
- )(standardRequest, codeVerifier, rootMeasurement, options);
607
+ )(
608
+ standardRequest,
609
+ codeVerifier,
610
+ rootMeasurement,
611
+ options?.hash
612
+ ? options
613
+ : { ...options, hash: responseString }
614
+ );
575
615
  }
576
616
  } catch (e) {
577
617
  this.browserStorage.resetRequestCache("");
@@ -840,6 +880,9 @@ export class StandardController implements IController {
840
880
  request.overrideInteractionInProgress,
841
881
  correlationId
842
882
  );
883
+ if (request.overrideInteractionInProgress) {
884
+ cancelPendingPopupPollingResponse(this.logger);
885
+ }
843
886
  } catch (e) {
844
887
  // Since this function is syncronous we need to reject
845
888
  return Promise.reject(e);
@@ -40,6 +40,7 @@ import {
40
40
  import { EndSessionPopupRequest } from "../request/EndSessionPopupRequest.js";
41
41
  import { NavigationOptions } from "../navigation/NavigationOptions.js";
42
42
  import * as BrowserUtils from "../utils/BrowserUtils.js";
43
+ import { computePocd } from "../utils/PopupOriginCheck.js";
43
44
  import { shouldUseEar } from "../utils/BrowserDetection.js";
44
45
  import * as PopupRelay from "../popup_relay/relayClient.js";
45
46
  import { base64Decode } from "../encode/Base64Decode.js";
@@ -209,6 +210,9 @@ export class PopupClient extends StandardInteractionClient {
209
210
  logoutRequest?.popupWindowAttributes || {},
210
211
  popupWindowParent: logoutRequest?.popupWindowParent ?? window,
211
212
  };
213
+ validLogoutRequest.popupOriginCheckDone =
214
+ this.getPopupOriginCheckDone(popupParams.popupWindowParent) ??
215
+ validLogoutRequest.popupOriginCheckDone;
212
216
  const authority = logoutRequest && logoutRequest.authority;
213
217
  const mainWindowRedirectUri =
214
218
  logoutRequest && logoutRequest.mainWindowRedirectUri;
@@ -358,6 +362,9 @@ export class PopupClient extends StandardInteractionClient {
358
362
  ...request,
359
363
  codeChallenge: pkce.challenge,
360
364
  ...tokenBindingParams,
365
+ popupOriginCheckDone: this.getPopupOriginCheckDone(
366
+ popupParams.popupWindowParent
367
+ ),
361
368
  };
362
369
 
363
370
  try {
@@ -544,6 +551,9 @@ export class PopupClient extends StandardInteractionClient {
544
551
  earJwk: earJwk,
545
552
  codeChallenge: pkce.challenge,
546
553
  ...tokenBindingParams,
554
+ popupOriginCheckDone: this.getPopupOriginCheckDone(
555
+ popupParams.popupWindowParent
556
+ ),
547
557
  };
548
558
  const popupWindow = await this.openPostFormPopup(
549
559
  popupRequest,
@@ -1144,6 +1154,32 @@ export class PopupClient extends StandardInteractionClient {
1144
1154
  ).libraryState.id;
1145
1155
  }
1146
1156
 
1157
+ /**
1158
+ * Asserts `pocd=1` for the relay flow. Direct popups also require the
1159
+ * environment of a delegated opening window to pass the origin check.
1160
+ *
1161
+ * With a relay the IdP window is a grandchild popup, which an untrusted
1162
+ * ancestor cannot reach by name — so the topology satisfies the check by
1163
+ * construction. The current window is framed and would otherwise compute
1164
+ * `0`. Without a delegated parent, the standard app check remains unchanged.
1165
+ *
1166
+ * @param popupWindowParent Window that opens the popup.
1167
+ */
1168
+ private getPopupOriginCheckDone(
1169
+ popupWindowParent: Window
1170
+ ): boolean | undefined {
1171
+ if (this.config.auth.popupRelayUri) {
1172
+ return true;
1173
+ }
1174
+ if (popupWindowParent !== window) {
1175
+ return (
1176
+ computePocd(this.config) === 1 &&
1177
+ computePocd(this.config, popupWindowParent) === 1
1178
+ );
1179
+ }
1180
+ return undefined;
1181
+ }
1182
+
1147
1183
  /**
1148
1184
  * Opens the interactive popup for a POST-form /authorize request. Shared by
1149
1185
  * the auth-code POST and EAR flows, which are identical apart from the form
@@ -663,7 +663,6 @@ export class RedirectClient extends StandardInteractionClient {
663
663
  return [null, ""];
664
664
  }
665
665
 
666
- BrowserUtils.clearHash(window);
667
666
  this.logger.verbose(
668
667
  "Hash contains known properties, returning response hash",
669
668
  this.correlationId
@@ -46,6 +46,7 @@ import {
46
46
  initializeBaseRequest,
47
47
  validateRequestMethod,
48
48
  } from "../request/RequestHelpers.js";
49
+ import { computePocd } from "../utils/PopupOriginCheck.js";
49
50
 
50
51
  /**
51
52
  * Defines the class structure and helper functions used by the "standard", non-brokered auth flows (popup, redirect, silent (RT), silent (iframe))
@@ -66,6 +67,11 @@ export abstract class StandardInteractionClient extends BaseInteractionClient {
66
67
  const validLogoutRequest: CommonEndSessionRequest = {
67
68
  correlationId: this.correlationId,
68
69
  ...logoutRequest,
70
+ /*
71
+ * Computed here rather than per flow so every end-session request
72
+ * carries it, matching the authorize path.
73
+ */
74
+ popupOriginCheckDone: computePocd(this.config) === 1,
69
75
  };
70
76
 
71
77
  /**
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable header/header */
2
2
  export const name = "@azure/msal-browser";
3
- export const version = "5.26.0";
3
+ export const version = "5.27.0";
@@ -29,6 +29,7 @@ import {
29
29
  } from "@azure/msal-common/browser";
30
30
  import * as BrowserPerformanceEvents from "../telemetry/BrowserPerformanceEvents.js";
31
31
  import { BrowserConfiguration } from "../config/Configuration.js";
32
+ import { computePocd } from "../utils/PopupOriginCheck.js";
32
33
  import { ApiId, BrowserConstants } from "../utils/BrowserConstants.js";
33
34
  import { version } from "../packageMetadata.js";
34
35
  import { CryptoOps } from "../crypto/CryptoOps.js";
@@ -156,7 +157,17 @@ async function getStandardParameters(
156
157
  ): Promise<Map<string, string>> {
157
158
  const parameters = AuthorizeProtocol.getStandardAuthorizeRequestParameters(
158
159
  { ...config.auth, authority: authority },
159
- request,
160
+ {
161
+ ...request,
162
+ /*
163
+ * Computed here rather than per flow so every authorize request
164
+ * carries it — GET, POST and EAR, interactive and silent alike.
165
+ * A request may assert it instead when the topology, rather than
166
+ * the current window, is what makes the popup unreachable.
167
+ */
168
+ popupOriginCheckDone:
169
+ request.popupOriginCheckDone ?? computePocd(config) === 1,
170
+ },
160
171
  logger,
161
172
  performanceClient
162
173
  );
@@ -267,6 +278,26 @@ export type AuthorizeFormData = {
267
278
  fields: Record<string, string>;
268
279
  };
269
280
 
281
+ function getAuthorizeFormAction(
282
+ authority: Authority,
283
+ request: CommonAuthorizationUrlRequest,
284
+ parameters: Map<string, string>
285
+ ): string {
286
+ const queryParams = new Map<string, string>();
287
+ RequestParameterBuilder.addExtraParameters(
288
+ queryParams,
289
+ request.extraQueryParameters || {}
290
+ );
291
+ if (parameters.has(AADServerParamKeys.POPUP_ORIGIN_CHECK_DONE)) {
292
+ queryParams.delete(AADServerParamKeys.POPUP_ORIGIN_CHECK_DONE);
293
+ }
294
+ RequestParameterBuilder.addCorrelationId(
295
+ queryParams,
296
+ request.correlationId
297
+ );
298
+ return AuthorizeProtocol.getAuthorizeUrl(authority, queryParams);
299
+ }
300
+
270
301
  /**
271
302
  * Builds the action URL + POST-body fields for the EAR /authorize form.
272
303
  */
@@ -309,19 +340,7 @@ export async function getEARFormData(
309
340
  ...request.extraParameters,
310
341
  });
311
342
 
312
- const queryParams = new Map<string, string>();
313
- RequestParameterBuilder.addExtraParameters(
314
- queryParams,
315
- request.extraQueryParameters || {}
316
- );
317
-
318
- // Add correlationId to query params so gateway can propagate it to IDPs
319
- RequestParameterBuilder.addCorrelationId(
320
- queryParams,
321
- request.correlationId
322
- );
323
-
324
- const action = AuthorizeProtocol.getAuthorizeUrl(authority, queryParams);
343
+ const action = getAuthorizeFormAction(authority, request, parameters);
325
344
 
326
345
  return { action, fields: Object.fromEntries(parameters) };
327
346
  }
@@ -381,20 +400,7 @@ export async function getCodeFormData(
381
400
  ...request.extraParameters,
382
401
  });
383
402
 
384
- // Add extraQueryParameters to be appended to request URL
385
- const queryParams = new Map<string, string>();
386
- RequestParameterBuilder.addExtraParameters(
387
- queryParams,
388
- request.extraQueryParameters || {}
389
- );
390
-
391
- // Add correlationId to query params so gateway can propagate it to IDPs
392
- RequestParameterBuilder.addCorrelationId(
393
- queryParams,
394
- request.correlationId
395
- );
396
-
397
- const action = AuthorizeProtocol.getAuthorizeUrl(authority, queryParams);
403
+ const action = getAuthorizeFormAction(authority, request, parameters);
398
404
 
399
405
  return { action, fields: Object.fromEntries(parameters) };
400
406
  }
@@ -144,9 +144,16 @@ export function parseAuthResponseFromUrl(): {
144
144
  }
145
145
 
146
146
  /**
147
- * Clears hash from window url.
147
+ * Clears a recognized authentication response fragment, preserving the query string.
148
+ * Assigns an empty hash, then removes the trailing # when history updates are available.
148
149
  */
149
150
  export function clearHash(contentWindow: Window): void {
151
+ const serverParams = UrlUtils.getDeserializedResponse(
152
+ contentWindow.location.hash
153
+ );
154
+ if (!serverParams) {
155
+ return;
156
+ }
150
157
  // Office.js sets history.replaceState to null
151
158
  contentWindow.location.hash = "";
152
159
  if (typeof contentWindow.history.replaceState === "function") {
@@ -0,0 +1,98 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { AuthError, Constants, Logger } from "@azure/msal-common/browser";
7
+ import { clearAuthResponseFromUrl } from "./BrowserUtils.js";
8
+ import * as BrowserAuthErrorCodes from "../error/BrowserAuthErrorCodes.js";
9
+
10
+ export const IFRAME_POLL_INTERVAL_MS = 50;
11
+ export const DEFAULT_IFRAME_TIMEOUT_MS = 10000;
12
+
13
+ /**
14
+ * Monitors an iframe content window until it loads a URL with a known hash, or hits a specified timeout.
15
+ *
16
+ * @param iframe - The hidden iframe to monitor.
17
+ * @param timeout - Maximum time (ms) to wait for navigation before rejecting with
18
+ * `monitor_window_timeout`.
19
+ * @param logger - Logger instance.
20
+ * @param correlationId
21
+ * @param responseMode - `"query"` or `"fragment"` — determines whether to read
22
+ * `location.search` or `location.hash`. Any value other than `"query"` is
23
+ * treated as fragment.
24
+ */
25
+ export async function monitorIframeForHash(
26
+ iframe: HTMLIFrameElement,
27
+ timeout: number,
28
+ logger: Logger,
29
+ correlationId: string,
30
+ responseMode: string
31
+ ): Promise<string> {
32
+ return new Promise<string>((resolve, reject) => {
33
+ if (timeout < DEFAULT_IFRAME_TIMEOUT_MS) {
34
+ logger.warning(
35
+ `system.iframeBridgeTimeout set to lower (${timeout}ms) than the default (${DEFAULT_IFRAME_TIMEOUT_MS}ms). This may result in timeouts.`,
36
+ correlationId
37
+ );
38
+ }
39
+
40
+ /*
41
+ * Polling for iframes can be purely timing based,
42
+ * since we don't need to account for interaction.
43
+ */
44
+ const timeoutId = window.setTimeout(() => {
45
+ window.clearInterval(intervalId);
46
+ reject(
47
+ new AuthError(
48
+ BrowserAuthErrorCodes.timedOut,
49
+ correlationId,
50
+ undefined,
51
+ "monitor_window_timeout"
52
+ )
53
+ );
54
+ }, timeout);
55
+
56
+ const intervalId = window.setInterval(() => {
57
+ const contentWindow = iframe.contentWindow;
58
+ if (!contentWindow) {
59
+ return;
60
+ }
61
+
62
+ let href: string = "";
63
+ try {
64
+ /*
65
+ * Will throw if cross origin,
66
+ * which should be caught and ignored
67
+ * since we need the interval to keep running while on STS UI.
68
+ */
69
+ href = contentWindow.location.href;
70
+ } catch (e) {}
71
+
72
+ if (!href || href === "about:blank") {
73
+ return;
74
+ }
75
+
76
+ const responseString =
77
+ responseMode === Constants.ResponseMode.QUERY
78
+ ? contentWindow.location.search
79
+ : contentWindow.location.hash;
80
+ window.clearTimeout(timeoutId);
81
+ window.clearInterval(intervalId);
82
+ resolve(responseString);
83
+ }, IFRAME_POLL_INTERVAL_MS);
84
+ }).finally(() => {
85
+ /*
86
+ * Strip auth-response params from the iframe URL. The monitor owns the
87
+ * iframe for the duration of the poll, mirroring cleanPopup in
88
+ * PopupMonitor.
89
+ */
90
+ try {
91
+ if (iframe.contentWindow) {
92
+ clearAuthResponseFromUrl(iframe.contentWindow);
93
+ }
94
+ } catch {
95
+ // Iframe may already be navigated away or cross-origin; ignore.
96
+ }
97
+ });
98
+ }
@@ -0,0 +1,158 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { Constants, Logger } from "@azure/msal-common/browser";
7
+ import { BrowserAuthError } from "../error/BrowserAuthError.js";
8
+ import * as BrowserAuthErrorCodes from "../error/BrowserAuthErrorCodes.js";
9
+ import { clearAuthResponseFromUrl } from "./BrowserUtils.js";
10
+
11
+ export const POPUP_POLL_INTERVAL_MS = 30;
12
+
13
+ let activePopupPoller:
14
+ | { correlationId: string; cancel: () => void }
15
+ | undefined;
16
+ /**
17
+ * Cancels legacy popup polling when an interaction is superseded.
18
+ *
19
+ * @internal
20
+ * @param logger Logger for the interaction.
21
+ */
22
+ export function cancelPendingPopupPollingResponse(logger: Logger): void {
23
+ if (activePopupPoller) {
24
+ logger.verbose(
25
+ "PopupMonitor.cancelPendingPopupPollingResponse - Cancelling pending popup poller",
26
+ activePopupPoller.correlationId
27
+ );
28
+ activePopupPoller.cancel();
29
+ }
30
+ }
31
+
32
+ /**
33
+ * Monitors a popup window for a URL change to the same origin as the parent application.
34
+ * Polls the popup at a specified interval until it is redirected back to the application,
35
+ * closed by the user, or a navigation to a same-origin URL is detected. Once a same-origin
36
+ * URL is detected, extracts the response string (query or hash) and resolves the promise.
37
+ *
38
+ * @param popupWindow - The popup window to monitor for navigation.
39
+ * @param popupWindowParent - The parent window that opened the popup.
40
+ * @param responseMode - Response mode (`"query"` | `"fragment"`) determines whether
41
+ * to read `location.search` or `location.hash` from the popup once on the same
42
+ * origin. Any value other than `"query"` is treated as fragment.
43
+ * @param logger - Logger instance.
44
+ * @param unloadWindow - Event handler to remove from the parent window on cleanup.
45
+ * @param correlationId
46
+ */
47
+ export async function monitorPopupForHash(
48
+ popupWindow: Window,
49
+ popupWindowParent: Window,
50
+ responseMode: string,
51
+ logger: Logger,
52
+ unloadWindow: (e: Event) => void,
53
+ correlationId: string
54
+ ): Promise<string> {
55
+ let poller: { correlationId: string; cancel: () => void } | undefined;
56
+ return new Promise<string>((resolve, reject) => {
57
+ logger.verbose(
58
+ "PopupMonitor.monitorPopupForHash - polling started",
59
+ correlationId
60
+ );
61
+
62
+ const intervalId = window.setInterval(() => {
63
+ if (popupWindow.closed) {
64
+ logger.error(
65
+ "PopupMonitor.monitorPopupForHash - window closed",
66
+ correlationId
67
+ );
68
+ window.clearInterval(intervalId);
69
+ reject(
70
+ new BrowserAuthError(
71
+ BrowserAuthErrorCodes.userCancelled,
72
+ correlationId
73
+ )
74
+ );
75
+ return;
76
+ }
77
+
78
+ let href = "";
79
+ try {
80
+ /*
81
+ * Will throw if cross origin,
82
+ * which should be caught and ignored
83
+ * since we need the interval to keep running while on STS UI.
84
+ */
85
+ href = popupWindow.location.href;
86
+ } catch (e) {}
87
+
88
+ // Don't process blank pages or cross domain
89
+ if (!href || href === "about:blank") {
90
+ return;
91
+ }
92
+ window.clearInterval(intervalId);
93
+
94
+ let responseString: string;
95
+ if (responseMode === Constants.ResponseMode.QUERY) {
96
+ responseString = popupWindow.location.search;
97
+ } else {
98
+ responseString = popupWindow.location.hash;
99
+ }
100
+
101
+ logger.verbose(
102
+ "PopupMonitor.monitorPopupForHash - popup window is on same origin as caller",
103
+ correlationId
104
+ );
105
+
106
+ resolve(responseString);
107
+ }, POPUP_POLL_INTERVAL_MS);
108
+
109
+ poller = {
110
+ correlationId,
111
+ cancel: () => {
112
+ window.clearInterval(intervalId);
113
+ if (activePopupPoller === poller) {
114
+ activePopupPoller = undefined;
115
+ }
116
+ reject(
117
+ new BrowserAuthError(
118
+ BrowserAuthErrorCodes.interactionInProgressCancelled,
119
+ correlationId
120
+ )
121
+ );
122
+ },
123
+ };
124
+ activePopupPoller = poller;
125
+ }).finally(() => {
126
+ if (poller && activePopupPoller === poller) {
127
+ activePopupPoller = undefined;
128
+ }
129
+ cleanPopup(popupWindow, popupWindowParent, unloadWindow);
130
+ });
131
+ }
132
+
133
+ /**
134
+ * Performs cleanup operations after popup authentication.
135
+ * Strips auth-response params (code/state) from the popup URL while it is still
136
+ * open, closes the popup window, and removes the 'beforeunload' event listener
137
+ * from the parent window.
138
+ *
139
+ * @param popupWindow - The popup window to be closed.
140
+ * @param popupWindowParent - The parent window from which the event listener will be removed.
141
+ * @param unloadWindow - The event handler function to remove.
142
+ */
143
+ export function cleanPopup(
144
+ popupWindow: Window,
145
+ popupWindowParent: Window,
146
+ unloadWindow: (e: Event) => void
147
+ ): void {
148
+ if (!popupWindow.closed) {
149
+ try {
150
+ clearAuthResponseFromUrl(popupWindow);
151
+ } catch {
152
+ // Popup may have become cross-origin or otherwise inaccessible; ignore.
153
+ }
154
+ }
155
+ popupWindow.close();
156
+
157
+ popupWindowParent.removeEventListener("beforeunload", unloadWindow);
158
+ }
@@ -0,0 +1,94 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import type { BrowserConfiguration } from "../config/Configuration.js";
7
+
8
+ /**
9
+ * `window.origin` of a document with an opaque origin, e.g. one sandboxed
10
+ * without `allow-same-origin`. Read from `window.origin`, not
11
+ * `location.origin`, which reports the real host even when sandboxed.
12
+ */
13
+ const OPAQUE_ORIGIN = "null";
14
+
15
+ /**
16
+ * Returns `true` when every ancestor browsing context is same-origin with
17
+ * `win`. A top-level document has no ancestors, so it always passes.
18
+ */
19
+ export function allAncestorsSameOrigin(win: Window): boolean {
20
+ try {
21
+ // Sandboxed: no origin to compare ancestors against.
22
+ if (win.origin === OPAQUE_ORIGIN) {
23
+ return false;
24
+ }
25
+ let current: Window = win;
26
+ // `window.parent` is self-referential at the top level, never falsy.
27
+ while (current !== current.parent) {
28
+ current = current.parent;
29
+ // Throws SecurityError if this ancestor is cross-origin.
30
+ void current.location.href;
31
+ }
32
+ return true;
33
+ } catch {
34
+ return false;
35
+ }
36
+ }
37
+
38
+ /**
39
+ * Returns `true` when the top-level window has no opener, or one that is
40
+ * same-origin with it.
41
+ *
42
+ * Reads the opener from `win.top`, not `win`: a framed document always reports
43
+ * `window.opener === null` and would pass while the top window's untrusted
44
+ * opener still holds a handle on it.
45
+ */
46
+ export function topOpenerIsSameOriginOrAbsent(win: Window): boolean {
47
+ try {
48
+ const top = win.top;
49
+ if (!top) {
50
+ // Detached from its browsing context; treat as unsafe.
51
+ return false;
52
+ }
53
+
54
+ const opener = top.opener as Window | null | undefined;
55
+ if (!opener || opener === top) {
56
+ return true;
57
+ }
58
+
59
+ // Throws SecurityError if the opener is cross-origin.
60
+ void opener.location.href;
61
+ return true;
62
+ } catch {
63
+ return false;
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Computes the `pocd` ("popup origin check done") authorize parameter value.
69
+ *
70
+ * `1` means no untrusted window can reach the popup, which is what lets Entra
71
+ * omit the `Cross-Origin-Opener-Policy` response header for the request.
72
+ *
73
+ * @param config Resolved browser configuration.
74
+ * @param win Window whose hosting environment is being checked. Defaults to the app window.
75
+ * @returns `1` when the check passes, otherwise `0`.
76
+ */
77
+ export function computePocd(
78
+ config: BrowserConfiguration,
79
+ win: Window | undefined = typeof window !== "undefined" ? window : undefined
80
+ ): 0 | 1 {
81
+ /*
82
+ * Only an explicit false opts out; anything else computes the check, so an
83
+ * unresolved config fails closed rather than asserting pocd=1.
84
+ */
85
+ if (config.auth.originCheck === false) {
86
+ return 1;
87
+ }
88
+
89
+ if (!win || !allAncestorsSameOrigin(win)) {
90
+ return 0;
91
+ }
92
+
93
+ return topOpenerIsSameOriginOrAbsent(win) ? 1 : 0;
94
+ }
@@ -60,9 +60,10 @@ export declare class PublicClientApplication implements IPublicClientApplication
60
60
  /**
61
61
  * Waits for the auth response from a popup window opened by MSAL.
62
62
  *
63
- * The default implementation delegates to MSAL's `BroadcastChannel`-based bridge.
64
- * Subclasses must return the raw response string (hash/query/fragment), or reject
65
- * with an `AuthError` on failure.
63
+ * The default implementation delegates to MSAL's `BroadcastChannel`-based bridge,
64
+ * or to the v4-style same-origin location poller when
65
+ * `system.enableLegacyPolling` is set. Subclasses must return the raw response
66
+ * string (hash/query/fragment), or reject with an `AuthError` on failure.
66
67
  *
67
68
  * @internal
68
69
  * @param request The in-flight authorization or end-session request.
@@ -73,7 +74,8 @@ export declare class PublicClientApplication implements IPublicClientApplication
73
74
  /**
74
75
  * Waits for the auth response from a hidden iframe used by MSAL silent flows.
75
76
  *
76
- * The default implementation delegates to MSAL's `BroadcastChannel`-based bridge.
77
+ * The default implementation delegates to MSAL's `BroadcastChannel`-based bridge,
78
+ * or to the v4-style location poller when `system.enableLegacyPolling` is set.
77
79
  * Subclasses must return the raw response string (hash/query/fragment), or reject
78
80
  * with an `AuthError` on failure.
79
81
  *