@azure/msal-browser 5.26.0 → 5.28.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 (463) 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 +9 -1
  7. package/dist/broker/nativeBroker/PlatformAuthDOMHandler.mjs.map +1 -1
  8. package/dist/broker/nativeBroker/PlatformAuthExtensionHandler.mjs +7 -6
  9. package/dist/broker/nativeBroker/PlatformAuthExtensionHandler.mjs.map +1 -1
  10. package/dist/broker/nativeBroker/PlatformAuthProvider.mjs +4 -2
  11. package/dist/broker/nativeBroker/PlatformAuthProvider.mjs.map +1 -1
  12. package/dist/broker/nativeBroker/PlatformAuthRequest.mjs +21 -7
  13. package/dist/broker/nativeBroker/PlatformAuthRequest.mjs.map +1 -1
  14. package/dist/cache/AccountManager.mjs +1 -1
  15. package/dist/cache/AsyncMemoryStorage.mjs +14 -1
  16. package/dist/cache/AsyncMemoryStorage.mjs.map +1 -1
  17. package/dist/cache/BrowserCacheManager.mjs +9 -2
  18. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  19. package/dist/cache/CacheHelpers.mjs +1 -1
  20. package/dist/cache/CacheKeys.mjs +1 -1
  21. package/dist/cache/CookieStorage.mjs +1 -1
  22. package/dist/cache/DatabaseStorage.mjs +1 -1
  23. package/dist/cache/EncryptedData.mjs +1 -1
  24. package/dist/cache/LocalStorage.mjs +1 -1
  25. package/dist/cache/MemoryStorage.mjs +1 -1
  26. package/dist/cache/SessionStorage.mjs +1 -1
  27. package/dist/cache/TokenCache.mjs +1 -1
  28. package/dist/config/Configuration.mjs +32 -4
  29. package/dist/config/Configuration.mjs.map +1 -1
  30. package/dist/controllers/NestedAppAuthController.mjs +1 -1
  31. package/dist/controllers/StandardController.mjs +100 -11
  32. package/dist/controllers/StandardController.mjs.map +1 -1
  33. package/dist/crypto/BrowserCrypto.mjs +1 -1
  34. package/dist/crypto/CryptoOps.mjs +1 -1
  35. package/dist/crypto/PkceGenerator.mjs +1 -1
  36. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  37. package/dist/crypto/TokenBindingKeyManager.mjs +14 -1
  38. package/dist/crypto/TokenBindingKeyManager.mjs.map +1 -1
  39. package/dist/custom_auth/CustomAuthConstants.mjs +1 -1
  40. package/dist/custom_auth/CustomAuthPublicClientApplication.mjs +1 -1
  41. package/dist/custom_auth/controller/CustomAuthStandardController.mjs +14 -2
  42. package/dist/custom_auth/controller/CustomAuthStandardController.mjs.map +1 -1
  43. package/dist/custom_auth/core/CustomAuthAuthority.mjs +1 -1
  44. package/dist/custom_auth/core/auth_flow/AuthFlowErrorBase.mjs +1 -1
  45. package/dist/custom_auth/core/auth_flow/AuthFlowResultBase.mjs +1 -1
  46. package/dist/custom_auth/core/auth_flow/AuthFlowState.mjs +1 -1
  47. package/dist/custom_auth/core/auth_flow/AuthFlowStateTypes.mjs +1 -1
  48. package/dist/custom_auth/core/auth_flow/jit/error_type/AuthMethodRegistrationError.mjs +1 -1
  49. package/dist/custom_auth/core/auth_flow/jit/result/AuthMethodRegistrationChallengeMethodResult.mjs +1 -1
  50. package/dist/custom_auth/core/auth_flow/jit/result/AuthMethodRegistrationSubmitChallengeResult.mjs +1 -1
  51. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationCompletedState.mjs +1 -1
  52. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationFailedState.mjs +1 -1
  53. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationState.mjs +1 -1
  54. package/dist/custom_auth/core/auth_flow/mfa/error_type/MfaError.mjs +1 -1
  55. package/dist/custom_auth/core/auth_flow/mfa/result/MfaRequestChallengeResult.mjs +1 -1
  56. package/dist/custom_auth/core/auth_flow/mfa/result/MfaSubmitChallengeResult.mjs +1 -1
  57. package/dist/custom_auth/core/auth_flow/mfa/state/MfaCompletedState.mjs +1 -1
  58. package/dist/custom_auth/core/auth_flow/mfa/state/MfaFailedState.mjs +1 -1
  59. package/dist/custom_auth/core/auth_flow/mfa/state/MfaState.mjs +1 -1
  60. package/dist/custom_auth/core/auth_flow/v2/CustomAuthFlowScenarioV2.mjs +1 -1
  61. package/dist/custom_auth/core/auth_flow/v2/CustomAuthResultV2.mjs +1 -1
  62. package/dist/custom_auth/core/auth_flow/v2/error/AuthFlowErrorSubcodesV2.mjs +1 -1
  63. package/dist/custom_auth/core/auth_flow/v2/error/AuthFlowErrorV2.mjs +1 -1
  64. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodRegistrationRequiredStateV2.mjs +68 -0
  65. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodRegistrationRequiredStateV2.mjs.map +1 -0
  66. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.mjs +3 -2
  67. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.mjs.map +1 -1
  68. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodVerificationRequiredStateV2.mjs +87 -0
  69. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodVerificationRequiredStateV2.mjs.map +1 -0
  70. package/dist/custom_auth/core/auth_flow/v2/state/ChallengeVerificationStateBaseV2.mjs +5 -3
  71. package/dist/custom_auth/core/auth_flow/v2/state/ChallengeVerificationStateBaseV2.mjs.map +1 -1
  72. package/dist/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.mjs +14 -2
  73. package/dist/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.mjs.map +1 -1
  74. package/dist/custom_auth/core/auth_flow/v2/state/CompletedStateV2.mjs +1 -1
  75. package/dist/custom_auth/core/auth_flow/v2/state/FailedStateV2.mjs +1 -1
  76. package/dist/custom_auth/core/auth_flow/v2/state/MFAVerificationRequiredStateV2.mjs +4 -3
  77. package/dist/custom_auth/core/auth_flow/v2/state/MFAVerificationRequiredStateV2.mjs.map +1 -1
  78. package/dist/custom_auth/core/error/CustomAuthApiError.mjs +1 -1
  79. package/dist/custom_auth/core/error/CustomAuthError.mjs +1 -1
  80. package/dist/custom_auth/core/error/HttpError.mjs +1 -1
  81. package/dist/custom_auth/core/error/HttpErrorCodes.mjs +1 -1
  82. package/dist/custom_auth/core/error/InvalidArgumentError.mjs +1 -1
  83. package/dist/custom_auth/core/error/InvalidConfigurationError.mjs +1 -1
  84. package/dist/custom_auth/core/error/InvalidConfigurationErrorCodes.mjs +1 -1
  85. package/dist/custom_auth/core/error/MethodNotImplementedError.mjs +1 -1
  86. package/dist/custom_auth/core/error/MsalCustomAuthError.mjs +1 -1
  87. package/dist/custom_auth/core/error/NoCachedAccountFoundError.mjs +1 -1
  88. package/dist/custom_auth/core/error/ParsedUrlError.mjs +1 -1
  89. package/dist/custom_auth/core/error/ParsedUrlErrorCodes.mjs +1 -1
  90. package/dist/custom_auth/core/error/UnexpectedError.mjs +1 -1
  91. package/dist/custom_auth/core/error/UnsupportedEnvironmentError.mjs +1 -1
  92. package/dist/custom_auth/core/error/UserAccountAttributeError.mjs +1 -1
  93. package/dist/custom_auth/core/error/UserAlreadySignedInError.mjs +1 -1
  94. package/dist/custom_auth/core/interaction_client/CustomAuthInteractionClientBase.mjs +1 -1
  95. package/dist/custom_auth/core/interaction_client/CustomAuthInterationClientFactory.mjs +1 -1
  96. package/dist/custom_auth/core/interaction_client/jit/JitClient.mjs +1 -1
  97. package/dist/custom_auth/core/interaction_client/jit/result/JitActionResult.mjs +1 -1
  98. package/dist/custom_auth/core/interaction_client/mfa/MfaClient.mjs +1 -1
  99. package/dist/custom_auth/core/interaction_client/mfa/result/MfaActionResult.mjs +1 -1
  100. package/dist/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.mjs +246 -73
  101. package/dist/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.mjs.map +1 -1
  102. package/dist/custom_auth/core/interaction_client/v2/InteractionClientBaseV2.mjs +1 -1
  103. package/dist/custom_auth/core/interaction_client/v2/result/FlowActionResultV2.mjs +10 -2
  104. package/dist/custom_auth/core/interaction_client/v2/result/FlowActionResultV2.mjs.map +1 -1
  105. package/dist/custom_auth/core/network_client/custom_auth_api/BaseApiClient.mjs +1 -1
  106. package/dist/custom_auth/core/network_client/custom_auth_api/CustomAuthApiClient.mjs +1 -1
  107. package/dist/custom_auth/core/network_client/custom_auth_api/CustomAuthApiEndpoint.mjs +1 -1
  108. package/dist/custom_auth/core/network_client/custom_auth_api/RegisterApiClient.mjs +1 -1
  109. package/dist/custom_auth/core/network_client/custom_auth_api/ResetPasswordApiClient.mjs +1 -1
  110. package/dist/custom_auth/core/network_client/custom_auth_api/SignInApiClient.mjs +1 -1
  111. package/dist/custom_auth/core/network_client/custom_auth_api/SignupApiClient.mjs +1 -1
  112. package/dist/custom_auth/core/network_client/custom_auth_api/types/ApiErrorCodes.mjs +1 -1
  113. package/dist/custom_auth/core/network_client/custom_auth_api/types/ApiSuberrors.mjs +1 -1
  114. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.mjs +10 -2
  115. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.mjs.map +1 -1
  116. package/dist/custom_auth/core/network_client/custom_auth_api/v2/BaseApiClientV2.mjs +1 -1
  117. package/dist/custom_auth/core/network_client/custom_auth_api/v2/CustomAuthApiClientV2.mjs +118 -25
  118. package/dist/custom_auth/core/network_client/custom_auth_api/v2/CustomAuthApiClientV2.mjs.map +1 -1
  119. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ErrorCodesV2.mjs +1 -1
  120. package/dist/custom_auth/core/network_client/custom_auth_api/v2/HrefResolverV2.mjs +1 -1
  121. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.mjs +2 -2
  122. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.mjs.map +1 -1
  123. package/dist/custom_auth/core/network_client/custom_auth_api/v2/response/ErrorNormalizerV2.mjs +1 -1
  124. package/dist/custom_auth/core/network_client/custom_auth_api/v2/result/BaseResultsV2.mjs +2 -12
  125. package/dist/custom_auth/core/network_client/custom_auth_api/v2/result/BaseResultsV2.mjs.map +1 -1
  126. package/dist/custom_auth/core/network_client/custom_auth_api/v2/result/SignUpResultsV2.mjs +2 -1
  127. package/dist/custom_auth/core/network_client/custom_auth_api/v2/result/SignUpResultsV2.mjs.map +1 -1
  128. package/dist/custom_auth/core/network_client/http_client/FetchHttpClient.mjs +1 -1
  129. package/dist/custom_auth/core/network_client/http_client/IHttpClient.mjs +1 -1
  130. package/dist/custom_auth/core/telemetry/FlowApiIdHelperV2.mjs +17 -3
  131. package/dist/custom_auth/core/telemetry/FlowApiIdHelperV2.mjs.map +1 -1
  132. package/dist/custom_auth/core/telemetry/PublicApiId.mjs +9 -3
  133. package/dist/custom_auth/core/telemetry/PublicApiId.mjs.map +1 -1
  134. package/dist/custom_auth/core/utils/ArgumentValidator.mjs +1 -1
  135. package/dist/custom_auth/core/utils/CustomHeaderUtils.mjs +1 -1
  136. package/dist/custom_auth/core/utils/UrlUtils.mjs +1 -1
  137. package/dist/custom_auth/get_account/auth_flow/CustomAuthAccountData.mjs +1 -1
  138. package/dist/custom_auth/get_account/auth_flow/error_type/GetAccountError.mjs +1 -1
  139. package/dist/custom_auth/get_account/auth_flow/result/GetAccessTokenResult.mjs +1 -1
  140. package/dist/custom_auth/get_account/auth_flow/result/GetAccountResult.mjs +1 -1
  141. package/dist/custom_auth/get_account/auth_flow/result/SignOutResult.mjs +1 -1
  142. package/dist/custom_auth/get_account/auth_flow/state/GetAccessTokenState.mjs +1 -1
  143. package/dist/custom_auth/get_account/auth_flow/state/GetAccountState.mjs +1 -1
  144. package/dist/custom_auth/get_account/auth_flow/state/SignOutState.mjs +1 -1
  145. package/dist/custom_auth/get_account/interaction_client/CustomAuthSilentCacheClient.mjs +1 -1
  146. package/dist/custom_auth/index.mjs +3 -1
  147. package/dist/custom_auth/index.mjs.map +1 -1
  148. package/dist/custom_auth/operating_context/CustomAuthOperatingContext.mjs +1 -1
  149. package/dist/custom_auth/reset_password/auth_flow/error_type/ResetPasswordError.mjs +1 -1
  150. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordResendCodeResult.mjs +1 -1
  151. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordStartResult.mjs +1 -1
  152. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordSubmitCodeResult.mjs +1 -1
  153. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordSubmitPasswordResult.mjs +1 -1
  154. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordCodeRequiredState.mjs +1 -1
  155. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordCompletedState.mjs +1 -1
  156. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordFailedState.mjs +1 -1
  157. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordPasswordRequiredState.mjs +1 -1
  158. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordState.mjs +1 -1
  159. package/dist/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.mjs +32 -13
  160. package/dist/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.mjs.map +1 -1
  161. package/dist/custom_auth/reset_password/interaction_client/ResetPasswordClient.mjs +1 -1
  162. package/dist/custom_auth/sign_in/auth_flow/SignInScenario.mjs +1 -1
  163. package/dist/custom_auth/sign_in/auth_flow/error_type/SignInError.mjs +1 -1
  164. package/dist/custom_auth/sign_in/auth_flow/result/SignInResendCodeResult.mjs +1 -1
  165. package/dist/custom_auth/sign_in/auth_flow/result/SignInResult.mjs +1 -1
  166. package/dist/custom_auth/sign_in/auth_flow/result/SignInSubmitCodeResult.mjs +1 -1
  167. package/dist/custom_auth/sign_in/auth_flow/result/SignInSubmitPasswordResult.mjs +1 -1
  168. package/dist/custom_auth/sign_in/auth_flow/state/SignInCodeRequiredState.mjs +1 -1
  169. package/dist/custom_auth/sign_in/auth_flow/state/SignInCompletedState.mjs +1 -1
  170. package/dist/custom_auth/sign_in/auth_flow/state/SignInContinuationState.mjs +1 -1
  171. package/dist/custom_auth/sign_in/auth_flow/state/SignInFailedState.mjs +1 -1
  172. package/dist/custom_auth/sign_in/auth_flow/state/SignInPasswordRequiredState.mjs +1 -1
  173. package/dist/custom_auth/sign_in/auth_flow/state/SignInState.mjs +1 -1
  174. package/dist/custom_auth/sign_in/auth_flow/v2/state/PasswordRequiredStateV2.mjs +14 -2
  175. package/dist/custom_auth/sign_in/auth_flow/v2/state/PasswordRequiredStateV2.mjs.map +1 -1
  176. package/dist/custom_auth/sign_in/auth_flow/v2/state/SignInContinuationStateV2.mjs +1 -1
  177. package/dist/custom_auth/sign_in/auth_flow/v2/state/SignInStateTransitionHandlerV2.mjs +1 -1
  178. package/dist/custom_auth/sign_in/interaction_client/SignInClient.mjs +1 -1
  179. package/dist/custom_auth/sign_in/interaction_client/result/SignInActionResult.mjs +1 -1
  180. package/dist/custom_auth/sign_up/auth_flow/error_type/SignUpError.mjs +1 -1
  181. package/dist/custom_auth/sign_up/auth_flow/result/SignUpResendCodeResult.mjs +1 -1
  182. package/dist/custom_auth/sign_up/auth_flow/result/SignUpResult.mjs +1 -1
  183. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitAttributesResult.mjs +1 -1
  184. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitCodeResult.mjs +1 -1
  185. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitPasswordResult.mjs +1 -1
  186. package/dist/custom_auth/sign_up/auth_flow/state/SignUpAttributesRequiredState.mjs +1 -1
  187. package/dist/custom_auth/sign_up/auth_flow/state/SignUpCodeRequiredState.mjs +1 -1
  188. package/dist/custom_auth/sign_up/auth_flow/state/SignUpCompletedState.mjs +1 -1
  189. package/dist/custom_auth/sign_up/auth_flow/state/SignUpFailedState.mjs +1 -1
  190. package/dist/custom_auth/sign_up/auth_flow/state/SignUpPasswordRequiredState.mjs +1 -1
  191. package/dist/custom_auth/sign_up/auth_flow/state/SignUpState.mjs +1 -1
  192. package/dist/custom_auth/sign_up/auth_flow/v2/state/AttributesRequiredStateV2.mjs +1 -1
  193. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpAttributesRequiredStateBaseV2.mjs +1 -1
  194. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpPasswordRequiredStateV2.mjs +1 -1
  195. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpStateTransitionHandlerV2.mjs +9 -2
  196. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpStateTransitionHandlerV2.mjs.map +1 -1
  197. package/dist/custom_auth/sign_up/interaction_client/SignUpClient.mjs +1 -1
  198. package/dist/custom_auth/sign_up/interaction_client/result/SignUpActionResult.mjs +1 -1
  199. package/dist/encode/Base64Decode.mjs +1 -1
  200. package/dist/encode/Base64Encode.mjs +1 -1
  201. package/dist/error/BrowserAuthError.mjs +1 -1
  202. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  203. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  204. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  205. package/dist/error/NativeAuthError.mjs +1 -1
  206. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  207. package/dist/error/NestedAppAuthError.mjs +1 -1
  208. package/dist/event/EventHandler.mjs +1 -1
  209. package/dist/event/EventMessage.mjs +1 -1
  210. package/dist/event/EventType.mjs +1 -1
  211. package/dist/index.mjs +1 -1
  212. package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
  213. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  214. package/dist/interaction_client/PlatformAuthInteractionClient.mjs +504 -75
  215. package/dist/interaction_client/PlatformAuthInteractionClient.mjs.map +1 -1
  216. package/dist/interaction_client/PopupClient.mjs +54 -20
  217. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  218. package/dist/interaction_client/RedirectClient.mjs +30 -16
  219. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  220. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  221. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  222. package/dist/interaction_client/SilentIframeClient.mjs +44 -32
  223. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  224. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  225. package/dist/interaction_client/StandardInteractionClient.mjs +7 -1
  226. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  227. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  228. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  229. package/dist/log-strings-mapping.json +79 -19
  230. package/dist/naa/BridgeError.mjs +1 -1
  231. package/dist/naa/BridgeProxy.mjs +1 -1
  232. package/dist/naa/BridgeStatusCode.mjs +1 -1
  233. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  234. package/dist/navigation/NavigationClient.mjs +1 -1
  235. package/dist/network/FetchClient.mjs +1 -1
  236. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  237. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  238. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  239. package/dist/packageMetadata.mjs +2 -2
  240. package/dist/popup_relay/constants.mjs +1 -1
  241. package/dist/popup_relay/index.mjs +1 -1
  242. package/dist/popup_relay/relayClient.mjs +1 -1
  243. package/dist/protocol/Authorize.mjs +43 -25
  244. package/dist/protocol/Authorize.mjs.map +1 -1
  245. package/dist/redirect_bridge/index.mjs +1 -1
  246. package/dist/request/RequestHelpers.mjs +35 -11
  247. package/dist/request/RequestHelpers.mjs.map +1 -1
  248. package/dist/request/SilentRequestHelpers.mjs +6 -6
  249. package/dist/request/SilentRequestHelpers.mjs.map +1 -1
  250. package/dist/response/ResponseHandler.mjs +1 -1
  251. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  252. package/dist/telemetry/BrowserPerformanceEvents.mjs +3 -2
  253. package/dist/telemetry/BrowserPerformanceEvents.mjs.map +1 -1
  254. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  255. package/dist/telemetry/BrowserRootPerformanceEvents.mjs +1 -1
  256. package/dist/utils/BrowserConstants.mjs +1 -1
  257. package/dist/utils/BrowserDetection.mjs +1 -1
  258. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  259. package/dist/utils/BrowserUtils.mjs +7 -2
  260. package/dist/utils/BrowserUtils.mjs.map +1 -1
  261. package/dist/utils/Helpers.mjs +1 -1
  262. package/dist/utils/IframeMonitor.mjs +81 -0
  263. package/dist/utils/IframeMonitor.mjs.map +1 -0
  264. package/dist/utils/MsalFrameStatsUtils.mjs +1 -1
  265. package/dist/utils/PopupMonitor.mjs +119 -0
  266. package/dist/utils/PopupMonitor.mjs.map +1 -0
  267. package/dist/utils/PopupOriginCheck.mjs +88 -0
  268. package/dist/utils/PopupOriginCheck.mjs.map +1 -0
  269. package/dist/webBrokerBridge/PendingRequestRegistry.mjs +1 -1
  270. package/dist/webBrokerBridge/PerfEventNames.mjs +1 -1
  271. package/dist/webBrokerBridge/WebBrokerBridgeError.mjs +1 -1
  272. package/dist/webBrokerBridge/WebBrokerBridgeErrorMap.mjs +1 -1
  273. package/dist/webBrokerBridge/adapter/CrossVersionRequestAdapter.mjs +1 -1
  274. package/dist/webBrokerBridge/index.mjs +1 -1
  275. package/lib/custom-auth-path/log-strings-mapping.json +71 -11
  276. package/lib/custom-auth-path/msal-custom-auth.cjs +2085 -451
  277. package/lib/custom-auth-path/msal-custom-auth.cjs.map +1 -1
  278. package/lib/custom-auth-path/msal-custom-auth.js +2085 -451
  279. package/lib/custom-auth-path/msal-custom-auth.js.map +1 -1
  280. package/lib/log-strings-mapping.json +39 -11
  281. package/lib/msal-browser.cjs +1461 -320
  282. package/lib/msal-browser.cjs.map +1 -1
  283. package/lib/msal-browser.js +1461 -320
  284. package/lib/msal-browser.js.map +1 -1
  285. package/lib/msal-browser.min.js +2 -2
  286. package/lib/popup-relay/msal-popup-relay.cjs +2 -2
  287. package/lib/popup-relay/msal-popup-relay.cjs.map +1 -1
  288. package/lib/popup-relay/msal-popup-relay.js +2 -2
  289. package/lib/popup-relay/msal-popup-relay.js.map +1 -1
  290. package/lib/popup-relay/msal-popup-relay.min.js +1 -1
  291. package/lib/redirect-bridge/msal-redirect-bridge.cjs +10 -10
  292. package/lib/redirect-bridge/msal-redirect-bridge.cjs.map +1 -1
  293. package/lib/redirect-bridge/msal-redirect-bridge.js +10 -10
  294. package/lib/redirect-bridge/msal-redirect-bridge.js.map +1 -1
  295. package/lib/redirect-bridge/msal-redirect-bridge.min.js +1 -1
  296. package/lib/web-broker-bridge/msal-web-broker-bridge.cjs +1 -1
  297. package/package.json +2 -2
  298. package/src/app/PublicClientApplication.ts +108 -8
  299. package/src/broker/nativeBroker/PlatformAuthDOMHandler.ts +15 -0
  300. package/src/broker/nativeBroker/PlatformAuthExtensionHandler.ts +6 -21
  301. package/src/broker/nativeBroker/PlatformAuthProvider.ts +3 -1
  302. package/src/broker/nativeBroker/PlatformAuthRequest.ts +12 -8
  303. package/src/broker/nativeBroker/PlatformAuthResponse.ts +31 -0
  304. package/src/cache/AsyncMemoryStorage.ts +16 -0
  305. package/src/cache/BrowserCacheManager.ts +19 -1
  306. package/src/config/Configuration.ts +63 -6
  307. package/src/controllers/StandardController.ts +153 -14
  308. package/src/crypto/TokenBindingKeyManager.ts +21 -0
  309. package/src/custom_auth/controller/CustomAuthStandardController.ts +18 -0
  310. package/src/custom_auth/core/auth_flow/v2/AuthenticationMethodRegistrationV2.ts +15 -0
  311. package/src/custom_auth/core/auth_flow/v2/result/AuthMethodRegistrationChallengeResultV2.ts +23 -0
  312. package/src/custom_auth/core/auth_flow/v2/result/AuthMethodVerificationSubmitChallengeResultV2.ts +26 -0
  313. package/src/custom_auth/core/auth_flow/v2/result/RequestChallengeResultV2.ts +1 -1
  314. package/src/custom_auth/core/auth_flow/v2/result/VerifyChallengeResultV2.ts +2 -0
  315. package/src/custom_auth/core/auth_flow/v2/state/AuthMethodRegistrationRequiredStateV2.ts +94 -0
  316. package/src/custom_auth/core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.ts +7 -2
  317. package/src/custom_auth/core/auth_flow/v2/state/AuthMethodVerificationRequiredStateV2.ts +132 -0
  318. package/src/custom_auth/core/auth_flow/v2/state/ChallengeVerificationStateBaseV2.ts +8 -2
  319. package/src/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.ts +18 -0
  320. package/src/custom_auth/core/auth_flow/v2/state/CustomAuthStateParametersV2.ts +13 -0
  321. package/src/custom_auth/core/auth_flow/v2/state/MFAVerificationRequiredStateV2.ts +8 -2
  322. package/src/custom_auth/core/interaction_client/v2/FlowContinuationStateV2.ts +1 -0
  323. package/src/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.ts +445 -91
  324. package/src/custom_auth/core/interaction_client/v2/parameter/FlowParamsV2.ts +25 -0
  325. package/src/custom_auth/core/interaction_client/v2/result/FlowActionResultV2.ts +34 -0
  326. package/src/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.ts +9 -0
  327. package/src/custom_auth/core/network_client/custom_auth_api/v2/CustomAuthApiClientV2.ts +262 -43
  328. package/src/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.ts +4 -7
  329. package/src/custom_auth/core/network_client/custom_auth_api/v2/request/RequestsV2.ts +21 -0
  330. package/src/custom_auth/core/network_client/custom_auth_api/v2/response/ResponsesV2.ts +41 -2
  331. package/src/custom_auth/core/network_client/custom_auth_api/v2/result/BaseResultsV2.ts +44 -19
  332. package/src/custom_auth/core/network_client/custom_auth_api/v2/result/ResetPasswordResultsV2.ts +4 -6
  333. package/src/custom_auth/core/network_client/custom_auth_api/v2/result/SignUpResultsV2.ts +6 -1
  334. package/src/custom_auth/core/telemetry/FlowApiIdHelperV2.ts +25 -1
  335. package/src/custom_auth/core/telemetry/PublicApiId.ts +6 -0
  336. package/src/custom_auth/index.ts +11 -0
  337. package/src/custom_auth/reset_password/auth_flow/v2/result/SubmitNewPasswordResultV2.ts +6 -7
  338. package/src/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.ts +47 -15
  339. package/src/custom_auth/sign_in/auth_flow/v2/result/SignInStartResultV2.ts +2 -0
  340. package/src/custom_auth/sign_in/auth_flow/v2/result/SubmitPasswordResultV2.ts +2 -0
  341. package/src/custom_auth/sign_in/auth_flow/v2/state/PasswordRequiredStateV2.ts +18 -0
  342. package/src/custom_auth/sign_up/auth_flow/v2/result/SubmitAttributesResultV2.ts +2 -0
  343. package/src/custom_auth/sign_up/auth_flow/v2/state/SignUpStateTransitionHandlerV2.ts +13 -0
  344. package/src/interaction_client/PlatformAuthInteractionClient.ts +851 -128
  345. package/src/interaction_client/PopupClient.ts +140 -83
  346. package/src/interaction_client/RedirectClient.ts +88 -35
  347. package/src/interaction_client/SilentIframeClient.ts +121 -95
  348. package/src/interaction_client/StandardInteractionClient.ts +6 -0
  349. package/src/packageMetadata.ts +1 -1
  350. package/src/protocol/Authorize.ts +80 -46
  351. package/src/request/RequestHelpers.ts +64 -11
  352. package/src/request/SilentRequestHelpers.ts +8 -9
  353. package/src/telemetry/BrowserPerformanceEvents.ts +1 -0
  354. package/src/utils/BrowserUtils.ts +8 -1
  355. package/src/utils/IframeMonitor.ts +98 -0
  356. package/src/utils/PopupMonitor.ts +158 -0
  357. package/src/utils/PopupOriginCheck.ts +94 -0
  358. package/types/app/PublicClientApplication.d.ts +6 -4
  359. package/types/app/PublicClientApplication.d.ts.map +1 -1
  360. package/types/broker/nativeBroker/PlatformAuthDOMHandler.d.ts.map +1 -1
  361. package/types/broker/nativeBroker/PlatformAuthExtensionHandler.d.ts.map +1 -1
  362. package/types/broker/nativeBroker/PlatformAuthProvider.d.ts.map +1 -1
  363. package/types/broker/nativeBroker/PlatformAuthRequest.d.ts +6 -1
  364. package/types/broker/nativeBroker/PlatformAuthRequest.d.ts.map +1 -1
  365. package/types/broker/nativeBroker/PlatformAuthResponse.d.ts +21 -0
  366. package/types/broker/nativeBroker/PlatformAuthResponse.d.ts.map +1 -1
  367. package/types/cache/AsyncMemoryStorage.d.ts +5 -0
  368. package/types/cache/AsyncMemoryStorage.d.ts.map +1 -1
  369. package/types/cache/BrowserCacheManager.d.ts +4 -0
  370. package/types/cache/BrowserCacheManager.d.ts.map +1 -1
  371. package/types/config/Configuration.d.ts +16 -0
  372. package/types/config/Configuration.d.ts.map +1 -1
  373. package/types/controllers/StandardController.d.ts +5 -0
  374. package/types/controllers/StandardController.d.ts.map +1 -1
  375. package/types/crypto/TokenBindingKeyManager.d.ts +9 -0
  376. package/types/crypto/TokenBindingKeyManager.d.ts.map +1 -1
  377. package/types/custom_auth/CustomAuthConstants.d.ts +1 -1
  378. package/types/custom_auth/controller/CustomAuthStandardController.d.ts.map +1 -1
  379. package/types/custom_auth/core/auth_flow/v2/AuthenticationMethodRegistrationV2.d.ts +11 -0
  380. package/types/custom_auth/core/auth_flow/v2/AuthenticationMethodRegistrationV2.d.ts.map +1 -0
  381. package/types/custom_auth/core/auth_flow/v2/result/AuthMethodRegistrationChallengeResultV2.d.ts +14 -0
  382. package/types/custom_auth/core/auth_flow/v2/result/AuthMethodRegistrationChallengeResultV2.d.ts.map +1 -0
  383. package/types/custom_auth/core/auth_flow/v2/result/AuthMethodVerificationSubmitChallengeResultV2.d.ts +15 -0
  384. package/types/custom_auth/core/auth_flow/v2/result/AuthMethodVerificationSubmitChallengeResultV2.d.ts.map +1 -0
  385. package/types/custom_auth/core/auth_flow/v2/result/RequestChallengeResultV2.d.ts +1 -1
  386. package/types/custom_auth/core/auth_flow/v2/result/VerifyChallengeResultV2.d.ts +2 -1
  387. package/types/custom_auth/core/auth_flow/v2/result/VerifyChallengeResultV2.d.ts.map +1 -1
  388. package/types/custom_auth/core/auth_flow/v2/state/AuthMethodRegistrationRequiredStateV2.d.ts +22 -0
  389. package/types/custom_auth/core/auth_flow/v2/state/AuthMethodRegistrationRequiredStateV2.d.ts.map +1 -0
  390. package/types/custom_auth/core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.d.ts.map +1 -1
  391. package/types/custom_auth/core/auth_flow/v2/state/AuthMethodVerificationRequiredStateV2.d.ts +28 -0
  392. package/types/custom_auth/core/auth_flow/v2/state/AuthMethodVerificationRequiredStateV2.d.ts.map +1 -0
  393. package/types/custom_auth/core/auth_flow/v2/state/ChallengeVerificationStateBaseV2.d.ts +3 -2
  394. package/types/custom_auth/core/auth_flow/v2/state/ChallengeVerificationStateBaseV2.d.ts.map +1 -1
  395. package/types/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.d.ts.map +1 -1
  396. package/types/custom_auth/core/auth_flow/v2/state/CustomAuthStateParametersV2.d.ts +9 -0
  397. package/types/custom_auth/core/auth_flow/v2/state/CustomAuthStateParametersV2.d.ts.map +1 -1
  398. package/types/custom_auth/core/auth_flow/v2/state/MFAVerificationRequiredStateV2.d.ts.map +1 -1
  399. package/types/custom_auth/core/interaction_client/v2/FlowContinuationStateV2.d.ts +1 -0
  400. package/types/custom_auth/core/interaction_client/v2/FlowContinuationStateV2.d.ts.map +1 -1
  401. package/types/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.d.ts +12 -5
  402. package/types/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.d.ts.map +1 -1
  403. package/types/custom_auth/core/interaction_client/v2/parameter/FlowParamsV2.d.ts +17 -0
  404. package/types/custom_auth/core/interaction_client/v2/parameter/FlowParamsV2.d.ts.map +1 -1
  405. package/types/custom_auth/core/interaction_client/v2/result/FlowActionResultV2.d.ts +18 -2
  406. package/types/custom_auth/core/interaction_client/v2/result/FlowActionResultV2.d.ts.map +1 -1
  407. package/types/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.d.ts +8 -0
  408. package/types/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.d.ts.map +1 -1
  409. package/types/custom_auth/core/network_client/custom_auth_api/v2/CustomAuthApiClientV2.d.ts +8 -2
  410. package/types/custom_auth/core/network_client/custom_auth_api/v2/CustomAuthApiClientV2.d.ts.map +1 -1
  411. package/types/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.d.ts +3 -3
  412. package/types/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.d.ts.map +1 -1
  413. package/types/custom_auth/core/network_client/custom_auth_api/v2/request/RequestsV2.d.ts +12 -0
  414. package/types/custom_auth/core/network_client/custom_auth_api/v2/request/RequestsV2.d.ts.map +1 -1
  415. package/types/custom_auth/core/network_client/custom_auth_api/v2/response/ResponsesV2.d.ts +29 -2
  416. package/types/custom_auth/core/network_client/custom_auth_api/v2/response/ResponsesV2.d.ts.map +1 -1
  417. package/types/custom_auth/core/network_client/custom_auth_api/v2/result/BaseResultsV2.d.ts +30 -17
  418. package/types/custom_auth/core/network_client/custom_auth_api/v2/result/BaseResultsV2.d.ts.map +1 -1
  419. package/types/custom_auth/core/network_client/custom_auth_api/v2/result/ResetPasswordResultsV2.d.ts +3 -1
  420. package/types/custom_auth/core/network_client/custom_auth_api/v2/result/ResetPasswordResultsV2.d.ts.map +1 -1
  421. package/types/custom_auth/core/network_client/custom_auth_api/v2/result/SignUpResultsV2.d.ts +3 -2
  422. package/types/custom_auth/core/network_client/custom_auth_api/v2/result/SignUpResultsV2.d.ts.map +1 -1
  423. package/types/custom_auth/core/telemetry/FlowApiIdHelperV2.d.ts +6 -1
  424. package/types/custom_auth/core/telemetry/FlowApiIdHelperV2.d.ts.map +1 -1
  425. package/types/custom_auth/core/telemetry/PublicApiId.d.ts +6 -0
  426. package/types/custom_auth/core/telemetry/PublicApiId.d.ts.map +1 -1
  427. package/types/custom_auth/index.d.ts +5 -0
  428. package/types/custom_auth/index.d.ts.map +1 -1
  429. package/types/custom_auth/reset_password/auth_flow/v2/result/SubmitNewPasswordResultV2.d.ts +6 -8
  430. package/types/custom_auth/reset_password/auth_flow/v2/result/SubmitNewPasswordResultV2.d.ts.map +1 -1
  431. package/types/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.d.ts +4 -4
  432. package/types/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.d.ts.map +1 -1
  433. package/types/custom_auth/sign_in/auth_flow/v2/result/SignInStartResultV2.d.ts +2 -1
  434. package/types/custom_auth/sign_in/auth_flow/v2/result/SignInStartResultV2.d.ts.map +1 -1
  435. package/types/custom_auth/sign_in/auth_flow/v2/result/SubmitPasswordResultV2.d.ts +2 -1
  436. package/types/custom_auth/sign_in/auth_flow/v2/result/SubmitPasswordResultV2.d.ts.map +1 -1
  437. package/types/custom_auth/sign_in/auth_flow/v2/state/PasswordRequiredStateV2.d.ts.map +1 -1
  438. package/types/custom_auth/sign_up/auth_flow/v2/result/SubmitAttributesResultV2.d.ts +2 -1
  439. package/types/custom_auth/sign_up/auth_flow/v2/result/SubmitAttributesResultV2.d.ts.map +1 -1
  440. package/types/custom_auth/sign_up/auth_flow/v2/state/SignUpStateTransitionHandlerV2.d.ts.map +1 -1
  441. package/types/interaction_client/PlatformAuthInteractionClient.d.ts +106 -5
  442. package/types/interaction_client/PlatformAuthInteractionClient.d.ts.map +1 -1
  443. package/types/interaction_client/PopupClient.d.ts +12 -0
  444. package/types/interaction_client/PopupClient.d.ts.map +1 -1
  445. package/types/interaction_client/RedirectClient.d.ts.map +1 -1
  446. package/types/interaction_client/SilentIframeClient.d.ts.map +1 -1
  447. package/types/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  448. package/types/packageMetadata.d.ts +1 -1
  449. package/types/protocol/Authorize.d.ts +4 -4
  450. package/types/protocol/Authorize.d.ts.map +1 -1
  451. package/types/request/RequestHelpers.d.ts +21 -3
  452. package/types/request/RequestHelpers.d.ts.map +1 -1
  453. package/types/request/SilentRequestHelpers.d.ts.map +1 -1
  454. package/types/telemetry/BrowserPerformanceEvents.d.ts +1 -0
  455. package/types/telemetry/BrowserPerformanceEvents.d.ts.map +1 -1
  456. package/types/utils/BrowserUtils.d.ts +2 -1
  457. package/types/utils/BrowserUtils.d.ts.map +1 -1
  458. package/types/utils/IframeMonitor.d.ts +17 -0
  459. package/types/utils/IframeMonitor.d.ts.map +1 -0
  460. package/types/utils/PopupMonitor.d.ts +37 -0
  461. package/types/utils/PopupMonitor.d.ts.map +1 -0
  462. package/types/utils/PopupOriginCheck.d.ts +27 -0
  463. package/types/utils/PopupOriginCheck.d.ts.map +1 -0
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v5.26.0 2026-10-21 */
1
+ /*! @azure/msal-browser v5.28.0 2026-11-05 */
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.3 2026-10-21 */
9
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
69
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
303
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
332
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
355
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
393
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
431
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
497
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
585
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
599
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
621
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
645
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
834
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
844
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
864
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.16.0 2026-11-05 */
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.3 2026-10-21 */
935
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
947
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
1027
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
1185
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
1339
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
1348
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
1358
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
1368
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
1439
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
1532
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
1643
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
1708
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
1995
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
2963
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
2997
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
3193
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
3693
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
3824
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
3872
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
3895
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
4170
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
4102
4171
  /* eslint-disable header/header */
