@azure/msal-browser 5.25.1 → 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 (516) 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 +7 -2
  25. package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
  26. package/dist/controllers/StandardController.mjs +36 -5
  27. package/dist/controllers/StandardController.mjs.map +1 -1
  28. package/dist/crypto/BrowserCrypto.mjs +1 -1
  29. package/dist/crypto/CryptoOps.mjs +1 -1
  30. package/dist/crypto/PkceGenerator.mjs +1 -1
  31. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  32. package/dist/crypto/TokenBindingKeyManager.mjs +1 -1
  33. package/dist/custom_auth/CustomAuthConstants.mjs +1 -1
  34. package/dist/custom_auth/CustomAuthPublicClientApplication.mjs +1 -1
  35. package/dist/custom_auth/controller/CustomAuthStandardController.mjs +49 -19
  36. package/dist/custom_auth/controller/CustomAuthStandardController.mjs.map +1 -1
  37. package/dist/custom_auth/core/CustomAuthAuthority.mjs +1 -1
  38. package/dist/custom_auth/core/auth_flow/AuthFlowErrorBase.mjs +1 -1
  39. package/dist/custom_auth/core/auth_flow/AuthFlowResultBase.mjs +1 -1
  40. package/dist/custom_auth/core/auth_flow/AuthFlowState.mjs +1 -1
  41. package/dist/custom_auth/core/auth_flow/AuthFlowStateTypes.mjs +1 -1
  42. package/dist/custom_auth/core/auth_flow/jit/error_type/AuthMethodRegistrationError.mjs +1 -1
  43. package/dist/custom_auth/core/auth_flow/jit/result/AuthMethodRegistrationChallengeMethodResult.mjs +1 -1
  44. package/dist/custom_auth/core/auth_flow/jit/result/AuthMethodRegistrationSubmitChallengeResult.mjs +1 -1
  45. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationCompletedState.mjs +1 -1
  46. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationFailedState.mjs +1 -1
  47. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationState.mjs +1 -1
  48. package/dist/custom_auth/core/auth_flow/mfa/error_type/MfaError.mjs +1 -1
  49. package/dist/custom_auth/core/auth_flow/mfa/result/MfaRequestChallengeResult.mjs +1 -1
  50. package/dist/custom_auth/core/auth_flow/mfa/result/MfaSubmitChallengeResult.mjs +1 -1
  51. package/dist/custom_auth/core/auth_flow/mfa/state/MfaCompletedState.mjs +1 -1
  52. package/dist/custom_auth/core/auth_flow/mfa/state/MfaFailedState.mjs +1 -1
  53. package/dist/custom_auth/core/auth_flow/mfa/state/MfaState.mjs +1 -1
  54. package/dist/custom_auth/core/auth_flow/v2/CustomAuthFlowScenarioV2.mjs +1 -1
  55. package/dist/custom_auth/core/auth_flow/v2/CustomAuthResultV2.mjs +8 -7
  56. package/dist/custom_auth/core/auth_flow/v2/CustomAuthResultV2.mjs.map +1 -1
  57. package/dist/custom_auth/core/auth_flow/v2/error/AuthFlowErrorSubcodesV2.mjs +4 -3
  58. package/dist/custom_auth/core/auth_flow/v2/error/AuthFlowErrorSubcodesV2.mjs.map +1 -1
  59. package/dist/custom_auth/core/auth_flow/v2/error/AuthFlowErrorV2.mjs +174 -0
  60. package/dist/custom_auth/core/auth_flow/v2/error/AuthFlowErrorV2.mjs.map +1 -0
  61. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.mjs +67 -17
  62. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.mjs.map +1 -1
  63. package/dist/custom_auth/core/auth_flow/v2/state/ChallengeVerificationStateBaseV2.mjs +3 -4
  64. package/dist/custom_auth/core/auth_flow/v2/state/ChallengeVerificationStateBaseV2.mjs.map +1 -1
  65. package/dist/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.mjs +7 -15
  66. package/dist/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.mjs.map +1 -1
  67. package/dist/custom_auth/core/auth_flow/v2/state/CompletedStateV2.mjs +1 -1
  68. package/dist/custom_auth/core/auth_flow/v2/state/FailedStateV2.mjs +1 -1
  69. package/dist/custom_auth/core/auth_flow/v2/state/MFAVerificationRequiredStateV2.mjs +1 -5
  70. package/dist/custom_auth/core/auth_flow/v2/state/MFAVerificationRequiredStateV2.mjs.map +1 -1
  71. package/dist/custom_auth/core/error/CustomAuthApiError.mjs +3 -2
  72. package/dist/custom_auth/core/error/CustomAuthApiError.mjs.map +1 -1
  73. package/dist/custom_auth/core/error/CustomAuthError.mjs +1 -1
  74. package/dist/custom_auth/core/error/HttpError.mjs +1 -1
  75. package/dist/custom_auth/core/error/HttpErrorCodes.mjs +1 -1
  76. package/dist/custom_auth/core/error/InvalidArgumentError.mjs +1 -1
  77. package/dist/custom_auth/core/error/InvalidConfigurationError.mjs +1 -1
  78. package/dist/custom_auth/core/error/InvalidConfigurationErrorCodes.mjs +1 -1
  79. package/dist/custom_auth/core/error/MethodNotImplementedError.mjs +1 -1
  80. package/dist/custom_auth/core/error/MsalCustomAuthError.mjs +1 -1
  81. package/dist/custom_auth/core/error/NoCachedAccountFoundError.mjs +1 -1
  82. package/dist/custom_auth/core/error/ParsedUrlError.mjs +1 -1
  83. package/dist/custom_auth/core/error/ParsedUrlErrorCodes.mjs +1 -1
  84. package/dist/custom_auth/core/error/UnexpectedError.mjs +1 -1
  85. package/dist/custom_auth/core/error/UnsupportedEnvironmentError.mjs +1 -1
  86. package/dist/custom_auth/core/error/UserAccountAttributeError.mjs +1 -1
  87. package/dist/custom_auth/core/error/UserAlreadySignedInError.mjs +1 -1
  88. package/dist/custom_auth/core/interaction_client/CustomAuthInteractionClientBase.mjs +1 -1
  89. package/dist/custom_auth/core/interaction_client/CustomAuthInterationClientFactory.mjs +1 -1
  90. package/dist/custom_auth/core/interaction_client/jit/JitClient.mjs +1 -1
  91. package/dist/custom_auth/core/interaction_client/jit/result/JitActionResult.mjs +1 -1
  92. package/dist/custom_auth/core/interaction_client/mfa/MfaClient.mjs +1 -1
  93. package/dist/custom_auth/core/interaction_client/mfa/result/MfaActionResult.mjs +1 -1
  94. package/dist/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.mjs +61 -52
  95. package/dist/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.mjs.map +1 -1
  96. package/dist/custom_auth/core/interaction_client/v2/InteractionClientBaseV2.mjs +6 -3
  97. package/dist/custom_auth/core/interaction_client/v2/InteractionClientBaseV2.mjs.map +1 -1
  98. package/dist/custom_auth/core/interaction_client/v2/result/FlowActionResultV2.mjs +1 -1
  99. package/dist/custom_auth/core/network_client/custom_auth_api/BaseApiClient.mjs +1 -1
  100. package/dist/custom_auth/core/network_client/custom_auth_api/CustomAuthApiClient.mjs +1 -1
  101. package/dist/custom_auth/core/network_client/custom_auth_api/CustomAuthApiEndpoint.mjs +1 -1
  102. package/dist/custom_auth/core/network_client/custom_auth_api/RegisterApiClient.mjs +1 -1
  103. package/dist/custom_auth/core/network_client/custom_auth_api/ResetPasswordApiClient.mjs +1 -1
  104. package/dist/custom_auth/core/network_client/custom_auth_api/SignInApiClient.mjs +1 -1
  105. package/dist/custom_auth/core/network_client/custom_auth_api/SignupApiClient.mjs +1 -1
  106. package/dist/custom_auth/core/network_client/custom_auth_api/types/ApiErrorCodes.mjs +1 -1
  107. package/dist/custom_auth/core/network_client/custom_auth_api/types/ApiSuberrors.mjs +1 -1
  108. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.mjs +1 -2
  109. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.mjs.map +1 -1
  110. package/dist/custom_auth/core/network_client/custom_auth_api/v2/BaseApiClientV2.mjs +12 -10
  111. package/dist/custom_auth/core/network_client/custom_auth_api/v2/BaseApiClientV2.mjs.map +1 -1
  112. package/dist/custom_auth/core/network_client/custom_auth_api/v2/CustomAuthApiClientV2.mjs +1 -1
  113. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ErrorCodesV2.mjs +3 -3
  114. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ErrorCodesV2.mjs.map +1 -1
  115. package/dist/custom_auth/core/network_client/custom_auth_api/v2/HrefResolverV2.mjs +1 -1
  116. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.mjs +3 -7
  117. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.mjs.map +1 -1
  118. package/dist/custom_auth/core/network_client/custom_auth_api/v2/response/ErrorNormalizerV2.mjs +2 -1
  119. package/dist/custom_auth/core/network_client/custom_auth_api/v2/response/ErrorNormalizerV2.mjs.map +1 -1
  120. package/dist/custom_auth/core/network_client/custom_auth_api/v2/result/BaseResultsV2.mjs +1 -1
  121. package/dist/custom_auth/core/network_client/custom_auth_api/v2/result/SignUpResultsV2.mjs +1 -1
  122. package/dist/custom_auth/core/network_client/http_client/FetchHttpClient.mjs +1 -1
  123. package/dist/custom_auth/core/network_client/http_client/IHttpClient.mjs +1 -1
  124. package/dist/custom_auth/core/telemetry/FlowApiIdHelperV2.mjs +1 -1
  125. package/dist/custom_auth/core/telemetry/PublicApiId.mjs +1 -1
  126. package/dist/custom_auth/core/utils/ArgumentValidator.mjs +8 -2
  127. package/dist/custom_auth/core/utils/ArgumentValidator.mjs.map +1 -1
  128. package/dist/custom_auth/core/utils/CustomHeaderUtils.mjs +1 -1
  129. package/dist/custom_auth/core/utils/UrlUtils.mjs +1 -1
  130. package/dist/custom_auth/get_account/auth_flow/CustomAuthAccountData.mjs +1 -1
  131. package/dist/custom_auth/get_account/auth_flow/error_type/GetAccountError.mjs +1 -1
  132. package/dist/custom_auth/get_account/auth_flow/result/GetAccessTokenResult.mjs +1 -1
  133. package/dist/custom_auth/get_account/auth_flow/result/GetAccountResult.mjs +1 -1
  134. package/dist/custom_auth/get_account/auth_flow/result/SignOutResult.mjs +1 -1
  135. package/dist/custom_auth/get_account/auth_flow/state/GetAccessTokenState.mjs +1 -1
  136. package/dist/custom_auth/get_account/auth_flow/state/GetAccountState.mjs +1 -1
  137. package/dist/custom_auth/get_account/auth_flow/state/SignOutState.mjs +1 -1
  138. package/dist/custom_auth/get_account/interaction_client/CustomAuthSilentCacheClient.mjs +1 -1
  139. package/dist/custom_auth/index.mjs +2 -11
  140. package/dist/custom_auth/index.mjs.map +1 -1
  141. package/dist/custom_auth/operating_context/CustomAuthOperatingContext.mjs +1 -1
  142. package/dist/custom_auth/reset_password/auth_flow/error_type/ResetPasswordError.mjs +1 -1
  143. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordResendCodeResult.mjs +1 -1
  144. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordStartResult.mjs +1 -1
  145. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordSubmitCodeResult.mjs +1 -1
  146. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordSubmitPasswordResult.mjs +1 -1
  147. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordCodeRequiredState.mjs +1 -1
  148. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordCompletedState.mjs +1 -1
  149. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordFailedState.mjs +1 -1
  150. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordPasswordRequiredState.mjs +1 -1
  151. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordState.mjs +1 -1
  152. package/dist/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.mjs +1 -3
  153. package/dist/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.mjs.map +1 -1
  154. package/dist/custom_auth/reset_password/interaction_client/ResetPasswordClient.mjs +1 -1
  155. package/dist/custom_auth/sign_in/auth_flow/SignInScenario.mjs +1 -1
  156. package/dist/custom_auth/sign_in/auth_flow/error_type/SignInError.mjs +1 -1
  157. package/dist/custom_auth/sign_in/auth_flow/result/SignInResendCodeResult.mjs +1 -1
  158. package/dist/custom_auth/sign_in/auth_flow/result/SignInResult.mjs +1 -1
  159. package/dist/custom_auth/sign_in/auth_flow/result/SignInSubmitCodeResult.mjs +1 -1
  160. package/dist/custom_auth/sign_in/auth_flow/result/SignInSubmitPasswordResult.mjs +1 -1
  161. package/dist/custom_auth/sign_in/auth_flow/state/SignInCodeRequiredState.mjs +1 -1
  162. package/dist/custom_auth/sign_in/auth_flow/state/SignInCompletedState.mjs +1 -1
  163. package/dist/custom_auth/sign_in/auth_flow/state/SignInContinuationState.mjs +1 -1
  164. package/dist/custom_auth/sign_in/auth_flow/state/SignInFailedState.mjs +1 -1
  165. package/dist/custom_auth/sign_in/auth_flow/state/SignInPasswordRequiredState.mjs +1 -1
  166. package/dist/custom_auth/sign_in/auth_flow/state/SignInState.mjs +1 -1
  167. package/dist/custom_auth/sign_in/auth_flow/v2/state/PasswordRequiredStateV2.mjs +5 -5
  168. package/dist/custom_auth/sign_in/auth_flow/v2/state/PasswordRequiredStateV2.mjs.map +1 -1
  169. package/dist/custom_auth/sign_in/auth_flow/v2/state/SignInContinuationStateV2.mjs +5 -16
  170. package/dist/custom_auth/sign_in/auth_flow/v2/state/SignInContinuationStateV2.mjs.map +1 -1
  171. package/dist/custom_auth/sign_in/auth_flow/v2/state/SignInStateTransitionHandlerV2.mjs +35 -0
  172. package/dist/custom_auth/sign_in/auth_flow/v2/state/SignInStateTransitionHandlerV2.mjs.map +1 -0
  173. package/dist/custom_auth/sign_in/interaction_client/SignInClient.mjs +1 -1
  174. package/dist/custom_auth/sign_in/interaction_client/result/SignInActionResult.mjs +1 -1
  175. package/dist/custom_auth/sign_up/auth_flow/error_type/SignUpError.mjs +1 -1
  176. package/dist/custom_auth/sign_up/auth_flow/result/SignUpResendCodeResult.mjs +1 -1
  177. package/dist/custom_auth/sign_up/auth_flow/result/SignUpResult.mjs +1 -1
  178. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitAttributesResult.mjs +1 -1
  179. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitCodeResult.mjs +1 -1
  180. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitPasswordResult.mjs +1 -1
  181. package/dist/custom_auth/sign_up/auth_flow/state/SignUpAttributesRequiredState.mjs +1 -1
  182. package/dist/custom_auth/sign_up/auth_flow/state/SignUpCodeRequiredState.mjs +1 -1
  183. package/dist/custom_auth/sign_up/auth_flow/state/SignUpCompletedState.mjs +1 -1
  184. package/dist/custom_auth/sign_up/auth_flow/state/SignUpFailedState.mjs +1 -1
  185. package/dist/custom_auth/sign_up/auth_flow/state/SignUpPasswordRequiredState.mjs +1 -1
  186. package/dist/custom_auth/sign_up/auth_flow/state/SignUpState.mjs +1 -1
  187. package/dist/custom_auth/sign_up/auth_flow/v2/state/AttributesRequiredStateV2.mjs +1 -3
  188. package/dist/custom_auth/sign_up/auth_flow/v2/state/AttributesRequiredStateV2.mjs.map +1 -1
  189. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpAttributesRequiredStateBaseV2.mjs +1 -1
  190. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpPasswordRequiredStateV2.mjs +1 -3
  191. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpPasswordRequiredStateV2.mjs.map +1 -1
  192. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpStateTransitionHandlerV2.mjs +1 -1
  193. package/dist/custom_auth/sign_up/interaction_client/SignUpClient.mjs +1 -1
  194. package/dist/custom_auth/sign_up/interaction_client/result/SignUpActionResult.mjs +1 -1
  195. package/dist/encode/Base64Decode.mjs +1 -1
  196. package/dist/encode/Base64Encode.mjs +1 -1
  197. package/dist/error/BrowserAuthError.mjs +1 -1
  198. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  199. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  200. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  201. package/dist/error/NativeAuthError.mjs +1 -1
  202. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  203. package/dist/error/NestedAppAuthError.mjs +1 -1
  204. package/dist/event/EventHandler.mjs +1 -1
  205. package/dist/event/EventMessage.mjs +1 -1
  206. package/dist/event/EventType.mjs +1 -1
  207. package/dist/index.mjs +1 -1
  208. package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
  209. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  210. package/dist/interaction_client/PlatformAuthInteractionClient.mjs +1 -1
  211. package/dist/interaction_client/PopupClient.mjs +31 -3
  212. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  213. package/dist/interaction_client/RedirectClient.mjs +5 -5
  214. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  215. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  216. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  217. package/dist/interaction_client/SilentIframeClient.mjs +4 -3
  218. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  219. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  220. package/dist/interaction_client/StandardInteractionClient.mjs +7 -1
  221. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  222. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  223. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  224. package/dist/log-strings-mapping.json +27 -7
  225. package/dist/naa/BridgeError.mjs +1 -1
  226. package/dist/naa/BridgeProxy.mjs +1 -1
  227. package/dist/naa/BridgeStatusCode.mjs +1 -1
  228. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  229. package/dist/navigation/NavigationClient.mjs +1 -1
  230. package/dist/network/FetchClient.mjs +1 -1
  231. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  232. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  233. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  234. package/dist/packageMetadata.mjs +2 -2
  235. package/dist/popup_relay/constants.mjs +1 -1
  236. package/dist/popup_relay/index.mjs +1 -1
  237. package/dist/popup_relay/relayClient.mjs +1 -1
  238. package/dist/protocol/Authorize.mjs +23 -13
  239. package/dist/protocol/Authorize.mjs.map +1 -1
  240. package/dist/redirect_bridge/index.mjs +1 -1
  241. package/dist/request/RequestHelpers.mjs +1 -1
  242. package/dist/request/SilentRequestHelpers.mjs +9 -3
  243. package/dist/request/SilentRequestHelpers.mjs.map +1 -1
  244. package/dist/response/ResponseHandler.mjs +1 -1
  245. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  246. package/dist/telemetry/BrowserPerformanceEvents.mjs +1 -1
  247. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  248. package/dist/telemetry/BrowserRootPerformanceEvents.mjs +1 -1
  249. package/dist/utils/BrowserConstants.mjs +1 -1
  250. package/dist/utils/BrowserDetection.mjs +53 -0
  251. package/dist/utils/BrowserDetection.mjs.map +1 -0
  252. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  253. package/dist/utils/BrowserUtils.mjs +7 -2
  254. package/dist/utils/BrowserUtils.mjs.map +1 -1
  255. package/dist/utils/Helpers.mjs +1 -1
  256. package/dist/utils/IframeMonitor.mjs +81 -0
  257. package/dist/utils/IframeMonitor.mjs.map +1 -0
  258. package/dist/utils/MsalFrameStatsUtils.mjs +1 -1
  259. package/dist/utils/PopupMonitor.mjs +119 -0
  260. package/dist/utils/PopupMonitor.mjs.map +1 -0
  261. package/dist/utils/PopupOriginCheck.mjs +88 -0
  262. package/dist/utils/PopupOriginCheck.mjs.map +1 -0
  263. package/dist/webBrokerBridge/PendingRequestRegistry.mjs +1 -1
  264. package/dist/webBrokerBridge/PerfEventNames.mjs +1 -1
  265. package/dist/webBrokerBridge/WebBrokerBridgeError.mjs +1 -1
  266. package/dist/webBrokerBridge/WebBrokerBridgeErrorMap.mjs +1 -1
  267. package/dist/webBrokerBridge/adapter/CrossVersionRequestAdapter.mjs +1 -1
  268. package/dist/webBrokerBridge/index.mjs +1 -1
  269. package/lib/custom-auth-path/log-strings-mapping.json +27 -7
  270. package/lib/custom-auth-path/msal-custom-auth.cjs +1157 -718
  271. package/lib/custom-auth-path/msal-custom-auth.cjs.map +1 -1
  272. package/lib/custom-auth-path/msal-custom-auth.js +1157 -718
  273. package/lib/custom-auth-path/msal-custom-auth.js.map +1 -1
  274. package/lib/log-strings-mapping.json +27 -3
  275. package/lib/msal-browser.cjs +678 -134
  276. package/lib/msal-browser.cjs.map +1 -1
  277. package/lib/msal-browser.js +678 -134
  278. package/lib/msal-browser.js.map +1 -1
  279. package/lib/msal-browser.min.js +2 -2
  280. package/lib/popup-relay/msal-popup-relay.cjs +2 -2
  281. package/lib/popup-relay/msal-popup-relay.cjs.map +1 -1
  282. package/lib/popup-relay/msal-popup-relay.js +2 -2
  283. package/lib/popup-relay/msal-popup-relay.js.map +1 -1
  284. package/lib/popup-relay/msal-popup-relay.min.js +1 -1
  285. package/lib/redirect-bridge/msal-redirect-bridge.cjs +10 -10
  286. package/lib/redirect-bridge/msal-redirect-bridge.cjs.map +1 -1
  287. package/lib/redirect-bridge/msal-redirect-bridge.js +10 -10
  288. package/lib/redirect-bridge/msal-redirect-bridge.js.map +1 -1
  289. package/lib/redirect-bridge/msal-redirect-bridge.min.js +1 -1
  290. package/lib/web-broker-bridge/msal-web-broker-bridge.cjs +1 -1
  291. package/package.json +2 -2
  292. package/src/app/PublicClientApplication.ts +108 -8
  293. package/src/config/Configuration.ts +63 -6
  294. package/src/controllers/NestedAppAuthController.ts +6 -1
  295. package/src/controllers/StandardController.ts +46 -3
  296. package/src/custom_auth/CustomAuthActionInputs.ts +16 -6
  297. package/src/custom_auth/controller/CustomAuthStandardController.ts +78 -17
  298. package/src/custom_auth/core/auth_flow/v2/CustomAuthResultV2.ts +18 -30
  299. package/src/custom_auth/core/auth_flow/v2/error/AuthFlowErrorSubcodesV2.ts +1 -0
  300. package/src/custom_auth/core/auth_flow/v2/error/AuthFlowErrorV2.ts +239 -0
  301. package/src/custom_auth/core/auth_flow/v2/result/MFAResendChallengeResultV2.ts +2 -5
  302. package/src/custom_auth/core/auth_flow/v2/result/MFASubmitChallengeResultV2.ts +0 -2
  303. package/src/custom_auth/core/auth_flow/v2/result/RequestChallengeResultV2.ts +13 -10
  304. package/src/custom_auth/core/auth_flow/v2/result/ResendCodeResultV2.ts +19 -0
  305. package/src/custom_auth/core/auth_flow/v2/result/ResetPasswordStartResultV2.ts +3 -6
  306. package/src/custom_auth/core/auth_flow/v2/result/VerifyChallengeResultV2.ts +4 -6
  307. package/src/custom_auth/core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.ts +114 -17
  308. package/src/custom_auth/core/auth_flow/v2/state/ChallengeVerificationStateBaseV2.ts +6 -3
  309. package/src/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.ts +17 -19
  310. package/src/custom_auth/core/auth_flow/v2/state/CustomAuthStateParametersV2.ts +5 -5
  311. package/src/custom_auth/core/auth_flow/v2/state/MFAVerificationRequiredStateV2.ts +0 -4
  312. package/src/custom_auth/core/error/CustomAuthApiError.ts +2 -1
  313. package/src/custom_auth/core/interaction_client/v2/FlowContinuationStateV2.ts +3 -4
  314. package/src/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.ts +75 -68
  315. package/src/custom_auth/core/interaction_client/v2/InteractionClientBaseV2.ts +6 -3
  316. package/src/custom_auth/core/interaction_client/v2/parameter/FlowParamsV2.ts +2 -4
  317. package/src/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.ts +0 -1
  318. package/src/custom_auth/core/network_client/custom_auth_api/v2/BaseApiClientV2.ts +17 -15
  319. package/src/custom_auth/core/network_client/custom_auth_api/v2/ErrorCodesV2.ts +1 -1
  320. package/src/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.ts +3 -11
  321. package/src/custom_auth/core/network_client/custom_auth_api/v2/request/RequestsV2.ts +2 -3
  322. package/src/custom_auth/core/network_client/custom_auth_api/v2/response/ErrorNormalizerV2.ts +1 -0
  323. package/src/custom_auth/core/network_client/custom_auth_api/v2/response/ErrorResponsesV2.ts +2 -0
  324. package/src/custom_auth/core/network_client/custom_auth_api/v2/response/ResponsesV2.ts +1 -1
  325. package/src/custom_auth/core/utils/ArgumentValidator.ts +13 -0
  326. package/src/custom_auth/index.ts +4 -14
  327. package/src/custom_auth/reset_password/auth_flow/v2/result/SubmitNewPasswordResultV2.ts +6 -10
  328. package/src/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.ts +0 -2
  329. package/src/custom_auth/sign_in/auth_flow/v2/result/SignInContinuationResultV2.ts +3 -6
  330. package/src/custom_auth/sign_in/auth_flow/v2/result/SignInStartResultV2.ts +2 -4
  331. package/src/custom_auth/sign_in/auth_flow/v2/result/SubmitPasswordResultV2.ts +2 -4
  332. package/src/custom_auth/sign_in/auth_flow/v2/state/PasswordRequiredStateV2.ts +5 -4
  333. package/src/custom_auth/sign_in/auth_flow/v2/state/SignInContinuationStateV2.ts +4 -23
  334. package/src/custom_auth/sign_in/auth_flow/v2/state/SignInStateTransitionHandlerV2.ts +56 -0
  335. package/src/custom_auth/sign_up/auth_flow/v2/result/SignUpStartResultV2.ts +1 -5
  336. package/src/custom_auth/sign_up/auth_flow/v2/result/SubmitAttributesResultV2.ts +2 -5
  337. package/src/custom_auth/sign_up/auth_flow/v2/state/AttributesRequiredStateV2.ts +0 -2
  338. package/src/custom_auth/sign_up/auth_flow/v2/state/SignUpPasswordRequiredStateV2.ts +0 -2
  339. package/src/interaction_client/PopupClient.ts +45 -1
  340. package/src/interaction_client/RedirectClient.ts +9 -5
  341. package/src/interaction_client/SilentIframeClient.ts +9 -2
  342. package/src/interaction_client/StandardInteractionClient.ts +6 -0
  343. package/src/packageMetadata.ts +1 -1
  344. package/src/protocol/Authorize.ts +34 -28
  345. package/src/request/SilentRequestHelpers.ts +11 -2
  346. package/src/utils/BrowserDetection.ts +85 -0
  347. package/src/utils/BrowserUtils.ts +8 -1
  348. package/src/utils/IframeMonitor.ts +98 -0
  349. package/src/utils/PopupMonitor.ts +158 -0
  350. package/src/utils/PopupOriginCheck.ts +94 -0
  351. package/types/app/PublicClientApplication.d.ts +6 -4
  352. package/types/app/PublicClientApplication.d.ts.map +1 -1
  353. package/types/config/Configuration.d.ts +16 -0
  354. package/types/config/Configuration.d.ts.map +1 -1
  355. package/types/controllers/NestedAppAuthController.d.ts.map +1 -1
  356. package/types/controllers/StandardController.d.ts.map +1 -1
  357. package/types/custom_auth/CustomAuthActionInputs.d.ts +16 -5
  358. package/types/custom_auth/CustomAuthActionInputs.d.ts.map +1 -1
  359. package/types/custom_auth/CustomAuthConstants.d.ts +1 -1
  360. package/types/custom_auth/controller/CustomAuthStandardController.d.ts +1 -0
  361. package/types/custom_auth/controller/CustomAuthStandardController.d.ts.map +1 -1
  362. package/types/custom_auth/core/auth_flow/v2/CustomAuthResultV2.d.ts +9 -11
  363. package/types/custom_auth/core/auth_flow/v2/CustomAuthResultV2.d.ts.map +1 -1
  364. package/types/custom_auth/core/auth_flow/v2/error/AuthFlowErrorSubcodesV2.d.ts +1 -0
  365. package/types/custom_auth/core/auth_flow/v2/error/AuthFlowErrorSubcodesV2.d.ts.map +1 -1
  366. package/types/custom_auth/core/auth_flow/v2/error/AuthFlowErrorV2.d.ts +90 -0
  367. package/types/custom_auth/core/auth_flow/v2/error/AuthFlowErrorV2.d.ts.map +1 -0
  368. package/types/custom_auth/core/auth_flow/v2/result/MFAResendChallengeResultV2.d.ts +1 -2
  369. package/types/custom_auth/core/auth_flow/v2/result/MFAResendChallengeResultV2.d.ts.map +1 -1
  370. package/types/custom_auth/core/auth_flow/v2/result/MFASubmitChallengeResultV2.d.ts +1 -2
  371. package/types/custom_auth/core/auth_flow/v2/result/MFASubmitChallengeResultV2.d.ts.map +1 -1
  372. package/types/custom_auth/core/auth_flow/v2/result/RequestChallengeResultV2.d.ts +8 -7
  373. package/types/custom_auth/core/auth_flow/v2/result/RequestChallengeResultV2.d.ts.map +1 -1
  374. package/types/custom_auth/core/auth_flow/v2/result/ResendCodeResultV2.d.ts +13 -0
  375. package/types/custom_auth/core/auth_flow/v2/result/ResendCodeResultV2.d.ts.map +1 -0
  376. package/types/custom_auth/core/auth_flow/v2/result/ResetPasswordStartResultV2.d.ts +2 -3
  377. package/types/custom_auth/core/auth_flow/v2/result/ResetPasswordStartResultV2.d.ts.map +1 -1
  378. package/types/custom_auth/core/auth_flow/v2/result/VerifyChallengeResultV2.d.ts +5 -6
  379. package/types/custom_auth/core/auth_flow/v2/result/VerifyChallengeResultV2.d.ts.map +1 -1
  380. package/types/custom_auth/core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.d.ts +9 -6
  381. package/types/custom_auth/core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.d.ts.map +1 -1
  382. package/types/custom_auth/core/auth_flow/v2/state/ChallengeVerificationStateBaseV2.d.ts.map +1 -1
  383. package/types/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.d.ts +2 -2
  384. package/types/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.d.ts.map +1 -1
  385. package/types/custom_auth/core/auth_flow/v2/state/CustomAuthStateParametersV2.d.ts +5 -3
  386. package/types/custom_auth/core/auth_flow/v2/state/CustomAuthStateParametersV2.d.ts.map +1 -1
  387. package/types/custom_auth/core/auth_flow/v2/state/MFAVerificationRequiredStateV2.d.ts.map +1 -1
  388. package/types/custom_auth/core/error/CustomAuthApiError.d.ts +2 -1
  389. package/types/custom_auth/core/error/CustomAuthApiError.d.ts.map +1 -1
  390. package/types/custom_auth/core/interaction_client/v2/FlowContinuationStateV2.d.ts +1 -3
  391. package/types/custom_auth/core/interaction_client/v2/FlowContinuationStateV2.d.ts.map +1 -1
  392. package/types/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.d.ts +2 -2
  393. package/types/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.d.ts.map +1 -1
  394. package/types/custom_auth/core/interaction_client/v2/InteractionClientBaseV2.d.ts +2 -2
  395. package/types/custom_auth/core/interaction_client/v2/InteractionClientBaseV2.d.ts.map +1 -1
  396. package/types/custom_auth/core/interaction_client/v2/parameter/FlowParamsV2.d.ts +2 -4
  397. package/types/custom_auth/core/interaction_client/v2/parameter/FlowParamsV2.d.ts.map +1 -1
  398. package/types/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.d.ts +0 -1
  399. package/types/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.d.ts.map +1 -1
  400. package/types/custom_auth/core/network_client/custom_auth_api/v2/BaseApiClientV2.d.ts +2 -2
  401. package/types/custom_auth/core/network_client/custom_auth_api/v2/BaseApiClientV2.d.ts.map +1 -1
  402. package/types/custom_auth/core/network_client/custom_auth_api/v2/ErrorCodesV2.d.ts +1 -1
  403. package/types/custom_auth/core/network_client/custom_auth_api/v2/ErrorCodesV2.d.ts.map +1 -1
  404. package/types/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.d.ts.map +1 -1
  405. package/types/custom_auth/core/network_client/custom_auth_api/v2/request/RequestsV2.d.ts +1 -2
  406. package/types/custom_auth/core/network_client/custom_auth_api/v2/request/RequestsV2.d.ts.map +1 -1
  407. package/types/custom_auth/core/network_client/custom_auth_api/v2/response/ErrorResponsesV2.d.ts +2 -0
  408. package/types/custom_auth/core/network_client/custom_auth_api/v2/response/ErrorResponsesV2.d.ts.map +1 -1
  409. package/types/custom_auth/core/network_client/custom_auth_api/v2/response/ResponsesV2.d.ts +1 -1
  410. package/types/custom_auth/core/network_client/custom_auth_api/v2/response/ResponsesV2.d.ts.map +1 -1
  411. package/types/custom_auth/core/utils/ArgumentValidator.d.ts +1 -0
  412. package/types/custom_auth/core/utils/ArgumentValidator.d.ts.map +1 -1
  413. package/types/custom_auth/index.d.ts +3 -12
  414. package/types/custom_auth/index.d.ts.map +1 -1
  415. package/types/custom_auth/reset_password/auth_flow/v2/result/SubmitNewPasswordResultV2.d.ts +5 -7
  416. package/types/custom_auth/reset_password/auth_flow/v2/result/SubmitNewPasswordResultV2.d.ts.map +1 -1
  417. package/types/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.d.ts.map +1 -1
  418. package/types/custom_auth/sign_in/auth_flow/v2/result/SignInContinuationResultV2.d.ts +4 -6
  419. package/types/custom_auth/sign_in/auth_flow/v2/result/SignInContinuationResultV2.d.ts.map +1 -1
  420. package/types/custom_auth/sign_in/auth_flow/v2/result/SignInStartResultV2.d.ts +3 -4
  421. package/types/custom_auth/sign_in/auth_flow/v2/result/SignInStartResultV2.d.ts.map +1 -1
  422. package/types/custom_auth/sign_in/auth_flow/v2/result/SubmitPasswordResultV2.d.ts +3 -4
  423. package/types/custom_auth/sign_in/auth_flow/v2/result/SubmitPasswordResultV2.d.ts.map +1 -1
  424. package/types/custom_auth/sign_in/auth_flow/v2/state/PasswordRequiredStateV2.d.ts.map +1 -1
  425. package/types/custom_auth/sign_in/auth_flow/v2/state/SignInContinuationStateV2.d.ts +4 -9
  426. package/types/custom_auth/sign_in/auth_flow/v2/state/SignInContinuationStateV2.d.ts.map +1 -1
  427. package/types/custom_auth/sign_in/auth_flow/v2/state/SignInStateTransitionHandlerV2.d.ts +9 -0
  428. package/types/custom_auth/sign_in/auth_flow/v2/state/SignInStateTransitionHandlerV2.d.ts.map +1 -0
  429. package/types/custom_auth/sign_up/auth_flow/v2/result/SignUpStartResultV2.d.ts +1 -2
  430. package/types/custom_auth/sign_up/auth_flow/v2/result/SignUpStartResultV2.d.ts.map +1 -1
  431. package/types/custom_auth/sign_up/auth_flow/v2/result/SubmitAttributesResultV2.d.ts +1 -2
  432. package/types/custom_auth/sign_up/auth_flow/v2/result/SubmitAttributesResultV2.d.ts.map +1 -1
  433. package/types/custom_auth/sign_up/auth_flow/v2/state/AttributesRequiredStateV2.d.ts.map +1 -1
  434. package/types/custom_auth/sign_up/auth_flow/v2/state/SignUpPasswordRequiredStateV2.d.ts.map +1 -1
  435. package/types/interaction_client/PopupClient.d.ts +12 -0
  436. package/types/interaction_client/PopupClient.d.ts.map +1 -1
  437. package/types/interaction_client/RedirectClient.d.ts.map +1 -1
  438. package/types/interaction_client/SilentIframeClient.d.ts.map +1 -1
  439. package/types/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  440. package/types/packageMetadata.d.ts +1 -1
  441. package/types/protocol/Authorize.d.ts.map +1 -1
  442. package/types/request/SilentRequestHelpers.d.ts +1 -1
  443. package/types/request/SilentRequestHelpers.d.ts.map +1 -1
  444. package/types/utils/BrowserDetection.d.ts +17 -0
  445. package/types/utils/BrowserDetection.d.ts.map +1 -0
  446. package/types/utils/BrowserUtils.d.ts +2 -1
  447. package/types/utils/BrowserUtils.d.ts.map +1 -1
  448. package/types/utils/IframeMonitor.d.ts +17 -0
  449. package/types/utils/IframeMonitor.d.ts.map +1 -0
  450. package/types/utils/PopupMonitor.d.ts +37 -0
  451. package/types/utils/PopupMonitor.d.ts.map +1 -0
  452. package/types/utils/PopupOriginCheck.d.ts +27 -0
  453. package/types/utils/PopupOriginCheck.d.ts.map +1 -0
  454. package/dist/custom_auth/core/auth_flow/v2/error/AuthFlowErrorBaseV2.mjs +0 -102
  455. package/dist/custom_auth/core/auth_flow/v2/error/AuthFlowErrorBaseV2.mjs.map +0 -1
  456. package/dist/custom_auth/core/auth_flow/v2/error/RequestChallengeErrorV2.mjs +0 -20
  457. package/dist/custom_auth/core/auth_flow/v2/error/RequestChallengeErrorV2.mjs.map +0 -1
  458. package/dist/custom_auth/core/auth_flow/v2/error/ResetPasswordStartErrorV2.mjs +0 -36
  459. package/dist/custom_auth/core/auth_flow/v2/error/ResetPasswordStartErrorV2.mjs.map +0 -1
  460. package/dist/custom_auth/core/auth_flow/v2/error/VerifyChallengeErrorV2.mjs +0 -29
  461. package/dist/custom_auth/core/auth_flow/v2/error/VerifyChallengeErrorV2.mjs.map +0 -1
  462. package/dist/custom_auth/core/auth_flow/v2/state/AuthenticationMethodSelectionStateBaseV2.mjs +0 -36
  463. package/dist/custom_auth/core/auth_flow/v2/state/AuthenticationMethodSelectionStateBaseV2.mjs.map +0 -1
  464. package/dist/custom_auth/core/auth_flow/v2/state/MFARequiredStateV2.mjs +0 -61
  465. package/dist/custom_auth/core/auth_flow/v2/state/MFARequiredStateV2.mjs.map +0 -1
  466. package/dist/custom_auth/reset_password/auth_flow/v2/error_type/SubmitNewPasswordErrorV2.mjs +0 -29
  467. package/dist/custom_auth/reset_password/auth_flow/v2/error_type/SubmitNewPasswordErrorV2.mjs.map +0 -1
  468. package/dist/custom_auth/sign_in/auth_flow/v2/error_type/SignInContinuationErrorV2.mjs +0 -18
  469. package/dist/custom_auth/sign_in/auth_flow/v2/error_type/SignInContinuationErrorV2.mjs.map +0 -1
  470. package/dist/custom_auth/sign_in/auth_flow/v2/error_type/SignInStartErrorV2.mjs +0 -37
  471. package/dist/custom_auth/sign_in/auth_flow/v2/error_type/SignInStartErrorV2.mjs.map +0 -1
  472. package/dist/custom_auth/sign_in/auth_flow/v2/error_type/SubmitPasswordErrorV2.mjs +0 -23
  473. package/dist/custom_auth/sign_in/auth_flow/v2/error_type/SubmitPasswordErrorV2.mjs.map +0 -1
  474. package/dist/custom_auth/sign_up/auth_flow/v2/error_type/SignUpStartErrorV2.mjs +0 -25
  475. package/dist/custom_auth/sign_up/auth_flow/v2/error_type/SignUpStartErrorV2.mjs.map +0 -1
  476. package/dist/custom_auth/sign_up/auth_flow/v2/error_type/SubmitAttributesErrorV2.mjs +0 -33
  477. package/dist/custom_auth/sign_up/auth_flow/v2/error_type/SubmitAttributesErrorV2.mjs.map +0 -1
  478. package/src/custom_auth/core/auth_flow/v2/error/AuthFlowErrorBaseV2.ts +0 -146
  479. package/src/custom_auth/core/auth_flow/v2/error/RequestChallengeErrorV2.ts +0 -15
  480. package/src/custom_auth/core/auth_flow/v2/error/ResetPasswordStartErrorV2.ts +0 -33
  481. package/src/custom_auth/core/auth_flow/v2/error/VerifyChallengeErrorV2.ts +0 -25
  482. package/src/custom_auth/core/auth_flow/v2/result/MFARequestChallengeResultV2.ts +0 -18
  483. package/src/custom_auth/core/auth_flow/v2/state/AuthenticationMethodSelectionStateBaseV2.ts +0 -59
  484. package/src/custom_auth/core/auth_flow/v2/state/MFARequiredStateV2.ts +0 -76
  485. package/src/custom_auth/reset_password/auth_flow/v2/error_type/SubmitNewPasswordErrorV2.ts +0 -25
  486. package/src/custom_auth/sign_in/auth_flow/v2/error_type/SignInContinuationErrorV2.ts +0 -13
  487. package/src/custom_auth/sign_in/auth_flow/v2/error_type/SignInStartErrorV2.ts +0 -35
  488. package/src/custom_auth/sign_in/auth_flow/v2/error_type/SubmitPasswordErrorV2.ts +0 -19
  489. package/src/custom_auth/sign_up/auth_flow/v2/error_type/SignUpStartErrorV2.ts +0 -21
  490. package/src/custom_auth/sign_up/auth_flow/v2/error_type/SubmitAttributesErrorV2.ts +0 -32
  491. package/types/custom_auth/core/auth_flow/v2/error/AuthFlowErrorBaseV2.d.ts +0 -40
  492. package/types/custom_auth/core/auth_flow/v2/error/AuthFlowErrorBaseV2.d.ts.map +0 -1
  493. package/types/custom_auth/core/auth_flow/v2/error/RequestChallengeErrorV2.d.ts +0 -11
  494. package/types/custom_auth/core/auth_flow/v2/error/RequestChallengeErrorV2.d.ts.map +0 -1
  495. package/types/custom_auth/core/auth_flow/v2/error/ResetPasswordStartErrorV2.d.ts +0 -23
  496. package/types/custom_auth/core/auth_flow/v2/error/ResetPasswordStartErrorV2.d.ts.map +0 -1
  497. package/types/custom_auth/core/auth_flow/v2/error/VerifyChallengeErrorV2.d.ts +0 -18
  498. package/types/custom_auth/core/auth_flow/v2/error/VerifyChallengeErrorV2.d.ts.map +0 -1
  499. package/types/custom_auth/core/auth_flow/v2/result/MFARequestChallengeResultV2.d.ts +0 -7
  500. package/types/custom_auth/core/auth_flow/v2/result/MFARequestChallengeResultV2.d.ts.map +0 -1
  501. package/types/custom_auth/core/auth_flow/v2/state/AuthenticationMethodSelectionStateBaseV2.d.ts +0 -17
  502. package/types/custom_auth/core/auth_flow/v2/state/AuthenticationMethodSelectionStateBaseV2.d.ts.map +0 -1
  503. package/types/custom_auth/core/auth_flow/v2/state/MFARequiredStateV2.d.ts +0 -18
  504. package/types/custom_auth/core/auth_flow/v2/state/MFARequiredStateV2.d.ts.map +0 -1
  505. package/types/custom_auth/reset_password/auth_flow/v2/error_type/SubmitNewPasswordErrorV2.d.ts +0 -18
  506. package/types/custom_auth/reset_password/auth_flow/v2/error_type/SubmitNewPasswordErrorV2.d.ts.map +0 -1
  507. package/types/custom_auth/sign_in/auth_flow/v2/error_type/SignInContinuationErrorV2.d.ts +0 -9
  508. package/types/custom_auth/sign_in/auth_flow/v2/error_type/SignInContinuationErrorV2.d.ts.map +0 -1
  509. package/types/custom_auth/sign_in/auth_flow/v2/error_type/SignInStartErrorV2.d.ts +0 -22
  510. package/types/custom_auth/sign_in/auth_flow/v2/error_type/SignInStartErrorV2.d.ts.map +0 -1
  511. package/types/custom_auth/sign_in/auth_flow/v2/error_type/SubmitPasswordErrorV2.d.ts +0 -12
  512. package/types/custom_auth/sign_in/auth_flow/v2/error_type/SubmitPasswordErrorV2.d.ts.map +0 -1
  513. package/types/custom_auth/sign_up/auth_flow/v2/error_type/SignUpStartErrorV2.d.ts +0 -14
  514. package/types/custom_auth/sign_up/auth_flow/v2/error_type/SignUpStartErrorV2.d.ts.map +0 -1
  515. package/types/custom_auth/sign_up/auth_flow/v2/error_type/SubmitAttributesErrorV2.d.ts +0 -20
  516. package/types/custom_auth/sign_up/auth_flow/v2/error_type/SubmitAttributesErrorV2.d.ts.map +0 -1
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v5.25.1 2026-10-13 */
1
+ /*! @azure/msal-browser v5.27.0 2026-10-27 */
2
2
  'use strict';
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
@@ -6,7 +6,7 @@
6
6
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.msalCustomAuth = {}));
7
7
  })(this, (function (exports) { 'use strict';
8
8
 
9
- /*! @azure/msal-common v16.14.2 2026-10-13 */
9
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
10
10
  /*
11
11
  * Copyright (c) Microsoft Corporation. All rights reserved.
12
12
  * Licensed under the MIT License.
@@ -58,9 +58,15 @@
58
58
  const EAR_JWE_CRYPTO = "ear_jwe_crypto";
59
59
  const RESOURCE = "resource";
60
60
  const CLI_DATA = "clidata";
61
- const ATTRIBUTE_TOKENS = "attribute_tokens";
61
+ const ATTRIBUTE_TOKENS = "attribute_tokens";
62
+ /**
63
+ * Popup-origin-check-done. Signals to the STS that the client verified the
64
+ * popup cannot be reached by an untrusted window, so the
65
+ * Cross-Origin-Opener-Policy response header may be omitted.
66
+ */
67
+ const POPUP_ORIGIN_CHECK_DONE = "pocd";
62
68
 
63
- /*! @azure/msal-common v16.14.2 2026-10-13 */
69
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
64
70
  /*
65
71
  * Copyright (c) Microsoft Corporation. All rights reserved.
66
72
  * Licensed under the MIT License.
@@ -294,7 +300,7 @@
294
300
  // Token renewal offset default in seconds
295
301
  const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
296
302
 
297
- /*! @azure/msal-common v16.14.2 2026-10-13 */
303
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
298
304
  /*
299
305
  * Copyright (c) Microsoft Corporation. All rights reserved.
300
306
  * Licensed under the MIT License.
@@ -323,7 +329,7 @@
323
329
  return new AuthError(code, correlationId, additionalMessage || getDefaultErrorMessage$1(code));
324
330
  }
325
331
 
326
- /*! @azure/msal-common v16.14.2 2026-10-13 */
332
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
327
333
 
328
334
  /*
329
335
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -346,7 +352,7 @@
346
352
  return new ClientAuthError(errorCode, correlationId, additionalMessage);
347
353
  }
348
354
 
349
- /*! @azure/msal-common v16.14.2 2026-10-13 */
355
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
350
356
  /*
351
357
  * Copyright (c) Microsoft Corporation. All rights reserved.
352
358
  * Licensed under the MIT License.
@@ -384,7 +390,7 @@
384
390
  const resourceParameterRequired = "resource_parameter_required";
385
391
  const misplacedResourceParam = "misplaced_resource_parameter";
386
392
 
387
- /*! @azure/msal-common v16.14.2 2026-10-13 */
393
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
388
394
 
389
395
  /*
390
396
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -422,7 +428,7 @@
422
428
  };
423
429
  }
424
430
 
425
- /*! @azure/msal-common v16.14.2 2026-10-13 */
431
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
426
432
 
427
433
  /*
428
434
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -488,7 +494,7 @@
488
494
  return matches[2];
489
495
  }
490
496
 
491
- /*! @azure/msal-common v16.14.2 2026-10-13 */
497
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
492
498
 
493
499
  /*
494
500
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -576,7 +582,7 @@
576
582
  return updatedAccountInfo;
577
583
  }
578
584
 
579
- /*! @azure/msal-common v16.14.2 2026-10-13 */
585
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
580
586
  /*
581
587
  * Copyright (c) Microsoft Corporation. All rights reserved.
582
588
  * Licensed under the MIT License.
@@ -590,7 +596,7 @@
590
596
  Ciam: 3,
591
597
  };
592
598
 
593
- /*! @azure/msal-common v16.14.2 2026-10-13 */
599
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
594
600
  /*
595
601
  * Copyright (c) Microsoft Corporation. All rights reserved.
596
602
  * Licensed under the MIT License.
@@ -612,7 +618,7 @@
612
618
  return null;
613
619
  }
614
620
 
615
- /*! @azure/msal-common v16.14.2 2026-10-13 */
621
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
616
622
  /*
617
623
  * Copyright (c) Microsoft Corporation. All rights reserved.
618
624
  * Licensed under the MIT License.
@@ -636,7 +642,7 @@
636
642
  EAR: "EAR",
637
643
  };
638
644
 
639
- /*! @azure/msal-common v16.14.2 2026-10-13 */
645
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
640
646
  /**
641
647
  * Returns the AccountInfo interface for this account.
642
648
  * @internal
@@ -825,7 +831,7 @@
825
831
  entity.hasOwnProperty("authorityType"));
826
832
  }
827
833
 
828
- /*! @azure/msal-common v16.14.2 2026-10-13 */
834
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
829
835
  /*
830
836
  * Copyright (c) Microsoft Corporation. All rights reserved.
831
837
  * Licensed under the MIT License.
@@ -835,7 +841,7 @@
835
841
  */
836
842
  const unexpectedError = "unexpected_error";
837
843
 
838
- /*! @azure/msal-common v16.14.2 2026-10-13 */
844
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
839
845
 
840
846
  /*
841
847
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -855,7 +861,47 @@
855
861
  return new ClientConfigurationError(errorCode, correlationId);
856
862
  }
857
863
 
858
- /*! @azure/msal-common v16.14.2 2026-10-13 */
864
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
865
+ /*
866
+ * Copyright (c) Microsoft Corporation. All rights reserved.
867
+ * Licensed under the MIT License.
868
+ */
869
+ // Track only our normalized copies, never caller-owned mutable inputs.
870
+ const normalizedHeaderRecords = new WeakSet();
871
+ /**
872
+ * Creates a lowercase-keyed snapshot without changing header values or the input.
873
+ * Reuses snapshots produced by this function to avoid repeated normalization.
874
+ * @internal
875
+ */
876
+ function normalizeResponseHeaders(headers) {
877
+ if (normalizedHeaderRecords.has(headers)) {
878
+ return headers;
879
+ }
880
+ const normalized = Object.fromEntries(Object.entries(headers).map(([name, value]) => [
881
+ name.toLowerCase(),
882
+ value,
883
+ ]));
884
+ normalizedHeaderRecords.add(normalized);
885
+ return normalized;
886
+ }
887
+ /**
888
+ * Reads a response header case-insensitively.
889
+ * Normalized snapshots are never scanned, even when a header is missing.
890
+ * @internal
891
+ */
892
+ function getResponseHeader(headers, name) {
893
+ const key = name.toLowerCase();
894
+ if (Object.prototype.hasOwnProperty.call(headers, key)) {
895
+ return headers[key];
896
+ }
897
+ if (normalizedHeaderRecords.has(headers)) {
898
+ return undefined;
899
+ }
900
+ const headerName = Object.keys(headers).find((header) => header.toLowerCase() === key);
901
+ return headerName === undefined ? undefined : headers[headerName];
902
+ }
903
+
904
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
859
905
  /*
860
906
  * Copyright (c) Microsoft Corporation. All rights reserved.
861
907
  * Licensed under the MIT License.
@@ -886,7 +932,7 @@
886
932
  const invalidDpopNonce = "invalid_dpop_nonce";
887
933
  const dpopMissingResourceContext = "dpop_missing_resource_context";
888
934
 
889
- /*! @azure/msal-common v16.14.2 2026-10-13 */
935
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
890
936
  /*
891
937
  * Copyright (c) Microsoft Corporation. All rights reserved.
892
938
  * Licensed under the MIT License.
@@ -898,7 +944,7 @@
898
944
  response.hasOwnProperty("jwks_uri"));
899
945
  }
900
946
 
901
- /*! @azure/msal-common v16.14.2 2026-10-13 */
947
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
902
948
  /*
903
949
  * Copyright (c) Microsoft Corporation. All rights reserved.
904
950
  * Licensed under the MIT License.
@@ -978,7 +1024,7 @@
978
1024
  }
979
1025
  }
980
1026
 
981
- /*! @azure/msal-common v16.14.2 2026-10-13 */
1027
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
982
1028
 
983
1029
  /*
984
1030
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1136,7 +1182,7 @@
1136
1182
  }
1137
1183
  }
1138
1184
 
1139
- /*! @azure/msal-common v16.14.2 2026-10-13 */
1185
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
1140
1186
 
1141
1187
  /*
1142
1188
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1290,7 +1336,7 @@
1290
1336
  return null;
1291
1337
  }
1292
1338
 
1293
- /*! @azure/msal-common v16.14.2 2026-10-13 */
1339
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
1294
1340
  /*
1295
1341
  * Copyright (c) Microsoft Corporation. All rights reserved.
1296
1342
  * Licensed under the MIT License.
@@ -1299,7 +1345,7 @@
1299
1345
  // AzureCloudInstance is not specified.
1300
1346
  None: "none"};
1301
1347
 
1302
- /*! @azure/msal-common v16.14.2 2026-10-13 */
1348
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
1303
1349
  /*
1304
1350
  * Copyright (c) Microsoft Corporation. All rights reserved.
1305
1351
  * Licensed under the MIT License.
@@ -1309,7 +1355,7 @@
1309
1355
  response.hasOwnProperty("metadata"));
1310
1356
  }
1311
1357
 
1312
- /*! @azure/msal-common v16.14.2 2026-10-13 */
1358
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
1313
1359
  /*
1314
1360
  * Copyright (c) Microsoft Corporation. All rights reserved.
1315
1361
  * Licensed under the MIT License.
@@ -1319,7 +1365,7 @@
1319
1365
  response.hasOwnProperty("error_description"));
1320
1366
  }
1321
1367
 
1322
- /*! @azure/msal-common v16.14.2 2026-10-13 */
1368
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
1323
1369
  /*
1324
1370
  * Copyright (c) Microsoft Corporation. All rights reserved.
1325
1371
  * Licensed under the MIT License.
@@ -1390,7 +1436,7 @@
1390
1436
  const CacheManagerGetRefreshToken = "cacheManagerGetRefreshToken";
1391
1437
  const SetUserData = "setUserData";
1392
1438
 
1393
- /*! @azure/msal-common v16.14.2 2026-10-13 */
1439
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
1394
1440
  /*
1395
1441
  * Copyright (c) Microsoft Corporation. All rights reserved.
1396
1442
  * Licensed under the MIT License.
@@ -1483,7 +1529,7 @@
1483
1529
  };
1484
1530
  };
1485
1531
 
1486
- /*! @azure/msal-common v16.14.2 2026-10-13 */
1532
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
1487
1533
 
1488
1534
  /*
1489
1535
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1594,7 +1640,7 @@
1594
1640
  },
1595
1641
  };
1596
1642
 
1597
- /*! @azure/msal-common v16.14.2 2026-10-13 */
1643
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
1598
1644
  /*
1599
1645
  * Copyright (c) Microsoft Corporation. All rights reserved.
1600
1646
  * Licensed under the MIT License.
@@ -1659,7 +1705,7 @@
1659
1705
  return cachedAtSec > nowSeconds();
1660
1706
  }
1661
1707
 
1662
- /*! @azure/msal-common v16.14.2 2026-10-13 */
1708
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
1663
1709
 
1664
1710
  /*
1665
1711
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1946,7 +1992,7 @@
1946
1992
  return [...attributeTokens].sort().join(" ");
1947
1993
  }
1948
1994
 
1949
- /*! @azure/msal-common v16.14.2 2026-10-13 */
1995
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
1950
1996
 
1951
1997
  /*
1952
1998
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2914,7 +2960,7 @@
2914
2960
  };
2915
2961
  }
2916
2962
 
2917
- /*! @azure/msal-common v16.14.2 2026-10-13 */
2963
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
2918
2964
 
2919
2965
  /*
2920
2966
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2948,7 +2994,7 @@
2948
2994
  }
2949
2995
  }
2950
2996
 
2951
- /*! @azure/msal-common v16.14.2 2026-10-13 */
2997
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
2952
2998
 
2953
2999
  /*
2954
3000
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3144,7 +3190,7 @@
3144
3190
  }
3145
3191
  }
3146
3192
 
3147
- /*! @azure/msal-common v16.14.2 2026-10-13 */
3193
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
3148
3194
 
3149
3195
  /*
3150
3196
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3425,6 +3471,20 @@
3425
3471
  parameters.set(INSTANCE_AWARE, "true");
3426
3472
  }
3427
3473
  }
3474
+ /**
3475
+ * Adds `pocd=1`, telling the STS that the client verified the popup driving
3476
+ * this request cannot be reached by an untrusted window, so the
3477
+ * Cross-Origin-Opener-Policy response header may be omitted.
3478
+ *
3479
+ * Only ever added when the check passed — a negative result is signalled by
3480
+ * omitting the parameter, which keeps the STS default (apply COOP) and stays
3481
+ * compatible with library versions that never send it.
3482
+ */
3483
+ function addPopupOriginCheckDone(parameters) {
3484
+ if (!parameters.has(POPUP_ORIGIN_CHECK_DONE)) {
3485
+ parameters.set(POPUP_ORIGIN_CHECK_DONE, "1");
3486
+ }
3487
+ }
3428
3488
  /**
3429
3489
  * Add extraParameters
3430
3490
  * @param extraParams - String dictionary containing extra parameters to be added.
@@ -3630,7 +3690,7 @@
3630
3690
  }
3631
3691
  }
3632
3692
 
3633
- /*! @azure/msal-common v16.14.2 2026-10-13 */
3693
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
3634
3694
 
3635
3695
  /*
3636
3696
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3651,7 +3711,8 @@
3651
3711
  return responseString;
3652
3712
  }
3653
3713
  /**
3654
- * Returns URL hash as server auth code response object.
3714
+ * Returns flat fragment or query parameters as an authorization response.
3715
+ * Application routes and unrecognized responses return null.
3655
3716
  */
3656
3717
  function getDeserializedResponse(responseString) {
3657
3718
  // Check if given hash is empty
@@ -3661,7 +3722,15 @@
3661
3722
  try {
3662
3723
  // Strip the # or ? symbol if present
3663
3724
  const normalizedResponse = stripLeadingHashOrQuery(responseString);
3664
- // If # symbol was not present, above will return empty string, so give original hash value
3725
+ /*
3726
+ * Require a flat parameter name, not an application route.
3727
+ * Reject routes like #/dashboard?tab=orders&code=... and
3728
+ * #/dashboard/orders&state=..., where ?, /, or # appears before
3729
+ * the first = or &. These characters are allowed in parameter values.
3730
+ */
3731
+ if (!/^[^=&?#/]+(?:=|&|$)/.test(normalizedResponse)) {
3732
+ return null;
3733
+ }
3665
3734
  const deserializedHash = Object.fromEntries(new URLSearchParams(normalizedResponse));
3666
3735
  // Check for known response properties
3667
3736
  if (deserializedHash.code ||
@@ -3752,7 +3821,7 @@
3752
3821
  }
3753
3822
  }
3754
3823
 
3755
- /*! @azure/msal-common v16.14.2 2026-10-13 */
3824
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
3756
3825
 
3757
3826
  /*
3758
3827
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3800,7 +3869,7 @@
3800
3869
  },
3801
3870
  };
3802
3871
 
3803
- /*! @azure/msal-common v16.14.2 2026-10-13 */
3872
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
3804
3873
 
3805
3874
  /*
3806
3875
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3823,7 +3892,7 @@
3823
3892
  },
3824
3893
  };
3825
3894
 
3826
- /*! @azure/msal-common v16.14.2 2026-10-13 */
3895
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
3827
3896
  /*
3828
3897
  * Copyright (c) Microsoft Corporation. All rights reserved.
3829
3898
  * Licensed under the MIT License.
@@ -4098,12 +4167,12 @@
4098
4167
  }
4099
4168
  }
4100
4169
 
4101
- /*! @azure/msal-common v16.14.2 2026-10-13 */
4170
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
4102
4171
  /* eslint-disable header/header */
4103
4172
  const name$1 = "@azure/msal-common";
4104
- const version$1 = "16.14.2";
4173
+ const version$1 = "16.15.0";
4105
4174
 
4106
- /*! @azure/msal-common v16.14.2 2026-10-13 */
4175
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
4107
4176
  /*
4108
4177
  * Copyright (c) Microsoft Corporation. All rights reserved.
4109
4178
  * Licensed under the MIT License.
@@ -4111,7 +4180,7 @@
4111
4180
  const cacheQuotaExceeded = "cache_quota_exceeded";
4112
4181
  const cacheErrorUnknown = "cache_error_unknown";
4113
4182
 
4114
- /*! @azure/msal-common v16.14.2 2026-10-13 */
4183
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
4115
4184
 
4116
4185
  /*
4117
4186
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4149,7 +4218,7 @@
4149
4218
  }
4150
4219
  }
4151
4220
 
4152
- /*! @azure/msal-common v16.14.2 2026-10-13 */
4221
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
4153
4222
 
4154
4223
  /*
4155
4224
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5336,7 +5405,7 @@
5336
5405
  }
5337
5406
  }
5338
5407
 
5339
- /*! @azure/msal-common v16.14.2 2026-10-13 */
5408
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
5340
5409
  /*
5341
5410
  * Copyright (c) Microsoft Corporation. All rights reserved.
5342
5411
  * Licensed under the MIT License.
@@ -5350,7 +5419,7 @@
5350
5419
  const PerformanceEventStatus = {
5351
5420
  InProgress: 1};
5352
5421
 
5353
- /*! @azure/msal-common v16.14.2 2026-10-13 */
5422
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
5354
5423
 
5355
5424
  /*
5356
5425
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5408,7 +5477,7 @@
5408
5477
  }
5409
5478
  }
5410
5479
 
5411
- /*! @azure/msal-common v16.14.2 2026-10-13 */
5480
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
5412
5481
 
5413
5482
  /*
5414
5483
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5506,7 +5575,7 @@
5506
5575
  return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
5507
5576
  }
5508
5577
 
5509
- /*! @azure/msal-common v16.14.2 2026-10-13 */
5578
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
5510
5579
  /*
5511
5580
  * Copyright (c) Microsoft Corporation. All rights reserved.
5512
5581
  * Licensed under the MIT License.
@@ -5533,7 +5602,7 @@
5533
5602
  }
5534
5603
  }
5535
5604
 
5536
- /*! @azure/msal-common v16.14.2 2026-10-13 */
5605
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
5537
5606
 
5538
5607
  /*
5539
5608
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5554,7 +5623,7 @@
5554
5623
  return new JoseHeaderError(code, correlationId);
5555
5624
  }
5556
5625
 
5557
- /*! @azure/msal-common v16.14.2 2026-10-13 */
5626
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
5558
5627
  /*
5559
5628
  * Copyright (c) Microsoft Corporation. All rights reserved.
5560
5629
  * Licensed under the MIT License.
@@ -5579,7 +5648,7 @@
5579
5648
  return Object.getPrototypeOf(value) === proto;
5580
5649
  }
5581
5650
 
5582
- /*! @azure/msal-common v16.14.2 2026-10-13 */
5651
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
5583
5652
  /*
5584
5653
  * Copyright (c) Microsoft Corporation. All rights reserved.
5585
5654
  * Licensed under the MIT License.
@@ -5589,7 +5658,7 @@
5589
5658
  const missingJwkError = "missing_jwk_error";
5590
5659
  const invalidJwkError = "invalid_jwk_error";
5591
5660
 
5592
- /*! @azure/msal-common v16.14.2 2026-10-13 */
5661
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
5593
5662
 
5594
5663
  /*
5595
5664
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5655,7 +5724,7 @@
5655
5724
  }
5656
5725
  }
5657
5726
 
5658
- /*! @azure/msal-common v16.14.2 2026-10-13 */
5727
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
5659
5728
 
5660
5729
  /*
5661
5730
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5756,7 +5825,7 @@
5756
5825
  }
5757
5826
  }
5758
5827
 
5759
- /*! @azure/msal-common v16.14.2 2026-10-13 */
5828
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
5760
5829
 
5761
5830
  /*
5762
5831
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5901,7 +5970,7 @@
5901
5970
  }
5902
5971
  }
5903
5972
 
5904
- /*! @azure/msal-common v16.14.2 2026-10-13 */
5973
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
5905
5974
  /*
5906
5975
  * Copyright (c) Microsoft Corporation. All rights reserved.
5907
5976
  * Licensed under the MIT License.
@@ -5952,7 +6021,7 @@
5952
6021
  */
5953
6022
  const interruptedUser = "interrupted_user";
5954
6023
 
5955
- /*! @azure/msal-common v16.14.2 2026-10-13 */
6024
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
5956
6025
 
5957
6026
  /*
5958
6027
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6019,7 +6088,7 @@
6019
6088
  return new InteractionRequiredAuthError(errorCode, correlationId, errorMessage);
6020
6089
  }
6021
6090
 
6022
- /*! @azure/msal-common v16.14.2 2026-10-13 */
6091
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
6023
6092
 
6024
6093
  /*
6025
6094
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6038,7 +6107,7 @@
6038
6107
  }
6039
6108
  }
6040
6109
 
6041
- /*! @azure/msal-common v16.14.2 2026-10-13 */
6110
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
6042
6111
 
6043
6112
  /*
6044
6113
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6109,7 +6178,7 @@
6109
6178
  }
6110
6179
  }
6111
6180
 
6112
- /*! @azure/msal-common v16.14.2 2026-10-13 */
6181
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
6113
6182
 
6114
6183
  /*
6115
6184
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6537,7 +6606,7 @@
6537
6606
  return baseAccount;
6538
6607
  }
6539
6608
 
6540
- /*! @azure/msal-common v16.14.2 2026-10-13 */
6609
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
6541
6610
  /*
6542
6611
  * Copyright (c) Microsoft Corporation. All rights reserved.
6543
6612
  * Licensed under the MIT License.
@@ -6547,7 +6616,7 @@
6547
6616
  UPN: "UPN",
6548
6617
  };
6549
6618
 
6550
- /*! @azure/msal-common v16.14.2 2026-10-13 */
6619
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
6551
6620
  /*
6552
6621
  * Copyright (c) Microsoft Corporation. All rights reserved.
6553
6622
  * Licensed under the MIT License.
@@ -6566,7 +6635,7 @@
6566
6635
  }
6567
6636
  }
6568
6637
 
6569
- /*! @azure/msal-common v16.14.2 2026-10-13 */
6638
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
6570
6639
 
6571
6640
  /*
6572
6641
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6590,7 +6659,7 @@
6590
6659
  };
6591
6660
  }
6592
6661
 
6593
- /*! @azure/msal-common v16.14.2 2026-10-13 */
6662
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
6594
6663
 
6595
6664
  /*
6596
6665
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6625,13 +6694,14 @@
6625
6694
  * Performs necessary throttling checks after a network request.
6626
6695
  * @param cacheManager
6627
6696
  * @param thumbprint
6628
- * @param response
6697
+ * @param response - Token response with case-insensitive header names.
6629
6698
  */
6630
6699
  static postProcess(cacheManager, thumbprint, response, correlationId) {
6700
+ const retryAfter = getRetryAfterHeader(response);
6631
6701
  if (ThrottlingUtils.checkResponseStatus(response) ||
6632
- ThrottlingUtils.checkResponseForRetryAfter(response)) {
6702
+ retryAfter !== undefined) {
6633
6703
  const thumbprintValue = {
6634
- throttleTime: ThrottlingUtils.calculateThrottleTime(parseInt(response.headers[HeaderNames.RETRY_AFTER])),
6704
+ throttleTime: ThrottlingUtils.calculateThrottleTime(parseInt(retryAfter || "")),
6635
6705
  error: response.body.error,
6636
6706
  errorCodes: response.body.error_codes,
6637
6707
  errorMessage: response.body.error_description,
@@ -6650,14 +6720,10 @@
6650
6720
  }
6651
6721
  /**
6652
6722
  * Checks a NetworkResponse object's RetryAfter header
6653
- * @param response
6723
+ * @param response - Token response with case-insensitive header names.
6654
6724
  */
6655
6725
  static checkResponseForRetryAfter(response) {
6656
- if (response.headers) {
6657
- return (response.headers.hasOwnProperty(HeaderNames.RETRY_AFTER) &&
6658
- (response.status < 200 || response.status >= 300));
6659
- }
6660
- return false;
6726
+ return getRetryAfterHeader(response) !== undefined;
6661
6727
  }
6662
6728
  /**
6663
6729
  * Calculates the Unix-time value for a throttle to expire given throttleTime in seconds.
@@ -6674,9 +6740,16 @@
6674
6740
  const key = this.generateThrottlingStorageKey(thumbprint);
6675
6741
  cacheManager.removeItem(key, request.correlationId);
6676
6742
  }
6743
+ }
6744
+ /** Reads Retry-After only for non-success responses. */
6745
+ function getRetryAfterHeader(response) {
6746
+ if ((response.status < 200 || response.status >= 300) && response.headers) {
6747
+ return getResponseHeader(response.headers, HeaderNames.RETRY_AFTER);
6748
+ }
6749
+ return undefined;
6677
6750
  }
6678
6751
 
6679
- /*! @azure/msal-common v16.14.2 2026-10-13 */
6752
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
6680
6753
 
6681
6754
  /*
6682
6755
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6707,7 +6780,7 @@
6707
6780
  return new NetworkError(error, httpStatus, responseHeaders);
6708
6781
  }
6709
6782
 
6710
- /*! @azure/msal-common v16.14.2 2026-10-13 */
6783
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
6711
6784
 
6712
6785
  /*
6713
6786
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6805,7 +6878,8 @@
6805
6878
  let response;
6806
6879
  try {
6807
6880
  response = await invokeAsync((networkClient.sendPostRequestAsync.bind(networkClient)), NetworkClientSendPostRequestAsync, logger, performanceClient, correlationId)(tokenEndpoint, { ...options, correlationId, performanceClient });
6808
- const responseHeaders = response.headers || {};
6881
+ const responseHeaders = normalizeResponseHeaders(response.headers || {});
6882
+ response = { ...response, headers: responseHeaders };
6809
6883
  performanceClient?.addFields({
6810
6884
  refreshTokenSize: response.body.refresh_token?.length || 0,
6811
6885
  httpVerToken: responseHeaders[HeaderNames.X_MS_HTTP_VERSION] || "",
@@ -6814,16 +6888,16 @@
6814
6888
  }
6815
6889
  catch (e) {
6816
6890
  if (e instanceof NetworkError) {
6817
- const responseHeaders = e.responseHeaders;
6891
+ const responseHeaders = e.responseHeaders
6892
+ ? normalizeResponseHeaders(e.responseHeaders)
6893
+ : undefined;
6818
6894
  if (responseHeaders) {
6819
6895
  performanceClient?.addFields({
6820
6896
  httpVerToken: responseHeaders[HeaderNames.X_MS_HTTP_VERSION] ||
6821
6897
  "",
6822
6898
  requestId: responseHeaders[HeaderNames.X_MS_REQUEST_ID] || "",
6823
- contentTypeHeader: responseHeaders[HeaderNames.CONTENT_TYPE] ||
6824
- undefined,
6825
- contentLengthHeader: responseHeaders[HeaderNames.CONTENT_LENGTH] ||
6826
- undefined,
6899
+ contentTypeHeader: getResponseHeader(responseHeaders, HeaderNames.CONTENT_TYPE) || undefined,
6900
+ contentLengthHeader: getResponseHeader(responseHeaders, HeaderNames.CONTENT_LENGTH) || undefined,
6827
6901
  httpStatus: e.httpStatus,
6828
6902
  }, correlationId);
6829
6903
  }
@@ -6840,7 +6914,7 @@
6840
6914
  return response;
6841
6915
  }
6842
6916
 
6843
- /*! @azure/msal-common v16.14.2 2026-10-13 */
6917
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
6844
6918
 
6845
6919
  /*
6846
6920
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7084,6 +7158,9 @@
7084
7158
  if (request.logoutHint) {
7085
7159
  addLogoutHint(parameters, request.logoutHint);
7086
7160
  }
7161
+ if (request.popupOriginCheckDone) {
7162
+ addPopupOriginCheckDone(parameters);
7163
+ }
7087
7164
  if (request.extraQueryParameters) {
7088
7165
  addExtraParameters(parameters, request.extraQueryParameters);
7089
7166
  }
@@ -7104,7 +7181,7 @@
7104
7181
  }
7105
7182
  }
7106
7183
 
7107
- /*! @azure/msal-common v16.14.2 2026-10-13 */
7184
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
7108
7185
 
7109
7186
  /*
7110
7187
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7239,6 +7316,9 @@
7239
7316
  !Object.keys(request.extraQueryParameters).includes(INSTANCE_AWARE))) {
7240
7317
  addInstanceAware(parameters);
7241
7318
  }
7319
+ if (request.popupOriginCheckDone) {
7320
+ addPopupOriginCheckDone(parameters);
7321
+ }
7242
7322
  return parameters;
7243
7323
  }
7244
7324
  /**
@@ -7331,7 +7411,7 @@
7331
7411
  return account.loginHint || account.idTokenClaims?.login_hint || null;
7332
7412
  }
7333
7413
 
7334
- /*! @azure/msal-common v16.14.2 2026-10-13 */
7414
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
7335
7415
 
7336
7416
  /*
7337
7417
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7566,7 +7646,7 @@
7566
7646
  }
7567
7647
  }
7568
7648
 
7569
- /*! @azure/msal-common v16.14.2 2026-10-13 */
7649
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
7570
7650
 
7571
7651
  /*
7572
7652
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7859,7 +7939,7 @@
7859
7939
  clearNativeBrokerErrorCode() { }
7860
7940
  }
7861
7941
 
7862
- /*! @azure/msal-common v16.14.2 2026-10-13 */
7942
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
7863
7943
 
7864
7944
  /*
7865
7945
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7986,7 +8066,7 @@
7986
8066
  }
7987
8067
  }
7988
8068
 
7989
- /*! @azure/msal-common v16.14.2 2026-10-13 */
8069
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
7990
8070
 
7991
8071
  /*
7992
8072
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8002,7 +8082,7 @@
8002
8082
  },
8003
8083
  };
8004
8084
 
8005
- /*! @azure/msal-common v16.14.2 2026-10-13 */
8085
+ /*! @azure/msal-common v16.15.0 2026-10-27 */
8006
8086
 
8007
8087
  /*
8008
8088
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8157,13 +8237,14 @@
8157
8237
  * Custom Auth API error.
8158
8238
  */
8159
8239
  class CustomAuthApiError extends CustomAuthError {
8160
- constructor(error, errorDescription, correlationId, errorCodes, subError, attributes, continuationToken, traceId, timestamp, attributeValidationDetails) {
8240
+ constructor(error, errorDescription, correlationId, errorCodes, subError, attributes, continuationToken, traceId, timestamp, attributeValidationDetails, innerErrorCode) {
8161
8241
  super(error, errorDescription, correlationId, errorCodes, subError);
8162
8242
  this.attributes = attributes;
8163
8243
  this.continuationToken = continuationToken;
8164
8244
  this.traceId = traceId;
8165
8245
  this.timestamp = timestamp;
8166
8246
  this.attributeValidationDetails = attributeValidationDetails;
8247
+ this.innerErrorCode = innerErrorCode;
8167
8248
  Object.setPrototypeOf(this, CustomAuthApiError.prototype);
8168
8249
  }
8169
8250
  }
@@ -8205,7 +8286,7 @@
8205
8286
  const INVALID_TOKEN_TYPE = "invalid_token_type";
8206
8287
  const HTTP_REQUEST_FAILED$1 = "http_request_failed";
8207
8288
  const INVALID_REQUEST = "invalid_request";
8208
- const USER_NOT_FOUND = "user_not_found";
8289
+ const USER_NOT_FOUND$1 = "user_not_found";
8209
8290
  const INVALID_GRANT = "invalid_grant";
8210
8291
  const CREDENTIAL_REQUIRED = "credential_required";
8211
8292
  const ATTRIBUTES_REQUIRED = "attributes_required";
@@ -8245,7 +8326,7 @@
8245
8326
  this.errorData = errorData;
8246
8327
  }
8247
8328
  isUserNotFoundError() {
8248
- return this.errorData.error === USER_NOT_FOUND;
8329
+ return this.errorData.error === USER_NOT_FOUND$1;
8249
8330
  }
8250
8331
  isUserInvalidError() {
8251
8332
  return ((this.errorData instanceof InvalidArgumentError &&
@@ -8427,11 +8508,17 @@
8427
8508
  }
8428
8509
  throw e; // Rethrow unexpected errors
8429
8510
  }
8511
+ }
8512
+ function ensureArgumentIsStringArray(argName, argValue, correlationId) {
8513
+ if (!Array.isArray(argValue) ||
8514
+ !argValue.every((value) => typeof value === "string")) {
8515
+ throw new InvalidArgumentError(argName, correlationId);
8516
+ }
8430
8517
  }
8431
8518
 
8432
8519
  /* eslint-disable header/header */
8433
8520
  const name = "@azure/msal-browser";
8434
- const version = "5.25.1";
8521
+ const version = "5.27.0";
8435
8522
 
8436
8523
  /*
8437
8524
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8641,7 +8728,7 @@
8641
8728
  * @returns true if the error is due to the user not being found, false otherwise.
8642
8729
  */
8643
8730
  isUserNotFound() {
8644
- return this.errorData.error === USER_NOT_FOUND;
8731
+ return this.errorData.error === USER_NOT_FOUND$1;
8645
8732
  }
8646
8733
  /**
8647
8734
  * Checks if the error is due to the username being invalid.
@@ -9877,9 +9964,14 @@
9877
9964
  };
9878
9965
  }
9879
9966
  /**
9880
- * Clears hash from window url.
9967
+ * Clears a recognized authentication response fragment, preserving the query string.
9968
+ * Assigns an empty hash, then removes the trailing # when history updates are available.
9881
9969
  */
9882
9970
  function clearHash(contentWindow) {
9971
+ const serverParams = getDeserializedResponse(contentWindow.location.hash);
9972
+ if (!serverParams) {
9973
+ return;
9974
+ }
9883
9975
  // Office.js sets history.replaceState to null
9884
9976
  contentWindow.location.hash = "";
9885
9977
  if (typeof contentWindow.history.replaceState === "function") {
@@ -9887,6 +9979,16 @@
9887
9979
  contentWindow.history.replaceState(null, "", `${contentWindow.location.origin}${contentWindow.location.pathname}${contentWindow.location.search}`);
9888
9980
  }
9889
9981
  }
9982
+ /**
9983
+ * Strips both hash and query string from the given window's URL by replacing
9984
+ * with origin + pathname only. Used to remove auth response parameters
9985
+ * (auth code, state, etc.) before the window is closed or navigated away.
9986
+ */
9987
+ function clearAuthResponseFromUrl(contentWindow) {
9988
+ if (typeof contentWindow.history?.replaceState === "function") {
9989
+ contentWindow.history.replaceState(null, "", `${contentWindow.location.origin}${contentWindow.location.pathname}`);
9990
+ }
9991
+ }
9890
9992
  /**
9891
9993
  * Replaces current hash with hash from provided url
9892
9994
  */
@@ -11072,6 +11174,90 @@
11072
11174
  return httpMethod;
11073
11175
  }
11074
11176
 
11177
+ /*
11178
+ * Copyright (c) Microsoft Corporation. All rights reserved.
11179
+ * Licensed under the MIT License.
11180
+ */
11181
+ /**
11182
+ * `window.origin` of a document with an opaque origin, e.g. one sandboxed
11183
+ * without `allow-same-origin`. Read from `window.origin`, not
11184
+ * `location.origin`, which reports the real host even when sandboxed.
11185
+ */
11186
+ const OPAQUE_ORIGIN = "null";
11187
+ /**
11188
+ * Returns `true` when every ancestor browsing context is same-origin with
11189
+ * `win`. A top-level document has no ancestors, so it always passes.
11190
+ */
11191
+ function allAncestorsSameOrigin(win) {
11192
+ try {
11193
+ // Sandboxed: no origin to compare ancestors against.
11194
+ if (win.origin === OPAQUE_ORIGIN) {
11195
+ return false;
11196
+ }
11197
+ let current = win;
11198
+ // `window.parent` is self-referential at the top level, never falsy.
11199
+ while (current !== current.parent) {
11200
+ current = current.parent;
11201
+ // Throws SecurityError if this ancestor is cross-origin.
11202
+ void current.location.href;
11203
+ }
11204
+ return true;
11205
+ }
11206
+ catch {
11207
+ return false;
11208
+ }
11209
+ }
11210
+ /**
11211
+ * Returns `true` when the top-level window has no opener, or one that is
11212
+ * same-origin with it.
11213
+ *
11214
+ * Reads the opener from `win.top`, not `win`: a framed document always reports
11215
+ * `window.opener === null` and would pass while the top window's untrusted
11216
+ * opener still holds a handle on it.
11217
+ */
11218
+ function topOpenerIsSameOriginOrAbsent(win) {
11219
+ try {
11220
+ const top = win.top;
11221
+ if (!top) {
11222
+ // Detached from its browsing context; treat as unsafe.
11223
+ return false;
11224
+ }
11225
+ const opener = top.opener;
11226
+ if (!opener || opener === top) {
11227
+ return true;
11228
+ }
11229
+ // Throws SecurityError if the opener is cross-origin.
11230
+ void opener.location.href;
11231
+ return true;
11232
+ }
11233
+ catch {
11234
+ return false;
11235
+ }
11236
+ }
11237
+ /**
11238
+ * Computes the `pocd` ("popup origin check done") authorize parameter value.
11239
+ *
11240
+ * `1` means no untrusted window can reach the popup, which is what lets Entra
11241
+ * omit the `Cross-Origin-Opener-Policy` response header for the request.
11242
+ *
11243
+ * @param config Resolved browser configuration.
11244
+ * @param win Window whose hosting environment is being checked. Defaults to the app window.
11245
+ * @returns `1` when the check passes, otherwise `0`.
11246
+ */
11247
+ function computePocd(config, win = typeof window !== "undefined" ? window : undefined) {
11248
+ /*
11249
+ * Only an explicit false opts out; anything else computes the check, so an
11250
+ * unresolved config fails closed rather than asserting pocd=1.
11251
+ */
11252
+ if (config.auth.originCheck === false) {
11253
+ return 1;
11254
+ }
11255
+ if (!win || !allAncestorsSameOrigin(win)) {
11256
+ return 0;
11257
+ }
11258
+ return topOpenerIsSameOriginOrAbsent(win) ? 1 : 0;
11259
+ }
11260
+
11075
11261
  /*
11076
11262
  * Copyright (c) Microsoft Corporation. All rights reserved.
11077
11263
  * Licensed under the MIT License.
@@ -11089,6 +11275,11 @@
11089
11275
  const validLogoutRequest = {
11090
11276
  correlationId: this.correlationId,
11091
11277
  ...logoutRequest,
11278
+ /*
11279
+ * Computed here rather than per flow so every end-session request
11280
+ * carries it, matching the authorize path.
11281
+ */
11282
+ popupOriginCheckDone: computePocd(this.config) === 1,
11092
11283
  };
11093
11284
  /**
11094
11285
  * Set logout_hint to be login_hint from ID Token Claims if present
@@ -12149,7 +12340,7 @@
12149
12340
  * Licensed under the MIT License.
12150
12341
  */
12151
12342
  const HTTP_REQUEST_FAILED = "http_request_failed";
12152
- const REDIRECT_TO_WEB = "redirect_to_web";
12343
+ const WEB_REDIRECT_REQUIRED = "web_redirect_required";
12153
12344
  const UNEXPECTED_ERROR = "unexpected_error";
12154
12345
  const AUTH_CODE_MISSING = "authorization_code_missing";
12155
12346
  const INVALID_TOKEN_RESPONSE = "invalid_token_response";
@@ -12201,6 +12392,7 @@
12201
12392
  code: readString(response.error) ?? UNEXPECTED_ERROR,
12202
12393
  message: readString(response.error_description),
12203
12394
  errorCodes: readNumberArray(response.error_codes),
12395
+ subError: readString(response.suberror),
12204
12396
  correlationId: readString(response.correlation_id),
12205
12397
  traceId: readString(response.trace_id),
12206
12398
  timestamp: readString(response.timestamp),
@@ -12216,32 +12408,6 @@
12216
12408
  return undefined;
12217
12409
  }
12218
12410
 
12219
- /*
12220
- * Copyright (c) Microsoft Corporation. All rights reserved.
12221
- * Licensed under the MIT License.
12222
- */
12223
- // Content type used by V2 JSON `/api` requests.
12224
- const JSON_CONTENT_TYPE = "application/json";
12225
- // Server action returned after successful credential verification.
12226
- const UPDATE_RELATION = "update";
12227
- const CHALLENGE_RELATION = "challenge";
12228
- const VERIFY_RELATION = "verify";
12229
- const RISK_VERIFY_RELATION = "riskverify";
12230
- const COLLECT_ATTRIBUTES_RELATION = "collectAttributes";
12231
- const AuthenticationMethodTypeV2 = {
12232
- EMAIL: "email",
12233
- PASSWORD: "password",
12234
- SMS: "sms",
12235
- };
12236
- /*
12237
- * Known `state` values on a HAL response. Kept open (the body field is typed as string) because
12238
- * the server may introduce new values; response parsing and flow logic branch on these constants.
12239
- */
12240
- const ResponseStateV2 = {
12241
- CONTINUE: "continue",
12242
- WEB_FALLBACK_REQUIRED: "webFallbackRequired",
12243
- };
12244
-
12245
12411
  /*
12246
12412
  * Copyright (c) Microsoft Corporation. All rights reserved.
12247
12413
  * Licensed under the MIT License.
@@ -12262,17 +12428,14 @@
12262
12428
  const correlationId = response.headers.get(HttpHeaderKeys.X_MS_REQUEST_ID) ??
12263
12429
  requestCorrelationId;
12264
12430
  const json = await this.parseBody(response, correlationId);
12265
- const state = typeof json.state === "string" ? json.state : undefined;
12266
12431
  const continuationToken = (typeof json.continuationToken === "string"
12267
12432
  ? json.continuationToken
12268
12433
  : undefined) ??
12269
12434
  (typeof json.continuation_token === "string"
12270
12435
  ? json.continuation_token
12271
12436
  : undefined);
12272
- const flatError = typeof json.error === "string" ? json.error : undefined;
12273
- const isWebFallbackRequired = flatError === REDIRECT_TO_WEB ||
12274
- state === ResponseStateV2.WEB_FALLBACK_REQUIRED;
12275
12437
  const error = normalizeServerErrorV2(json);
12438
+ const isWebFallbackRequired = error?.subError === WEB_REDIRECT_REQUIRED;
12276
12439
  // Surface the header correlation id on the body (HalResponseBaseV2.correlationId).
12277
12440
  json.correlationId = correlationId;
12278
12441
  return {
@@ -12388,6 +12551,31 @@
12388
12551
  return path.startsWith("/") ? path : `/${path}`;
12389
12552
  }
12390
12553
 
12554
+ /*
12555
+ * Copyright (c) Microsoft Corporation. All rights reserved.
12556
+ * Licensed under the MIT License.
12557
+ */
12558
+ // Content type used by V2 JSON `/api` requests.
12559
+ const JSON_CONTENT_TYPE = "application/json";
12560
+ // Server action returned after successful credential verification.
12561
+ const UPDATE_RELATION = "update";
12562
+ const CHALLENGE_RELATION = "challenge";
12563
+ const VERIFY_RELATION = "verify";
12564
+ const RISK_VERIFY_RELATION = "riskverify";
12565
+ const COLLECT_ATTRIBUTES_RELATION = "collectAttributes";
12566
+ const AuthenticationMethodTypeV2 = {
12567
+ EMAIL: "email",
12568
+ PASSWORD: "password",
12569
+ SMS: "sms",
12570
+ };
12571
+ /*
12572
+ * Known `state` values on a HAL response. Kept open (the body field is typed as string) because
12573
+ * the server may introduce new values; response parsing and flow logic branch on these constants.
12574
+ */
12575
+ const ResponseStateV2 = {
12576
+ CONTINUE: "continue",
12577
+ };
12578
+
12391
12579
  /*
12392
12580
  * Copyright (c) Microsoft Corporation. All rights reserved.
12393
12581
  * Licensed under the MIT License.
@@ -12430,13 +12618,16 @@
12430
12618
  /*
12431
12619
  * Starts authorization and returns the initial continuation token and flow links.
12432
12620
  */
12433
- async authorizeChallengeStart(context, scopes) {
12621
+ async authorizeChallengeStart(context, scopes, claims) {
12434
12622
  const request = {
12435
12623
  client_id: this.clientId,
12436
12624
  };
12437
12625
  if (scopes?.length) {
12438
12626
  request.scope = scopes.join(" ");
12439
12627
  }
12628
+ if (claims) {
12629
+ request.claims = claims;
12630
+ }
12440
12631
  const parsedResponse = await this.postOAuthForm(AUTHORIZE_CHALLENGE, request, context);
12441
12632
  const { continuationToken, correlationId, error, body } = parsedResponse;
12442
12633
  /*
@@ -12463,7 +12654,7 @@
12463
12654
  */
12464
12655
  async completeWithTokens(request, context) {
12465
12656
  const code = await this.authorizeChallengeContinue(request.continuationToken, context);
12466
- return this.token(code, request.scopes, context);
12657
+ return this.token(code, context);
12467
12658
  }
12468
12659
  /*
12469
12660
  * Redeems a continuation token for an authorization code.
@@ -12484,7 +12675,7 @@
12484
12675
  /*
12485
12676
  * Exchanges an authorization code for tokens.
12486
12677
  */
12487
- async token(code, scopes, context) {
12678
+ async token(code, context) {
12488
12679
  const request = {
12489
12680
  client_id: this.clientId,
12490
12681
  grant_type: GrantType$1.AUTHORIZATION_CODE_GRANT,
@@ -12492,9 +12683,6 @@
12492
12683
  // Required so the server returns the client_info blob MSAL uses to build the home account id.
12493
12684
  client_info: "1",
12494
12685
  };
12495
- if (scopes.length > 0) {
12496
- request.scope = scopes.join(" ");
12497
- }
12498
12686
  const parsedResponse = await this.postOAuthForm(SIGNIN_TOKEN, request, context);
12499
12687
  this.throwOnApiError(parsedResponse);
12500
12688
  this.ensureTokenResponseIsValid(parsedResponse.body, parsedResponse.correlationId);
@@ -12547,11 +12735,13 @@
12547
12735
  }
12548
12736
  }
12549
12737
  toApiError(serverError, correlationId) {
12550
- return new CustomAuthApiError(serverError.code, serverError.message ?? "", serverError.correlationId ?? correlationId, serverError.errorCodes, serverError.innerErrorCode, undefined, undefined, serverError.traceId, serverError.timestamp, serverError.attributeValidationDetails);
12738
+ return new CustomAuthApiError(serverError.code, serverError.message ?? "", serverError.correlationId ?? correlationId, serverError.errorCodes, serverError.subError, undefined, undefined, serverError.traceId, serverError.timestamp, serverError.attributeValidationDetails, serverError.innerErrorCode);
12551
12739
  }
12552
12740
  throwOnWebFallback(parsedResponse) {
12553
12741
  if (parsedResponse.isWebFallbackRequired) {
12554
- throw new CustomAuthApiError(REDIRECT_TO_WEB, "The server requires the flow to continue in a web browser", parsedResponse.correlationId);
12742
+ if (parsedResponse.error?.subError === WEB_REDIRECT_REQUIRED) {
12743
+ throw this.toApiError(parsedResponse.error, parsedResponse.correlationId);
12744
+ }
12555
12745
  }
12556
12746
  }
12557
12747
  ensureTokenResponseIsValid(tokenResponse, correlationId) {
@@ -12879,13 +13069,16 @@
12879
13069
  ...defaultScopes.filter((scope) => !seenScopes.has(scope.toLowerCase())),
12880
13070
  ];
12881
13071
  }
12882
- async handleTokenResponse(tokenResponse, requestScopes, correlationId, apiId) {
13072
+ async handleTokenResponse(tokenResponse, requestedScopes, correlationId, apiId) {
12883
13073
  this.logger.verbose("Processing V2 token response.", correlationId);
12884
13074
  const requestTimestamp = Math.round(new Date().getTime() / 1000.0);
13075
+ const responseScopes = tokenResponse.scope
13076
+ ? tokenResponse.scope.split(" ").filter((scope) => !!scope)
13077
+ : requestedScopes;
12885
13078
  const result = await this.tokenResponseHandler.handleServerTokenResponse(tokenResponse, this.customAuthAuthority, requestTimestamp, {
12886
13079
  authority: this.customAuthAuthority.canonicalAuthority,
12887
13080
  correlationId,
12888
- scopes: requestScopes,
13081
+ scopes: responseScopes,
12889
13082
  }, apiId);
12890
13083
  return result;
12891
13084
  }
@@ -13009,13 +13202,15 @@
13009
13202
  this.apiClient = apiClient;
13010
13203
  }
13011
13204
  /*
13012
- * Starts sign-in using the preferred supported method offered by the server.
13205
+ * Starts sign-in by automatically using a sole supported method or returning
13206
+ * multiple supported methods for user selection.
13013
13207
  */
13014
13208
  async signIn(parameters) {
13015
13209
  const correlationId = parameters.correlationId;
13016
13210
  const context = this.createRequestContext(SIGN_IN_V2_START, correlationId);
13017
13211
  this.logger.verbose("Starting V2 sign-in.", correlationId);
13018
- const entryResult = await this.apiClient.authorizeChallengeStart(context);
13212
+ const scopes = this.getScopes(parameters.scopes);
13213
+ const entryResult = await this.apiClient.authorizeChallengeStart(context, scopes, parameters.claims);
13019
13214
  const startResult = await this.apiClient.signInStart(this.requireLink(correlationId, entryResult.signInHref, {
13020
13215
  code: SIGN_IN_UNSUPPORTED,
13021
13216
  message: "The authorize-challenge entry response did not include a sign-in link.",
@@ -13027,10 +13222,8 @@
13027
13222
  const continuationState = {
13028
13223
  continuationToken: startResult.continuationToken,
13029
13224
  scenario: CustomAuthFlowScenarioV2.SignIn,
13225
+ scopes,
13030
13226
  links: {},
13031
- tokenRequest: {
13032
- scopes: parameters.scopes,
13033
- },
13034
13227
  };
13035
13228
  const methods = startResult.methods.map((method) => ({
13036
13229
  id: method.id,
@@ -13038,7 +13231,15 @@
13038
13231
  hint: method.hint,
13039
13232
  challengeHref: method.challengeHref,
13040
13233
  }));
13041
- const selectedMethod = this.selectSignInMethod(methods, parameters.password !== undefined, correlationId);
13234
+ const supportedMethods = this.getSupportedSignInMethods(methods, correlationId);
13235
+ if (supportedMethods.length > 1) {
13236
+ return createFlowMethodSelectionRequiredResultV2({
13237
+ correlationId,
13238
+ continuationState,
13239
+ methods: supportedMethods,
13240
+ });
13241
+ }
13242
+ const selectedMethod = supportedMethods[0];
13042
13243
  const challengeResult = await this.requestChallenge({
13043
13244
  correlationId,
13044
13245
  continuationState: {
@@ -13071,7 +13272,8 @@
13071
13272
  const correlationId = parameters.correlationId;
13072
13273
  const context = this.createRequestContext(SIGN_UP_V2_START, correlationId);
13073
13274
  this.logger.verbose("Starting V2 sign-up.", correlationId);
13074
- const entryResult = await this.apiClient.authorizeChallengeStart(context, parameters.scopes);
13275
+ const scopes = this.getScopes(parameters.scopes);
13276
+ const entryResult = await this.apiClient.authorizeChallengeStart(context, scopes, parameters.claims);
13075
13277
  const startResult = await this.apiClient.signUpStart(this.requireLink(correlationId, entryResult.signUpHref, {
13076
13278
  code: SIGN_UP_UNSUPPORTED,
13077
13279
  message: "The authorize-challenge entry response did not include a sign-up link.",
@@ -13091,10 +13293,8 @@
13091
13293
  const continuationState = {
13092
13294
  continuationToken: startResult.continuationToken,
13093
13295
  scenario: CustomAuthFlowScenarioV2.SignUp,
13296
+ scopes,
13094
13297
  links: {},
13095
- tokenRequest: {
13096
- scopes: parameters.scopes,
13097
- },
13098
13298
  signUp: {
13099
13299
  passwordWasSupplied: attributes.password !== undefined,
13100
13300
  },
@@ -13115,7 +13315,8 @@
13115
13315
  const correlationId = parameters.correlationId;
13116
13316
  const context = this.createRequestContext(RESET_PASSWORD_V2_START, correlationId);
13117
13317
  this.logger.verbose("Starting V2 self-service password reset.", correlationId);
13118
- const entryResult = await this.apiClient.authorizeChallengeStart(context);
13318
+ const scopes = this.getScopes(parameters.scopes);
13319
+ const entryResult = await this.apiClient.authorizeChallengeStart(context, scopes, parameters.claims);
13119
13320
  const startResult = await this.apiClient.resetPasswordStart(this.requireLink(correlationId, entryResult.resetPasswordHref, {
13120
13321
  code: RESET_PASSWORD_UNSUPPORTED,
13121
13322
  message: "The authorize-challenge entry response did not include a reset-password link.",
@@ -13127,6 +13328,7 @@
13127
13328
  const continuationState = {
13128
13329
  continuationToken: startResult.continuationToken,
13129
13330
  scenario: CustomAuthFlowScenarioV2.PasswordReset,
13331
+ scopes,
13130
13332
  links: {},
13131
13333
  };
13132
13334
  const methods = startResult.methods.map((method) => ({
@@ -13181,21 +13383,30 @@
13181
13383
  */
13182
13384
  async requestChallenge(parameters) {
13183
13385
  const challengeResult = await this.sendMethodChallenge(parameters, "requestChallenge");
13184
- const challengeType = challengeResult.type ?? AuthenticationMethodTypeV2.EMAIL;
13386
+ const challengeType = challengeResult.type;
13387
+ const normalizedChallengeType = challengeType?.toLowerCase();
13185
13388
  const continuationState = this.createChallengeContinuationState(parameters.continuationState, challengeResult);
13186
- if (challengeType.toLowerCase() === AuthenticationMethodTypeV2.PASSWORD) {
13389
+ if (normalizedChallengeType === AuthenticationMethodTypeV2.PASSWORD) {
13187
13390
  return createFlowPasswordRequiredResultV2({
13188
13391
  correlationId: parameters.correlationId,
13189
13392
  continuationState,
13190
13393
  });
13191
13394
  }
13192
- return createFlowCodeRequiredResultV2({
13193
- correlationId: parameters.correlationId,
13194
- continuationState,
13195
- channel: challengeType,
13196
- sentTo: challengeResult.hint,
13197
- codeLength: challengeResult.codeLength,
13198
- });
13395
+ if (normalizedChallengeType === AuthenticationMethodTypeV2.EMAIL ||
13396
+ normalizedChallengeType === AuthenticationMethodTypeV2.SMS) {
13397
+ return createFlowCodeRequiredResultV2({
13398
+ correlationId: parameters.correlationId,
13399
+ continuationState,
13400
+ channel: challengeType,
13401
+ sentTo: challengeResult.hint,
13402
+ codeLength: challengeResult.codeLength,
13403
+ });
13404
+ }
13405
+ const message = challengeType
13406
+ ? `Challenge type '${challengeType}' is not supported.`
13407
+ : "Challenge type is missing.";
13408
+ this.logger.error(message, parameters.correlationId);
13409
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, parameters.correlationId);
13199
13410
  }
13200
13411
  /*
13201
13412
  * Verifies the submitted one-time code using the server-provided link. The
@@ -13220,6 +13431,7 @@
13220
13431
  continuationState: {
13221
13432
  continuationToken: verifyResult.continuationToken,
13222
13433
  scenario: continuationState.scenario,
13434
+ scopes: continuationState.scopes,
13223
13435
  links: { update: verifyResult.updateHref },
13224
13436
  },
13225
13437
  });
@@ -13234,10 +13446,10 @@
13234
13446
  const nextContinuationState = {
13235
13447
  continuationToken: verifyResult.continuationToken,
13236
13448
  scenario: continuationState.scenario,
13449
+ scopes: continuationState.scopes,
13237
13450
  links: {
13238
13451
  submitAttributes: verifyResult.submitAttributesHref,
13239
13452
  },
13240
- tokenRequest: continuationState.tokenRequest,
13241
13453
  signUp: continuationState.signUp,
13242
13454
  };
13243
13455
  const attributes = verifyResult.attributes.filter((attribute) => attribute.attributeId.toLowerCase() !== "password");
@@ -13263,8 +13475,8 @@
13263
13475
  continuationState: {
13264
13476
  continuationToken: verifyResult.continuationToken,
13265
13477
  scenario: continuationState.scenario,
13478
+ scopes: continuationState.scopes,
13266
13479
  links: {},
13267
- tokenRequest: continuationState.tokenRequest,
13268
13480
  },
13269
13481
  });
13270
13482
  }
@@ -13341,6 +13553,7 @@
13341
13553
  continuationState: {
13342
13554
  continuationToken: completionToken,
13343
13555
  scenario: continuationState.scenario,
13556
+ scopes: continuationState.scopes,
13344
13557
  links: {},
13345
13558
  },
13346
13559
  });
@@ -13362,12 +13575,10 @@
13362
13575
  const apiId = this.resolveStepApiId(continuationState.scenario, "signInWithContinuation", correlationId);
13363
13576
  const context = this.createRequestContext(apiId, correlationId);
13364
13577
  this.logger.verbose("Signing in with a V2 continuation.", correlationId);
13365
- const scopes = this.getScopes(parameters.scopes);
13366
13578
  const tokenResponse = await this.apiClient.completeWithTokens({
13367
13579
  continuationToken: continuationState.continuationToken,
13368
- scopes,
13369
13580
  }, context);
13370
- const authenticationResult = await this.handleTokenResponse(tokenResponse, scopes, correlationId, apiId);
13581
+ const authenticationResult = await this.handleTokenResponse(tokenResponse, continuationState.scopes, correlationId, apiId);
13371
13582
  this.logger.verbose("V2 continuation sign-in completed.", correlationId);
13372
13583
  return createFlowCompletedResultV2({
13373
13584
  correlationId,
@@ -13382,8 +13593,8 @@
13382
13593
  continuationState: {
13383
13594
  continuationToken: verifyResult.continuationToken,
13384
13595
  scenario: continuationState.scenario,
13596
+ scopes: continuationState.scopes,
13385
13597
  links: {},
13386
- tokenRequest: continuationState.tokenRequest,
13387
13598
  },
13388
13599
  methods: verifyResult.methods.map((method) => ({
13389
13600
  id: method.id,
@@ -13400,23 +13611,17 @@
13400
13611
  this.logger.error(message, correlationId);
13401
13612
  throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13402
13613
  }
13403
- selectSignInMethod(methods, passwordProvided, correlationId) {
13404
- const passwordMethod = methods.find((method) => method.type.toLowerCase() ===
13405
- AuthenticationMethodTypeV2.PASSWORD);
13406
- const emailMethod = methods.find((method) => method.type.toLowerCase() === AuthenticationMethodTypeV2.EMAIL);
13407
- if (passwordProvided) {
13408
- if (passwordMethod) {
13409
- return passwordMethod;
13410
- }
13411
- const message = "A password was supplied, but the sign-in response did not include a password method.";
13412
- this.logger.error(message, correlationId);
13413
- throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13414
- }
13415
- const selectedMethod = emailMethod ?? passwordMethod;
13416
- if (selectedMethod) {
13417
- return selectedMethod;
13614
+ getSupportedSignInMethods(methods, correlationId) {
13615
+ const supportedMethods = methods.filter((method) => {
13616
+ const methodType = method.type.toLowerCase();
13617
+ return (methodType === AuthenticationMethodTypeV2.EMAIL ||
13618
+ methodType === AuthenticationMethodTypeV2.PASSWORD ||
13619
+ methodType === AuthenticationMethodTypeV2.SMS);
13620
+ });
13621
+ if (supportedMethods.length > 0) {
13622
+ return supportedMethods;
13418
13623
  }
13419
- const message = "The sign-in start response did not include a supported email or password method.";
13624
+ const message = "The sign-in start response did not include a supported email, SMS, or password method.";
13420
13625
  this.logger.error(message, correlationId);
13421
13626
  throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13422
13627
  }
@@ -13428,11 +13633,11 @@
13428
13633
  continuationState: {
13429
13634
  continuationToken: result.continuationToken,
13430
13635
  scenario: continuationState.scenario,
13636
+ scopes: continuationState.scopes,
13431
13637
  links: {
13432
13638
  verify: result.verifyHref,
13433
13639
  resend: result.resendHref,
13434
13640
  },
13435
- tokenRequest: continuationState.tokenRequest,
13436
13641
  signUp: continuationState.signUp,
13437
13642
  },
13438
13643
  channel: result.type,
@@ -13447,10 +13652,10 @@
13447
13652
  const nextContinuationState = {
13448
13653
  continuationToken: result.continuationToken,
13449
13654
  scenario: continuationState.scenario,
13655
+ scopes: continuationState.scopes,
13450
13656
  links: {
13451
13657
  submitAttributes: result.submitAttributesHref,
13452
13658
  },
13453
- tokenRequest: continuationState.tokenRequest,
13454
13659
  signUp: continuationState.signUp,
13455
13660
  };
13456
13661
  const attributes = result.attributes.filter((attribute) => attribute.attributeId.toLowerCase() !== "password");
@@ -13475,8 +13680,8 @@
13475
13680
  continuationState: {
13476
13681
  continuationToken: result.continuationToken,
13477
13682
  scenario: continuationState.scenario,
13683
+ scopes: continuationState.scopes,
13478
13684
  links: {},
13479
- tokenRequest: continuationState.tokenRequest,
13480
13685
  },
13481
13686
  });
13482
13687
  }
@@ -13507,10 +13712,9 @@
13507
13712
  continuationState: {
13508
13713
  continuationToken,
13509
13714
  scenario: continuationState.scenario,
13715
+ scopes: continuationState.scopes,
13510
13716
  links: {},
13511
- tokenRequest: continuationState.tokenRequest,
13512
13717
  },
13513
- scopes: continuationState.tokenRequest?.scopes,
13514
13718
  });
13515
13719
  }
13516
13720
  async sendMethodChallenge(parameters, step) {
@@ -13539,15 +13743,13 @@
13539
13743
  return {
13540
13744
  continuationToken: challengeResult.continuationToken,
13541
13745
  scenario: continuationState.scenario,
13746
+ scopes: continuationState.scopes,
13542
13747
  links: {
13543
13748
  challenge: continuationState.links.challenge,
13544
13749
  verify: challengeResult.verifyHref,
13545
13750
  resend: challengeResult.resendHref ??
13546
13751
  continuationState.links.resend,
13547
13752
  },
13548
- ...(continuationState.tokenRequest && {
13549
- tokenRequest: continuationState.tokenRequest,
13550
- }),
13551
13753
  ...(continuationState.signUp && {
13552
13754
  signUp: continuationState.signUp,
13553
13755
  }),
@@ -13590,93 +13792,24 @@
13590
13792
  }
13591
13793
  }
13592
13794
 
13593
- /*
13594
- * Copyright (c) Microsoft Corporation. All rights reserved.
13595
- * Licensed under the MIT License.
13596
- */
13597
- /**
13598
- * Result of a native auth V2 operation. Use {@link CustomAuthResultV2.isState}
13599
- * to narrow the state before accessing its members.
13600
- */
13601
- class CustomAuthResultV2 {
13602
- constructor(state, data, scenario = CustomAuthFlowScenarioV2.Unknown) {
13603
- this.state = state;
13604
- this.data = data;
13605
- this.scenario = scenario;
13606
- }
13607
- /**
13608
- * Narrows the result to a specific state by its `stateType` discriminator.
13609
- * A successful match makes the state's properties available without a cast.
13610
- * @param stateType - The state type to test for.
13611
- * @returns True (and narrows `state`) when the current state matches `stateType`.
13612
- */
13613
- isState(stateType) {
13614
- return this.state.stateType === stateType;
13615
- }
13616
- /**
13617
- * Checks whether the result is in the terminal failed state. A failed result
13618
- * contains the flow-specific error.
13619
- * @returns True (and narrows `state`) when the operation failed.
13620
- */
13621
- isFailed() {
13622
- return this.state.stateType === "failed";
13623
- }
13624
- /**
13625
- * Creates a failed result from the supplied error. The result uses the
13626
- * shared {@link FailedStateV2} terminal state.
13627
- * @param error - The error that occurred.
13628
- * @param options - The flow-error type and error context.
13629
- * @returns A failed result carrying the flow-specific error.
13630
- */
13631
- static createWithError(error, options) {
13632
- const { errorType: ErrorType, scenario = CustomAuthFlowScenarioV2.Unknown, correlationId, } = options;
13633
- const errorData = CustomAuthResultV2.createErrorData(error, correlationId);
13634
- const flowError = new ErrorType(errorData, scenario);
13635
- const result = new CustomAuthResultV2(new FailedStateV2(), undefined, scenario);
13636
- result.error = flowError;
13637
- return result;
13638
- }
13639
- static createErrorData(error, correlationId) {
13640
- if (error instanceof CustomAuthError) {
13641
- return error;
13642
- }
13643
- if (error instanceof AuthError) {
13644
- const errorCodes = [];
13645
- if ("errorNo" in error) {
13646
- if (typeof error.errorNo === "string") {
13647
- const code = Number(error.errorNo);
13648
- if (!isNaN(code)) {
13649
- errorCodes.push(code);
13650
- }
13651
- }
13652
- else if (typeof error.errorNo === "number") {
13653
- errorCodes.push(error.errorNo);
13654
- }
13655
- }
13656
- return new MsalCustomAuthError(error.errorCode, error.errorMessage, error.subError, errorCodes, error.correlationId);
13657
- }
13658
- return new UnexpectedError(error, correlationId);
13659
- }
13660
- }
13661
-
13662
13795
  /*
13663
13796
  * Copyright (c) Microsoft Corporation. All rights reserved.
13664
13797
  * Licensed under the MIT License.
13665
13798
  */
13666
13799
  const INVALID_ONE_TIME_CODE = "invalidOneTimeCode";
13667
13800
  const INVALID_USERNAME_OR_PASSWORD = "invalidUserNameOrPassword";
13668
- const PASSWORD_TOO_WEAK = "passwordTooWeak";
13801
+ const PASSWORD_TOO_WEAK = "passwordTooWeak";
13802
+ const USER_NOT_FOUND = "userNotFound";
13669
13803
 
13670
13804
  /*
13671
13805
  * Copyright (c) Microsoft Corporation. All rights reserved.
13672
13806
  * Licensed under the MIT License.
13673
13807
  */
13674
- /*
13675
- * Standalone V2 error base; intentionally does NOT extend the V1 AuthFlowErrorBase.
13676
- * Provides the detectors common to every V2 flow; each per-action subclass adds only
13677
- * the detectors relevant to its own action.
13808
+ /**
13809
+ * Error returned by a native authentication V2 operation. Use its classifiers
13810
+ * to handle known failures while retaining raw diagnostics through `errorData`.
13678
13811
  */
13679
- class AuthFlowErrorBaseV2 {
13812
+ class AuthFlowErrorV2 {
13680
13813
  constructor(errorData, scenario = CustomAuthFlowScenarioV2.Unknown) {
13681
13814
  this.errorData = errorData;
13682
13815
  this.scenario = scenario;
@@ -13690,18 +13823,36 @@
13690
13823
  get errorDescription() {
13691
13824
  return this.errorData.errorDescription;
13692
13825
  }
13826
+ get innerErrorCode() {
13827
+ return this.errorData instanceof CustomAuthApiError
13828
+ ? this.errorData.innerErrorCode
13829
+ : undefined;
13830
+ }
13693
13831
  /**
13694
- * Checks if the error requires the flow to continue in the browser. The
13695
- * server surfaces this as a `redirect_to_web` failure, so a browser hand-off
13696
- * always arrives as a `FailedStateV2` on which this detector returns true.
13697
- * @returns True if the browser is required, false otherwise.
13832
+ * Gets the attribute ids that the service reports as required.
13698
13833
  */
13699
- isBrowserRequired() {
13700
- return this.errorData.error === REDIRECT_TO_WEB;
13834
+ get requiredAttributes() {
13835
+ return this.getAttributeIdsByCode("attributeRequired");
13701
13836
  }
13702
13837
  /**
13703
- * Checks if the error is due to a caller-supplied argument failing
13704
- * client-side validation before the request was issued (for example an empty
13838
+ * Gets the attribute ids whose submitted values failed validation.
13839
+ */
13840
+ get invalidAttributes() {
13841
+ return this.getAttributeIdsByCode("attributeValidationFailed");
13842
+ }
13843
+ /**
13844
+ * Checks if the error requires the flow to continue in the browser. The
13845
+ * server surfaces this as the `web_redirect_required` OAuth suberror, so a
13846
+ * browser hand-off arrives as a `FailedStateV2` on which this detector
13847
+ * returns true.
13848
+ * @returns True if the browser is required, false otherwise.
13849
+ */
13850
+ isBrowserRequired() {
13851
+ return this.errorData.subError === WEB_REDIRECT_REQUIRED;
13852
+ }
13853
+ /**
13854
+ * Checks if the error is due to a caller-supplied argument failing
13855
+ * client-side validation before the request was issued (for example an empty
13705
13856
  * username, code, or password, or an unknown method id). Use it to prompt the
13706
13857
  * user to correct the input rather than treating it as a server failure.
13707
13858
  * @returns True if the input was invalid, false otherwise.
@@ -13709,6 +13860,47 @@
13709
13860
  isInvalidInput() {
13710
13861
  return this.errorData instanceof InvalidArgumentError;
13711
13862
  }
13863
+ /**
13864
+ * Checks whether the service rejected the username parameter. Use it to ask
13865
+ * the user to correct the supplied username.
13866
+ * @returns True when the username is invalid, otherwise false.
13867
+ */
13868
+ isInvalidUsername() {
13869
+ return this.isUserInvalidError();
13870
+ }
13871
+ /**
13872
+ * Checks whether the supplied username does not identify an account. Use it
13873
+ * to distinguish a missing account from other request failures.
13874
+ * @returns True when the service reports that the user was not found.
13875
+ */
13876
+ isUserNotFound() {
13877
+ return this.isUserNotFoundError();
13878
+ }
13879
+ /**
13880
+ * Checks whether the service rejected the supplied sign-in credentials. This
13881
+ * classifier does not identify new-password policy failures.
13882
+ * @returns True when the username or password is incorrect.
13883
+ */
13884
+ isInvalidCredentials() {
13885
+ return this.isPasswordIncorrectError();
13886
+ }
13887
+ /**
13888
+ * Checks whether the service rejected a one-time code. Use it to prompt the
13889
+ * user to re-enter the code or request a new one.
13890
+ * @returns True when the one-time code is invalid, otherwise false.
13891
+ */
13892
+ isInvalidCode() {
13893
+ return this.isInvalidCodeError();
13894
+ }
13895
+ /**
13896
+ * Checks whether a new password violates password policy. It recognizes
13897
+ * both weak-password responses and password-targeted validation details.
13898
+ * @returns True when the new password is invalid, otherwise false.
13899
+ */
13900
+ isInvalidPassword() {
13901
+ return (this.isInvalidPasswordError() ||
13902
+ this.isPasswordPolicyViolationError());
13903
+ }
13712
13904
  /**
13713
13905
  * Checks whether an account already exists for the supplied identifier.
13714
13906
  * This can occur at different stages while completing sign-up.
@@ -13717,15 +13909,19 @@
13717
13909
  isUserAlreadyExists() {
13718
13910
  return this.getAttributeValidationDetails().some((detail) => detail.code === "userAlreadyExists");
13719
13911
  }
13720
- /*
13721
- * User-not-found arrives as AADSTS50034. The nested `/api` error carries no
13722
- * innerError and no error_codes array, so the AADSTS marker in the message is
13723
- * the only signal.
13912
+ /**
13913
+ * Checks whether the service requires attributes omitted from the request.
13914
+ * Use it to collect the required attributes before resubmitting.
13915
+ * @returns True when required attributes are missing, otherwise false.
13724
13916
  */
13725
- // TODO: Use the service-provided suberror when it becomes available.
13917
+ isMissingRequiredAttributes() {
13918
+ return this.requiredAttributes.length > 0;
13919
+ }
13726
13920
  isUserNotFoundError() {
13727
13921
  return (this.errorData.error === "invalidRequest" &&
13728
- this.errorData.errorDescription?.includes("AADSTS50034") === true);
13922
+ (this.innerErrorCode === USER_NOT_FOUND ||
13923
+ this.errorData.errorDescription?.includes("AADSTS50034") ===
13924
+ true));
13729
13925
  }
13730
13926
  isUserInvalidError() {
13731
13927
  return (this.errorData.error === "invalidRequest" &&
@@ -13734,23 +13930,26 @@
13734
13930
  .toLowerCase()
13735
13931
  .includes("username parameter"));
13736
13932
  }
13737
- // The verification endpoint uses this outer/inner code pair for an invalid one-time code.
13738
13933
  isInvalidCodeError() {
13739
13934
  return (this.errorData.error === "invalidGrant" &&
13740
- this.errorData.subError === INVALID_ONE_TIME_CODE);
13935
+ this.innerErrorCode === INVALID_ONE_TIME_CODE);
13741
13936
  }
13742
- // New password rejected by policy: inner `passwordTooWeak` (AADSTS120002).
13743
13937
  isInvalidPasswordError() {
13744
13938
  return (this.errorData.error === "invalidRequest" &&
13745
- this.errorData.subError === PASSWORD_TOO_WEAK);
13939
+ this.innerErrorCode === PASSWORD_TOO_WEAK);
13746
13940
  }
13747
13941
  isPasswordPolicyViolationError() {
13748
- return this.getAttributeValidationDetails().some((detail) => detail.code === "passwordPolicyViolation" &&
13749
- detail.attributeIds?.some((attributeId) => attributeId.toLowerCase() === "password") === true);
13942
+ return this.getAttributeValidationDetails().some((detail) => {
13943
+ const attributeIds = detail.attributeIds;
13944
+ return (detail.code === "passwordPolicyViolation" &&
13945
+ Array.isArray(attributeIds) &&
13946
+ attributeIds.some((attributeId) => typeof attributeId === "string" &&
13947
+ attributeId.toLowerCase() === "password"));
13948
+ });
13750
13949
  }
13751
13950
  isPasswordIncorrectError() {
13752
13951
  return (this.errorData.error === "invalidGrant" &&
13753
- this.errorData.subError === INVALID_USERNAME_OR_PASSWORD);
13952
+ this.innerErrorCode === INVALID_USERNAME_OR_PASSWORD);
13754
13953
  }
13755
13954
  getAttributeValidationDetails() {
13756
13955
  const details = this.errorData.attributeValidationDetails;
@@ -13758,6 +13957,12 @@
13758
13957
  ? details.filter((detail) => typeof detail === "object" && detail !== null)
13759
13958
  : [];
13760
13959
  }
13960
+ getAttributeIdsByCode(code) {
13961
+ const attributeIds = this.getAttributeValidationDetails().flatMap((detail) => detail.code === code && Array.isArray(detail.attributeIds)
13962
+ ? detail.attributeIds.filter((attributeId) => typeof attributeId === "string")
13963
+ : []);
13964
+ return [...new Set(attributeIds)];
13965
+ }
13761
13966
  }
13762
13967
 
13763
13968
  /*
@@ -13765,35 +13970,67 @@
13765
13970
  * Licensed under the MIT License.
13766
13971
  */
13767
13972
  /**
13768
- * Error raised when requesting (or resending) a challenge for a selected
13769
- * authentication method. It is a shared action error bound to the shared
13770
- * `RequestChallengeResultV2` and returned regardless of which entry flow reached
13771
- * it. It currently exposes no action-specific detectors — only the inherited
13772
- * `isBrowserRequired()`.
13773
- */
13774
- class RequestChallengeErrorV2 extends AuthFlowErrorBaseV2 {
13775
- }
13776
-
13777
- /*
13778
- * Copyright (c) Microsoft Corporation. All rights reserved.
13779
- * Licensed under the MIT License.
13780
- */
13781
- /**
13782
- * Error raised when verifying a challenge (submitting a one-time code). It
13783
- * exposes the detectors relevant to code verification so the app can respond to
13784
- * a rejected code specifically. Unrecognised failures carry no specific
13785
- * detector; inspect the error code (`unexpected_error` when the server gives
13786
- * none) and `errorDescription`.
13973
+ * Result of a native auth V2 operation. Use {@link CustomAuthResultV2.isState}
13974
+ * to narrow the state before accessing its members.
13787
13975
  */
13788
- class VerifyChallengeErrorV2 extends AuthFlowErrorBaseV2 {
13976
+ class CustomAuthResultV2 {
13977
+ constructor(state, data, scenario = CustomAuthFlowScenarioV2.Unknown) {
13978
+ this.state = state;
13979
+ this.data = data;
13980
+ this.scenario = scenario;
13981
+ }
13789
13982
  /**
13790
- * Checks if the error is due to the provided code being invalid or expired.
13791
- * Use it to prompt the user to re-enter the code or request a new one, rather
13792
- * than restarting the whole flow.
13793
- * @returns True if the code is invalid, false otherwise.
13983
+ * Narrows the result to a specific state by its `stateType` discriminator.
13984
+ * A successful match makes the state's properties available without a cast.
13985
+ * @param stateType - The state type to test for.
13986
+ * @returns True (and narrows `state`) when the current state matches `stateType`.
13794
13987
  */
13795
- isInvalidCode() {
13796
- return this.isInvalidCodeError();
13988
+ isState(stateType) {
13989
+ return this.state.stateType === stateType;
13990
+ }
13991
+ /**
13992
+ * Checks whether the result is in the terminal failed state. A failed result
13993
+ * contains the unified V2 flow error.
13994
+ * @returns True (and narrows `state`) when the operation failed.
13995
+ */
13996
+ isFailed() {
13997
+ return this.state.stateType === "failed";
13998
+ }
13999
+ /**
14000
+ * Creates a failed result from the supplied error. The result uses the
14001
+ * shared {@link FailedStateV2} terminal state and unified V2 flow error.
14002
+ * @param error - The error that occurred.
14003
+ * @param options - The flow-error context.
14004
+ * @returns A failed result carrying the unified V2 flow error.
14005
+ */
14006
+ static createWithError(error, options) {
14007
+ const { scenario = CustomAuthFlowScenarioV2.Unknown, correlationId } = options;
14008
+ const errorData = CustomAuthResultV2.createErrorData(error, correlationId);
14009
+ const flowError = new AuthFlowErrorV2(errorData, scenario);
14010
+ const result = new CustomAuthResultV2(new FailedStateV2(), undefined, scenario);
14011
+ result.error = flowError;
14012
+ return result;
14013
+ }
14014
+ static createErrorData(error, correlationId) {
14015
+ if (error instanceof CustomAuthError) {
14016
+ return error;
14017
+ }
14018
+ if (error instanceof AuthError) {
14019
+ const errorCodes = [];
14020
+ if ("errorNo" in error) {
14021
+ if (typeof error.errorNo === "string") {
14022
+ const code = Number(error.errorNo);
14023
+ if (!isNaN(code)) {
14024
+ errorCodes.push(code);
14025
+ }
14026
+ }
14027
+ else if (typeof error.errorNo === "number") {
14028
+ errorCodes.push(error.errorNo);
14029
+ }
14030
+ }
14031
+ return new MsalCustomAuthError(error.errorCode, error.errorMessage, error.subError, errorCodes, error.correlationId);
14032
+ }
14033
+ return new UnexpectedError(error, correlationId);
13797
14034
  }
13798
14035
  }
13799
14036
 
@@ -13814,18 +14051,6 @@
13814
14051
  }
13815
14052
  }
13816
14053
 
13817
- /*
13818
- * Copyright (c) Microsoft Corporation. All rights reserved.
13819
- * Licensed under the MIT License.
13820
- */
13821
- /**
13822
- * Error raised when redeeming a completed V2 flow's continuation for tokens.
13823
- * It adds no action-specific detectors beyond the inherited
13824
- * `isBrowserRequired()`; the app typically retries or starts sign-in explicitly.
13825
- */
13826
- class SignInContinuationErrorV2 extends AuthFlowErrorBaseV2 {
13827
- }
13828
-
13829
14054
  /*
13830
14055
  * Copyright (c) Microsoft Corporation. All rights reserved.
13831
14056
  * Licensed under the MIT License.
@@ -13842,25 +14067,17 @@
13842
14067
  }
13843
14068
  /**
13844
14069
  * Signs the user in using the continuation established by the completed V2
13845
- * flow. On success the returned result reaches the completed state
13846
- * carrying the signed-in account data; on failure the result's error reports
13847
- * why the follow-up sign-in could not complete.
13848
- * @param inputs - Optional scopes requested for the issued token. Claims
13849
- * are accepted for API alignment but are not sent until the V2 service
13850
- * supports them on authorize-challenge.
13851
- * @returns The result of signing in after the password reset.
13852
- */
13853
- async signIn(inputs) {
14070
+ * flow. The result either reaches the completed state with the signed-in
14071
+ * account data or reports why the follow-up sign-in could not complete.
14072
+ * @returns The result of completing the continuation sign-in.
14073
+ */
14074
+ async signIn() {
13854
14075
  const { correlationId, logger, continuationState, flowClient } = this.stateParameters;
13855
14076
  try {
13856
- if (inputs?.claims) {
13857
- ensureArgumentIsJSONString("inputs.claims", inputs.claims, correlationId);
13858
- }
13859
14077
  logger.verbose("Signing in with a V2 continuation.", correlationId);
13860
14078
  const result = await flowClient.signInWithContinuation({
13861
14079
  correlationId,
13862
14080
  continuationState,
13863
- scopes: inputs?.scopes,
13864
14081
  });
13865
14082
  const account = new CustomAuthAccountData(result.authenticationResult.account, this.stateParameters.config, this.stateParameters.cacheClient, logger, correlationId);
13866
14083
  return new CustomAuthResultV2(new CompletedStateV2(), account, continuationState.scenario);
@@ -13868,7 +14085,6 @@
13868
14085
  catch (error) {
13869
14086
  logger.errorPii(`Failed to sign in with a V2 continuation. Error: '${error}'.`, correlationId);
13870
14087
  return CustomAuthResultV2.createWithError(error, {
13871
- errorType: SignInContinuationErrorV2,
13872
14088
  scenario: continuationState.scenario,
13873
14089
  correlationId,
13874
14090
  });
@@ -13876,29 +14092,6 @@
13876
14092
  }
13877
14093
  }
13878
14094
 
13879
- /*
13880
- * Copyright (c) Microsoft Corporation. All rights reserved.
13881
- * Licensed under the MIT License.
13882
- */
13883
- /**
13884
- * Error raised when submitting a new password. It exposes the detectors relevant
13885
- * to password submission so the app can react to a rejected password
13886
- * specifically. Unrecognised failures carry no specific detector; inspect the
13887
- * error code (`unexpected_error` when the server gives none) and
13888
- * `errorDescription`.
13889
- */
13890
- class SubmitNewPasswordErrorV2 extends AuthFlowErrorBaseV2 {
13891
- /**
13892
- * Checks if the error is due to the new password being invalid, for example
13893
- * because it fails the tenant's complexity policy. Use it to prompt the user
13894
- * for a stronger password rather than restarting the reset flow.
13895
- * @returns True if the new password is invalid, false otherwise.
13896
- */
13897
- isInvalidPassword() {
13898
- return this.isInvalidPasswordError();
13899
- }
13900
- }
13901
-
13902
14095
  /*
13903
14096
  * Copyright (c) Microsoft Corporation. All rights reserved.
13904
14097
  * Licensed under the MIT License.
@@ -13941,7 +14134,6 @@
13941
14134
  catch (error) {
13942
14135
  logger.errorPii(`Failed to submit V2 new password. Error: '${error}'.`, correlationId);
13943
14136
  return CustomAuthResultV2.createWithError(error, {
13944
- errorType: SubmitNewPasswordErrorV2,
13945
14137
  scenario: continuationState.scenario,
13946
14138
  correlationId,
13947
14139
  });
@@ -13962,9 +14154,7 @@
13962
14154
  this.codeLength = stateParameters.codeLength;
13963
14155
  }
13964
14156
  async submitCodeCore(code) {
13965
- if (this.codeLength) {
13966
- this.ensureCodeIsValid(code, this.codeLength);
13967
- }
14157
+ ensureArgumentIsNotNullOrUndefined("code", code, this.stateParameters.correlationId);
13968
14158
  return this.stateParameters.flowClient.submitCode({
13969
14159
  correlationId: this.stateParameters.correlationId,
13970
14160
  continuationState: this.stateParameters.continuationState,
@@ -13979,157 +14169,6 @@
13979
14169
  }
13980
14170
  }
13981
14171
 
13982
- /*
13983
- * Copyright (c) Microsoft Corporation. All rights reserved.
13984
- * Licensed under the MIT License.
13985
- */
13986
- /**
13987
- * State returned when sign-in requires verification of an email or SMS MFA
13988
- * challenge. It allows the app to submit the challenge or request a replacement.
13989
- */
13990
- class MFAVerificationRequiredStateV2 extends ChallengeVerificationStateBaseV2 {
13991
- constructor() {
13992
- super(...arguments);
13993
- this.stateType = "mfaVerificationRequired";
13994
- }
13995
- /**
13996
- * Submits the email or SMS challenge as the second authentication factor.
13997
- * Successful verification completes sign-in.
13998
- * @param challenge - The challenge value to submit.
13999
- * @returns The result of submitting the MFA challenge.
14000
- */
14001
- async submitChallenge(challenge) {
14002
- const { correlationId, logger, continuationState } = this.stateParameters;
14003
- try {
14004
- logger.verbose("Submitting V2 MFA challenge.", correlationId);
14005
- const result = await this.submitCodeCore(challenge);
14006
- if (result.type !== FLOW_COMPLETED_V2) {
14007
- throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, `MFA challenge submission result type '${result.type}' is not supported.`, correlationId);
14008
- }
14009
- const account = new CustomAuthAccountData(result.authenticationResult.account, this.stateParameters.config, this.stateParameters.cacheClient, logger, correlationId);
14010
- return new CustomAuthResultV2(new CompletedStateV2(), account, continuationState.scenario);
14011
- }
14012
- catch (error) {
14013
- logger.errorPii(`Failed to submit V2 MFA challenge. Error: '${error}'.`, correlationId);
14014
- return CustomAuthResultV2.createWithError(error, {
14015
- errorType: VerifyChallengeErrorV2,
14016
- scenario: continuationState.scenario,
14017
- correlationId,
14018
- });
14019
- }
14020
- }
14021
- /**
14022
- * Requests a replacement challenge for the selected MFA method. The
14023
- * returned state contains the refreshed email or SMS challenge metadata.
14024
- * @returns The result of requesting a replacement MFA challenge.
14025
- */
14026
- async resendChallenge() {
14027
- const { correlationId, logger, continuationState } = this.stateParameters;
14028
- try {
14029
- logger.verbose("Resending V2 MFA challenge.", correlationId);
14030
- const result = await this.resendCodeCore();
14031
- return new CustomAuthResultV2(new MFAVerificationRequiredStateV2({
14032
- correlationId: result.correlationId,
14033
- logger,
14034
- config: this.stateParameters.config,
14035
- flowClient: this.stateParameters.flowClient,
14036
- continuationState: result.continuationState,
14037
- cacheClient: this.stateParameters.cacheClient,
14038
- method: this.method,
14039
- sentTo: result.sentTo,
14040
- channel: result.channel,
14041
- codeLength: result.codeLength,
14042
- }), undefined, result.continuationState.scenario);
14043
- }
14044
- catch (error) {
14045
- logger.errorPii(`Failed to resend V2 MFA challenge. Error: '${error}'.`, correlationId);
14046
- return CustomAuthResultV2.createWithError(error, {
14047
- errorType: RequestChallengeErrorV2,
14048
- scenario: continuationState.scenario,
14049
- correlationId,
14050
- });
14051
- }
14052
- }
14053
- }
14054
-
14055
- /*
14056
- * Copyright (c) Microsoft Corporation. All rights reserved.
14057
- * Licensed under the MIT License.
14058
- */
14059
- class AuthenticationMethodSelectionStateBaseV2 extends AuthFlowActionRequiredStateBase {
14060
- constructor(stateParameters) {
14061
- super(stateParameters);
14062
- this.methods = stateParameters.methods;
14063
- }
14064
- async requestSelectedMethodChallenge(method) {
14065
- const { correlationId, continuationState, flowClient } = this.stateParameters;
14066
- const selectedMethod = this.methods.find((candidate) => candidate.id === method.id);
14067
- if (!selectedMethod) {
14068
- throw new InvalidArgumentError("method", correlationId);
14069
- }
14070
- const result = await flowClient.requestChallenge({
14071
- correlationId,
14072
- continuationState: {
14073
- ...continuationState,
14074
- links: {
14075
- ...continuationState.links,
14076
- challenge: selectedMethod.challengeHref,
14077
- },
14078
- },
14079
- });
14080
- return { result, selectedMethod };
14081
- }
14082
- }
14083
-
14084
- /*
14085
- * Copyright (c) Microsoft Corporation. All rights reserved.
14086
- * Licensed under the MIT License.
14087
- */
14088
- /**
14089
- * State returned when sign-in requires a registered multi-factor
14090
- * authentication method.
14091
- */
14092
- class MFARequiredStateV2 extends AuthenticationMethodSelectionStateBaseV2 {
14093
- constructor() {
14094
- super(...arguments);
14095
- this.stateType = "mfaRequired";
14096
- }
14097
- /**
14098
- * Requests a challenge for a registered MFA method.
14099
- * @param method - A method from {@link methods}.
14100
- * @returns A result requiring challenge verification or describing failure.
14101
- */
14102
- async requestChallenge(method) {
14103
- const { correlationId, logger, continuationState, flowClient } = this.stateParameters;
14104
- try {
14105
- const { result, selectedMethod } = await this.requestSelectedMethodChallenge(method);
14106
- if (result.type !== FLOW_CODE_REQUIRED_V2) {
14107
- throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, `MFA method selection expected a code challenge but received '${result.type}'.`, correlationId);
14108
- }
14109
- return new CustomAuthResultV2(new MFAVerificationRequiredStateV2({
14110
- correlationId: result.correlationId,
14111
- logger,
14112
- config: this.stateParameters.config,
14113
- flowClient,
14114
- continuationState: result.continuationState,
14115
- cacheClient: this.stateParameters.cacheClient,
14116
- method: selectedMethod,
14117
- sentTo: result.sentTo,
14118
- channel: result.channel,
14119
- codeLength: result.codeLength,
14120
- }), undefined, result.continuationState.scenario);
14121
- }
14122
- catch (error) {
14123
- logger.errorPii(`Failed to request V2 MFA challenge. Error: '${error}'.`, correlationId);
14124
- return CustomAuthResultV2.createWithError(error, {
14125
- errorType: RequestChallengeErrorV2,
14126
- scenario: continuationState.scenario,
14127
- correlationId,
14128
- });
14129
- }
14130
- }
14131
- }
14132
-
14133
14172
  /*
14134
14173
  * Copyright (c) Microsoft Corporation. All rights reserved.
14135
14174
  * Licensed under the MIT License.
@@ -14187,15 +14226,11 @@
14187
14226
  }), undefined, result.continuationState.scenario);
14188
14227
  }
14189
14228
  if (result.type === FLOW_MFA_REQUIRED_V2) {
14190
- return new CustomAuthResultV2(new MFARequiredStateV2({
14191
- correlationId: result.correlationId,
14192
- logger,
14193
- config: this.stateParameters.config,
14194
- flowClient: this.stateParameters.flowClient,
14195
- continuationState: result.continuationState,
14196
- cacheClient: this.stateParameters.cacheClient,
14197
- methods: result.methods,
14198
- }), undefined, result.continuationState.scenario);
14229
+ const signInStateTransitionHandler = this.stateParameters.signInStateTransitionHandler;
14230
+ if (!signInStateTransitionHandler) {
14231
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, "Sign-in state transition handler is missing.", correlationId);
14232
+ }
14233
+ return signInStateTransitionHandler.handleMfaRequired(result, this.stateParameters);
14199
14234
  }
14200
14235
  if (result.type === FLOW_COMPLETED_V2) {
14201
14236
  const account = new CustomAuthAccountData(result.authenticationResult.account, this.stateParameters.config, this.stateParameters.cacheClient, logger, correlationId);
@@ -14206,7 +14241,6 @@
14206
14241
  catch (error) {
14207
14242
  logger.errorPii(`Failed to submit V2 first-factor code. Error: '${error}'.`, correlationId);
14208
14243
  return CustomAuthResultV2.createWithError(error, {
14209
- errorType: VerifyChallengeErrorV2,
14210
14244
  scenario: continuationState.scenario,
14211
14245
  correlationId,
14212
14246
  });
@@ -14230,6 +14264,7 @@
14230
14264
  continuationState: result.continuationState,
14231
14265
  cacheClient: this.stateParameters.cacheClient,
14232
14266
  signUpStateTransitionHandler: this.stateParameters.signUpStateTransitionHandler,
14267
+ signInStateTransitionHandler: this.stateParameters.signInStateTransitionHandler,
14233
14268
  method: this.method,
14234
14269
  sentTo: result.sentTo,
14235
14270
  channel: result.channel,
@@ -14239,7 +14274,77 @@
14239
14274
  catch (error) {
14240
14275
  logger.errorPii(`Failed to resend V2 first-factor code. Error: '${error}'.`, correlationId);
14241
14276
  return CustomAuthResultV2.createWithError(error, {
14242
- errorType: RequestChallengeErrorV2,
14277
+ scenario: continuationState.scenario,
14278
+ correlationId,
14279
+ });
14280
+ }
14281
+ }
14282
+ }
14283
+
14284
+ /*
14285
+ * Copyright (c) Microsoft Corporation. All rights reserved.
14286
+ * Licensed under the MIT License.
14287
+ */
14288
+ /**
14289
+ * State returned when sign-in requires verification of an email or SMS MFA
14290
+ * challenge. It allows the app to submit the challenge or request a replacement.
14291
+ */
14292
+ class MFAVerificationRequiredStateV2 extends ChallengeVerificationStateBaseV2 {
14293
+ constructor() {
14294
+ super(...arguments);
14295
+ this.stateType = "mfaVerificationRequired";
14296
+ }
14297
+ /**
14298
+ * Submits the email or SMS challenge as the second authentication factor.
14299
+ * Successful verification completes sign-in.
14300
+ * @param challenge - The challenge value to submit.
14301
+ * @returns The result of submitting the MFA challenge.
14302
+ */
14303
+ async submitChallenge(challenge) {
14304
+ const { correlationId, logger, continuationState } = this.stateParameters;
14305
+ try {
14306
+ logger.verbose("Submitting V2 MFA challenge.", correlationId);
14307
+ const result = await this.submitCodeCore(challenge);
14308
+ if (result.type !== FLOW_COMPLETED_V2) {
14309
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, `MFA challenge submission result type '${result.type}' is not supported.`, correlationId);
14310
+ }
14311
+ const account = new CustomAuthAccountData(result.authenticationResult.account, this.stateParameters.config, this.stateParameters.cacheClient, logger, correlationId);
14312
+ return new CustomAuthResultV2(new CompletedStateV2(), account, continuationState.scenario);
14313
+ }
14314
+ catch (error) {
14315
+ logger.errorPii(`Failed to submit V2 MFA challenge. Error: '${error}'.`, correlationId);
14316
+ return CustomAuthResultV2.createWithError(error, {
14317
+ scenario: continuationState.scenario,
14318
+ correlationId,
14319
+ });
14320
+ }
14321
+ }
14322
+ /**
14323
+ * Requests a replacement challenge for the selected MFA method. The
14324
+ * returned state contains the refreshed email or SMS challenge metadata.
14325
+ * @returns The result of requesting a replacement MFA challenge.
14326
+ */
14327
+ async resendChallenge() {
14328
+ const { correlationId, logger, continuationState } = this.stateParameters;
14329
+ try {
14330
+ logger.verbose("Resending V2 MFA challenge.", correlationId);
14331
+ const result = await this.resendCodeCore();
14332
+ return new CustomAuthResultV2(new MFAVerificationRequiredStateV2({
14333
+ correlationId: result.correlationId,
14334
+ logger,
14335
+ config: this.stateParameters.config,
14336
+ flowClient: this.stateParameters.flowClient,
14337
+ continuationState: result.continuationState,
14338
+ cacheClient: this.stateParameters.cacheClient,
14339
+ method: this.method,
14340
+ sentTo: result.sentTo,
14341
+ channel: result.channel,
14342
+ codeLength: result.codeLength,
14343
+ }), undefined, result.continuationState.scenario);
14344
+ }
14345
+ catch (error) {
14346
+ logger.errorPii(`Failed to resend V2 MFA challenge. Error: '${error}'.`, correlationId);
14347
+ return CustomAuthResultV2.createWithError(error, {
14243
14348
  scenario: continuationState.scenario,
14244
14349
  correlationId,
14245
14350
  });
@@ -14257,23 +14362,23 @@
14257
14362
  * methods and lets the app request a challenge for the chosen one. The flow
14258
14363
  * stays on this state until a challenge is successfully requested.
14259
14364
  */
14260
- class AuthMethodSelectionRequiredStateV2 extends AuthenticationMethodSelectionStateBaseV2 {
14261
- constructor() {
14262
- super(...arguments);
14365
+ class AuthMethodSelectionRequiredStateV2 extends AuthFlowActionRequiredStateBase {
14366
+ constructor(stateParameters) {
14367
+ super(stateParameters);
14263
14368
  this.stateType = "authMethodSelectionRequired";
14369
+ this.methods = stateParameters.methods;
14264
14370
  }
14265
14371
  /**
14266
- * Requests a challenge for the selected authentication method. The returned
14372
+ * Selects an authentication method and requests its challenge. The returned
14267
14373
  * state identifies the credential the application must collect.
14268
- * @param method - The method to challenge, from {@link methods}.
14269
- * @returns The result of requesting the challenge.
14374
+ * @param method - The method to select, from {@link methods}.
14375
+ * @returns The result of selecting the method and requesting its challenge.
14270
14376
  */
14271
- async requestChallenge(method) {
14272
- const { correlationId, logger, continuationState, flowClient } = this.stateParameters;
14377
+ async selectAuthMethod(method) {
14378
+ const { authenticationFactor, correlationId, logger, continuationState, flowClient, signInStateTransitionHandler, } = this.stateParameters;
14273
14379
  try {
14274
14380
  logger.verbose("Requesting challenge for the selected V2 method.", correlationId);
14275
14381
  const { result, selectedMethod } = await this.requestSelectedMethodChallenge(method);
14276
- const resultType = result.type;
14277
14382
  const commonStateParameters = {
14278
14383
  correlationId: result.correlationId,
14279
14384
  logger,
@@ -14282,128 +14387,78 @@
14282
14387
  continuationState: result.continuationState,
14283
14388
  cacheClient: this.stateParameters.cacheClient,
14284
14389
  };
14285
- if (result.type === FLOW_CODE_REQUIRED_V2 &&
14390
+ if (authenticationFactor === AuthenticationFactorV2.SINGLE_FACTOR &&
14391
+ result.type === FLOW_CODE_REQUIRED_V2 &&
14286
14392
  (result.channel?.toLowerCase() ===
14287
14393
  AuthenticationMethodTypeV2.EMAIL ||
14288
14394
  result.channel?.toLowerCase() ===
14289
14395
  AuthenticationMethodTypeV2.SMS)) {
14290
14396
  return new CustomAuthResultV2(new CodeRequiredStateV2({
14291
14397
  ...commonStateParameters,
14398
+ signInStateTransitionHandler,
14292
14399
  method: selectedMethod,
14293
14400
  sentTo: result.sentTo,
14294
14401
  channel: result.channel,
14295
14402
  codeLength: result.codeLength,
14296
14403
  }), undefined, result.continuationState.scenario);
14297
14404
  }
14298
- throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, `Challenge type '${resultType}' with channel '${result.type === FLOW_CODE_REQUIRED_V2
14299
- ? result.channel
14300
- : AuthenticationMethodTypeV2.PASSWORD}' is not supported for password reset.`, correlationId);
14301
- }
14302
- catch (error) {
14303
- logger.errorPii(`Failed to request V2 challenge. Error: '${error}'.`, correlationId);
14304
- return CustomAuthResultV2.createWithError(error, {
14305
- errorType: RequestChallengeErrorV2,
14306
- scenario: continuationState.scenario,
14307
- correlationId,
14308
- });
14309
- }
14310
- }
14311
- }
14312
-
14313
- /*
14314
- * Copyright (c) Microsoft Corporation. All rights reserved.
14315
- * Licensed under the MIT License.
14316
- */
14317
- /**
14318
- * Error raised by the first call of the native auth V2 reset-password flow
14319
- * (`resetPasswordV2`). It surfaces only the detectors relevant to starting a
14320
- * password reset, so an app inspecting `result.error` sees a small, focused set.
14321
- * Any unrecognised failure carries no specific detector; inspect the error code
14322
- * (`unexpected_error` when the server gives none) and `errorDescription`.
14323
- */
14324
- class ResetPasswordStartErrorV2 extends AuthFlowErrorBaseV2 {
14325
- /**
14326
- * Checks if the supplied username is empty or invalid.
14327
- * @returns True if the username is invalid, false otherwise.
14328
- */
14329
- isInvalidUsername() {
14330
- return this.isUserInvalidError();
14331
- }
14332
- /**
14333
- * Checks if the error is due to the user not being found. Use it to tell the
14334
- * user no account matches the supplied username, rather than exposing a
14335
- * generic failure that hides the real cause.
14336
- * @returns True if the user was not found, false otherwise.
14337
- */
14338
- isUserNotFound() {
14339
- return this.isUserNotFoundError();
14340
- }
14341
- }
14342
-
14343
- /*
14344
- * Copyright (c) Microsoft Corporation. All rights reserved.
14345
- * Licensed under the MIT License.
14346
- */
14347
- /**
14348
- * Error returned when native auth V2 sign-in cannot start.
14349
- */
14350
- class SignInStartErrorV2 extends AuthFlowErrorBaseV2 {
14351
- /**
14352
- * Checks whether the service rejected the username parameter.
14353
- * @returns True when the username was empty or invalid.
14354
- */
14355
- isInvalidUsername() {
14356
- return this.isUserInvalidError();
14357
- }
14358
- /**
14359
- * Checks whether the supplied username does not identify an account.
14360
- * @returns True when the service reports that the user was not found.
14361
- */
14362
- isUserNotFound() {
14363
- return this.isUserNotFoundError();
14364
- }
14365
- /**
14366
- * Checks whether an automatically submitted password was rejected.
14367
- * @returns True when the password is incorrect.
14368
- */
14369
- isInvalidPassword() {
14370
- return this.isPasswordIncorrectError();
14371
- }
14372
- }
14373
-
14374
- /*
14375
- * Copyright (c) Microsoft Corporation. All rights reserved.
14376
- * Licensed under the MIT License.
14377
- */
14378
- /**
14379
- * Error returned when native auth V2 sign-up cannot start. It exposes
14380
- * detectors for failures that an app can correct without restarting the flow.
14381
- */
14382
- class SignUpStartErrorV2 extends AuthFlowErrorBaseV2 {
14383
- /**
14384
- * Checks whether an upfront password violates the tenant's password policy.
14385
- * Use it to prompt the user for a stronger password.
14386
- * @returns True when the password violates policy, otherwise false.
14387
- */
14388
- isInvalidPassword() {
14389
- return this.isPasswordPolicyViolationError();
14405
+ if (continuationState.scenario ===
14406
+ CustomAuthFlowScenarioV2.SignIn &&
14407
+ authenticationFactor === AuthenticationFactorV2.SINGLE_FACTOR &&
14408
+ result.type === FLOW_PASSWORD_REQUIRED_V2) {
14409
+ if (!signInStateTransitionHandler) {
14410
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, "Sign-in method selection cannot map a password challenge without a sign-in transition handler.", correlationId);
14411
+ }
14412
+ return signInStateTransitionHandler.handlePasswordRequired(result, commonStateParameters);
14413
+ }
14414
+ if (authenticationFactor === AuthenticationFactorV2.MULTI_FACTOR &&
14415
+ result.type === FLOW_CODE_REQUIRED_V2) {
14416
+ return new CustomAuthResultV2(new MFAVerificationRequiredStateV2({
14417
+ ...commonStateParameters,
14418
+ method: selectedMethod,
14419
+ sentTo: result.sentTo,
14420
+ channel: result.channel,
14421
+ codeLength: result.codeLength,
14422
+ }), undefined, result.continuationState.scenario);
14423
+ }
14424
+ const expectedChallenge = authenticationFactor === AuthenticationFactorV2.SINGLE_FACTOR
14425
+ ? continuationState.scenario ===
14426
+ CustomAuthFlowScenarioV2.SignIn
14427
+ ? "an email or SMS code challenge or a password challenge for single-factor sign-in"
14428
+ : "an email or SMS code challenge for single-factor authentication"
14429
+ : "a code challenge for multi-factor authentication";
14430
+ const returnedChallenge = result.type === FLOW_CODE_REQUIRED_V2
14431
+ ? result.channel
14432
+ ? `a '${result.channel}' code challenge`
14433
+ : "a code challenge without a channel"
14434
+ : "a password challenge";
14435
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, `Authentication method selection expected ${expectedChallenge}, but the server returned ${returnedChallenge}.`, correlationId);
14436
+ }
14437
+ catch (error) {
14438
+ logger.errorPii(`Failed to request V2 challenge. Error: '${error}'.`, correlationId);
14439
+ return CustomAuthResultV2.createWithError(error, {
14440
+ scenario: continuationState.scenario,
14441
+ correlationId,
14442
+ });
14443
+ }
14390
14444
  }
14391
- }
14392
-
14393
- /*
14394
- * Copyright (c) Microsoft Corporation. All rights reserved.
14395
- * Licensed under the MIT License.
14396
- */
14397
- /**
14398
- * Error returned when a password cannot be submitted for V2 sign-in.
14399
- */
14400
- class SubmitPasswordErrorV2 extends AuthFlowErrorBaseV2 {
14401
- /**
14402
- * Checks whether the supplied password was rejected.
14403
- * @returns True when the password is incorrect.
14404
- */
14405
- isInvalidPassword() {
14406
- return this.isPasswordIncorrectError();
14445
+ async requestSelectedMethodChallenge(method) {
14446
+ const { correlationId, continuationState, flowClient } = this.stateParameters;
14447
+ const selectedMethod = this.methods.find((candidate) => candidate.id === method.id);
14448
+ if (!selectedMethod) {
14449
+ throw new InvalidArgumentError("method", correlationId);
14450
+ }
14451
+ const result = await flowClient.requestChallenge({
14452
+ correlationId,
14453
+ continuationState: {
14454
+ ...continuationState,
14455
+ links: {
14456
+ ...continuationState.links,
14457
+ challenge: selectedMethod.challengeHref,
14458
+ },
14459
+ },
14460
+ });
14461
+ return { result, selectedMethod };
14407
14462
  }
14408
14463
  }
14409
14464
 
@@ -14440,7 +14495,7 @@
14440
14495
  return new CustomAuthResultV2(new CompletedStateV2(), account, continuationState.scenario);
14441
14496
  }
14442
14497
  if (result.type === FLOW_MFA_REQUIRED_V2) {
14443
- return new CustomAuthResultV2(new MFARequiredStateV2({
14498
+ return new CustomAuthResultV2(new AuthMethodSelectionRequiredStateV2({
14444
14499
  correlationId: result.correlationId,
14445
14500
  logger,
14446
14501
  config: this.stateParameters.config,
@@ -14448,6 +14503,7 @@
14448
14503
  continuationState: result.continuationState,
14449
14504
  cacheClient: this.stateParameters.cacheClient,
14450
14505
  methods: result.methods,
14506
+ authenticationFactor: AuthenticationFactorV2.MULTI_FACTOR,
14451
14507
  }), undefined, result.continuationState.scenario);
14452
14508
  }
14453
14509
  throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, `Password verification result type '${resultType}' is not supported.`, correlationId);
@@ -14455,7 +14511,6 @@
14455
14511
  catch (error) {
14456
14512
  logger.errorPii(`Failed to submit V2 sign-in password. Error: '${error}'.`, correlationId);
14457
14513
  return CustomAuthResultV2.createWithError(error, {
14458
- errorType: SubmitPasswordErrorV2,
14459
14514
  scenario: continuationState.scenario,
14460
14515
  correlationId,
14461
14516
  });
@@ -14467,26 +14522,25 @@
14467
14522
  * Copyright (c) Microsoft Corporation. All rights reserved.
14468
14523
  * Licensed under the MIT License.
14469
14524
  */
14470
- /**
14471
- * Error returned when additional V2 sign-up attributes cannot be submitted. It
14472
- * identifies attribute failures that an app can correct and resubmit.
14473
- */
14474
- class SubmitAttributesErrorV2 extends AuthFlowErrorBaseV2 {
14475
- /**
14476
- * Checks whether the service requires attributes omitted from the request.
14477
- * Use it to collect the required attributes before resubmitting.
14478
- * @returns True when required attributes are missing, otherwise false.
14479
- */
14480
- isMissingRequiredAttributes() {
14481
- return this.getAttributeValidationDetails().some((detail) => detail.code === "attributeRequired");
14525
+ class SignInStateTransitionHandlerV2 {
14526
+ handlePasswordRequired(result, stateParameters) {
14527
+ return new CustomAuthResultV2(new PasswordRequiredStateV2({
14528
+ ...stateParameters,
14529
+ correlationId: result.correlationId,
14530
+ continuationState: result.continuationState,
14531
+ }), undefined, result.continuationState.scenario);
14482
14532
  }
14483
- /**
14484
- * Checks whether a submitted password violates the tenant's password policy.
14485
- * Use it to prompt the user for a stronger password.
14486
- * @returns True when the password violates policy, otherwise false.
14487
- */
14488
- isInvalidPassword() {
14489
- return this.isPasswordPolicyViolationError();
14533
+ handleMfaRequired(result, stateParameters) {
14534
+ return new CustomAuthResultV2(new AuthMethodSelectionRequiredStateV2({
14535
+ correlationId: result.correlationId,
14536
+ logger: stateParameters.logger,
14537
+ config: stateParameters.config,
14538
+ flowClient: stateParameters.flowClient,
14539
+ continuationState: result.continuationState,
14540
+ cacheClient: stateParameters.cacheClient,
14541
+ methods: result.methods,
14542
+ authenticationFactor: AuthenticationFactorV2.MULTI_FACTOR,
14543
+ }), undefined, result.continuationState.scenario);
14490
14544
  }
14491
14545
  }
14492
14546
 
@@ -14533,7 +14587,6 @@
14533
14587
  catch (error) {
14534
14588
  logger.errorPii(`Failed to submit V2 sign-up attributes. Error: '${error}'.`, correlationId);
14535
14589
  return CustomAuthResultV2.createWithError(error, {
14536
- errorType: SubmitAttributesErrorV2,
14537
14590
  scenario: continuationState.scenario,
14538
14591
  correlationId,
14539
14592
  });
@@ -14572,7 +14625,6 @@
14572
14625
  catch (error) {
14573
14626
  logger.errorPii(`Failed to submit V2 sign-up password. Error: '${error}'.`, correlationId);
14574
14627
  return CustomAuthResultV2.createWithError(error, {
14575
- errorType: SubmitAttributesErrorV2,
14576
14628
  scenario: continuationState.scenario,
14577
14629
  correlationId,
14578
14630
  });
@@ -19947,6 +19999,116 @@
19947
19999
  return browserStorage.getActiveAccount(correlationId);
19948
20000
  }
19949
20001
 
20002
+ /*
20003
+ * Copyright (c) Microsoft Corporation. All rights reserved.
20004
+ * Licensed under the MIT License.
20005
+ */
20006
+ const POPUP_POLL_INTERVAL_MS = 30;
20007
+ let activePopupPoller;
20008
+ /**
20009
+ * Cancels legacy popup polling when an interaction is superseded.
20010
+ *
20011
+ * @internal
20012
+ * @param logger Logger for the interaction.
20013
+ */
20014
+ function cancelPendingPopupPollingResponse(logger) {
20015
+ if (activePopupPoller) {
20016
+ logger.verbose("PopupMonitor.cancelPendingPopupPollingResponse - Cancelling pending popup poller", activePopupPoller.correlationId);
20017
+ activePopupPoller.cancel();
20018
+ }
20019
+ }
20020
+ /**
20021
+ * Monitors a popup window for a URL change to the same origin as the parent application.
20022
+ * Polls the popup at a specified interval until it is redirected back to the application,
20023
+ * closed by the user, or a navigation to a same-origin URL is detected. Once a same-origin
20024
+ * URL is detected, extracts the response string (query or hash) and resolves the promise.
20025
+ *
20026
+ * @param popupWindow - The popup window to monitor for navigation.
20027
+ * @param popupWindowParent - The parent window that opened the popup.
20028
+ * @param responseMode - Response mode (`"query"` | `"fragment"`) determines whether
20029
+ * to read `location.search` or `location.hash` from the popup once on the same
20030
+ * origin. Any value other than `"query"` is treated as fragment.
20031
+ * @param logger - Logger instance.
20032
+ * @param unloadWindow - Event handler to remove from the parent window on cleanup.
20033
+ * @param correlationId
20034
+ */
20035
+ async function monitorPopupForHash(popupWindow, popupWindowParent, responseMode, logger, unloadWindow, correlationId) {
20036
+ let poller;
20037
+ return new Promise((resolve, reject) => {
20038
+ logger.verbose("PopupMonitor.monitorPopupForHash - polling started", correlationId);
20039
+ const intervalId = window.setInterval(() => {
20040
+ if (popupWindow.closed) {
20041
+ logger.error("PopupMonitor.monitorPopupForHash - window closed", correlationId);
20042
+ window.clearInterval(intervalId);
20043
+ reject(new BrowserAuthError(userCancelled, correlationId));
20044
+ return;
20045
+ }
20046
+ let href = "";
20047
+ try {
20048
+ /*
20049
+ * Will throw if cross origin,
20050
+ * which should be caught and ignored
20051
+ * since we need the interval to keep running while on STS UI.
20052
+ */
20053
+ href = popupWindow.location.href;
20054
+ }
20055
+ catch (e) { }
20056
+ // Don't process blank pages or cross domain
20057
+ if (!href || href === "about:blank") {
20058
+ return;
20059
+ }
20060
+ window.clearInterval(intervalId);
20061
+ let responseString;
20062
+ if (responseMode === ResponseMode.QUERY) {
20063
+ responseString = popupWindow.location.search;
20064
+ }
20065
+ else {
20066
+ responseString = popupWindow.location.hash;
20067
+ }
20068
+ logger.verbose("PopupMonitor.monitorPopupForHash - popup window is on same origin as caller", correlationId);
20069
+ resolve(responseString);
20070
+ }, POPUP_POLL_INTERVAL_MS);
20071
+ poller = {
20072
+ correlationId,
20073
+ cancel: () => {
20074
+ window.clearInterval(intervalId);
20075
+ if (activePopupPoller === poller) {
20076
+ activePopupPoller = undefined;
20077
+ }
20078
+ reject(new BrowserAuthError(interactionInProgressCancelled, correlationId));
20079
+ },
20080
+ };
20081
+ activePopupPoller = poller;
20082
+ }).finally(() => {
20083
+ if (poller && activePopupPoller === poller) {
20084
+ activePopupPoller = undefined;
20085
+ }
20086
+ cleanPopup(popupWindow, popupWindowParent, unloadWindow);
20087
+ });
20088
+ }
20089
+ /**
20090
+ * Performs cleanup operations after popup authentication.
20091
+ * Strips auth-response params (code/state) from the popup URL while it is still
20092
+ * open, closes the popup window, and removes the 'beforeunload' event listener
20093
+ * from the parent window.
20094
+ *
20095
+ * @param popupWindow - The popup window to be closed.
20096
+ * @param popupWindowParent - The parent window from which the event listener will be removed.
20097
+ * @param unloadWindow - The event handler function to remove.
20098
+ */
20099
+ function cleanPopup(popupWindow, popupWindowParent, unloadWindow) {
20100
+ if (!popupWindow.closed) {
20101
+ try {
20102
+ clearAuthResponseFromUrl(popupWindow);
20103
+ }
20104
+ catch {
20105
+ // Popup may have become cross-origin or otherwise inaccessible; ignore.
20106
+ }
20107
+ }
20108
+ popupWindow.close();
20109
+ popupWindowParent.removeEventListener("beforeunload", unloadWindow);
20110
+ }
20111
+
19950
20112
  /*
19951
20113
  * Copyright (c) Microsoft Corporation. All rights reserved.
19952
20114
  * Licensed under the MIT License.
@@ -20049,6 +20211,53 @@
20049
20211
  }
20050
20212
  }
20051
20213
 
20214
+ /*
20215
+ * Copyright (c) Microsoft Corporation. All rights reserved.
20216
+ * Licensed under the MIT License.
20217
+ */
20218
+ /**
20219
+ * Returns true when the supplied user agent is using Safari
20220
+ *
20221
+ * @internal
20222
+ */
20223
+ function isSafari(userAgent = typeof navigator !== "undefined"
20224
+ ? navigator.userAgent
20225
+ : "") {
20226
+ if (/OPR\/|OPiOS|PhantomJS|SamsungBrowser|Edge|EdgiOS|EdgA/.test(userAgent)) {
20227
+ return false;
20228
+ }
20229
+ const browserNavigator = typeof navigator !== "undefined"
20230
+ ? navigator
20231
+ : undefined;
20232
+ if (/Edg/.test(userAgent) ||
20233
+ browserNavigator?.userAgentData?.brands?.some((brand) => brand?.brand === "Microsoft Edge")) {
20234
+ return false;
20235
+ }
20236
+ if (/Electron|CriOS|Chrome|Trident|FxiOS|Firefox/.test(userAgent)) {
20237
+ return false;
20238
+ }
20239
+ return /Safari/.test(userAgent) || /AppleWebKit/.test(userAgent);
20240
+ }
20241
+ /**
20242
+ * Returns true when EAR should be used for the current request.
20243
+ *
20244
+ * Safari cannot complete EAR's cross-origin form POST, so requests configured
20245
+ * for EAR transparently use authorization code flow instead.
20246
+ *
20247
+ * @internal
20248
+ */
20249
+ function shouldUseEar(protocolMode, logger, performanceClient, correlationId, userAgent) {
20250
+ if (protocolMode !== ProtocolMode.EAR) {
20251
+ return false;
20252
+ }
20253
+ if (!isSafari(userAgent)) {
20254
+ return true;
20255
+ }
20256
+ logger.verbose("Safari detected. Falling back from EAR to authorization code flow.", correlationId);
20257
+ performanceClient.addFields({ "ext.earFallbackReason": "safari" }, correlationId);
20258
+ return false;
20259
+ }
20260
+
20052
20261
  /*
20053
20262
  * Copyright (c) Microsoft Corporation. All rights reserved.
20054
20263
  * Licensed under the MIT License.
@@ -21290,7 +21499,16 @@
21290
21499
  * @returns
21291
21500
  */
21292
21501
  async function getStandardParameters(config, authority, request, logger, performanceClient) {
21293
- const parameters = getStandardAuthorizeRequestParameters({ ...config.auth, authority: authority }, request, logger, performanceClient);
21502
+ const parameters = getStandardAuthorizeRequestParameters({ ...config.auth, authority: authority }, {
21503
+ ...request,
21504
+ /*
21505
+ * Computed here rather than per flow so every authorize request
21506
+ * carries it — GET, POST and EAR, interactive and silent alike.
21507
+ * A request may assert it instead when the topology, rather than
21508
+ * the current window, is what makes the popup unreachable.
21509
+ */
21510
+ popupOriginCheckDone: request.popupOriginCheckDone ?? computePocd(config) === 1,
21511
+ }, logger, performanceClient);
21294
21512
  addLibraryInfo(parameters, {
21295
21513
  sku: BrowserConstants.MSAL_SKU,
21296
21514
  version: version,
@@ -21344,6 +21562,15 @@
21344
21562
  });
21345
21563
  return getAuthorizeUrl(authority, parameters);
21346
21564
  }
21565
+ function getAuthorizeFormAction(authority, request, parameters) {
21566
+ const queryParams = new Map();
21567
+ addExtraParameters(queryParams, request.extraQueryParameters || {});
21568
+ if (parameters.has(POPUP_ORIGIN_CHECK_DONE)) {
21569
+ queryParams.delete(POPUP_ORIGIN_CHECK_DONE);
21570
+ }
21571
+ addCorrelationId(queryParams, request.correlationId);
21572
+ return getAuthorizeUrl(authority, queryParams);
21573
+ }
21347
21574
  /**
21348
21575
  * Builds the action URL + POST-body fields for the EAR /authorize form.
21349
21576
  */
@@ -21359,11 +21586,7 @@
21359
21586
  addExtraParameters(parameters, {
21360
21587
  ...request.extraParameters,
21361
21588
  });
21362
- const queryParams = new Map();
21363
- addExtraParameters(queryParams, request.extraQueryParameters || {});
21364
- // Add correlationId to query params so gateway can propagate it to IDPs
21365
- addCorrelationId(queryParams, request.correlationId);
21366
- const action = getAuthorizeUrl(authority, queryParams);
21589
+ const action = getAuthorizeFormAction(authority, request, parameters);
21367
21590
  return { action, fields: Object.fromEntries(parameters) };
21368
21591
  }
21369
21592
  /**
@@ -21384,12 +21607,7 @@
21384
21607
  addExtraParameters(parameters, {
21385
21608
  ...request.extraParameters,
21386
21609
  });
21387
- // Add extraQueryParameters to be appended to request URL
21388
- const queryParams = new Map();
21389
- addExtraParameters(queryParams, request.extraQueryParameters || {});
21390
- // Add correlationId to query params so gateway can propagate it to IDPs
21391
- addCorrelationId(queryParams, request.correlationId);
21392
- const action = getAuthorizeUrl(authority, queryParams);
21610
+ const action = getAuthorizeFormAction(authority, request, parameters);
21393
21611
  return { action, fields: Object.fromEntries(parameters) };
21394
21612
  }
21395
21613
  /**
@@ -21776,7 +21994,7 @@
21776
21994
  */
21777
21995
  // Default timeout for popup windows and iframes in milliseconds
21778
21996
  const DEFAULT_POPUP_TIMEOUT_MS = 60000;
21779
- const DEFAULT_IFRAME_TIMEOUT_MS = 10000;
21997
+ const DEFAULT_IFRAME_TIMEOUT_MS$1 = 10000;
21780
21998
  const DEFAULT_REDIRECT_TIMEOUT_MS = 30000;
21781
21999
  const DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS = 2000;
21782
22000
  /**
@@ -21817,6 +22035,8 @@
21817
22035
  instanceAware: false,
21818
22036
  isMcp: false,
21819
22037
  verifySSO: false,
22038
+ // Legacy polling needs COOP omitted, so it implies asserting pocd=1.
22039
+ originCheck: !userInputSystem?.enableLegacyPolling,
21820
22040
  };
21821
22041
  // Default cache options for browser
21822
22042
  const DEFAULT_CACHE_OPTIONS = {
@@ -21841,7 +22061,7 @@
21841
22061
  : StubbedNetworkModule,
21842
22062
  navigationClient: new NavigationClient(),
21843
22063
  popupBridgeTimeout: userInputSystem?.popupBridgeTimeout || DEFAULT_POPUP_TIMEOUT_MS,
21844
- iframeBridgeTimeout: userInputSystem?.iframeBridgeTimeout || DEFAULT_IFRAME_TIMEOUT_MS,
22064
+ iframeBridgeTimeout: userInputSystem?.iframeBridgeTimeout || DEFAULT_IFRAME_TIMEOUT_MS$1,
21845
22065
  redirectNavigationTimeout: DEFAULT_REDIRECT_TIMEOUT_MS,
21846
22066
  allowRedirectInIframe: false,
21847
22067
  navigatePopups: true,
@@ -21850,6 +22070,7 @@
21850
22070
  DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS,
21851
22071
  protocolMode: ProtocolMode.AAD,
21852
22072
  serverTelemetryEnabled: false,
22073
+ enableLegacyPolling: false,
21853
22074
  };
21854
22075
  const providedSystemOptions = {
21855
22076
  ...DEFAULT_BROWSER_SYSTEM_OPTIONS,
@@ -21867,11 +22088,17 @@
21867
22088
  iframeTimeoutTelemetry: false,
21868
22089
  allowPlatformBrokerWithDOM: false,
21869
22090
  };
22091
+ let logger;
22092
+ const getLogger = () => {
22093
+ if (!logger) {
22094
+ logger = new Logger(providedSystemOptions.loggerOptions, name, version);
22095
+ }
22096
+ return logger;
22097
+ };
21870
22098
  // Throw an error if user has set OIDCOptions without being in OIDC protocol mode
21871
22099
  if (userInputSystem?.protocolMode !== ProtocolMode.OIDC &&
21872
22100
  userInputAuth?.OIDCOptions) {
21873
- const logger = new Logger(providedSystemOptions.loggerOptions, name, version);
21874
- logger.warning(JSON.stringify(createClientConfigurationError(cannotSetOIDCOptions, "")), "");
22101
+ getLogger().warning(JSON.stringify(createClientConfigurationError(cannotSetOIDCOptions, "")), "");
21875
22102
  }
21876
22103
  // Throw an error if user has set allowPlatformBroker to true with OIDC protocol mode
21877
22104
  if (userInputSystem?.protocolMode &&
@@ -21879,6 +22106,24 @@
21879
22106
  providedSystemOptions?.allowPlatformBroker) {
21880
22107
  throw createClientConfigurationError(cannotAllowPlatformBroker, "");
21881
22108
  }
22109
+ /*
22110
+ * The origin check computes 0 in the embedded contexts legacy polling
22111
+ * serves, so re-enabling it there breaks the flow. Honor it, but warn.
22112
+ */
22113
+ if (userInputSystem?.enableLegacyPolling &&
22114
+ userInputAuth?.originCheck === true) {
22115
+ getLogger().warning("buildConfiguration: system.enableLegacyPolling is true and auth.originCheck is explicitly true. Legacy polling requires pocd=1, which the origin check will not produce in an embedded context. Unset auth.originCheck to let legacy polling assert it.", "");
22116
+ }
22117
+ /*
22118
+ * Opting out is a deliberate risk transfer, not an error — but the app
22119
+ * cannot know at config time that the risky topology is actually present.
22120
+ */
22121
+ if ((userInputAuth?.originCheck ?? DEFAULT_AUTH_OPTIONS.originCheck) ===
22122
+ false &&
22123
+ typeof window !== "undefined" &&
22124
+ !topOpenerIsSameOriginOrAbsent(window)) {
22125
+ getLogger().warning("buildConfiguration: auth.originCheck is disabled and the top-level window has a cross-origin opener. MSAL will assert pocd=1, so the STS omits Cross-Origin-Opener-Policy and that opener can reach the auth popup. The application is responsible for this risk.", "");
22126
+ }
21882
22127
  const overlayedConfig = {
21883
22128
  auth: {
21884
22129
  ...DEFAULT_AUTH_OPTIONS,
@@ -22687,6 +22932,9 @@
22687
22932
  popupWindowAttributes: logoutRequest?.popupWindowAttributes || {},
22688
22933
  popupWindowParent: logoutRequest?.popupWindowParent ?? window,
22689
22934
  };
22935
+ validLogoutRequest.popupOriginCheckDone =
22936
+ this.getPopupOriginCheckDone(popupParams.popupWindowParent) ??
22937
+ validLogoutRequest.popupOriginCheckDone;
22690
22938
  const authority = logoutRequest && logoutRequest.authority;
22691
22939
  const mainWindowRedirectUri = logoutRequest && logoutRequest.mainWindowRedirectUri;
22692
22940
  // navigatePopups flag set to false. Acquires token without first opening popup. Popup will be opened later asynchronously.
@@ -22727,7 +22975,7 @@
22727
22975
  }
22728
22976
  const isPlatformBroker = isPlatformAuthAllowed(this.config, this.logger, this.correlationId, this.platformAuthProvider, request.authenticationScheme);
22729
22977
  validRequest.platformBroker = isPlatformBroker;
22730
- if (this.config.system.protocolMode === ProtocolMode.EAR) {
22978
+ if (shouldUseEar(this.config.system.protocolMode, this.logger, this.performanceClient, this.correlationId)) {
22731
22979
  return this.executeEarFlow(validRequest, popupParams, pkceCodes);
22732
22980
  }
22733
22981
  else {
@@ -22751,6 +22999,7 @@
22751
22999
  ...request,
22752
23000
  codeChallenge: pkce.challenge,
22753
23001
  ...tokenBindingParams,
23002
+ popupOriginCheckDone: this.getPopupOriginCheckDone(popupParams.popupWindowParent),
22754
23003
  };
22755
23004
  try {
22756
23005
  // Initialize the client
@@ -22814,6 +23063,7 @@
22814
23063
  earJwk: earJwk,
22815
23064
  codeChallenge: pkce.challenge,
22816
23065
  ...tokenBindingParams,
23066
+ popupOriginCheckDone: this.getPopupOriginCheckDone(popupParams.popupWindowParent),
22817
23067
  };
22818
23068
  const popupWindow = await this.openPostFormPopup(popupRequest, discoveredAuthority, popupParams, correlationId, true);
22819
23069
  // Monitor the popup for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.
@@ -23086,6 +23336,27 @@
23086
23336
  getRelayStateId(state, correlationId) {
23087
23337
  return parseRequestState(base64Decode, state, correlationId).libraryState.id;
23088
23338
  }
23339
+ /**
23340
+ * Asserts `pocd=1` for the relay flow. Direct popups also require the
23341
+ * environment of a delegated opening window to pass the origin check.
23342
+ *
23343
+ * With a relay the IdP window is a grandchild popup, which an untrusted
23344
+ * ancestor cannot reach by name — so the topology satisfies the check by
23345
+ * construction. The current window is framed and would otherwise compute
23346
+ * `0`. Without a delegated parent, the standard app check remains unchanged.
23347
+ *
23348
+ * @param popupWindowParent Window that opens the popup.
23349
+ */
23350
+ getPopupOriginCheckDone(popupWindowParent) {
23351
+ if (this.config.auth.popupRelayUri) {
23352
+ return true;
23353
+ }
23354
+ if (popupWindowParent !== window) {
23355
+ return (computePocd(this.config) === 1 &&
23356
+ computePocd(this.config, popupWindowParent) === 1);
23357
+ }
23358
+ return undefined;
23359
+ }
23089
23360
  /**
23090
23361
  * Opens the interactive popup for a POST-form /authorize request. Shared by
23091
23362
  * the auth-code POST and EAR flows, which are identical apart from the form
@@ -23181,7 +23452,7 @@
23181
23452
  // Clear temporary cache if the back button is clicked during the redirect flow.
23182
23453
  window.addEventListener("pageshow", handleBackButton);
23183
23454
  try {
23184
- const redirectOperation = this.config.system.protocolMode === ProtocolMode.EAR
23455
+ const redirectOperation = shouldUseEar(this.config.system.protocolMode, this.logger, this.performanceClient, this.correlationId)
23185
23456
  ? this.executeEarFlow(validRequest)
23186
23457
  : this.executeCodeFlow(validRequest);
23187
23458
  await Promise.race([redirectOperation, backButtonCancellation]);
@@ -23408,7 +23679,6 @@
23408
23679
  }
23409
23680
  return [null, ""];
23410
23681
  }
23411
- clearHash(window);
23412
23682
  this.logger.verbose("Hash contains known properties, returning response hash", this.correlationId);
23413
23683
  return [response, responseString];
23414
23684
  }
@@ -23683,7 +23953,7 @@
23683
23953
  const silentRequest = await invokeAsync(initializeAuthorizationRequest, StandardInteractionClientInitializeAuthorizationRequest, this.logger, this.performanceClient, this.correlationId)(inputRequest, InteractionType.Silent, this.config, this.browserCrypto, this.browserStorage, this.logger, this.performanceClient, this.correlationId);
23684
23954
  silentRequest.platformBroker = isPlatformAuthAllowed(this.config, this.logger, this.correlationId, this.platformAuthProvider, silentRequest.authenticationScheme);
23685
23955
  preconnect(silentRequest.authority);
23686
- if (this.config.system.protocolMode === ProtocolMode.EAR) {
23956
+ if (shouldUseEar(this.config.system.protocolMode, this.logger, this.performanceClient, this.correlationId)) {
23687
23957
  return this.executeEarFlow(silentRequest);
23688
23958
  }
23689
23959
  else {
@@ -24067,14 +24337,20 @@
24067
24337
  return prepareRequest(input);
24068
24338
  }
24069
24339
  /**
24070
- * Preserves the standard web thumbprint and caller-owned request references.
24340
+ * Extends the web thumbprint with silent-flow options while preserving caller-owned references.
24071
24341
  */
24072
24342
  function prepareWebSilentRequest({ request, account, correlationId, config, }) {
24073
24343
  const thumbprint = getRequestThumbprint(config.auth.clientId, {
24074
24344
  ...request,
24075
24345
  authority: request.authority || config.auth.authority}, account.homeAccountId);
24076
24346
  return {
24077
- key: JSON.stringify(thumbprint),
24347
+ key: JSON.stringify({
24348
+ ...thumbprint,
24349
+ forceRefresh: !!request.forceRefresh,
24350
+ cacheLookupPolicy: request.cacheLookupPolicy ?? CacheLookupPolicy.Default,
24351
+ extraParameters: canonicalizeStringDict(request.extraParameters),
24352
+ extraQueryParameters: canonicalizeStringDict(request.extraQueryParameters),
24353
+ }),
24078
24354
  request,
24079
24355
  account,
24080
24356
  };
@@ -24361,7 +24637,32 @@
24361
24637
  * @returns
24362
24638
  */
24363
24639
  async handleRedirectPromiseInternal(options) {
24364
- if (!this.browserStorage.isInteractionInProgress(true)) {
24640
+ // Preserve the response for RedirectClient before removing it from the URL.
24641
+ const responseString = options?.hash ||
24642
+ (this.config.auth.OIDCOptions.responseMode ===
24643
+ ResponseMode.QUERY
24644
+ ? window.location.search
24645
+ : window.location.hash);
24646
+ const anyClientInteractionInProgress = this.browserStorage.isInteractionInProgress(false);
24647
+ const currentClientInteraction = this.browserStorage.isInteractionInProgress(true);
24648
+ const isBridgeCallback = isInPopup() ||
24649
+ (isInIframe() &&
24650
+ !this.config.system.allowRedirectInIframe);
24651
+ /*
24652
+ * Clear recognized response fragments for:
24653
+ * - Stale callbacks with no pending interaction.
24654
+ * - This client's login callback, even if request setup or response validation fails.
24655
+ * - This client's logout callback containing state, before the SIGNOUT early return.
24656
+ * Leave another client's callback untouched. clearHash preserves query strings
24657
+ * and application routes, and does nothing when no response fragment is present.
24658
+ * Skip popup and non-redirect iframe callbacks: legacy apps may call HRP
24659
+ * before their redirect bridge reads and broadcasts the response.
24660
+ */
24661
+ if (!isBridgeCallback &&
24662
+ (!anyClientInteractionInProgress || currentClientInteraction)) {
24663
+ clearHash(window);
24664
+ }
24665
+ if (!currentClientInteraction) {
24365
24666
  this.logger.info("handleRedirectPromise called but there is no interaction in progress, returning null.", "");
24366
24667
  return null;
24367
24668
  }
@@ -24369,7 +24670,7 @@
24369
24670
  if (interactionType === INTERACTION_TYPE.SIGNOUT) {
24370
24671
  this.logger.verbose("handleRedirectPromise removing interaction_in_progress flag and returning null after sign-out", "");
24371
24672
  this.browserStorage.setInteractionInProgress(false);
24372
- return Promise.resolve(null);
24673
+ return null;
24373
24674
  }
24374
24675
  const loggedInAccounts = this.getAllAccounts();
24375
24676
  const platformBrokerRequest = this.browserStorage.getCachedNativeRequest();
@@ -24399,7 +24700,9 @@
24399
24700
  rootMeasurement = this.performanceClient.startMeasurement(AcquireTokenRedirect, correlationId);
24400
24701
  this.logger.trace("handleRedirectPromise - acquiring token from web flow", correlationId);
24401
24702
  const redirectClient = this.createRedirectClient(correlationId);
24402
- redirectResponse = invokeAsync(redirectClient.handleRedirectPromise.bind(redirectClient), HandleRedirectPromiseMeasurement, this.logger, this.performanceClient, rootMeasurement.event.correlationId)(standardRequest, codeVerifier, rootMeasurement, options);
24703
+ redirectResponse = invokeAsync(redirectClient.handleRedirectPromise.bind(redirectClient), HandleRedirectPromiseMeasurement, this.logger, this.performanceClient, rootMeasurement.event.correlationId)(standardRequest, codeVerifier, rootMeasurement, options?.hash
24704
+ ? options
24705
+ : { ...options, hash: responseString });
24403
24706
  }
24404
24707
  }
24405
24708
  catch (e) {
@@ -24547,6 +24850,9 @@
24547
24850
  this.logger.verbose("acquireTokenPopup called", correlationId);
24548
24851
  preflightCheck(this.initialized, atPopupMeasurement, this.config, request);
24549
24852
  this.browserStorage.setInteractionInProgress(true, INTERACTION_TYPE.SIGNIN, request.overrideInteractionInProgress, correlationId);
24853
+ if (request.overrideInteractionInProgress) {
24854
+ cancelPendingPopupPollingResponse(this.logger);
24855
+ }
24550
24856
  }
24551
24857
  catch (e) {
24552
24858
  // Since this function is syncronous we need to reject
@@ -25685,6 +25991,7 @@
25685
25991
  constructor(operatingContext, customAuthApiClient, customAuthApiClientV2) {
25686
25992
  super(operatingContext);
25687
25993
  this.signUpStateTransitionHandlerV2 = new SignUpStateTransitionHandlerV2();
25994
+ this.signInStateTransitionHandlerV2 = new SignInStateTransitionHandlerV2();
25688
25995
  if (!this.isBrowserEnvironment) {
25689
25996
  this.logger.verbose("The SDK can only be used in a browser environment.", "");
25690
25997
  throw new UnsupportedEnvironmentError();
@@ -25962,11 +26269,19 @@
25962
26269
  try {
25963
26270
  ensureArgumentIsNotNullOrUndefined("inputs", inputs, correlationId);
25964
26271
  ensureArgumentIsNotEmptyString("inputs.username", inputs.username, correlationId);
26272
+ if (inputs.scopes !== undefined && inputs.scopes !== null) {
26273
+ ensureArgumentIsStringArray("inputs.scopes", inputs.scopes, correlationId);
26274
+ }
26275
+ if (inputs.claims) {
26276
+ ensureArgumentIsJSONString("inputs.claims", inputs.claims, correlationId);
26277
+ }
25965
26278
  this.ensureUserNotSignedIn(correlationId);
25966
26279
  this.logger.verbose("Starting native auth V2 password-reset flow.", correlationId);
25967
26280
  const result = await this.flowClientV2.resetPassword({
25968
26281
  correlationId,
25969
26282
  username: inputs.username,
26283
+ scopes: inputs.scopes,
26284
+ claims: inputs.claims,
25970
26285
  });
25971
26286
  this.logger.verbose("Native auth V2 password-reset flow started.", correlationId);
25972
26287
  if (result.type === FLOW_CODE_REQUIRED_V2) {
@@ -25991,12 +26306,12 @@
25991
26306
  continuationState: result.continuationState,
25992
26307
  cacheClient: this.cacheClient,
25993
26308
  methods: result.methods,
26309
+ authenticationFactor: AuthenticationFactorV2.SINGLE_FACTOR,
25994
26310
  }), undefined, result.continuationState.scenario);
25995
26311
  }
25996
26312
  catch (error) {
25997
26313
  this.logger.errorPii(`An error occurred during native auth V2 reset-password: '${error}'`, correlationId);
25998
26314
  return CustomAuthResultV2.createWithError(error, {
25999
- errorType: ResetPasswordStartErrorV2,
26000
26315
  scenario: CustomAuthFlowScenarioV2.PasswordReset,
26001
26316
  correlationId,
26002
26317
  });
@@ -26007,6 +26322,9 @@
26007
26322
  try {
26008
26323
  ensureArgumentIsNotNullOrUndefined("inputs", inputs, correlationId);
26009
26324
  ensureArgumentIsNotEmptyString("inputs.username", inputs.username, correlationId);
26325
+ if (inputs.scopes !== undefined && inputs.scopes !== null) {
26326
+ ensureArgumentIsStringArray("inputs.scopes", inputs.scopes, correlationId);
26327
+ }
26010
26328
  if (inputs.claims) {
26011
26329
  ensureArgumentIsJSONString("inputs.claims", inputs.claims, correlationId);
26012
26330
  }
@@ -26017,19 +26335,19 @@
26017
26335
  username: inputs.username,
26018
26336
  password: inputs.password,
26019
26337
  scopes: inputs.scopes,
26338
+ claims: inputs.claims,
26020
26339
  });
26021
26340
  if (result.type === FLOW_COMPLETED_V2) {
26022
26341
  return new CustomAuthResultV2(new CompletedStateV2(), new CustomAuthAccountData(result.authenticationResult.account, this.customAuthConfig, this.cacheClient, this.logger, correlationId), CustomAuthFlowScenarioV2.SignIn);
26023
26342
  }
26024
- if (result.type === FLOW_MFA_REQUIRED_V2) {
26025
- return new CustomAuthResultV2(new MFARequiredStateV2({
26343
+ if (result.type === FLOW_PASSWORD_REQUIRED_V2) {
26344
+ return new CustomAuthResultV2(new PasswordRequiredStateV2({
26026
26345
  correlationId: result.correlationId,
26027
26346
  logger: this.logger,
26028
26347
  config: this.customAuthConfig,
26029
26348
  flowClient: this.flowClientV2,
26030
26349
  continuationState: result.continuationState,
26031
26350
  cacheClient: this.cacheClient,
26032
- methods: result.methods,
26033
26351
  }), undefined, result.continuationState.scenario);
26034
26352
  }
26035
26353
  if (result.type === FLOW_CODE_REQUIRED_V2) {
@@ -26040,20 +26358,36 @@
26040
26358
  flowClient: this.flowClientV2,
26041
26359
  continuationState: result.continuationState,
26042
26360
  cacheClient: this.cacheClient,
26361
+ signInStateTransitionHandler: this.signInStateTransitionHandlerV2,
26043
26362
  method: result.method,
26044
26363
  sentTo: result.sentTo,
26045
26364
  channel: result.channel,
26046
26365
  codeLength: result.codeLength,
26047
26366
  }), undefined, result.continuationState.scenario);
26048
26367
  }
26049
- if (result.type === FLOW_PASSWORD_REQUIRED_V2) {
26050
- return new CustomAuthResultV2(new PasswordRequiredStateV2({
26368
+ if (result.type === FLOW_METHOD_SELECTION_REQUIRED_V2) {
26369
+ return new CustomAuthResultV2(new AuthMethodSelectionRequiredStateV2({
26370
+ correlationId: result.correlationId,
26371
+ logger: this.logger,
26372
+ config: this.customAuthConfig,
26373
+ flowClient: this.flowClientV2,
26374
+ continuationState: result.continuationState,
26375
+ cacheClient: this.cacheClient,
26376
+ methods: result.methods,
26377
+ authenticationFactor: AuthenticationFactorV2.SINGLE_FACTOR,
26378
+ signInStateTransitionHandler: this.signInStateTransitionHandlerV2,
26379
+ }), undefined, result.continuationState.scenario);
26380
+ }
26381
+ if (result.type === FLOW_MFA_REQUIRED_V2) {
26382
+ return new CustomAuthResultV2(new AuthMethodSelectionRequiredStateV2({
26051
26383
  correlationId: result.correlationId,
26052
26384
  logger: this.logger,
26053
26385
  config: this.customAuthConfig,
26054
26386
  flowClient: this.flowClientV2,
26055
26387
  continuationState: result.continuationState,
26056
26388
  cacheClient: this.cacheClient,
26389
+ methods: result.methods,
26390
+ authenticationFactor: AuthenticationFactorV2.MULTI_FACTOR,
26057
26391
  }), undefined, result.continuationState.scenario);
26058
26392
  }
26059
26393
  throw new UnexpectedError("Unsupported native auth V2 sign-in result type.", correlationId);
@@ -26061,7 +26395,6 @@
26061
26395
  catch (error) {
26062
26396
  this.logger.errorPii(`An error occurred during native auth V2 sign-in: '${error}'`, correlationId);
26063
26397
  return CustomAuthResultV2.createWithError(error, {
26064
- errorType: SignInStartErrorV2,
26065
26398
  scenario: CustomAuthFlowScenarioV2.SignIn,
26066
26399
  correlationId,
26067
26400
  });
@@ -26076,6 +26409,12 @@
26076
26409
  ensureArgumentIsNotNullOrUndefined("inputs.password", inputs.password, correlationId);
26077
26410
  ensureArgumentIsNotEmptyString("inputs.password", inputs.password, correlationId);
26078
26411
  }
26412
+ if (inputs.scopes !== undefined && inputs.scopes !== null) {
26413
+ ensureArgumentIsStringArray("inputs.scopes", inputs.scopes, correlationId);
26414
+ }
26415
+ if (inputs.claims) {
26416
+ ensureArgumentIsJSONString("inputs.claims", inputs.claims, correlationId);
26417
+ }
26079
26418
  this.ensureUserNotSignedIn(correlationId);
26080
26419
  this.logger.verbose("Starting native auth V2 sign-up.", correlationId);
26081
26420
  const result = await this.flowClientV2.signUp({
@@ -26121,7 +26460,6 @@
26121
26460
  catch (error) {
26122
26461
  this.logger.errorPii(`An error occurred during native auth V2 sign-up: '${error}'`, correlationId);
26123
26462
  return CustomAuthResultV2.createWithError(error, {
26124
- errorType: SignUpStartErrorV2,
26125
26463
  scenario: CustomAuthFlowScenarioV2.SignUp,
26126
26464
  correlationId,
26127
26465
  });
@@ -26613,6 +26951,79 @@
26613
26951
  */
26614
26952
  NestedAppOperatingContext.ID = "NestedAppOperatingContext";
26615
26953
 
26954
+ /*
26955
+ * Copyright (c) Microsoft Corporation. All rights reserved.
26956
+ * Licensed under the MIT License.
26957
+ */
26958
+ const IFRAME_POLL_INTERVAL_MS = 50;
26959
+ const DEFAULT_IFRAME_TIMEOUT_MS = 10000;
26960
+ /**
26961
+ * Monitors an iframe content window until it loads a URL with a known hash, or hits a specified timeout.
26962
+ *
26963
+ * @param iframe - The hidden iframe to monitor.
26964
+ * @param timeout - Maximum time (ms) to wait for navigation before rejecting with
26965
+ * `monitor_window_timeout`.
26966
+ * @param logger - Logger instance.
26967
+ * @param correlationId
26968
+ * @param responseMode - `"query"` or `"fragment"` — determines whether to read
26969
+ * `location.search` or `location.hash`. Any value other than `"query"` is
26970
+ * treated as fragment.
26971
+ */
26972
+ async function monitorIframeForHash(iframe, timeout, logger, correlationId, responseMode) {
26973
+ return new Promise((resolve, reject) => {
26974
+ if (timeout < DEFAULT_IFRAME_TIMEOUT_MS) {
26975
+ logger.warning(`system.iframeBridgeTimeout set to lower (${timeout}ms) than the default (${DEFAULT_IFRAME_TIMEOUT_MS}ms). This may result in timeouts.`, correlationId);
26976
+ }
26977
+ /*
26978
+ * Polling for iframes can be purely timing based,
26979
+ * since we don't need to account for interaction.
26980
+ */
26981
+ const timeoutId = window.setTimeout(() => {
26982
+ window.clearInterval(intervalId);
26983
+ reject(new AuthError(timedOut, correlationId, undefined, "monitor_window_timeout"));
26984
+ }, timeout);
26985
+ const intervalId = window.setInterval(() => {
26986
+ const contentWindow = iframe.contentWindow;
26987
+ if (!contentWindow) {
26988
+ return;
26989
+ }
26990
+ let href = "";
26991
+ try {
26992
+ /*
26993
+ * Will throw if cross origin,
26994
+ * which should be caught and ignored
26995
+ * since we need the interval to keep running while on STS UI.
26996
+ */
26997
+ href = contentWindow.location.href;
26998
+ }
26999
+ catch (e) { }
27000
+ if (!href || href === "about:blank") {
27001
+ return;
27002
+ }
27003
+ const responseString = responseMode === ResponseMode.QUERY
27004
+ ? contentWindow.location.search
27005
+ : contentWindow.location.hash;
27006
+ window.clearTimeout(timeoutId);
27007
+ window.clearInterval(intervalId);
27008
+ resolve(responseString);
27009
+ }, IFRAME_POLL_INTERVAL_MS);
27010
+ }).finally(() => {
27011
+ /*
27012
+ * Strip auth-response params from the iframe URL. The monitor owns the
27013
+ * iframe for the duration of the poll, mirroring cleanPopup in
27014
+ * PopupMonitor.
27015
+ */
27016
+ try {
27017
+ if (iframe.contentWindow) {
27018
+ clearAuthResponseFromUrl(iframe.contentWindow);
27019
+ }
27020
+ }
27021
+ catch {
27022
+ // Iframe may already be navigated away or cross-origin; ignore.
27023
+ }
27024
+ });
27025
+ }
27026
+
26616
27027
  /*
26617
27028
  * Copyright (c) Microsoft Corporation. All rights reserved.
26618
27029
  * Licensed under the MIT License.
@@ -26655,27 +27066,29 @@
26655
27066
  /**
26656
27067
  * Waits for the auth response from a popup window opened by MSAL.
26657
27068
  *
26658
- * The default implementation delegates to MSAL's `BroadcastChannel`-based bridge.
26659
- * Subclasses must return the raw response string (hash/query/fragment), or reject
26660
- * with an `AuthError` on failure.
27069
+ * The default implementation delegates to MSAL's `BroadcastChannel`-based bridge,
27070
+ * or to the v4-style same-origin location poller when
27071
+ * `system.enableLegacyPolling` is set. Subclasses must return the raw response
27072
+ * string (hash/query/fragment), or reject with an `AuthError` on failure.
26661
27073
  *
26662
27074
  * @internal
26663
27075
  * @param request The in-flight authorization or end-session request.
26664
27076
  * @param popupWindow The popup window opened by MSAL.
26665
27077
  * @param popupWindowParent The parent window that opened the popup.
26666
27078
  */
26667
- async waitForPopupResponse(request,
26668
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
26669
- popupWindow,
26670
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
26671
- popupWindowParent) {
27079
+ async waitForPopupResponse(request, popupWindow, popupWindowParent) {
26672
27080
  const controller = this.controller;
26673
- return waitForBridgeResponse(controller.getConfiguration().system.popupBridgeTimeout, controller.getLogger(), request, controller.getPerformanceClient());
27081
+ const config = controller.getConfiguration();
27082
+ if (config.system.enableLegacyPolling) {
27083
+ return waitForPopupPollingResponse(config, controller.getLogger(), controller.getPerformanceClient(), request, popupWindow, popupWindowParent);
27084
+ }
27085
+ return waitForBridgeResponse(config.system.popupBridgeTimeout, controller.getLogger(), request, controller.getPerformanceClient());
26674
27086
  }
26675
27087
  /**
26676
27088
  * Waits for the auth response from a hidden iframe used by MSAL silent flows.
26677
27089
  *
26678
- * The default implementation delegates to MSAL's `BroadcastChannel`-based bridge.
27090
+ * The default implementation delegates to MSAL's `BroadcastChannel`-based bridge,
27091
+ * or to the v4-style location poller when `system.enableLegacyPolling` is set.
26679
27092
  * Subclasses must return the raw response string (hash/query/fragment), or reject
26680
27093
  * with an `AuthError` on failure.
26681
27094
  *
@@ -26683,11 +27096,12 @@
26683
27096
  * @param iframe The hidden iframe MSAL attached to the document.
26684
27097
  * @param request The in-flight authorization request.
26685
27098
  */
26686
- async waitForIframeResponse(
26687
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
26688
- iframe, request) {
27099
+ async waitForIframeResponse(iframe, request) {
26689
27100
  const controller = this.controller;
26690
27101
  const config = controller.getConfiguration();
27102
+ if (config.system.enableLegacyPolling) {
27103
+ return waitForIframePollingResponse(config, controller.getLogger(), controller.getPerformanceClient(), iframe, request);
27104
+ }
26691
27105
  return waitForBridgeResponse(config.system.iframeBridgeTimeout, controller.getLogger(), request, controller.getPerformanceClient(), config.experimental);
26692
27106
  }
26693
27107
  /**
@@ -26920,6 +27334,40 @@
26920
27334
  clearCache(logoutRequest) {
26921
27335
  return this.controller.clearCache(logoutRequest);
26922
27336
  }
27337
+ }
27338
+ /**
27339
+ * Collects a popup auth response using the v4-style same-origin location
27340
+ * poller instead of the `BroadcastChannel` redirect bridge.
27341
+ */
27342
+ async function waitForPopupPollingResponse(config, logger, performanceClient, request, popupWindow, popupWindowParent) {
27343
+ const responseMode = config.auth.OIDCOptions?.responseMode === ResponseMode.QUERY
27344
+ ? ResponseMode.QUERY
27345
+ : ResponseMode.FRAGMENT;
27346
+ performanceClient.addFields({ usesLegacyPolling: true }, request.correlationId);
27347
+ const unloadHandler = () => {
27348
+ try {
27349
+ if (popupWindow && !popupWindow.closed) {
27350
+ popupWindow.close();
27351
+ }
27352
+ }
27353
+ catch {
27354
+ /* ignore */
27355
+ }
27356
+ };
27357
+ popupWindowParent.addEventListener("beforeunload", unloadHandler);
27358
+ return monitorPopupForHash(popupWindow, popupWindowParent, responseMode, logger, unloadHandler, request.correlationId);
27359
+ }
27360
+ /**
27361
+ * Collects a silent-iframe auth response using the v4-style location poller
27362
+ * instead of the `BroadcastChannel` redirect bridge.
27363
+ */
27364
+ async function waitForIframePollingResponse(config, logger, performanceClient, iframe, request) {
27365
+ const responseMode = config.auth.OIDCOptions?.responseMode === ResponseMode.QUERY
27366
+ ? ResponseMode.QUERY
27367
+ : ResponseMode.FRAGMENT;
27368
+ const iframePollTimeout = config.system.iframeBridgeTimeout;
27369
+ performanceClient.addFields({ usesLegacyPolling: true, iframePollTimeout }, request.correlationId);
27370
+ return monitorIframeForHash(iframe, iframePollTimeout, logger, request.correlationId, responseMode);
26923
27371
  }
26924
27372
 
26925
27373
  /*
@@ -27055,6 +27503,7 @@
27055
27503
 
27056
27504
  exports.AttributesRequiredStateV2 = AttributesRequiredStateV2;
27057
27505
  exports.AuthFlowActionRequiredStateBase = AuthFlowActionRequiredStateBase;
27506
+ exports.AuthFlowErrorV2 = AuthFlowErrorV2;
27058
27507
  exports.AuthFlowStateBase = AuthFlowStateBase;
27059
27508
  exports.AuthMethodRegistrationChallengeMethodError = AuthMethodRegistrationChallengeMethodError;
27060
27509
  exports.AuthMethodRegistrationChallengeMethodResult = AuthMethodRegistrationChallengeMethodResult;
@@ -27081,7 +27530,6 @@
27081
27530
  exports.HttpError = HttpError;
27082
27531
  exports.InvalidArgumentError = InvalidArgumentError;
27083
27532
  exports.InvalidConfigurationError = InvalidConfigurationError;
27084
- exports.MFARequiredStateV2 = MFARequiredStateV2;
27085
27533
  exports.MFAVerificationRequiredStateV2 = MFAVerificationRequiredStateV2;
27086
27534
  exports.MethodNotImplementedError = MethodNotImplementedError;
27087
27535
  exports.MfaAwaitingState = MfaAwaitingState;
@@ -27097,7 +27545,6 @@
27097
27545
  exports.NoCachedAccountFoundError = NoCachedAccountFoundError;
27098
27546
  exports.ParsedUrlError = ParsedUrlError;
27099
27547
  exports.PasswordRequiredStateV2 = PasswordRequiredStateV2;
27100
- exports.RequestChallengeErrorV2 = RequestChallengeErrorV2;
27101
27548
  exports.ResetPasswordCodeRequiredState = ResetPasswordCodeRequiredState;
27102
27549
  exports.ResetPasswordCompletedState = ResetPasswordCompletedState;
27103
27550
  exports.ResetPasswordError = ResetPasswordError;
@@ -27105,7 +27552,6 @@
27105
27552
  exports.ResetPasswordPasswordRequiredState = ResetPasswordPasswordRequiredState;
27106
27553
  exports.ResetPasswordResendCodeError = ResetPasswordResendCodeError;
27107
27554
  exports.ResetPasswordResendCodeResult = ResetPasswordResendCodeResult;
27108
- exports.ResetPasswordStartErrorV2 = ResetPasswordStartErrorV2;
27109
27555
  exports.ResetPasswordStartResult = ResetPasswordStartResult;
27110
27556
  exports.ResetPasswordState = ResetPasswordState;
27111
27557
  exports.ResetPasswordSubmitCodeError = ResetPasswordSubmitCodeError;
@@ -27114,7 +27560,6 @@
27114
27560
  exports.ResetPasswordSubmitPasswordResult = ResetPasswordSubmitPasswordResult;
27115
27561
  exports.SignInCodeRequiredState = SignInCodeRequiredState;
27116
27562
  exports.SignInCompletedState = SignInCompletedState;
27117
- exports.SignInContinuationErrorV2 = SignInContinuationErrorV2;
27118
27563
  exports.SignInContinuationState = SignInContinuationState;
27119
27564
  exports.SignInContinuationStateV2 = SignInContinuationStateV2;
27120
27565
  exports.SignInError = SignInError;
@@ -27123,7 +27568,6 @@
27123
27568
  exports.SignInResendCodeError = SignInResendCodeError;
27124
27569
  exports.SignInResendCodeResult = SignInResendCodeResult;
27125
27570
  exports.SignInResult = SignInResult;
27126
- exports.SignInStartErrorV2 = SignInStartErrorV2;
27127
27571
  exports.SignInState = SignInState;
27128
27572
  exports.SignInSubmitCodeError = SignInSubmitCodeError;
27129
27573
  exports.SignInSubmitCodeResult = SignInSubmitCodeResult;
@@ -27141,7 +27585,6 @@
27141
27585
  exports.SignUpResendCodeError = SignUpResendCodeError;
27142
27586
  exports.SignUpResendCodeResult = SignUpResendCodeResult;
27143
27587
  exports.SignUpResult = SignUpResult;
27144
- exports.SignUpStartErrorV2 = SignUpStartErrorV2;
27145
27588
  exports.SignUpState = SignUpState;
27146
27589
  exports.SignUpSubmitAttributesError = SignUpSubmitAttributesError;
27147
27590
  exports.SignUpSubmitAttributesResult = SignUpSubmitAttributesResult;
@@ -27149,14 +27592,10 @@
27149
27592
  exports.SignUpSubmitCodeResult = SignUpSubmitCodeResult;
27150
27593
  exports.SignUpSubmitPasswordError = SignUpSubmitPasswordError;
27151
27594
  exports.SignUpSubmitPasswordResult = SignUpSubmitPasswordResult;
27152
- exports.SubmitAttributesErrorV2 = SubmitAttributesErrorV2;
27153
- exports.SubmitNewPasswordErrorV2 = SubmitNewPasswordErrorV2;
27154
- exports.SubmitPasswordErrorV2 = SubmitPasswordErrorV2;
27155
27595
  exports.UnexpectedError = UnexpectedError;
27156
27596
  exports.UnsupportedEnvironmentError = UnsupportedEnvironmentError;
27157
27597
  exports.UserAccountAttributeError = UserAccountAttributeError;
27158
27598
  exports.UserAlreadySignedInError = UserAlreadySignedInError;
27159
- exports.VerifyChallengeErrorV2 = VerifyChallengeErrorV2;
27160
27599
 
27161
27600
  }));
27162
27601
  //# sourceMappingURL=msal-custom-auth.js.map