@azure/msal-browser 5.29.0 → 5.30.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 (322) hide show
  1. package/dist/app/IPublicClientApplication.mjs +1 -1
  2. package/dist/app/PublicClientApplication.mjs +1 -1
  3. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  4. package/dist/broker/nativeBroker/PlatformAuthDOMHandler.mjs +1 -1
  5. package/dist/broker/nativeBroker/PlatformAuthExtensionHandler.mjs +1 -1
  6. package/dist/broker/nativeBroker/PlatformAuthProvider.mjs +1 -1
  7. package/dist/broker/nativeBroker/PlatformAuthRequest.mjs +1 -1
  8. package/dist/cache/AccountManager.mjs +1 -1
  9. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  10. package/dist/cache/BrowserCacheManager.mjs +2 -3
  11. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  12. package/dist/cache/CacheHelpers.mjs +1 -1
  13. package/dist/cache/CacheKeys.mjs +1 -1
  14. package/dist/cache/CookieStorage.mjs +1 -1
  15. package/dist/cache/DatabaseStorage.mjs +1 -1
  16. package/dist/cache/EncryptedData.mjs +1 -1
  17. package/dist/cache/LocalStorage.mjs +1 -1
  18. package/dist/cache/MemoryStorage.mjs +1 -1
  19. package/dist/cache/SessionStorage.mjs +1 -1
  20. package/dist/cache/TokenCache.mjs +1 -1
  21. package/dist/config/Configuration.mjs +11 -2
  22. package/dist/config/Configuration.mjs.map +1 -1
  23. package/dist/controllers/NestedAppAuthController.mjs +1 -1
  24. package/dist/controllers/StandardController.mjs +1 -1
  25. package/dist/crypto/BrowserCrypto.mjs +185 -3
  26. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  27. package/dist/crypto/CryptoOps.mjs +1 -1
  28. package/dist/crypto/PkceGenerator.mjs +1 -1
  29. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  30. package/dist/crypto/TokenBindingKeyManager.mjs +1 -1
  31. package/dist/custom_auth/CustomAuthConstants.mjs +1 -1
  32. package/dist/custom_auth/CustomAuthPublicClientApplication.mjs +1 -1
  33. package/dist/custom_auth/controller/CustomAuthStandardController.mjs +1 -1
  34. package/dist/custom_auth/core/CustomAuthAuthority.mjs +1 -1
  35. package/dist/custom_auth/core/auth_flow/AuthFlowErrorBase.mjs +1 -1
  36. package/dist/custom_auth/core/auth_flow/AuthFlowResultBase.mjs +1 -1
  37. package/dist/custom_auth/core/auth_flow/AuthFlowState.mjs +1 -1
  38. package/dist/custom_auth/core/auth_flow/AuthFlowStateTypes.mjs +1 -1
  39. package/dist/custom_auth/core/auth_flow/jit/error_type/AuthMethodRegistrationError.mjs +1 -1
  40. package/dist/custom_auth/core/auth_flow/jit/result/AuthMethodRegistrationChallengeMethodResult.mjs +1 -1
  41. package/dist/custom_auth/core/auth_flow/jit/result/AuthMethodRegistrationSubmitChallengeResult.mjs +1 -1
  42. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationCompletedState.mjs +1 -1
  43. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationFailedState.mjs +1 -1
  44. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationState.mjs +1 -1
  45. package/dist/custom_auth/core/auth_flow/mfa/error_type/MfaError.mjs +1 -1
  46. package/dist/custom_auth/core/auth_flow/mfa/result/MfaRequestChallengeResult.mjs +1 -1
  47. package/dist/custom_auth/core/auth_flow/mfa/result/MfaSubmitChallengeResult.mjs +1 -1
  48. package/dist/custom_auth/core/auth_flow/mfa/state/MfaCompletedState.mjs +1 -1
  49. package/dist/custom_auth/core/auth_flow/mfa/state/MfaFailedState.mjs +1 -1
  50. package/dist/custom_auth/core/auth_flow/mfa/state/MfaState.mjs +1 -1
  51. package/dist/custom_auth/core/auth_flow/v2/CustomAuthFlowScenarioV2.mjs +1 -1
  52. package/dist/custom_auth/core/auth_flow/v2/CustomAuthResultV2.mjs +1 -1
  53. package/dist/custom_auth/core/auth_flow/v2/error/AuthFlowErrorSubcodesV2.mjs +1 -1
  54. package/dist/custom_auth/core/auth_flow/v2/error/AuthFlowErrorV2.mjs +1 -1
  55. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodRegistrationRequiredStateV2.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/AuthMethodVerificationRequiredStateV2.mjs +1 -1
  58. package/dist/custom_auth/core/auth_flow/v2/state/ChallengeVerificationStateBaseV2.mjs +1 -1
  59. package/dist/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.mjs +1 -1
  60. package/dist/custom_auth/core/auth_flow/v2/state/CompletedStateV2.mjs +1 -1
  61. package/dist/custom_auth/core/auth_flow/v2/state/FailedStateV2.mjs +1 -1
  62. package/dist/custom_auth/core/auth_flow/v2/state/MFAVerificationRequiredStateV2.mjs +1 -1
  63. package/dist/custom_auth/core/auth_flow/v2/state/PasswordRequiredStateV2.mjs +1 -1
  64. package/dist/custom_auth/core/error/CustomAuthApiError.mjs +1 -1
  65. package/dist/custom_auth/core/error/CustomAuthError.mjs +1 -1
  66. package/dist/custom_auth/core/error/HttpError.mjs +1 -1
  67. package/dist/custom_auth/core/error/HttpErrorCodes.mjs +1 -1
  68. package/dist/custom_auth/core/error/InvalidArgumentError.mjs +1 -1
  69. package/dist/custom_auth/core/error/InvalidConfigurationError.mjs +1 -1
  70. package/dist/custom_auth/core/error/InvalidConfigurationErrorCodes.mjs +1 -1
  71. package/dist/custom_auth/core/error/MethodNotImplementedError.mjs +1 -1
  72. package/dist/custom_auth/core/error/MsalCustomAuthError.mjs +1 -1
  73. package/dist/custom_auth/core/error/NoCachedAccountFoundError.mjs +1 -1
  74. package/dist/custom_auth/core/error/ParsedUrlError.mjs +1 -1
  75. package/dist/custom_auth/core/error/ParsedUrlErrorCodes.mjs +1 -1
  76. package/dist/custom_auth/core/error/UnexpectedError.mjs +1 -1
  77. package/dist/custom_auth/core/error/UnsupportedEnvironmentError.mjs +1 -1
  78. package/dist/custom_auth/core/error/UserAccountAttributeError.mjs +1 -1
  79. package/dist/custom_auth/core/error/UserAlreadySignedInError.mjs +1 -1
  80. package/dist/custom_auth/core/interaction_client/CustomAuthInteractionClientBase.mjs +1 -1
  81. package/dist/custom_auth/core/interaction_client/CustomAuthInterationClientFactory.mjs +1 -1
  82. package/dist/custom_auth/core/interaction_client/jit/JitClient.mjs +1 -1
  83. package/dist/custom_auth/core/interaction_client/jit/result/JitActionResult.mjs +1 -1
  84. package/dist/custom_auth/core/interaction_client/mfa/MfaClient.mjs +1 -1
  85. package/dist/custom_auth/core/interaction_client/mfa/result/MfaActionResult.mjs +1 -1
  86. package/dist/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.mjs +1 -1
  87. package/dist/custom_auth/core/interaction_client/v2/InteractionClientBaseV2.mjs +1 -1
  88. package/dist/custom_auth/core/interaction_client/v2/result/FlowActionResultV2.mjs +1 -1
  89. package/dist/custom_auth/core/network_client/custom_auth_api/BaseApiClient.mjs +1 -1
  90. package/dist/custom_auth/core/network_client/custom_auth_api/CustomAuthApiClient.mjs +1 -1
  91. package/dist/custom_auth/core/network_client/custom_auth_api/CustomAuthApiEndpoint.mjs +1 -1
  92. package/dist/custom_auth/core/network_client/custom_auth_api/RegisterApiClient.mjs +1 -1
  93. package/dist/custom_auth/core/network_client/custom_auth_api/ResetPasswordApiClient.mjs +1 -1
  94. package/dist/custom_auth/core/network_client/custom_auth_api/SignInApiClient.mjs +1 -1
  95. package/dist/custom_auth/core/network_client/custom_auth_api/SignupApiClient.mjs +1 -1
  96. package/dist/custom_auth/core/network_client/custom_auth_api/types/ApiErrorCodes.mjs +1 -1
  97. package/dist/custom_auth/core/network_client/custom_auth_api/types/ApiSuberrors.mjs +1 -1
  98. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.mjs +1 -1
  99. package/dist/custom_auth/core/network_client/custom_auth_api/v2/BaseApiClientV2.mjs +1 -1
  100. package/dist/custom_auth/core/network_client/custom_auth_api/v2/CustomAuthApiClientV2.mjs +1 -1
  101. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ErrorCodesV2.mjs +1 -1
  102. package/dist/custom_auth/core/network_client/custom_auth_api/v2/HrefResolverV2.mjs +1 -1
  103. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.mjs +1 -1
  104. package/dist/custom_auth/core/network_client/custom_auth_api/v2/response/ErrorNormalizerV2.mjs +1 -1
  105. package/dist/custom_auth/core/network_client/custom_auth_api/v2/result/BaseResultsV2.mjs +1 -1
  106. package/dist/custom_auth/core/network_client/custom_auth_api/v2/result/SignUpResultsV2.mjs +1 -1
  107. package/dist/custom_auth/core/network_client/http_client/FetchHttpClient.mjs +1 -1
  108. package/dist/custom_auth/core/network_client/http_client/IHttpClient.mjs +1 -1
  109. package/dist/custom_auth/core/telemetry/FlowApiIdHelperV2.mjs +1 -1
  110. package/dist/custom_auth/core/telemetry/PublicApiId.mjs +1 -1
  111. package/dist/custom_auth/core/utils/ArgumentValidator.mjs +1 -1
  112. package/dist/custom_auth/core/utils/CustomHeaderUtils.mjs +1 -1
  113. package/dist/custom_auth/core/utils/UrlUtils.mjs +1 -1
  114. package/dist/custom_auth/get_account/auth_flow/CustomAuthAccountData.mjs +1 -1
  115. package/dist/custom_auth/get_account/auth_flow/error_type/GetAccountError.mjs +1 -1
  116. package/dist/custom_auth/get_account/auth_flow/result/GetAccessTokenResult.mjs +1 -1
  117. package/dist/custom_auth/get_account/auth_flow/result/GetAccountResult.mjs +1 -1
  118. package/dist/custom_auth/get_account/auth_flow/result/SignOutResult.mjs +1 -1
  119. package/dist/custom_auth/get_account/auth_flow/state/GetAccessTokenState.mjs +1 -1
  120. package/dist/custom_auth/get_account/auth_flow/state/GetAccountState.mjs +1 -1
  121. package/dist/custom_auth/get_account/auth_flow/state/SignOutState.mjs +1 -1
  122. package/dist/custom_auth/get_account/interaction_client/CustomAuthSilentCacheClient.mjs +1 -1
  123. package/dist/custom_auth/index.mjs +1 -1
  124. package/dist/custom_auth/operating_context/CustomAuthOperatingContext.mjs +1 -1
  125. package/dist/custom_auth/reset_password/auth_flow/error_type/ResetPasswordError.mjs +1 -1
  126. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordResendCodeResult.mjs +1 -1
  127. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordStartResult.mjs +1 -1
  128. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordSubmitCodeResult.mjs +1 -1
  129. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordSubmitPasswordResult.mjs +1 -1
  130. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordCodeRequiredState.mjs +1 -1
  131. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordCompletedState.mjs +1 -1
  132. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordFailedState.mjs +1 -1
  133. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordPasswordRequiredState.mjs +1 -1
  134. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordState.mjs +1 -1
  135. package/dist/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.mjs +1 -1
  136. package/dist/custom_auth/reset_password/auth_flow/v2/state/ResetPasswordStateTransitionHandlerV2.mjs +1 -1
  137. package/dist/custom_auth/reset_password/interaction_client/ResetPasswordClient.mjs +1 -1
  138. package/dist/custom_auth/sign_in/auth_flow/SignInScenario.mjs +1 -1
  139. package/dist/custom_auth/sign_in/auth_flow/error_type/SignInError.mjs +1 -1
  140. package/dist/custom_auth/sign_in/auth_flow/result/SignInResendCodeResult.mjs +1 -1
  141. package/dist/custom_auth/sign_in/auth_flow/result/SignInResult.mjs +1 -1
  142. package/dist/custom_auth/sign_in/auth_flow/result/SignInSubmitCodeResult.mjs +1 -1
  143. package/dist/custom_auth/sign_in/auth_flow/result/SignInSubmitPasswordResult.mjs +1 -1
  144. package/dist/custom_auth/sign_in/auth_flow/state/SignInCodeRequiredState.mjs +1 -1
  145. package/dist/custom_auth/sign_in/auth_flow/state/SignInCompletedState.mjs +1 -1
  146. package/dist/custom_auth/sign_in/auth_flow/state/SignInContinuationState.mjs +1 -1
  147. package/dist/custom_auth/sign_in/auth_flow/state/SignInFailedState.mjs +1 -1
  148. package/dist/custom_auth/sign_in/auth_flow/state/SignInPasswordRequiredState.mjs +1 -1
  149. package/dist/custom_auth/sign_in/auth_flow/state/SignInState.mjs +1 -1
  150. package/dist/custom_auth/sign_in/auth_flow/v2/state/SignInContinuationStateV2.mjs +1 -1
  151. package/dist/custom_auth/sign_in/auth_flow/v2/state/SignInStateTransitionHandlerV2.mjs +1 -1
  152. package/dist/custom_auth/sign_in/interaction_client/SignInClient.mjs +1 -1
  153. package/dist/custom_auth/sign_in/interaction_client/result/SignInActionResult.mjs +1 -1
  154. package/dist/custom_auth/sign_up/auth_flow/error_type/SignUpError.mjs +1 -1
  155. package/dist/custom_auth/sign_up/auth_flow/result/SignUpResendCodeResult.mjs +1 -1
  156. package/dist/custom_auth/sign_up/auth_flow/result/SignUpResult.mjs +1 -1
  157. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitAttributesResult.mjs +1 -1
  158. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitCodeResult.mjs +1 -1
  159. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitPasswordResult.mjs +1 -1
  160. package/dist/custom_auth/sign_up/auth_flow/state/SignUpAttributesRequiredState.mjs +1 -1
  161. package/dist/custom_auth/sign_up/auth_flow/state/SignUpCodeRequiredState.mjs +1 -1
  162. package/dist/custom_auth/sign_up/auth_flow/state/SignUpCompletedState.mjs +1 -1
  163. package/dist/custom_auth/sign_up/auth_flow/state/SignUpFailedState.mjs +1 -1
  164. package/dist/custom_auth/sign_up/auth_flow/state/SignUpPasswordRequiredState.mjs +1 -1
  165. package/dist/custom_auth/sign_up/auth_flow/state/SignUpState.mjs +1 -1
  166. package/dist/custom_auth/sign_up/auth_flow/v2/state/AttributesRequiredStateV2.mjs +1 -1
  167. package/dist/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountCodeRequiredStateV2.mjs +1 -1
  168. package/dist/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountPasswordRequiredStateV2.mjs +1 -1
  169. package/dist/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountStateTransitionHelperV2.mjs +1 -1
  170. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpStateTransitionHandlerV2.mjs +1 -1
  171. package/dist/custom_auth/sign_up/interaction_client/SignUpClient.mjs +1 -1
  172. package/dist/custom_auth/sign_up/interaction_client/result/SignUpActionResult.mjs +1 -1
  173. package/dist/encode/Base64Decode.mjs +1 -1
  174. package/dist/encode/Base64Encode.mjs +1 -1
  175. package/dist/error/BrowserAuthError.mjs +1 -1
  176. package/dist/error/BrowserAuthErrorCodes.mjs +3 -2
  177. package/dist/error/BrowserAuthErrorCodes.mjs.map +1 -1
  178. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  179. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  180. package/dist/error/NativeAuthError.mjs +1 -1
  181. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  182. package/dist/error/NestedAppAuthError.mjs +1 -1
  183. package/dist/event/EventHandler.mjs +1 -1
  184. package/dist/event/EventMessage.mjs +1 -1
  185. package/dist/event/EventType.mjs +1 -1
  186. package/dist/index.mjs +1 -1
  187. package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
  188. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  189. package/dist/interaction_client/PlatformAuthInteractionClient.mjs +1 -1
  190. package/dist/interaction_client/PopupClient.mjs +27 -21
  191. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  192. package/dist/interaction_client/RedirectClient.mjs +13 -11
  193. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  194. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  195. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  196. package/dist/interaction_client/SilentIframeClient.mjs +5 -8
  197. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  198. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  199. package/dist/interaction_client/StandardInteractionClient.mjs +5 -1
  200. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  201. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  202. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  203. package/dist/log-strings-mapping.json +701 -697
  204. package/dist/naa/BridgeError.mjs +1 -1
  205. package/dist/naa/BridgeProxy.mjs +1 -1
  206. package/dist/naa/BridgeStatusCode.mjs +1 -1
  207. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  208. package/dist/navigation/NavigationClient.mjs +1 -1
  209. package/dist/network/FetchClient.mjs +1 -1
  210. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  211. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  212. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  213. package/dist/packageMetadata.mjs +2 -2
  214. package/dist/popup_relay/constants.mjs +24 -6
  215. package/dist/popup_relay/constants.mjs.map +1 -1
  216. package/dist/popup_relay/index.mjs +142 -44
  217. package/dist/popup_relay/index.mjs.map +1 -1
  218. package/dist/popup_relay/relayClient.mjs +66 -23
  219. package/dist/popup_relay/relayClient.mjs.map +1 -1
  220. package/dist/protocol/Authorize.mjs +70 -13
  221. package/dist/protocol/Authorize.mjs.map +1 -1
  222. package/dist/redirect_bridge/index.mjs +1 -1
  223. package/dist/request/RequestHelpers.mjs +1 -1
  224. package/dist/request/SilentRequestHelpers.mjs +2 -1
  225. package/dist/request/SilentRequestHelpers.mjs.map +1 -1
  226. package/dist/response/ResponseHandler.mjs +1 -1
  227. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  228. package/dist/telemetry/BrowserPerformanceEvents.mjs +9 -2
  229. package/dist/telemetry/BrowserPerformanceEvents.mjs.map +1 -1
  230. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  231. package/dist/telemetry/BrowserRootPerformanceEvents.mjs +1 -1
  232. package/dist/utils/BrowserConstants.mjs +1 -1
  233. package/dist/utils/BrowserDetection.mjs +1 -1
  234. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  235. package/dist/utils/BrowserUtils.mjs +1 -1
  236. package/dist/utils/Helpers.mjs +1 -1
  237. package/dist/utils/IframeMonitor.mjs +1 -1
  238. package/dist/utils/MsalFrameStatsUtils.mjs +1 -1
  239. package/dist/utils/PopupMonitor.mjs +1 -1
  240. package/dist/utils/PopupOriginCheck.mjs +1 -1
  241. package/dist/webBrokerBridge/PendingRequestRegistry.mjs +1 -1
  242. package/dist/webBrokerBridge/PerfEventNames.mjs +1 -1
  243. package/dist/webBrokerBridge/WebBrokerBridgeError.mjs +1 -1
  244. package/dist/webBrokerBridge/WebBrokerBridgeErrorMap.mjs +1 -1
  245. package/dist/webBrokerBridge/adapter/CrossVersionRequestAdapter.mjs +1 -1
  246. package/dist/webBrokerBridge/index.mjs +1 -1
  247. package/lib/custom-auth-path/log-strings-mapping.json +13 -9
  248. package/lib/custom-auth-path/msal-custom-auth.cjs +519 -143
  249. package/lib/custom-auth-path/msal-custom-auth.cjs.map +1 -1
  250. package/lib/custom-auth-path/msal-custom-auth.js +519 -143
  251. package/lib/custom-auth-path/msal-custom-auth.js.map +1 -1
  252. package/lib/log-strings-mapping.json +13 -9
  253. package/lib/msal-browser.cjs +523 -145
  254. package/lib/msal-browser.cjs.map +1 -1
  255. package/lib/msal-browser.js +523 -145
  256. package/lib/msal-browser.js.map +1 -1
  257. package/lib/msal-browser.min.js +2 -2
  258. package/lib/popup-relay/msal-popup-relay.cjs +231 -60
  259. package/lib/popup-relay/msal-popup-relay.cjs.map +1 -1
  260. package/lib/popup-relay/msal-popup-relay.js +231 -60
  261. package/lib/popup-relay/msal-popup-relay.js.map +1 -1
  262. package/lib/popup-relay/msal-popup-relay.min.js +2 -2
  263. package/lib/redirect-bridge/msal-redirect-bridge.cjs +39 -10
  264. package/lib/redirect-bridge/msal-redirect-bridge.cjs.map +1 -1
  265. package/lib/redirect-bridge/msal-redirect-bridge.js +39 -10
  266. package/lib/redirect-bridge/msal-redirect-bridge.js.map +1 -1
  267. package/lib/redirect-bridge/msal-redirect-bridge.min.js +2 -2
  268. package/lib/web-broker-bridge/msal-web-broker-bridge.cjs +1 -1
  269. package/package.json +2 -2
  270. package/src/cache/BrowserCacheManager.ts +1 -5
  271. package/src/config/Configuration.ts +35 -0
  272. package/src/crypto/BrowserCrypto.ts +363 -0
  273. package/src/error/AsymmetricEarSubErrors.ts +18 -0
  274. package/src/error/BrowserAuthErrorCodes.ts +1 -0
  275. package/src/interaction_client/PopupClient.ts +59 -29
  276. package/src/interaction_client/RedirectClient.ts +15 -14
  277. package/src/interaction_client/SilentIframeClient.ts +9 -13
  278. package/src/interaction_client/StandardInteractionClient.ts +4 -0
  279. package/src/packageMetadata.ts +1 -1
  280. package/src/popup_relay/constants.ts +34 -3
  281. package/src/popup_relay/index.ts +200 -45
  282. package/src/popup_relay/relayClient.ts +108 -24
  283. package/src/protocol/Authorize.ts +118 -11
  284. package/src/request/PopupRequest.ts +1 -0
  285. package/src/request/RedirectRequest.ts +1 -0
  286. package/src/request/SilentRequestHelpers.ts +1 -0
  287. package/src/request/SsoSilentRequest.ts +1 -0
  288. package/src/telemetry/BrowserPerformanceEvents.ts +7 -0
  289. package/types/cache/BrowserCacheManager.d.ts.map +1 -1
  290. package/types/config/Configuration.d.ts +14 -0
  291. package/types/config/Configuration.d.ts.map +1 -1
  292. package/types/crypto/BrowserCrypto.d.ts +34 -0
  293. package/types/crypto/BrowserCrypto.d.ts.map +1 -1
  294. package/types/custom_auth/CustomAuthConstants.d.ts +1 -1
  295. package/types/error/AsymmetricEarSubErrors.d.ts +14 -0
  296. package/types/error/AsymmetricEarSubErrors.d.ts.map +1 -0
  297. package/types/error/BrowserAuthErrorCodes.d.ts +1 -0
  298. package/types/error/BrowserAuthErrorCodes.d.ts.map +1 -1
  299. package/types/interaction_client/PopupClient.d.ts +3 -1
  300. package/types/interaction_client/PopupClient.d.ts.map +1 -1
  301. package/types/interaction_client/RedirectClient.d.ts +0 -1
  302. package/types/interaction_client/RedirectClient.d.ts.map +1 -1
  303. package/types/interaction_client/SilentIframeClient.d.ts.map +1 -1
  304. package/types/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  305. package/types/packageMetadata.d.ts +1 -1
  306. package/types/popup_relay/constants.d.ts +10 -3
  307. package/types/popup_relay/constants.d.ts.map +1 -1
  308. package/types/popup_relay/index.d.ts +27 -11
  309. package/types/popup_relay/index.d.ts.map +1 -1
  310. package/types/popup_relay/relayClient.d.ts +9 -11
  311. package/types/popup_relay/relayClient.d.ts.map +1 -1
  312. package/types/protocol/Authorize.d.ts +5 -0
  313. package/types/protocol/Authorize.d.ts.map +1 -1
  314. package/types/request/PopupRequest.d.ts +1 -1
  315. package/types/request/PopupRequest.d.ts.map +1 -1
  316. package/types/request/RedirectRequest.d.ts +1 -1
  317. package/types/request/RedirectRequest.d.ts.map +1 -1
  318. package/types/request/SilentRequestHelpers.d.ts.map +1 -1
  319. package/types/request/SsoSilentRequest.d.ts +1 -1
  320. package/types/request/SsoSilentRequest.d.ts.map +1 -1
  321. package/types/telemetry/BrowserPerformanceEvents.d.ts +7 -0
  322. package/types/telemetry/BrowserPerformanceEvents.d.ts.map +1 -1