4103
4172
  const name$1 = "@azure/msal-common";
4104
- const version$1 = "16.14.3";
4173
+ const version$1 = "16.16.0";
4105
4174
 
4106
- /*! @azure/msal-common v16.14.3 2026-10-21 */
4175
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
4183
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
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.3 2026-10-21 */
4221
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
4153
4222
 
4154
4223
  /*
4155
4224
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4398,6 +4467,7 @@
4398
4467
  };
4399
4468
  const tokenKeys = this.getTokenKeys();
4400
4469
  const currentScopes = ScopeSet.fromString(credential.target, correlationId);
4470
+ const accessTokenKeysToRemove = [];
4401
4471
  tokenKeys.accessToken.forEach((key) => {
4402
4472
  if (!this.accessTokenKeyMatchesFilter(key, accessTokenFilter, false)) {
4403
4473
  return;
@@ -4407,10 +4477,13 @@
4407
4477
  this.credentialMatchesFilter(tokenEntity, accessTokenFilter, correlationId)) {
4408
4478
  const tokenScopeSet = ScopeSet.fromString(tokenEntity.target, correlationId);
4409
4479
  if (tokenScopeSet.intersectingScopeSets(currentScopes)) {
4410
- this.removeAccessToken(key, correlationId);
4480
+ accessTokenKeysToRemove.push(key);
4411
4481
  }
4412
4482
  }
4413
4483
  });
4484
+ for (const key of accessTokenKeysToRemove) {
4485
+ await this.removeAccessTokenAndTokenBindingKey(key, correlationId, credential.keyId);
4486
+ }
4414
4487
  await this.setAccessTokenCredential(credential, correlationId, kmsi, additionalCacheKeyHash);
4415
4488
  }
4416
4489
  /**
@@ -4646,12 +4719,32 @@
4646
4719
  * @param correlationId
4647
4720
  */
4648
4721
  removeAccessToken(key, correlationId) {
4722
+ const credential = this.removeAccessTokenCredential(key, correlationId);
4723
+ if (credential) {
4724
+ void this.removeTokenBindingKeyForCredential(credential, correlationId);
4725
+ }
4726
+ }
4727
+ /**
4728
+ * Removes an access token and waits for any unreferenced token-binding key
4729
+ * cleanup. Internal callers that require deterministic cleanup should use
4730
+ * this method instead of the synchronous public cache contract.
4731
+ */
4732
+ async removeAccessTokenAndTokenBindingKey(key, correlationId, preservedKeyId) {
4733
+ const credential = this.removeAccessTokenCredential(key, correlationId);
4734
+ if (credential) {
4735
+ await this.removeTokenBindingKeyForCredential(credential, correlationId, preservedKeyId);
4736
+ }
4737
+ }
4738
+ removeAccessTokenCredential(key, correlationId) {
4649
4739
  const credential = this.getAccessTokenCredential(key, correlationId);
4650
4740
  if (!credential) {
4651
- return;
4741
+ return null;
4652
4742
  }
4653
4743
  this.removeItem(key, correlationId);
4654
4744
  this.performanceClient.incrementFields({ accessTokensRemoved: 1 }, correlationId);
4745
+ return credential;
4746
+ }
4747
+ async removeTokenBindingKeyForCredential(credential, correlationId, preservedKeyId) {
4655
4748
  // Remove Token Binding Key from key store for token-bound access token credentials
4656
4749
  if (credential.credentialType.toLowerCase() ===
4657
4750
  CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase()) {
@@ -4661,19 +4754,28 @@
4661
4754
  case AuthenticationScheme.DPOP.toLowerCase(): {
4662
4755
  const accessTokenWithAuthSchemeEntity = credential;
4663
4756
  const kid = accessTokenWithAuthSchemeEntity.keyId;
4664
- if (kid) {
4665
- void this.tokenBindingKeyManager
4666
- .removeTokenBindingKey(kid, correlationId)
4667
- .catch(() => {
4757
+ if (kid &&
4758
+ kid !== preservedKeyId &&
4759
+ !this.isTokenBindingKeyReferenced(kid, correlationId)) {
4760
+ try {
4761
+ await this.tokenBindingKeyManager.removeTokenBindingKey(kid, correlationId);
4762
+ }
4763
+ catch {
4668
4764
  this.commonLogger.error("0id34f", correlationId);
4669
4765
  this.performanceClient?.incrementFields({ removeTokenBindingKeyFailure: 1 }, correlationId);
4670
- });
4766
+ }
4671
4767
  }
4672
4768
  break;
4673
4769
  }
4674
4770
  }
4675
4771
  }
4676
4772
  }
4773
+ isTokenBindingKeyReferenced(keyId, correlationId) {
4774
+ return this.getTokenKeys().accessToken.some((accessTokenKey) => {
4775
+ const accessToken = this.getAccessTokenCredential(accessTokenKey, correlationId);
4776
+ return accessToken?.keyId === keyId;
4777
+ });
4778
+ }
4677
4779
  /**
4678
4780
  * Removes all app metadata objects from cache.
4679
4781
  */
@@ -4812,6 +4914,7 @@
4812
4914
  const scopes = ScopeSet.createSearchScopes(request.scopes, correlationId);
4813
4915
  const authScheme = request.authenticationScheme ||
4814
4916
  AuthenticationScheme.BEARER;
4917
+ const normalizedAuthScheme = authScheme.toLowerCase();
4815
4918
  /*
4816
4919
  * Distinguish between Bearer and PoP/SSH token cache types
4817
4920
  * Cast to lowercase to handle "bearer" from ADFS
@@ -4836,7 +4939,10 @@
4836
4939
  tokenType: authScheme,
4837
4940
  keyId: authScheme === AuthenticationScheme.SSH
4838
4941
  ? request.sshKid
4839
- : undefined,
4942
+ : normalizedAuthScheme ===
4943
+ AuthenticationScheme.DPOP.toLowerCase()
4944
+ ? request.popKid || request.dpopJkt
4945
+ : undefined,
4840
4946
  additionalCacheKeyComponents: additionalCacheKeyComponents,
4841
4947
  };
4842
4948
  const accessTokenKeys = (tokenKeys && tokenKeys.accessToken) ||
@@ -5336,7 +5442,7 @@
5336
5442
  }
5337
5443
  }
5338
5444
 
5339
- /*! @azure/msal-common v16.14.3 2026-10-21 */
5445
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
5340
5446
  /*
5341
5447
  * Copyright (c) Microsoft Corporation. All rights reserved.
5342
5448
  * Licensed under the MIT License.
@@ -5350,7 +5456,7 @@
5350
5456
  const PerformanceEventStatus = {
5351
5457
  InProgress: 1};
5352
5458
 
5353
- /*! @azure/msal-common v16.14.3 2026-10-21 */
5459
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
5354
5460
 
5355
5461
  /*
5356
5462
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5408,7 +5514,7 @@
5408
5514
  }
5409
5515
  }
5410
5516
 
5411
- /*! @azure/msal-common v16.14.3 2026-10-21 */
5517
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
5412
5518
 
5413
5519
  /*
5414
5520
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5506,7 +5612,7 @@
5506
5612
  return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
5507
5613
  }
5508
5614
 
5509
- /*! @azure/msal-common v16.14.3 2026-10-21 */
5615
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
5510
5616
  /*
5511
5617
  * Copyright (c) Microsoft Corporation. All rights reserved.
5512
5618
  * Licensed under the MIT License.
@@ -5533,7 +5639,7 @@
5533
5639
  }
5534
5640
  }
5535
5641
 
5536
- /*! @azure/msal-common v16.14.3 2026-10-21 */
5642
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
5537
5643
 
5538
5644
  /*
5539
5645
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5554,7 +5660,7 @@
5554
5660
  return new JoseHeaderError(code, correlationId);
5555
5661
  }
5556
5662
 
5557
- /*! @azure/msal-common v16.14.3 2026-10-21 */
5663
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
5558
5664
  /*
5559
5665
  * Copyright (c) Microsoft Corporation. All rights reserved.
5560
5666
  * Licensed under the MIT License.
@@ -5579,7 +5685,7 @@
5579
5685
  return Object.getPrototypeOf(value) === proto;
5580
5686
  }
5581
5687
 
5582
- /*! @azure/msal-common v16.14.3 2026-10-21 */
5688
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
5583
5689
  /*
5584
5690
  * Copyright (c) Microsoft Corporation. All rights reserved.
5585
5691
  * Licensed under the MIT License.
@@ -5589,7 +5695,7 @@
5589
5695
  const missingJwkError = "missing_jwk_error";
5590
5696
  const invalidJwkError = "invalid_jwk_error";
5591
5697
 
5592
- /*! @azure/msal-common v16.14.3 2026-10-21 */
5698
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
5593
5699
 
5594
5700
  /*
5595
5701
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5655,7 +5761,7 @@
5655
5761
  }
5656
5762
  }
5657
5763
 
5658
- /*! @azure/msal-common v16.14.3 2026-10-21 */
5764
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
5659
5765
 
5660
5766
  /*
5661
5767
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5756,7 +5862,7 @@
5756
5862
  }
5757
5863
  }
5758
5864
 
5759
- /*! @azure/msal-common v16.14.3 2026-10-21 */
5865
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
5760
5866
 
5761
5867
  /*
5762
5868
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5806,13 +5912,22 @@
5806
5912
  throw createClientConfigurationError(invalidDpopNonce, correlationId);
5807
5913
  }
5808
5914
  }
5915
+ /**
5916
+ * Validates and normalizes the HTTP resource context for a DPoP-bound request.
5917
+ * @internal
5918
+ */
5919
+ function normalizeDpopResourceRequestContext(context, correlationId = "") {
5920
+ return {
5921
+ htm: normalizeHtm(context.htm, correlationId),
5922
+ htu: normalizeHtu(context.htu, correlationId),
5923
+ };
5924
+ }
5809
5925
  /**
5810
5926
  * Builds RFC 9449 DPoP proof JWT payloads for token-endpoint and
5811
5927
  * resource-endpoint proof bindings.
5812
5928
  *
5813
- * Not exported from any public package entry point.
5814
- * This helper is internal-only until DPoP is wired into acquisition flows
5815
- * in a subsequent work item.
5929
+ * Exported from package entry points for use by MSAL Browser.
5930
+ * This helper remains an unsupported internal API for direct consumers.
5816
5931
  *
5817
5932
  * DPoP proofs do not contain SHR fields (at, ts, m, u, p, q).
5818
5933
  * @internal
@@ -5867,10 +5982,11 @@
5867
5982
  */
5868
5983
  buildResourceProofClaims(params, correlationId = "") {
5869
5984
  validateDpopNonce(params.nonce, correlationId);
5985
+ const resourceContext = normalizeDpopResourceRequestContext(params, correlationId);
5870
5986
  const claims = {
5871
5987
  jti: this.cryptoUtils.createNewGuid(),
5872
- htm: normalizeHtm(params.htm, correlationId),
5873
- htu: normalizeHtu(params.htu, correlationId),
5988
+ htm: resourceContext.htm,
5989
+ htu: resourceContext.htu,
5874
5990
  ath: params.ath,
5875
5991
  iat: nowSeconds(),
5876
5992
  };
@@ -5901,7 +6017,7 @@
5901
6017
  }
5902
6018
  }
5903
6019
 
5904
- /*! @azure/msal-common v16.14.3 2026-10-21 */
6020
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
5905
6021
  /*
5906
6022
  * Copyright (c) Microsoft Corporation. All rights reserved.
5907
6023
  * Licensed under the MIT License.
@@ -5952,7 +6068,7 @@
5952
6068
  */
5953
6069
  const interruptedUser = "interrupted_user";
5954
6070
 
5955
- /*! @azure/msal-common v16.14.3 2026-10-21 */
6071
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
5956
6072
 
5957
6073
  /*
5958
6074
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6019,7 +6135,7 @@
6019
6135
  return new InteractionRequiredAuthError(errorCode, correlationId, errorMessage);
6020
6136
  }
6021
6137
 
6022
- /*! @azure/msal-common v16.14.3 2026-10-21 */
6138
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
6023
6139
 
6024
6140
  /*
6025
6141
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6038,7 +6154,7 @@
6038
6154
  }
6039
6155
  }
6040
6156
 
6041
- /*! @azure/msal-common v16.14.3 2026-10-21 */
6157
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
6042
6158
 
6043
6159
  /*
6044
6160
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6109,7 +6225,7 @@
6109
6225
  }
6110
6226
  }
6111
6227
 
6112
- /*! @azure/msal-common v16.14.3 2026-10-21 */
6228
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
6113
6229
 
6114
6230
  /*
6115
6231
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6537,7 +6653,7 @@
6537
6653
  return baseAccount;
6538
6654
  }
6539
6655
 
6540
- /*! @azure/msal-common v16.14.3 2026-10-21 */
6656
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
6541
6657
  /*
6542
6658
  * Copyright (c) Microsoft Corporation. All rights reserved.
6543
6659
  * Licensed under the MIT License.
@@ -6547,7 +6663,7 @@
6547
6663
  UPN: "UPN",
6548
6664
  };
6549
6665
 
6550
- /*! @azure/msal-common v16.14.3 2026-10-21 */
6666
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
6551
6667
  /*
6552
6668
  * Copyright (c) Microsoft Corporation. All rights reserved.
6553
6669
  * Licensed under the MIT License.
@@ -6566,7 +6682,7 @@
6566
6682
  }
6567
6683
  }
6568
6684
 
6569
- /*! @azure/msal-common v16.14.3 2026-10-21 */
6685
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
6570
6686
 
6571
6687
  /*
6572
6688
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6590,7 +6706,7 @@
6590
6706
  };
6591
6707
  }
6592
6708
 
6593
- /*! @azure/msal-common v16.14.3 2026-10-21 */
6709
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
6594
6710
 
6595
6711
  /*
6596
6712
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6625,13 +6741,14 @@
6625
6741
  * Performs necessary throttling checks after a network request.
6626
6742
  * @param cacheManager
6627
6743
  * @param thumbprint
6628
- * @param response
6744
+ * @param response - Token response with case-insensitive header names.
6629
6745
  */
6630
6746
  static postProcess(cacheManager, thumbprint, response, correlationId) {
6747
+ const retryAfter = getRetryAfterHeader(response);
6631
6748
  if (ThrottlingUtils.checkResponseStatus(response) ||
6632
- ThrottlingUtils.checkResponseForRetryAfter(response)) {
6749
+ retryAfter !== undefined) {
6633
6750
  const thumbprintValue = {
6634
- throttleTime: ThrottlingUtils.calculateThrottleTime(parseInt(response.headers[HeaderNames.RETRY_AFTER])),
6751
+ throttleTime: ThrottlingUtils.calculateThrottleTime(parseInt(retryAfter || "")),
6635
6752
  error: response.body.error,
6636
6753
  errorCodes: response.body.error_codes,
6637
6754
  errorMessage: response.body.error_description,
@@ -6650,14 +6767,10 @@
6650
6767
  }
6651
6768
  /**
6652
6769
  * Checks a NetworkResponse object's RetryAfter header
6653
- * @param response
6770
+ * @param response - Token response with case-insensitive header names.
6654
6771
  */
6655
6772
  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;
6773
+ return getRetryAfterHeader(response) !== undefined;
6661
6774
  }
6662
6775
  /**
6663
6776
  * Calculates the Unix-time value for a throttle to expire given throttleTime in seconds.
@@ -6674,9 +6787,16 @@
6674
6787
  const key = this.generateThrottlingStorageKey(thumbprint);
6675
6788
  cacheManager.removeItem(key, request.correlationId);
6676
6789
  }
6790
+ }
6791
+ /** Reads Retry-After only for non-success responses. */
6792
+ function getRetryAfterHeader(response) {
6793
+ if ((response.status < 200 || response.status >= 300) && response.headers) {
6794
+ return getResponseHeader(response.headers, HeaderNames.RETRY_AFTER);
6795
+ }
6796
+ return undefined;
6677
6797
  }
6678
6798
 
6679
- /*! @azure/msal-common v16.14.3 2026-10-21 */
6799
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
6680
6800
 
6681
6801
  /*
6682
6802
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6707,7 +6827,7 @@
6707
6827
  return new NetworkError(error, httpStatus, responseHeaders);
6708
6828
  }
6709
6829
 
6710
- /*! @azure/msal-common v16.14.3 2026-10-21 */
6830
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
6711
6831
 
6712
6832
  /*
6713
6833
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6805,7 +6925,8 @@
6805
6925
  let response;
6806
6926
  try {
6807
6927
  response = await invokeAsync((networkClient.sendPostRequestAsync.bind(networkClient)), NetworkClientSendPostRequestAsync, logger, performanceClient, correlationId)(tokenEndpoint, { ...options, correlationId, performanceClient });
6808
- const responseHeaders = response.headers || {};
6928
+ const responseHeaders = normalizeResponseHeaders(response.headers || {});
6929
+ response = { ...response, headers: responseHeaders };
6809
6930
  performanceClient?.addFields({
6810
6931
  refreshTokenSize: response.body.refresh_token?.length || 0,
6811
6932
  httpVerToken: responseHeaders[HeaderNames.X_MS_HTTP_VERSION] || "",
@@ -6814,16 +6935,16 @@
6814
6935
  }
6815
6936
  catch (e) {
6816
6937
  if (e instanceof NetworkError) {
6817
- const responseHeaders = e.responseHeaders;
6938
+ const responseHeaders = e.responseHeaders
6939
+ ? normalizeResponseHeaders(e.responseHeaders)
6940
+ : undefined;
6818
6941
  if (responseHeaders) {
6819
6942
  performanceClient?.addFields({
6820
6943
  httpVerToken: responseHeaders[HeaderNames.X_MS_HTTP_VERSION] ||
6821
6944
  "",
6822
6945
  requestId: responseHeaders[HeaderNames.X_MS_REQUEST_ID] || "",
6823
- contentTypeHeader: responseHeaders[HeaderNames.CONTENT_TYPE] ||
6824
- undefined,
6825
- contentLengthHeader: responseHeaders[HeaderNames.CONTENT_LENGTH] ||
6826
- undefined,
6946
+ contentTypeHeader: getResponseHeader(responseHeaders, HeaderNames.CONTENT_TYPE) || undefined,
6947
+ contentLengthHeader: getResponseHeader(responseHeaders, HeaderNames.CONTENT_LENGTH) || undefined,
6827
6948
  httpStatus: e.httpStatus,
6828
6949
  }, correlationId);
6829
6950
  }
@@ -6840,7 +6961,7 @@
6840
6961
  return response;
6841
6962
  }
6842
6963
 
6843
- /*! @azure/msal-common v16.14.3 2026-10-21 */
6964
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
6844
6965
 
6845
6966
  /*
6846
6967
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7084,6 +7205,9 @@
7084
7205
  if (request.logoutHint) {
7085
7206
  addLogoutHint(parameters, request.logoutHint);
7086
7207
  }
7208
+ if (request.popupOriginCheckDone) {
7209
+ addPopupOriginCheckDone(parameters);
7210
+ }
7087
7211
  if (request.extraQueryParameters) {
7088
7212
  addExtraParameters(parameters, request.extraQueryParameters);
7089
7213
  }
@@ -7104,7 +7228,7 @@
7104
7228
  }
7105
7229
  }
7106
7230
 
7107
- /*! @azure/msal-common v16.14.3 2026-10-21 */
7231
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
7108
7232
 
7109
7233
  /*
7110
7234
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7239,6 +7363,9 @@
7239
7363
  !Object.keys(request.extraQueryParameters).includes(INSTANCE_AWARE))) {
7240
7364
  addInstanceAware(parameters);
7241
7365
  }
7366
+ if (request.popupOriginCheckDone) {
7367
+ addPopupOriginCheckDone(parameters);
7368
+ }
7242
7369
  return parameters;
7243
7370
  }
7244
7371
  /**
@@ -7331,7 +7458,7 @@
7331
7458
  return account.loginHint || account.idTokenClaims?.login_hint || null;
7332
7459
  }
7333
7460
 
7334
- /*! @azure/msal-common v16.14.3 2026-10-21 */
7461
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
7335
7462
 
7336
7463
  /*
7337
7464
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7566,7 +7693,7 @@
7566
7693
  }
7567
7694
  }
7568
7695
 
7569
- /*! @azure/msal-common v16.14.3 2026-10-21 */
7696
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
7570
7697
 
7571
7698
  /*
7572
7699
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7859,7 +7986,7 @@
7859
7986
  clearNativeBrokerErrorCode() { }
7860
7987
  }
7861
7988
 
7862
- /*! @azure/msal-common v16.14.3 2026-10-21 */
7989
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
7863
7990
 
7864
7991
  /*
7865
7992
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7986,7 +8113,7 @@
7986
8113
  }
7987
8114
  }
7988
8115
 
7989
- /*! @azure/msal-common v16.14.3 2026-10-21 */
8116
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
7990
8117
 
7991
8118
  /*
7992
8119
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8002,7 +8129,7 @@
8002
8129
  },
8003
8130
  };
8004
8131
 
8005
- /*! @azure/msal-common v16.14.3 2026-10-21 */
8132
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
8006
8133
 
8007
8134
  /*
8008
8135
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8438,7 +8565,7 @@
8438
8565
 
8439
8566
  /* eslint-disable header/header */
8440
8567
  const name = "@azure/msal-browser";
8441
- const version = "5.26.0";
8568
+ const version = "5.28.0";
8442
8569
 
8443
8570
  /*
8444
8571
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -9064,6 +9191,7 @@
9064
9191
  const PlatformAuthHandleNativeResponse = "platformAuthHandleNativeResponse";
9065
9192
  const PlatformAuthCacheAccount = "platformAuthCacheAccount";
9066
9193
  const PlatformAuthCacheNativeTokens = "platformAuthCacheNativeTokens";
9194
+ const PlatformAuthDpopKeyCleanup = "platformAuthDpopKeyCleanup";
9067
9195
  const RemoveHiddenIframe = "removeHiddenIframe";
9068
9196
  const ImportExistingCache = "importExistingCache";
9069
9197
  /**
@@ -9135,7 +9263,6 @@
9135
9263
  const uninitializedPublicClientApplication = "uninitialized_public_client_application";
9136
9264
  const nativePromptNotSupported = "native_prompt_not_supported";
9137
9265
  const invalidBase64String = "invalid_base64_string";
9138
- const invalidPopTokenRequest = "invalid_pop_token_request";
9139
9266
  const unsupportedTokenBindingAlgorithm = "unsupported_token_binding_algorithm";
9140
9267
  const tokenBindingKeyAlgorithmMismatch = "token_binding_key_algorithm_mismatch";
9141
9268
  const tokenBindingKeyJwkThumbprintMismatch = "token_binding_key_jwk_thumbprint_mismatch";
@@ -9884,9 +10011,14 @@
9884
10011
  };
9885
10012
  }
9886
10013
  /**
9887
- * Clears hash from window url.
10014
+ * Clears a recognized authentication response fragment, preserving the query string.
10015
+ * Assigns an empty hash, then removes the trailing # when history updates are available.
9888
10016
  */
9889
10017
  function clearHash(contentWindow) {
10018
+ const serverParams = getDeserializedResponse(contentWindow.location.hash);
10019
+ if (!serverParams) {
10020
+ return;
10021
+ }
9890
10022
  // Office.js sets history.replaceState to null
9891
10023
  contentWindow.location.hash = "";
9892
10024
  if (typeof contentWindow.history.replaceState === "function") {
@@ -9894,6 +10026,16 @@
9894
10026
  contentWindow.history.replaceState(null, "", `${contentWindow.location.origin}${contentWindow.location.pathname}${contentWindow.location.search}`);
9895
10027
  }
9896
10028
  }
10029
+ /**
10030
+ * Strips both hash and query string from the given window's URL by replacing
10031
+ * with origin + pathname only. Used to remove auth response parameters
10032
+ * (auth code, state, etc.) before the window is closed or navigated away.
10033
+ */
10034
+ function clearAuthResponseFromUrl(contentWindow) {
10035
+ if (typeof contentWindow.history?.replaceState === "function") {
10036
+ contentWindow.history.replaceState(null, "", `${contentWindow.location.origin}${contentWindow.location.pathname}`);
10037
+ }
10038
+ }
9897
10039
  /**
9898
10040
  * Replaces current hash with hash from provided url
9899
10041
  */
@@ -10473,6 +10615,19 @@
10473
10615
  return cacheKeys;
10474
10616
  }
10475
10617
  }
10618
+ /**
10619
+ * Returns whether a key is available in persistent storage. Unlike
10620
+ * containsKey, this does not consult the in-memory fallback.
10621
+ */
10622
+ async containsKeyInPersistentStorage(key, correlationId) {
10623
+ try {
10624
+ return await this.indexedDBCache.containsKey(key);
10625
+ }
10626
+ catch (e) {
10627
+ this.handleDatabaseAccessError(e, correlationId);
10628
+ return false;
10629
+ }
10630
+ }
10476
10631
  /**
10477
10632
  * Returns true or false if the given key is present in the cache.
10478
10633
  * @param key
@@ -10578,6 +10733,12 @@
10578
10733
  throw createClientAuthError(bindingKeyNotRemoved, correlationId);
10579
10734
  }
10580
10735
  }
10736
+ /**
10737
+ * Returns whether a browser token-binding key is available.
10738
+ */
10739
+ async hasTokenBindingKey(keyId, correlationId) {
10740
+ return this.cache.containsKey(keyId, correlationId);
10741
+ }
10581
10742
  /**
10582
10743
  * Clears browser token-binding keys from memory and persistent storage.
10583
10744
  * @param correlationId - Request correlation identifier.
@@ -10639,6 +10800,13 @@
10639
10800
  }
10640
10801
  return cachedKeyPair;
10641
10802
  }
10803
+ /**
10804
+ * Returns whether a browser token-binding key survived in persistent
10805
+ * storage and can be restored after a redirect navigation.
10806
+ */
10807
+ async isTokenBindingKeyPersisted(keyId, correlationId) {
10808
+ return this.cache.containsKeyInPersistentStorage(keyId, correlationId);
10809
+ }
10642
10810
  /** @internal */
10643
10811
  getTokenBindingKeyTelemetry(cachedKeyPair, fallbackAlgorithm) {
10644
10812
  return {
@@ -10969,19 +11137,13 @@
10969
11137
  }
10970
11138
  /**
10971
11139
  * Resolves the token-binding parameters needed before building authorize or token requests.
10972
- * Public PCA DPoP requests use a dpopJkt thumbprint, while platform broker PoP requests use
10973
- * a reqCnf confirmation claim. Requests that do not require request-time token binding return
10974
- * no additional parameters.
11140
+ * DPoP requests provision a browser key for token endpoint redemption. Platform broker
11141
+ * authorization requests retain the key for auth-code fallback but suppress dpop_jkt on
11142
+ * /authorize. Platform broker PoP requests use a reqCnf confirmation claim.
10975
11143
  */
10976
11144
  async function getTokenBindingRequestParams(request, tokenBindingKeyManager, logger, performanceClient) {
10977
11145
  switch (request.authenticationScheme) {
10978
11146
  case AuthenticationScheme.DPOP:
10979
- if (request.platformBroker) {
10980
- return {};
10981
- }
10982
- if (request.dpopJkt) {
10983
- return { dpopJkt: request.dpopJkt };
10984
- }
10985
11147
  return {
10986
11148
  dpopJkt: await tokenBindingKeyManager.provisionTokenBindingKey({
10987
11149
  tokenBindingKeyType: AuthenticationScheme.DPOP.toLowerCase(),
@@ -11004,6 +11166,36 @@
11004
11166
  return {};
11005
11167
  }
11006
11168
  }
11169
+ /**
11170
+ * Removes a DPoP key that was provisioned for an authorization attempt which
11171
+ * did not complete. Cleanup failures are recorded without replacing the
11172
+ * original authorization error.
11173
+ */
11174
+ async function removeTokenBindingKeyOnFailure(request, tokenBindingKeyManager, logger, performanceClient) {
11175
+ if (request.authenticationScheme !== AuthenticationScheme.DPOP ||
11176
+ !request.dpopJkt) {
11177
+ return;
11178
+ }
11179
+ try {
11180
+ await tokenBindingKeyManager.removeTokenBindingKey(request.dpopJkt, request.correlationId);
11181
+ }
11182
+ catch {
11183
+ logger.error("Failed to remove unused DPoP key after authorization failure.", request.correlationId);
11184
+ performanceClient.incrementFields({ removeTokenBindingKeyFailure: 1 }, request.correlationId);
11185
+ }
11186
+ }
11187
+ /**
11188
+ * Returns whether an MSAL-owned DPoP key is available in persistent storage
11189
+ * before a redirect navigation. Custom managers without a persistence probe
11190
+ * retain their existing behavior.
11191
+ */
11192
+ async function isTokenBindingKeyPersistedForRedirect(request, tokenBindingKeyManager) {
11193
+ const keyId = request.dpopJkt ?? request.keyId;
11194
+ if (!keyId || !tokenBindingKeyManager.isTokenBindingKeyPersisted) {
11195
+ return true;
11196
+ }
11197
+ return tokenBindingKeyManager.isTokenBindingKeyPersisted(keyId, request.correlationId);
11198
+ }
11007
11199
  /**
11008
11200
  * Initializer function for all request APIs
11009
11201
  * @param request
@@ -11079,6 +11271,90 @@
11079
11271
  return httpMethod;
11080
11272
  }
11081
11273
 
11274
+ /*
11275
+ * Copyright (c) Microsoft Corporation. All rights reserved.
11276
+ * Licensed under the MIT License.
11277
+ */
11278
+ /**
11279
+ * `window.origin` of a document with an opaque origin, e.g. one sandboxed
11280
+ * without `allow-same-origin`. Read from `window.origin`, not
11281
+ * `location.origin`, which reports the real host even when sandboxed.
11282
+ */
11283
+ const OPAQUE_ORIGIN = "null";
11284
+ /**
11285
+ * Returns `true` when every ancestor browsing context is same-origin with
11286
+ * `win`. A top-level document has no ancestors, so it always passes.
11287
+ */
11288
+ function allAncestorsSameOrigin(win) {
11289
+ try {
11290
+ // Sandboxed: no origin to compare ancestors against.
11291
+ if (win.origin === OPAQUE_ORIGIN) {
11292
+ return false;
11293
+ }
11294
+ let current = win;
11295
+ // `window.parent` is self-referential at the top level, never falsy.
11296
+ while (current !== current.parent) {
11297
+ current = current.parent;
11298
+ // Throws SecurityError if this ancestor is cross-origin.
11299
+ void current.location.href;
11300
+ }
11301
+ return true;
11302
+ }
11303
+ catch {
11304
+ return false;
11305
+ }
11306
+ }
11307
+ /**
11308
+ * Returns `true` when the top-level window has no opener, or one that is
11309
+ * same-origin with it.
11310
+ *
11311
+ * Reads the opener from `win.top`, not `win`: a framed document always reports
11312
+ * `window.opener === null` and would pass while the top window's untrusted
11313
+ * opener still holds a handle on it.
11314
+ */
11315
+ function topOpenerIsSameOriginOrAbsent(win) {
11316
+ try {
11317
+ const top = win.top;
11318
+ if (!top) {
11319
+ // Detached from its browsing context; treat as unsafe.
11320
+ return false;
11321
+ }
11322
+ const opener = top.opener;
11323
+ if (!opener || opener === top) {
11324
+ return true;
11325
+ }
11326
+ // Throws SecurityError if the opener is cross-origin.
11327
+ void opener.location.href;
11328
+ return true;
11329
+ }
11330
+ catch {
11331
+ return false;
11332
+ }
11333
+ }
11334
+ /**
11335
+ * Computes the `pocd` ("popup origin check done") authorize parameter value.
11336
+ *
11337
+ * `1` means no untrusted window can reach the popup, which is what lets Entra
11338
+ * omit the `Cross-Origin-Opener-Policy` response header for the request.
11339
+ *
11340
+ * @param config Resolved browser configuration.
11341
+ * @param win Window whose hosting environment is being checked. Defaults to the app window.
11342
+ * @returns `1` when the check passes, otherwise `0`.
11343
+ */
11344
+ function computePocd(config, win = typeof window !== "undefined" ? window : undefined) {
11345
+ /*
11346
+ * Only an explicit false opts out; anything else computes the check, so an
11347
+ * unresolved config fails closed rather than asserting pocd=1.
11348
+ */
11349
+ if (config.auth.originCheck === false) {
11350
+ return 1;
11351
+ }
11352
+ if (!win || !allAncestorsSameOrigin(win)) {
11353
+ return 0;
11354
+ }
11355
+ return topOpenerIsSameOriginOrAbsent(win) ? 1 : 0;
11356
+ }
11357
+
11082
11358
  /*
11083
11359
  * Copyright (c) Microsoft Corporation. All rights reserved.
11084
11360
  * Licensed under the MIT License.
@@ -11096,6 +11372,11 @@
11096
11372
  const validLogoutRequest = {
11097
11373
  correlationId: this.correlationId,
11098
11374
  ...logoutRequest,
11375
+ /*
11376
+ * Computed here rather than per flow so every end-session request
11377
+ * carries it, matching the authorize path.
11378
+ */
11379
+ popupOriginCheckDone: computePocd(this.config) === 1,
11099
11380
  };
11100
11381
  /**
11101
11382
  * Set logout_hint to be login_hint from ID Token Claims if present
@@ -11435,7 +11716,13 @@
11435
11716
  const SIGN_UP_V2_SUBMIT_CODE = 100213;
11436
11717
  const SIGN_UP_V2_SUBMIT_ATTRIBUTES = 100214;
11437
11718
  const SIGN_UP_V2_RESEND_CODE = 100215;
11438
- const SIGN_UP_V2_COMPLETE = 100216;
11719
+ const SIGN_UP_V2_COMPLETE = 100216;
11720
+ const JIT_V2_ENROLL_AUTH_METHOD = 100217;
11721
+ const JIT_V2_SUBMIT_CHALLENGE = 100218;
11722
+ const JIT_V2_RESEND_CHALLENGE = 100219;
11723
+ const MFA_V2_SELECT_AUTH_METHOD = 100220;
11724
+ const MFA_V2_SUBMIT_CHALLENGE = 100221;
11725
+ const MFA_V2_RESEND_CHALLENGE = 100222;
11439
11726
 
11440
11727
  /*
11441
11728
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -12265,7 +12552,7 @@
12265
12552
  }
12266
12553
  // Required href; throws when it is absent.
12267
12554
  requireHref(href, relation, correlationId, missingHrefError) {
12268
- if (!href) {
12555
+ if (typeof href !== "string" || !href.trim()) {
12269
12556
  const errorCode = missingHrefError?.code ?? INVALID_HAL_RESPONSE;
12270
12557
  const errorMessage = missingHrefError?.message ??
12271
12558
  `Invalid HAL response: missing '${relation}' link`;
@@ -12379,9 +12666,17 @@
12379
12666
  const VERIFY_RELATION = "verify";
12380
12667
  const RISK_VERIFY_RELATION = "riskverify";
12381
12668
  const COLLECT_ATTRIBUTES_RELATION = "collectAttributes";
12669
+ const ENROLL_RELATION = "enroll";
12670
+ const ACTIVATE_RELATION = "activate";
12671
+ const RESEND_RELATION = "resend";
12672
+ const POLL_RELATION = "poll";
12382
12673
  const AuthenticationMethodTypeV2 = {
12383
12674
  EMAIL: "email",
12384
12675
  PASSWORD: "password",
12676
+ PHONE: "phone",
12677
+ SMS: "sms",
12678
+ };
12679
+ const PhoneRegistrationChannelV2 = {
12385
12680
  SMS: "sms",
12386
12681
  };
12387
12682
  /*
@@ -12599,16 +12894,6 @@
12599
12894
  const AuthenticationFactorV2 = {
12600
12895
  SINGLE_FACTOR: "singleFactor",
12601
12896
  MULTI_FACTOR: "multiFactor",
12602
- };
12603
- const ChallengeNextActionV2 = {
12604
- VERIFY: "verify",
12605
- RISK_VERIFY: "riskVerify",
12606
- };
12607
- const VerifyNextActionV2 = {
12608
- UPDATE: "update",
12609
- CONTINUE: "continue",
12610
- CHALLENGE: "challenge",
12611
- COLLECT_ATTRIBUTES: "collectAttributes",
12612
12897
  };
12613
12898
 
12614
12899
  /*
@@ -12619,6 +12904,7 @@
12619
12904
  VERIFY: "verify",
12620
12905
  COLLECT_ATTRIBUTES: "collectAttributes",
12621
12906
  CONTINUE: "continue",
12907
+ ENROLL: "enroll",
12622
12908
  };
12623
12909
 
12624
12910
  /*
@@ -12682,6 +12968,13 @@
12682
12968
  attributes: parsedResponse.body.attributes,
12683
12969
  };
12684
12970
  }
12971
+ if (parsedResponse.body.action === ENROLL_RELATION) {
12972
+ return {
12973
+ nextAction: ENROLL_RELATION,
12974
+ continuationToken,
12975
+ methods: this.resolveEnrollmentMethods(this.handler.requireMethods(parsedResponse.body._embedded?.methods, correlationId), correlationId),
12976
+ };
12977
+ }
12685
12978
  const message = "Invalid HAL response: sign-up attribute submission returned no known next action";
12686
12979
  this.logger?.error(message, correlationId);
12687
12980
  throw new CustomAuthApiError(INVALID_HAL_RESPONSE, message, correlationId);
@@ -12711,6 +13004,39 @@
12711
13004
  const parsedResponse = await this.sendActionRequest(verifyHref, HttpMethod.POST, request, context);
12712
13005
  return this.toVerifyResult(parsedResponse);
12713
13006
  }
13007
+ async enrollAuthMethod(enrollHref, request, context) {
13008
+ return this.sendEnrollmentRequest(enrollHref, request, context);
13009
+ }
13010
+ async resendAuthMethodRegistrationChallenge(resendHref, request, context) {
13011
+ return this.sendEnrollmentRequest(resendHref, request, context);
13012
+ }
13013
+ async sendEnrollmentRequest(href, request, context) {
13014
+ const parsedResponse = await this.sendActionRequest(href, HttpMethod.POST, request, context);
13015
+ if (parsedResponse.body.action !== ACTIVATE_RELATION) {
13016
+ throw new CustomAuthApiError(INVALID_HAL_RESPONSE, "Invalid HAL response: enrollment returned no activation action", parsedResponse.correlationId);
13017
+ }
13018
+ const links = parsedResponse.body._links;
13019
+ return {
13020
+ nextAction: ACTIVATE_RELATION,
13021
+ continuationToken: this.handler.requireContinuationToken(parsedResponse.continuationToken, parsedResponse.correlationId),
13022
+ hint: parsedResponse.body.hint,
13023
+ codeLength: this.normalizeCodeLength(parsedResponse.body.codeLength),
13024
+ activateHref: this.handler.requireHref(links?.activate?.href, ACTIVATE_RELATION, parsedResponse.correlationId),
13025
+ resendHref: links && "resend" in links
13026
+ ? this.handler.requireHref(links.resend?.href, RESEND_RELATION, parsedResponse.correlationId)
13027
+ : undefined,
13028
+ };
13029
+ }
13030
+ async activateAuthMethod(activateHref, request, context) {
13031
+ const parsedResponse = await this.sendActionRequest(activateHref, HttpMethod.POST, request, context);
13032
+ if (parsedResponse.body.state !== ResponseStateV2.CONTINUE) {
13033
+ throw new CustomAuthApiError(INVALID_HAL_RESPONSE, "Invalid HAL response: activation returned no continuation state", parsedResponse.correlationId);
13034
+ }
13035
+ return {
13036
+ nextAction: ResponseStateV2.CONTINUE,
13037
+ continuationToken: this.handler.requireContinuationToken(parsedResponse.continuationToken, parsedResponse.correlationId),
13038
+ };
13039
+ }
12714
13040
  /*
12715
13041
  * Submits the new password and returns the link used to poll for completion.
12716
13042
  */
@@ -12723,25 +13049,43 @@
12723
13049
  };
12724
13050
  }
12725
13051
  /*
12726
- * Polls once for reset completion and returns the next server-provided link.
13052
+ * Sends a poll request and validates the data needed for the next flow step.
12727
13053
  */
12728
13054
  async poll(pollHref, request, context) {
12729
13055
  const parsedResponse = await this.sendActionRequest(pollHref, HttpMethod.POST, request, context);
12730
- const isCompleted = parsedResponse.body.state === ResponseStateV2.CONTINUE;
12731
- return {
12732
- continuationToken: parsedResponse.continuationToken ?? request.continuationToken,
12733
- isCompleted,
12734
- pollHref: isCompleted
12735
- ? undefined
12736
- : this.handler.requireHref(parsedResponse.body._links?.poll?.href, "poll", parsedResponse.correlationId),
12737
- };
13056
+ const correlationId = parsedResponse.correlationId;
13057
+ const continuationToken = this.handler.requireContinuationToken(parsedResponse.continuationToken, correlationId);
13058
+ const nextAction = parsedResponse.body.action ?? parsedResponse.body.state;
13059
+ if (nextAction === ENROLL_RELATION) {
13060
+ return {
13061
+ nextAction,
13062
+ continuationToken,
13063
+ enrollmentMethods: this.resolveEnrollmentMethods(this.handler.requireMethods(parsedResponse.body._embedded?.methods, correlationId), correlationId),
13064
+ };
13065
+ }
13066
+ if (nextAction === POLL_RELATION) {
13067
+ return {
13068
+ nextAction: POLL_RELATION,
13069
+ continuationToken,
13070
+ pollHref: this.handler.requireHref(parsedResponse.body._links?.poll?.href, POLL_RELATION, correlationId),
13071
+ };
13072
+ }
13073
+ if (nextAction === ResponseStateV2.CONTINUE) {
13074
+ return {
13075
+ nextAction,
13076
+ continuationToken,
13077
+ };
13078
+ }
13079
+ const message = `Password reset poll next action '${nextAction}' is not supported.`;
13080
+ this.logger?.error(message, correlationId);
13081
+ throw new CustomAuthApiError(INVALID_HAL_RESPONSE, message, correlationId);
12738
13082
  }
12739
13083
  async sendStartRequest(startHref, request, context) {
12740
13084
  const parsedResponse = await this.sendActionRequest(startHref, HttpMethod.POST, request, context);
12741
13085
  const continuationToken = this.handler.requireContinuationToken(parsedResponse.continuationToken, parsedResponse.correlationId);
12742
13086
  return {
12743
13087
  continuationToken,
12744
- methods: this.resolveMethods(parsedResponse.body, parsedResponse.correlationId),
13088
+ methods: this.resolveMethods(this.handler.requireMethods(parsedResponse.body._embedded?.methods, parsedResponse.correlationId), parsedResponse.correlationId),
12745
13089
  authenticationFactor: this.resolveAuthenticationFactor(parsedResponse.body.challengeContext?.authenticationFactor, parsedResponse.correlationId),
12746
13090
  scenario: parsedResponse.body.scenario,
12747
13091
  };
@@ -12751,13 +13095,13 @@
12751
13095
  const continuationToken = this.handler.requireContinuationToken(parsedResponse.continuationToken, correlationId);
12752
13096
  if (parsedResponse.body.state === ResponseStateV2.CONTINUE) {
12753
13097
  return {
12754
- nextAction: VerifyNextActionV2.CONTINUE,
13098
+ nextAction: ResponseStateV2.CONTINUE,
12755
13099
  continuationToken,
12756
13100
  };
12757
13101
  }
12758
13102
  if (parsedResponse.body.action === COLLECT_ATTRIBUTES_RELATION) {
12759
13103
  return {
12760
- nextAction: VerifyNextActionV2.COLLECT_ATTRIBUTES,
13104
+ nextAction: COLLECT_ATTRIBUTES_RELATION,
12761
13105
  continuationToken,
12762
13106
  attributes: parsedResponse.body.attributes ?? [],
12763
13107
  submitAttributesHref: this.handler.requireHref(parsedResponse.body._links?.submitAttributes?.href, "submitAttributes", correlationId),
@@ -12765,21 +13109,45 @@
12765
13109
  }
12766
13110
  if (parsedResponse.body.action === UPDATE_RELATION) {
12767
13111
  return {
12768
- nextAction: VerifyNextActionV2.UPDATE,
13112
+ nextAction: UPDATE_RELATION,
12769
13113
  continuationToken,
12770
13114
  updateHref: this.handler.requireHref(parsedResponse.body._links?.update?.href, "update", correlationId),
12771
13115
  };
12772
13116
  }
12773
13117
  if (parsedResponse.body.action === CHALLENGE_RELATION) {
12774
13118
  return {
12775
- nextAction: VerifyNextActionV2.CHALLENGE,
13119
+ nextAction: CHALLENGE_RELATION,
12776
13120
  continuationToken,
12777
13121
  authenticationFactor: this.resolveAuthenticationFactor(parsedResponse.body.challengeContext?.authenticationFactor, correlationId),
12778
- methods: this.resolveMethods(parsedResponse.body, correlationId),
13122
+ methods: this.resolveMethods(this.handler.requireMethods(parsedResponse.body._embedded?.methods, correlationId), correlationId),
13123
+ };
13124
+ }
13125
+ if (parsedResponse.body.action === ENROLL_RELATION) {
13126
+ return {
13127
+ nextAction: ENROLL_RELATION,
13128
+ continuationToken,
13129
+ methods: this.resolveEnrollmentMethods(this.handler.requireMethods(parsedResponse.body._embedded?.methods, correlationId), correlationId),
12779
13130
  };
12780
13131
  }
12781
13132
  throw new CustomAuthApiError(INVALID_HAL_RESPONSE, "Invalid HAL response: verify returned no known next action", correlationId);
12782
13133
  }
13134
+ resolveEnrollmentMethods(methods, correlationId) {
13135
+ return methods.map((method) => {
13136
+ if (typeof method.type !== "string" || !method.type.trim()) {
13137
+ throw new CustomAuthApiError(INVALID_HAL_RESPONSE, "Invalid HAL response: enrollment method type is malformed", correlationId);
13138
+ }
13139
+ if (method.channels !== undefined &&
13140
+ (!Array.isArray(method.channels) ||
13141
+ method.channels.length === 0)) {
13142
+ throw new CustomAuthApiError(INVALID_HAL_RESPONSE, "Invalid HAL response: enrollment method channels are malformed", correlationId);
13143
+ }
13144
+ return {
13145
+ type: method.type,
13146
+ channels: method.channels,
13147
+ enrollHref: this.handler.requireHref(method._links?.enroll?.href, ENROLL_RELATION, correlationId),
13148
+ };
13149
+ });
13150
+ }
12783
13151
  resolveAuthenticationFactor(authenticationFactor, correlationId) {
12784
13152
  if (authenticationFactor === AuthenticationFactorV2.SINGLE_FACTOR ||
12785
13153
  authenticationFactor === AuthenticationFactorV2.MULTI_FACTOR) {
@@ -12795,7 +13163,7 @@
12795
13163
  if (parsedResponse.body.action === RISK_VERIFY_RELATION) {
12796
13164
  const riskResponse = parsedResponse.body;
12797
13165
  return {
12798
- nextAction: ChallengeNextActionV2.RISK_VERIFY,
13166
+ nextAction: RISK_VERIFY_RELATION,
12799
13167
  continuationToken: this.handler.requireContinuationToken(parsedResponse.continuationToken, parsedResponse.correlationId),
12800
13168
  riskVerifyHref: this.handler.requireHref(riskResponse._links?.riskverify?.href, RISK_VERIFY_RELATION, parsedResponse.correlationId),
12801
13169
  };
@@ -12813,18 +13181,29 @@
12813
13181
  "payload" in parsedResponse.body
12814
13182
  ? parsedResponse.body
12815
13183
  : undefined;
13184
+ const isPasswordChallenge = parsedResponse.body.type?.toLowerCase() ===
13185
+ AuthenticationMethodTypeV2.PASSWORD;
13186
+ const verifyHref = this.handler.requireHref(links?.verify?.href, VERIFY_RELATION, parsedResponse.correlationId);
13187
+ const resendHref = !isPasswordChallenge && links && "resend" in links
13188
+ ? this.handler.requireHref(links.resend?.href, RESEND_RELATION, parsedResponse.correlationId)
13189
+ : undefined;
13190
+ const codeLength = isPasswordChallenge
13191
+ ? undefined
13192
+ : this.normalizeCodeLength(codeMetadata?.codeLength ?? codeMetadata?.payload?.codeLength);
12816
13193
  return {
12817
- nextAction: ChallengeNextActionV2.VERIFY,
13194
+ nextAction: VERIFY_RELATION,
12818
13195
  continuationToken,
12819
- verifyHref: this.handler.requireHref(links?.verify?.href, "verify", parsedResponse.correlationId),
12820
- resendHref: links && "resend" in links ? links.resend?.href : undefined,
12821
- codeLength: codeMetadata?.codeLength ?? codeMetadata?.payload?.codeLength,
13196
+ verifyHref,
13197
+ resendHref,
13198
+ codeLength,
12822
13199
  hint: codeMetadata?.hint,
12823
13200
  type: parsedResponse.body.type,
12824
13201
  };
12825
13202
  }
12826
- resolveMethods(body, correlationId) {
12827
- const methods = this.handler.requireMethods(body._embedded?.methods, correlationId);
13203
+ normalizeCodeLength(value) {
13204
+ return typeof value === "number" && Number.isInteger(value) ? value : 0;
13205
+ }
13206
+ resolveMethods(methods, correlationId) {
12828
13207
  const resolved = [];
12829
13208
  methods.forEach((method, index) => {
12830
13209
  const href = method._links?.challenge?.href;
@@ -12920,6 +13299,8 @@
12920
13299
  const FLOW_ATTRIBUTES_REQUIRED_V2 = "FlowAttributesRequiredResultV2";
12921
13300
  const FLOW_SIGN_IN_CONTINUATION_REQUIRED_V2 = "FlowSignInContinuationRequiredResultV2";
12922
13301
  const FLOW_COMPLETED_V2 = "FlowCompletedResultV2";
13302
+ const FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2 = "FlowAuthMethodRegistrationRequiredResultV2";
13303
+ const FLOW_AUTH_METHOD_VERIFICATION_REQUIRED_V2 = "FlowAuthMethodVerificationRequiredResultV2";
12923
13304
  function createFlowMethodSelectionRequiredResultV2(input) {
12924
13305
  return { type: FLOW_METHOD_SELECTION_REQUIRED_V2, ...input };
12925
13306
  }
@@ -12946,6 +13327,12 @@
12946
13327
  }
12947
13328
  function createFlowCompletedResultV2(input) {
12948
13329
  return { type: FLOW_COMPLETED_V2, ...input };
13330
+ }
13331
+ function createFlowAuthMethodRegistrationRequiredResultV2(input) {
13332
+ return { type: FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2, ...input };
13333
+ }
13334
+ function createFlowAuthMethodVerificationRequiredResultV2(input) {
13335
+ return { type: FLOW_AUTH_METHOD_VERIFICATION_REQUIRED_V2, ...input };
12949
13336
  }
12950
13337
 
12951
13338
  /*
@@ -12992,7 +13379,20 @@
12992
13379
  signInWithContinuation: SIGN_UP_V2_COMPLETE,
12993
13380
  },
12994
13381
  };
12995
- function getPublicApiIdV2(scenario, step) {
13382
+ const MFA_STEP_API_IDS_V2 = {
13383
+ requestChallenge: MFA_V2_SELECT_AUTH_METHOD,
13384
+ submitCode: MFA_V2_SUBMIT_CHALLENGE,
13385
+ resendCode: MFA_V2_RESEND_CHALLENGE,
13386
+ };
13387
+ /**
13388
+ * Resolves the telemetry API ID for a flow step. MFA challenge operations use
13389
+ * distinct IDs when the sign-in caller identifies the second factor.
13390
+ */
13391
+ function getPublicApiIdV2(scenario, step, authenticationFactor) {
13392
+ if (scenario === CustomAuthFlowScenarioV2.SignIn &&
13393
+ authenticationFactor === AuthenticationFactorV2.MULTI_FACTOR) {
13394
+ return (MFA_STEP_API_IDS_V2[step] ?? FLOW_STEP_API_IDS_V2[scenario]?.[step]);
13395
+ }
12996
13396
  return FLOW_STEP_API_IDS_V2[scenario]?.[step];
12997
13397
  }
12998
13398
 
@@ -13116,8 +13516,9 @@
13116
13516
  },
13117
13517
  };
13118
13518
  const result = this.toSignUpActionResult(submitResult, continuationState, correlationId);
13119
- if (result.type === FLOW_SIGN_IN_CONTINUATION_REQUIRED_V2) {
13120
- const message = "Initial sign-up attribute submission cannot complete without code verification or additional attributes.";
13519
+ if (result.type === FLOW_SIGN_IN_CONTINUATION_REQUIRED_V2 ||
13520
+ result.type === FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2) {
13521
+ const message = `Initial sign-up attribute submission returned unsupported next action '${submitResult.nextAction}'.`;
13121
13522
  this.logger.error(message, correlationId);
13122
13523
  throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13123
13524
  }
@@ -13224,6 +13625,47 @@
13224
13625
  this.logger.error(message, parameters.correlationId);
13225
13626
  throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, parameters.correlationId);
13226
13627
  }
13628
+ /*
13629
+ * Registers the selected offered method and returns activation metadata.
13630
+ */
13631
+ async registerAuthMethod(parameters) {
13632
+ const { continuationState, correlationId } = parameters;
13633
+ if (!parameters.verificationContact?.trim()) {
13634
+ throw new InvalidArgumentError("verificationContact", correlationId);
13635
+ }
13636
+ const registrationRequest = this.createRegistrationRequest(parameters.method, parameters.verificationContact, continuationState.continuationToken, correlationId);
13637
+ const context = this.createRequestContext(JIT_V2_ENROLL_AUTH_METHOD, correlationId);
13638
+ this.logger.verbose("Registering a V2 authentication method.", correlationId);
13639
+ const result = await this.apiClient.enrollAuthMethod(this.requireLink(correlationId, parameters.method.enrollHref), registrationRequest, context);
13640
+ return this.createAuthMethodVerificationRequiredResult(continuationState, result, correlationId);
13641
+ }
13642
+ /*
13643
+ * Activates the registered method and redeems the resulting continuation
13644
+ * for tokens.
13645
+ */
13646
+ async verifyAuthMethodRegistration(parameters) {
13647
+ const { continuationState, correlationId } = parameters;
13648
+ const context = this.createRequestContext(JIT_V2_SUBMIT_CHALLENGE, correlationId);
13649
+ this.logger.verbose("Activating a V2 authentication method.", correlationId);
13650
+ const result = await this.apiClient.activateAuthMethod(this.requireLink(correlationId, continuationState.links.activate), {
13651
+ continuationToken: continuationState.continuationToken,
13652
+ otp: parameters.code,
13653
+ }, context);
13654
+ return this.completeSignInAfterVerification(continuationState, result.continuationToken, correlationId);
13655
+ }
13656
+ /*
13657
+ * Requests a replacement activation challenge through the server-provided
13658
+ * resend link using the latest continuation token.
13659
+ */
13660
+ async resendAuthMethodRegistrationChallenge(parameters) {
13661
+ const { continuationState, correlationId } = parameters;
13662
+ const context = this.createRequestContext(JIT_V2_RESEND_CHALLENGE, correlationId);
13663
+ this.logger.verbose("Resending a V2 authentication-method activation challenge.", correlationId);
13664
+ const result = await this.apiClient.resendAuthMethodRegistrationChallenge(this.requireLink(correlationId, continuationState.links.resend), {
13665
+ continuationToken: continuationState.continuationToken,
13666
+ }, context);
13667
+ return this.createAuthMethodVerificationRequiredResult(continuationState, result, correlationId);
13668
+ }
13227
13669
  /*
13228
13670
  * Verifies the submitted one-time code using the server-provided link. The
13229
13671
  * response determines the next required action.
@@ -13231,7 +13673,7 @@
13231
13673
  async submitCode(parameters) {
13232
13674
  const continuationState = parameters.continuationState;
13233
13675
  const correlationId = parameters.correlationId;
13234
- const context = this.createRequestContext(this.resolveStepApiId(continuationState.scenario, "submitCode", correlationId), correlationId);
13676
+ const context = this.createRequestContext(this.resolveStepApiId(continuationState.scenario, "submitCode", correlationId, parameters.authenticationFactor), correlationId);
13235
13677
  this.logger.verbose("Submitting V2 one-time code.", correlationId);
13236
13678
  const verifyHref = this.requireLink(correlationId, continuationState.links.verify);
13237
13679
  const verifyRequest = {
@@ -13241,7 +13683,7 @@
13241
13683
  const verifyResult = await this.apiClient.verifyChallenge(verifyHref, verifyRequest, context);
13242
13684
  if (continuationState.scenario ===
13243
13685
  CustomAuthFlowScenarioV2.PasswordReset &&
13244
- verifyResult.nextAction === VerifyNextActionV2.UPDATE) {
13686
+ verifyResult.nextAction === UPDATE_RELATION) {
13245
13687
  return createFlowNewPasswordRequiredResultV2({
13246
13688
  correlationId,
13247
13689
  continuationState: {
@@ -13255,46 +13697,8 @@
13255
13697
  if (continuationState.scenario === CustomAuthFlowScenarioV2.SignIn) {
13256
13698
  return this.handleSignInVerification(continuationState, verifyResult, correlationId);
13257
13699
  }
13258
- if (continuationState.scenario === CustomAuthFlowScenarioV2.SignUp &&
13259
- verifyResult.nextAction === VerifyNextActionV2.COLLECT_ATTRIBUTES) {
13260
- const requiredPasswordAttribute = verifyResult.attributes.find((attribute) => attribute.attributeId.toLowerCase() === "password" &&
13261
- attribute.required === true);
13262
- const nextContinuationState = {
13263
- continuationToken: verifyResult.continuationToken,
13264
- scenario: continuationState.scenario,
13265
- scopes: continuationState.scopes,
13266
- links: {
13267
- submitAttributes: verifyResult.submitAttributesHref,
13268
- },
13269
- signUp: continuationState.signUp,
13270
- };
13271
- const attributes = verifyResult.attributes.filter((attribute) => attribute.attributeId.toLowerCase() !== "password");
13272
- if (requiredPasswordAttribute &&
13273
- continuationState.signUp?.passwordWasSupplied !== true) {
13274
- return createFlowSignUpPasswordRequiredResultV2({
13275
- correlationId,
13276
- continuationState: nextContinuationState,
13277
- attributes,
13278
- requiredPasswordAttribute,
13279
- });
13280
- }
13281
- return createFlowAttributesRequiredResultV2({
13282
- correlationId,
13283
- continuationState: nextContinuationState,
13284
- attributes,
13285
- });
13286
- }
13287
- if (continuationState.scenario === CustomAuthFlowScenarioV2.SignUp &&
13288
- verifyResult.nextAction === VerifyNextActionV2.CONTINUE) {
13289
- return createFlowSignInContinuationRequiredResultV2({
13290
- correlationId,
13291
- continuationState: {
13292
- continuationToken: verifyResult.continuationToken,
13293
- scenario: continuationState.scenario,
13294
- scopes: continuationState.scopes,
13295
- links: {},
13296
- },
13297
- });
13700
+ if (continuationState.scenario === CustomAuthFlowScenarioV2.SignUp) {
13701
+ return this.handleSignUpVerification(continuationState, verifyResult, correlationId);
13298
13702
  }
13299
13703
  const message = `Verification next action '${verifyResult.nextAction}' is not supported for the '${continuationState.scenario}' flow.`;
13300
13704
  this.logger.error(message, correlationId);
@@ -13345,34 +13749,52 @@
13345
13749
  }, context);
13346
13750
  let pollToken = updateResult.continuationToken;
13347
13751
  let pollHref = updateResult.pollHref;
13348
- let completionToken;
13752
+ let pollResult;
13753
+ let isPolling = false;
13349
13754
  for (let attempt = 1; attempt <= POLL_MAX_ATTEMPTS; attempt++) {
13350
- const pollResult = await this.apiClient.poll(pollHref, { continuationToken: pollToken }, context);
13351
- if (pollResult.isCompleted) {
13352
- completionToken = pollResult.continuationToken;
13755
+ pollResult = await this.apiClient.poll(pollHref, { continuationToken: pollToken }, context);
13756
+ isPolling = pollResult.nextAction === POLL_RELATION;
13757
+ if (!isPolling) {
13353
13758
  break;
13354
13759
  }
13355
13760
  pollToken = pollResult.continuationToken;
13356
- pollHref = pollResult.pollHref ?? pollHref;
13761
+ pollHref = this.requireLink(correlationId, pollResult.pollHref);
13357
13762
  if (attempt < POLL_MAX_ATTEMPTS) {
13358
13763
  await delay(POLL_INTERVAL_MS);
13359
13764
  }
13360
13765
  }
13361
- if (!completionToken) {
13766
+ if (!pollResult || isPolling) {
13362
13767
  const message = "The password reset did not complete within the allotted number of polling attempts.";
13363
13768
  this.logger.error(message, correlationId);
13364
13769
  throw new CustomAuthError(RESET_PASSWORD_TIMEOUT, message, correlationId);
13365
13770
  }
13366
- this.logger.verbose("V2 password reset applied; sign-in required.", correlationId);
13367
- return createFlowSignInContinuationRequiredResultV2({
13368
- correlationId,
13369
- continuationState: {
13370
- continuationToken: completionToken,
13371
- scenario: continuationState.scenario,
13372
- scopes: continuationState.scopes,
13373
- links: {},
13374
- },
13375
- });
13771
+ if (pollResult.nextAction === ENROLL_RELATION &&
13772
+ pollResult.enrollmentMethods) {
13773
+ return this.createAuthMethodRegistrationRequiredResult({
13774
+ correlationId,
13775
+ continuationState: {
13776
+ ...continuationState,
13777
+ continuationToken: pollResult.continuationToken,
13778
+ links: {},
13779
+ },
13780
+ methods: pollResult.enrollmentMethods,
13781
+ });
13782
+ }
13783
+ if (pollResult.nextAction === ResponseStateV2.CONTINUE) {
13784
+ this.logger.verbose("V2 password reset applied; sign-in required.", correlationId);
13785
+ return createFlowSignInContinuationRequiredResultV2({
13786
+ correlationId,
13787
+ continuationState: {
13788
+ continuationToken: pollResult.continuationToken,
13789
+ scenario: continuationState.scenario,
13790
+ scopes: continuationState.scopes,
13791
+ links: {},
13792
+ },
13793
+ });
13794
+ }
13795
+ const message = `Password reset poll next action '${pollResult.nextAction}' is not supported.`;
13796
+ this.logger.error(message, correlationId);
13797
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13376
13798
  }
13377
13799
  /*
13378
13800
  * Verifies a sign-in password and returns the next sign-in action.
@@ -13402,7 +13824,18 @@
13402
13824
  });
13403
13825
  }
13404
13826
  async handleSignInVerification(continuationState, verifyResult, correlationId) {
13405
- if (verifyResult.nextAction === VerifyNextActionV2.CHALLENGE) {
13827
+ if (verifyResult.nextAction === ENROLL_RELATION) {
13828
+ return this.createAuthMethodRegistrationRequiredResult({
13829
+ correlationId,
13830
+ continuationState: {
13831
+ ...continuationState,
13832
+ continuationToken: verifyResult.continuationToken,
13833
+ links: {},
13834
+ },
13835
+ methods: verifyResult.methods,
13836
+ });
13837
+ }
13838
+ if (verifyResult.nextAction === CHALLENGE_RELATION) {
13406
13839
  this.ensureAuthenticationFactor(verifyResult.authenticationFactor, AuthenticationFactorV2.MULTI_FACTOR, "after sign-in verification", correlationId);
13407
13840
  return createFlowMFARequiredResultV2({
13408
13841
  correlationId,
@@ -13420,13 +13853,68 @@
13420
13853
  })),
13421
13854
  });
13422
13855
  }
13423
- if (verifyResult.nextAction === VerifyNextActionV2.CONTINUE) {
13856
+ if (verifyResult.nextAction === ResponseStateV2.CONTINUE) {
13424
13857
  return this.completeSignInAfterVerification(continuationState, verifyResult.continuationToken, correlationId);
13425
13858
  }
13426
13859
  const message = `Verification next action '${verifyResult.nextAction}' is not supported for sign-in.`;
13427
13860
  this.logger.error(message, correlationId);
13428
13861
  throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13429
13862
  }
13863
+ handleSignUpVerification(continuationState, verifyResult, correlationId) {
13864
+ if (verifyResult.nextAction === COLLECT_ATTRIBUTES_RELATION) {
13865
+ const requiredPasswordAttribute = verifyResult.attributes.find((attribute) => attribute.attributeId.toLowerCase() === "password" &&
13866
+ attribute.required === true);
13867
+ const nextContinuationState = {
13868
+ continuationToken: verifyResult.continuationToken,
13869
+ scenario: continuationState.scenario,
13870
+ scopes: continuationState.scopes,
13871
+ links: {
13872
+ submitAttributes: verifyResult.submitAttributesHref,
13873
+ },
13874
+ signUp: continuationState.signUp,
13875
+ };
13876
+ const attributes = verifyResult.attributes.filter((attribute) => attribute.attributeId.toLowerCase() !== "password");
13877
+ if (requiredPasswordAttribute &&
13878
+ continuationState.signUp?.passwordWasSupplied !== true) {
13879
+ return createFlowSignUpPasswordRequiredResultV2({
13880
+ correlationId,
13881
+ continuationState: nextContinuationState,
13882
+ attributes,
13883
+ requiredPasswordAttribute,
13884
+ });
13885
+ }
13886
+ return createFlowAttributesRequiredResultV2({
13887
+ correlationId,
13888
+ continuationState: nextContinuationState,
13889
+ attributes,
13890
+ });
13891
+ }
13892
+ if (verifyResult.nextAction === ENROLL_RELATION) {
13893
+ return this.createAuthMethodRegistrationRequiredResult({
13894
+ correlationId,
13895
+ continuationState: {
13896
+ ...continuationState,
13897
+ continuationToken: verifyResult.continuationToken,
13898
+ links: {},
13899
+ },
13900
+ methods: verifyResult.methods,
13901
+ });
13902
+ }
13903
+ if (verifyResult.nextAction === ResponseStateV2.CONTINUE) {
13904
+ return createFlowSignInContinuationRequiredResultV2({
13905
+ correlationId,
13906
+ continuationState: {
13907
+ continuationToken: verifyResult.continuationToken,
13908
+ scenario: continuationState.scenario,
13909
+ scopes: continuationState.scopes,
13910
+ links: {},
13911
+ },
13912
+ });
13913
+ }
13914
+ const message = `Verification next action '${verifyResult.nextAction}' is not supported for the '${continuationState.scenario}' flow.`;
13915
+ this.logger.error(message, correlationId);
13916
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13917
+ }
13430
13918
  getSupportedSignInMethods(methods, correlationId) {
13431
13919
  const supportedMethods = methods.filter((method) => {
13432
13920
  const methodType = method.type.toLowerCase();
@@ -13441,6 +13929,79 @@
13441
13929
  this.logger.error(message, correlationId);
13442
13930
  throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13443
13931
  }
13932
+ createRegistrationRequest(method, verificationContact, continuationToken, correlationId) {
13933
+ if (method.type === AuthenticationMethodTypeV2.EMAIL) {
13934
+ return {
13935
+ continuationToken,
13936
+ email: verificationContact,
13937
+ };
13938
+ }
13939
+ const [channel] = method.channels ?? [];
13940
+ if (method.type === AuthenticationMethodTypeV2.PHONE &&
13941
+ channel === PhoneRegistrationChannelV2.SMS) {
13942
+ return {
13943
+ continuationToken,
13944
+ phoneNumber: verificationContact,
13945
+ channel,
13946
+ };
13947
+ }
13948
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, "The selected authentication method is not supported for registration.", correlationId);
13949
+ }
13950
+ createAuthMethodRegistrationRequiredResult(parameters) {
13951
+ const { correlationId, continuationState } = parameters;
13952
+ const supportedMethods = parameters.methods.filter((method) => {
13953
+ const methodType = method.type.trim().toLowerCase();
13954
+ return (methodType === AuthenticationMethodTypeV2.EMAIL ||
13955
+ (methodType === AuthenticationMethodTypeV2.PHONE &&
13956
+ method.channels?.includes(PhoneRegistrationChannelV2.SMS)));
13957
+ });
13958
+ if (supportedMethods.length === 0) {
13959
+ const message = "The enrollment response did not include a supported registration method.";
13960
+ this.logger.error(message, correlationId);
13961
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13962
+ }
13963
+ const methods = supportedMethods.map((method) => {
13964
+ const methodType = method.type.trim().toLowerCase();
13965
+ const channel = method.channels?.find((candidate) => candidate === PhoneRegistrationChannelV2.SMS);
13966
+ if (methodType === AuthenticationMethodTypeV2.EMAIL) {
13967
+ return {
13968
+ type: AuthenticationMethodTypeV2.EMAIL,
13969
+ enrollHref: this.requireLink(correlationId, method.enrollHref),
13970
+ };
13971
+ }
13972
+ if (methodType === AuthenticationMethodTypeV2.PHONE &&
13973
+ channel === PhoneRegistrationChannelV2.SMS) {
13974
+ return {
13975
+ type: AuthenticationMethodTypeV2.PHONE,
13976
+ channels: [channel],
13977
+ enrollHref: this.requireLink(correlationId, method.enrollHref),
13978
+ };
13979
+ }
13980
+ const message = "The enrollment response included an unsupported registration method.";
13981
+ this.logger.error(message, correlationId);
13982
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13983
+ });
13984
+ return createFlowAuthMethodRegistrationRequiredResultV2({
13985
+ correlationId,
13986
+ continuationState,
13987
+ methods,
13988
+ });
13989
+ }
13990
+ createAuthMethodVerificationRequiredResult(continuationState, result, correlationId) {
13991
+ return createFlowAuthMethodVerificationRequiredResultV2({
13992
+ correlationId,
13993
+ continuationState: {
13994
+ ...continuationState,
13995
+ continuationToken: result.continuationToken,
13996
+ links: {
13997
+ activate: this.requireLink(correlationId, result.activateHref),
13998
+ resend: result.resendHref,
13999
+ },
14000
+ },
14001
+ sentTo: result.hint,
14002
+ codeLength: result.codeLength,
14003
+ });
14004
+ }
13444
14005
  toSignUpActionResult(result, continuationState, correlationId) {
13445
14006
  const nextAction = result.nextAction;
13446
14007
  if (result.nextAction === SignUpSubmitAttributesNextActionV2.VERIFY) {
@@ -13461,6 +14022,17 @@
13461
14022
  codeLength: result.codeLength,
13462
14023
  });
13463
14024
  }
14025
+ if (result.nextAction === SignUpSubmitAttributesNextActionV2.ENROLL) {
14026
+ return this.createAuthMethodRegistrationRequiredResult({
14027
+ correlationId,
14028
+ continuationState: {
14029
+ ...continuationState,
14030
+ continuationToken: result.continuationToken,
14031
+ links: {},
14032
+ },
14033
+ methods: result.methods,
14034
+ });
14035
+ }
13464
14036
  if (result.nextAction ===
13465
14037
  SignUpSubmitAttributesNextActionV2.COLLECT_ATTRIBUTES) {
13466
14038
  const requiredPasswordAttribute = result.attributes.find((attribute) => attribute.attributeId.toLowerCase() === "password" &&
@@ -13539,16 +14111,16 @@
13539
14111
  const challengeHref = step === "resendCode"
13540
14112
  ? continuationState.links.resend
13541
14113
  : continuationState.links.challenge;
13542
- const context = this.createRequestContext(this.resolveStepApiId(continuationState.scenario, step, correlationId), correlationId);
14114
+ const context = this.createRequestContext(this.resolveStepApiId(continuationState.scenario, step, correlationId, parameters.authenticationFactor), correlationId);
13543
14115
  this.logger.verbose(step === "resendCode"
13544
14116
  ? "Resending V2 one-time code."
13545
14117
  : "Requesting V2 challenge.", correlationId);
13546
14118
  const challengeResult = await this.apiClient.requestChallenge(this.requireLink(correlationId, challengeHref), { continuationToken: continuationState.continuationToken }, context);
13547
14119
  const nextAction = challengeResult.nextAction;
13548
- if (challengeResult.nextAction === ChallengeNextActionV2.VERIFY) {
14120
+ if (challengeResult.nextAction === VERIFY_RELATION) {
13549
14121
  return challengeResult;
13550
14122
  }
13551
- if (challengeResult.nextAction === ChallengeNextActionV2.RISK_VERIFY) {
14123
+ if (challengeResult.nextAction === RISK_VERIFY_RELATION) {
13552
14124
  return this.apiClient.verifyRisk(challengeResult.riskVerifyHref, { continuationToken: challengeResult.continuationToken }, context);
13553
14125
  }
13554
14126
  const message = `Challenge next action '${nextAction}' is not supported.`;
@@ -13571,8 +14143,8 @@
13571
14143
  }),
13572
14144
  };
13573
14145
  }
13574
- resolveStepApiId(scenario, step, correlationId) {
13575
- const apiId = getPublicApiIdV2(scenario, step);
14146
+ resolveStepApiId(scenario, step, correlationId, authenticationFactor) {
14147
+ const apiId = getPublicApiIdV2(scenario, step, authenticationFactor);
13576
14148
  if (apiId === undefined) {
13577
14149
  const message = `No telemetry API id is registered for step '${step}' of the '${scenario}' flow.`;
13578
14150
  this.logger.error(message, correlationId);
@@ -13581,7 +14153,7 @@
13581
14153
  return apiId;
13582
14154
  }
13583
14155
  requireLink(correlationId, href, missingLinkError) {
13584
- if (!href) {
14156
+ if (typeof href !== "string" || !href.trim()) {
13585
14157
  const errorCode = missingLinkError?.code ?? CONTINUATION_LINK_MISSING;
13586
14158
  const message = missingLinkError?.message ??
13587
14159
  "The continuation state is missing a link required to advance the flow.";
@@ -13867,6 +14439,141 @@
13867
14439
  }
13868
14440
  }
13869
14441
 
14442
+ /*
14443
+ * Copyright (c) Microsoft Corporation. All rights reserved.
14444
+ * Licensed under the MIT License.
14445
+ */
14446
+ /**
14447
+ * State returned when a newly registered authentication method must be
14448
+ * activated with the challenge sent by the service.
14449
+ */
14450
+ class AuthMethodVerificationRequiredStateV2 extends AuthFlowActionRequiredStateBase {
14451
+ constructor(stateParameters) {
14452
+ super(stateParameters);
14453
+ this.stateType = "authMethodVerificationRequired";
14454
+ this.type = stateParameters.type;
14455
+ this.sentTo = stateParameters.sentTo;
14456
+ this.codeLength = stateParameters.codeLength;
14457
+ }
14458
+ /**
14459
+ * Submits the activation challenge for the registered method.
14460
+ * @param challenge - The activation challenge to submit.
14461
+ * @returns The completed authentication result or a failed state.
14462
+ */
14463
+ async submitChallenge(challenge) {
14464
+ const { correlationId, continuationState, flowClient, logger } = this.stateParameters;
14465
+ try {
14466
+ ensureArgumentIsNotNullOrUndefined("challenge", challenge, correlationId);
14467
+ logger.verbose("Submitting a V2 authentication-method activation challenge.", correlationId);
14468
+ const result = await flowClient.verifyAuthMethodRegistration({
14469
+ correlationId,
14470
+ continuationState,
14471
+ code: challenge,
14472
+ });
14473
+ const account = new CustomAuthAccountData(result.authenticationResult.account, this.stateParameters.config, this.stateParameters.cacheClient, logger, correlationId);
14474
+ return new CustomAuthResultV2(new CompletedStateV2(), account, continuationState.scenario);
14475
+ }
14476
+ catch (error) {
14477
+ logger.errorPii(`Failed to submit the V2 authentication-method activation challenge. Error: '${error}'.`, correlationId);
14478
+ return CustomAuthResultV2.createWithError(error, {
14479
+ scenario: continuationState.scenario,
14480
+ correlationId,
14481
+ });
14482
+ }
14483
+ }
14484
+ /**
14485
+ * Requests a replacement activation challenge using the retained server
14486
+ * resend link.
14487
+ * @returns Refreshed activation metadata or a failed state.
14488
+ */
14489
+ async resendChallenge() {
14490
+ const { correlationId, continuationState, flowClient, logger } = this.stateParameters;
14491
+ try {
14492
+ logger.verbose("Resending a V2 authentication-method activation challenge.", correlationId);
14493
+ const result = await flowClient.resendAuthMethodRegistrationChallenge({
14494
+ correlationId,
14495
+ continuationState,
14496
+ });
14497
+ return new CustomAuthResultV2(new AuthMethodVerificationRequiredStateV2({
14498
+ correlationId: result.correlationId,
14499
+ logger,
14500
+ config: this.stateParameters.config,
14501
+ flowClient,
14502
+ cacheClient: this.stateParameters.cacheClient,
14503
+ continuationState: result.continuationState,
14504
+ type: this.type,
14505
+ sentTo: result.sentTo ?? this.sentTo,
14506
+ codeLength: result.codeLength,
14507
+ }), undefined, result.continuationState.scenario);
14508
+ }
14509
+ catch (error) {
14510
+ logger.errorPii(`Failed to resend the V2 authentication-method activation challenge. Error: '${error}'.`, correlationId);
14511
+ return CustomAuthResultV2.createWithError(error, {
14512
+ scenario: continuationState.scenario,
14513
+ correlationId,
14514
+ });
14515
+ }
14516
+ }
14517
+ }
14518
+
14519
+ /*
14520
+ * Copyright (c) Microsoft Corporation. All rights reserved.
14521
+ * Licensed under the MIT License.
14522
+ */
14523
+ /**
14524
+ * State returned when an authentication method must be registered. Applications
14525
+ * select one of the sanitized offered methods and provide its contact value.
14526
+ */
14527
+ class AuthMethodRegistrationRequiredStateV2 extends AuthFlowActionRequiredStateBase {
14528
+ constructor(stateParameters) {
14529
+ super(stateParameters);
14530
+ this.stateType = "authMethodRegistrationRequired";
14531
+ this.methods = stateParameters.methods;
14532
+ }
14533
+ /**
14534
+ * Selects an authentication method for strong-auth registration and requests
14535
+ * its activation challenge.
14536
+ * @param method - A method from {@link methods}.
14537
+ * @param verificationContact - The email address or phone number to register.
14538
+ * @returns The registration activation result.
14539
+ */
14540
+ async selectAuthMethod(method, verificationContact) {
14541
+ const { correlationId, continuationState, flowClient, logger } = this.stateParameters;
14542
+ try {
14543
+ const selectedMethod = this.methods.find((candidate) => candidate.type === method.type);
14544
+ if (!selectedMethod) {
14545
+ throw new InvalidArgumentError("method", correlationId);
14546
+ }
14547
+ ensureArgumentIsNotEmptyString("verificationContact", verificationContact, correlationId);
14548
+ logger.verbose("Registering the selected V2 authentication method.", correlationId);
14549
+ const result = await flowClient.registerAuthMethod({
14550
+ correlationId,
14551
+ continuationState,
14552
+ method: selectedMethod,
14553
+ verificationContact,
14554
+ });
14555
+ return new CustomAuthResultV2(new AuthMethodVerificationRequiredStateV2({
14556
+ correlationId: result.correlationId,
14557
+ logger,
14558
+ config: this.stateParameters.config,
14559
+ flowClient,
14560
+ cacheClient: this.stateParameters.cacheClient,
14561
+ continuationState: result.continuationState,
14562
+ type: selectedMethod.type,
14563
+ sentTo: result.sentTo,
14564
+ codeLength: result.codeLength,
14565
+ }), undefined, result.continuationState.scenario);
14566
+ }
14567
+ catch (error) {
14568
+ logger.errorPii(`Failed to register the selected V2 authentication method. Error: '${error}'.`, correlationId);
14569
+ return CustomAuthResultV2.createWithError(error, {
14570
+ scenario: continuationState.scenario,
14571
+ correlationId,
14572
+ });
14573
+ }
14574
+ }
14575
+ }
14576
+
13870
14577
  /*
13871
14578
  * Copyright (c) Microsoft Corporation. All rights reserved.
13872
14579
  * Licensed under the MIT License.
@@ -13914,8 +14621,8 @@
13914
14621
  */
13915
14622
  /**
13916
14623
  * State returned when the user must supply a new password to complete the flow.
13917
- * A successful submission returns `SignInContinuationStateV2` so the app can
13918
- * sign the user in.
14624
+ * A successful submission can require registration or return a continuation
14625
+ * for sign-in.
13919
14626
  */
13920
14627
  class NewPasswordRequiredStateV2 extends AuthFlowActionRequiredStateBase {
13921
14628
  constructor() {
@@ -13923,8 +14630,8 @@
13923
14630
  this.stateType = "newPasswordRequired";
13924
14631
  }
13925
14632
  /**
13926
- * Submits the new password to complete the reset. The result either allows
13927
- * sign-in or reports that the password was rejected.
14633
+ * Submits the new password to complete the reset. Enrollment may be
14634
+ * required before sign-in; a rejected password returns an error.
13928
14635
  * @param password - The new password to set.
13929
14636
  * @returns The result of submitting the new password.
13930
14637
  */
@@ -13938,14 +14645,29 @@
13938
14645
  continuationState,
13939
14646
  newPassword: password,
13940
14647
  });
13941
- return new CustomAuthResultV2(new SignInContinuationStateV2({
13942
- correlationId: result.correlationId,
13943
- logger,
13944
- config: this.stateParameters.config,
13945
- flowClient,
13946
- continuationState: result.continuationState,
13947
- cacheClient: this.stateParameters.cacheClient,
13948
- }), undefined, result.continuationState.scenario);
14648
+ const resultType = result.type;
14649
+ if (result.type === FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2) {
14650
+ return new CustomAuthResultV2(new AuthMethodRegistrationRequiredStateV2({
14651
+ correlationId: result.correlationId,
14652
+ logger,
14653
+ config: this.stateParameters.config,
14654
+ flowClient,
14655
+ continuationState: result.continuationState,
14656
+ cacheClient: this.stateParameters.cacheClient,
14657
+ methods: result.methods,
14658
+ }), undefined, result.continuationState.scenario);
14659
+ }
14660
+ if (result.type === FLOW_SIGN_IN_CONTINUATION_REQUIRED_V2) {
14661
+ return new CustomAuthResultV2(new SignInContinuationStateV2({
14662
+ correlationId: result.correlationId,
14663
+ logger,
14664
+ config: this.stateParameters.config,
14665
+ flowClient,
14666
+ continuationState: result.continuationState,
14667
+ cacheClient: this.stateParameters.cacheClient,
14668
+ }), undefined, result.continuationState.scenario);
14669
+ }
14670
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, `Password submission result type '${resultType}' is not supported.`, correlationId);
13949
14671
  }
13950
14672
  catch (error) {
13951
14673
  logger.errorPii(`Failed to submit V2 new password. Error: '${error}'.`, correlationId);
@@ -13969,18 +14691,20 @@
13969
14691
  this.channel = stateParameters.channel;
13970
14692
  this.codeLength = stateParameters.codeLength;
13971
14693
  }
13972
- async submitCodeCore(code) {
14694
+ async submitCodeCore(code, authenticationFactor) {
13973
14695
  ensureArgumentIsNotNullOrUndefined("code", code, this.stateParameters.correlationId);
13974
14696
  return this.stateParameters.flowClient.submitCode({
13975
14697
  correlationId: this.stateParameters.correlationId,
13976
14698
  continuationState: this.stateParameters.continuationState,
14699
+ authenticationFactor,
13977
14700
  code,
13978
14701
  });
13979
14702
  }
13980
- async resendCodeCore() {
14703
+ async resendCodeCore(authenticationFactor) {
13981
14704
  return this.stateParameters.flowClient.resendCode({
13982
14705
  correlationId: this.stateParameters.correlationId,
13983
14706
  continuationState: this.stateParameters.continuationState,
14707
+ authenticationFactor,
13984
14708
  });
13985
14709
  }
13986
14710
  }
@@ -14041,6 +14765,17 @@
14041
14765
  cacheClient: this.stateParameters.cacheClient,
14042
14766
  }), undefined, result.continuationState.scenario);