@@ -58,7 +58,6 @@ import * as ResponseHandler from "../response/ResponseHandler.js";
58
58
  import * as Authorize from "../protocol/Authorize.js";
59
59
  import { generatePkceCodes } from "../crypto/PkceGenerator.js";
60
60
  import { isPlatformAuthAllowed } from "../broker/nativeBroker/PlatformAuthProvider.js";
61
- import { generateEarKey } from "../crypto/BrowserCrypto.js";
62
61
  import { IPlatformAuthHandler } from "../broker/nativeBroker/IPlatformAuthHandler.js";
63
62
  import {
64
63
  clearCacheOnLogout,
@@ -346,13 +345,6 @@ export class RedirectClient extends StandardInteractionClient {
346
345
  account
347
346
  );
348
347
 
349
- const earJwk = await invokeAsync(
350
- generateEarKey,
351
- BrowserPerformanceEvents.GenerateEarKey,
352
- this.logger,
353
- this.performanceClient,
354
- correlationId
355
- )();
356
348
  const pkceCodes = await invokeAsync(
357
349
  generatePkceCodes,
358
350
  BrowserPerformanceEvents.GeneratePkceCodes,
@@ -367,14 +359,19 @@ export class RedirectClient extends StandardInteractionClient {
367
359
  this.logger,
368
360
  this.performanceClient
369
361
  );
370
- const redirectRequest = {
362
+ let redirectRequest: CommonAuthorizationUrlRequest = {
371
363
  ...request,
372
- earJwk: earJwk,
373
364
  codeChallenge: pkceCodes.challenge,
374
365
  ...tokenBindingParams,
375
366
  };
376
367
 
377
368
  try {
369
+ redirectRequest = await Authorize.initializeEarRequest(
370
+ this.config,
371
+ redirectRequest,
372
+ this.logger,
373
+ this.performanceClient
374
+ );
378
375
  if (
379
376
  !(await isTokenBindingKeyPersistedForRedirect(
380
377
  redirectRequest,
@@ -411,14 +408,15 @@ export class RedirectClient extends StandardInteractionClient {
411
408
  );
412
409
  }, this.config.system.redirectNavigationTimeout);
413
410
  });
414
- } catch (e) {
411
+ } catch (error) {
412
+ this.browserStorage.resetRequestCache(correlationId);
415
413
  await removeTokenBindingKeyOnFailure(
416
414
  redirectRequest,
417
415
  this.tokenBindingKeyManager,
418
416
  this.logger,
419
417
  this.performanceClient
420
418
  );
421
- throw e;
419
+ throw error;
422
420
  }
423
421
  }
424
422
 
@@ -813,7 +811,11 @@ export class RedirectClient extends StandardInteractionClient {
813
811
  this.logger,
814
812
  this.performanceClient,
815
813
  this.correlationId
816
- )({ serverTelemetryManager, requestAuthority: request.authority });
814
+ )({
815
+ serverTelemetryManager,
816
+ requestAuthority: request.authority,
817
+ requestExtraQueryParameters: request.extraQueryParameters,
818
+ });
817
819
  return invokeAsync(
818
820
  Authorize.handleResponseCode,
819
821
  BrowserPerformanceEvents.HandleResponseCode,
@@ -840,7 +842,6 @@ export class RedirectClient extends StandardInteractionClient {
840
842
  /**
841
843
  * Redirects window to given URL.
842
844
  * @param urlNavigate
843
- * @param onRedirectNavigateRequest - onRedirectNavigate callback provided on the request
844
845
  */
845
846
  async initiateAuthRequest(requestUrl: string): Promise<void> {
846
847
  this.logger.verbose(
@@ -55,7 +55,6 @@ import * as ResponseHandler from "../response/ResponseHandler.js";
55
55
  import * as Authorize from "../protocol/Authorize.js";
56
56
  import { generatePkceCodes } from "../crypto/PkceGenerator.js";
57
57
  import { isPlatformAuthAllowed } from "../broker/nativeBroker/PlatformAuthProvider.js";
58
- import { generateEarKey } from "../crypto/BrowserCrypto.js";
59
58
  import { IPlatformAuthHandler } from "../broker/nativeBroker/IPlatformAuthHandler.js";
60
59
  import {
61
60
  getDiscoveredAuthority,
@@ -305,13 +304,6 @@ export class SilentIframeClient extends StandardInteractionClient {
305
304
  account
306
305
  );
307
306
 
308
- const earJwk = await invokeAsync(
309
- generateEarKey,
310
- BrowserPerformanceEvents.GenerateEarKey,
311
- this.logger,
312
- this.performanceClient,
313
- correlationId
314
- )();
315
307
  const pkceCodes = await invokeAsync(
316
308
  generatePkceCodes,
317
309
  BrowserPerformanceEvents.GeneratePkceCodes,
@@ -319,11 +311,15 @@ export class SilentIframeClient extends StandardInteractionClient {
319
311
  this.performanceClient,
320
312
  correlationId
321
313
  )(this.performanceClient, this.logger, correlationId);
322
- const silentRequest = {
323
- ...request,
324
- earJwk: earJwk,
325
- codeChallenge: pkceCodes.challenge,
326
- };
314
+ const silentRequest = await Authorize.initializeEarRequest(
315
+ this.config,
316
+ {
317
+ ...request,
318
+ codeChallenge: pkceCodes.challenge,
319
+ },
320
+ this.logger,
321
+ this.performanceClient
322
+ );
327
323
 
328
324
  // Create the iframe, register the response listener, then navigate, so the listener is active before the iframe can respond.
329
325
  const iframe = createHiddenIframe();
@@ -284,6 +284,10 @@ export abstract class StandardInteractionClient extends BaseInteractionClient {
284
284
  clientId: this.config.auth.clientId,
285
285
  authority: discoveredAuthority,
286
286
  clientCapabilities: this.config.auth.clientCapabilities,
287
+ instanceAware: requestExtraQueryParameters?.instance_aware
288
+ ?.length
289
+ ? requestExtraQueryParameters.instance_aware === "true"
290
+ : this.config.auth.instanceAware,
287
291
  redirectUri: this.config.auth.redirectUri,
288
292
  isMcp: this.config.auth.isMcp,
289
293
  },
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable header/header */
2
2
  export const name = "@azure/msal-browser";
3
- export const version = "5.29.0";
3
+ export const version = "5.30.0";
@@ -3,15 +3,46 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ import {
7
+ BrowserAuthErrorCodes,
8
+ createBrowserAuthError,
9
+ } from "../error/BrowserAuthError.js";
10
+
6
11
  /**
7
12
  * postMessage envelope type used to relay an auth response from a popup-relay
8
13
  * page (see `runPopupRelay`) back to the embedded frame that opened it. See
9
14
  * {@link BrowserAuthOptions.popupRelayUri}.
10
15
  *
11
- * Kept dependency-free so both the relay-page entry (`./index.js`) and the
12
- * client-side helpers (`./relayClient.js`) can import it without either bundle
13
- * pulling in the other's dependencies.
16
+ * Shared by the relay-page entry and client helpers without importing either
17
+ * implementation into the other bundle.
14
18
  *
15
19
  * @internal
16
20
  */
17
21
  export const POPUP_RELAY_RESPONSE_TYPE = "msal:popup-relay-response:v1";
22
+
23
+ /** @internal Response bound to an authenticated v2 relay document. */
24
+ export const POPUP_RELAY_V2_RESPONSE_TYPE = "msal:popup-relay-response:v2";
25
+
26
+ /** @internal Ready signal for the authenticated popup-relay request handoff. */
27
+ export const POPUP_RELAY_READY_TYPE = "msal:popup-relay-ready:v2";
28
+
29
+ /** @internal Request delivered only to the same-origin relay window. */
30
+ export const POPUP_RELAY_REQUEST_TYPE = "msal:popup-relay-request:v2";
31
+
32
+ /** @internal Resolve the compatibility default without downgrading invalid versions. */
33
+ export function getPopupRelayProtocolVersion(
34
+ version: unknown,
35
+ correlationId: string = ""
36
+ ): 1 | 2 {
37
+ if (version === undefined) {
38
+ return 1;
39
+ }
40
+ if (version !== 1 && version !== 2) {
41
+ throw createBrowserAuthError(
42
+ BrowserAuthErrorCodes.popupRelayUnsupportedFlow,
43
+ correlationId,
44
+ "popup_relay_invalid_protocol"
45
+ );
46
+ }
47
+ return version;
48
+ }
@@ -3,16 +3,32 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { POPUP_RELAY_RESPONSE_TYPE } from "./constants.js";
7
6
  import {
7
+ POPUP_RELAY_READY_TYPE,
8
+ POPUP_RELAY_REQUEST_TYPE,
9
+ POPUP_RELAY_RESPONSE_TYPE,
10
+ POPUP_RELAY_V2_RESPONSE_TYPE,
11
+ getPopupRelayProtocolVersion,
12
+ } from "./constants.js";
13
+ import {
14
+ BrowserAuthError,
8
15
  BrowserAuthErrorCodes,
9
16
  createBrowserAuthError,
10
17
  } from "../error/BrowserAuthError.js";
11
18
  import { createForm } from "../protocol/Authorize.js";
12
19
  import { PopupWindowAttributes } from "../request/PopupWindowAttributes.js";
20
+ import { createNewGuid } from "../crypto/BrowserCrypto.js";
13
21
 
14
22
  /** Options for {@link runPopupRelay}. */
15
23
  export type PopupRelayOptions = {
24
+ /**
25
+ * Wire protocol accepted by this endpoint. Defaults to 1 to preserve
26
+ * existing relay deployments. Version 1 is deprecated due to security
27
+ * concerns: URL-fragment descriptors do not authenticate their provenance.
28
+ * Deploy a separate endpoint with version 2 for authenticated handoff,
29
+ * then retire the v1 endpoint.
30
+ */
31
+ protocolVersion?: 1 | 2;
16
32
  /**
17
33
  * Sizing/positioning for the IdP child popup the relay page opens. Same
18
34
  * shape as `PopupRequest.popupWindowAttributes` (`popupSize` with width and
@@ -37,7 +53,10 @@ export type PopupRelayOptions = {
37
53
  * **Optional — omitting it does not disable the relay.** The relay page
38
54
  * always rejects non-`https:` navigation targets; this option additionally
39
55
  * pins *which* https origins are acceptable. When omitted, any https origin
40
- * is allowed, which is how every existing relay page already behaves.
56
+ * is allowed. V1 is deprecated due to security concerns: it accepts
57
+ * unauthenticated fragment descriptors and retains the legacy
58
+ * arbitrary-navigation risk until the endpoint is retired. V2 requires an
59
+ * authenticated opener request even when this option is omitted.
41
60
  * Passing an explicitly empty array means "allow nothing" and will reject
42
61
  * every navigation.
43
62
  */
@@ -101,12 +120,10 @@ function normalizeAllowedOrigins(allowedAuthorityOrigins: string[]): string[] {
101
120
  }
102
121
 
103
122
  /**
104
- * Validates a navigation target taken from the relay page's hash before it can
123
+ * Validates a navigation target before it can
105
124
  * reach `window.open` or a form `action`.
106
125
  *
107
- * The hash is *not* authority: anyone can craft a link to the deployed relay
108
- * page, so a target must be proven safe rather than assumed to have been built
109
- * by MSAL. Only absolute `https:` URLs without embedded credentials are
126
+ * Only absolute `https:` URLs without embedded credentials are
110
127
  * accepted, which rules out active/local schemes (`javascript:`, `data:`,
111
128
  * `blob:`, `vbscript:`, `file:`) that would otherwise execute in — or read
112
129
  * from — the relay page's own first-party security origin. `https:`-only also
@@ -162,27 +179,20 @@ function validateNavigationTarget(
162
179
  }
163
180
 
164
181
  /**
165
- * Parses and fully validates the relayed request carried in the relay page's
166
- * hash. Every field is treated as attacker-controlled: the shape is checked
167
- * exactly (no implicit GET fallback for an unknown `method`) and both
182
+ * Fully validates a v1 descriptor or an authenticated v2 request. The shape
183
+ * is checked exactly (no implicit GET fallback for an unknown `method`) and both
168
184
  * navigation targets — the GET `url` and the POST `action` — are run through
169
185
  * {@link validateNavigationTarget}.
170
186
  */
171
187
  function parseRelayRequest(
172
- rawReq: string,
188
+ rawReq: unknown,
173
189
  allowedAuthorityOrigins?: string[]
174
190
  ): PopupRelayRequest {
175
- let parsed;
176
- try {
177
- parsed = JSON.parse(rawReq);
178
- } catch (e) {
179
- parsed = null;
180
- }
181
- if (typeof parsed !== "object" || parsed === null) {
191
+ if (typeof rawReq !== "object" || rawReq === null) {
182
192
  throwRelayError(BAD_REQUEST_SUBERROR);
183
193
  }
184
194
 
185
- const request = parsed as Record<string, unknown>;
195
+ const request = rawReq as Record<string, unknown>;
186
196
  const id = request.id;
187
197
  if (typeof id !== "string" || !id) {
188
198
  throwRelayError(BAD_REQUEST_SUBERROR);
@@ -245,17 +255,22 @@ function buildChildPopupFeatures(attributes?: PopupWindowAttributes): string {
245
255
  /**
246
256
  * Entry point for the top-level "popup-relay" page referenced by
247
257
  * `auth.popupRelayUri`. Call this from the relay page (which MSAL opens as a
248
- * top-level popup from inside an embedded, cross-origin iframe). It:
258
+ * top-level popup from inside an embedded, cross-origin iframe).
259
+ *
260
+ * V1 (the compatibility default) is deprecated due to security concerns. It
261
+ * executes validated but unauthenticated fragment descriptors and returns the
262
+ * legacy response envelope. It retains the legacy risk when origins are not
263
+ * pinned; retire that endpoint after migrating callers.
249
264
  *
250
- * 1. Reads the IdP navigation MSAL passed in this page's hash (a GET URL, or a
251
- * POST form for the form_post / EAR response modes), then scrubs the hash.
252
- * 2. Validates that navigation. The relay page is directly reachable, so the
253
- * hash is untrusted input: the request shape is checked exactly and the
254
- * navigation target must be an absolute `https:` URL (optionally pinned to
255
- * {@link PopupRelayOptions.allowedAuthorityOrigins}). Anything else — in
256
- * particular active schemes such as `javascript:` — is rejected before it
257
- * can reach `window.open` or a form `action`.
258
- * 3. Opens the IdP child popup and performs that navigation (the relay page
265
+ * V2 must be explicitly selected on both the app and its separate relay
266
+ * endpoint. It:
267
+ *
268
+ * 1. Reads the request id from the hash, then scrubs the hash. Navigation
269
+ * descriptors in the hash are never executed.
270
+ * 2. Reserves a blank child popup during the user gesture, then requests the
271
+ * navigation from the opener through an origin- and source-checked
272
+ * postMessage handoff bound to this relay document's nonce.
273
+ * 3. Validates and performs the authenticated navigation (the relay page
259
274
  * stays put, so its `window.opener` link back to the embedded frame
260
275
  * survives COOP).
261
276
  * 4. Waits for the child's redirect URI page (which must run the redirect
@@ -274,13 +289,33 @@ function buildChildPopupFeatures(attributes?: PopupWindowAttributes): string {
274
289
  * @param options - {@link PopupRelayOptions}
275
290
  */
276
291
  export function runPopupRelay(options?: PopupRelayOptions): void {
292
+ const protocolVersion = getPopupRelayProtocolVersion(
293
+ options?.protocolVersion
294
+ );
277
295
  const opener = window.opener as Window | null;
278
296
  const targetOrigin = window.location.origin;
279
297
 
280
298
  const hashParams = new URLSearchParams(
281
299
  window.location.hash.replace(/^#/, "")
282
300
  );
283
- const rawReq = hashParams.get("req") || "";
301
+ const incomingVersion = hashParams.has("id") ? 2 : 1;
302
+ let legacyDescriptor: unknown;
303
+ if (incomingVersion === 1) {
304
+ try {
305
+ legacyDescriptor = JSON.parse(hashParams.get("req") || "");
306
+ } catch {
307
+ legacyDescriptor = null;
308
+ }
309
+ }
310
+ let id: unknown = hashParams.get("id") || "";
311
+ if (
312
+ incomingVersion === 1 &&
313
+ legacyDescriptor &&
314
+ typeof legacyDescriptor === "object" &&
315
+ "id" in legacyDescriptor
316
+ ) {
317
+ id = legacyDescriptor.id;
318
+ }
284
319
 
285
320
  // Scrub the relayed request out of the relay page's own URL immediately.
286
321
  if (typeof window.history.replaceState === "function") {
@@ -299,15 +334,42 @@ export function runPopupRelay(options?: PopupRelayOptions): void {
299
334
  );
300
335
  }
301
336
 
302
- /*
303
- * Validate everything before opening anything: the relay page is directly
304
- * reachable, so the hash is attacker-controlled input, not authority.
305
- */
306
- const request = parseRelayRequest(rawReq, options?.allowedAuthorityOrigins);
337
+ if (typeof id !== "string" || !id) {
338
+ throwRelayError(BAD_REQUEST_SUBERROR);
339
+ }
307
340
 
308
- const id = request.id;
341
+ if (incomingVersion !== protocolVersion) {
342
+ const error = createBrowserAuthError(
343
+ BrowserAuthErrorCodes.popupRelayUnsupportedFlow,
344
+ "",
345
+ "popup_relay_protocol_mismatch"
346
+ );
347
+ opener.postMessage(
348
+ {
349
+ type:
350
+ incomingVersion === 1
351
+ ? POPUP_RELAY_RESPONSE_TYPE
352
+ : POPUP_RELAY_V2_RESPONSE_TYPE,
353
+ id,
354
+ error: error.errorCode,
355
+ subError: error.subError,
356
+ },
357
+ targetOrigin
358
+ );
359
+ throw error;
360
+ }
361
+
362
+ const legacyRequest =
363
+ protocolVersion === 1
364
+ ? parseRelayRequest(
365
+ legacyDescriptor,
366
+ options?.allowedAuthorityOrigins
367
+ )
368
+ : undefined;
369
+ const nonce = protocolVersion === 2 ? createNewGuid() : undefined;
309
370
  const channel = new BroadcastChannel(id);
310
371
  let settled = false;
372
+ let requestReceived = protocolVersion === 1;
311
373
  /*
312
374
  * Timer handles are kept on a const holder so relay() (declared before the
313
375
  * timers are created) can clear them — `let` handles trip prefer-const, and
@@ -318,7 +380,11 @@ export function runPopupRelay(options?: PopupRelayOptions): void {
318
380
  timeoutId?: number;
319
381
  } = {};
320
382
 
321
- const relay = (message: { payload?: string; error?: string }): void => {
383
+ const relay = (message: {
384
+ payload?: string;
385
+ error?: string;
386
+ subError?: string;
387
+ }): void => {
322
388
  if (settled) {
323
389
  return;
324
390
  }
@@ -330,8 +396,18 @@ export function runPopupRelay(options?: PopupRelayOptions): void {
330
396
  }
331
397
  clearInterval(timers.closedPoll);
332
398
  clearTimeout(timers.timeoutId);
399
+ window.removeEventListener("message", onRequest);
400
+ window.removeEventListener("pagehide", onPageHide);
333
401
  opener.postMessage(
334
- { type: POPUP_RELAY_RESPONSE_TYPE, id, ...message },
402
+ {
403
+ type:
404
+ protocolVersion === 1
405
+ ? POPUP_RELAY_RESPONSE_TYPE
406
+ : POPUP_RELAY_V2_RESPONSE_TYPE,
407
+ id,
408
+ ...(protocolVersion === 2 ? { nonce } : {}),
409
+ ...message,
410
+ },
335
411
  targetOrigin
336
412
  );
337
413
  setTimeout(() => {
@@ -346,29 +422,96 @@ export function runPopupRelay(options?: PopupRelayOptions): void {
346
422
  // The redirect bridge broadcasts the raw auth response payload here.
347
423
  channel.onmessage = (event: MessageEvent): void => {
348
424
  const payload = event.data && event.data.payload;
349
- if (payload) {
425
+ if (requestReceived && payload) {
350
426
  relay({ payload });
351
427
  }
352
428
  };
353
429
 
430
+ const onRequest = (event: MessageEvent): void => {
431
+ const data = event.data;
432
+ if (
433
+ settled ||
434
+ requestReceived ||
435
+ protocolVersion !== 2 ||
436
+ !childPopup ||
437
+ event.origin !== targetOrigin ||
438
+ event.source !== opener ||
439
+ !data ||
440
+ data.type !== POPUP_RELAY_REQUEST_TYPE ||
441
+ data.id !== id ||
442
+ data.nonce !== nonce
443
+ ) {
444
+ return;
445
+ }
446
+ window.removeEventListener("message", onRequest);
447
+ try {
448
+ const request = parseRelayRequest(
449
+ data.request,
450
+ options?.allowedAuthorityOrigins
451
+ );
452
+ if (request.id !== id) {
453
+ throwRelayError(BAD_REQUEST_SUBERROR);
454
+ }
455
+ requestReceived = true;
456
+ if (request.method === "GET") {
457
+ childPopup.location.replace(request.url);
458
+ } else {
459
+ createForm(
460
+ childPopup.document,
461
+ request.action,
462
+ request.fields
463
+ ).submit();
464
+ }
465
+ } catch (e) {
466
+ relay({
467
+ error:
468
+ e instanceof BrowserAuthError
469
+ ? e.errorCode
470
+ : BrowserAuthErrorCodes.popupWindowError,
471
+ subError:
472
+ e instanceof BrowserAuthError
473
+ ? e.subError
474
+ : "popup_relay_navigation_failed",
475
+ });
476
+ childPopup.close();
477
+ }
478
+ };
479
+
354
480
  const features = buildChildPopupFeatures(options?.popupWindowAttributes);
481
+ // Reserve a fresh window before the asynchronous handoff consumes activation.
355
482
  const childPopup =
356
- request.method === "POST"
357
- ? window.open("about:blank", "msalPopupRelayChild", features)
358
- : window.open(request.url, "msalPopupRelayChild", features);
483
+ legacyRequest?.method === "GET"
484
+ ? window.open(legacyRequest.url, "msalPopupRelayChild", features)
485
+ : window.open(
486
+ "about:blank",
487
+ protocolVersion === 1 ? "msalPopupRelayChild" : "_blank",
488
+ features
489
+ );
359
490
 
360
491
  if (!childPopup) {
361
492
  relay({ error: BrowserAuthErrorCodes.popupWindowError });
362
493
  return;
363
494
  }
364
495
 
365
- if (request.method === "POST") {
496
+ function onPageHide(): void {
497
+ settled = true;
498
+ window.removeEventListener("message", onRequest);
499
+ window.removeEventListener("pagehide", onPageHide);
500
+ clearInterval(timers.closedPoll);
501
+ clearTimeout(timers.timeoutId);
502
+ channel.close();
503
+ childPopup?.close();
504
+ }
505
+ if (protocolVersion === 2) {
506
+ window.addEventListener("message", onRequest);
507
+ } else if (legacyRequest?.method === "POST") {
366
508
  createForm(
367
509
  childPopup.document,
368
- request.action,
369
- request.fields
510
+ legacyRequest.action,
511
+ legacyRequest.fields
370
512
  ).submit();
371
513
  }
514
+ window.addEventListener("pagehide", onPageHide);
372
515
 
373
516
  timers.closedPoll = window.setInterval(() => {
374
517
  if (childPopup.closed && !settled) {
@@ -397,7 +540,19 @@ export function runPopupRelay(options?: PopupRelayOptions): void {
397
540
  } catch (e) {
398
541
  /* ignore */
399
542
  }
400
- relay({ error: BrowserAuthErrorCodes.timedOut });
543
+ relay({
544
+ error: BrowserAuthErrorCodes.timedOut,
545
+ subError: requestReceived
546
+ ? undefined
547
+ : "popup_relay_handshake_timeout",
548
+ });
401
549
  }
402
550
  }, options?.timeoutMs || DEFAULT_POPUP_RELAY_TIMEOUT_MS);
551
+
552
+ if (protocolVersion === 2) {
553
+ opener.postMessage(
554
+ { type: POPUP_RELAY_READY_TYPE, id, nonce },
555
+ targetOrigin
556
+ );
557
+ }
403
558
  }