14043
14767
  }
14768
+ if (result.type === FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2) {
14769
+ return new CustomAuthResultV2(new AuthMethodRegistrationRequiredStateV2({
14770
+ correlationId: result.correlationId,
14771
+ logger,
14772
+ config: this.stateParameters.config,
14773
+ flowClient: this.stateParameters.flowClient,
14774
+ continuationState: result.continuationState,
14775
+ cacheClient: this.stateParameters.cacheClient,
14776
+ methods: result.methods,
14777
+ }), undefined, result.continuationState.scenario);
14778
+ }
14044
14779
  if (result.type === FLOW_MFA_REQUIRED_V2) {
14045
14780
  const signInStateTransitionHandler = this.stateParameters.signInStateTransitionHandler;
14046
14781
  if (!signInStateTransitionHandler) {
@@ -14120,7 +14855,7 @@
14120
14855
  const { correlationId, logger, continuationState } = this.stateParameters;
14121
14856
  try {
14122
14857
  logger.verbose("Submitting V2 MFA challenge.", correlationId);
14123
- const result = await this.submitCodeCore(challenge);
14858
+ const result = await this.submitCodeCore(challenge, AuthenticationFactorV2.MULTI_FACTOR);
14124
14859
  if (result.type !== FLOW_COMPLETED_V2) {
14125
14860
  throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, `MFA challenge submission result type '${result.type}' is not supported.`, correlationId);
14126
14861
  }
@@ -14144,7 +14879,7 @@
14144
14879
  const { correlationId, logger, continuationState } = this.stateParameters;
14145
14880
  try {
14146
14881
  logger.verbose("Resending V2 MFA challenge.", correlationId);
14147
- const result = await this.resendCodeCore();
14882
+ const result = await this.resendCodeCore(AuthenticationFactorV2.MULTI_FACTOR);
14148
14883
  return new CustomAuthResultV2(new MFAVerificationRequiredStateV2({
14149
14884
  correlationId: result.correlationId,
14150
14885
  logger,
@@ -14259,13 +14994,14 @@
14259
14994
  }
14260
14995
  }
14261
14996
  async requestSelectedMethodChallenge(method) {
14262
- const { correlationId, continuationState, flowClient } = this.stateParameters;
14997
+ const { correlationId, continuationState, flowClient, authenticationFactor, } = this.stateParameters;
14263
14998
  const selectedMethod = this.methods.find((candidate) => candidate.id === method.id);
14264
14999
  if (!selectedMethod) {
14265
15000
  throw new InvalidArgumentError("method", correlationId);
14266
15001
  }
14267
15002
  const result = await flowClient.requestChallenge({
14268
15003
  correlationId,
15004
+ authenticationFactor,
14269
15005
  continuationState: {
14270
15006
  ...continuationState,
14271
15007
  links: {
@@ -14310,6 +15046,17 @@
14310
15046
  const account = new CustomAuthAccountData(result.authenticationResult.account, this.stateParameters.config, this.stateParameters.cacheClient, logger, correlationId);
14311
15047
  return new CustomAuthResultV2(new CompletedStateV2(), account, continuationState.scenario);
14312
15048
  }
15049
+ if (result.type === FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2) {
15050
+ return new CustomAuthResultV2(new AuthMethodRegistrationRequiredStateV2({
15051
+ correlationId: result.correlationId,
15052
+ logger,
15053
+ config: this.stateParameters.config,
15054
+ flowClient,
15055
+ continuationState: result.continuationState,
15056
+ cacheClient: this.stateParameters.cacheClient,
15057
+ methods: result.methods,
15058
+ }), undefined, result.continuationState.scenario);
15059
+ }
14313
15060
  if (result.type === FLOW_MFA_REQUIRED_V2) {
14314
15061
  return new CustomAuthResultV2(new AuthMethodSelectionRequiredStateV2({
14315
15062
  correlationId: result.correlationId,
@@ -14466,6 +15213,12 @@
14466
15213
  if (result.type === FLOW_SIGN_IN_CONTINUATION_REQUIRED_V2) {
14467
15214
  return new CustomAuthResultV2(new SignInContinuationStateV2(commonStateParameters), undefined, result.continuationState.scenario);
14468
15215
  }
15216
+ if (result.type === FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2) {
15217
+ return new CustomAuthResultV2(new AuthMethodRegistrationRequiredStateV2({
15218
+ ...commonStateParameters,
15219
+ methods: result.methods,
15220
+ }), undefined, result.continuationState.scenario);
15221
+ }
14469
15222
  throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, `Sign-up ${submission} submission result type '${result.type}' is not supported.`, stateParameters.correlationId);
14470
15223
  }
14471
15224
  handleVerification(result, stateParameters) {
@@ -18939,7 +19692,7 @@
18939
19692
  throw cacheError;
18940
19693
  }
18941
19694
  // When cache quota is exceeded, start removing access tokens until we can successfully set the item
18942
- this.removeAccessToken(accessTokenKeys[i], correlationId, false // Don't save token keys yet, do it at the end
19695
+ await this.removeAccessTokenAndTokenBindingKey(accessTokenKeys[i], correlationId, undefined, false // Don't save token keys yet, do it at the end
18943
19696
  );
18944
19697
  }
18945
19698
  else {
@@ -19081,6 +19834,13 @@
19081
19834
  super.removeAccessToken(key, correlationId);
19082
19835
  updateTokenKeys && this.removeAccessTokenKeys([key], correlationId);
19083
19836
  }
19837
+ /**
19838
+ * Removes an access token and awaits token-binding key cleanup.
19839
+ */
19840
+ async removeAccessTokenAndTokenBindingKey(key, correlationId, preservedKeyId, updateTokenKeys = true) {
19841
+ await super.removeAccessTokenAndTokenBindingKey(key, correlationId, preservedKeyId);
19842
+ updateTokenKeys && this.removeAccessTokenKeys([key], correlationId);
19843
+ }
19084
19844
  /**
19085
19845
  * Remove access token key from the key map
19086
19846
  * @param key
@@ -19815,6 +20575,116 @@
19815
20575
  return browserStorage.getActiveAccount(correlationId);
19816
20576
  }
19817
20577
 
20578
+ /*
20579
+ * Copyright (c) Microsoft Corporation. All rights reserved.
20580
+ * Licensed under the MIT License.
20581
+ */
20582
+ const POPUP_POLL_INTERVAL_MS = 30;
20583
+ let activePopupPoller;
20584
+ /**
20585
+ * Cancels legacy popup polling when an interaction is superseded.
20586
+ *
20587
+ * @internal
20588
+ * @param logger Logger for the interaction.
20589
+ */
20590
+ function cancelPendingPopupPollingResponse(logger) {
20591
+ if (activePopupPoller) {
20592
+ logger.verbose("PopupMonitor.cancelPendingPopupPollingResponse - Cancelling pending popup poller", activePopupPoller.correlationId);
20593
+ activePopupPoller.cancel();
20594
+ }
20595
+ }
20596
+ /**
20597
+ * Monitors a popup window for a URL change to the same origin as the parent application.
20598
+ * Polls the popup at a specified interval until it is redirected back to the application,
20599
+ * closed by the user, or a navigation to a same-origin URL is detected. Once a same-origin
20600
+ * URL is detected, extracts the response string (query or hash) and resolves the promise.
20601
+ *
20602
+ * @param popupWindow - The popup window to monitor for navigation.
20603
+ * @param popupWindowParent - The parent window that opened the popup.
20604
+ * @param responseMode - Response mode (`"query"` | `"fragment"`) determines whether
20605
+ * to read `location.search` or `location.hash` from the popup once on the same
20606
+ * origin. Any value other than `"query"` is treated as fragment.
20607
+ * @param logger - Logger instance.
20608
+ * @param unloadWindow - Event handler to remove from the parent window on cleanup.
20609
+ * @param correlationId
20610
+ */
20611
+ async function monitorPopupForHash(popupWindow, popupWindowParent, responseMode, logger, unloadWindow, correlationId) {
20612
+ let poller;
20613
+ return new Promise((resolve, reject) => {
20614
+ logger.verbose("PopupMonitor.monitorPopupForHash - polling started", correlationId);
20615
+ const intervalId = window.setInterval(() => {
20616
+ if (popupWindow.closed) {
20617
+ logger.error("PopupMonitor.monitorPopupForHash - window closed", correlationId);
20618
+ window.clearInterval(intervalId);
20619
+ reject(new BrowserAuthError(userCancelled, correlationId));
20620
+ return;
20621
+ }
20622
+ let href = "";
20623
+ try {
20624
+ /*
20625
+ * Will throw if cross origin,
20626
+ * which should be caught and ignored
20627
+ * since we need the interval to keep running while on STS UI.
20628
+ */
20629
+ href = popupWindow.location.href;
20630
+ }
20631
+ catch (e) { }
20632
+ // Don't process blank pages or cross domain
20633
+ if (!href || href === "about:blank") {
20634
+ return;
20635
+ }
20636
+ window.clearInterval(intervalId);
20637
+ let responseString;
20638
+ if (responseMode === ResponseMode.QUERY) {
20639
+ responseString = popupWindow.location.search;
20640
+ }
20641
+ else {
20642
+ responseString = popupWindow.location.hash;
20643
+ }
20644
+ logger.verbose("PopupMonitor.monitorPopupForHash - popup window is on same origin as caller", correlationId);
20645
+ resolve(responseString);
20646
+ }, POPUP_POLL_INTERVAL_MS);
20647
+ poller = {
20648
+ correlationId,
20649
+ cancel: () => {
20650
+ window.clearInterval(intervalId);
20651
+ if (activePopupPoller === poller) {
20652
+ activePopupPoller = undefined;
20653
+ }
20654
+ reject(new BrowserAuthError(interactionInProgressCancelled, correlationId));
20655
+ },
20656
+ };
20657
+ activePopupPoller = poller;
20658
+ }).finally(() => {
20659
+ if (poller && activePopupPoller === poller) {
20660
+ activePopupPoller = undefined;
20661
+ }
20662
+ cleanPopup(popupWindow, popupWindowParent, unloadWindow);
20663
+ });
20664
+ }
20665
+ /**
20666
+ * Performs cleanup operations after popup authentication.
20667
+ * Strips auth-response params (code/state) from the popup URL while it is still
20668
+ * open, closes the popup window, and removes the 'beforeunload' event listener
20669
+ * from the parent window.
20670
+ *
20671
+ * @param popupWindow - The popup window to be closed.
20672
+ * @param popupWindowParent - The parent window from which the event listener will be removed.
20673
+ * @param unloadWindow - The event handler function to remove.
20674
+ */
20675
+ function cleanPopup(popupWindow, popupWindowParent, unloadWindow) {
20676
+ if (!popupWindow.closed) {
20677
+ try {
20678
+ clearAuthResponseFromUrl(popupWindow);
20679
+ }
20680
+ catch {
20681
+ // Popup may have become cross-origin or otherwise inaccessible; ignore.
20682
+ }
20683
+ }
20684
+ popupWindow.close();
20685
+ popupWindowParent.removeEventListener("beforeunload", unloadWindow);
20686
+ }
20687
+
19818
20688
  /*
19819
20689
  * Copyright (c) Microsoft Corporation. All rights reserved.
19820
20690
  * Licensed under the MIT License.
@@ -20235,12 +21105,26 @@
20235
21105
  * Copyright (c) Microsoft Corporation. All rights reserved.
20236
21106
  * Licensed under the MIT License.
20237
21107
  */
21108
+ /**
21109
+ * Key storage enclaves supported by the platform broker.
21110
+ */
21111
+ const PlatformAuthEnclave = {
21112
+ /**
21113
+ * Persisted software key using MS_KEY_STORAGE_PROVIDER.
21114
+ */
21115
+ SOFTWARE: "sw"};
20238
21116
  /**
20239
21117
  * Token types supported by the platform broker request contract.
20240
21118
  */
20241
21119
  const PlatformAuthTokenType = {
20242
21120
  DPOP_WITH_PROOF: "dpop+proof",
20243
21121
  };
21122
+ /**
21123
+ * Token binding preferences supported by the platform broker.
21124
+ */
21125
+ const PlatformAuthBindingPreference = {
21126
+ ATTESTED: "attested",
21127
+ };
20244
21128
  const PROOF_OF_POSSESSION_TOKEN_TYPES = [
20245
21129
  AuthenticationScheme.POP,
20246
21130
  AuthenticationScheme.DPOP,
@@ -20256,19 +21140,19 @@
20256
21140
  /**
20257
21141
  * Adds canonical proof request fields to the broker no-cache property bag.
20258
21142
  */
20259
- function createPlatformAuthExtraParametersNoCache(extraParametersNoCache, isProofOfPossessionRequest, resourceRequestMethod, resourceRequestUri, dpopNonce) {
20260
- if (!isProofOfPossessionRequest) {
20261
- return extraParametersNoCache;
21143
+ function createPlatformAuthExtraParametersNoCache(tokenType, resourceRequestMethod, resourceRequestUri, dpopNonce) {
21144
+ if (!isProofOfPossessionTokenType(tokenType)) {
21145
+ return undefined;
20262
21146
  }
20263
21147
  return {
20264
- ...extraParametersNoCache,
20265
21148
  ...(resourceRequestMethod && {
20266
21149
  pop_method: resourceRequestMethod,
20267
21150
  }),
20268
21151
  ...(resourceRequestUri && {
20269
21152
  pop_url: resourceRequestUri,
20270
21153
  }),
20271
- ...(dpopNonce && {
21154
+ ...(tokenType === PlatformAuthTokenType.DPOP_WITH_PROOF &&
21155
+ dpopNonce && {
20272
21156
  pop_nonce: dpopNonce,
20273
21157
  }),
20274
21158
  };
@@ -20415,6 +21299,7 @@
20415
21299
  * Copyright (c) Microsoft Corporation. All rights reserved.
20416
21300
  * Licensed under the MIT License.
20417
21301
  */
21302
+ const DPOP_POP_KID_NOT_SUPPORTED = "dpop_pop_kid_not_supported";
20418
21303
  class PlatformAuthInteractionClient extends BaseInteractionClient {
20419
21304
  constructor(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, provider, accountId, nativeStorageImpl, correlationId, tokenBindingKeyManager) {
20420
21305
  super(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, performanceClient, correlationId, provider, tokenBindingKeyManager);
@@ -20473,17 +21358,9 @@
20473
21358
  throw e;
20474
21359
  }
20475
21360
  // check if the tokens can be retrieved from internal cache
21361
+ let cachedResult;
20476
21362
  try {
20477
- const result = await this.acquireTokensFromCache(this.accountId, nativeRequest);
20478
- // Served from the native internal cache; token did not come directly from the broker
20479
- nativeATMeasurement.add({
20480
- isNativeBroker: false,
20481
- });
20482
- nativeATMeasurement.end({
20483
- success: true,
20484
- fromCache: true,
20485
- });
20486
- return result;
21363
+ cachedResult = await this.acquireTokensFromCache(this.accountId, nativeRequest);
20487
21364
  }
20488
21365
  catch (e) {
20489
21366
  if (cacheLookupPolicy === CacheLookupPolicy.AccessToken) {
@@ -20494,13 +21371,28 @@
20494
21371
  nativeATMeasurement.end({
20495
21372
  success: false,
20496
21373
  });
21374
+ await this.resetGeneratedDpopRequestKeyBestEffort(nativeRequest);
20497
21375
  throw e;
20498
21376
  }
20499
21377
  // continue with a native call for any and all errors
20500
21378
  this.logger.info("MSAL internal Cache does not contain tokens, proceed to make a native call", this.correlationId);
20501
21379
  }
21380
+ if (cachedResult) {
21381
+ // Served from the native internal cache; token did not come directly from the broker
21382
+ nativeATMeasurement.add({
21383
+ isNativeBroker: false,
21384
+ });
21385
+ nativeATMeasurement.end({
21386
+ success: true,
21387
+ fromCache: true,
21388
+ });
21389
+ await this.resetGeneratedDpopRequestKey(nativeRequest);
21390
+ return cachedResult;
21391
+ }
20502
21392
  // dispatch the request to the broker
20503
21393
  try {
21394
+ await this.prepareDpopBrokerRequest(nativeRequest);
21395
+ this.addDpopBrokerAttemptTelemetry(nativeRequest);
20504
21396
  const validatedResponse = await this.platformAuthProvider.sendMessage(nativeRequest);
20505
21397
  const result = await invokeAsync(this.handleNativeResponse.bind(this), PlatformAuthHandleNativeResponse, this.logger, this.performanceClient, this.correlationId)(validatedResponse, nativeRequest, reqTimestamp, request.storeInCache);
20506
21398
  nativeATMeasurement.end({
@@ -20518,6 +21410,7 @@
20518
21410
  success: false,
20519
21411
  }, e);
20520
21412
  this.setBrokerErrorTelemetry(e);
21413
+ await this.resetGeneratedDpopRequestKeyBestEffort(nativeRequest);
20521
21414
  throw e;
20522
21415
  }
20523
21416
  }
@@ -20552,6 +21445,7 @@
20552
21445
  scopes: ScopeSet.fromString(request.scope, this.correlationId).asArray(),
20553
21446
  account: cachedAccount,
20554
21447
  forceRefresh: false,
21448
+ ...this.createSilentCacheTokenBindingParameters(request),
20555
21449
  resource: request.extraParameters?.resource,
20556
21450
  };
20557
21451
  // Preserve FMI partition semantics for silent cache filtering.
@@ -20560,6 +21454,29 @@
20560
21454
  }
20561
21455
  return silentRequest;
20562
21456
  }
21457
+ /**
21458
+ * Maps platform-broker token-binding state to silent-cache request fields.
21459
+ * @param request
21460
+ */
21461
+ createSilentCacheTokenBindingParameters(request) {
21462
+ const authenticationScheme = this.isDpopBrokerRequest(request)
21463
+ ? AuthenticationScheme.DPOP
21464
+ : request.tokenType;
21465
+ if (authenticationScheme !== AuthenticationScheme.DPOP &&
21466
+ authenticationScheme !== AuthenticationScheme.POP) {
21467
+ return { authenticationScheme };
21468
+ }
21469
+ return {
21470
+ authenticationScheme,
21471
+ ...(authenticationScheme === AuthenticationScheme.DPOP &&
21472
+ request.keyId && { dpopJkt: request.keyId }),
21473
+ ...(authenticationScheme === AuthenticationScheme.POP &&
21474
+ request.signPopToken === false &&
21475
+ request.keyId && { popKid: request.keyId }),
21476
+ resourceRequestMethod: request.resourceRequestMethod,
21477
+ resourceRequestUri: request.resourceRequestUri,
21478
+ };
21479
+ }
20563
21480
  /**
20564
21481
  * Fetches the tokens from the cache if un-expired
20565
21482
  * @param nativeAccountId
@@ -20608,10 +21525,22 @@
20608
21525
  const nativeRequest = await invokeAsync(this.initializePlatformRequest.bind(this), PlatformAuthInteractionClientInitializeRequest, this.logger, this.performanceClient, this.correlationId)(request);
20609
21526
  const navigateToLoginRequestUrl = options?.navigateToLoginRequestUrl ?? true;
20610
21527
  try {
20611
- await this.platformAuthProvider.sendMessage(nativeRequest);
21528
+ await this.prepareDpopBrokerRequest(nativeRequest);
21529
+ this.addDpopBrokerAttemptTelemetry(nativeRequest);
21530
+ const response = await this.platformAuthProvider.sendMessage(nativeRequest);
21531
+ const dpopBrokerOutcome = this.validateDpopBrokerOutcome(response, nativeRequest);
21532
+ if (dpopBrokerOutcome === "L3") {
21533
+ await this.resetGeneratedDpopRequestKey(nativeRequest);
21534
+ }
20612
21535
  }
20613
21536
  catch (e) {
20614
- // Only throw fatal errors here to allow application to fallback to regular redirect. Otherwise proceed and the error will be thrown in handleRedirectPromise
21537
+ /*
21538
+ * Raw persistent/transient broker errors are retrieved again in
21539
+ * phase two. Availability errors are thrown for controller-managed
21540
+ * web fallback, while translated cancellation, network, and
21541
+ * interaction-required errors are surfaced without being swallowed.
21542
+ */
21543
+ await this.resetGeneratedDpopRequestKeyBestEffort(nativeRequest);
20615
21544
  if (e instanceof NativeAuthError) {
20616
21545
  const serverTelemetryManager = initializeServerTelemetryManager(this.apiId, this.config.auth.clientId, this.correlationId, this.browserStorage, this.logger, undefined, this.config.system.serverTelemetryEnabled);
20617
21546
  serverTelemetryManager.setNativeBrokerErrorCode(e.errorCode);
@@ -20626,6 +21555,16 @@
20626
21555
  throw e;
20627
21556
  }
20628
21557
  }
21558
+ else if (this.isDpopBrokerRequest(nativeRequest)) {
21559
+ throw e;
21560
+ }
21561
+ }
21562
+ try {
21563
+ await this.ensureRedirectDpopKeyIsPersisted(nativeRequest);
21564
+ }
21565
+ catch (e) {
21566
+ await this.resetGeneratedDpopRequestKeyBestEffort(nativeRequest);
21567
+ throw e;
20629
21568
  }
20630
21569
  this.browserStorage.setTemporaryCache(TemporaryCacheKeys.NATIVE_REQUEST, JSON.stringify({
20631
21570
  ...nativeRequest,
@@ -20640,7 +21579,14 @@
20640
21579
  ? UrlString.getAbsoluteUrl(request.redirectStartPage || window.location.href, getCurrentUri(), this.correlationId)
20641
21580
  : getRedirectUri(request.redirectUri, this.config.auth.redirectUri, this.logger, this.correlationId);
20642
21581
  rootMeasurement.end({ success: true });
20643
- await this.navigationClient.navigateExternal(redirectUri, navigationOptions); // Need to treat this as external to ensure handleRedirectPromise is run again
21582
+ try {
21583
+ await this.navigationClient.navigateExternal(redirectUri, navigationOptions); // Need to treat this as external to ensure handleRedirectPromise is run again
21584
+ }
21585
+ catch (e) {
21586
+ this.browserStorage.removeItem(this.browserStorage.generateCacheKey(TemporaryCacheKeys.NATIVE_REQUEST));
21587
+ await this.resetGeneratedDpopRequestKeyBestEffort(nativeRequest);
21588
+ throw e;
21589
+ }
20644
21590
  }
20645
21591
  /**
20646
21592
  * If the previous page called native platform for a token using redirect APIs, send the same request again and return the response
@@ -20673,6 +21619,8 @@
20673
21619
  this.browserStorage.removeItem(this.browserStorage.generateCacheKey(TemporaryCacheKeys.NATIVE_REQUEST));
20674
21620
  const reqTimestamp = nowSeconds();
20675
21621
  try {
21622
+ await this.prepareDpopBrokerRequest(request, true);
21623
+ this.addDpopBrokerAttemptTelemetry(request);
20676
21624
  this.logger.verbose("NativeInteractionClient - handleRedirectPromise sending message to native broker.", this.correlationId);
20677
21625
  const response = await this.platformAuthProvider.sendMessage(request);
20678
21626
  const authResult = await invokeAsync(this.handleNativeResponse.bind(this), PlatformAuthHandleNativeResponse, this.logger, this.performanceClient, this.correlationId)(response, request, reqTimestamp, storeInCache);
@@ -20681,7 +21629,12 @@
20681
21629
  return authResult;
20682
21630
  }
20683
21631
  catch (e) {
21632
+ if (e instanceof NativeAuthError) {
21633
+ const serverTelemetryManager = initializeServerTelemetryManager(this.apiId, this.config.auth.clientId, this.correlationId, this.browserStorage, this.logger, undefined, this.config.system.serverTelemetryEnabled);
21634
+ serverTelemetryManager.setNativeBrokerErrorCode(e.errorCode);
21635
+ }
20684
21636
  this.setBrokerErrorTelemetry(e);
21637
+ await this.resetGeneratedDpopRequestKeyBestEffort(request);
20685
21638
  throw e;
20686
21639
  }
20687
21640
  }
@@ -20701,6 +21654,7 @@
20701
21654
  */
20702
21655
  async handleNativeResponse(response, request, reqTimestamp, storeInCache) {
20703
21656
  this.logger.trace("NativeInteractionClient - handleNativeResponse called.", this.correlationId);
21657
+ const dpopBrokerOutcome = this.validateDpopBrokerOutcome(response, request);
20704
21658
  // generate identifiers
20705
21659
  const idTokenClaims = extractTokenClaims(response.id_token, base64Decode, this.correlationId);
20706
21660
  const homeAccountIdentifier = this.createHomeAccountIdentifier(response, idTokenClaims);
@@ -20726,10 +21680,17 @@
20726
21680
  response.expires_in = Number(response.expires_in);
20727
21681
  // generate authenticationResult
20728
21682
  const result = await invokeAsync(this.generateAuthenticationResult.bind(this), NativeGenerateAuthResult, this.logger, this.performanceClient, this.correlationId)(response, request, idTokenClaims, baseAccount, authority.canonicalAuthority, reqTimestamp);
21683
+ const isL3DpopResponse = dpopBrokerOutcome === "L3";
20729
21684
  // cache accounts and tokens in the appropriate storage
20730
- await invokeAsync(this.cacheAccount.bind(this), PlatformAuthCacheAccount, this.logger, this.performanceClient, this.correlationId)(baseAccount, isKmsi(idTokenClaims));
21685
+ const shouldRemoveGeneratedDpopKey = isL3DpopResponse ||
21686
+ (this.isDpopBrokerRequest(request) &&
21687
+ storeInCache?.accessToken === false);
21688
+ if (shouldRemoveGeneratedDpopKey) {
21689
+ await this.resetGeneratedDpopRequestKey(request);
21690
+ }
21691
+ await invokeAsync(this.cacheAccount.bind(this), PlatformAuthCacheAccount, this.logger, this.performanceClient, this.correlationId)(baseAccount, isKmsi(idTokenClaims), !isL3DpopResponse);
20731
21692
  await invokeAsync(this.cacheNativeTokens.bind(this), PlatformAuthCacheNativeTokens, this.logger, this.performanceClient, this.correlationId)(response, request, homeAccountIdentifier, idTokenClaims, result.tenantId, reqTimestamp, authority.getPreferredCache(), // environment
20732
- storeInCache);
21693
+ storeInCache, dpopBrokerOutcome);
20733
21694
  return result;
20734
21695
  }
20735
21696
  /**
@@ -20805,7 +21766,7 @@
20805
21766
  */
20806
21767
  async generateAuthenticationResult(response, request, idTokenClaims, accountEntity, authority, reqTimestamp) {
20807
21768
  // Add Native Broker fields to Telemetry
20808
- const mats = this.addTelemetryFromNativeResponse(response.properties.MATS);
21769
+ const mats = this.addTelemetryFromNativeResponse(response.properties?.MATS);
20809
21770
  // If scopes not returned in server response, use request scopes
20810
21771
  const responseScopes = this.generateScopes(request.scope, response.scope);
20811
21772
  const accountProperties = response.account.properties || {};
@@ -20831,9 +21792,17 @@
20831
21792
  }
20832
21793
  // generate PoP token as needed
20833
21794
  const responseAccessToken = await this.generatePopAccessToken(response, request);
20834
- const tokenType = request.tokenType === AuthenticationScheme.POP
20835
- ? AuthenticationScheme.POP
20836
- : AuthenticationScheme.BEARER;
21795
+ const isDpopRequest = this.isDpopBrokerRequest(request);
21796
+ let tokenType = AuthenticationScheme.BEARER;
21797
+ if (isDpopRequest) {
21798
+ tokenType = AuthenticationScheme.DPOP;
21799
+ }
21800
+ else if (request.tokenType === AuthenticationScheme.POP) {
21801
+ tokenType = AuthenticationScheme.POP;
21802
+ }
21803
+ const dpopProof = isDpopRequest
21804
+ ? await this.generateDpopProof(response, request)
21805
+ : undefined;
20837
21806
  const result = {
20838
21807
  authority: authority,
20839
21808
  uniqueId: uid,
@@ -20847,6 +21816,7 @@
20847
21816
  // Request timestamp and NativeResponse expires_in are in seconds, converting to Date for AuthenticationResult
20848
21817
  expiresOn: toDateFromSeconds(reqTimestamp + response.expires_in),
20849
21818
  tokenType: tokenType,
21819
+ dpopProof,
20850
21820
  correlationId: this.correlationId,
20851
21821
  state: response.state,
20852
21822
  fromPlatformBroker: true,
@@ -20860,11 +21830,13 @@
20860
21830
  * cache the account entity in browser storage
20861
21831
  * @param accountEntity
20862
21832
  */
20863
- async cacheAccount(accountEntity, kmsi) {
21833
+ async cacheAccount(accountEntity, kmsi, clearExistingTokens = true) {
20864
21834
  // Store the account info and hence `nativeAccountId` in browser cache
20865
21835
  await this.browserStorage.setAccount(accountEntity, this.correlationId, kmsi, this.apiId);
20866
21836
  // Remove any existing cached tokens for this account in browser storage
20867
- this.browserStorage.removeAccountContext(getAccountInfo(accountEntity), this.correlationId);
21837
+ if (clearExistingTokens) {
21838
+ this.browserStorage.removeAccountContext(getAccountInfo(accountEntity), this.correlationId);
21839
+ }
20868
21840
  }
20869
21841
  /**
20870
21842
  * Stores the access_token and id_token in inmemory storage
@@ -20876,8 +21848,18 @@
20876
21848
  * @param tenantId
20877
21849
  * @param reqTimestamp
20878
21850
  */
20879
- async cacheNativeTokens(response, request, homeAccountIdentifier, idTokenClaims, tenantId, reqTimestamp, environment, storeInCache) {
21851
+ async cacheNativeTokens(response, request, homeAccountIdentifier, idTokenClaims, tenantId, reqTimestamp, environment, storeInCache, dpopBrokerOutcome = "none") {
20880
21852
  const cachedIdToken = createIdTokenEntity(homeAccountIdentifier, environment, response.id_token || "", request.clientId, idTokenClaims.tid || "");
21853
+ // save idtoken credential in configured browser storage
21854
+ if (!!cachedIdToken && storeInCache?.idToken !== false) {
21855
+ await this.browserStorage.setIdTokenCredential(cachedIdToken, this.correlationId, isKmsi(idTokenClaims));
21856
+ }
21857
+ if (dpopBrokerOutcome === "L3") {
21858
+ return;
21859
+ }
21860
+ if (storeInCache?.accessToken === false) {
21861
+ return;
21862
+ }
20881
21863
  // cache accessToken in inmemory storage
20882
21864
  const expiresIn = request.tokenType === AuthenticationScheme.POP
20883
21865
  ? SHR_NONCE_VALIDITY
@@ -20887,18 +21869,14 @@
20887
21869
  const tokenExpirationSeconds = reqTimestamp + expiresIn;
20888
21870
  const responseScopes = this.generateScopes(response.scope, request.scope);
20889
21871
  const additionalCacheKeyComponents = request.attributeTokens
20890
- ? {
20891
- attribute_tokens: request.attributeTokens,
20892
- }
21872
+ ? { attribute_tokens: request.attributeTokens }
20893
21873
  : undefined;
20894
- const cachedAccessToken = createAccessTokenEntity(homeAccountIdentifier, environment, response.access_token, request.clientId, idTokenClaims.tid || tenantId, responseScopes.printScopes(), tokenExpirationSeconds, 0, base64Decode, request.correlationId, undefined, request.tokenType, undefined, request.keyId, additionalCacheKeyComponents);
21874
+ const cachedAccessToken = createAccessTokenEntity(homeAccountIdentifier, environment, response.access_token, request.clientId, idTokenClaims.tid || tenantId, responseScopes.printScopes(), tokenExpirationSeconds, 0, base64Decode, request.correlationId, undefined, this.isDpopBrokerRequest(request)
21875
+ ? AuthenticationScheme.DPOP
21876
+ : request.tokenType, undefined, request.keyId, additionalCacheKeyComponents);
20895
21877
  if (request.extraParameters?.resource) {
20896
21878
  cachedAccessToken.resource = request.extraParameters.resource;
20897
21879
  }
20898
- // save idtoken credential in configured browser storage
20899
- if (!!cachedIdToken && storeInCache?.idToken !== false) {
20900
- await this.browserStorage.setIdTokenCredential(cachedIdToken, this.correlationId, isKmsi(idTokenClaims));
20901
- }
20902
21880
  // save access token credential in memory storage
20903
21881
  const nativeCacheRecord = {
20904
21882
  accessToken: cachedAccessToken,
@@ -20975,11 +21953,7 @@
20975
21953
  const configClaims = request.skipBrokerClaims && !!request.embeddedClientId
20976
21954
  ? undefined
20977
21955
  : this.config.auth.clientCapabilities;
20978
- /*
20979
- * scopes are expected to be received by the native broker as "scope" and will be added to the request below. Other properties that should be dropped from the request to the native broker can be included in the object destructuring here.
20980
- * attributeTokens is destructured out because PlatformAuthRequest represents it as a pre-serialized string, not the caller-provided Array<string>.
20981
- */
20982
- const { scopes, claims, extraParametersNoCache, dpopNonce } = request;
21956
+ const { scopes, claims, dpopNonce } = request;
20983
21957
  const scopeSet = new ScopeSet([...(scopes || []), ...OIDC_DEFAULT_SCOPES], this.correlationId);
20984
21958
  const mergedClaims = buildMergedClaims(claims, configClaims?.length ? configClaims : undefined);
20985
21959
  const hasAttributeTokens = !!request.attributeTokens?.length;
@@ -21003,56 +21977,390 @@
21003
21977
  loginHint: request.loginHint,
21004
21978
  extraParameters: {
21005
21979
  ...request.extraParameters,
21006
- ...(request.resource && { resource: request.resource }), // resource is set for MCP scenarios
21980
+ // Native broker resource is set for MCP scenarios.
21981
+ ...(request.resource && { resource: request.resource }),
21007
21982
  },
21008
21983
  extendedExpiryToken: false,
21009
21984
  keyId: request.popKid,
21010
- resourceRequestMethod: request.resourceRequestMethod,
21011
- resourceRequestUri: request.resourceRequestUri,
21012
- shrClaims: request.shrClaims,
21013
- shrNonce: request.shrNonce,
21014
- extraParametersNoCache: createPlatformAuthExtraParametersNoCache(extraParametersNoCache, isProofOfPossessionTokenType(request.authenticationScheme), request.resourceRequestMethod, request.resourceRequestUri, dpopNonce),
21015
21985
  };
21016
21986
  if (hasAttributeTokens) {
21017
21987
  validatedRequest.attributeTokens =
21018
21988
  serializeAttributeTokens(request.attributeTokens);
21019
21989
  }
21020
- // Check for PoP token requests: signPopToken should only be set to true if popKid is not set
21021
- if (validatedRequest.signPopToken && !!request.popKid) {
21022
- throw createBrowserAuthError(invalidPopTokenRequest, this.correlationId);
21990
+ this.handleExtraBrokerParams(validatedRequest, request.embeddedClientId);
21991
+ validatedRequest.extraParameters =
21992
+ validatedRequest.extraParameters || {};
21993
+ validatedRequest.extraParameters.telemetry =
21994
+ PlatformAuthConstants.MATS_TELEMETRY;
21995
+ if (request.authenticationScheme === AuthenticationScheme.POP) {
21996
+ const shrParameters = {
21997
+ resourceRequestMethod: request.resourceRequestMethod,
21998
+ resourceRequestUri: request.resourceRequestUri,
21999
+ shrClaims: request.shrClaims,
22000
+ shrNonce: request.shrNonce,
22001
+ correlationId: this.correlationId,
22002
+ };
22003
+ const popTokenGenerator = new PopTokenGenerator(this.browserCrypto, this.tokenBindingKeyManager, this.performanceClient);
22004
+ if (!validatedRequest.keyId) {
22005
+ const generatedReqCnfData = await invokeAsync(popTokenGenerator.generateCnf.bind(popTokenGenerator), PopTokenGenerateCnf, this.logger, this.performanceClient, this.correlationId)(shrParameters, this.logger);
22006
+ validatedRequest.reqCnf = generatedReqCnfData.reqCnfString;
22007
+ validatedRequest.keyId = generatedReqCnfData.kid;
22008
+ validatedRequest.signPopToken = true;
22009
+ }
22010
+ else {
22011
+ validatedRequest.reqCnf = this.browserCrypto.base64UrlEncode(JSON.stringify({ kid: validatedRequest.keyId }));
22012
+ validatedRequest.signPopToken = false;
22013
+ }
22014
+ validatedRequest.resourceRequestMethod =
22015
+ request.resourceRequestMethod;
22016
+ validatedRequest.resourceRequestUri = request.resourceRequestUri;
22017
+ validatedRequest.shrClaims = request.shrClaims;
22018
+ validatedRequest.shrNonce = request.shrNonce;
22019
+ }
22020
+ else if (request.authenticationScheme === AuthenticationScheme.DPOP) {
22021
+ Object.assign(validatedRequest, this.createDpopRequestParameters(request));
22022
+ }
22023
+ validatedRequest.extraParametersNoCache =
22024
+ createPlatformAuthExtraParametersNoCache(validatedRequest.tokenType, validatedRequest.resourceRequestMethod, validatedRequest.resourceRequestUri, dpopNonce);
22025
+ this.addRequestSKUs(validatedRequest);
22026
+ return validatedRequest;
22027
+ }
22028
+ /**
22029
+ * Creates and validates the broker-specific parameters for a DPoP request.
22030
+ * @param request - Developer-provided token request.
22031
+ * @returns Broker parameters for a DPoP token and resource proof.
22032
+ */
22033
+ createDpopRequestParameters(request) {
22034
+ if (request.popKid) {
22035
+ throw createBrowserAuthError(DPOP_POP_KID_NOT_SUPPORTED, this.correlationId);
22036
+ }
22037
+ if (!request.resourceRequestMethod?.trim() ||
22038
+ !request.resourceRequestUri?.trim()) {
22039
+ throw createClientConfigurationError(dpopMissingResourceContext, this.correlationId);
22040
+ }
22041
+ const resourceContext = normalizeDpopResourceRequestContext({
22042
+ htm: request.resourceRequestMethod,
22043
+ htu: request.resourceRequestUri,
22044
+ }, this.correlationId);
22045
+ return {
22046
+ tokenType: PlatformAuthTokenType.DPOP_WITH_PROOF,
22047
+ preferBinding: PlatformAuthBindingPreference.ATTESTED,
22048
+ keyId: request.dpopJkt,
22049
+ resourceRequestMethod: resourceContext.htm,
22050
+ resourceRequestUri: resourceContext.htu,
22051
+ };
22052
+ }
22053
+ /**
22054
+ * Provisions the local key and confirmation data for a DPoP broker request.
22055
+ * @param request - Broker request to prepare.
22056
+ * @param reuseExistingKey - Whether a complete existing key binding may be reused.
22057
+ */
22058
+ async prepareDpopBrokerRequest(request, reuseExistingKey = false) {
22059
+ if (request.tokenType !== PlatformAuthTokenType.DPOP_WITH_PROOF) {
22060
+ return;
22061
+ }
22062
+ /*
22063
+ * Phase one clears both fields after an L3 response or non-fatal broker
22064
+ * error. In that case phase two must provision a replacement. If either
22065
+ * field remains, treat it as a retained binding and validate it fully.
22066
+ */
22067
+ if (reuseExistingKey && (request.keyId || request.reqCnf)) {
22068
+ if (!request.keyId || !request.reqCnf) {
22069
+ throw createAuthError(unexpectedError, this.correlationId, "DPoP request key binding is incomplete after redirect.");
22070
+ }
22071
+ const expectedReqCnf = this.createDpopBrokerReqCnf(request.keyId);
22072
+ if (request.reqCnf !== expectedReqCnf) {
22073
+ throw createAuthError(unexpectedError, this.correlationId, "DPoP request key binding is invalid after redirect.");
22074
+ }
22075
+ const hasKey = this.tokenBindingKeyManager.hasTokenBindingKey !== undefined
22076
+ ? await this.tokenBindingKeyManager.hasTokenBindingKey(request.keyId, this.correlationId)
22077
+ : await this.tokenBindingKeyManager
22078
+ .getTokenBindingPublicKeyJwk(request.keyId, this.correlationId)
22079
+ .then(() => true, () => false);
22080
+ if (!hasKey) {
22081
+ throw createAuthError(unexpectedError, this.correlationId, "DPoP request key is unavailable after redirect.");
22082
+ }
22083
+ return;
22084
+ }
22085
+ if (request.reqCnf) {
22086
+ throw createAuthError(unexpectedError, this.correlationId, "Unexpected preexisting DPoP request key.");
22087
+ }
22088
+ if (!request.keyId) {
22089
+ request.keyId =
22090
+ await this.tokenBindingKeyManager.provisionTokenBindingKey({
22091
+ tokenBindingKeyType: AuthenticationScheme.DPOP.toLowerCase(),
22092
+ tokenBindingKeyAlgorithm: JsonWebTokenAlgorithms.ES256,
22093
+ correlationId: this.correlationId,
22094
+ });
22095
+ }
22096
+ request.reqCnf = this.createDpopBrokerReqCnf(request.keyId);
22097
+ }
22098
+ /**
22099
+ * Creates the confirmation claim for an MSAL-owned broker DPoP key.
22100
+ * @param keyId - Browser-managed DPoP key identifier.
22101
+ * @returns Encoded broker confirmation claim.
22102
+ */
22103
+ createDpopBrokerReqCnf(keyId) {
22104
+ return this.browserCrypto.base64UrlEncode(JSON.stringify({
22105
+ kid: keyId,
22106
+ xms_ksl: PlatformAuthInteractionClient.MSAL_DPOP_KEY_STORAGE_LOCATION,
22107
+ }));
22108
+ }
22109
+ /**
22110
+ * Ensures an owned DPoP key can survive redirect navigation before the
22111
+ * request metadata is persisted for phase two.
22112
+ */
22113
+ async ensureRedirectDpopKeyIsPersisted(request) {
22114
+ if (!this.isDpopBrokerRequest(request) || !request.keyId) {
22115
+ return;
22116
+ }
22117
+ if (!(await isTokenBindingKeyPersistedForRedirect(request, this.tokenBindingKeyManager))) {
22118
+ throw createAuthError(unexpectedError, this.correlationId, "DPoP request key could not be persisted for redirect.");
22119
+ }
22120
+ }
22121
+ /**
22122
+ * Validates and normalizes the DPoP binding outcome returned by the broker.
22123
+ * @param response - Broker response to validate.
22124
+ * @param request - Broker request associated with the response.
22125
+ * @returns The validated DPoP binding level, or `none` for non-DPoP requests.
22126
+ */
22127
+ validateDpopBrokerOutcome(response, request) {
22128
+ const isDpopRequest = this.isDpopBrokerRequest(request);
22129
+ const normalizedResponse = this.normalizeDpopBrokerResponse(response);
22130
+ const normalizedRequestTokenType = request.tokenType
22131
+ ?.trim()
22132
+ .toLowerCase();
22133
+ const bindingPreferenceSent = request.bindingPreferenceSent ??
22134
+ request.preferBinding !== undefined;
22135
+ const hasDpopResponse = this.isDpopBrokerTokenType(normalizedResponse.tokenType) ||
22136
+ normalizedResponse.proof !== undefined ||
22137
+ normalizedResponse.hasBindingAttested;
22138
+ if (!isDpopRequest) {
22139
+ if (hasDpopResponse) {
22140
+ this.throwInvalidDpopResponse("unexpected_response", "Unexpected DPoP broker response.");
22141
+ }
22142
+ return "none";
22143
+ }
22144
+ if (!this.isDpopBrokerTokenType(normalizedResponse.tokenType)) {
22145
+ this.throwInvalidDpopResponse("unknown_token_type", "Unknown DPoP broker response.");
22146
+ }
22147
+ this.validateNormalizedDpopBrokerResponse(normalizedResponse, bindingPreferenceSent);
22148
+ if (normalizedResponse.tokenType ===
22149
+ PlatformAuthTokenType.DPOP_WITH_PROOF.toLowerCase()) {
22150
+ return this.validateDpopBrokerL3Outcome(normalizedRequestTokenType, normalizedResponse);
22151
+ }
22152
+ return this.validateDpopBrokerL1Outcome(request, normalizedRequestTokenType, normalizedResponse, bindingPreferenceSent);
22153
+ }
22154
+ /**
22155
+ * Normalizes the canonical DPoP fields returned under response properties.
22156
+ */
22157
+ normalizeDpopBrokerResponse(response) {
22158
+ const responseProperties = response.properties;
22159
+ const rawTokenType = responseProperties?.token_type;
22160
+ const tokenType = typeof rawTokenType === "string"
22161
+ ? rawTokenType.trim().toLowerCase()
22162
+ : undefined;
22163
+ const rawBindingAttested = responseProperties?.binding_attested;
22164
+ let bindingAttested;
22165
+ if (typeof rawBindingAttested === "string") {
22166
+ const normalizedBindingAttested = rawBindingAttested
22167
+ .trim()
22168
+ .toLowerCase();
22169
+ if (normalizedBindingAttested === "true") {
22170
+ bindingAttested = true;
22171
+ }
22172
+ else if (normalizedBindingAttested === "false") {
22173
+ bindingAttested = false;
22174
+ }
22175
+ }
22176
+ return {
22177
+ tokenType,
22178
+ proof: responseProperties?.DPoP,
22179
+ bindingAttested,
22180
+ hasBindingAttested: rawBindingAttested !== undefined,
22181
+ hasMalformedBindingAttested: rawBindingAttested !== undefined &&
22182
+ bindingAttested === undefined,
22183
+ };
22184
+ }
22185
+ /**
22186
+ * Validates normalized fields shared by L1 and L3 broker DPoP responses.
22187
+ */
22188
+ validateNormalizedDpopBrokerResponse(normalizedResponse, bindingPreferenceSent) {
22189
+ if (normalizedResponse.hasMalformedBindingAttested) {
22190
+ this.throwInvalidDpopResponse("invalid_attestation", "Conflicting DPoP broker response.");
22191
+ }
22192
+ if (bindingPreferenceSent &&
22193
+ normalizedResponse.bindingAttested === undefined) {
22194
+ this.throwInvalidDpopResponse("missing_attestation", "Conflicting DPoP broker response.");
22195
+ }
22196
+ }
22197
+ /**
22198
+ * Validates a broker-returned L3 DPoP proof outcome.
22199
+ */
22200
+ validateDpopBrokerL3Outcome(normalizedRequestTokenType, normalizedResponse) {
22201
+ const dpopWithProofTokenType = PlatformAuthTokenType.DPOP_WITH_PROOF.toLowerCase();
22202
+ if (typeof normalizedResponse.proof !== "string" ||
22203
+ normalizedResponse.proof.trim().length === 0) {
22204
+ this.throwInvalidDpopResponse("missing_proof", "Malformed DPoP broker response.");
22205
+ }
22206
+ if (normalizedResponse.bindingAttested !== true) {
22207
+ this.throwInvalidDpopResponse("invalid_attestation", "Malformed DPoP broker response.");
22208
+ }
22209
+ if (normalizedRequestTokenType !== dpopWithProofTokenType ||
22210
+ normalizedResponse.tokenType !== dpopWithProofTokenType) {
22211
+ this.throwInvalidDpopResponse("conflicting_fields", "Malformed DPoP broker response.");
22212
+ }
22213
+ this.performanceClient.addFields({
22214
+ "ext.brokerDpopOutcome": "l3",
22215
+ "ext.brokerDpopBindingLevel": "L3",
22216
+ }, this.correlationId);
22217
+ return "L3";
22218
+ }
22219
+ /**
22220
+ * Validates an L1 DPoP outcome that MSAL will sign with its local key.
22221
+ */
22222
+ validateDpopBrokerL1Outcome(request, normalizedRequestTokenType, normalizedResponse, bindingPreferenceSent) {
22223
+ if (normalizedResponse.proof !== undefined) {
22224
+ this.throwInvalidDpopResponse("conflicting_fields", "Malformed DPoP broker L1 response.");
22225
+ }
22226
+ if (normalizedRequestTokenType !==
22227
+ PlatformAuthTokenType.DPOP_WITH_PROOF.toLowerCase()) {
22228
+ this.throwInvalidDpopResponse("conflicting_fields", "Malformed DPoP broker L1 response.");
22229
+ }
22230
+ if (normalizedResponse.bindingAttested !== false &&
22231
+ !(!bindingPreferenceSent &&
22232
+ normalizedResponse.bindingAttested === undefined)) {
22233
+ this.throwInvalidDpopResponse("invalid_attestation", "Malformed DPoP broker L1 response.");
22234
+ }
22235
+ if (!request.reqCnf || !request.keyId) {
22236
+ this.throwInvalidDpopResponse("missing_l1_binding", "Malformed DPoP broker L1 response.");
22237
+ }
22238
+ this.performanceClient.addFields({
22239
+ "ext.brokerDpopOutcome": "l1",
22240
+ "ext.brokerDpopBindingLevel": "L1",
22241
+ }, this.correlationId);
22242
+ return "L1";
22243
+ }
22244
+ /**
22245
+ * Emits bounded failure telemetry and rejects an invalid DPoP response.
22246
+ */
22247
+ throwInvalidDpopResponse(failureReason, message) {
22248
+ this.performanceClient.addFields({
22249
+ "ext.brokerDpopOutcome": "invalid_response",
22250
+ "ext.brokerDpopFailureReason": failureReason,
22251
+ }, this.correlationId);
22252
+ throw createAuthError(unexpectedError, this.correlationId, message);
22253
+ }
22254
+ /**
22255
+ * Returns the broker proof or signs an L1 resource proof with the local key.
22256
+ * @param response - Broker response containing the access token and optional proof.
22257
+ * @param request - Broker request containing the proof context and local key.
22258
+ * @returns The resource proof for the broker access token.
22259
+ */
22260
+ async generateDpopProof(response, request) {
22261
+ const brokerProof = response.properties?.DPoP;
22262
+ if (brokerProof !== undefined) {
22263
+ return brokerProof;
22264
+ }
22265
+ const dpopProofGenerator = new DpopProofGenerator(this.browserCrypto, this.tokenBindingKeyManager);
22266
+ return dpopProofGenerator.generateResourceProof({
22267
+ htu: request.resourceRequestUri,
22268
+ htm: request.resourceRequestMethod,
22269
+ accessToken: response.access_token,
22270
+ nonce: request.extraParametersNoCache?.pop_nonce,
22271
+ }, request.keyId, this.correlationId);
22272
+ }
22273
+ /**
22274
+ * Removes a generated DPoP request key and clears its request metadata.
22275
+ * @param request - Broker request whose generated key should be removed.
22276
+ */
22277
+ async resetGeneratedDpopRequestKey(request) {
22278
+ if (!this.isDpopBrokerRequest(request) || !request.keyId) {
22279
+ return;
22280
+ }
22281
+ const cleanupMeasurement = this.performanceClient.startMeasurement(PlatformAuthDpopKeyCleanup, this.correlationId);
22282
+ this.performanceClient.incrementFields({ "ext.brokerDpopKeyCleanupAttemptCount": 1 }, this.correlationId);
22283
+ try {
22284
+ if (request.keyId && !(await this.removeDpopKey(request.keyId))) {
22285
+ throw createAuthError(unexpectedError, this.correlationId, "Failed to remove generated DPoP request key.");
22286
+ }
22287
+ this.performanceClient.addFields({
22288
+ "ext.brokerDpopKeyCleanupOutcome": "succeeded",
22289
+ }, this.correlationId);
22290
+ cleanupMeasurement.end({ success: true });
22291
+ request.keyId = undefined;
22292
+ request.reqCnf = undefined;
22293
+ }
22294
+ catch (error) {
22295
+ this.performanceClient.addFields({
22296
+ "ext.brokerDpopKeyCleanupOutcome": "failed",
22297
+ }, this.correlationId);
22298
+ this.performanceClient.incrementFields({ "ext.brokerDpopKeyCleanupFailureCount": 1 }, this.correlationId);
22299
+ cleanupMeasurement.end({ success: false }, error);
22300
+ throw error;
22301
+ }
22302
+ }
22303
+ /**
22304
+ * Attempts to remove a generated DPoP request key without replacing an
22305
+ * existing operation error with a cleanup failure.
22306
+ * @param request - Broker request whose generated key should be removed.
22307
+ */
22308
+ async resetGeneratedDpopRequestKeyBestEffort(request) {
22309
+ try {
22310
+ await this.resetGeneratedDpopRequestKey(request);
22311
+ }
22312
+ catch {
22313
+ this.logger.error("Failed to remove generated DPoP request key after an operation error.", this.correlationId);
22314
+ this.performanceClient.incrementFields({ removeTokenBindingKeyFailure: 1 }, this.correlationId);
22315
+ request.keyId = undefined;
22316
+ request.reqCnf = undefined;
22317
+ }
22318
+ }
22319
+ /**
22320
+ * Records that a DPoP request is about to be dispatched to the platform broker.
22321
+ * @param request - Broker request about to cross the provider boundary.
22322
+ */
22323
+ addDpopBrokerAttemptTelemetry(request) {
22324
+ if (!this.isDpopBrokerRequest(request)) {
22325
+ return;
22326
+ }
22327
+ this.performanceClient.addFields({
22328
+ "ext.brokerDpopAttempted": 1,
22329
+ }, this.correlationId);
22330
+ }
22331
+ /**
22332
+ * Determines whether a request uses the DPoP broker protocol.
22333
+ * @param request - Broker request to inspect.
22334
+ * @returns Whether the request uses a DPoP token type.
22335
+ */
22336
+ isDpopBrokerRequest(request) {
22337
+ return this.isDpopBrokerTokenType(request.tokenType);
22338
+ }
22339
+ /**
22340
+ * Determines whether a token type represents a DPoP broker request.
22341
+ * @param tokenType - Token type to inspect.
22342
+ * @returns Whether the token type is a supported DPoP broker token type.
22343
+ */
22344
+ isDpopBrokerTokenType(tokenType) {
22345
+ const normalizedTokenType = tokenType?.trim().toLowerCase();
22346
+ return (normalizedTokenType === PlatformAuthTokenType.DPOP_WITH_PROOF ||
22347
+ normalizedTokenType ===
22348
+ AuthenticationScheme.DPOP.toLowerCase());
22349
+ }
22350
+ /**
22351
+ * Removes a DPoP key while reporting cleanup failures.
22352
+ * @param keyId - Identifier of the DPoP key to remove.
22353
+ * @returns Whether the key was removed successfully.
22354
+ */
22355
+ async removeDpopKey(keyId) {
22356
+ try {
22357
+ await this.tokenBindingKeyManager.removeTokenBindingKey(keyId, this.correlationId);
22358
+ return true;
21023
22359
  }
21024
- this.handleExtraBrokerParams(validatedRequest, request.embeddedClientId);
21025
- validatedRequest.extraParameters =
21026
- validatedRequest.extraParameters || {};
21027
- validatedRequest.extraParameters.telemetry =
21028
- PlatformAuthConstants.MATS_TELEMETRY;
21029
- if (request.authenticationScheme === AuthenticationScheme.POP) {
21030
- // add POP request type
21031
- const shrParameters = {
21032
- resourceRequestUri: request.resourceRequestUri,
21033
- resourceRequestMethod: request.resourceRequestMethod,
21034
- shrClaims: request.shrClaims,
21035
- shrNonce: request.shrNonce,
21036
- correlationId: this.correlationId,
21037
- };
21038
- const popTokenGenerator = new PopTokenGenerator(this.browserCrypto, this.tokenBindingKeyManager, this.performanceClient);
21039
- // generate reqCnf if not provided in the request
21040
- let reqCnfData;
21041
- if (!validatedRequest.keyId) {
21042
- const generatedReqCnfData = await invokeAsync(popTokenGenerator.generateCnf.bind(popTokenGenerator), PopTokenGenerateCnf, this.logger, this.performanceClient, this.correlationId)(shrParameters, this.logger);
21043
- reqCnfData = generatedReqCnfData.reqCnfString;
21044
- validatedRequest.keyId = generatedReqCnfData.kid;
21045
- validatedRequest.signPopToken = true;
21046
- }
21047
- else {
21048
- reqCnfData = this.browserCrypto.base64UrlEncode(JSON.stringify({ kid: validatedRequest.keyId }));
21049
- validatedRequest.signPopToken = false;
21050
- }
21051
- // SPAs require whole string to be passed to broker
21052
- validatedRequest.reqCnf = reqCnfData;
22360
+ catch {
22361
+ this.logger.error("Failed to remove unused DPoP key", this.correlationId);
22362
+ return false;
21053
22363
  }
21054
- this.addRequestSKUs(validatedRequest);
21055
- return validatedRequest;
21056
22364
  }
21057
22365
  async getCanonicalAuthority(request) {
21058
22366
  const requestAuthority = request.authority || this.config.auth.authority;
@@ -21092,29 +22400,28 @@
21092
22400
  }
21093
22401
  }
21094
22402
  /**
21095
- * Handles extra broker request parameters
21096
- * @param request {PlatformAuthRequest}
21097
- * @private
22403
+ * Handles extra broker request parameters.
22404
+ * @param request - Platform broker request.
22405
+ * @param embeddedClientId - Embedded application client identifier.
21098
22406
  */
21099
22407
  handleExtraBrokerParams(request, embeddedClientId) {
21100
- const hasExtraBrokerParams = request.extraParameters &&
21101
- request.extraParameters.hasOwnProperty(BROKER_CLIENT_ID) &&
21102
- request.extraParameters.hasOwnProperty(BROKER_REDIRECT_URI) &&
21103
- request.extraParameters.hasOwnProperty(CLIENT_ID);
22408
+ const hasOwnParameter = (parameter) => Object.prototype.hasOwnProperty.call(request.extraParameters, parameter);
22409
+ const hasExtraBrokerParams = hasOwnParameter(BROKER_CLIENT_ID) &&
22410
+ hasOwnParameter(BROKER_REDIRECT_URI) &&
22411
+ hasOwnParameter(CLIENT_ID);
21104
22412
  if (!embeddedClientId && !hasExtraBrokerParams) {
21105
22413
  return;
21106
22414
  }
21107
- let child_client_id = "";
21108
- const child_redirect_uri = request.redirectUri;
22415
+ const childRedirectUri = request.redirectUri;
22416
+ const childClientId = embeddedClientId ||
22417
+ request.extraParameters?.[CLIENT_ID] ||
22418
+ "";
21109
22419
  if (embeddedClientId) {
21110
22420
  request.redirectUri = this.config.auth.redirectUri;
21111
- child_client_id = embeddedClientId;
21112
22421
  }
21113
22422
  else if (request.extraParameters) {
21114
22423
  request.redirectUri =
21115
22424
  request.extraParameters[BROKER_REDIRECT_URI];
21116
- child_client_id =
21117
- request.extraParameters[CLIENT_ID];
21118
22425
  }
21119
22426
  const {
21120
22427
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -21125,15 +22432,20 @@
21125
22432
  [CLIENT_ID]: _clientId, ...remainingExtraParameters } = request.extraParameters || {};
21126
22433
  request.extraParameters = {
21127
22434
  ...remainingExtraParameters,
21128
- child_client_id,
21129
- child_redirect_uri,
22435
+ child_client_id: childClientId,
22436
+ child_redirect_uri: childRedirectUri,
21130
22437
  };
21131
22438
  this.performanceClient?.addFields({
21132
- embeddedClientId: child_client_id,
21133
- embeddedRedirectUri: child_redirect_uri,
22439
+ embeddedClientId: childClientId,
22440
+ embeddedRedirectUri: childRedirectUri,
21134
22441
  }, this.correlationId);
21135
22442
  }
21136
- }
22443
+ }
22444
+ /**
22445
+ * Storage location reported for MSAL-owned browser DPoP keys in reqCnf.
22446
+ * This does not constrain the binding selected by the platform broker.
22447
+ */
22448
+ PlatformAuthInteractionClient.MSAL_DPOP_KEY_STORAGE_LOCATION = PlatformAuthEnclave.SOFTWARE;
21137
22449
 
21138
22450
  /*
21139
22451
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -21205,7 +22517,16 @@
21205
22517
  * @returns
21206
22518
  */
21207
22519
  async function getStandardParameters(config, authority, request, logger, performanceClient) {
21208
- const parameters = getStandardAuthorizeRequestParameters({ ...config.auth, authority: authority }, request, logger, performanceClient);
22520
+ const parameters = getStandardAuthorizeRequestParameters({ ...config.auth, authority: authority }, {
22521
+ ...request,
22522
+ /*
22523
+ * Computed here rather than per flow so every authorize request
22524
+ * carries it — GET, POST and EAR, interactive and silent alike.
22525
+ * A request may assert it instead when the topology, rather than
22526
+ * the current window, is what makes the popup unreachable.
22527
+ */
22528
+ popupOriginCheckDone: request.popupOriginCheckDone ?? computePocd(config) === 1,
22529
+ }, logger, performanceClient);
21209
22530
  addLibraryInfo(parameters, {
21210
22531
  sku: BrowserConstants.MSAL_SKU,
21211
22532
  version: version,
@@ -21230,6 +22551,7 @@
21230
22551
  }
21231
22552
  }
21232
22553
  if (request.authenticationScheme === AuthenticationScheme.DPOP &&
22554
+ !request.platformBroker &&
21233
22555
  request.dpopJkt) {
21234
22556
  parameters.set(DPOP_JKT, request.dpopJkt);
21235
22557
  }
@@ -21259,6 +22581,15 @@
21259
22581
  });
21260
22582
  return getAuthorizeUrl(authority, parameters);
21261
22583
  }
22584
+ function getAuthorizeFormAction(authority, request, parameters) {
22585
+ const queryParams = new Map();
22586
+ addExtraParameters(queryParams, request.extraQueryParameters || {});
22587
+ if (parameters.has(POPUP_ORIGIN_CHECK_DONE)) {
22588
+ queryParams.delete(POPUP_ORIGIN_CHECK_DONE);
22589
+ }
22590
+ addCorrelationId(queryParams, request.correlationId);
22591
+ return getAuthorizeUrl(authority, queryParams);
22592
+ }
21262
22593
  /**
21263
22594
  * Builds the action URL + POST-body fields for the EAR /authorize form.
21264
22595
  */
@@ -21274,11 +22605,7 @@
21274
22605
  addExtraParameters(parameters, {
21275
22606
  ...request.extraParameters,
21276
22607
  });
21277
- const queryParams = new Map();
21278
- addExtraParameters(queryParams, request.extraQueryParameters || {});
21279
- // Add correlationId to query params so gateway can propagate it to IDPs
21280
- addCorrelationId(queryParams, request.correlationId);
21281
- const action = getAuthorizeUrl(authority, queryParams);
22608
+ const action = getAuthorizeFormAction(authority, request, parameters);
21282
22609
  return { action, fields: Object.fromEntries(parameters) };
21283
22610
  }
21284
22611
  /**
@@ -21299,12 +22626,7 @@
21299
22626
  addExtraParameters(parameters, {
21300
22627
  ...request.extraParameters,
21301
22628
  });
21302
- // Add extraQueryParameters to be appended to request URL
21303
- const queryParams = new Map();
21304
- addExtraParameters(queryParams, request.extraQueryParameters || {});
21305
- // Add correlationId to query params so gateway can propagate it to IDPs
21306
- addCorrelationId(queryParams, request.correlationId);
21307
- const action = getAuthorizeUrl(authority, queryParams);
22629
+ const action = getAuthorizeFormAction(authority, request, parameters);
21308
22630
  return { action, fields: Object.fromEntries(parameters) };
21309
22631
  }
21310
22632
  /**
@@ -21353,19 +22675,25 @@
21353
22675
  * @param nativeMessageHandler
21354
22676
  * @returns
21355
22677
  */
21356
- async function handleResponsePlatformBroker(request, accountId, apiId, config, browserStorage, nativeStorage, eventHandler, logger, performanceClient, platformAuthProvider) {
22678
+ async function handleResponsePlatformBroker(request, accountId, apiId, config, browserStorage, nativeStorage, eventHandler, logger, performanceClient, platformAuthProvider, tokenBindingKeyManager = new TokenBindingKeyManager(logger, performanceClient)) {
21357
22679
  logger.verbose("Account id found, calling WAM for token", request.correlationId);
21358
22680
  if (!platformAuthProvider) {
21359
22681
  throw createBrowserAuthError(nativeConnectionNotEstablished, request.correlationId);
21360
22682
  }
21361
22683
  const browserCrypto = new CryptoOps(logger, performanceClient);
21362
- const nativeInteractionClient = new PlatformAuthInteractionClient(config, browserStorage, browserCrypto, logger, eventHandler, config.system.navigationClient, apiId, performanceClient, platformAuthProvider, accountId, nativeStorage, request.correlationId);
22684
+ const nativeInteractionClient = new PlatformAuthInteractionClient(config, browserStorage, browserCrypto, logger, eventHandler, config.system.navigationClient, apiId, performanceClient, platformAuthProvider, accountId, nativeStorage, request.correlationId, tokenBindingKeyManager);
21363
22685
  const { userRequestState } = parseRequestState(browserCrypto.base64Decode, request.state, request.correlationId);
21364
- return invokeAsync(nativeInteractionClient.acquireToken.bind(nativeInteractionClient), NativeInteractionClientAcquireToken, logger, performanceClient, request.correlationId)({
21365
- ...request,
21366
- state: userRequestState,
21367
- prompt: undefined, // Server should handle the prompt, ideally native broker can do this part silently
21368
- });
22686
+ try {
22687
+ return await invokeAsync(nativeInteractionClient.acquireToken.bind(nativeInteractionClient), NativeInteractionClientAcquireToken, logger, performanceClient, request.correlationId)({
22688
+ ...request,
22689
+ state: userRequestState,
22690
+ prompt: undefined, // Server should handle the prompt, ideally native broker can do this part silently
22691
+ });
22692
+ }
22693
+ catch (e) {
22694
+ await removeTokenBindingKeyOnFailure(request, tokenBindingKeyManager, logger, performanceClient);
22695
+ throw e;
22696
+ }
21369
22697
  }
21370
22698
  /**
21371
22699
  * Response handler when server returns code on the /authorize request
@@ -21378,13 +22706,13 @@
21378
22706
  * @param performanceClient
21379
22707
  * @returns
21380
22708
  */
21381
- async function handleResponseCode(request, response, codeVerifier, apiId, config, authClient, browserStorage, nativeStorage, eventHandler, logger, performanceClient, platformAuthProvider) {
22709
+ async function handleResponseCode(request, response, codeVerifier, apiId, config, authClient, browserStorage, nativeStorage, eventHandler, logger, performanceClient, platformAuthProvider, tokenBindingKeyManager = new TokenBindingKeyManager(logger, performanceClient)) {
21382
22710
  // Remove throttle if it exists
21383
22711
  ThrottlingUtils.removeThrottle(browserStorage, config.auth.clientId, request);
21384
22712
  // Instrument clientdata telemetry fields from the authorize response
21385
22713
  instrumentClientData(response, request.correlationId, performanceClient);
21386
22714
  if (response.accountId) {
21387
- return invokeAsync(handleResponsePlatformBroker, HandleResponsePlatformBroker, logger, performanceClient, request.correlationId)(request, response.accountId, apiId, config, browserStorage, nativeStorage, eventHandler, logger, performanceClient, platformAuthProvider);
22715
+ return invokeAsync(handleResponsePlatformBroker, HandleResponsePlatformBroker, logger, performanceClient, request.correlationId)(request, response.accountId, apiId, config, browserStorage, nativeStorage, eventHandler, logger, performanceClient, platformAuthProvider, tokenBindingKeyManager);
21388
22716
  }
21389
22717
  const authCodeRequest = {
21390
22718
  ...request,
@@ -21412,7 +22740,7 @@
21412
22740
  * @param nativeMessageHandler
21413
22741
  * @returns
21414
22742
  */
21415
- async function handleResponseEAR(request, response, apiId, config, authority, browserStorage, nativeStorage, eventHandler, logger, performanceClient, platformAuthProvider) {
22743
+ async function handleResponseEAR(request, response, apiId, config, authority, browserStorage, nativeStorage, eventHandler, logger, performanceClient, platformAuthProvider, tokenBindingKeyManager = new TokenBindingKeyManager(logger, performanceClient)) {
21416
22744
  // Remove throttle if it exists
21417
22745
  ThrottlingUtils.removeThrottle(browserStorage, config.auth.clientId, request);
21418
22746
  // Instrument clientdata telemetry fields from the authorize response
@@ -21427,9 +22755,9 @@
21427
22755
  }
21428
22756
  const decryptedData = JSON.parse(await invokeAsync(decryptEarResponse, DecryptEarResponse, logger, performanceClient, request.correlationId)(request.earJwk, response.ear_jwe));
21429
22757
  if (decryptedData.accountId) {
21430
- return invokeAsync(handleResponsePlatformBroker, HandleResponsePlatformBroker, logger, performanceClient, request.correlationId)(request, decryptedData.accountId, apiId, config, browserStorage, nativeStorage, eventHandler, logger, performanceClient, platformAuthProvider);
22758
+ return invokeAsync(handleResponsePlatformBroker, HandleResponsePlatformBroker, logger, performanceClient, request.correlationId)(request, decryptedData.accountId, apiId, config, browserStorage, nativeStorage, eventHandler, logger, performanceClient, platformAuthProvider, tokenBindingKeyManager);
21431
22759
  }
21432
- const responseHandler = new ResponseHandler(config.auth.clientId, browserStorage, new CryptoOps(logger, performanceClient), logger, performanceClient, null, null, new TokenBindingKeyManager(logger, performanceClient));
22760
+ const responseHandler = new ResponseHandler(config.auth.clientId, browserStorage, new CryptoOps(logger, performanceClient), logger, performanceClient, null, null, tokenBindingKeyManager);
21433
22761
  // Validate response. This function throws a server error if an error is returned by the server.
21434
22762
  responseHandler.validateTokenResponse(decryptedData, request.correlationId);
21435
22763
  // Temporary until response handler is refactored to be more flow agnostic.
@@ -21691,7 +23019,7 @@
21691
23019
  */
21692
23020
  // Default timeout for popup windows and iframes in milliseconds
21693
23021
  const DEFAULT_POPUP_TIMEOUT_MS = 60000;
21694
- const DEFAULT_IFRAME_TIMEOUT_MS = 10000;
23022
+ const DEFAULT_IFRAME_TIMEOUT_MS$1 = 10000;
21695
23023
  const DEFAULT_REDIRECT_TIMEOUT_MS = 30000;
21696
23024
  const DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS = 2000;
21697
23025
  /**
@@ -21732,6 +23060,8 @@
21732
23060
  instanceAware: false,
21733
23061
  isMcp: false,
21734
23062
  verifySSO: false,
23063
+ // Legacy polling needs COOP omitted, so it implies asserting pocd=1.
23064
+ originCheck: !userInputSystem?.enableLegacyPolling,
21735
23065
  };
21736
23066
  // Default cache options for browser
21737
23067
  const DEFAULT_CACHE_OPTIONS = {
@@ -21756,7 +23086,7 @@
21756
23086
  : StubbedNetworkModule,
21757
23087
  navigationClient: new NavigationClient(),
21758
23088
  popupBridgeTimeout: userInputSystem?.popupBridgeTimeout || DEFAULT_POPUP_TIMEOUT_MS,
21759
- iframeBridgeTimeout: userInputSystem?.iframeBridgeTimeout || DEFAULT_IFRAME_TIMEOUT_MS,
23089
+ iframeBridgeTimeout: userInputSystem?.iframeBridgeTimeout || DEFAULT_IFRAME_TIMEOUT_MS$1,
21760
23090
  redirectNavigationTimeout: DEFAULT_REDIRECT_TIMEOUT_MS,
21761
23091
  allowRedirectInIframe: false,
21762
23092
  navigatePopups: true,
@@ -21765,6 +23095,7 @@
21765
23095
  DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS,
21766
23096
  protocolMode: ProtocolMode.AAD,
21767
23097
  serverTelemetryEnabled: false,
23098
+ enableLegacyPolling: false,
21768
23099
  };
21769
23100
  const providedSystemOptions = {
21770
23101
  ...DEFAULT_BROWSER_SYSTEM_OPTIONS,
@@ -21782,11 +23113,17 @@
21782
23113
  iframeTimeoutTelemetry: false,
21783
23114
  allowPlatformBrokerWithDOM: false,
21784
23115
  };
23116
+ let logger;
23117
+ const getLogger = () => {
23118
+ if (!logger) {
23119
+ logger = new Logger(providedSystemOptions.loggerOptions, name, version);
23120
+ }
23121
+ return logger;
23122
+ };
21785
23123
  // Throw an error if user has set OIDCOptions without being in OIDC protocol mode
21786
23124
  if (userInputSystem?.protocolMode !== ProtocolMode.OIDC &&
21787
23125
  userInputAuth?.OIDCOptions) {
21788
- const logger = new Logger(providedSystemOptions.loggerOptions, name, version);
21789
- logger.warning(JSON.stringify(createClientConfigurationError(cannotSetOIDCOptions, "")), "");
23126
+ getLogger().warning(JSON.stringify(createClientConfigurationError(cannotSetOIDCOptions, "")), "");
21790
23127
  }
21791
23128
  // Throw an error if user has set allowPlatformBroker to true with OIDC protocol mode
21792
23129
  if (userInputSystem?.protocolMode &&
@@ -21794,6 +23131,24 @@
21794
23131
  providedSystemOptions?.allowPlatformBroker) {
21795
23132
  throw createClientConfigurationError(cannotAllowPlatformBroker, "");
21796
23133
  }
23134
+ /*
23135
+ * The origin check computes 0 in the embedded contexts legacy polling
23136
+ * serves, so re-enabling it there breaks the flow. Honor it, but warn.
23137
+ */
23138
+ if (userInputSystem?.enableLegacyPolling &&
23139
+ userInputAuth?.originCheck === true) {
23140
+ 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.", "");
23141
+ }
23142
+ /*
23143
+ * Opting out is a deliberate risk transfer, not an error — but the app
23144
+ * cannot know at config time that the risky topology is actually present.
23145
+ */
23146
+ if ((userInputAuth?.originCheck ?? DEFAULT_AUTH_OPTIONS.originCheck) ===
23147
+ false &&
23148
+ typeof window !== "undefined" &&
23149
+ !topOpenerIsSameOriginOrAbsent(window)) {
23150
+ 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.", "");
23151
+ }
21797
23152
  const overlayedConfig = {
21798
23153
  auth: {
21799
23154
  ...DEFAULT_AUTH_OPTIONS,
@@ -21849,6 +23204,7 @@
21849
23204
  const extensionRequest = { ...request };
21850
23205
  delete extensionRequest.resourceRequestMethod;
21851
23206
  delete extensionRequest.resourceRequestUri;
23207
+ delete extensionRequest.bindingPreferenceSent;
21852
23208
  const messageBody = {
21853
23209
  method: NativeExtensionMethod.GetToken,
21854
23210
  request: extensionRequest,
@@ -21860,8 +23216,9 @@
21860
23216
  body: messageBody,
21861
23217
  };
21862
23218
  this.logger.trace(`'${this.platformAuthType}' - Sending request to browser extension`, correlationId);
21863
- this.logger.tracePii(`'${this.platformAuthType}' - Sending request to browser extension: '${JSON.stringify(req)}'`, correlationId);
21864
23219
  this.messageChannel.port1.postMessage(req);
23220
+ request.bindingPreferenceSent =
23221
+ extensionRequest.preferBinding !== undefined;
21865
23222
  const response = await new Promise((resolve, reject) => {
21866
23223
  this.resolvers.set(req.responseId, {
21867
23224
  resolve,
@@ -22058,13 +23415,11 @@
22058
23415
  try {
22059
23416
  const response = request.body.response;
22060
23417
  this.logger.trace(`'${this.platformAuthType}' - Received response from browser extension`, correlationId);
22061
- this.logger.tracePii(`'${this.platformAuthType}' - Received response from browser extension: '${JSON.stringify(response)}'`, correlationId);
22062
23418
  if (response.status !== "Success") {
22063
23419
  resolver.reject(createNativeAuthError(response.code, correlationId, response.description, response.ext));
22064
23420
  }
22065
23421
  else if (response.result) {
22066
- if (response.result["code"] &&
22067
- response.result["description"]) {
23422
+ if (response.result["code"]) {
22068
23423
  resolver.reject(createNativeAuthError(response.result["code"], correlationId, response.result["description"], response.result["ext"]));
22069
23424
  }
22070
23425
  else {
@@ -22145,11 +23500,12 @@
22145
23500
  Object.prototype.hasOwnProperty.call(response, "account") &&
22146
23501
  Object.prototype.hasOwnProperty.call(response, "scope") &&
22147
23502
  Object.prototype.hasOwnProperty.call(response, "expires_in")) {
23503
+ const validatedResponse = response;
22148
23504
  validationMeasurement.end({
22149
23505
  success: true,
22150
23506
  platformAuthProviderType: this.platformAuthType,
22151
23507
  });
22152
- return response;
23508
+ return validatedResponse;
22153
23509
  }
22154
23510
  else {
22155
23511
  const error = createAuthError(unexpectedError, responseCorrelationId, "Response missing expected properties.");
@@ -22191,6 +23547,7 @@
22191
23547
  * Copyright (c) Microsoft Corporation. All rights reserved.
22192
23548
  * Licensed under the MIT License.
22193
23549
  */
23550
+ const PLATFORM_AUTH_DOM_DPOP_NOT_SUPPORTED = "platform_auth_dom_dpop_not_supported";
22194
23551
  class PlatformAuthDOMHandler {
22195
23552
  constructor(logger, performanceClient, correlationId) {
22196
23553
  this.logger = logger;
@@ -22270,6 +23627,10 @@
22270
23627
  });
22271
23628
  this.logger.trace(`'${this.platformAuthType}' - Sending request to browser DOM API`, correlationId);
22272
23629
  try {
23630
+ if (request.tokenType?.trim().toLowerCase() ===
23631
+ PlatformAuthTokenType.DPOP_WITH_PROOF) {
23632
+ throw createBrowserAuthError(PLATFORM_AUTH_DOM_DPOP_NOT_SUPPORTED, correlationId);
23633
+ }
22273
23634
  const platformDOMRequest = invoke(this.initializePlatformDOMRequest.bind(this), PlatformAuthDOMInitializeRequest, this.logger, this.performanceClient, correlationId)(request);
22274
23635
  const response =
22275
23636
  // @ts-ignore
@@ -22296,6 +23657,7 @@
22296
23657
  this.logger.trace(`'${this.platformAuthType}' - initializeNativeDOMRequest called`, requestCorrelationId);
22297
23658
  delete remainingProperties.resourceRequestMethod;
22298
23659
  delete remainingProperties.resourceRequestUri;
23660
+ delete remainingProperties.bindingPreferenceSent;
22299
23661
  const validExtraParameters = this.getDOMExtraParams(remainingProperties, requestCorrelationId);
22300
23662
  const platformDOMRequest = {
22301
23663
  accountId: accountId,
@@ -22506,7 +23868,9 @@
22506
23868
  logger.trace("isPlatformAuthAllowed called", correlationId);
22507
23869
  const schemeSupported = !authenticationScheme ||
22508
23870
  authenticationScheme === AuthenticationScheme.BEARER ||
22509
- authenticationScheme === AuthenticationScheme.POP;
23871
+ authenticationScheme === AuthenticationScheme.POP ||
23872
+ (authenticationScheme === AuthenticationScheme.DPOP &&
23873
+ !(platformAuthProvider instanceof PlatformAuthDOMHandler));
22510
23874
  const fields = {
22511
23875
  allowPlatformBroker: config.system.allowPlatformBroker,
22512
23876
  ...(config.system.allowPlatformBroker && {
@@ -22602,6 +23966,9 @@
22602
23966
  popupWindowAttributes: logoutRequest?.popupWindowAttributes || {},
22603
23967
  popupWindowParent: logoutRequest?.popupWindowParent ?? window,
22604
23968
  };
23969
+ validLogoutRequest.popupOriginCheckDone =
23970
+ this.getPopupOriginCheckDone(popupParams.popupWindowParent) ??
23971
+ validLogoutRequest.popupOriginCheckDone;
22605
23972
  const authority = logoutRequest && logoutRequest.authority;
22606
23973
  const mainWindowRedirectUri = logoutRequest && logoutRequest.mainWindowRedirectUri;
22607
23974
  // navigatePopups flag set to false. Acquires token without first opening popup. Popup will be opened later asynchronously.
@@ -22666,6 +24033,7 @@
22666
24033
  ...request,
22667
24034
  codeChallenge: pkce.challenge,
22668
24035
  ...tokenBindingParams,
24036
+ popupOriginCheckDone: this.getPopupOriginCheckDone(popupParams.popupWindowParent),
22669
24037
  };
22670
24038
  try {
22671
24039
  // Initialize the client
@@ -22699,12 +24067,13 @@
22699
24067
  // Wait for the redirect bridge response
22700
24068
  const responseString = await this.waitForPopupResponse(request, popupWindow, popupParams.popupWindowParent);
22701
24069
  const serverParams = invoke(deserializeResponse, DeserializeResponse, this.logger, this.performanceClient, this.correlationId)(responseString, this.config.auth.OIDCOptions.responseMode, this.logger, this.correlationId);
22702
- return await invokeAsync(handleResponseCode, HandleResponseCode, this.logger, this.performanceClient, correlationId)(popupRequest, serverParams, pkce.verifier, ApiId.acquireTokenPopup, this.config, authClient, this.browserStorage, this.nativeStorage, this.eventHandler, this.logger, this.performanceClient, this.platformAuthProvider);
24070
+ return await invokeAsync(handleResponseCode, HandleResponseCode, this.logger, this.performanceClient, correlationId)(popupRequest, serverParams, pkce.verifier, ApiId.acquireTokenPopup, this.config, authClient, this.browserStorage, this.nativeStorage, this.eventHandler, this.logger, this.performanceClient, this.platformAuthProvider, this.tokenBindingKeyManager);
22703
24071
  }
22704
24072
  }
22705
24073
  catch (e) {
22706
24074
  // Close the synchronous popup if an error is thrown before the window unload event is registered
22707
24075
  popupParams.popup?.close();
24076
+ await removeTokenBindingKeyOnFailure(popupRequest, this.tokenBindingKeyManager, this.logger, this.performanceClient);
22708
24077
  if (e instanceof AuthError) {
22709
24078
  e.correlationId = this.correlationId;
22710
24079
  serverTelemetryManager.cacheFailedRequest(e);
@@ -22729,24 +24098,31 @@
22729
24098
  earJwk: earJwk,
22730
24099
  codeChallenge: pkce.challenge,
22731
24100
  ...tokenBindingParams,
24101
+ popupOriginCheckDone: this.getPopupOriginCheckDone(popupParams.popupWindowParent),
22732
24102
  };
22733
- const popupWindow = await this.openPostFormPopup(popupRequest, discoveredAuthority, popupParams, correlationId, true);
22734
- // Monitor the popup for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.
22735
- const responseString = await invokeAsync(this.waitForPopupResponse.bind(this), SilentHandlerMonitorIframeForHash, this.logger, this.performanceClient, correlationId)(popupRequest, popupWindow, popupParams.popupWindowParent);
22736
- const serverParams = invoke(deserializeResponse, DeserializeResponse, this.logger, this.performanceClient, this.correlationId)(responseString, this.config.auth.OIDCOptions.responseMode, this.logger, this.correlationId);
22737
- if (!serverParams.ear_jwe && serverParams.code) {
22738
- const authClient = await invokeAsync(this.createAuthCodeClient.bind(this), StandardInteractionClientCreateAuthCodeClient, this.logger, this.performanceClient, correlationId)({
22739
- serverTelemetryManager: initializeServerTelemetryManager(ApiId.acquireTokenPopup, this.config.auth.clientId, correlationId, this.browserStorage, this.logger, undefined, this.config.system.serverTelemetryEnabled),
22740
- requestAuthority: request.authority,
22741
- requestAzureCloudOptions: request.azureCloudOptions,
22742
- requestExtraQueryParameters: request.extraQueryParameters,
22743
- account: request.account,
22744
- authority: discoveredAuthority,
22745
- });
22746
- return invokeAsync(handleResponseCode, HandleResponseCode, this.logger, this.performanceClient, correlationId)(popupRequest, serverParams, pkce.verifier, ApiId.acquireTokenPopup, this.config, authClient, this.browserStorage, this.nativeStorage, this.eventHandler, this.logger, this.performanceClient, this.platformAuthProvider);
24103
+ try {
24104
+ const popupWindow = await this.openPostFormPopup(popupRequest, discoveredAuthority, popupParams, correlationId, true);
24105
+ // Monitor the popup for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.
24106
+ const responseString = await invokeAsync(this.waitForPopupResponse.bind(this), SilentHandlerMonitorIframeForHash, this.logger, this.performanceClient, correlationId)(popupRequest, popupWindow, popupParams.popupWindowParent);
24107
+ const serverParams = invoke(deserializeResponse, DeserializeResponse, this.logger, this.performanceClient, this.correlationId)(responseString, this.config.auth.OIDCOptions.responseMode, this.logger, this.correlationId);
24108
+ if (!serverParams.ear_jwe && serverParams.code) {
24109
+ const authClient = await invokeAsync(this.createAuthCodeClient.bind(this), StandardInteractionClientCreateAuthCodeClient, this.logger, this.performanceClient, correlationId)({
24110
+ serverTelemetryManager: initializeServerTelemetryManager(ApiId.acquireTokenPopup, this.config.auth.clientId, correlationId, this.browserStorage, this.logger, undefined, this.config.system.serverTelemetryEnabled),
24111
+ requestAuthority: request.authority,
24112
+ requestAzureCloudOptions: request.azureCloudOptions,
24113
+ requestExtraQueryParameters: request.extraQueryParameters,
24114
+ account: request.account,
24115
+ authority: discoveredAuthority,
24116
+ });
24117
+ return await invokeAsync(handleResponseCode, HandleResponseCode, this.logger, this.performanceClient, correlationId)(popupRequest, serverParams, pkce.verifier, ApiId.acquireTokenPopup, this.config, authClient, this.browserStorage, this.nativeStorage, this.eventHandler, this.logger, this.performanceClient, this.platformAuthProvider, this.tokenBindingKeyManager);
24118
+ }
24119
+ else {
24120
+ return await invokeAsync(handleResponseEAR, HandleResponseEar, this.logger, this.performanceClient, correlationId)(popupRequest, serverParams, ApiId.acquireTokenPopup, this.config, discoveredAuthority, this.browserStorage, this.nativeStorage, this.eventHandler, this.logger, this.performanceClient, this.platformAuthProvider, this.tokenBindingKeyManager);
24121
+ }
22747
24122
  }
22748
- else {
22749
- return invokeAsync(handleResponseEAR, HandleResponseEar, this.logger, this.performanceClient, correlationId)(popupRequest, serverParams, ApiId.acquireTokenPopup, this.config, discoveredAuthority, this.browserStorage, this.nativeStorage, this.eventHandler, this.logger, this.performanceClient, this.platformAuthProvider);
24123
+ catch (e) {
24124
+ await removeTokenBindingKeyOnFailure(popupRequest, this.tokenBindingKeyManager, this.logger, this.performanceClient);
24125
+ throw e;
22750
24126
  }
22751
24127
  }
22752
24128
  async executeCodeFlowWithPost(request, popupParams, authClient, pkceVerifier) {
@@ -22757,7 +24133,7 @@
22757
24133
  // Monitor the popup for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.
22758
24134
  const responseString = await invokeAsync(this.waitForPopupResponse.bind(this), SilentHandlerMonitorIframeForHash, this.logger, this.performanceClient, correlationId)(request, popupWindow, popupParams.popupWindowParent);
22759
24135
  const serverParams = invoke(deserializeResponse, DeserializeResponse, this.logger, this.performanceClient, this.correlationId)(responseString, this.config.auth.OIDCOptions.responseMode, this.logger, this.correlationId);
22760
- return invokeAsync(handleResponseCode, HandleResponseCode, this.logger, this.performanceClient, correlationId)(request, serverParams, pkceVerifier, ApiId.acquireTokenPopup, this.config, authClient, this.browserStorage, this.nativeStorage, this.eventHandler, this.logger, this.performanceClient, this.platformAuthProvider);
24136
+ return invokeAsync(handleResponseCode, HandleResponseCode, this.logger, this.performanceClient, correlationId)(request, serverParams, pkceVerifier, ApiId.acquireTokenPopup, this.config, authClient, this.browserStorage, this.nativeStorage, this.eventHandler, this.logger, this.performanceClient, this.platformAuthProvider, this.tokenBindingKeyManager);
22761
24137
  }
22762
24138
  /**
22763
24139
  *
@@ -23001,6 +24377,27 @@
23001
24377
  getRelayStateId(state, correlationId) {
23002
24378
  return parseRequestState(base64Decode, state, correlationId).libraryState.id;
23003
24379
  }
24380
+ /**
24381
+ * Asserts `pocd=1` for the relay flow. Direct popups also require the
24382
+ * environment of a delegated opening window to pass the origin check.
24383
+ *
24384
+ * With a relay the IdP window is a grandchild popup, which an untrusted
24385
+ * ancestor cannot reach by name — so the topology satisfies the check by
24386
+ * construction. The current window is framed and would otherwise compute
24387
+ * `0`. Without a delegated parent, the standard app check remains unchanged.
24388
+ *
24389
+ * @param popupWindowParent Window that opens the popup.
24390
+ */
24391
+ getPopupOriginCheckDone(popupWindowParent) {
24392
+ if (this.config.auth.popupRelayUri) {
24393
+ return true;
24394
+ }
24395
+ if (popupWindowParent !== window) {
24396
+ return (computePocd(this.config) === 1 &&
24397
+ computePocd(this.config, popupWindowParent) === 1);
24398
+ }
24399
+ return undefined;
24400
+ }
23004
24401
  /**
23005
24402
  * Opens the interactive popup for a POST-form /authorize request. Shared by
23006
24403
  * the auth-code POST and EAR flows, which are identical apart from the form
@@ -23124,8 +24521,11 @@
23124
24521
  codeChallenge: pkceCodes.challenge,
23125
24522
  ...tokenBindingParams,
23126
24523
  };
23127
- this.browserStorage.cacheAuthorizeRequest(redirectRequest, this.correlationId, pkceCodes.verifier);
23128
24524
  try {
24525
+ if (!(await isTokenBindingKeyPersistedForRedirect(redirectRequest, this.tokenBindingKeyManager))) {
24526
+ throw createBrowserAuthError(cryptoKeyNotFound, this.correlationId);
24527
+ }
24528
+ this.browserStorage.cacheAuthorizeRequest(redirectRequest, this.correlationId, pkceCodes.verifier);
23129
24529
  if (redirectRequest.httpMethod === HttpMethod$1.POST) {
23130
24530
  return await this.executeCodeFlowWithPost(redirectRequest);
23131
24531
  }
@@ -23145,6 +24545,7 @@
23145
24545
  }
23146
24546
  }
23147
24547
  catch (e) {
24548
+ await removeTokenBindingKeyOnFailure(redirectRequest, this.tokenBindingKeyManager, this.logger, this.performanceClient);
23148
24549
  if (e instanceof AuthError) {
23149
24550
  e.correlationId = this.correlationId;
23150
24551
  serverTelemetryManager.cacheFailedRequest(e);
@@ -23169,14 +24570,23 @@
23169
24570
  codeChallenge: pkceCodes.challenge,
23170
24571
  ...tokenBindingParams,
23171
24572
  };
23172
- this.browserStorage.cacheAuthorizeRequest(redirectRequest, this.correlationId, pkceCodes.verifier);
23173
- const form = await getEARForm(document, this.config, discoveredAuthority, redirectRequest, this.logger, this.performanceClient);
23174
- form.submit();
23175
- return new Promise((resolve, reject) => {
23176
- setTimeout(() => {
23177
- reject(createBrowserAuthError(timedOut, "", "failed_to_redirect"));
23178
- }, this.config.system.redirectNavigationTimeout);
23179
- });
24573
+ try {
24574
+ if (!(await isTokenBindingKeyPersistedForRedirect(redirectRequest, this.tokenBindingKeyManager))) {
24575
+ throw createBrowserAuthError(cryptoKeyNotFound, this.correlationId);
24576
+ }
24577
+ this.browserStorage.cacheAuthorizeRequest(redirectRequest, this.correlationId, pkceCodes.verifier);
24578
+ const form = await getEARForm(document, this.config, discoveredAuthority, redirectRequest, this.logger, this.performanceClient);
24579
+ form.submit();
24580
+ return await new Promise((resolve, reject) => {
24581
+ setTimeout(() => {
24582
+ reject(createBrowserAuthError(timedOut, "", "failed_to_redirect"));
24583
+ }, this.config.system.redirectNavigationTimeout);
24584
+ });
24585
+ }
24586
+ catch (e) {
24587
+ await removeTokenBindingKeyOnFailure(redirectRequest, this.tokenBindingKeyManager, this.logger, this.performanceClient);
24588
+ throw e;
24589
+ }
23180
24590
  }
23181
24591
  /**
23182
24592
  * Executes classic Authorization Code flow with a POST request.
@@ -23215,6 +24625,7 @@
23215
24625
  if (!serverParams) {
23216
24626
  // Not a recognized server response hash or hash not associated with a redirect request
23217
24627
  this.logger.info("handleRedirectPromise did not detect a response as a result of a redirect. Cleaning temporary cache.", this.correlationId);
24628
+ await removeTokenBindingKeyOnFailure(request, this.tokenBindingKeyManager, this.logger, this.performanceClient);
23218
24629
  this.browserStorage.resetRequestCache(this.correlationId);
23219
24630
  // Do not instrument "no_server_response" if user clicked back button
23220
24631
  if (getNavigationType() !== "back_forward") {
@@ -23284,6 +24695,7 @@
23284
24695
  return null;
23285
24696
  }
23286
24697
  catch (e) {
24698
+ await removeTokenBindingKeyOnFailure(request, this.tokenBindingKeyManager, this.logger, this.performanceClient);
23287
24699
  if (e instanceof AuthError) {
23288
24700
  e.correlationId = this.correlationId;
23289
24701
  serverTelemetryManager.cacheFailedRequest(e);
@@ -23323,7 +24735,6 @@
23323
24735
  }
23324
24736
  return [null, ""];
23325
24737
  }
23326
- clearHash(window);
23327
24738
  this.logger.verbose("Hash contains known properties, returning response hash", this.correlationId);
23328
24739
  return [response, responseString];
23329
24740
  }
@@ -23351,10 +24762,10 @@
23351
24762
  const { authority, azureCloudOptions, extraQueryParameters, account } = request;
23352
24763
  if (serverParams.ear_jwe) {
23353
24764
  const discoveredAuthority = await invokeAsync(getDiscoveredAuthority, StandardInteractionClientGetDiscoveredAuthority, this.logger, this.performanceClient, request.correlationId)(this.config, this.correlationId, this.performanceClient, this.browserStorage, this.logger, authority, azureCloudOptions, extraQueryParameters, account);
23354
- return invokeAsync(handleResponseEAR, HandleResponseEar, this.logger, this.performanceClient, request.correlationId)(request, serverParams, ApiId.acquireTokenRedirect, this.config, discoveredAuthority, this.browserStorage, this.nativeStorage, this.eventHandler, this.logger, this.performanceClient, this.platformAuthProvider);
24765
+ return invokeAsync(handleResponseEAR, HandleResponseEar, this.logger, this.performanceClient, request.correlationId)(request, serverParams, ApiId.acquireTokenRedirect, this.config, discoveredAuthority, this.browserStorage, this.nativeStorage, this.eventHandler, this.logger, this.performanceClient, this.platformAuthProvider, this.tokenBindingKeyManager);
23355
24766
  }
23356
24767
  const authClient = await invokeAsync(this.createAuthCodeClient.bind(this), StandardInteractionClientCreateAuthCodeClient, this.logger, this.performanceClient, this.correlationId)({ serverTelemetryManager, requestAuthority: request.authority });
23357
- return invokeAsync(handleResponseCode, HandleResponseCode, this.logger, this.performanceClient, request.correlationId)(request, serverParams, codeVerifier, ApiId.acquireTokenRedirect, this.config, authClient, this.browserStorage, this.nativeStorage, this.eventHandler, this.logger, this.performanceClient, this.platformAuthProvider);
24768
+ return invokeAsync(handleResponseCode, HandleResponseCode, this.logger, this.performanceClient, request.correlationId)(request, serverParams, codeVerifier, ApiId.acquireTokenRedirect, this.config, authClient, this.browserStorage, this.nativeStorage, this.eventHandler, this.logger, this.performanceClient, this.platformAuthProvider, this.tokenBindingKeyManager);
23358
24769
  }
23359
24770
  /**
23360
24771
  * Redirects window to given URL.
@@ -23685,10 +25096,10 @@
23685
25096
  account: request.account,
23686
25097
  authority: discoveredAuthority,
23687
25098
  });
23688
- return invokeAsync(handleResponseCode, HandleResponseCode, this.logger, this.performanceClient, correlationId)(silentRequest, serverParams, pkceCodes.verifier, this.apiId, this.config, authClient, this.browserStorage, this.nativeStorage, this.eventHandler, this.logger, this.performanceClient, this.platformAuthProvider);
25099
+ return invokeAsync(handleResponseCode, HandleResponseCode, this.logger, this.performanceClient, correlationId)(silentRequest, serverParams, pkceCodes.verifier, this.apiId, this.config, authClient, this.browserStorage, this.nativeStorage, this.eventHandler, this.logger, this.performanceClient, this.platformAuthProvider, this.tokenBindingKeyManager);
23689
25100
  }
23690
25101
  else {
23691
- return invokeAsync(handleResponseEAR, HandleResponseEar, this.logger, this.performanceClient, correlationId)(silentRequest, serverParams, this.apiId, this.config, discoveredAuthority, this.browserStorage, this.nativeStorage, this.eventHandler, this.logger, this.performanceClient, this.platformAuthProvider);
25102
+ return invokeAsync(handleResponseEAR, HandleResponseEar, this.logger, this.performanceClient, correlationId)(silentRequest, serverParams, this.apiId, this.config, discoveredAuthority, this.browserStorage, this.nativeStorage, this.eventHandler, this.logger, this.performanceClient, this.platformAuthProvider, this.tokenBindingKeyManager);
23692
25103
  }
23693
25104
  }
23694
25105
  /**
@@ -23738,7 +25149,13 @@
23738
25149
  */
23739
25150
  async silentTokenHelper(authClient, request) {
23740
25151
  const { serverParams, pkceCodes, silentRequest } = await this.silentAuthorizeHelper(authClient, request);
23741
- return invokeAsync(handleResponseCode, HandleResponseCode, this.logger, this.performanceClient, request.correlationId)(silentRequest, serverParams, pkceCodes.verifier, this.apiId, this.config, authClient, this.browserStorage, this.nativeStorage, this.eventHandler, this.logger, this.performanceClient, this.platformAuthProvider);
25152
+ try {
25153
+ return await invokeAsync(handleResponseCode, HandleResponseCode, this.logger, this.performanceClient, request.correlationId)(silentRequest, serverParams, pkceCodes.verifier, this.apiId, this.config, authClient, this.browserStorage, this.nativeStorage, this.eventHandler, this.logger, this.performanceClient, this.platformAuthProvider, this.tokenBindingKeyManager);
25154
+ }
25155
+ catch (e) {
25156
+ await removeTokenBindingKeyOnFailure(silentRequest, this.tokenBindingKeyManager, this.logger, this.performanceClient);
25157
+ throw e;
25158
+ }
23742
25159
  }
23743
25160
  /**
23744
25161
  * Shared helper that generates PKCE codes, builds the /authorize URL,
@@ -23755,38 +25172,44 @@
23755
25172
  codeChallenge: pkceCodes.challenge,
23756
25173
  ...tokenBindingParams,
23757
25174
  };
23758
- // Create the iframe, register the response listener, then navigate, so the listener is active before the iframe can respond.
23759
- const iframe = createHiddenIframe();
23760
- const responseType = this.config.auth.OIDCOptions.responseMode;
23761
- // Wait for response from the redirect bridge.
23762
- let responseString;
23763
25175
  try {
23764
- const responsePromise = invokeAsync(this.waitForIframeResponse.bind(this), SilentHandlerMonitorIframeForHash, this.logger, this.performanceClient, correlationId)(iframe, request);
23765
- responsePromise.catch(() => {
23766
- /*
23767
- * If URL creation or navigation below throws before
23768
- * responsePromise is awaited, the listener still rejects on
23769
- * timeout. Swallow it here so it does not surface as an
23770
- * unhandled rejection; the navigation error is propagated
23771
- * instead.
23772
- */
23773
- });
23774
- if (request.httpMethod === HttpMethod$1.POST) {
23775
- await invokeAsync(initiateCodeFlowWithPost, SilentHandlerInitiateAuthRequest, this.logger, this.performanceClient, correlationId)(iframe, this.config, authClient.authority, silentRequest, this.logger, this.performanceClient);
25176
+ // Create the iframe, register the response listener, then navigate, so the listener is active before the iframe can respond.
25177
+ const iframe = createHiddenIframe();
25178
+ const responseType = this.config.auth.OIDCOptions.responseMode;
25179
+ // Wait for response from the redirect bridge.
25180
+ let responseString;
25181
+ try {
25182
+ const responsePromise = invokeAsync(this.waitForIframeResponse.bind(this), SilentHandlerMonitorIframeForHash, this.logger, this.performanceClient, correlationId)(iframe, request);
25183
+ responsePromise.catch(() => {
25184
+ /*
25185
+ * If URL creation or navigation below throws before
25186
+ * responsePromise is awaited, the listener still rejects on
25187
+ * timeout. Swallow it here so it does not surface as an
25188
+ * unhandled rejection; the navigation error is propagated
25189
+ * instead.
25190
+ */
25191
+ });
25192
+ if (request.httpMethod === HttpMethod$1.POST) {
25193
+ await invokeAsync(initiateCodeFlowWithPost, SilentHandlerInitiateAuthRequest, this.logger, this.performanceClient, correlationId)(iframe, this.config, authClient.authority, silentRequest, this.logger, this.performanceClient);
25194
+ }
25195
+ else {
25196
+ // Create authorize request url
25197
+ const navigateUrl = await invokeAsync(getAuthCodeRequestUrl, GetAuthCodeUrl, this.logger, this.performanceClient, correlationId)(this.config, authClient.authority, silentRequest, this.logger, this.performanceClient);
25198
+ // Navigate the iframe to the authorize request url
25199
+ await invokeAsync(initiateCodeRequest, SilentHandlerInitiateAuthRequest, this.logger, this.performanceClient, correlationId)(iframe, navigateUrl, this.logger, correlationId);
25200
+ }
25201
+ responseString = await responsePromise;
23776
25202
  }
23777
- else {
23778
- // Create authorize request url
23779
- const navigateUrl = await invokeAsync(getAuthCodeRequestUrl, GetAuthCodeUrl, this.logger, this.performanceClient, correlationId)(this.config, authClient.authority, silentRequest, this.logger, this.performanceClient);
23780
- // Navigate the iframe to the authorize request url
23781
- await invokeAsync(initiateCodeRequest, SilentHandlerInitiateAuthRequest, this.logger, this.performanceClient, correlationId)(iframe, navigateUrl, this.logger, correlationId);
25203
+ finally {
25204
+ invoke(removeHiddenIframe, RemoveHiddenIframe, this.logger, this.performanceClient, correlationId)(iframe);
23782
25205
  }
23783
- responseString = await responsePromise;
25206
+ const serverParams = invoke(deserializeResponse, DeserializeResponse, this.logger, this.performanceClient, correlationId)(responseString, responseType, this.logger, this.correlationId);
25207
+ return { serverParams, pkceCodes, silentRequest };
23784
25208
  }
23785
- finally {
23786
- invoke(removeHiddenIframe, RemoveHiddenIframe, this.logger, this.performanceClient, correlationId)(iframe);
25209
+ catch (e) {
25210
+ await removeTokenBindingKeyOnFailure(silentRequest, this.tokenBindingKeyManager, this.logger, this.performanceClient);
25211
+ throw e;
23787
25212
  }
23788
- const serverParams = invoke(deserializeResponse, DeserializeResponse, this.logger, this.performanceClient, correlationId)(responseString, responseType, this.logger, this.correlationId);
23789
- return { serverParams, pkceCodes, silentRequest };
23790
25213
  }
23791
25214
  async waitForIframeResponse(iframe, request) {
23792
25215
  if (this.waitForIframeResponseHook) {
@@ -24047,7 +25470,6 @@
24047
25470
  : undefined,
24048
25471
  extraParameters: canonicalizeStringDict(request.extraParameters),
24049
25472
  extraQueryParameters: canonicalizeStringDict(request.extraQueryParameters),
24050
- extraParametersNoCache: canonicalizeStringDict(request.extraParametersNoCache),
24051
25473
  forceRefresh: !!request.forceRefresh,
24052
25474
  cacheLookupPolicy: request.cacheLookupPolicy ?? CacheLookupPolicy.Default,
24053
25475
  });
@@ -24056,8 +25478,12 @@
24056
25478
  * Copies caller-owned mutable inputs before asynchronous broker initialization.
24057
25479
  */
24058
25480
  function snapshotPlatformSilentRequest(request) {
24059
- return {
25481
+ const snapshot = {
24060
25482
  ...request,
25483
+ };
25484
+ delete snapshot.extraParametersNoCache;
25485
+ return {
25486
+ ...snapshot,
24061
25487
  scopes: [...(request.scopes || [])],
24062
25488
  account: { ...request.account },
24063
25489
  azureCloudOptions: request.azureCloudOptions
@@ -24069,9 +25495,6 @@
24069
25495
  extraQueryParameters: request.extraQueryParameters
24070
25496
  ? { ...request.extraQueryParameters }
24071
25497
  : undefined,
24072
- extraParametersNoCache: request.extraParametersNoCache
24073
- ? { ...request.extraParametersNoCache }
24074
- : undefined,
24075
25498
  attributeTokens: request.attributeTokens
24076
25499
  ? [...request.attributeTokens]
24077
25500
  : undefined,
@@ -24282,7 +25705,32 @@
24282
25705
  * @returns
24283
25706
  */
24284
25707
  async handleRedirectPromiseInternal(options) {
24285
- if (!this.browserStorage.isInteractionInProgress(true)) {
25708
+ // Preserve the response for RedirectClient before removing it from the URL.
25709
+ const responseString = options?.hash ||
25710
+ (this.config.auth.OIDCOptions.responseMode ===
25711
+ ResponseMode.QUERY
25712
+ ? window.location.search
25713
+ : window.location.hash);
25714
+ const anyClientInteractionInProgress = this.browserStorage.isInteractionInProgress(false);
25715
+ const currentClientInteraction = this.browserStorage.isInteractionInProgress(true);
25716
+ const isBridgeCallback = isInPopup() ||
25717
+ (isInIframe() &&
25718
+ !this.config.system.allowRedirectInIframe);
25719
+ /*
25720
+ * Clear recognized response fragments for:
25721
+ * - Stale callbacks with no pending interaction.
25722
+ * - This client's login callback, even if request setup or response validation fails.
25723
+ * - This client's logout callback containing state, before the SIGNOUT early return.
25724
+ * Leave another client's callback untouched. clearHash preserves query strings
25725
+ * and application routes, and does nothing when no response fragment is present.
25726
+ * Skip popup and non-redirect iframe callbacks: legacy apps may call HRP
25727
+ * before their redirect bridge reads and broadcasts the response.
25728
+ */
25729
+ if (!isBridgeCallback &&
25730
+ (!anyClientInteractionInProgress || currentClientInteraction)) {
25731
+ clearHash(window);
25732
+ }
25733
+ if (!currentClientInteraction) {
24286
25734
  this.logger.info("handleRedirectPromise called but there is no interaction in progress, returning null.", "");
24287
25735
  return null;
24288
25736
  }
@@ -24290,7 +25738,7 @@
24290
25738
  if (interactionType === INTERACTION_TYPE.SIGNOUT) {
24291
25739
  this.logger.verbose("handleRedirectPromise removing interaction_in_progress flag and returning null after sign-out", "");
24292
25740
  this.browserStorage.setInteractionInProgress(false);
24293
- return Promise.resolve(null);
25741
+ return null;
24294
25742
  }
24295
25743
  const loggedInAccounts = this.getAllAccounts();
24296
25744
  const platformBrokerRequest = this.browserStorage.getCachedNativeRequest();
@@ -24320,7 +25768,9 @@
24320
25768
  rootMeasurement = this.performanceClient.startMeasurement(AcquireTokenRedirect, correlationId);
24321
25769
  this.logger.trace("handleRedirectPromise - acquiring token from web flow", correlationId);
24322
25770
  const redirectClient = this.createRedirectClient(correlationId);
24323
- redirectResponse = invokeAsync(redirectClient.handleRedirectPromise.bind(redirectClient), HandleRedirectPromiseMeasurement, this.logger, this.performanceClient, rootMeasurement.event.correlationId)(standardRequest, codeVerifier, rootMeasurement, options);
25771
+ redirectResponse = invokeAsync(redirectClient.handleRedirectPromise.bind(redirectClient), HandleRedirectPromiseMeasurement, this.logger, this.performanceClient, rootMeasurement.event.correlationId)(standardRequest, codeVerifier, rootMeasurement, options?.hash
25772
+ ? options
25773
+ : { ...options, hash: responseString });
24324
25774
  }
24325
25775
  }
24326
25776
  catch (e) {
@@ -24409,8 +25859,9 @@
24409
25859
  let result;
24410
25860
  const platformAuthProvider = this.platformAuthProvider;
24411
25861
  if (this.canUsePlatformBroker(request) && platformAuthProvider) {
25862
+ const nativeRequest = this.sanitizeNativeBrokerRequest(request, correlationId);
24412
25863
  const nativeClient = new PlatformAuthInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, ApiId.acquireTokenRedirect, this.performanceClient, platformAuthProvider, this.getNativeAccountId(request), this.nativeInternalStorage, correlationId, this.tokenBindingKeyManager);
24413
- result = invokeAsync(nativeClient.acquireTokenRedirect.bind(nativeClient), NativeInteractionClientAcquireTokenRedirect, this.logger, this.performanceClient, correlationId)(request, atrMeasurement).catch((e) => {
25864
+ result = invokeAsync(nativeClient.acquireTokenRedirect.bind(nativeClient), NativeInteractionClientAcquireTokenRedirect, this.logger, this.performanceClient, correlationId)(nativeRequest, atrMeasurement).catch((e) => {
24414
25865
  if (e instanceof NativeAuthError &&
24415
25866
  isFatalNativeAuthError(e)) {
24416
25867
  this.platformAuthProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt platform broker calls
@@ -24468,6 +25919,9 @@
24468
25919
  this.logger.verbose("acquireTokenPopup called", correlationId);
24469
25920
  preflightCheck(this.initialized, atPopupMeasurement, this.config, request);
24470
25921
  this.browserStorage.setInteractionInProgress(true, INTERACTION_TYPE.SIGNIN, request.overrideInteractionInProgress, correlationId);
25922
+ if (request.overrideInteractionInProgress) {
25923
+ cancelPendingPopupPollingResponse(this.logger);
25924
+ }
24471
25925
  }
24472
25926
  catch (e) {
24473
25927
  // Since this function is syncronous we need to reject
@@ -24952,6 +26406,13 @@
24952
26406
  const correlationId = this.getRequestCorrelationId(logoutRequest);
24953
26407
  redirectPreflightCheck(this.initialized, this.config);
24954
26408
  this.browserStorage.setInteractionInProgress(true, INTERACTION_TYPE.SIGNOUT);
26409
+ try {
26410
+ await this.clearNativeCache(logoutRequest?.account, correlationId);
26411
+ }
26412
+ catch (error) {
26413
+ this.browserStorage.setInteractionInProgress(false);
26414
+ throw error;
26415
+ }
24955
26416
  const redirectClient = this.createRedirectClient(correlationId);
24956
26417
  return redirectClient.logout(logoutRequest);
24957
26418
  }
@@ -24965,7 +26426,11 @@
24965
26426
  preflightCheck$1(this.initialized);
24966
26427
  this.browserStorage.setInteractionInProgress(true, INTERACTION_TYPE.SIGNOUT);
24967
26428
  const popupClient = this.createPopupClient(correlationId);
24968
- return popupClient.logout(logoutRequest).finally(() => {
26429
+ const nativeCacheClear = this.clearNativeCache(logoutRequest?.account, correlationId);
26430
+ const popupLogout = popupClient.logout(logoutRequest);
26431
+ return Promise.all([nativeCacheClear, popupLogout])
26432
+ .then(() => undefined)
26433
+ .finally(() => {
24969
26434
  this.browserStorage.setInteractionInProgress(false);
24970
26435
  });
24971
26436
  }
@@ -24984,7 +26449,30 @@
24984
26449
  }
24985
26450
  const correlationId = this.getRequestCorrelationId(logoutRequest);
24986
26451
  const cacheClient = this.createSilentCacheClient(correlationId);
24987
- return cacheClient.logout(logoutRequest);
26452
+ const nativeCacheClear = this.clearNativeCache(logoutRequest?.account, correlationId);
26453
+ const browserCacheClear = cacheClient.logout(logoutRequest);
26454
+ await Promise.all([nativeCacheClear, browserCacheClear]);
26455
+ }
26456
+ async clearNativeCache(account, correlationId) {
26457
+ const homeAccountId = account?.homeAccountId.toLowerCase();
26458
+ const environment = account?.environment.toLowerCase();
26459
+ const accessTokenKeys = this.nativeInternalStorage
26460
+ .getTokenKeys()
26461
+ .accessToken.filter((key) => {
26462
+ if (!account) {
26463
+ return true;
26464
+ }
26465
+ const accessToken = this.nativeInternalStorage.getAccessTokenCredential(key, correlationId);
26466
+ if (!accessToken) {
26467
+ return false;
26468
+ }
26469
+ return (accessToken.homeAccountId.toLowerCase() === homeAccountId &&
26470
+ accessToken.environment.toLowerCase() === environment);
26471
+ });
26472
+ await Promise.all(accessTokenKeys.map((key) => this.nativeInternalStorage.removeAccessTokenAndTokenBindingKey(key, correlationId)));
26473
+ if (!account) {
26474
+ this.nativeInternalStorage.clear(correlationId);
26475
+ }
24988
26476
  }
24989
26477
  // #endregion
24990
26478
  // #region Account APIs
@@ -25066,6 +26554,19 @@
25066
26554
  }
25067
26555
  }
25068
26556
  // #region Helpers
26557
+ /**
26558
+ * Removes internal DPoP key state from application-originated broker requests.
26559
+ */
26560
+ sanitizeNativeBrokerRequest(request, correlationId) {
26561
+ if (!request.dpopJkt) {
26562
+ return request;
26563
+ }
26564
+ this.logger.warning("Ignoring caller-provided dpopJkt for a direct platform broker request.", correlationId);
26565
+ return {
26566
+ ...request,
26567
+ dpopJkt: undefined,
26568
+ };
26569
+ }
25069
26570
  /**
25070
26571
  * Acquire a token from native device (e.g. WAM)
25071
26572
  * @param request
@@ -25085,7 +26586,8 @@
25085
26586
  throw createBrowserAuthError(nativeConnectionNotEstablished, correlationId);
25086
26587
  }
25087
26588
  const nativeClient = new PlatformAuthInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, apiId, this.performanceClient, this.platformAuthProvider, accountId || this.getNativeAccountId(request), this.nativeInternalStorage, correlationId, this.tokenBindingKeyManager);
25088
- return invokeAsync(nativeClient.acquireToken.bind(nativeClient), NativeInteractionClientAcquireToken, this.logger, this.performanceClient, correlationId)(request, cacheLookupPolicy);
26589
+ const nativeRequest = this.sanitizeNativeBrokerRequest(request, correlationId);
26590
+ return invokeAsync(nativeClient.acquireToken.bind(nativeClient), NativeInteractionClientAcquireToken, this.logger, this.performanceClient, correlationId)(nativeRequest, cacheLookupPolicy);
25089
26591
  }
25090
26592
  /**
25091
26593
  * Returns boolean indicating if this request can use the platform broker
@@ -25365,14 +26867,23 @@
25365
26867
  correlationId,
25366
26868
  config: this.config,
25367
26869
  }, this.platformAuthProvider, this.logger, this.performanceClient);
25368
- const inProgressRequest = this.activeSilentTokenRequests.get(preparedRequest.key);
26870
+ const shouldDeduplicate = preparedRequest.request.authenticationScheme !==
26871
+ AuthenticationScheme.DPOP;
26872
+ const inProgressRequest = shouldDeduplicate
26873
+ ? this.activeSilentTokenRequests.get(preparedRequest.key)
26874
+ : undefined;
25369
26875
  if (typeof inProgressRequest === "undefined") {
25370
- this.logger.verbose("acquireTokenSilent called for the first time, storing active request", correlationId);
26876
+ this.logger.verbose(shouldDeduplicate
26877
+ ? "acquireTokenSilent called for the first time, storing active request"
26878
+ : "acquireTokenSilent called for DPoP request, starting an independent operation", correlationId);
25371
26879
  this.performanceClient.addFields({ deduped: false }, correlationId);
25372
26880
  const activeRequest = invokeAsync(this.acquireTokenSilentAsync.bind(this), AcquireTokenSilentAsync, this.logger, this.performanceClient, correlationId)({
25373
26881
  ...preparedRequest.request,
25374
26882
  correlationId,
25375
26883
  }, preparedRequest.account);
26884
+ if (!shouldDeduplicate) {
26885
+ return activeRequest;
26886
+ }
25376
26887
  this.activeSilentTokenRequests.set(preparedRequest.key, activeRequest);
25377
26888
  return activeRequest.finally(() => {
25378
26889
  this.activeSilentTokenRequests.delete(preparedRequest.key);
@@ -25965,6 +27476,17 @@
25965
27476
  cacheClient: this.cacheClient,
25966
27477
  }), undefined, result.continuationState.scenario);
25967
27478
  }
27479
+ if (result.type === FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2) {
27480
+ return new CustomAuthResultV2(new AuthMethodRegistrationRequiredStateV2({
27481
+ correlationId: result.correlationId,
27482
+ logger: this.logger,
27483
+ config: this.customAuthConfig,
27484
+ flowClient: this.flowClientV2,
27485
+ continuationState: result.continuationState,
27486
+ cacheClient: this.cacheClient,
27487
+ methods: result.methods,
27488
+ }), undefined, result.continuationState.scenario);
27489
+ }
25968
27490
  if (result.type === FLOW_CODE_REQUIRED_V2) {
25969
27491
  return new CustomAuthResultV2(new CodeRequiredStateV2({
25970
27492
  correlationId: result.correlationId,
@@ -26566,6 +28088,79 @@
26566
28088
  */
26567
28089
  NestedAppOperatingContext.ID = "NestedAppOperatingContext";
26568
28090
 
28091
+ /*
28092
+ * Copyright (c) Microsoft Corporation. All rights reserved.
28093
+ * Licensed under the MIT License.
28094
+ */
28095
+ const IFRAME_POLL_INTERVAL_MS = 50;
28096
+ const DEFAULT_IFRAME_TIMEOUT_MS = 10000;
28097
+ /**
28098
+ * Monitors an iframe content window until it loads a URL with a known hash, or hits a specified timeout.
28099
+ *
28100
+ * @param iframe - The hidden iframe to monitor.
28101
+ * @param timeout - Maximum time (ms) to wait for navigation before rejecting with
28102
+ * `monitor_window_timeout`.
28103
+ * @param logger - Logger instance.
28104
+ * @param correlationId
28105
+ * @param responseMode - `"query"` or `"fragment"` — determines whether to read
28106
+ * `location.search` or `location.hash`. Any value other than `"query"` is
28107
+ * treated as fragment.
28108
+ */
28109
+ async function monitorIframeForHash(iframe, timeout, logger, correlationId, responseMode) {
28110
+ return new Promise((resolve, reject) => {
28111
+ if (timeout < DEFAULT_IFRAME_TIMEOUT_MS) {
28112
+ logger.warning(`system.iframeBridgeTimeout set to lower (${timeout}ms) than the default (${DEFAULT_IFRAME_TIMEOUT_MS}ms). This may result in timeouts.`, correlationId);
28113
+ }
28114
+ /*
28115
+ * Polling for iframes can be purely timing based,
28116
+ * since we don't need to account for interaction.
28117
+ */
28118
+ const timeoutId = window.setTimeout(() => {
28119
+ window.clearInterval(intervalId);
28120
+ reject(new AuthError(timedOut, correlationId, undefined, "monitor_window_timeout"));
28121
+ }, timeout);
28122
+ const intervalId = window.setInterval(() => {
28123
+ const contentWindow = iframe.contentWindow;
28124
+ if (!contentWindow) {
28125
+ return;
28126
+ }
28127
+ let href = "";
28128
+ try {
28129
+ /*
28130
+ * Will throw if cross origin,
28131
+ * which should be caught and ignored
28132
+ * since we need the interval to keep running while on STS UI.
28133
+ */
28134
+ href = contentWindow.location.href;
28135
+ }
28136
+ catch (e) { }
28137
+ if (!href || href === "about:blank") {
28138
+ return;
28139
+ }
28140
+ const responseString = responseMode === ResponseMode.QUERY
28141
+ ? contentWindow.location.search
28142
+ : contentWindow.location.hash;
28143
+ window.clearTimeout(timeoutId);
28144
+ window.clearInterval(intervalId);
28145
+ resolve(responseString);
28146
+ }, IFRAME_POLL_INTERVAL_MS);
28147
+ }).finally(() => {
28148
+ /*
28149
+ * Strip auth-response params from the iframe URL. The monitor owns the
28150
+ * iframe for the duration of the poll, mirroring cleanPopup in
28151
+ * PopupMonitor.
28152
+ */
28153
+ try {
28154
+ if (iframe.contentWindow) {
28155
+ clearAuthResponseFromUrl(iframe.contentWindow);
28156
+ }
28157
+ }
28158
+ catch {
28159
+ // Iframe may already be navigated away or cross-origin; ignore.
28160
+ }
28161
+ });
28162
+ }
28163
+
26569
28164
  /*
26570
28165
  * Copyright (c) Microsoft Corporation. All rights reserved.
26571
28166
  * Licensed under the MIT License.
@@ -26608,27 +28203,29 @@
26608
28203
  /**
26609
28204
  * Waits for the auth response from a popup window opened by MSAL.
26610
28205
  *
26611
- * The default implementation delegates to MSAL's `BroadcastChannel`-based bridge.
26612
- * Subclasses must return the raw response string (hash/query/fragment), or reject
26613
- * with an `AuthError` on failure.
28206
+ * The default implementation delegates to MSAL's `BroadcastChannel`-based bridge,
28207
+ * or to the v4-style same-origin location poller when
28208
+ * `system.enableLegacyPolling` is set. Subclasses must return the raw response
28209
+ * string (hash/query/fragment), or reject with an `AuthError` on failure.
26614
28210
  *
26615
28211
  * @internal
26616
28212
  * @param request The in-flight authorization or end-session request.
26617
28213
  * @param popupWindow The popup window opened by MSAL.
26618
28214
  * @param popupWindowParent The parent window that opened the popup.
26619
28215
  */
26620
- async waitForPopupResponse(request,
26621
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
26622
- popupWindow,
26623
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
26624
- popupWindowParent) {
28216
+ async waitForPopupResponse(request, popupWindow, popupWindowParent) {
26625
28217
  const controller = this.controller;
26626
- return waitForBridgeResponse(controller.getConfiguration().system.popupBridgeTimeout, controller.getLogger(), request, controller.getPerformanceClient());
28218
+ const config = controller.getConfiguration();
28219
+ if (config.system.enableLegacyPolling) {
28220
+ return waitForPopupPollingResponse(config, controller.getLogger(), controller.getPerformanceClient(), request, popupWindow, popupWindowParent);
28221
+ }
28222
+ return waitForBridgeResponse(config.system.popupBridgeTimeout, controller.getLogger(), request, controller.getPerformanceClient());
26627
28223
  }
26628
28224
  /**
26629
28225
  * Waits for the auth response from a hidden iframe used by MSAL silent flows.
26630
28226
  *
26631
- * The default implementation delegates to MSAL's `BroadcastChannel`-based bridge.
28227
+ * The default implementation delegates to MSAL's `BroadcastChannel`-based bridge,
28228
+ * or to the v4-style location poller when `system.enableLegacyPolling` is set.
26632
28229
  * Subclasses must return the raw response string (hash/query/fragment), or reject
26633
28230
  * with an `AuthError` on failure.
26634
28231
  *
@@ -26636,11 +28233,12 @@
26636
28233
  * @param iframe The hidden iframe MSAL attached to the document.
26637
28234
  * @param request The in-flight authorization request.
26638
28235
  */
26639
- async waitForIframeResponse(
26640
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
26641
- iframe, request) {
28236
+ async waitForIframeResponse(iframe, request) {
26642
28237
  const controller = this.controller;
26643
28238
  const config = controller.getConfiguration();
28239
+ if (config.system.enableLegacyPolling) {
28240
+ return waitForIframePollingResponse(config, controller.getLogger(), controller.getPerformanceClient(), iframe, request);
28241
+ }
26644
28242
  return waitForBridgeResponse(config.system.iframeBridgeTimeout, controller.getLogger(), request, controller.getPerformanceClient(), config.experimental);
26645
28243
  }
26646
28244
  /**
@@ -26873,6 +28471,40 @@
26873
28471
  clearCache(logoutRequest) {
26874
28472
  return this.controller.clearCache(logoutRequest);
26875
28473
  }
28474
+ }
28475
+ /**
28476
+ * Collects a popup auth response using the v4-style same-origin location
28477
+ * poller instead of the `BroadcastChannel` redirect bridge.
28478
+ */
28479
+ async function waitForPopupPollingResponse(config, logger, performanceClient, request, popupWindow, popupWindowParent) {
28480
+ const responseMode = config.auth.OIDCOptions?.responseMode === ResponseMode.QUERY
28481
+ ? ResponseMode.QUERY
28482
+ : ResponseMode.FRAGMENT;
28483
+ performanceClient.addFields({ usesLegacyPolling: true }, request.correlationId);
28484
+ const unloadHandler = () => {
28485
+ try {
28486
+ if (popupWindow && !popupWindow.closed) {
28487
+ popupWindow.close();
28488
+ }
28489
+ }
28490
+ catch {
28491
+ /* ignore */
28492
+ }
28493
+ };
28494
+ popupWindowParent.addEventListener("beforeunload", unloadHandler);
28495
+ return monitorPopupForHash(popupWindow, popupWindowParent, responseMode, logger, unloadHandler, request.correlationId);
28496
+ }
28497
+ /**
28498
+ * Collects a silent-iframe auth response using the v4-style location poller
28499
+ * instead of the `BroadcastChannel` redirect bridge.
28500
+ */
28501
+ async function waitForIframePollingResponse(config, logger, performanceClient, iframe, request) {
28502
+ const responseMode = config.auth.OIDCOptions?.responseMode === ResponseMode.QUERY
28503
+ ? ResponseMode.QUERY
28504
+ : ResponseMode.FRAGMENT;
28505
+ const iframePollTimeout = config.system.iframeBridgeTimeout;
28506
+ performanceClient.addFields({ usesLegacyPolling: true, iframePollTimeout }, request.correlationId);
28507
+ return monitorIframeForHash(iframe, iframePollTimeout, logger, request.correlationId, responseMode);
26876
28508
  }
26877
28509
 
26878
28510
  /*
@@ -27015,10 +28647,12 @@
27015
28647
  exports.AuthMethodRegistrationCompletedState = AuthMethodRegistrationCompletedState;
27016
28648
  exports.AuthMethodRegistrationFailedState = AuthMethodRegistrationFailedState;
27017
28649
  exports.AuthMethodRegistrationRequiredState = AuthMethodRegistrationRequiredState;
28650
+ exports.AuthMethodRegistrationRequiredStateV2 = AuthMethodRegistrationRequiredStateV2;
27018
28651
  exports.AuthMethodRegistrationSubmitChallengeError = AuthMethodRegistrationSubmitChallengeError;
27019
28652
  exports.AuthMethodRegistrationSubmitChallengeResult = AuthMethodRegistrationSubmitChallengeResult;
27020
28653
  exports.AuthMethodSelectionRequiredStateV2 = AuthMethodSelectionRequiredStateV2;
27021
28654
  exports.AuthMethodVerificationRequiredState = AuthMethodVerificationRequiredState;
28655
+ exports.AuthMethodVerificationRequiredStateV2 = AuthMethodVerificationRequiredStateV2;
27022
28656
  exports.CodeRequiredStateV2 = CodeRequiredStateV2;
27023
28657
  exports.CompletedStateV2 = CompletedStateV2;
27024
28658
  exports.CustomAuthAccountData = CustomAuthAccountData;