@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,8 +1,8 @@
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
  'use strict';
4
4
 
5
- /*! @azure/msal-common v16.14.3 2026-10-21 */
5
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
6
6
  /*
7
7
  * Copyright (c) Microsoft Corporation. All rights reserved.
8
8
  * Licensed under the MIT License.
@@ -54,9 +54,15 @@ const EAR_JWK = "ear_jwk";
54
54
  const EAR_JWE_CRYPTO = "ear_jwe_crypto";
55
55
  const RESOURCE = "resource";
56
56
  const CLI_DATA = "clidata";
57
- const ATTRIBUTE_TOKENS = "attribute_tokens";
57
+ const ATTRIBUTE_TOKENS = "attribute_tokens";
58
+ /**
59
+ * Popup-origin-check-done. Signals to the STS that the client verified the
60
+ * popup cannot be reached by an untrusted window, so the
61
+ * Cross-Origin-Opener-Policy response header may be omitted.
62
+ */
63
+ const POPUP_ORIGIN_CHECK_DONE = "pocd";
58
64
 
59
- /*! @azure/msal-common v16.14.3 2026-10-21 */
65
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
60
66
  /*
61
67
  * Copyright (c) Microsoft Corporation. All rights reserved.
62
68
  * Licensed under the MIT License.
@@ -290,7 +296,7 @@ const JsonWebTokenTypes = {
290
296
  // Token renewal offset default in seconds
291
297
  const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
292
298
 
293
- /*! @azure/msal-common v16.14.3 2026-10-21 */
299
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
294
300
  /*
295
301
  * Copyright (c) Microsoft Corporation. All rights reserved.
296
302
  * Licensed under the MIT License.
@@ -319,7 +325,7 @@ function createAuthError(code, correlationId, additionalMessage) {
319
325
  return new AuthError(code, correlationId, additionalMessage || getDefaultErrorMessage$1(code));
320
326
  }
321
327
 
322
- /*! @azure/msal-common v16.14.3 2026-10-21 */
328
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
323
329
 
324
330
  /*
325
331
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -342,7 +348,7 @@ function createClientAuthError(errorCode, correlationId, additionalMessage) {
342
348
  return new ClientAuthError(errorCode, correlationId, additionalMessage);
343
349
  }
344
350
 
345
- /*! @azure/msal-common v16.14.3 2026-10-21 */
351
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
346
352
  /*
347
353
  * Copyright (c) Microsoft Corporation. All rights reserved.
348
354
  * Licensed under the MIT License.
@@ -380,7 +386,7 @@ const methodNotImplemented = "method_not_implemented";
380
386
  const resourceParameterRequired = "resource_parameter_required";
381
387
  const misplacedResourceParam = "misplaced_resource_parameter";
382
388
 
383
- /*! @azure/msal-common v16.14.3 2026-10-21 */
389
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
384
390
 
385
391
  /*
386
392
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -418,7 +424,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
418
424
  };
419
425
  }
420
426
 
421
- /*! @azure/msal-common v16.14.3 2026-10-21 */
427
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
422
428
 
423
429
  /*
424
430
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -484,7 +490,7 @@ function getJWSPayload(authToken, correlationId) {
484
490
  return matches[2];
485
491
  }
486
492
 
487
- /*! @azure/msal-common v16.14.3 2026-10-21 */
493
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
488
494
 
489
495
  /*
490
496
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -572,7 +578,7 @@ function updateAccountTenantProfileData(baseAccountInfo, tenantProfile, idTokenC
572
578
  return updatedAccountInfo;
573
579
  }
574
580
 
575
- /*! @azure/msal-common v16.14.3 2026-10-21 */
581
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
576
582
  /*
577
583
  * Copyright (c) Microsoft Corporation. All rights reserved.
578
584
  * Licensed under the MIT License.
@@ -586,7 +592,7 @@ const AuthorityType = {
586
592
  Ciam: 3,
587
593
  };
588
594
 
589
- /*! @azure/msal-common v16.14.3 2026-10-21 */
595
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
590
596
  /*
591
597
  * Copyright (c) Microsoft Corporation. All rights reserved.
592
598
  * Licensed under the MIT License.
@@ -608,7 +614,7 @@ function getTenantIdFromIdTokenClaims(idTokenClaims) {
608
614
  return null;
609
615
  }
610
616
 
611
- /*! @azure/msal-common v16.14.3 2026-10-21 */
617
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
612
618
  /*
613
619
  * Copyright (c) Microsoft Corporation. All rights reserved.
614
620
  * Licensed under the MIT License.
@@ -632,7 +638,7 @@ const ProtocolMode = {
632
638
  EAR: "EAR",
633
639
  };
634
640
 
635
- /*! @azure/msal-common v16.14.3 2026-10-21 */
641
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
636
642
  /**
637
643
  * Returns the AccountInfo interface for this account.
638
644
  * @internal
@@ -821,7 +827,7 @@ function isAccountEntity(entity) {
821
827
  entity.hasOwnProperty("authorityType"));
822
828
  }
823
829
 
824
- /*! @azure/msal-common v16.14.3 2026-10-21 */
830
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
825
831
  /*
826
832
  * Copyright (c) Microsoft Corporation. All rights reserved.
827
833
  * Licensed under the MIT License.
@@ -831,7 +837,7 @@ function isAccountEntity(entity) {
831
837
  */
832
838
  const unexpectedError = "unexpected_error";
833
839
 
834
- /*! @azure/msal-common v16.14.3 2026-10-21 */
840
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
835
841
 
836
842
  /*
837
843
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -851,7 +857,47 @@ function createClientConfigurationError(errorCode, correlationId) {
851
857
  return new ClientConfigurationError(errorCode, correlationId);
852
858
  }
853
859
 
854
- /*! @azure/msal-common v16.14.3 2026-10-21 */
860
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
861
+ /*
862
+ * Copyright (c) Microsoft Corporation. All rights reserved.
863
+ * Licensed under the MIT License.
864
+ */
865
+ // Track only our normalized copies, never caller-owned mutable inputs.
866
+ const normalizedHeaderRecords = new WeakSet();
867
+ /**
868
+ * Creates a lowercase-keyed snapshot without changing header values or the input.
869
+ * Reuses snapshots produced by this function to avoid repeated normalization.
870
+ * @internal
871
+ */
872
+ function normalizeResponseHeaders(headers) {
873
+ if (normalizedHeaderRecords.has(headers)) {
874
+ return headers;
875
+ }
876
+ const normalized = Object.fromEntries(Object.entries(headers).map(([name, value]) => [
877
+ name.toLowerCase(),
878
+ value,
879
+ ]));
880
+ normalizedHeaderRecords.add(normalized);
881
+ return normalized;
882
+ }
883
+ /**
884
+ * Reads a response header case-insensitively.
885
+ * Normalized snapshots are never scanned, even when a header is missing.
886
+ * @internal
887
+ */
888
+ function getResponseHeader(headers, name) {
889
+ const key = name.toLowerCase();
890
+ if (Object.prototype.hasOwnProperty.call(headers, key)) {
891
+ return headers[key];
892
+ }
893
+ if (normalizedHeaderRecords.has(headers)) {
894
+ return undefined;
895
+ }
896
+ const headerName = Object.keys(headers).find((header) => header.toLowerCase() === key);
897
+ return headerName === undefined ? undefined : headers[headerName];
898
+ }
899
+
900
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
855
901
  /*
856
902
  * Copyright (c) Microsoft Corporation. All rights reserved.
857
903
  * Licensed under the MIT License.
@@ -882,7 +928,7 @@ const invalidDpopHtu = "invalid_dpop_htu";
882
928
  const invalidDpopNonce = "invalid_dpop_nonce";
883
929
  const dpopMissingResourceContext = "dpop_missing_resource_context";
884
930
 
885
- /*! @azure/msal-common v16.14.3 2026-10-21 */
931
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
886
932
  /*
887
933
  * Copyright (c) Microsoft Corporation. All rights reserved.
888
934
  * Licensed under the MIT License.
@@ -894,7 +940,7 @@ function isOpenIdConfigResponse(response) {
894
940
  response.hasOwnProperty("jwks_uri"));
895
941
  }
896
942
 
897
- /*! @azure/msal-common v16.14.3 2026-10-21 */
943
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
898
944
  /*
899
945
  * Copyright (c) Microsoft Corporation. All rights reserved.
900
946
  * Licensed under the MIT License.
@@ -974,7 +1020,7 @@ class StringUtils {
974
1020
  }
975
1021
  }
976
1022
 
977
- /*! @azure/msal-common v16.14.3 2026-10-21 */
1023
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
978
1024
 
979
1025
  /*
980
1026
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1132,7 +1178,7 @@ class UrlString {
1132
1178
  }
1133
1179
  }
1134
1180
 
1135
- /*! @azure/msal-common v16.14.3 2026-10-21 */
1181
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
1136
1182
 
1137
1183
  /*
1138
1184
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1286,7 +1332,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
1286
1332
  return null;
1287
1333
  }
1288
1334
 
1289
- /*! @azure/msal-common v16.14.3 2026-10-21 */
1335
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
1290
1336
  /*
1291
1337
  * Copyright (c) Microsoft Corporation. All rights reserved.
1292
1338
  * Licensed under the MIT License.
@@ -1295,7 +1341,7 @@ const AzureCloudInstance = {
1295
1341
  // AzureCloudInstance is not specified.
1296
1342
  None: "none"};
1297
1343
 
1298
- /*! @azure/msal-common v16.14.3 2026-10-21 */
1344
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
1299
1345
  /*
1300
1346
  * Copyright (c) Microsoft Corporation. All rights reserved.
1301
1347
  * Licensed under the MIT License.
@@ -1305,7 +1351,7 @@ function isCloudInstanceDiscoveryResponse(response) {
1305
1351
  response.hasOwnProperty("metadata"));
1306
1352
  }
1307
1353
 
1308
- /*! @azure/msal-common v16.14.3 2026-10-21 */
1354
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
1309
1355
  /*
1310
1356
  * Copyright (c) Microsoft Corporation. All rights reserved.
1311
1357
  * Licensed under the MIT License.
@@ -1315,7 +1361,7 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
1315
1361
  response.hasOwnProperty("error_description"));
1316
1362
  }
1317
1363
 
1318
- /*! @azure/msal-common v16.14.3 2026-10-21 */
1364
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
1319
1365
  /*
1320
1366
  * Copyright (c) Microsoft Corporation. All rights reserved.
1321
1367
  * Licensed under the MIT License.
@@ -1386,7 +1432,7 @@ const RegionDiscoveryGetCurrentVersion = "regionDiscoveryGetCurrentVersion";
1386
1432
  const CacheManagerGetRefreshToken = "cacheManagerGetRefreshToken";
1387
1433
  const SetUserData = "setUserData";
1388
1434
 
1389
- /*! @azure/msal-common v16.14.3 2026-10-21 */
1435
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
1390
1436
  /*
1391
1437
  * Copyright (c) Microsoft Corporation. All rights reserved.
1392
1438
  * Licensed under the MIT License.
@@ -1479,7 +1525,7 @@ const invokeAsync = (callback, eventName, logger, telemetryClient, correlationId
1479
1525
  };
1480
1526
  };
1481
1527
 
1482
- /*! @azure/msal-common v16.14.3 2026-10-21 */
1528
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
1483
1529
 
1484
1530
  /*
1485
1531
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1590,7 +1636,7 @@ RegionDiscovery.IMDS_OPTIONS = {
1590
1636
  },
1591
1637
  };
1592
1638
 
1593
- /*! @azure/msal-common v16.14.3 2026-10-21 */
1639
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
1594
1640
  /*
1595
1641
  * Copyright (c) Microsoft Corporation. All rights reserved.
1596
1642
  * Licensed under the MIT License.
@@ -1655,7 +1701,7 @@ function wasClockTurnedBack(cachedAt) {
1655
1701
  return cachedAtSec > nowSeconds();
1656
1702
  }
1657
1703
 
1658
- /*! @azure/msal-common v16.14.3 2026-10-21 */
1704
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
1659
1705
 
1660
1706
  /*
1661
1707
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1942,7 +1988,7 @@ function serializeAttributeTokens(attributeTokens) {
1942
1988
  return [...attributeTokens].sort().join(" ");
1943
1989
  }
1944
1990
 
1945
- /*! @azure/msal-common v16.14.3 2026-10-21 */
1991
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
1946
1992
 
1947
1993
  /*
1948
1994
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2910,7 +2956,7 @@ function buildStaticAuthorityOptions(authOptions) {
2910
2956
  };
2911
2957
  }
2912
2958
 
2913
- /*! @azure/msal-common v16.14.3 2026-10-21 */
2959
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
2914
2960
 
2915
2961
  /*
2916
2962
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2944,7 +2990,7 @@ async function createDiscoveredInstance(authorityUri, networkClient, cacheManage
2944
2990
  }
2945
2991
  }
2946
2992
 
2947
- /*! @azure/msal-common v16.14.3 2026-10-21 */
2993
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
2948
2994
 
2949
2995
  /*
2950
2996
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3140,7 +3186,7 @@ class ScopeSet {
3140
3186
  }
3141
3187
  }
3142
3188
 
3143
- /*! @azure/msal-common v16.14.3 2026-10-21 */
3189
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
3144
3190
 
3145
3191
  /*
3146
3192
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3421,6 +3467,20 @@ function addInstanceAware(parameters) {
3421
3467
  parameters.set(INSTANCE_AWARE, "true");
3422
3468
  }
3423
3469
  }
3470
+ /**
3471
+ * Adds `pocd=1`, telling the STS that the client verified the popup driving
3472
+ * this request cannot be reached by an untrusted window, so the
3473
+ * Cross-Origin-Opener-Policy response header may be omitted.
3474
+ *
3475
+ * Only ever added when the check passed — a negative result is signalled by
3476
+ * omitting the parameter, which keeps the STS default (apply COOP) and stays
3477
+ * compatible with library versions that never send it.
3478
+ */
3479
+ function addPopupOriginCheckDone(parameters) {
3480
+ if (!parameters.has(POPUP_ORIGIN_CHECK_DONE)) {
3481
+ parameters.set(POPUP_ORIGIN_CHECK_DONE, "1");
3482
+ }
3483
+ }
3424
3484
  /**
3425
3485
  * Add extraParameters
3426
3486
  * @param extraParams - String dictionary containing extra parameters to be added.
@@ -3626,7 +3686,7 @@ function addAttributeTokens(parameters, attributeTokens) {
3626
3686
  }
3627
3687
  }
3628
3688
 
3629
- /*! @azure/msal-common v16.14.3 2026-10-21 */
3689
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
3630
3690
 
3631
3691
  /*
3632
3692
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3647,7 +3707,8 @@ function stripLeadingHashOrQuery(responseString) {
3647
3707
  return responseString;
3648
3708
  }
3649
3709
  /**
3650
- * Returns URL hash as server auth code response object.
3710
+ * Returns flat fragment or query parameters as an authorization response.
3711
+ * Application routes and unrecognized responses return null.
3651
3712
  */
3652
3713
  function getDeserializedResponse(responseString) {
3653
3714
  // Check if given hash is empty
@@ -3657,7 +3718,15 @@ function getDeserializedResponse(responseString) {
3657
3718
  try {
3658
3719
  // Strip the # or ? symbol if present
3659
3720
  const normalizedResponse = stripLeadingHashOrQuery(responseString);
3660
- // If # symbol was not present, above will return empty string, so give original hash value
3721
+ /*
3722
+ * Require a flat parameter name, not an application route.
3723
+ * Reject routes like #/dashboard?tab=orders&code=... and
3724
+ * #/dashboard/orders&state=..., where ?, /, or # appears before
3725
+ * the first = or &. These characters are allowed in parameter values.
3726
+ */
3727
+ if (!/^[^=&?#/]+(?:=|&|$)/.test(normalizedResponse)) {
3728
+ return null;
3729
+ }
3661
3730
  const deserializedHash = Object.fromEntries(new URLSearchParams(normalizedResponse));
3662
3731
  // Check for known response properties
3663
3732
  if (deserializedHash.code ||
@@ -3748,7 +3817,7 @@ function validateUrl(url, logger, correlationId) {
3748
3817
  }
3749
3818
  }
3750
3819
 
3751
- /*! @azure/msal-common v16.14.3 2026-10-21 */
3820
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
3752
3821
 
3753
3822
  /*
3754
3823
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3796,7 +3865,7 @@ const DEFAULT_CRYPTO_IMPLEMENTATION = {
3796
3865
  },
3797
3866
  };
3798
3867
 
3799
- /*! @azure/msal-common v16.14.3 2026-10-21 */
3868
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
3800
3869
 
3801
3870
  /*
3802
3871
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3819,7 +3888,7 @@ const DEFAULT_TOKEN_BINDING_KEY_MANAGER = {
3819
3888
  },
3820
3889
  };
3821
3890
 
3822
- /*! @azure/msal-common v16.14.3 2026-10-21 */
3891
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
3823
3892
  /*
3824
3893
  * Copyright (c) Microsoft Corporation. All rights reserved.
3825
3894
  * Licensed under the MIT License.
@@ -4094,12 +4163,12 @@ class Logger {
4094
4163
  }
4095
4164
  }
4096
4165
 
4097
- /*! @azure/msal-common v16.14.3 2026-10-21 */
4166
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
4098
4167
  /* eslint-disable header/header */
4099
4168
  const name$1 = "@azure/msal-common";
4100
- const version$1 = "16.14.3";
4169
+ const version$1 = "16.16.0";
4101
4170
 
4102
- /*! @azure/msal-common v16.14.3 2026-10-21 */
4171
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
4103
4172
  /*
4104
4173
  * Copyright (c) Microsoft Corporation. All rights reserved.
4105
4174
  * Licensed under the MIT License.
@@ -4107,7 +4176,7 @@ const version$1 = "16.14.3";
4107
4176
  const cacheQuotaExceeded = "cache_quota_exceeded";
4108
4177
  const cacheErrorUnknown = "cache_error_unknown";
4109
4178
 
4110
- /*! @azure/msal-common v16.14.3 2026-10-21 */
4179
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
4111
4180
 
4112
4181
  /*
4113
4182
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4145,7 +4214,7 @@ function createCacheError(e) {
4145
4214
  }
4146
4215
  }
4147
4216
 
4148
- /*! @azure/msal-common v16.14.3 2026-10-21 */
4217
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
4149
4218
 
4150
4219
  /*
4151
4220
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4394,6 +4463,7 @@ class CacheManager {
4394
4463
  };
4395
4464
  const tokenKeys = this.getTokenKeys();
4396
4465
  const currentScopes = ScopeSet.fromString(credential.target, correlationId);
4466
+ const accessTokenKeysToRemove = [];
4397
4467
  tokenKeys.accessToken.forEach((key) => {
4398
4468
  if (!this.accessTokenKeyMatchesFilter(key, accessTokenFilter, false)) {
4399
4469
  return;
@@ -4403,10 +4473,13 @@ class CacheManager {
4403
4473
  this.credentialMatchesFilter(tokenEntity, accessTokenFilter, correlationId)) {
4404
4474
  const tokenScopeSet = ScopeSet.fromString(tokenEntity.target, correlationId);
4405
4475
  if (tokenScopeSet.intersectingScopeSets(currentScopes)) {
4406
- this.removeAccessToken(key, correlationId);
4476
+ accessTokenKeysToRemove.push(key);
4407
4477
  }
4408
4478
  }
4409
4479
  });
4480
+ for (const key of accessTokenKeysToRemove) {
4481
+ await this.removeAccessTokenAndTokenBindingKey(key, correlationId, credential.keyId);
4482
+ }
4410
4483
  await this.setAccessTokenCredential(credential, correlationId, kmsi, additionalCacheKeyHash);
4411
4484
  }
4412
4485
  /**
@@ -4642,12 +4715,32 @@ class CacheManager {
4642
4715
  * @param correlationId
4643
4716
  */
4644
4717
  removeAccessToken(key, correlationId) {
4718
+ const credential = this.removeAccessTokenCredential(key, correlationId);
4719
+ if (credential) {
4720
+ void this.removeTokenBindingKeyForCredential(credential, correlationId);
4721
+ }
4722
+ }
4723
+ /**
4724
+ * Removes an access token and waits for any unreferenced token-binding key
4725
+ * cleanup. Internal callers that require deterministic cleanup should use
4726
+ * this method instead of the synchronous public cache contract.
4727
+ */
4728
+ async removeAccessTokenAndTokenBindingKey(key, correlationId, preservedKeyId) {
4729
+ const credential = this.removeAccessTokenCredential(key, correlationId);
4730
+ if (credential) {
4731
+ await this.removeTokenBindingKeyForCredential(credential, correlationId, preservedKeyId);
4732
+ }
4733
+ }
4734
+ removeAccessTokenCredential(key, correlationId) {
4645
4735
  const credential = this.getAccessTokenCredential(key, correlationId);
4646
4736
  if (!credential) {
4647
- return;
4737
+ return null;
4648
4738
  }
4649
4739
  this.removeItem(key, correlationId);
4650
4740
  this.performanceClient.incrementFields({ accessTokensRemoved: 1 }, correlationId);
4741
+ return credential;
4742
+ }
4743
+ async removeTokenBindingKeyForCredential(credential, correlationId, preservedKeyId) {
4651
4744
  // Remove Token Binding Key from key store for token-bound access token credentials
4652
4745
  if (credential.credentialType.toLowerCase() ===
4653
4746
  CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME.toLowerCase()) {
@@ -4657,19 +4750,28 @@ class CacheManager {
4657
4750
  case AuthenticationScheme.DPOP.toLowerCase(): {
4658
4751
  const accessTokenWithAuthSchemeEntity = credential;
4659
4752
  const kid = accessTokenWithAuthSchemeEntity.keyId;
4660
- if (kid) {
4661
- void this.tokenBindingKeyManager
4662
- .removeTokenBindingKey(kid, correlationId)
4663
- .catch(() => {
4753
+ if (kid &&
4754
+ kid !== preservedKeyId &&
4755
+ !this.isTokenBindingKeyReferenced(kid, correlationId)) {
4756
+ try {
4757
+ await this.tokenBindingKeyManager.removeTokenBindingKey(kid, correlationId);
4758
+ }
4759
+ catch {
4664
4760
  this.commonLogger.error("0id34f", correlationId);
4665
4761
  this.performanceClient?.incrementFields({ removeTokenBindingKeyFailure: 1 }, correlationId);
4666
- });
4762
+ }
4667
4763
  }
4668
4764
  break;
4669
4765
  }
4670
4766
  }
4671
4767
  }
4672
4768
  }
4769
+ isTokenBindingKeyReferenced(keyId, correlationId) {
4770
+ return this.getTokenKeys().accessToken.some((accessTokenKey) => {
4771
+ const accessToken = this.getAccessTokenCredential(accessTokenKey, correlationId);
4772
+ return accessToken?.keyId === keyId;
4773
+ });
4774
+ }
4673
4775
  /**
4674
4776
  * Removes all app metadata objects from cache.
4675
4777
  */
@@ -4808,6 +4910,7 @@ class CacheManager {
4808
4910
  const scopes = ScopeSet.createSearchScopes(request.scopes, correlationId);
4809
4911
  const authScheme = request.authenticationScheme ||
4810
4912
  AuthenticationScheme.BEARER;
4913
+ const normalizedAuthScheme = authScheme.toLowerCase();
4811
4914
  /*
4812
4915
  * Distinguish between Bearer and PoP/SSH token cache types
4813
4916
  * Cast to lowercase to handle "bearer" from ADFS
@@ -4832,7 +4935,10 @@ class CacheManager {
4832
4935
  tokenType: authScheme,
4833
4936
  keyId: authScheme === AuthenticationScheme.SSH
4834
4937
  ? request.sshKid
4835
- : undefined,
4938
+ : normalizedAuthScheme ===
4939
+ AuthenticationScheme.DPOP.toLowerCase()
4940
+ ? request.popKid || request.dpopJkt
4941
+ : undefined,
4836
4942
  additionalCacheKeyComponents: additionalCacheKeyComponents,
4837
4943
  };
4838
4944
  const accessTokenKeys = (tokenKeys && tokenKeys.accessToken) ||
@@ -5332,7 +5438,7 @@ class DefaultStorageClass extends CacheManager {
5332
5438
  }
5333
5439
  }
5334
5440
 
5335
- /*! @azure/msal-common v16.14.3 2026-10-21 */
5441
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
5336
5442
  /*
5337
5443
  * Copyright (c) Microsoft Corporation. All rights reserved.
5338
5444
  * Licensed under the MIT License.
@@ -5346,7 +5452,7 @@ class DefaultStorageClass extends CacheManager {
5346
5452
  const PerformanceEventStatus = {
5347
5453
  InProgress: 1};
5348
5454
 
5349
- /*! @azure/msal-common v16.14.3 2026-10-21 */
5455
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
5350
5456
 
5351
5457
  /*
5352
5458
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5404,7 +5510,7 @@ class StubPerformanceClient {
5404
5510
  }
5405
5511
  }
5406
5512
 
5407
- /*! @azure/msal-common v16.14.3 2026-10-21 */
5513
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
5408
5514
 
5409
5515
  /*
5410
5516
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5502,7 +5608,7 @@ function isOidcProtocolMode(config) {
5502
5608
  return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
5503
5609
  }
5504
5610
 
5505
- /*! @azure/msal-common v16.14.3 2026-10-21 */
5611
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
5506
5612
  /*
5507
5613
  * Copyright (c) Microsoft Corporation. All rights reserved.
5508
5614
  * Licensed under the MIT License.
@@ -5529,7 +5635,7 @@ function isOidcProtocolMode(config) {
5529
5635
  }
5530
5636
  }
5531
5637
 
5532
- /*! @azure/msal-common v16.14.3 2026-10-21 */
5638
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
5533
5639
 
5534
5640
  /*
5535
5641
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5550,7 +5656,7 @@ function createJoseHeaderError(code, correlationId) {
5550
5656
  return new JoseHeaderError(code, correlationId);
5551
5657
  }
5552
5658
 
5553
- /*! @azure/msal-common v16.14.3 2026-10-21 */
5659
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
5554
5660
  /*
5555
5661
  * Copyright (c) Microsoft Corporation. All rights reserved.
5556
5662
  * Licensed under the MIT License.
@@ -5575,7 +5681,7 @@ function isPlainObject(value) {
5575
5681
  return Object.getPrototypeOf(value) === proto;
5576
5682
  }
5577
5683
 
5578
- /*! @azure/msal-common v16.14.3 2026-10-21 */
5684
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
5579
5685
  /*
5580
5686
  * Copyright (c) Microsoft Corporation. All rights reserved.
5581
5687
  * Licensed under the MIT License.
@@ -5585,7 +5691,7 @@ const missingAlgError = "missing_alg_error";
5585
5691
  const missingJwkError = "missing_jwk_error";
5586
5692
  const invalidJwkError = "invalid_jwk_error";
5587
5693
 
5588
- /*! @azure/msal-common v16.14.3 2026-10-21 */
5694
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
5589
5695
 
5590
5696
  /*
5591
5697
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5651,7 +5757,7 @@ class JoseHeader {
5651
5757
  }
5652
5758
  }
5653
5759
 
5654
- /*! @azure/msal-common v16.14.3 2026-10-21 */
5760
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
5655
5761
 
5656
5762
  /*
5657
5763
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5752,7 +5858,7 @@ class PopTokenGenerator {
5752
5858
  }
5753
5859
  }
5754
5860
 
5755
- /*! @azure/msal-common v16.14.3 2026-10-21 */
5861
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
5756
5862
 
5757
5863
  /*
5758
5864
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5802,13 +5908,22 @@ function validateDpopNonce(nonce, correlationId) {
5802
5908
  throw createClientConfigurationError(invalidDpopNonce, correlationId);
5803
5909
  }
5804
5910
  }
5911
+ /**
5912
+ * Validates and normalizes the HTTP resource context for a DPoP-bound request.
5913
+ * @internal
5914
+ */
5915
+ function normalizeDpopResourceRequestContext(context, correlationId = "") {
5916
+ return {
5917
+ htm: normalizeHtm(context.htm, correlationId),
5918
+ htu: normalizeHtu(context.htu, correlationId),
5919
+ };
5920
+ }
5805
5921
  /**
5806
5922
  * Builds RFC 9449 DPoP proof JWT payloads for token-endpoint and
5807
5923
  * resource-endpoint proof bindings.
5808
5924
  *
5809
- * Not exported from any public package entry point.
5810
- * This helper is internal-only until DPoP is wired into acquisition flows
5811
- * in a subsequent work item.
5925
+ * Exported from package entry points for use by MSAL Browser.
5926
+ * This helper remains an unsupported internal API for direct consumers.
5812
5927
  *
5813
5928
  * DPoP proofs do not contain SHR fields (at, ts, m, u, p, q).
5814
5929
  * @internal
@@ -5863,10 +5978,11 @@ class DpopProofGenerator {
5863
5978
  */
5864
5979
  buildResourceProofClaims(params, correlationId = "") {
5865
5980
  validateDpopNonce(params.nonce, correlationId);
5981
+ const resourceContext = normalizeDpopResourceRequestContext(params, correlationId);
5866
5982
  const claims = {
5867
5983
  jti: this.cryptoUtils.createNewGuid(),
5868
- htm: normalizeHtm(params.htm, correlationId),
5869
- htu: normalizeHtu(params.htu, correlationId),
5984
+ htm: resourceContext.htm,
5985
+ htu: resourceContext.htu,
5870
5986
  ath: params.ath,
5871
5987
  iat: nowSeconds(),
5872
5988
  };
@@ -5897,7 +6013,7 @@ class DpopProofGenerator {
5897
6013
  }
5898
6014
  }
5899
6015
 
5900
- /*! @azure/msal-common v16.14.3 2026-10-21 */
6016
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
5901
6017
  /*
5902
6018
  * Copyright (c) Microsoft Corporation. All rights reserved.
5903
6019
  * Licensed under the MIT License.
@@ -5948,7 +6064,7 @@ const badToken = "bad_token";
5948
6064
  */
5949
6065
  const interruptedUser = "interrupted_user";
5950
6066
 
5951
- /*! @azure/msal-common v16.14.3 2026-10-21 */
6067
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
5952
6068
 
5953
6069
  /*
5954
6070
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6015,7 +6131,7 @@ function createInteractionRequiredAuthError(errorCode, correlationId, errorMessa
6015
6131
  return new InteractionRequiredAuthError(errorCode, correlationId, errorMessage);
6016
6132
  }
6017
6133
 
6018
- /*! @azure/msal-common v16.14.3 2026-10-21 */
6134
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
6019
6135
 
6020
6136
  /*
6021
6137
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6034,7 +6150,7 @@ class ServerError extends AuthError {
6034
6150
  }
6035
6151
  }
6036
6152
 
6037
- /*! @azure/msal-common v16.14.3 2026-10-21 */
6153
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
6038
6154
 
6039
6155
  /*
6040
6156
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6105,7 +6221,7 @@ function parseRequestState(base64Decode, state, correlationId) {
6105
6221
  }
6106
6222
  }
6107
6223
 
6108
- /*! @azure/msal-common v16.14.3 2026-10-21 */
6224
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
6109
6225
 
6110
6226
  /*
6111
6227
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6533,7 +6649,7 @@ function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decod
6533
6649
  return baseAccount;
6534
6650
  }
6535
6651
 
6536
- /*! @azure/msal-common v16.14.3 2026-10-21 */
6652
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
6537
6653
  /*
6538
6654
  * Copyright (c) Microsoft Corporation. All rights reserved.
6539
6655
  * Licensed under the MIT License.
@@ -6543,7 +6659,7 @@ const CcsCredentialType = {
6543
6659
  UPN: "UPN",
6544
6660
  };
6545
6661
 
6546
- /*! @azure/msal-common v16.14.3 2026-10-21 */
6662
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
6547
6663
  /*
6548
6664
  * Copyright (c) Microsoft Corporation. All rights reserved.
6549
6665
  * Licensed under the MIT License.
@@ -6562,7 +6678,7 @@ async function getClientAssertion(clientAssertion, clientId, tokenEndpoint, fmiP
6562
6678
  }
6563
6679
  }
6564
6680
 
6565
- /*! @azure/msal-common v16.14.3 2026-10-21 */
6681
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
6566
6682
 
6567
6683
  /*
6568
6684
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6586,7 +6702,7 @@ function getRequestThumbprint(clientId, request, homeAccountId) {
6586
6702
  };
6587
6703
  }
6588
6704
 
6589
- /*! @azure/msal-common v16.14.3 2026-10-21 */
6705
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
6590
6706
 
6591
6707
  /*
6592
6708
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6621,13 +6737,14 @@ class ThrottlingUtils {
6621
6737
  * Performs necessary throttling checks after a network request.
6622
6738
  * @param cacheManager
6623
6739
  * @param thumbprint
6624
- * @param response
6740
+ * @param response - Token response with case-insensitive header names.
6625
6741
  */
6626
6742
  static postProcess(cacheManager, thumbprint, response, correlationId) {
6743
+ const retryAfter = getRetryAfterHeader(response);
6627
6744
  if (ThrottlingUtils.checkResponseStatus(response) ||
6628
- ThrottlingUtils.checkResponseForRetryAfter(response)) {
6745
+ retryAfter !== undefined) {
6629
6746
  const thumbprintValue = {
6630
- throttleTime: ThrottlingUtils.calculateThrottleTime(parseInt(response.headers[HeaderNames.RETRY_AFTER])),
6747
+ throttleTime: ThrottlingUtils.calculateThrottleTime(parseInt(retryAfter || "")),
6631
6748
  error: response.body.error,
6632
6749
  errorCodes: response.body.error_codes,
6633
6750
  errorMessage: response.body.error_description,
@@ -6646,14 +6763,10 @@ class ThrottlingUtils {
6646
6763
  }
6647
6764
  /**
6648
6765
  * Checks a NetworkResponse object's RetryAfter header
6649
- * @param response
6766
+ * @param response - Token response with case-insensitive header names.
6650
6767
  */
6651
6768
  static checkResponseForRetryAfter(response) {
6652
- if (response.headers) {
6653
- return (response.headers.hasOwnProperty(HeaderNames.RETRY_AFTER) &&
6654
- (response.status < 200 || response.status >= 300));
6655
- }
6656
- return false;
6769
+ return getRetryAfterHeader(response) !== undefined;
6657
6770
  }
6658
6771
  /**
6659
6772
  * Calculates the Unix-time value for a throttle to expire given throttleTime in seconds.
@@ -6670,9 +6783,16 @@ class ThrottlingUtils {
6670
6783
  const key = this.generateThrottlingStorageKey(thumbprint);
6671
6784
  cacheManager.removeItem(key, request.correlationId);
6672
6785
  }
6786
+ }
6787
+ /** Reads Retry-After only for non-success responses. */
6788
+ function getRetryAfterHeader(response) {
6789
+ if ((response.status < 200 || response.status >= 300) && response.headers) {
6790
+ return getResponseHeader(response.headers, HeaderNames.RETRY_AFTER);
6791
+ }
6792
+ return undefined;
6673
6793
  }
6674
6794
 
6675
- /*! @azure/msal-common v16.14.3 2026-10-21 */
6795
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
6676
6796
 
6677
6797
  /*
6678
6798
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6703,7 +6823,7 @@ function createNetworkError(error, httpStatus, responseHeaders, additionalError)
6703
6823
  return new NetworkError(error, httpStatus, responseHeaders);
6704
6824
  }
6705
6825
 
6706
- /*! @azure/msal-common v16.14.3 2026-10-21 */
6826
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
6707
6827
 
6708
6828
  /*
6709
6829
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6801,7 +6921,8 @@ async function sendPostRequest(thumbprint, tokenEndpoint, options, correlationId
6801
6921
  let response;
6802
6922
  try {
6803
6923
  response = await invokeAsync((networkClient.sendPostRequestAsync.bind(networkClient)), NetworkClientSendPostRequestAsync, logger, performanceClient, correlationId)(tokenEndpoint, { ...options, correlationId, performanceClient });
6804
- const responseHeaders = response.headers || {};
6924
+ const responseHeaders = normalizeResponseHeaders(response.headers || {});
6925
+ response = { ...response, headers: responseHeaders };
6805
6926
  performanceClient?.addFields({
6806
6927
  refreshTokenSize: response.body.refresh_token?.length || 0,
6807
6928
  httpVerToken: responseHeaders[HeaderNames.X_MS_HTTP_VERSION] || "",
@@ -6810,16 +6931,16 @@ async function sendPostRequest(thumbprint, tokenEndpoint, options, correlationId
6810
6931
  }
6811
6932
  catch (e) {
6812
6933
  if (e instanceof NetworkError) {
6813
- const responseHeaders = e.responseHeaders;
6934
+ const responseHeaders = e.responseHeaders
6935
+ ? normalizeResponseHeaders(e.responseHeaders)
6936
+ : undefined;
6814
6937
  if (responseHeaders) {
6815
6938
  performanceClient?.addFields({
6816
6939
  httpVerToken: responseHeaders[HeaderNames.X_MS_HTTP_VERSION] ||
6817
6940
  "",
6818
6941
  requestId: responseHeaders[HeaderNames.X_MS_REQUEST_ID] || "",
6819
- contentTypeHeader: responseHeaders[HeaderNames.CONTENT_TYPE] ||
6820
- undefined,
6821
- contentLengthHeader: responseHeaders[HeaderNames.CONTENT_LENGTH] ||
6822
- undefined,
6942
+ contentTypeHeader: getResponseHeader(responseHeaders, HeaderNames.CONTENT_TYPE) || undefined,
6943
+ contentLengthHeader: getResponseHeader(responseHeaders, HeaderNames.CONTENT_LENGTH) || undefined,
6823
6944
  httpStatus: e.httpStatus,
6824
6945
  }, correlationId);
6825
6946
  }
@@ -6836,7 +6957,7 @@ async function sendPostRequest(thumbprint, tokenEndpoint, options, correlationId
6836
6957
  return response;
6837
6958
  }
6838
6959
 
6839
- /*! @azure/msal-common v16.14.3 2026-10-21 */
6960
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
6840
6961
 
6841
6962
  /*
6842
6963
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7080,6 +7201,9 @@ class AuthorizationCodeClient {
7080
7201
  if (request.logoutHint) {
7081
7202
  addLogoutHint(parameters, request.logoutHint);
7082
7203
  }
7204
+ if (request.popupOriginCheckDone) {
7205
+ addPopupOriginCheckDone(parameters);
7206
+ }
7083
7207
  if (request.extraQueryParameters) {
7084
7208
  addExtraParameters(parameters, request.extraQueryParameters);
7085
7209
  }
@@ -7100,7 +7224,7 @@ class AuthorizationCodeClient {
7100
7224
  }
7101
7225
  }
7102
7226
 
7103
- /*! @azure/msal-common v16.14.3 2026-10-21 */
7227
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
7104
7228
 
7105
7229
  /*
7106
7230
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7235,6 +7359,9 @@ function getStandardAuthorizeRequestParameters(authOptions, request, logger, per
7235
7359
  !Object.keys(request.extraQueryParameters).includes(INSTANCE_AWARE))) {
7236
7360
  addInstanceAware(parameters);
7237
7361
  }
7362
+ if (request.popupOriginCheckDone) {
7363
+ addPopupOriginCheckDone(parameters);
7364
+ }
7238
7365
  return parameters;
7239
7366
  }
7240
7367
  /**
@@ -7327,7 +7454,7 @@ function extractLoginHint(account) {
7327
7454
  return account.loginHint || account.idTokenClaims?.login_hint || null;
7328
7455
  }
7329
7456
 
7330
- /*! @azure/msal-common v16.14.3 2026-10-21 */
7457
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
7331
7458
 
7332
7459
  /*
7333
7460
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7562,7 +7689,7 @@ class RefreshTokenClient {
7562
7689
  }
7563
7690
  }
7564
7691
 
7565
- /*! @azure/msal-common v16.14.3 2026-10-21 */
7692
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
7566
7693
 
7567
7694
  /*
7568
7695
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7855,7 +7982,7 @@ class StubServerTelemetryManager extends ServerTelemetryManager {
7855
7982
  clearNativeBrokerErrorCode() { }
7856
7983
  }
7857
7984
 
7858
- /*! @azure/msal-common v16.14.3 2026-10-21 */
7985
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
7859
7986
 
7860
7987
  /*
7861
7988
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7982,7 +8109,7 @@ class SilentFlowClient {
7982
8109
  }
7983
8110
  }
7984
8111
 
7985
- /*! @azure/msal-common v16.14.3 2026-10-21 */
8112
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
7986
8113
 
7987
8114
  /*
7988
8115
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7998,7 +8125,7 @@ const StubbedNetworkModule = {
7998
8125
  },
7999
8126
  };
8000
8127
 
8001
- /*! @azure/msal-common v16.14.3 2026-10-21 */
8128
+ /*! @azure/msal-common v16.16.0 2026-11-05 */
8002
8129
 
8003
8130
  /*
8004
8131
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8434,7 +8561,7 @@ function ensureArgumentIsStringArray(argName, argValue, correlationId) {
8434
8561
 
8435
8562
  /* eslint-disable header/header */
8436
8563
  const name = "@azure/msal-browser";
8437
- const version = "5.26.0";
8564
+ const version = "5.28.0";
8438
8565
 
8439
8566
  /*
8440
8567
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -9060,6 +9187,7 @@ const PlatformAuthInteractionClientInitializeRequest = "platformAuthInteractionC
9060
9187
  const PlatformAuthHandleNativeResponse = "platformAuthHandleNativeResponse";
9061
9188
  const PlatformAuthCacheAccount = "platformAuthCacheAccount";
9062
9189
  const PlatformAuthCacheNativeTokens = "platformAuthCacheNativeTokens";
9190
+ const PlatformAuthDpopKeyCleanup = "platformAuthDpopKeyCleanup";
9063
9191
  const RemoveHiddenIframe = "removeHiddenIframe";
9064
9192
  const ImportExistingCache = "importExistingCache";
9065
9193
  /**
@@ -9131,7 +9259,6 @@ const nativeConnectionNotEstablished = "native_connection_not_established";
9131
9259
  const uninitializedPublicClientApplication = "uninitialized_public_client_application";
9132
9260
  const nativePromptNotSupported = "native_prompt_not_supported";
9133
9261
  const invalidBase64String = "invalid_base64_string";
9134
- const invalidPopTokenRequest = "invalid_pop_token_request";
9135
9262
  const unsupportedTokenBindingAlgorithm = "unsupported_token_binding_algorithm";
9136
9263
  const tokenBindingKeyAlgorithmMismatch = "token_binding_key_algorithm_mismatch";
9137
9264
  const tokenBindingKeyJwkThumbprintMismatch = "token_binding_key_jwk_thumbprint_mismatch";
@@ -9880,9 +10007,14 @@ function parseAuthResponseFromUrl() {
9880
10007
  };
9881
10008
  }
9882
10009
  /**
9883
- * Clears hash from window url.
10010
+ * Clears a recognized authentication response fragment, preserving the query string.
10011
+ * Assigns an empty hash, then removes the trailing # when history updates are available.
9884
10012
  */
9885
10013
  function clearHash(contentWindow) {
10014
+ const serverParams = getDeserializedResponse(contentWindow.location.hash);
10015
+ if (!serverParams) {
10016
+ return;
10017
+ }
9886
10018
  // Office.js sets history.replaceState to null
9887
10019
  contentWindow.location.hash = "";
9888
10020
  if (typeof contentWindow.history.replaceState === "function") {
@@ -9890,6 +10022,16 @@ function clearHash(contentWindow) {
9890
10022
  contentWindow.history.replaceState(null, "", `${contentWindow.location.origin}${contentWindow.location.pathname}${contentWindow.location.search}`);
9891
10023
  }
9892
10024
  }
10025
+ /**
10026
+ * Strips both hash and query string from the given window's URL by replacing
10027
+ * with origin + pathname only. Used to remove auth response parameters
10028
+ * (auth code, state, etc.) before the window is closed or navigated away.
10029
+ */
10030
+ function clearAuthResponseFromUrl(contentWindow) {
10031
+ if (typeof contentWindow.history?.replaceState === "function") {
10032
+ contentWindow.history.replaceState(null, "", `${contentWindow.location.origin}${contentWindow.location.pathname}`);
10033
+ }
10034
+ }
9893
10035
  /**
9894
10036
  * Replaces current hash with hash from provided url
9895
10037
  */
@@ -10469,6 +10611,19 @@ class AsyncMemoryStorage {
10469
10611
  return cacheKeys;
10470
10612
  }
10471
10613
  }
10614
+ /**
10615
+ * Returns whether a key is available in persistent storage. Unlike
10616
+ * containsKey, this does not consult the in-memory fallback.
10617
+ */
10618
+ async containsKeyInPersistentStorage(key, correlationId) {
10619
+ try {
10620
+ return await this.indexedDBCache.containsKey(key);
10621
+ }
10622
+ catch (e) {
10623
+ this.handleDatabaseAccessError(e, correlationId);
10624
+ return false;
10625
+ }
10626
+ }
10472
10627
  /**
10473
10628
  * Returns true or false if the given key is present in the cache.
10474
10629
  * @param key
@@ -10574,6 +10729,12 @@ class TokenBindingKeyManager {
10574
10729
  throw createClientAuthError(bindingKeyNotRemoved, correlationId);
10575
10730
  }
10576
10731
  }
10732
+ /**
10733
+ * Returns whether a browser token-binding key is available.
10734
+ */
10735
+ async hasTokenBindingKey(keyId, correlationId) {
10736
+ return this.cache.containsKey(keyId, correlationId);
10737
+ }
10577
10738
  /**
10578
10739
  * Clears browser token-binding keys from memory and persistent storage.
10579
10740
  * @param correlationId - Request correlation identifier.
@@ -10635,6 +10796,13 @@ class TokenBindingKeyManager {
10635
10796
  }
10636
10797
  return cachedKeyPair;
10637
10798
  }
10799
+ /**
10800
+ * Returns whether a browser token-binding key survived in persistent
10801
+ * storage and can be restored after a redirect navigation.
10802
+ */
10803
+ async isTokenBindingKeyPersisted(keyId, correlationId) {
10804
+ return this.cache.containsKeyInPersistentStorage(keyId, correlationId);
10805
+ }
10638
10806
  /** @internal */
10639
10807
  getTokenBindingKeyTelemetry(cachedKeyPair, fallbackAlgorithm) {
10640
10808
  return {
@@ -10965,19 +11133,13 @@ function validateDpopRequest(request, correlationId) {
10965
11133
  }
10966
11134
  /**
10967
11135
  * Resolves the token-binding parameters needed before building authorize or token requests.
10968
- * Public PCA DPoP requests use a dpopJkt thumbprint, while platform broker PoP requests use
10969
- * a reqCnf confirmation claim. Requests that do not require request-time token binding return
10970
- * no additional parameters.
11136
+ * DPoP requests provision a browser key for token endpoint redemption. Platform broker
11137
+ * authorization requests retain the key for auth-code fallback but suppress dpop_jkt on
11138
+ * /authorize. Platform broker PoP requests use a reqCnf confirmation claim.
10971
11139
  */
10972
11140
  async function getTokenBindingRequestParams(request, tokenBindingKeyManager, logger, performanceClient) {
10973
11141
  switch (request.authenticationScheme) {
10974
11142
  case AuthenticationScheme.DPOP:
10975
- if (request.platformBroker) {
10976
- return {};
10977
- }
10978
- if (request.dpopJkt) {
10979
- return { dpopJkt: request.dpopJkt };
10980
- }
10981
11143
  return {
10982
11144
  dpopJkt: await tokenBindingKeyManager.provisionTokenBindingKey({
10983
11145
  tokenBindingKeyType: AuthenticationScheme.DPOP.toLowerCase(),
@@ -11000,6 +11162,36 @@ async function getTokenBindingRequestParams(request, tokenBindingKeyManager, log
11000
11162
  return {};
11001
11163
  }
11002
11164
  }
11165
+ /**
11166
+ * Removes a DPoP key that was provisioned for an authorization attempt which
11167
+ * did not complete. Cleanup failures are recorded without replacing the
11168
+ * original authorization error.
11169
+ */
11170
+ async function removeTokenBindingKeyOnFailure(request, tokenBindingKeyManager, logger, performanceClient) {
11171
+ if (request.authenticationScheme !== AuthenticationScheme.DPOP ||
11172
+ !request.dpopJkt) {
11173
+ return;
11174
+ }
11175
+ try {
11176
+ await tokenBindingKeyManager.removeTokenBindingKey(request.dpopJkt, request.correlationId);
11177
+ }
11178
+ catch {
11179
+ logger.error("1su7ne", request.correlationId);
11180
+ performanceClient.incrementFields({ removeTokenBindingKeyFailure: 1 }, request.correlationId);
11181
+ }
11182
+ }
11183
+ /**
11184
+ * Returns whether an MSAL-owned DPoP key is available in persistent storage
11185
+ * before a redirect navigation. Custom managers without a persistence probe
11186
+ * retain their existing behavior.
11187
+ */
11188
+ async function isTokenBindingKeyPersistedForRedirect(request, tokenBindingKeyManager) {
11189
+ const keyId = request.dpopJkt ?? request.keyId;
11190
+ if (!keyId || !tokenBindingKeyManager.isTokenBindingKeyPersisted) {
11191
+ return true;
11192
+ }
11193
+ return tokenBindingKeyManager.isTokenBindingKeyPersisted(keyId, request.correlationId);
11194
+ }
11003
11195
  /**
11004
11196
  * Initializer function for all request APIs
11005
11197
  * @param request
@@ -11075,6 +11267,90 @@ function validateRequestMethod(interactionRequest, protocolMode) {
11075
11267
  return httpMethod;
11076
11268
  }
11077
11269
 
11270
+ /*
11271
+ * Copyright (c) Microsoft Corporation. All rights reserved.
11272
+ * Licensed under the MIT License.
11273
+ */
11274
+ /**
11275
+ * `window.origin` of a document with an opaque origin, e.g. one sandboxed
11276
+ * without `allow-same-origin`. Read from `window.origin`, not
11277
+ * `location.origin`, which reports the real host even when sandboxed.
11278
+ */
11279
+ const OPAQUE_ORIGIN = "null";
11280
+ /**
11281
+ * Returns `true` when every ancestor browsing context is same-origin with
11282
+ * `win`. A top-level document has no ancestors, so it always passes.
11283
+ */
11284
+ function allAncestorsSameOrigin(win) {
11285
+ try {
11286
+ // Sandboxed: no origin to compare ancestors against.
11287
+ if (win.origin === OPAQUE_ORIGIN) {
11288
+ return false;
11289
+ }
11290
+ let current = win;
11291
+ // `window.parent` is self-referential at the top level, never falsy.
11292
+ while (current !== current.parent) {
11293
+ current = current.parent;
11294
+ // Throws SecurityError if this ancestor is cross-origin.
11295
+ void current.location.href;
11296
+ }
11297
+ return true;
11298
+ }
11299
+ catch {
11300
+ return false;
11301
+ }
11302
+ }
11303
+ /**
11304
+ * Returns `true` when the top-level window has no opener, or one that is
11305
+ * same-origin with it.
11306
+ *
11307
+ * Reads the opener from `win.top`, not `win`: a framed document always reports
11308
+ * `window.opener === null` and would pass while the top window's untrusted
11309
+ * opener still holds a handle on it.
11310
+ */
11311
+ function topOpenerIsSameOriginOrAbsent(win) {
11312
+ try {
11313
+ const top = win.top;
11314
+ if (!top) {
11315
+ // Detached from its browsing context; treat as unsafe.
11316
+ return false;
11317
+ }
11318
+ const opener = top.opener;
11319
+ if (!opener || opener === top) {
11320
+ return true;
11321
+ }
11322
+ // Throws SecurityError if the opener is cross-origin.
11323
+ void opener.location.href;
11324
+ return true;
11325
+ }
11326
+ catch {
11327
+ return false;
11328
+ }
11329
+ }
11330
+ /**
11331
+ * Computes the `pocd` ("popup origin check done") authorize parameter value.
11332
+ *
11333
+ * `1` means no untrusted window can reach the popup, which is what lets Entra
11334
+ * omit the `Cross-Origin-Opener-Policy` response header for the request.
11335
+ *
11336
+ * @param config Resolved browser configuration.
11337
+ * @param win Window whose hosting environment is being checked. Defaults to the app window.
11338
+ * @returns `1` when the check passes, otherwise `0`.
11339
+ */
11340
+ function computePocd(config, win = typeof window !== "undefined" ? window : undefined) {
11341
+ /*
11342
+ * Only an explicit false opts out; anything else computes the check, so an
11343
+ * unresolved config fails closed rather than asserting pocd=1.
11344
+ */
11345
+ if (config.auth.originCheck === false) {
11346
+ return 1;
11347
+ }
11348
+ if (!win || !allAncestorsSameOrigin(win)) {
11349
+ return 0;
11350
+ }
11351
+ return topOpenerIsSameOriginOrAbsent(win) ? 1 : 0;
11352
+ }
11353
+
11078
11354
  /*
11079
11355
  * Copyright (c) Microsoft Corporation. All rights reserved.
11080
11356
  * Licensed under the MIT License.
@@ -11092,6 +11368,11 @@ class StandardInteractionClient extends BaseInteractionClient {
11092
11368
  const validLogoutRequest = {
11093
11369
  correlationId: this.correlationId,
11094
11370
  ...logoutRequest,
11371
+ /*
11372
+ * Computed here rather than per flow so every end-session request
11373
+ * carries it, matching the authorize path.
11374
+ */
11375
+ popupOriginCheckDone: computePocd(this.config) === 1,
11095
11376
  };
11096
11377
  /**
11097
11378
  * Set logout_hint to be login_hint from ID Token Claims if present
@@ -11431,7 +11712,13 @@ const SIGN_UP_V2_CHALLENGE = 100212;
11431
11712
  const SIGN_UP_V2_SUBMIT_CODE = 100213;
11432
11713
  const SIGN_UP_V2_SUBMIT_ATTRIBUTES = 100214;
11433
11714
  const SIGN_UP_V2_RESEND_CODE = 100215;
11434
- const SIGN_UP_V2_COMPLETE = 100216;
11715
+ const SIGN_UP_V2_COMPLETE = 100216;
11716
+ const JIT_V2_ENROLL_AUTH_METHOD = 100217;
11717
+ const JIT_V2_SUBMIT_CHALLENGE = 100218;
11718
+ const JIT_V2_RESEND_CHALLENGE = 100219;
11719
+ const MFA_V2_SELECT_AUTH_METHOD = 100220;
11720
+ const MFA_V2_SUBMIT_CHALLENGE = 100221;
11721
+ const MFA_V2_RESEND_CHALLENGE = 100222;
11435
11722
 
11436
11723
  /*
11437
11724
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -12261,7 +12548,7 @@ class ResponseHandlerV2 {
12261
12548
  }
12262
12549
  // Required href; throws when it is absent.
12263
12550
  requireHref(href, relation, correlationId, missingHrefError) {
12264
- if (!href) {
12551
+ if (typeof href !== "string" || !href.trim()) {
12265
12552
  const errorCode = missingHrefError?.code ?? INVALID_HAL_RESPONSE;
12266
12553
  const errorMessage = missingHrefError?.message ??
12267
12554
  `Invalid HAL response: missing '${relation}' link`;
@@ -12375,9 +12662,17 @@ const CHALLENGE_RELATION = "challenge";
12375
12662
  const VERIFY_RELATION = "verify";
12376
12663
  const RISK_VERIFY_RELATION = "riskverify";
12377
12664
  const COLLECT_ATTRIBUTES_RELATION = "collectAttributes";
12665
+ const ENROLL_RELATION = "enroll";
12666
+ const ACTIVATE_RELATION = "activate";
12667
+ const RESEND_RELATION = "resend";
12668
+ const POLL_RELATION = "poll";
12378
12669
  const AuthenticationMethodTypeV2 = {
12379
12670
  EMAIL: "email",
12380
12671
  PASSWORD: "password",
12672
+ PHONE: "phone",
12673
+ SMS: "sms",
12674
+ };
12675
+ const PhoneRegistrationChannelV2 = {
12381
12676
  SMS: "sms",
12382
12677
  };
12383
12678
  /*
@@ -12595,16 +12890,6 @@ class BaseApiClientV2 {
12595
12890
  const AuthenticationFactorV2 = {
12596
12891
  SINGLE_FACTOR: "singleFactor",
12597
12892
  MULTI_FACTOR: "multiFactor",
12598
- };
12599
- const ChallengeNextActionV2 = {
12600
- VERIFY: "verify",
12601
- RISK_VERIFY: "riskVerify",
12602
- };
12603
- const VerifyNextActionV2 = {
12604
- UPDATE: "update",
12605
- CONTINUE: "continue",
12606
- CHALLENGE: "challenge",
12607
- COLLECT_ATTRIBUTES: "collectAttributes",
12608
12893
  };
12609
12894
 
12610
12895
  /*
@@ -12615,6 +12900,7 @@ const SignUpSubmitAttributesNextActionV2 = {
12615
12900
  VERIFY: "verify",
12616
12901
  COLLECT_ATTRIBUTES: "collectAttributes",
12617
12902
  CONTINUE: "continue",
12903
+ ENROLL: "enroll",
12618
12904
  };
12619
12905
 
12620
12906
  /*
@@ -12678,6 +12964,13 @@ class CustomAuthApiClientV2 extends BaseApiClientV2 {
12678
12964
  attributes: parsedResponse.body.attributes,
12679
12965
  };
12680
12966
  }
12967
+ if (parsedResponse.body.action === ENROLL_RELATION) {
12968
+ return {
12969
+ nextAction: ENROLL_RELATION,
12970
+ continuationToken,
12971
+ methods: this.resolveEnrollmentMethods(this.handler.requireMethods(parsedResponse.body._embedded?.methods, correlationId), correlationId),
12972
+ };
12973
+ }
12681
12974
  const message = "Invalid HAL response: sign-up attribute submission returned no known next action";
12682
12975
  this.logger?.error(message, correlationId);
12683
12976
  throw new CustomAuthApiError(INVALID_HAL_RESPONSE, message, correlationId);
@@ -12707,6 +13000,39 @@ class CustomAuthApiClientV2 extends BaseApiClientV2 {
12707
13000
  const parsedResponse = await this.sendActionRequest(verifyHref, HttpMethod.POST, request, context);
12708
13001
  return this.toVerifyResult(parsedResponse);
12709
13002
  }
13003
+ async enrollAuthMethod(enrollHref, request, context) {
13004
+ return this.sendEnrollmentRequest(enrollHref, request, context);
13005
+ }
13006
+ async resendAuthMethodRegistrationChallenge(resendHref, request, context) {
13007
+ return this.sendEnrollmentRequest(resendHref, request, context);
13008
+ }
13009
+ async sendEnrollmentRequest(href, request, context) {
13010
+ const parsedResponse = await this.sendActionRequest(href, HttpMethod.POST, request, context);
13011
+ if (parsedResponse.body.action !== ACTIVATE_RELATION) {
13012
+ throw new CustomAuthApiError(INVALID_HAL_RESPONSE, "Invalid HAL response: enrollment returned no activation action", parsedResponse.correlationId);
13013
+ }
13014
+ const links = parsedResponse.body._links;
13015
+ return {
13016
+ nextAction: ACTIVATE_RELATION,
13017
+ continuationToken: this.handler.requireContinuationToken(parsedResponse.continuationToken, parsedResponse.correlationId),
13018
+ hint: parsedResponse.body.hint,
13019
+ codeLength: this.normalizeCodeLength(parsedResponse.body.codeLength),
13020
+ activateHref: this.handler.requireHref(links?.activate?.href, ACTIVATE_RELATION, parsedResponse.correlationId),
13021
+ resendHref: links && "resend" in links
13022
+ ? this.handler.requireHref(links.resend?.href, RESEND_RELATION, parsedResponse.correlationId)
13023
+ : undefined,
13024
+ };
13025
+ }
13026
+ async activateAuthMethod(activateHref, request, context) {
13027
+ const parsedResponse = await this.sendActionRequest(activateHref, HttpMethod.POST, request, context);
13028
+ if (parsedResponse.body.state !== ResponseStateV2.CONTINUE) {
13029
+ throw new CustomAuthApiError(INVALID_HAL_RESPONSE, "Invalid HAL response: activation returned no continuation state", parsedResponse.correlationId);
13030
+ }
13031
+ return {
13032
+ nextAction: ResponseStateV2.CONTINUE,
13033
+ continuationToken: this.handler.requireContinuationToken(parsedResponse.continuationToken, parsedResponse.correlationId),
13034
+ };
13035
+ }
12710
13036
  /*
12711
13037
  * Submits the new password and returns the link used to poll for completion.
12712
13038
  */
@@ -12719,25 +13045,43 @@ class CustomAuthApiClientV2 extends BaseApiClientV2 {
12719
13045
  };
12720
13046
  }
12721
13047
  /*
12722
- * Polls once for reset completion and returns the next server-provided link.
13048
+ * Sends a poll request and validates the data needed for the next flow step.
12723
13049
  */
12724
13050
  async poll(pollHref, request, context) {
12725
13051
  const parsedResponse = await this.sendActionRequest(pollHref, HttpMethod.POST, request, context);
12726
- const isCompleted = parsedResponse.body.state === ResponseStateV2.CONTINUE;
12727
- return {
12728
- continuationToken: parsedResponse.continuationToken ?? request.continuationToken,
12729
- isCompleted,
12730
- pollHref: isCompleted
12731
- ? undefined
12732
- : this.handler.requireHref(parsedResponse.body._links?.poll?.href, "poll", parsedResponse.correlationId),
12733
- };
13052
+ const correlationId = parsedResponse.correlationId;
13053
+ const continuationToken = this.handler.requireContinuationToken(parsedResponse.continuationToken, correlationId);
13054
+ const nextAction = parsedResponse.body.action ?? parsedResponse.body.state;
13055
+ if (nextAction === ENROLL_RELATION) {
13056
+ return {
13057
+ nextAction,
13058
+ continuationToken,
13059
+ enrollmentMethods: this.resolveEnrollmentMethods(this.handler.requireMethods(parsedResponse.body._embedded?.methods, correlationId), correlationId),
13060
+ };
13061
+ }
13062
+ if (nextAction === POLL_RELATION) {
13063
+ return {
13064
+ nextAction: POLL_RELATION,
13065
+ continuationToken,
13066
+ pollHref: this.handler.requireHref(parsedResponse.body._links?.poll?.href, POLL_RELATION, correlationId),
13067
+ };
13068
+ }
13069
+ if (nextAction === ResponseStateV2.CONTINUE) {
13070
+ return {
13071
+ nextAction,
13072
+ continuationToken,
13073
+ };
13074
+ }
13075
+ const message = `Password reset poll next action '${nextAction}' is not supported.`;
13076
+ this.logger?.error(message, correlationId);
13077
+ throw new CustomAuthApiError(INVALID_HAL_RESPONSE, message, correlationId);
12734
13078
  }
12735
13079
  async sendStartRequest(startHref, request, context) {
12736
13080
  const parsedResponse = await this.sendActionRequest(startHref, HttpMethod.POST, request, context);
12737
13081
  const continuationToken = this.handler.requireContinuationToken(parsedResponse.continuationToken, parsedResponse.correlationId);
12738
13082
  return {
12739
13083
  continuationToken,
12740
- methods: this.resolveMethods(parsedResponse.body, parsedResponse.correlationId),
13084
+ methods: this.resolveMethods(this.handler.requireMethods(parsedResponse.body._embedded?.methods, parsedResponse.correlationId), parsedResponse.correlationId),
12741
13085
  authenticationFactor: this.resolveAuthenticationFactor(parsedResponse.body.challengeContext?.authenticationFactor, parsedResponse.correlationId),
12742
13086
  scenario: parsedResponse.body.scenario,
12743
13087
  };
@@ -12747,13 +13091,13 @@ class CustomAuthApiClientV2 extends BaseApiClientV2 {
12747
13091
  const continuationToken = this.handler.requireContinuationToken(parsedResponse.continuationToken, correlationId);
12748
13092
  if (parsedResponse.body.state === ResponseStateV2.CONTINUE) {
12749
13093
  return {
12750
- nextAction: VerifyNextActionV2.CONTINUE,
13094
+ nextAction: ResponseStateV2.CONTINUE,
12751
13095
  continuationToken,
12752
13096
  };
12753
13097
  }
12754
13098
  if (parsedResponse.body.action === COLLECT_ATTRIBUTES_RELATION) {
12755
13099
  return {
12756
- nextAction: VerifyNextActionV2.COLLECT_ATTRIBUTES,
13100
+ nextAction: COLLECT_ATTRIBUTES_RELATION,
12757
13101
  continuationToken,
12758
13102
  attributes: parsedResponse.body.attributes ?? [],
12759
13103
  submitAttributesHref: this.handler.requireHref(parsedResponse.body._links?.submitAttributes?.href, "submitAttributes", correlationId),
@@ -12761,21 +13105,45 @@ class CustomAuthApiClientV2 extends BaseApiClientV2 {
12761
13105
  }
12762
13106
  if (parsedResponse.body.action === UPDATE_RELATION) {
12763
13107
  return {
12764
- nextAction: VerifyNextActionV2.UPDATE,
13108
+ nextAction: UPDATE_RELATION,
12765
13109
  continuationToken,
12766
13110
  updateHref: this.handler.requireHref(parsedResponse.body._links?.update?.href, "update", correlationId),
12767
13111
  };
12768
13112
  }
12769
13113
  if (parsedResponse.body.action === CHALLENGE_RELATION) {
12770
13114
  return {
12771
- nextAction: VerifyNextActionV2.CHALLENGE,
13115
+ nextAction: CHALLENGE_RELATION,
12772
13116
  continuationToken,
12773
13117
  authenticationFactor: this.resolveAuthenticationFactor(parsedResponse.body.challengeContext?.authenticationFactor, correlationId),
12774
- methods: this.resolveMethods(parsedResponse.body, correlationId),
13118
+ methods: this.resolveMethods(this.handler.requireMethods(parsedResponse.body._embedded?.methods, correlationId), correlationId),
13119
+ };
13120
+ }
13121
+ if (parsedResponse.body.action === ENROLL_RELATION) {
13122
+ return {
13123
+ nextAction: ENROLL_RELATION,
13124
+ continuationToken,
13125
+ methods: this.resolveEnrollmentMethods(this.handler.requireMethods(parsedResponse.body._embedded?.methods, correlationId), correlationId),
12775
13126
  };
12776
13127
  }
12777
13128
  throw new CustomAuthApiError(INVALID_HAL_RESPONSE, "Invalid HAL response: verify returned no known next action", correlationId);
12778
13129
  }
13130
+ resolveEnrollmentMethods(methods, correlationId) {
13131
+ return methods.map((method) => {
13132
+ if (typeof method.type !== "string" || !method.type.trim()) {
13133
+ throw new CustomAuthApiError(INVALID_HAL_RESPONSE, "Invalid HAL response: enrollment method type is malformed", correlationId);
13134
+ }
13135
+ if (method.channels !== undefined &&
13136
+ (!Array.isArray(method.channels) ||
13137
+ method.channels.length === 0)) {
13138
+ throw new CustomAuthApiError(INVALID_HAL_RESPONSE, "Invalid HAL response: enrollment method channels are malformed", correlationId);
13139
+ }
13140
+ return {
13141
+ type: method.type,
13142
+ channels: method.channels,
13143
+ enrollHref: this.handler.requireHref(method._links?.enroll?.href, ENROLL_RELATION, correlationId),
13144
+ };
13145
+ });
13146
+ }
12779
13147
  resolveAuthenticationFactor(authenticationFactor, correlationId) {
12780
13148
  if (authenticationFactor === AuthenticationFactorV2.SINGLE_FACTOR ||
12781
13149
  authenticationFactor === AuthenticationFactorV2.MULTI_FACTOR) {
@@ -12791,7 +13159,7 @@ class CustomAuthApiClientV2 extends BaseApiClientV2 {
12791
13159
  if (parsedResponse.body.action === RISK_VERIFY_RELATION) {
12792
13160
  const riskResponse = parsedResponse.body;
12793
13161
  return {
12794
- nextAction: ChallengeNextActionV2.RISK_VERIFY,
13162
+ nextAction: RISK_VERIFY_RELATION,
12795
13163
  continuationToken: this.handler.requireContinuationToken(parsedResponse.continuationToken, parsedResponse.correlationId),
12796
13164
  riskVerifyHref: this.handler.requireHref(riskResponse._links?.riskverify?.href, RISK_VERIFY_RELATION, parsedResponse.correlationId),
12797
13165
  };
@@ -12809,18 +13177,29 @@ class CustomAuthApiClientV2 extends BaseApiClientV2 {
12809
13177
  "payload" in parsedResponse.body
12810
13178
  ? parsedResponse.body
12811
13179
  : undefined;
13180
+ const isPasswordChallenge = parsedResponse.body.type?.toLowerCase() ===
13181
+ AuthenticationMethodTypeV2.PASSWORD;
13182
+ const verifyHref = this.handler.requireHref(links?.verify?.href, VERIFY_RELATION, parsedResponse.correlationId);
13183
+ const resendHref = !isPasswordChallenge && links && "resend" in links
13184
+ ? this.handler.requireHref(links.resend?.href, RESEND_RELATION, parsedResponse.correlationId)
13185
+ : undefined;
13186
+ const codeLength = isPasswordChallenge
13187
+ ? undefined
13188
+ : this.normalizeCodeLength(codeMetadata?.codeLength ?? codeMetadata?.payload?.codeLength);
12812
13189
  return {
12813
- nextAction: ChallengeNextActionV2.VERIFY,
13190
+ nextAction: VERIFY_RELATION,
12814
13191
  continuationToken,
12815
- verifyHref: this.handler.requireHref(links?.verify?.href, "verify", parsedResponse.correlationId),
12816
- resendHref: links && "resend" in links ? links.resend?.href : undefined,
12817
- codeLength: codeMetadata?.codeLength ?? codeMetadata?.payload?.codeLength,
13192
+ verifyHref,
13193
+ resendHref,
13194
+ codeLength,
12818
13195
  hint: codeMetadata?.hint,
12819
13196
  type: parsedResponse.body.type,
12820
13197
  };
12821
13198
  }
12822
- resolveMethods(body, correlationId) {
12823
- const methods = this.handler.requireMethods(body._embedded?.methods, correlationId);
13199
+ normalizeCodeLength(value) {
13200
+ return typeof value === "number" && Number.isInteger(value) ? value : 0;
13201
+ }
13202
+ resolveMethods(methods, correlationId) {
12824
13203
  const resolved = [];
12825
13204
  methods.forEach((method, index) => {
12826
13205
  const href = method._links?.challenge?.href;
@@ -12916,6 +13295,8 @@ const FLOW_NEW_PASSWORD_REQUIRED_V2 = "FlowNewPasswordRequiredResultV2";
12916
13295
  const FLOW_ATTRIBUTES_REQUIRED_V2 = "FlowAttributesRequiredResultV2";
12917
13296
  const FLOW_SIGN_IN_CONTINUATION_REQUIRED_V2 = "FlowSignInContinuationRequiredResultV2";
12918
13297
  const FLOW_COMPLETED_V2 = "FlowCompletedResultV2";
13298
+ const FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2 = "FlowAuthMethodRegistrationRequiredResultV2";
13299
+ const FLOW_AUTH_METHOD_VERIFICATION_REQUIRED_V2 = "FlowAuthMethodVerificationRequiredResultV2";
12919
13300
  function createFlowMethodSelectionRequiredResultV2(input) {
12920
13301
  return { type: FLOW_METHOD_SELECTION_REQUIRED_V2, ...input };
12921
13302
  }
@@ -12942,6 +13323,12 @@ function createFlowSignInContinuationRequiredResultV2(input) {
12942
13323
  }
12943
13324
  function createFlowCompletedResultV2(input) {
12944
13325
  return { type: FLOW_COMPLETED_V2, ...input };
13326
+ }
13327
+ function createFlowAuthMethodRegistrationRequiredResultV2(input) {
13328
+ return { type: FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2, ...input };
13329
+ }
13330
+ function createFlowAuthMethodVerificationRequiredResultV2(input) {
13331
+ return { type: FLOW_AUTH_METHOD_VERIFICATION_REQUIRED_V2, ...input };
12945
13332
  }
12946
13333
 
12947
13334
  /*
@@ -12988,7 +13375,20 @@ const FLOW_STEP_API_IDS_V2 = {
12988
13375
  signInWithContinuation: SIGN_UP_V2_COMPLETE,
12989
13376
  },
12990
13377
  };
12991
- function getPublicApiIdV2(scenario, step) {
13378
+ const MFA_STEP_API_IDS_V2 = {
13379
+ requestChallenge: MFA_V2_SELECT_AUTH_METHOD,
13380
+ submitCode: MFA_V2_SUBMIT_CHALLENGE,
13381
+ resendCode: MFA_V2_RESEND_CHALLENGE,
13382
+ };
13383
+ /**
13384
+ * Resolves the telemetry API ID for a flow step. MFA challenge operations use
13385
+ * distinct IDs when the sign-in caller identifies the second factor.
13386
+ */
13387
+ function getPublicApiIdV2(scenario, step, authenticationFactor) {
13388
+ if (scenario === CustomAuthFlowScenarioV2.SignIn &&
13389
+ authenticationFactor === AuthenticationFactorV2.MULTI_FACTOR) {
13390
+ return (MFA_STEP_API_IDS_V2[step] ?? FLOW_STEP_API_IDS_V2[scenario]?.[step]);
13391
+ }
12992
13392
  return FLOW_STEP_API_IDS_V2[scenario]?.[step];
12993
13393
  }
12994
13394
 
@@ -13112,8 +13512,9 @@ class FlowInteractionClientV2 extends InteractionClientBaseV2 {
13112
13512
  },
13113
13513
  };
13114
13514
  const result = this.toSignUpActionResult(submitResult, continuationState, correlationId);
13115
- if (result.type === FLOW_SIGN_IN_CONTINUATION_REQUIRED_V2) {
13116
- const message = "Initial sign-up attribute submission cannot complete without code verification or additional attributes.";
13515
+ if (result.type === FLOW_SIGN_IN_CONTINUATION_REQUIRED_V2 ||
13516
+ result.type === FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2) {
13517
+ const message = `Initial sign-up attribute submission returned unsupported next action '${submitResult.nextAction}'.`;
13117
13518
  this.logger.error(message, correlationId);
13118
13519
  throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13119
13520
  }
@@ -13220,6 +13621,47 @@ class FlowInteractionClientV2 extends InteractionClientBaseV2 {
13220
13621
  this.logger.error(message, parameters.correlationId);
13221
13622
  throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, parameters.correlationId);
13222
13623
  }
13624
+ /*
13625
+ * Registers the selected offered method and returns activation metadata.
13626
+ */
13627
+ async registerAuthMethod(parameters) {
13628
+ const { continuationState, correlationId } = parameters;
13629
+ if (!parameters.verificationContact?.trim()) {
13630
+ throw new InvalidArgumentError("verificationContact", correlationId);
13631
+ }
13632
+ const registrationRequest = this.createRegistrationRequest(parameters.method, parameters.verificationContact, continuationState.continuationToken, correlationId);
13633
+ const context = this.createRequestContext(JIT_V2_ENROLL_AUTH_METHOD, correlationId);
13634
+ this.logger.verbose("0dfkz9", correlationId);
13635
+ const result = await this.apiClient.enrollAuthMethod(this.requireLink(correlationId, parameters.method.enrollHref), registrationRequest, context);
13636
+ return this.createAuthMethodVerificationRequiredResult(continuationState, result, correlationId);
13637
+ }
13638
+ /*
13639
+ * Activates the registered method and redeems the resulting continuation
13640
+ * for tokens.
13641
+ */
13642
+ async verifyAuthMethodRegistration(parameters) {
13643
+ const { continuationState, correlationId } = parameters;
13644
+ const context = this.createRequestContext(JIT_V2_SUBMIT_CHALLENGE, correlationId);
13645
+ this.logger.verbose("073pof", correlationId);
13646
+ const result = await this.apiClient.activateAuthMethod(this.requireLink(correlationId, continuationState.links.activate), {
13647
+ continuationToken: continuationState.continuationToken,
13648
+ otp: parameters.code,
13649
+ }, context);
13650
+ return this.completeSignInAfterVerification(continuationState, result.continuationToken, correlationId);
13651
+ }
13652
+ /*
13653
+ * Requests a replacement activation challenge through the server-provided
13654
+ * resend link using the latest continuation token.
13655
+ */
13656
+ async resendAuthMethodRegistrationChallenge(parameters) {
13657
+ const { continuationState, correlationId } = parameters;
13658
+ const context = this.createRequestContext(JIT_V2_RESEND_CHALLENGE, correlationId);
13659
+ this.logger.verbose("04qvjc", correlationId);
13660
+ const result = await this.apiClient.resendAuthMethodRegistrationChallenge(this.requireLink(correlationId, continuationState.links.resend), {
13661
+ continuationToken: continuationState.continuationToken,
13662
+ }, context);
13663
+ return this.createAuthMethodVerificationRequiredResult(continuationState, result, correlationId);
13664
+ }
13223
13665
  /*
13224
13666
  * Verifies the submitted one-time code using the server-provided link. The
13225
13667
  * response determines the next required action.
@@ -13227,7 +13669,7 @@ class FlowInteractionClientV2 extends InteractionClientBaseV2 {
13227
13669
  async submitCode(parameters) {
13228
13670
  const continuationState = parameters.continuationState;
13229
13671
  const correlationId = parameters.correlationId;
13230
- const context = this.createRequestContext(this.resolveStepApiId(continuationState.scenario, "submitCode", correlationId), correlationId);
13672
+ const context = this.createRequestContext(this.resolveStepApiId(continuationState.scenario, "submitCode", correlationId, parameters.authenticationFactor), correlationId);
13231
13673
  this.logger.verbose("16ks6n", correlationId);
13232
13674
  const verifyHref = this.requireLink(correlationId, continuationState.links.verify);
13233
13675
  const verifyRequest = {
@@ -13237,7 +13679,7 @@ class FlowInteractionClientV2 extends InteractionClientBaseV2 {
13237
13679
  const verifyResult = await this.apiClient.verifyChallenge(verifyHref, verifyRequest, context);
13238
13680
  if (continuationState.scenario ===
13239
13681
  CustomAuthFlowScenarioV2.PasswordReset &&
13240
- verifyResult.nextAction === VerifyNextActionV2.UPDATE) {
13682
+ verifyResult.nextAction === UPDATE_RELATION) {
13241
13683
  return createFlowNewPasswordRequiredResultV2({
13242
13684
  correlationId,
13243
13685
  continuationState: {
@@ -13251,46 +13693,8 @@ class FlowInteractionClientV2 extends InteractionClientBaseV2 {
13251
13693
  if (continuationState.scenario === CustomAuthFlowScenarioV2.SignIn) {
13252
13694
  return this.handleSignInVerification(continuationState, verifyResult, correlationId);
13253
13695
  }
13254
- if (continuationState.scenario === CustomAuthFlowScenarioV2.SignUp &&
13255
- verifyResult.nextAction === VerifyNextActionV2.COLLECT_ATTRIBUTES) {
13256
- const requiredPasswordAttribute = verifyResult.attributes.find((attribute) => attribute.attributeId.toLowerCase() === "password" &&
13257
- attribute.required === true);
13258
- const nextContinuationState = {
13259
- continuationToken: verifyResult.continuationToken,
13260
- scenario: continuationState.scenario,
13261
- scopes: continuationState.scopes,
13262
- links: {
13263
- submitAttributes: verifyResult.submitAttributesHref,
13264
- },
13265
- signUp: continuationState.signUp,
13266
- };
13267
- const attributes = verifyResult.attributes.filter((attribute) => attribute.attributeId.toLowerCase() !== "password");
13268
- if (requiredPasswordAttribute &&
13269
- continuationState.signUp?.passwordWasSupplied !== true) {
13270
- return createFlowSignUpPasswordRequiredResultV2({
13271
- correlationId,
13272
- continuationState: nextContinuationState,
13273
- attributes,
13274
- requiredPasswordAttribute,
13275
- });
13276
- }
13277
- return createFlowAttributesRequiredResultV2({
13278
- correlationId,
13279
- continuationState: nextContinuationState,
13280
- attributes,
13281
- });
13282
- }
13283
- if (continuationState.scenario === CustomAuthFlowScenarioV2.SignUp &&
13284
- verifyResult.nextAction === VerifyNextActionV2.CONTINUE) {
13285
- return createFlowSignInContinuationRequiredResultV2({
13286
- correlationId,
13287
- continuationState: {
13288
- continuationToken: verifyResult.continuationToken,
13289
- scenario: continuationState.scenario,
13290
- scopes: continuationState.scopes,
13291
- links: {},
13292
- },
13293
- });
13696
+ if (continuationState.scenario === CustomAuthFlowScenarioV2.SignUp) {
13697
+ return this.handleSignUpVerification(continuationState, verifyResult, correlationId);
13294
13698
  }
13295
13699
  const message = `Verification next action '${verifyResult.nextAction}' is not supported for the '${continuationState.scenario}' flow.`;
13296
13700
  this.logger.error(message, correlationId);
@@ -13341,34 +13745,52 @@ class FlowInteractionClientV2 extends InteractionClientBaseV2 {
13341
13745
  }, context);
13342
13746
  let pollToken = updateResult.continuationToken;
13343
13747
  let pollHref = updateResult.pollHref;
13344
- let completionToken;
13748
+ let pollResult;
13749
+ let isPolling = false;
13345
13750
  for (let attempt = 1; attempt <= POLL_MAX_ATTEMPTS; attempt++) {
13346
- const pollResult = await this.apiClient.poll(pollHref, { continuationToken: pollToken }, context);
13347
- if (pollResult.isCompleted) {
13348
- completionToken = pollResult.continuationToken;
13751
+ pollResult = await this.apiClient.poll(pollHref, { continuationToken: pollToken }, context);
13752
+ isPolling = pollResult.nextAction === POLL_RELATION;
13753
+ if (!isPolling) {
13349
13754
  break;
13350
13755
  }
13351
13756
  pollToken = pollResult.continuationToken;
13352
- pollHref = pollResult.pollHref ?? pollHref;
13757
+ pollHref = this.requireLink(correlationId, pollResult.pollHref);
13353
13758
  if (attempt < POLL_MAX_ATTEMPTS) {
13354
13759
  await delay(POLL_INTERVAL_MS);
13355
13760
  }
13356
13761
  }
13357
- if (!completionToken) {
13762
+ if (!pollResult || isPolling) {
13358
13763
  const message = "The password reset did not complete within the allotted number of polling attempts.";
13359
13764
  this.logger.error(message, correlationId);
13360
13765
  throw new CustomAuthError(RESET_PASSWORD_TIMEOUT, message, correlationId);
13361
13766
  }
13362
- this.logger.verbose("0hrwdj", correlationId);
13363
- return createFlowSignInContinuationRequiredResultV2({
13364
- correlationId,
13365
- continuationState: {
13366
- continuationToken: completionToken,
13367
- scenario: continuationState.scenario,
13368
- scopes: continuationState.scopes,
13369
- links: {},
13370
- },
13371
- });
13767
+ if (pollResult.nextAction === ENROLL_RELATION &&
13768
+ pollResult.enrollmentMethods) {
13769
+ return this.createAuthMethodRegistrationRequiredResult({
13770
+ correlationId,
13771
+ continuationState: {
13772
+ ...continuationState,
13773
+ continuationToken: pollResult.continuationToken,
13774
+ links: {},
13775
+ },
13776
+ methods: pollResult.enrollmentMethods,
13777
+ });
13778
+ }
13779
+ if (pollResult.nextAction === ResponseStateV2.CONTINUE) {
13780
+ this.logger.verbose("0hrwdj", correlationId);
13781
+ return createFlowSignInContinuationRequiredResultV2({
13782
+ correlationId,
13783
+ continuationState: {
13784
+ continuationToken: pollResult.continuationToken,
13785
+ scenario: continuationState.scenario,
13786
+ scopes: continuationState.scopes,
13787
+ links: {},
13788
+ },
13789
+ });
13790
+ }
13791
+ const message = `Password reset poll next action '${pollResult.nextAction}' is not supported.`;
13792
+ this.logger.error(message, correlationId);
13793
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13372
13794
  }
13373
13795
  /*
13374
13796
  * Verifies a sign-in password and returns the next sign-in action.
@@ -13398,7 +13820,18 @@ class FlowInteractionClientV2 extends InteractionClientBaseV2 {
13398
13820
  });
13399
13821
  }
13400
13822
  async handleSignInVerification(continuationState, verifyResult, correlationId) {
13401
- if (verifyResult.nextAction === VerifyNextActionV2.CHALLENGE) {
13823
+ if (verifyResult.nextAction === ENROLL_RELATION) {
13824
+ return this.createAuthMethodRegistrationRequiredResult({
13825
+ correlationId,
13826
+ continuationState: {
13827
+ ...continuationState,
13828
+ continuationToken: verifyResult.continuationToken,
13829
+ links: {},
13830
+ },
13831
+ methods: verifyResult.methods,
13832
+ });
13833
+ }
13834
+ if (verifyResult.nextAction === CHALLENGE_RELATION) {
13402
13835
  this.ensureAuthenticationFactor(verifyResult.authenticationFactor, AuthenticationFactorV2.MULTI_FACTOR, "after sign-in verification", correlationId);
13403
13836
  return createFlowMFARequiredResultV2({
13404
13837
  correlationId,
@@ -13416,13 +13849,68 @@ class FlowInteractionClientV2 extends InteractionClientBaseV2 {
13416
13849
  })),
13417
13850
  });
13418
13851
  }
13419
- if (verifyResult.nextAction === VerifyNextActionV2.CONTINUE) {
13852
+ if (verifyResult.nextAction === ResponseStateV2.CONTINUE) {
13420
13853
  return this.completeSignInAfterVerification(continuationState, verifyResult.continuationToken, correlationId);
13421
13854
  }
13422
13855
  const message = `Verification next action '${verifyResult.nextAction}' is not supported for sign-in.`;
13423
13856
  this.logger.error(message, correlationId);
13424
13857
  throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13425
13858
  }
13859
+ handleSignUpVerification(continuationState, verifyResult, correlationId) {
13860
+ if (verifyResult.nextAction === COLLECT_ATTRIBUTES_RELATION) {
13861
+ const requiredPasswordAttribute = verifyResult.attributes.find((attribute) => attribute.attributeId.toLowerCase() === "password" &&
13862
+ attribute.required === true);
13863
+ const nextContinuationState = {
13864
+ continuationToken: verifyResult.continuationToken,
13865
+ scenario: continuationState.scenario,
13866
+ scopes: continuationState.scopes,
13867
+ links: {
13868
+ submitAttributes: verifyResult.submitAttributesHref,
13869
+ },
13870
+ signUp: continuationState.signUp,
13871
+ };
13872
+ const attributes = verifyResult.attributes.filter((attribute) => attribute.attributeId.toLowerCase() !== "password");
13873
+ if (requiredPasswordAttribute &&
13874
+ continuationState.signUp?.passwordWasSupplied !== true) {
13875
+ return createFlowSignUpPasswordRequiredResultV2({
13876
+ correlationId,
13877
+ continuationState: nextContinuationState,
13878
+ attributes,
13879
+ requiredPasswordAttribute,
13880
+ });
13881
+ }
13882
+ return createFlowAttributesRequiredResultV2({
13883
+ correlationId,
13884
+ continuationState: nextContinuationState,
13885
+ attributes,
13886
+ });
13887
+ }
13888
+ if (verifyResult.nextAction === ENROLL_RELATION) {
13889
+ return this.createAuthMethodRegistrationRequiredResult({
13890
+ correlationId,
13891
+ continuationState: {
13892
+ ...continuationState,
13893
+ continuationToken: verifyResult.continuationToken,
13894
+ links: {},
13895
+ },
13896
+ methods: verifyResult.methods,
13897
+ });
13898
+ }
13899
+ if (verifyResult.nextAction === ResponseStateV2.CONTINUE) {
13900
+ return createFlowSignInContinuationRequiredResultV2({
13901
+ correlationId,
13902
+ continuationState: {
13903
+ continuationToken: verifyResult.continuationToken,
13904
+ scenario: continuationState.scenario,
13905
+ scopes: continuationState.scopes,
13906
+ links: {},
13907
+ },
13908
+ });
13909
+ }
13910
+ const message = `Verification next action '${verifyResult.nextAction}' is not supported for the '${continuationState.scenario}' flow.`;
13911
+ this.logger.error(message, correlationId);
13912
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13913
+ }
13426
13914
  getSupportedSignInMethods(methods, correlationId) {
13427
13915
  const supportedMethods = methods.filter((method) => {
13428
13916
  const methodType = method.type.toLowerCase();
@@ -13437,6 +13925,79 @@ class FlowInteractionClientV2 extends InteractionClientBaseV2 {
13437
13925
  this.logger.error(message, correlationId);
13438
13926
  throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13439
13927
  }
13928
+ createRegistrationRequest(method, verificationContact, continuationToken, correlationId) {
13929
+ if (method.type === AuthenticationMethodTypeV2.EMAIL) {
13930
+ return {
13931
+ continuationToken,
13932
+ email: verificationContact,
13933
+ };
13934
+ }
13935
+ const [channel] = method.channels ?? [];
13936
+ if (method.type === AuthenticationMethodTypeV2.PHONE &&
13937
+ channel === PhoneRegistrationChannelV2.SMS) {
13938
+ return {
13939
+ continuationToken,
13940
+ phoneNumber: verificationContact,
13941
+ channel,
13942
+ };
13943
+ }
13944
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, "The selected authentication method is not supported for registration.", correlationId);
13945
+ }
13946
+ createAuthMethodRegistrationRequiredResult(parameters) {
13947
+ const { correlationId, continuationState } = parameters;
13948
+ const supportedMethods = parameters.methods.filter((method) => {
13949
+ const methodType = method.type.trim().toLowerCase();
13950
+ return (methodType === AuthenticationMethodTypeV2.EMAIL ||
13951
+ (methodType === AuthenticationMethodTypeV2.PHONE &&
13952
+ method.channels?.includes(PhoneRegistrationChannelV2.SMS)));
13953
+ });
13954
+ if (supportedMethods.length === 0) {
13955
+ const message = "The enrollment response did not include a supported registration method.";
13956
+ this.logger.error(message, correlationId);
13957
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13958
+ }
13959
+ const methods = supportedMethods.map((method) => {
13960
+ const methodType = method.type.trim().toLowerCase();
13961
+ const channel = method.channels?.find((candidate) => candidate === PhoneRegistrationChannelV2.SMS);
13962
+ if (methodType === AuthenticationMethodTypeV2.EMAIL) {
13963
+ return {
13964
+ type: AuthenticationMethodTypeV2.EMAIL,
13965
+ enrollHref: this.requireLink(correlationId, method.enrollHref),
13966
+ };
13967
+ }
13968
+ if (methodType === AuthenticationMethodTypeV2.PHONE &&
13969
+ channel === PhoneRegistrationChannelV2.SMS) {
13970
+ return {
13971
+ type: AuthenticationMethodTypeV2.PHONE,
13972
+ channels: [channel],
13973
+ enrollHref: this.requireLink(correlationId, method.enrollHref),
13974
+ };
13975
+ }
13976
+ const message = "The enrollment response included an unsupported registration method.";
13977
+ this.logger.error(message, correlationId);
13978
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13979
+ });
13980
+ return createFlowAuthMethodRegistrationRequiredResultV2({
13981
+ correlationId,
13982
+ continuationState,
13983
+ methods,
13984
+ });
13985
+ }
13986
+ createAuthMethodVerificationRequiredResult(continuationState, result, correlationId) {
13987
+ return createFlowAuthMethodVerificationRequiredResultV2({
13988
+ correlationId,
13989
+ continuationState: {
13990
+ ...continuationState,
13991
+ continuationToken: result.continuationToken,
13992
+ links: {
13993
+ activate: this.requireLink(correlationId, result.activateHref),
13994
+ resend: result.resendHref,
13995
+ },
13996
+ },
13997
+ sentTo: result.hint,
13998
+ codeLength: result.codeLength,
13999
+ });
14000
+ }
13440
14001
  toSignUpActionResult(result, continuationState, correlationId) {
13441
14002
  const nextAction = result.nextAction;
13442
14003
  if (result.nextAction === SignUpSubmitAttributesNextActionV2.VERIFY) {
@@ -13457,6 +14018,17 @@ class FlowInteractionClientV2 extends InteractionClientBaseV2 {
13457
14018
  codeLength: result.codeLength,
13458
14019
  });
13459
14020
  }
14021
+ if (result.nextAction === SignUpSubmitAttributesNextActionV2.ENROLL) {
14022
+ return this.createAuthMethodRegistrationRequiredResult({
14023
+ correlationId,
14024
+ continuationState: {
14025
+ ...continuationState,
14026
+ continuationToken: result.continuationToken,
14027
+ links: {},
14028
+ },
14029
+ methods: result.methods,
14030
+ });
14031
+ }
13460
14032
  if (result.nextAction ===
13461
14033
  SignUpSubmitAttributesNextActionV2.COLLECT_ATTRIBUTES) {
13462
14034
  const requiredPasswordAttribute = result.attributes.find((attribute) => attribute.attributeId.toLowerCase() === "password" &&
@@ -13535,16 +14107,16 @@ class FlowInteractionClientV2 extends InteractionClientBaseV2 {
13535
14107
  const challengeHref = step === "resendCode"
13536
14108
  ? continuationState.links.resend
13537
14109
  : continuationState.links.challenge;
13538
- const context = this.createRequestContext(this.resolveStepApiId(continuationState.scenario, step, correlationId), correlationId);
14110
+ const context = this.createRequestContext(this.resolveStepApiId(continuationState.scenario, step, correlationId, parameters.authenticationFactor), correlationId);
13539
14111
  this.logger.verbose(step === "0d2mys"
13540
14112
  ? "Resending V2 one-time code."
13541
14113
  : "Requesting V2 challenge.", correlationId);
13542
14114
  const challengeResult = await this.apiClient.requestChallenge(this.requireLink(correlationId, challengeHref), { continuationToken: continuationState.continuationToken }, context);
13543
14115
  const nextAction = challengeResult.nextAction;
13544
- if (challengeResult.nextAction === ChallengeNextActionV2.VERIFY) {
14116
+ if (challengeResult.nextAction === VERIFY_RELATION) {
13545
14117
  return challengeResult;
13546
14118
  }
13547
- if (challengeResult.nextAction === ChallengeNextActionV2.RISK_VERIFY) {
14119
+ if (challengeResult.nextAction === RISK_VERIFY_RELATION) {
13548
14120
  return this.apiClient.verifyRisk(challengeResult.riskVerifyHref, { continuationToken: challengeResult.continuationToken }, context);
13549
14121
  }
13550
14122
  const message = `Challenge next action '${nextAction}' is not supported.`;
@@ -13567,8 +14139,8 @@ class FlowInteractionClientV2 extends InteractionClientBaseV2 {
13567
14139
  }),
13568
14140
  };
13569
14141
  }
13570
- resolveStepApiId(scenario, step, correlationId) {
13571
- const apiId = getPublicApiIdV2(scenario, step);
14142
+ resolveStepApiId(scenario, step, correlationId, authenticationFactor) {
14143
+ const apiId = getPublicApiIdV2(scenario, step, authenticationFactor);
13572
14144
  if (apiId === undefined) {
13573
14145
  const message = `No telemetry API id is registered for step '${step}' of the '${scenario}' flow.`;
13574
14146
  this.logger.error(message, correlationId);
@@ -13577,7 +14149,7 @@ class FlowInteractionClientV2 extends InteractionClientBaseV2 {
13577
14149
  return apiId;
13578
14150
  }
13579
14151
  requireLink(correlationId, href, missingLinkError) {
13580
- if (!href) {
14152
+ if (typeof href !== "string" || !href.trim()) {
13581
14153
  const errorCode = missingLinkError?.code ?? CONTINUATION_LINK_MISSING;
13582
14154
  const message = missingLinkError?.message ??
13583
14155
  "The continuation state is missing a link required to advance the flow.";
@@ -13863,6 +14435,141 @@ class CompletedStateV2 extends AuthFlowStateBase {
13863
14435
  }
13864
14436
  }
13865
14437
 
14438
+ /*
14439
+ * Copyright (c) Microsoft Corporation. All rights reserved.
14440
+ * Licensed under the MIT License.
14441
+ */
14442
+ /**
14443
+ * State returned when a newly registered authentication method must be
14444
+ * activated with the challenge sent by the service.
14445
+ */
14446
+ class AuthMethodVerificationRequiredStateV2 extends AuthFlowActionRequiredStateBase {
14447
+ constructor(stateParameters) {
14448
+ super(stateParameters);
14449
+ this.stateType = "authMethodVerificationRequired";
14450
+ this.type = stateParameters.type;
14451
+ this.sentTo = stateParameters.sentTo;
14452
+ this.codeLength = stateParameters.codeLength;
14453
+ }
14454
+ /**
14455
+ * Submits the activation challenge for the registered method.
14456
+ * @param challenge - The activation challenge to submit.
14457
+ * @returns The completed authentication result or a failed state.
14458
+ */
14459
+ async submitChallenge(challenge) {
14460
+ const { correlationId, continuationState, flowClient, logger } = this.stateParameters;
14461
+ try {
14462
+ ensureArgumentIsNotNullOrUndefined("challenge", challenge, correlationId);
14463
+ logger.verbose("0c4x62", correlationId);
14464
+ const result = await flowClient.verifyAuthMethodRegistration({
14465
+ correlationId,
14466
+ continuationState,
14467
+ code: challenge,
14468
+ });
14469
+ const account = new CustomAuthAccountData(result.authenticationResult.account, this.stateParameters.config, this.stateParameters.cacheClient, logger, correlationId);
14470
+ return new CustomAuthResultV2(new CompletedStateV2(), account, continuationState.scenario);
14471
+ }
14472
+ catch (error) {
14473
+ logger.errorPii(`1mwqno ${error}`, correlationId);
14474
+ return CustomAuthResultV2.createWithError(error, {
14475
+ scenario: continuationState.scenario,
14476
+ correlationId,
14477
+ });
14478
+ }
14479
+ }
14480
+ /**
14481
+ * Requests a replacement activation challenge using the retained server
14482
+ * resend link.
14483
+ * @returns Refreshed activation metadata or a failed state.
14484
+ */
14485
+ async resendChallenge() {
14486
+ const { correlationId, continuationState, flowClient, logger } = this.stateParameters;
14487
+ try {
14488
+ logger.verbose("04qvjc", correlationId);
14489
+ const result = await flowClient.resendAuthMethodRegistrationChallenge({
14490
+ correlationId,
14491
+ continuationState,
14492
+ });
14493
+ return new CustomAuthResultV2(new AuthMethodVerificationRequiredStateV2({
14494
+ correlationId: result.correlationId,
14495
+ logger,
14496
+ config: this.stateParameters.config,
14497
+ flowClient,
14498
+ cacheClient: this.stateParameters.cacheClient,
14499
+ continuationState: result.continuationState,
14500
+ type: this.type,
14501
+ sentTo: result.sentTo ?? this.sentTo,
14502
+ codeLength: result.codeLength,
14503
+ }), undefined, result.continuationState.scenario);
14504
+ }
14505
+ catch (error) {
14506
+ logger.errorPii(`1m3w34 ${error}`, correlationId);
14507
+ return CustomAuthResultV2.createWithError(error, {
14508
+ scenario: continuationState.scenario,
14509
+ correlationId,
14510
+ });
14511
+ }
14512
+ }
14513
+ }
14514
+
14515
+ /*
14516
+ * Copyright (c) Microsoft Corporation. All rights reserved.
14517
+ * Licensed under the MIT License.
14518
+ */
14519
+ /**
14520
+ * State returned when an authentication method must be registered. Applications
14521
+ * select one of the sanitized offered methods and provide its contact value.
14522
+ */
14523
+ class AuthMethodRegistrationRequiredStateV2 extends AuthFlowActionRequiredStateBase {
14524
+ constructor(stateParameters) {
14525
+ super(stateParameters);
14526
+ this.stateType = "authMethodRegistrationRequired";
14527
+ this.methods = stateParameters.methods;
14528
+ }
14529
+ /**
14530
+ * Selects an authentication method for strong-auth registration and requests
14531
+ * its activation challenge.
14532
+ * @param method - A method from {@link methods}.
14533
+ * @param verificationContact - The email address or phone number to register.
14534
+ * @returns The registration activation result.
14535
+ */
14536
+ async selectAuthMethod(method, verificationContact) {
14537
+ const { correlationId, continuationState, flowClient, logger } = this.stateParameters;
14538
+ try {
14539
+ const selectedMethod = this.methods.find((candidate) => candidate.type === method.type);
14540
+ if (!selectedMethod) {
14541
+ throw new InvalidArgumentError("method", correlationId);
14542
+ }
14543
+ ensureArgumentIsNotEmptyString("verificationContact", verificationContact, correlationId);
14544
+ logger.verbose("1lzpbc", correlationId);
14545
+ const result = await flowClient.registerAuthMethod({
14546
+ correlationId,
14547
+ continuationState,
14548
+ method: selectedMethod,
14549
+ verificationContact,
14550
+ });
14551
+ return new CustomAuthResultV2(new AuthMethodVerificationRequiredStateV2({
14552
+ correlationId: result.correlationId,
14553
+ logger,
14554
+ config: this.stateParameters.config,
14555
+ flowClient,
14556
+ cacheClient: this.stateParameters.cacheClient,
14557
+ continuationState: result.continuationState,
14558
+ type: selectedMethod.type,
14559
+ sentTo: result.sentTo,
14560
+ codeLength: result.codeLength,
14561
+ }), undefined, result.continuationState.scenario);
14562
+ }
14563
+ catch (error) {
14564
+ logger.errorPii(`03yx60 ${error}`, correlationId);
14565
+ return CustomAuthResultV2.createWithError(error, {
14566
+ scenario: continuationState.scenario,
14567
+ correlationId,
14568
+ });
14569
+ }
14570
+ }
14571
+ }
14572
+
13866
14573
  /*
13867
14574
  * Copyright (c) Microsoft Corporation. All rights reserved.
13868
14575
  * Licensed under the MIT License.
@@ -13910,8 +14617,8 @@ class SignInContinuationStateV2 extends AuthFlowActionRequiredStateBase {
13910
14617
  */
13911
14618
  /**
13912
14619
  * State returned when the user must supply a new password to complete the flow.
13913
- * A successful submission returns `SignInContinuationStateV2` so the app can
13914
- * sign the user in.
14620
+ * A successful submission can require registration or return a continuation
14621
+ * for sign-in.
13915
14622
  */
13916
14623
  class NewPasswordRequiredStateV2 extends AuthFlowActionRequiredStateBase {
13917
14624
  constructor() {
@@ -13919,8 +14626,8 @@ class NewPasswordRequiredStateV2 extends AuthFlowActionRequiredStateBase {
13919
14626
  this.stateType = "newPasswordRequired";
13920
14627
  }
13921
14628
  /**
13922
- * Submits the new password to complete the reset. The result either allows
13923
- * sign-in or reports that the password was rejected.
14629
+ * Submits the new password to complete the reset. Enrollment may be
14630
+ * required before sign-in; a rejected password returns an error.
13924
14631
  * @param password - The new password to set.
13925
14632
  * @returns The result of submitting the new password.
13926
14633
  */
@@ -13934,14 +14641,29 @@ class NewPasswordRequiredStateV2 extends AuthFlowActionRequiredStateBase {
13934
14641
  continuationState,
13935
14642
  newPassword: password,
13936
14643
  });
13937
- return new CustomAuthResultV2(new SignInContinuationStateV2({
13938
- correlationId: result.correlationId,
13939
- logger,
13940
- config: this.stateParameters.config,
13941
- flowClient,
13942
- continuationState: result.continuationState,
13943
- cacheClient: this.stateParameters.cacheClient,
13944
- }), undefined, result.continuationState.scenario);
14644
+ const resultType = result.type;
14645
+ if (result.type === FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2) {
14646
+ return new CustomAuthResultV2(new AuthMethodRegistrationRequiredStateV2({
14647
+ correlationId: result.correlationId,
14648
+ logger,
14649
+ config: this.stateParameters.config,
14650
+ flowClient,
14651
+ continuationState: result.continuationState,
14652
+ cacheClient: this.stateParameters.cacheClient,
14653
+ methods: result.methods,
14654
+ }), undefined, result.continuationState.scenario);
14655
+ }
14656
+ if (result.type === FLOW_SIGN_IN_CONTINUATION_REQUIRED_V2) {
14657
+ return new CustomAuthResultV2(new SignInContinuationStateV2({
14658
+ correlationId: result.correlationId,
14659
+ logger,
14660
+ config: this.stateParameters.config,
14661
+ flowClient,
14662
+ continuationState: result.continuationState,
14663
+ cacheClient: this.stateParameters.cacheClient,
14664
+ }), undefined, result.continuationState.scenario);
14665
+ }
14666
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, `Password submission result type '${resultType}' is not supported.`, correlationId);
13945
14667
  }
13946
14668
  catch (error) {
13947
14669
  logger.errorPii(`03m081 ${error}`, correlationId);
@@ -13965,18 +14687,20 @@ class ChallengeVerificationStateBaseV2 extends AuthFlowActionRequiredStateBase {
13965
14687
  this.channel = stateParameters.channel;
13966
14688
  this.codeLength = stateParameters.codeLength;
13967
14689
  }
13968
- async submitCodeCore(code) {
14690
+ async submitCodeCore(code, authenticationFactor) {
13969
14691
  ensureArgumentIsNotNullOrUndefined("code", code, this.stateParameters.correlationId);
13970
14692
  return this.stateParameters.flowClient.submitCode({
13971
14693
  correlationId: this.stateParameters.correlationId,
13972
14694
  continuationState: this.stateParameters.continuationState,
14695
+ authenticationFactor,
13973
14696
  code,
13974
14697
  });
13975
14698
  }
13976
- async resendCodeCore() {
14699
+ async resendCodeCore(authenticationFactor) {
13977
14700
  return this.stateParameters.flowClient.resendCode({
13978
14701
  correlationId: this.stateParameters.correlationId,
13979
14702
  continuationState: this.stateParameters.continuationState,
14703
+ authenticationFactor,
13980
14704
  });
13981
14705
  }
13982
14706
  }
@@ -14037,6 +14761,17 @@ class CodeRequiredStateV2 extends ChallengeVerificationStateBaseV2 {
14037
14761
  cacheClient: this.stateParameters.cacheClient,
14038
14762
  }), undefined, result.continuationState.scenario);
14039
14763
  }
14764
+ if (result.type === FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2) {
14765
+ return new CustomAuthResultV2(new AuthMethodRegistrationRequiredStateV2({
14766
+ correlationId: result.correlationId,
14767
+ logger,
14768
+ config: this.stateParameters.config,
14769
+ flowClient: this.stateParameters.flowClient,
14770
+ continuationState: result.continuationState,
14771
+ cacheClient: this.stateParameters.cacheClient,
14772
+ methods: result.methods,
14773
+ }), undefined, result.continuationState.scenario);
14774
+ }
14040
14775
  if (result.type === FLOW_MFA_REQUIRED_V2) {
14041
14776
  const signInStateTransitionHandler = this.stateParameters.signInStateTransitionHandler;
14042
14777
  if (!signInStateTransitionHandler) {
@@ -14116,7 +14851,7 @@ class MFAVerificationRequiredStateV2 extends ChallengeVerificationStateBaseV2 {
14116
14851
  const { correlationId, logger, continuationState } = this.stateParameters;
14117
14852
  try {
14118
14853
  logger.verbose("10k0lc", correlationId);
14119
- const result = await this.submitCodeCore(challenge);
14854
+ const result = await this.submitCodeCore(challenge, AuthenticationFactorV2.MULTI_FACTOR);
14120
14855
  if (result.type !== FLOW_COMPLETED_V2) {
14121
14856
  throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, `MFA challenge submission result type '${result.type}' is not supported.`, correlationId);
14122
14857
  }
@@ -14140,7 +14875,7 @@ class MFAVerificationRequiredStateV2 extends ChallengeVerificationStateBaseV2 {
14140
14875
  const { correlationId, logger, continuationState } = this.stateParameters;
14141
14876
  try {
14142
14877
  logger.verbose("13st9u", correlationId);
14143
- const result = await this.resendCodeCore();
14878
+ const result = await this.resendCodeCore(AuthenticationFactorV2.MULTI_FACTOR);
14144
14879
  return new CustomAuthResultV2(new MFAVerificationRequiredStateV2({
14145
14880
  correlationId: result.correlationId,
14146
14881
  logger,
@@ -14255,13 +14990,14 @@ class AuthMethodSelectionRequiredStateV2 extends AuthFlowActionRequiredStateBase
14255
14990
  }
14256
14991
  }
14257
14992
  async requestSelectedMethodChallenge(method) {
14258
- const { correlationId, continuationState, flowClient } = this.stateParameters;
14993
+ const { correlationId, continuationState, flowClient, authenticationFactor, } = this.stateParameters;
14259
14994
  const selectedMethod = this.methods.find((candidate) => candidate.id === method.id);
14260
14995
  if (!selectedMethod) {
14261
14996
  throw new InvalidArgumentError("method", correlationId);
14262
14997
  }
14263
14998
  const result = await flowClient.requestChallenge({
14264
14999
  correlationId,
15000
+ authenticationFactor,
14265
15001
  continuationState: {
14266
15002
  ...continuationState,
14267
15003
  links: {
@@ -14306,6 +15042,17 @@ class PasswordRequiredStateV2 extends AuthFlowActionRequiredStateBase {
14306
15042
  const account = new CustomAuthAccountData(result.authenticationResult.account, this.stateParameters.config, this.stateParameters.cacheClient, logger, correlationId);
14307
15043
  return new CustomAuthResultV2(new CompletedStateV2(), account, continuationState.scenario);
14308
15044
  }
15045
+ if (result.type === FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2) {
15046
+ return new CustomAuthResultV2(new AuthMethodRegistrationRequiredStateV2({
15047
+ correlationId: result.correlationId,
15048
+ logger,
15049
+ config: this.stateParameters.config,
15050
+ flowClient,
15051
+ continuationState: result.continuationState,
15052
+ cacheClient: this.stateParameters.cacheClient,
15053
+ methods: result.methods,
15054
+ }), undefined, result.continuationState.scenario);
15055
+ }
14309
15056
  if (result.type === FLOW_MFA_REQUIRED_V2) {
14310
15057
  return new CustomAuthResultV2(new AuthMethodSelectionRequiredStateV2({
14311
15058
  correlationId: result.correlationId,
@@ -14462,6 +15209,12 @@ class SignUpStateTransitionHandlerV2 {
14462
15209
  if (result.type === FLOW_SIGN_IN_CONTINUATION_REQUIRED_V2) {
14463
15210
  return new CustomAuthResultV2(new SignInContinuationStateV2(commonStateParameters), undefined, result.continuationState.scenario);
14464
15211
  }
15212
+ if (result.type === FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2) {
15213
+ return new CustomAuthResultV2(new AuthMethodRegistrationRequiredStateV2({
15214
+ ...commonStateParameters,
15215
+ methods: result.methods,
15216
+ }), undefined, result.continuationState.scenario);
15217
+ }
14465
15218
  throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, `Sign-up ${submission} submission result type '${result.type}' is not supported.`, stateParameters.correlationId);
14466
15219
  }
14467
15220
  handleVerification(result, stateParameters) {
@@ -18935,7 +19688,7 @@ class BrowserCacheManager extends CacheManager {
18935
19688
  throw cacheError;
18936
19689
  }
18937
19690
  // When cache quota is exceeded, start removing access tokens until we can successfully set the item
18938
- this.removeAccessToken(accessTokenKeys[i], correlationId, false // Don't save token keys yet, do it at the end
19691
+ await this.removeAccessTokenAndTokenBindingKey(accessTokenKeys[i], correlationId, undefined, false // Don't save token keys yet, do it at the end
18939
19692
  );
18940
19693
  }
18941
19694
  else {
@@ -19077,6 +19830,13 @@ class BrowserCacheManager extends CacheManager {
19077
19830
  super.removeAccessToken(key, correlationId);
19078
19831
  updateTokenKeys && this.removeAccessTokenKeys([key], correlationId);
19079
19832
  }
19833
+ /**
19834
+ * Removes an access token and awaits token-binding key cleanup.
19835
+ */
19836
+ async removeAccessTokenAndTokenBindingKey(key, correlationId, preservedKeyId, updateTokenKeys = true) {
19837
+ await super.removeAccessTokenAndTokenBindingKey(key, correlationId, preservedKeyId);
19838
+ updateTokenKeys && this.removeAccessTokenKeys([key], correlationId);
19839
+ }
19080
19840
  /**
19081
19841
  * Remove access token key from the key map
19082
19842
  * @param key
@@ -19811,6 +20571,116 @@ function getActiveAccount(browserStorage, correlationId) {
19811
20571
  return browserStorage.getActiveAccount(correlationId);
19812
20572
  }
19813
20573
 
20574
+ /*
20575
+ * Copyright (c) Microsoft Corporation. All rights reserved.
20576
+ * Licensed under the MIT License.
20577
+ */
20578
+ const POPUP_POLL_INTERVAL_MS = 30;
20579
+ let activePopupPoller;
20580
+ /**
20581
+ * Cancels legacy popup polling when an interaction is superseded.
20582
+ *
20583
+ * @internal
20584
+ * @param logger Logger for the interaction.
20585
+ */
20586
+ function cancelPendingPopupPollingResponse(logger) {
20587
+ if (activePopupPoller) {
20588
+ logger.verbose("0g9n3p", activePopupPoller.correlationId);
20589
+ activePopupPoller.cancel();
20590
+ }
20591
+ }
20592
+ /**
20593
+ * Monitors a popup window for a URL change to the same origin as the parent application.
20594
+ * Polls the popup at a specified interval until it is redirected back to the application,
20595
+ * closed by the user, or a navigation to a same-origin URL is detected. Once a same-origin
20596
+ * URL is detected, extracts the response string (query or hash) and resolves the promise.
20597
+ *
20598
+ * @param popupWindow - The popup window to monitor for navigation.
20599
+ * @param popupWindowParent - The parent window that opened the popup.
20600
+ * @param responseMode - Response mode (`"query"` | `"fragment"`) determines whether
20601
+ * to read `location.search` or `location.hash` from the popup once on the same
20602
+ * origin. Any value other than `"query"` is treated as fragment.
20603
+ * @param logger - Logger instance.
20604
+ * @param unloadWindow - Event handler to remove from the parent window on cleanup.
20605
+ * @param correlationId
20606
+ */
20607
+ async function monitorPopupForHash(popupWindow, popupWindowParent, responseMode, logger, unloadWindow, correlationId) {
20608
+ let poller;
20609
+ return new Promise((resolve, reject) => {
20610
+ logger.verbose("0cp91u", correlationId);
20611
+ const intervalId = window.setInterval(() => {
20612
+ if (popupWindow.closed) {
20613
+ logger.error("0n69wb", correlationId);
20614
+ window.clearInterval(intervalId);
20615
+ reject(new BrowserAuthError(userCancelled, correlationId));
20616
+ return;
20617
+ }
20618
+ let href = "";
20619
+ try {
20620
+ /*
20621
+ * Will throw if cross origin,
20622
+ * which should be caught and ignored
20623
+ * since we need the interval to keep running while on STS UI.
20624
+ */
20625
+ href = popupWindow.location.href;
20626
+ }
20627
+ catch (e) { }
20628
+ // Don't process blank pages or cross domain
20629
+ if (!href || href === "about:blank") {
20630
+ return;
20631
+ }
20632
+ window.clearInterval(intervalId);
20633
+ let responseString;
20634
+ if (responseMode === ResponseMode.QUERY) {
20635
+ responseString = popupWindow.location.search;
20636
+ }
20637
+ else {
20638
+ responseString = popupWindow.location.hash;
20639
+ }
20640
+ logger.verbose("0po9er", correlationId);
20641
+ resolve(responseString);
20642
+ }, POPUP_POLL_INTERVAL_MS);
20643
+ poller = {
20644
+ correlationId,
20645
+ cancel: () => {
20646
+ window.clearInterval(intervalId);
20647
+ if (activePopupPoller === poller) {
20648
+ activePopupPoller = undefined;
20649
+ }
20650
+ reject(new BrowserAuthError(interactionInProgressCancelled, correlationId));
20651
+ },
20652
+ };
20653
+ activePopupPoller = poller;
20654
+ }).finally(() => {
20655
+ if (poller && activePopupPoller === poller) {
20656
+ activePopupPoller = undefined;
20657
+ }
20658
+ cleanPopup(popupWindow, popupWindowParent, unloadWindow);
20659
+ });
20660
+ }
20661
+ /**
20662
+ * Performs cleanup operations after popup authentication.
20663
+ * Strips auth-response params (code/state) from the popup URL while it is still
20664
+ * open, closes the popup window, and removes the 'beforeunload' event listener
20665
+ * from the parent window.
20666
+ *
20667
+ * @param popupWindow - The popup window to be closed.
20668
+ * @param popupWindowParent - The parent window from which the event listener will be removed.
20669
+ * @param unloadWindow - The event handler function to remove.
20670
+ */
20671
+ function cleanPopup(popupWindow, popupWindowParent, unloadWindow) {
20672
+ if (!popupWindow.closed) {
20673
+ try {
20674
+ clearAuthResponseFromUrl(popupWindow);
20675
+ }
20676
+ catch {
20677
+ // Popup may have become cross-origin or otherwise inaccessible; ignore.
20678
+ }
20679
+ }
20680
+ popupWindow.close();
20681
+ popupWindowParent.removeEventListener("beforeunload", unloadWindow);
20682
+ }
20683
+
19814
20684
  /*
19815
20685
  * Copyright (c) Microsoft Corporation. All rights reserved.
19816
20686
  * Licensed under the MIT License.
@@ -20231,12 +21101,26 @@ class InteractionHandler {
20231
21101
  * Copyright (c) Microsoft Corporation. All rights reserved.
20232
21102
  * Licensed under the MIT License.
20233
21103
  */
21104
+ /**
21105
+ * Key storage enclaves supported by the platform broker.
21106
+ */
21107
+ const PlatformAuthEnclave = {
21108
+ /**
21109
+ * Persisted software key using MS_KEY_STORAGE_PROVIDER.
21110
+ */
21111
+ SOFTWARE: "sw"};
20234
21112
  /**
20235
21113
  * Token types supported by the platform broker request contract.
20236
21114
  */
20237
21115
  const PlatformAuthTokenType = {
20238
21116
  DPOP_WITH_PROOF: "dpop+proof",
20239
21117
  };
21118
+ /**
21119
+ * Token binding preferences supported by the platform broker.
21120
+ */
21121
+ const PlatformAuthBindingPreference = {
21122
+ ATTESTED: "attested",
21123
+ };
20240
21124
  const PROOF_OF_POSSESSION_TOKEN_TYPES = [
20241
21125
  AuthenticationScheme.POP,
20242
21126
  AuthenticationScheme.DPOP,
@@ -20252,19 +21136,19 @@ function isProofOfPossessionTokenType(tokenType) {
20252
21136
  /**
20253
21137
  * Adds canonical proof request fields to the broker no-cache property bag.
20254
21138
  */
20255
- function createPlatformAuthExtraParametersNoCache(extraParametersNoCache, isProofOfPossessionRequest, resourceRequestMethod, resourceRequestUri, dpopNonce) {
20256
- if (!isProofOfPossessionRequest) {
20257
- return extraParametersNoCache;
21139
+ function createPlatformAuthExtraParametersNoCache(tokenType, resourceRequestMethod, resourceRequestUri, dpopNonce) {
21140
+ if (!isProofOfPossessionTokenType(tokenType)) {
21141
+ return undefined;
20258
21142
  }
20259
21143
  return {
20260
- ...extraParametersNoCache,
20261
21144
  ...(resourceRequestMethod && {
20262
21145
  pop_method: resourceRequestMethod,
20263
21146
  }),
20264
21147
  ...(resourceRequestUri && {
20265
21148
  pop_url: resourceRequestUri,
20266
21149
  }),
20267
- ...(dpopNonce && {
21150
+ ...(tokenType === PlatformAuthTokenType.DPOP_WITH_PROOF &&
21151
+ dpopNonce && {
20268
21152
  pop_nonce: dpopNonce,
20269
21153
  }),
20270
21154
  };
@@ -20411,6 +21295,7 @@ class SilentCacheClient extends StandardInteractionClient {
20411
21295
  * Copyright (c) Microsoft Corporation. All rights reserved.
20412
21296
  * Licensed under the MIT License.
20413
21297
  */
21298
+ const DPOP_POP_KID_NOT_SUPPORTED = "dpop_pop_kid_not_supported";
20414
21299
  class PlatformAuthInteractionClient extends BaseInteractionClient {
20415
21300
  constructor(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, apiId, performanceClient, provider, accountId, nativeStorageImpl, correlationId, tokenBindingKeyManager) {
20416
21301
  super(config, browserStorage, browserCrypto, logger, eventHandler, navigationClient, performanceClient, correlationId, provider, tokenBindingKeyManager);
@@ -20469,17 +21354,9 @@ class PlatformAuthInteractionClient extends BaseInteractionClient {
20469
21354
  throw e;
20470
21355
  }
20471
21356
  // check if the tokens can be retrieved from internal cache
21357
+ let cachedResult;
20472
21358
  try {
20473
- const result = await this.acquireTokensFromCache(this.accountId, nativeRequest);
20474
- // Served from the native internal cache; token did not come directly from the broker
20475
- nativeATMeasurement.add({
20476
- isNativeBroker: false,
20477
- });
20478
- nativeATMeasurement.end({
20479
- success: true,
20480
- fromCache: true,
20481
- });
20482
- return result;
21359
+ cachedResult = await this.acquireTokensFromCache(this.accountId, nativeRequest);
20483
21360
  }
20484
21361
  catch (e) {
20485
21362
  if (cacheLookupPolicy === CacheLookupPolicy.AccessToken) {
@@ -20490,13 +21367,28 @@ class PlatformAuthInteractionClient extends BaseInteractionClient {
20490
21367
  nativeATMeasurement.end({
20491
21368
  success: false,
20492
21369
  });
21370
+ await this.resetGeneratedDpopRequestKeyBestEffort(nativeRequest);
20493
21371
  throw e;
20494
21372
  }
20495
21373
  // continue with a native call for any and all errors
20496
21374
  this.logger.info("0957j1", this.correlationId);
20497
21375
  }
21376
+ if (cachedResult) {
21377
+ // Served from the native internal cache; token did not come directly from the broker
21378
+ nativeATMeasurement.add({
21379
+ isNativeBroker: false,
21380
+ });
21381
+ nativeATMeasurement.end({
21382
+ success: true,
21383
+ fromCache: true,
21384
+ });
21385
+ await this.resetGeneratedDpopRequestKey(nativeRequest);
21386
+ return cachedResult;
21387
+ }
20498
21388
  // dispatch the request to the broker
20499
21389
  try {
21390
+ await this.prepareDpopBrokerRequest(nativeRequest);
21391
+ this.addDpopBrokerAttemptTelemetry(nativeRequest);
20500
21392
  const validatedResponse = await this.platformAuthProvider.sendMessage(nativeRequest);
20501
21393
  const result = await invokeAsync(this.handleNativeResponse.bind(this), PlatformAuthHandleNativeResponse, this.logger, this.performanceClient, this.correlationId)(validatedResponse, nativeRequest, reqTimestamp, request.storeInCache);
20502
21394
  nativeATMeasurement.end({
@@ -20514,6 +21406,7 @@ class PlatformAuthInteractionClient extends BaseInteractionClient {
20514
21406
  success: false,
20515
21407
  }, e);
20516
21408
  this.setBrokerErrorTelemetry(e);
21409
+ await this.resetGeneratedDpopRequestKeyBestEffort(nativeRequest);
20517
21410
  throw e;
20518
21411
  }
20519
21412
  }
@@ -20548,6 +21441,7 @@ class PlatformAuthInteractionClient extends BaseInteractionClient {
20548
21441
  scopes: ScopeSet.fromString(request.scope, this.correlationId).asArray(),
20549
21442
  account: cachedAccount,
20550
21443
  forceRefresh: false,
21444
+ ...this.createSilentCacheTokenBindingParameters(request),
20551
21445
  resource: request.extraParameters?.resource,
20552
21446
  };
20553
21447
  // Preserve FMI partition semantics for silent cache filtering.
@@ -20556,6 +21450,29 @@ class PlatformAuthInteractionClient extends BaseInteractionClient {
20556
21450
  }
20557
21451
  return silentRequest;
20558
21452
  }
21453
+ /**
21454
+ * Maps platform-broker token-binding state to silent-cache request fields.
21455
+ * @param request
21456
+ */
21457
+ createSilentCacheTokenBindingParameters(request) {
21458
+ const authenticationScheme = this.isDpopBrokerRequest(request)
21459
+ ? AuthenticationScheme.DPOP
21460
+ : request.tokenType;
21461
+ if (authenticationScheme !== AuthenticationScheme.DPOP &&
21462
+ authenticationScheme !== AuthenticationScheme.POP) {
21463
+ return { authenticationScheme };
21464
+ }
21465
+ return {
21466
+ authenticationScheme,
21467
+ ...(authenticationScheme === AuthenticationScheme.DPOP &&
21468
+ request.keyId && { dpopJkt: request.keyId }),
21469
+ ...(authenticationScheme === AuthenticationScheme.POP &&
21470
+ request.signPopToken === false &&
21471
+ request.keyId && { popKid: request.keyId }),
21472
+ resourceRequestMethod: request.resourceRequestMethod,
21473
+ resourceRequestUri: request.resourceRequestUri,
21474
+ };
21475
+ }
20559
21476
  /**
20560
21477
  * Fetches the tokens from the cache if un-expired
20561
21478
  * @param nativeAccountId
@@ -20604,10 +21521,22 @@ class PlatformAuthInteractionClient extends BaseInteractionClient {
20604
21521
  const nativeRequest = await invokeAsync(this.initializePlatformRequest.bind(this), PlatformAuthInteractionClientInitializeRequest, this.logger, this.performanceClient, this.correlationId)(request);
20605
21522
  const navigateToLoginRequestUrl = options?.navigateToLoginRequestUrl ?? true;
20606
21523
  try {
20607
- await this.platformAuthProvider.sendMessage(nativeRequest);
21524
+ await this.prepareDpopBrokerRequest(nativeRequest);
21525
+ this.addDpopBrokerAttemptTelemetry(nativeRequest);
21526
+ const response = await this.platformAuthProvider.sendMessage(nativeRequest);
21527
+ const dpopBrokerOutcome = this.validateDpopBrokerOutcome(response, nativeRequest);
21528
+ if (dpopBrokerOutcome === "L3") {
21529
+ await this.resetGeneratedDpopRequestKey(nativeRequest);
21530
+ }
20608
21531
  }
20609
21532
  catch (e) {
20610
- // Only throw fatal errors here to allow application to fallback to regular redirect. Otherwise proceed and the error will be thrown in handleRedirectPromise
21533
+ /*
21534
+ * Raw persistent/transient broker errors are retrieved again in
21535
+ * phase two. Availability errors are thrown for controller-managed
21536
+ * web fallback, while translated cancellation, network, and
21537
+ * interaction-required errors are surfaced without being swallowed.
21538
+ */
21539
+ await this.resetGeneratedDpopRequestKeyBestEffort(nativeRequest);
20611
21540
  if (e instanceof NativeAuthError) {
20612
21541
  const serverTelemetryManager = initializeServerTelemetryManager(this.apiId, this.config.auth.clientId, this.correlationId, this.browserStorage, this.logger, undefined, this.config.system.serverTelemetryEnabled);
20613
21542
  serverTelemetryManager.setNativeBrokerErrorCode(e.errorCode);
@@ -20622,6 +21551,16 @@ class PlatformAuthInteractionClient extends BaseInteractionClient {
20622
21551
  throw e;
20623
21552
  }
20624
21553
  }
21554
+ else if (this.isDpopBrokerRequest(nativeRequest)) {
21555
+ throw e;
21556
+ }
21557
+ }
21558
+ try {
21559
+ await this.ensureRedirectDpopKeyIsPersisted(nativeRequest);
21560
+ }
21561
+ catch (e) {
21562
+ await this.resetGeneratedDpopRequestKeyBestEffort(nativeRequest);
21563
+ throw e;
20625
21564
  }
20626
21565
  this.browserStorage.setTemporaryCache(TemporaryCacheKeys.NATIVE_REQUEST, JSON.stringify({
20627
21566
  ...nativeRequest,
@@ -20636,7 +21575,14 @@ class PlatformAuthInteractionClient extends BaseInteractionClient {
20636
21575
  ? UrlString.getAbsoluteUrl(request.redirectStartPage || window.location.href, getCurrentUri(), this.correlationId)
20637
21576
  : getRedirectUri(request.redirectUri, this.config.auth.redirectUri, this.logger, this.correlationId);
20638
21577
  rootMeasurement.end({ success: true });
20639
- await this.navigationClient.navigateExternal(redirectUri, navigationOptions); // Need to treat this as external to ensure handleRedirectPromise is run again
21578
+ try {
21579
+ await this.navigationClient.navigateExternal(redirectUri, navigationOptions); // Need to treat this as external to ensure handleRedirectPromise is run again
21580
+ }
21581
+ catch (e) {
21582
+ this.browserStorage.removeItem(this.browserStorage.generateCacheKey(TemporaryCacheKeys.NATIVE_REQUEST));
21583
+ await this.resetGeneratedDpopRequestKeyBestEffort(nativeRequest);
21584
+ throw e;
21585
+ }
20640
21586
  }
20641
21587
  /**
20642
21588
  * If the previous page called native platform for a token using redirect APIs, send the same request again and return the response
@@ -20669,6 +21615,8 @@ class PlatformAuthInteractionClient extends BaseInteractionClient {
20669
21615
  this.browserStorage.removeItem(this.browserStorage.generateCacheKey(TemporaryCacheKeys.NATIVE_REQUEST));
20670
21616
  const reqTimestamp = nowSeconds();
20671
21617
  try {
21618
+ await this.prepareDpopBrokerRequest(request, true);
21619
+ this.addDpopBrokerAttemptTelemetry(request);
20672
21620
  this.logger.verbose("003x5a", this.correlationId);
20673
21621
  const response = await this.platformAuthProvider.sendMessage(request);
20674
21622
  const authResult = await invokeAsync(this.handleNativeResponse.bind(this), PlatformAuthHandleNativeResponse, this.logger, this.performanceClient, this.correlationId)(response, request, reqTimestamp, storeInCache);
@@ -20677,7 +21625,12 @@ class PlatformAuthInteractionClient extends BaseInteractionClient {
20677
21625
  return authResult;
20678
21626
  }
20679
21627
  catch (e) {
21628
+ if (e instanceof NativeAuthError) {
21629
+ const serverTelemetryManager = initializeServerTelemetryManager(this.apiId, this.config.auth.clientId, this.correlationId, this.browserStorage, this.logger, undefined, this.config.system.serverTelemetryEnabled);
21630
+ serverTelemetryManager.setNativeBrokerErrorCode(e.errorCode);
21631
+ }
20680
21632
  this.setBrokerErrorTelemetry(e);
21633
+ await this.resetGeneratedDpopRequestKeyBestEffort(request);
20681
21634
  throw e;
20682
21635
  }
20683
21636
  }
@@ -20697,6 +21650,7 @@ class PlatformAuthInteractionClient extends BaseInteractionClient {
20697
21650
  */
20698
21651
  async handleNativeResponse(response, request, reqTimestamp, storeInCache) {
20699
21652
  this.logger.trace("1bojln", this.correlationId);
21653
+ const dpopBrokerOutcome = this.validateDpopBrokerOutcome(response, request);
20700
21654
  // generate identifiers
20701
21655
  const idTokenClaims = extractTokenClaims(response.id_token, base64Decode, this.correlationId);
20702
21656
  const homeAccountIdentifier = this.createHomeAccountIdentifier(response, idTokenClaims);
@@ -20722,10 +21676,17 @@ class PlatformAuthInteractionClient extends BaseInteractionClient {
20722
21676
  response.expires_in = Number(response.expires_in);
20723
21677
  // generate authenticationResult
20724
21678
  const result = await invokeAsync(this.generateAuthenticationResult.bind(this), NativeGenerateAuthResult, this.logger, this.performanceClient, this.correlationId)(response, request, idTokenClaims, baseAccount, authority.canonicalAuthority, reqTimestamp);
21679
+ const isL3DpopResponse = dpopBrokerOutcome === "L3";
20725
21680
  // cache accounts and tokens in the appropriate storage
20726
- await invokeAsync(this.cacheAccount.bind(this), PlatformAuthCacheAccount, this.logger, this.performanceClient, this.correlationId)(baseAccount, isKmsi(idTokenClaims));
21681
+ const shouldRemoveGeneratedDpopKey = isL3DpopResponse ||
21682
+ (this.isDpopBrokerRequest(request) &&
21683
+ storeInCache?.accessToken === false);
21684
+ if (shouldRemoveGeneratedDpopKey) {
21685
+ await this.resetGeneratedDpopRequestKey(request);
21686
+ }
21687
+ await invokeAsync(this.cacheAccount.bind(this), PlatformAuthCacheAccount, this.logger, this.performanceClient, this.correlationId)(baseAccount, isKmsi(idTokenClaims), !isL3DpopResponse);
20727
21688
  await invokeAsync(this.cacheNativeTokens.bind(this), PlatformAuthCacheNativeTokens, this.logger, this.performanceClient, this.correlationId)(response, request, homeAccountIdentifier, idTokenClaims, result.tenantId, reqTimestamp, authority.getPreferredCache(), // environment
20728
- storeInCache);
21689
+ storeInCache, dpopBrokerOutcome);
20729
21690
  return result;
20730
21691
  }
20731
21692
  /**
@@ -20801,7 +21762,7 @@ class PlatformAuthInteractionClient extends BaseInteractionClient {
20801
21762
  */
20802
21763
  async generateAuthenticationResult(response, request, idTokenClaims, accountEntity, authority, reqTimestamp) {
20803
21764
  // Add Native Broker fields to Telemetry
20804
- const mats = this.addTelemetryFromNativeResponse(response.properties.MATS);
21765
+ const mats = this.addTelemetryFromNativeResponse(response.properties?.MATS);
20805
21766
  // If scopes not returned in server response, use request scopes
20806
21767
  const responseScopes = this.generateScopes(request.scope, response.scope);
20807
21768
  const accountProperties = response.account.properties || {};
@@ -20827,9 +21788,17 @@ class PlatformAuthInteractionClient extends BaseInteractionClient {
20827
21788
  }
20828
21789
  // generate PoP token as needed
20829
21790
  const responseAccessToken = await this.generatePopAccessToken(response, request);
20830
- const tokenType = request.tokenType === AuthenticationScheme.POP
20831
- ? AuthenticationScheme.POP
20832
- : AuthenticationScheme.BEARER;
21791
+ const isDpopRequest = this.isDpopBrokerRequest(request);
21792
+ let tokenType = AuthenticationScheme.BEARER;
21793
+ if (isDpopRequest) {
21794
+ tokenType = AuthenticationScheme.DPOP;
21795
+ }
21796
+ else if (request.tokenType === AuthenticationScheme.POP) {
21797
+ tokenType = AuthenticationScheme.POP;
21798
+ }
21799
+ const dpopProof = isDpopRequest
21800
+ ? await this.generateDpopProof(response, request)
21801
+ : undefined;
20833
21802
  const result = {
20834
21803
  authority: authority,
20835
21804
  uniqueId: uid,
@@ -20843,6 +21812,7 @@ class PlatformAuthInteractionClient extends BaseInteractionClient {
20843
21812
  // Request timestamp and NativeResponse expires_in are in seconds, converting to Date for AuthenticationResult
20844
21813
  expiresOn: toDateFromSeconds(reqTimestamp + response.expires_in),
20845
21814
  tokenType: tokenType,
21815
+ dpopProof,
20846
21816
  correlationId: this.correlationId,
20847
21817
  state: response.state,
20848
21818
  fromPlatformBroker: true,
@@ -20856,11 +21826,13 @@ class PlatformAuthInteractionClient extends BaseInteractionClient {
20856
21826
  * cache the account entity in browser storage
20857
21827
  * @param accountEntity
20858
21828
  */
20859
- async cacheAccount(accountEntity, kmsi) {
21829
+ async cacheAccount(accountEntity, kmsi, clearExistingTokens = true) {
20860
21830
  // Store the account info and hence `nativeAccountId` in browser cache
20861
21831
  await this.browserStorage.setAccount(accountEntity, this.correlationId, kmsi, this.apiId);
20862
21832
  // Remove any existing cached tokens for this account in browser storage
20863
- this.browserStorage.removeAccountContext(getAccountInfo(accountEntity), this.correlationId);
21833
+ if (clearExistingTokens) {
21834
+ this.browserStorage.removeAccountContext(getAccountInfo(accountEntity), this.correlationId);
21835
+ }
20864
21836
  }
20865
21837
  /**
20866
21838
  * Stores the access_token and id_token in inmemory storage
@@ -20872,8 +21844,18 @@ class PlatformAuthInteractionClient extends BaseInteractionClient {
20872
21844
  * @param tenantId
20873
21845
  * @param reqTimestamp
20874
21846
  */
20875
- async cacheNativeTokens(response, request, homeAccountIdentifier, idTokenClaims, tenantId, reqTimestamp, environment, storeInCache) {
21847
+ async cacheNativeTokens(response, request, homeAccountIdentifier, idTokenClaims, tenantId, reqTimestamp, environment, storeInCache, dpopBrokerOutcome = "none") {
20876
21848
  const cachedIdToken = createIdTokenEntity(homeAccountIdentifier, environment, response.id_token || "", request.clientId, idTokenClaims.tid || "");
21849
+ // save idtoken credential in configured browser storage
21850
+ if (!!cachedIdToken && storeInCache?.idToken !== false) {
21851
+ await this.browserStorage.setIdTokenCredential(cachedIdToken, this.correlationId, isKmsi(idTokenClaims));
21852
+ }
21853
+ if (dpopBrokerOutcome === "L3") {
21854
+ return;
21855
+ }
21856
+ if (storeInCache?.accessToken === false) {
21857
+ return;
21858
+ }
20877
21859
  // cache accessToken in inmemory storage
20878
21860
  const expiresIn = request.tokenType === AuthenticationScheme.POP
20879
21861
  ? SHR_NONCE_VALIDITY
@@ -20883,18 +21865,14 @@ class PlatformAuthInteractionClient extends BaseInteractionClient {
20883
21865
  const tokenExpirationSeconds = reqTimestamp + expiresIn;
20884
21866
  const responseScopes = this.generateScopes(response.scope, request.scope);
20885
21867
  const additionalCacheKeyComponents = request.attributeTokens
20886
- ? {
20887
- attribute_tokens: request.attributeTokens,
20888
- }
21868
+ ? { attribute_tokens: request.attributeTokens }
20889
21869
  : undefined;
20890
- 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);
21870
+ const cachedAccessToken = createAccessTokenEntity(homeAccountIdentifier, environment, response.access_token, request.clientId, idTokenClaims.tid || tenantId, responseScopes.printScopes(), tokenExpirationSeconds, 0, base64Decode, request.correlationId, undefined, this.isDpopBrokerRequest(request)
21871
+ ? AuthenticationScheme.DPOP
21872
+ : request.tokenType, undefined, request.keyId, additionalCacheKeyComponents);
20891
21873
  if (request.extraParameters?.resource) {
20892
21874
  cachedAccessToken.resource = request.extraParameters.resource;
20893
21875
  }
20894
- // save idtoken credential in configured browser storage
20895
- if (!!cachedIdToken && storeInCache?.idToken !== false) {
20896
- await this.browserStorage.setIdTokenCredential(cachedIdToken, this.correlationId, isKmsi(idTokenClaims));
20897
- }
20898
21876
  // save access token credential in memory storage
20899
21877
  const nativeCacheRecord = {
20900
21878
  accessToken: cachedAccessToken,
@@ -20971,11 +21949,7 @@ class PlatformAuthInteractionClient extends BaseInteractionClient {
20971
21949
  const configClaims = request.skipBrokerClaims && !!request.embeddedClientId
20972
21950
  ? undefined
20973
21951
  : this.config.auth.clientCapabilities;
20974
- /*
20975
- * 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.
20976
- * attributeTokens is destructured out because PlatformAuthRequest represents it as a pre-serialized string, not the caller-provided Array<string>.
20977
- */
20978
- const { scopes, claims, extraParametersNoCache, dpopNonce } = request;
21952
+ const { scopes, claims, dpopNonce } = request;
20979
21953
  const scopeSet = new ScopeSet([...(scopes || []), ...OIDC_DEFAULT_SCOPES], this.correlationId);
20980
21954
  const mergedClaims = buildMergedClaims(claims, configClaims?.length ? configClaims : undefined);
20981
21955
  const hasAttributeTokens = !!request.attributeTokens?.length;
@@ -20999,56 +21973,390 @@ class PlatformAuthInteractionClient extends BaseInteractionClient {
20999
21973
  loginHint: request.loginHint,
21000
21974
  extraParameters: {
21001
21975
  ...request.extraParameters,
21002
- ...(request.resource && { resource: request.resource }), // resource is set for MCP scenarios
21976
+ // Native broker resource is set for MCP scenarios.
21977
+ ...(request.resource && { resource: request.resource }),
21003
21978
  },
21004
21979
  extendedExpiryToken: false,
21005
21980
  keyId: request.popKid,
21006
- resourceRequestMethod: request.resourceRequestMethod,
21007
- resourceRequestUri: request.resourceRequestUri,
21008
- shrClaims: request.shrClaims,
21009
- shrNonce: request.shrNonce,
21010
- extraParametersNoCache: createPlatformAuthExtraParametersNoCache(extraParametersNoCache, isProofOfPossessionTokenType(request.authenticationScheme), request.resourceRequestMethod, request.resourceRequestUri, dpopNonce),
21011
21981
  };
21012
21982
  if (hasAttributeTokens) {
21013
21983
  validatedRequest.attributeTokens =
21014
21984
  serializeAttributeTokens(request.attributeTokens);
21015
21985
  }
21016
- // Check for PoP token requests: signPopToken should only be set to true if popKid is not set
21017
- if (validatedRequest.signPopToken && !!request.popKid) {
21018
- throw createBrowserAuthError(invalidPopTokenRequest, this.correlationId);
21986
+ this.handleExtraBrokerParams(validatedRequest, request.embeddedClientId);
21987
+ validatedRequest.extraParameters =
21988
+ validatedRequest.extraParameters || {};
21989
+ validatedRequest.extraParameters.telemetry =
21990
+ PlatformAuthConstants.MATS_TELEMETRY;
21991
+ if (request.authenticationScheme === AuthenticationScheme.POP) {
21992
+ const shrParameters = {
21993
+ resourceRequestMethod: request.resourceRequestMethod,
21994
+ resourceRequestUri: request.resourceRequestUri,
21995
+ shrClaims: request.shrClaims,
21996
+ shrNonce: request.shrNonce,
21997
+ correlationId: this.correlationId,
21998
+ };
21999
+ const popTokenGenerator = new PopTokenGenerator(this.browserCrypto, this.tokenBindingKeyManager, this.performanceClient);
22000
+ if (!validatedRequest.keyId) {
22001
+ const generatedReqCnfData = await invokeAsync(popTokenGenerator.generateCnf.bind(popTokenGenerator), PopTokenGenerateCnf, this.logger, this.performanceClient, this.correlationId)(shrParameters, this.logger);
22002
+ validatedRequest.reqCnf = generatedReqCnfData.reqCnfString;
22003
+ validatedRequest.keyId = generatedReqCnfData.kid;
22004
+ validatedRequest.signPopToken = true;
22005
+ }
22006
+ else {
22007
+ validatedRequest.reqCnf = this.browserCrypto.base64UrlEncode(JSON.stringify({ kid: validatedRequest.keyId }));
22008
+ validatedRequest.signPopToken = false;
22009
+ }
22010
+ validatedRequest.resourceRequestMethod =
22011
+ request.resourceRequestMethod;
22012
+ validatedRequest.resourceRequestUri = request.resourceRequestUri;
22013
+ validatedRequest.shrClaims = request.shrClaims;
22014
+ validatedRequest.shrNonce = request.shrNonce;
22015
+ }
22016
+ else if (request.authenticationScheme === AuthenticationScheme.DPOP) {
22017
+ Object.assign(validatedRequest, this.createDpopRequestParameters(request));
22018
+ }
22019
+ validatedRequest.extraParametersNoCache =
22020
+ createPlatformAuthExtraParametersNoCache(validatedRequest.tokenType, validatedRequest.resourceRequestMethod, validatedRequest.resourceRequestUri, dpopNonce);
22021
+ this.addRequestSKUs(validatedRequest);
22022
+ return validatedRequest;
22023
+ }
22024
+ /**
22025
+ * Creates and validates the broker-specific parameters for a DPoP request.
22026
+ * @param request - Developer-provided token request.
22027
+ * @returns Broker parameters for a DPoP token and resource proof.
22028
+ */
22029
+ createDpopRequestParameters(request) {
22030
+ if (request.popKid) {
22031
+ throw createBrowserAuthError(DPOP_POP_KID_NOT_SUPPORTED, this.correlationId);
22032
+ }
22033
+ if (!request.resourceRequestMethod?.trim() ||
22034
+ !request.resourceRequestUri?.trim()) {
22035
+ throw createClientConfigurationError(dpopMissingResourceContext, this.correlationId);
22036
+ }
22037
+ const resourceContext = normalizeDpopResourceRequestContext({
22038
+ htm: request.resourceRequestMethod,
22039
+ htu: request.resourceRequestUri,
22040
+ }, this.correlationId);
22041
+ return {
22042
+ tokenType: PlatformAuthTokenType.DPOP_WITH_PROOF,
22043
+ preferBinding: PlatformAuthBindingPreference.ATTESTED,
22044
+ keyId: request.dpopJkt,
22045
+ resourceRequestMethod: resourceContext.htm,
22046
+ resourceRequestUri: resourceContext.htu,
22047
+ };
22048
+ }
22049
+ /**
22050
+ * Provisions the local key and confirmation data for a DPoP broker request.
22051
+ * @param request - Broker request to prepare.
22052
+ * @param reuseExistingKey - Whether a complete existing key binding may be reused.
22053
+ */
22054
+ async prepareDpopBrokerRequest(request, reuseExistingKey = false) {
22055
+ if (request.tokenType !== PlatformAuthTokenType.DPOP_WITH_PROOF) {
22056
+ return;
22057
+ }
22058
+ /*
22059
+ * Phase one clears both fields after an L3 response or non-fatal broker
22060
+ * error. In that case phase two must provision a replacement. If either
22061
+ * field remains, treat it as a retained binding and validate it fully.
22062
+ */
22063
+ if (reuseExistingKey && (request.keyId || request.reqCnf)) {
22064
+ if (!request.keyId || !request.reqCnf) {
22065
+ throw createAuthError(unexpectedError, this.correlationId, "DPoP request key binding is incomplete after redirect.");
22066
+ }
22067
+ const expectedReqCnf = this.createDpopBrokerReqCnf(request.keyId);
22068
+ if (request.reqCnf !== expectedReqCnf) {
22069
+ throw createAuthError(unexpectedError, this.correlationId, "DPoP request key binding is invalid after redirect.");
22070
+ }
22071
+ const hasKey = this.tokenBindingKeyManager.hasTokenBindingKey !== undefined
22072
+ ? await this.tokenBindingKeyManager.hasTokenBindingKey(request.keyId, this.correlationId)
22073
+ : await this.tokenBindingKeyManager
22074
+ .getTokenBindingPublicKeyJwk(request.keyId, this.correlationId)
22075
+ .then(() => true, () => false);
22076
+ if (!hasKey) {
22077
+ throw createAuthError(unexpectedError, this.correlationId, "DPoP request key is unavailable after redirect.");
22078
+ }
22079
+ return;
22080
+ }
22081
+ if (request.reqCnf) {
22082
+ throw createAuthError(unexpectedError, this.correlationId, "Unexpected preexisting DPoP request key.");
22083
+ }
22084
+ if (!request.keyId) {
22085
+ request.keyId =
22086
+ await this.tokenBindingKeyManager.provisionTokenBindingKey({
22087
+ tokenBindingKeyType: AuthenticationScheme.DPOP.toLowerCase(),
22088
+ tokenBindingKeyAlgorithm: JsonWebTokenAlgorithms.ES256,
22089
+ correlationId: this.correlationId,
22090
+ });
22091
+ }
22092
+ request.reqCnf = this.createDpopBrokerReqCnf(request.keyId);
22093
+ }
22094
+ /**
22095
+ * Creates the confirmation claim for an MSAL-owned broker DPoP key.
22096
+ * @param keyId - Browser-managed DPoP key identifier.
22097
+ * @returns Encoded broker confirmation claim.
22098
+ */
22099
+ createDpopBrokerReqCnf(keyId) {
22100
+ return this.browserCrypto.base64UrlEncode(JSON.stringify({
22101
+ kid: keyId,
22102
+ xms_ksl: PlatformAuthInteractionClient.MSAL_DPOP_KEY_STORAGE_LOCATION,
22103
+ }));
22104
+ }
22105
+ /**
22106
+ * Ensures an owned DPoP key can survive redirect navigation before the
22107
+ * request metadata is persisted for phase two.
22108
+ */
22109
+ async ensureRedirectDpopKeyIsPersisted(request) {
22110
+ if (!this.isDpopBrokerRequest(request) || !request.keyId) {
22111
+ return;
22112
+ }
22113
+ if (!(await isTokenBindingKeyPersistedForRedirect(request, this.tokenBindingKeyManager))) {
22114
+ throw createAuthError(unexpectedError, this.correlationId, "DPoP request key could not be persisted for redirect.");
22115
+ }
22116
+ }
22117
+ /**
22118
+ * Validates and normalizes the DPoP binding outcome returned by the broker.
22119
+ * @param response - Broker response to validate.
22120
+ * @param request - Broker request associated with the response.
22121
+ * @returns The validated DPoP binding level, or `none` for non-DPoP requests.
22122
+ */
22123
+ validateDpopBrokerOutcome(response, request) {
22124
+ const isDpopRequest = this.isDpopBrokerRequest(request);
22125
+ const normalizedResponse = this.normalizeDpopBrokerResponse(response);
22126
+ const normalizedRequestTokenType = request.tokenType
22127
+ ?.trim()
22128
+ .toLowerCase();
22129
+ const bindingPreferenceSent = request.bindingPreferenceSent ??
22130
+ request.preferBinding !== undefined;
22131
+ const hasDpopResponse = this.isDpopBrokerTokenType(normalizedResponse.tokenType) ||
22132
+ normalizedResponse.proof !== undefined ||
22133
+ normalizedResponse.hasBindingAttested;
22134
+ if (!isDpopRequest) {
22135
+ if (hasDpopResponse) {
22136
+ this.throwInvalidDpopResponse("unexpected_response", "Unexpected DPoP broker response.");
22137
+ }
22138
+ return "none";
22139
+ }
22140
+ if (!this.isDpopBrokerTokenType(normalizedResponse.tokenType)) {
22141
+ this.throwInvalidDpopResponse("unknown_token_type", "Unknown DPoP broker response.");
22142
+ }
22143
+ this.validateNormalizedDpopBrokerResponse(normalizedResponse, bindingPreferenceSent);
22144
+ if (normalizedResponse.tokenType ===
22145
+ PlatformAuthTokenType.DPOP_WITH_PROOF.toLowerCase()) {
22146
+ return this.validateDpopBrokerL3Outcome(normalizedRequestTokenType, normalizedResponse);
22147
+ }
22148
+ return this.validateDpopBrokerL1Outcome(request, normalizedRequestTokenType, normalizedResponse, bindingPreferenceSent);
22149
+ }
22150
+ /**
22151
+ * Normalizes the canonical DPoP fields returned under response properties.
22152
+ */
22153
+ normalizeDpopBrokerResponse(response) {
22154
+ const responseProperties = response.properties;
22155
+ const rawTokenType = responseProperties?.token_type;
22156
+ const tokenType = typeof rawTokenType === "string"
22157
+ ? rawTokenType.trim().toLowerCase()
22158
+ : undefined;
22159
+ const rawBindingAttested = responseProperties?.binding_attested;
22160
+ let bindingAttested;
22161
+ if (typeof rawBindingAttested === "string") {
22162
+ const normalizedBindingAttested = rawBindingAttested
22163
+ .trim()
22164
+ .toLowerCase();
22165
+ if (normalizedBindingAttested === "true") {
22166
+ bindingAttested = true;
22167
+ }
22168
+ else if (normalizedBindingAttested === "false") {
22169
+ bindingAttested = false;
22170
+ }
22171
+ }
22172
+ return {
22173
+ tokenType,
22174
+ proof: responseProperties?.DPoP,
22175
+ bindingAttested,
22176
+ hasBindingAttested: rawBindingAttested !== undefined,
22177
+ hasMalformedBindingAttested: rawBindingAttested !== undefined &&
22178
+ bindingAttested === undefined,
22179
+ };
22180
+ }
22181
+ /**
22182
+ * Validates normalized fields shared by L1 and L3 broker DPoP responses.
22183
+ */
22184
+ validateNormalizedDpopBrokerResponse(normalizedResponse, bindingPreferenceSent) {
22185
+ if (normalizedResponse.hasMalformedBindingAttested) {
22186
+ this.throwInvalidDpopResponse("invalid_attestation", "Conflicting DPoP broker response.");
22187
+ }
22188
+ if (bindingPreferenceSent &&
22189
+ normalizedResponse.bindingAttested === undefined) {
22190
+ this.throwInvalidDpopResponse("missing_attestation", "Conflicting DPoP broker response.");
22191
+ }
22192
+ }
22193
+ /**
22194
+ * Validates a broker-returned L3 DPoP proof outcome.
22195
+ */
22196
+ validateDpopBrokerL3Outcome(normalizedRequestTokenType, normalizedResponse) {
22197
+ const dpopWithProofTokenType = PlatformAuthTokenType.DPOP_WITH_PROOF.toLowerCase();
22198
+ if (typeof normalizedResponse.proof !== "string" ||
22199
+ normalizedResponse.proof.trim().length === 0) {
22200
+ this.throwInvalidDpopResponse("missing_proof", "Malformed DPoP broker response.");
22201
+ }
22202
+ if (normalizedResponse.bindingAttested !== true) {
22203
+ this.throwInvalidDpopResponse("invalid_attestation", "Malformed DPoP broker response.");
22204
+ }
22205
+ if (normalizedRequestTokenType !== dpopWithProofTokenType ||
22206
+ normalizedResponse.tokenType !== dpopWithProofTokenType) {
22207
+ this.throwInvalidDpopResponse("conflicting_fields", "Malformed DPoP broker response.");
22208
+ }
22209
+ this.performanceClient.addFields({
22210
+ "ext.brokerDpopOutcome": "l3",
22211
+ "ext.brokerDpopBindingLevel": "L3",
22212
+ }, this.correlationId);
22213
+ return "L3";
22214
+ }
22215
+ /**
22216
+ * Validates an L1 DPoP outcome that MSAL will sign with its local key.
22217
+ */
22218
+ validateDpopBrokerL1Outcome(request, normalizedRequestTokenType, normalizedResponse, bindingPreferenceSent) {
22219
+ if (normalizedResponse.proof !== undefined) {
22220
+ this.throwInvalidDpopResponse("conflicting_fields", "Malformed DPoP broker L1 response.");
22221
+ }
22222
+ if (normalizedRequestTokenType !==
22223
+ PlatformAuthTokenType.DPOP_WITH_PROOF.toLowerCase()) {
22224
+ this.throwInvalidDpopResponse("conflicting_fields", "Malformed DPoP broker L1 response.");
22225
+ }
22226
+ if (normalizedResponse.bindingAttested !== false &&
22227
+ !(!bindingPreferenceSent &&
22228
+ normalizedResponse.bindingAttested === undefined)) {
22229
+ this.throwInvalidDpopResponse("invalid_attestation", "Malformed DPoP broker L1 response.");
22230
+ }
22231
+ if (!request.reqCnf || !request.keyId) {
22232
+ this.throwInvalidDpopResponse("missing_l1_binding", "Malformed DPoP broker L1 response.");
22233
+ }
22234
+ this.performanceClient.addFields({
22235
+ "ext.brokerDpopOutcome": "l1",
22236
+ "ext.brokerDpopBindingLevel": "L1",
22237
+ }, this.correlationId);
22238
+ return "L1";
22239
+ }
22240
+ /**
22241
+ * Emits bounded failure telemetry and rejects an invalid DPoP response.
22242
+ */
22243
+ throwInvalidDpopResponse(failureReason, message) {
22244
+ this.performanceClient.addFields({
22245
+ "ext.brokerDpopOutcome": "invalid_response",
22246
+ "ext.brokerDpopFailureReason": failureReason,
22247
+ }, this.correlationId);
22248
+ throw createAuthError(unexpectedError, this.correlationId, message);
22249
+ }
22250
+ /**
22251
+ * Returns the broker proof or signs an L1 resource proof with the local key.
22252
+ * @param response - Broker response containing the access token and optional proof.
22253
+ * @param request - Broker request containing the proof context and local key.
22254
+ * @returns The resource proof for the broker access token.
22255
+ */
22256
+ async generateDpopProof(response, request) {
22257
+ const brokerProof = response.properties?.DPoP;
22258
+ if (brokerProof !== undefined) {
22259
+ return brokerProof;
22260
+ }
22261
+ const dpopProofGenerator = new DpopProofGenerator(this.browserCrypto, this.tokenBindingKeyManager);
22262
+ return dpopProofGenerator.generateResourceProof({
22263
+ htu: request.resourceRequestUri,
22264
+ htm: request.resourceRequestMethod,
22265
+ accessToken: response.access_token,
22266
+ nonce: request.extraParametersNoCache?.pop_nonce,
22267
+ }, request.keyId, this.correlationId);
22268
+ }
22269
+ /**
22270
+ * Removes a generated DPoP request key and clears its request metadata.
22271
+ * @param request - Broker request whose generated key should be removed.
22272
+ */
22273
+ async resetGeneratedDpopRequestKey(request) {
22274
+ if (!this.isDpopBrokerRequest(request) || !request.keyId) {
22275
+ return;
22276
+ }
22277
+ const cleanupMeasurement = this.performanceClient.startMeasurement(PlatformAuthDpopKeyCleanup, this.correlationId);
22278
+ this.performanceClient.incrementFields({ "ext.brokerDpopKeyCleanupAttemptCount": 1 }, this.correlationId);
22279
+ try {
22280
+ if (request.keyId && !(await this.removeDpopKey(request.keyId))) {
22281
+ throw createAuthError(unexpectedError, this.correlationId, "Failed to remove generated DPoP request key.");
22282
+ }
22283
+ this.performanceClient.addFields({
22284
+ "ext.brokerDpopKeyCleanupOutcome": "succeeded",
22285
+ }, this.correlationId);
22286
+ cleanupMeasurement.end({ success: true });
22287
+ request.keyId = undefined;
22288
+ request.reqCnf = undefined;
22289
+ }
22290
+ catch (error) {
22291
+ this.performanceClient.addFields({
22292
+ "ext.brokerDpopKeyCleanupOutcome": "failed",
22293
+ }, this.correlationId);
22294
+ this.performanceClient.incrementFields({ "ext.brokerDpopKeyCleanupFailureCount": 1 }, this.correlationId);
22295
+ cleanupMeasurement.end({ success: false }, error);
22296
+ throw error;
22297
+ }
22298
+ }
22299
+ /**
22300
+ * Attempts to remove a generated DPoP request key without replacing an
22301
+ * existing operation error with a cleanup failure.
22302
+ * @param request - Broker request whose generated key should be removed.
22303
+ */
22304
+ async resetGeneratedDpopRequestKeyBestEffort(request) {
22305
+ try {
22306
+ await this.resetGeneratedDpopRequestKey(request);
22307
+ }
22308
+ catch {
22309
+ this.logger.error("1kxxak", this.correlationId);
22310
+ this.performanceClient.incrementFields({ removeTokenBindingKeyFailure: 1 }, this.correlationId);
22311
+ request.keyId = undefined;
22312
+ request.reqCnf = undefined;
22313
+ }
22314
+ }
22315
+ /**
22316
+ * Records that a DPoP request is about to be dispatched to the platform broker.
22317
+ * @param request - Broker request about to cross the provider boundary.
22318
+ */
22319
+ addDpopBrokerAttemptTelemetry(request) {
22320
+ if (!this.isDpopBrokerRequest(request)) {
22321
+ return;
22322
+ }
22323
+ this.performanceClient.addFields({
22324
+ "ext.brokerDpopAttempted": 1,
22325
+ }, this.correlationId);
22326
+ }
22327
+ /**
22328
+ * Determines whether a request uses the DPoP broker protocol.
22329
+ * @param request - Broker request to inspect.
22330
+ * @returns Whether the request uses a DPoP token type.
22331
+ */
22332
+ isDpopBrokerRequest(request) {
22333
+ return this.isDpopBrokerTokenType(request.tokenType);
22334
+ }
22335
+ /**
22336
+ * Determines whether a token type represents a DPoP broker request.
22337
+ * @param tokenType - Token type to inspect.
22338
+ * @returns Whether the token type is a supported DPoP broker token type.
22339
+ */
22340
+ isDpopBrokerTokenType(tokenType) {
22341
+ const normalizedTokenType = tokenType?.trim().toLowerCase();
22342
+ return (normalizedTokenType === PlatformAuthTokenType.DPOP_WITH_PROOF ||
22343
+ normalizedTokenType ===
22344
+ AuthenticationScheme.DPOP.toLowerCase());
22345
+ }
22346
+ /**
22347
+ * Removes a DPoP key while reporting cleanup failures.
22348
+ * @param keyId - Identifier of the DPoP key to remove.
22349
+ * @returns Whether the key was removed successfully.
22350
+ */
22351
+ async removeDpopKey(keyId) {
22352
+ try {
22353
+ await this.tokenBindingKeyManager.removeTokenBindingKey(keyId, this.correlationId);
22354
+ return true;
21019
22355
  }
21020
- this.handleExtraBrokerParams(validatedRequest, request.embeddedClientId);
21021
- validatedRequest.extraParameters =
21022
- validatedRequest.extraParameters || {};
21023
- validatedRequest.extraParameters.telemetry =
21024
- PlatformAuthConstants.MATS_TELEMETRY;
21025
- if (request.authenticationScheme === AuthenticationScheme.POP) {
21026
- // add POP request type
21027
- const shrParameters = {
21028
- resourceRequestUri: request.resourceRequestUri,
21029
- resourceRequestMethod: request.resourceRequestMethod,
21030
- shrClaims: request.shrClaims,
21031
- shrNonce: request.shrNonce,
21032
- correlationId: this.correlationId,
21033
- };
21034
- const popTokenGenerator = new PopTokenGenerator(this.browserCrypto, this.tokenBindingKeyManager, this.performanceClient);
21035
- // generate reqCnf if not provided in the request
21036
- let reqCnfData;
21037
- if (!validatedRequest.keyId) {
21038
- const generatedReqCnfData = await invokeAsync(popTokenGenerator.generateCnf.bind(popTokenGenerator), PopTokenGenerateCnf, this.logger, this.performanceClient, this.correlationId)(shrParameters, this.logger);
21039
- reqCnfData = generatedReqCnfData.reqCnfString;
21040
- validatedRequest.keyId = generatedReqCnfData.kid;
21041
- validatedRequest.signPopToken = true;
21042
- }
21043
- else {
21044
- reqCnfData = this.browserCrypto.base64UrlEncode(JSON.stringify({ kid: validatedRequest.keyId }));
21045
- validatedRequest.signPopToken = false;
21046
- }
21047
- // SPAs require whole string to be passed to broker
21048
- validatedRequest.reqCnf = reqCnfData;
22356
+ catch {
22357
+ this.logger.error("1w60e4", this.correlationId);
22358
+ return false;
21049
22359
  }
21050
- this.addRequestSKUs(validatedRequest);
21051
- return validatedRequest;
21052
22360
  }
21053
22361
  async getCanonicalAuthority(request) {
21054
22362
  const requestAuthority = request.authority || this.config.auth.authority;
@@ -21088,29 +22396,28 @@ class PlatformAuthInteractionClient extends BaseInteractionClient {
21088
22396
  }
21089
22397
  }
21090
22398
  /**
21091
- * Handles extra broker request parameters
21092
- * @param request {PlatformAuthRequest}
21093
- * @private
22399
+ * Handles extra broker request parameters.
22400
+ * @param request - Platform broker request.
22401
+ * @param embeddedClientId - Embedded application client identifier.
21094
22402
  */
21095
22403
  handleExtraBrokerParams(request, embeddedClientId) {
21096
- const hasExtraBrokerParams = request.extraParameters &&
21097
- request.extraParameters.hasOwnProperty(BROKER_CLIENT_ID) &&
21098
- request.extraParameters.hasOwnProperty(BROKER_REDIRECT_URI) &&
21099
- request.extraParameters.hasOwnProperty(CLIENT_ID);
22404
+ const hasOwnParameter = (parameter) => Object.prototype.hasOwnProperty.call(request.extraParameters, parameter);
22405
+ const hasExtraBrokerParams = hasOwnParameter(BROKER_CLIENT_ID) &&
22406
+ hasOwnParameter(BROKER_REDIRECT_URI) &&
22407
+ hasOwnParameter(CLIENT_ID);
21100
22408
  if (!embeddedClientId && !hasExtraBrokerParams) {
21101
22409
  return;
21102
22410
  }
21103
- let child_client_id = "";
21104
- const child_redirect_uri = request.redirectUri;
22411
+ const childRedirectUri = request.redirectUri;
22412
+ const childClientId = embeddedClientId ||
22413
+ request.extraParameters?.[CLIENT_ID] ||
22414
+ "";
21105
22415
  if (embeddedClientId) {
21106
22416
  request.redirectUri = this.config.auth.redirectUri;
21107
- child_client_id = embeddedClientId;
21108
22417
  }
21109
22418
  else if (request.extraParameters) {
21110
22419
  request.redirectUri =
21111
22420
  request.extraParameters[BROKER_REDIRECT_URI];
21112
- child_client_id =
21113
- request.extraParameters[CLIENT_ID];
21114
22421
  }
21115
22422
  const {
21116
22423
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -21121,15 +22428,20 @@ class PlatformAuthInteractionClient extends BaseInteractionClient {
21121
22428
  [CLIENT_ID]: _clientId, ...remainingExtraParameters } = request.extraParameters || {};
21122
22429
  request.extraParameters = {
21123
22430
  ...remainingExtraParameters,
21124
- child_client_id,
21125
- child_redirect_uri,
22431
+ child_client_id: childClientId,
22432
+ child_redirect_uri: childRedirectUri,
21126
22433
  };
21127
22434
  this.performanceClient?.addFields({
21128
- embeddedClientId: child_client_id,
21129
- embeddedRedirectUri: child_redirect_uri,
22435
+ embeddedClientId: childClientId,
22436
+ embeddedRedirectUri: childRedirectUri,
21130
22437
  }, this.correlationId);
21131
22438
  }
21132
- }
22439
+ }
22440
+ /**
22441
+ * Storage location reported for MSAL-owned browser DPoP keys in reqCnf.
22442
+ * This does not constrain the binding selected by the platform broker.
22443
+ */
22444
+ PlatformAuthInteractionClient.MSAL_DPOP_KEY_STORAGE_LOCATION = PlatformAuthEnclave.SOFTWARE;
21133
22445
 
21134
22446
  /*
21135
22447
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -21201,7 +22513,16 @@ function instrumentClientData(response, correlationId, performanceClient) {
21201
22513
  * @returns
21202
22514
  */
21203
22515
  async function getStandardParameters(config, authority, request, logger, performanceClient) {
21204
- const parameters = getStandardAuthorizeRequestParameters({ ...config.auth, authority: authority }, request, logger, performanceClient);
22516
+ const parameters = getStandardAuthorizeRequestParameters({ ...config.auth, authority: authority }, {
22517
+ ...request,
22518
+ /*
22519
+ * Computed here rather than per flow so every authorize request
22520
+ * carries it — GET, POST and EAR, interactive and silent alike.
22521
+ * A request may assert it instead when the topology, rather than
22522
+ * the current window, is what makes the popup unreachable.
22523
+ */
22524
+ popupOriginCheckDone: request.popupOriginCheckDone ?? computePocd(config) === 1,
22525
+ }, logger, performanceClient);
21205
22526
  addLibraryInfo(parameters, {
21206
22527
  sku: BrowserConstants.MSAL_SKU,
21207
22528
  version: version,
@@ -21226,6 +22547,7 @@ async function getStandardParameters(config, authority, request, logger, perform
21226
22547
  }
21227
22548
  }
21228
22549
  if (request.authenticationScheme === AuthenticationScheme.DPOP &&
22550
+ !request.platformBroker &&
21229
22551
  request.dpopJkt) {
21230
22552
  parameters.set(DPOP_JKT, request.dpopJkt);
21231
22553
  }
@@ -21255,6 +22577,15 @@ async function getAuthCodeRequestUrl(config, authority, request, logger, perform
21255
22577
  });
21256
22578
  return getAuthorizeUrl(authority, parameters);
21257
22579
  }
22580
+ function getAuthorizeFormAction(authority, request, parameters) {
22581
+ const queryParams = new Map();
22582
+ addExtraParameters(queryParams, request.extraQueryParameters || {});
22583
+ if (parameters.has(POPUP_ORIGIN_CHECK_DONE)) {
22584
+ queryParams.delete(POPUP_ORIGIN_CHECK_DONE);
22585
+ }
22586
+ addCorrelationId(queryParams, request.correlationId);
22587
+ return getAuthorizeUrl(authority, queryParams);
22588
+ }
21258
22589
  /**
21259
22590
  * Builds the action URL + POST-body fields for the EAR /authorize form.
21260
22591
  */
@@ -21270,11 +22601,7 @@ async function getEARFormData(config, authority, request, logger, performanceCli
21270
22601
  addExtraParameters(parameters, {
21271
22602
  ...request.extraParameters,
21272
22603
  });
21273
- const queryParams = new Map();
21274
- addExtraParameters(queryParams, request.extraQueryParameters || {});
21275
- // Add correlationId to query params so gateway can propagate it to IDPs
21276
- addCorrelationId(queryParams, request.correlationId);
21277
- const action = getAuthorizeUrl(authority, queryParams);
22604
+ const action = getAuthorizeFormAction(authority, request, parameters);
21278
22605
  return { action, fields: Object.fromEntries(parameters) };
21279
22606
  }
21280
22607
  /**
@@ -21295,12 +22622,7 @@ async function getCodeFormData(config, authority, request, logger, performanceCl
21295
22622
  addExtraParameters(parameters, {
21296
22623
  ...request.extraParameters,
21297
22624
  });
21298
- // Add extraQueryParameters to be appended to request URL
21299
- const queryParams = new Map();
21300
- addExtraParameters(queryParams, request.extraQueryParameters || {});
21301
- // Add correlationId to query params so gateway can propagate it to IDPs
21302
- addCorrelationId(queryParams, request.correlationId);
21303
- const action = getAuthorizeUrl(authority, queryParams);
22625
+ const action = getAuthorizeFormAction(authority, request, parameters);
21304
22626
  return { action, fields: Object.fromEntries(parameters) };
21305
22627
  }
21306
22628
  /**
@@ -21349,19 +22671,25 @@ function createForm(frame, action, fields) {
21349
22671
  * @param nativeMessageHandler
21350
22672
  * @returns
21351
22673
  */
21352
- async function handleResponsePlatformBroker(request, accountId, apiId, config, browserStorage, nativeStorage, eventHandler, logger, performanceClient, platformAuthProvider) {
22674
+ async function handleResponsePlatformBroker(request, accountId, apiId, config, browserStorage, nativeStorage, eventHandler, logger, performanceClient, platformAuthProvider, tokenBindingKeyManager = new TokenBindingKeyManager(logger, performanceClient)) {
21353
22675
  logger.verbose("11qcow", request.correlationId);
21354
22676
  if (!platformAuthProvider) {
21355
22677
  throw createBrowserAuthError(nativeConnectionNotEstablished, request.correlationId);
21356
22678
  }
21357
22679
  const browserCrypto = new CryptoOps(logger, performanceClient);
21358
- const nativeInteractionClient = new PlatformAuthInteractionClient(config, browserStorage, browserCrypto, logger, eventHandler, config.system.navigationClient, apiId, performanceClient, platformAuthProvider, accountId, nativeStorage, request.correlationId);
22680
+ const nativeInteractionClient = new PlatformAuthInteractionClient(config, browserStorage, browserCrypto, logger, eventHandler, config.system.navigationClient, apiId, performanceClient, platformAuthProvider, accountId, nativeStorage, request.correlationId, tokenBindingKeyManager);
21359
22681
  const { userRequestState } = parseRequestState(browserCrypto.base64Decode, request.state, request.correlationId);
21360
- return invokeAsync(nativeInteractionClient.acquireToken.bind(nativeInteractionClient), NativeInteractionClientAcquireToken, logger, performanceClient, request.correlationId)({
21361
- ...request,
21362
- state: userRequestState,
21363
- prompt: undefined, // Server should handle the prompt, ideally native broker can do this part silently
21364
- });
22682
+ try {
22683
+ return await invokeAsync(nativeInteractionClient.acquireToken.bind(nativeInteractionClient), NativeInteractionClientAcquireToken, logger, performanceClient, request.correlationId)({
22684
+ ...request,
22685
+ state: userRequestState,
22686
+ prompt: undefined, // Server should handle the prompt, ideally native broker can do this part silently
22687
+ });
22688
+ }
22689
+ catch (e) {
22690
+ await removeTokenBindingKeyOnFailure(request, tokenBindingKeyManager, logger, performanceClient);
22691
+ throw e;
22692
+ }
21365
22693
  }
21366
22694
  /**
21367
22695
  * Response handler when server returns code on the /authorize request
@@ -21374,13 +22702,13 @@ async function handleResponsePlatformBroker(request, accountId, apiId, config, b
21374
22702
  * @param performanceClient
21375
22703
  * @returns
21376
22704
  */
21377
- async function handleResponseCode(request, response, codeVerifier, apiId, config, authClient, browserStorage, nativeStorage, eventHandler, logger, performanceClient, platformAuthProvider) {
22705
+ async function handleResponseCode(request, response, codeVerifier, apiId, config, authClient, browserStorage, nativeStorage, eventHandler, logger, performanceClient, platformAuthProvider, tokenBindingKeyManager = new TokenBindingKeyManager(logger, performanceClient)) {
21378
22706
  // Remove throttle if it exists
21379
22707
  ThrottlingUtils.removeThrottle(browserStorage, config.auth.clientId, request);
21380
22708
  // Instrument clientdata telemetry fields from the authorize response
21381
22709
  instrumentClientData(response, request.correlationId, performanceClient);
21382
22710
  if (response.accountId) {
21383
- return invokeAsync(handleResponsePlatformBroker, HandleResponsePlatformBroker, logger, performanceClient, request.correlationId)(request, response.accountId, apiId, config, browserStorage, nativeStorage, eventHandler, logger, performanceClient, platformAuthProvider);
22711
+ return invokeAsync(handleResponsePlatformBroker, HandleResponsePlatformBroker, logger, performanceClient, request.correlationId)(request, response.accountId, apiId, config, browserStorage, nativeStorage, eventHandler, logger, performanceClient, platformAuthProvider, tokenBindingKeyManager);
21384
22712
  }
21385
22713
  const authCodeRequest = {
21386
22714
  ...request,
@@ -21408,7 +22736,7 @@ async function handleResponseCode(request, response, codeVerifier, apiId, config
21408
22736
  * @param nativeMessageHandler
21409
22737
  * @returns
21410
22738
  */
21411
- async function handleResponseEAR(request, response, apiId, config, authority, browserStorage, nativeStorage, eventHandler, logger, performanceClient, platformAuthProvider) {
22739
+ async function handleResponseEAR(request, response, apiId, config, authority, browserStorage, nativeStorage, eventHandler, logger, performanceClient, platformAuthProvider, tokenBindingKeyManager = new TokenBindingKeyManager(logger, performanceClient)) {
21412
22740
  // Remove throttle if it exists
21413
22741
  ThrottlingUtils.removeThrottle(browserStorage, config.auth.clientId, request);
21414
22742
  // Instrument clientdata telemetry fields from the authorize response
@@ -21423,9 +22751,9 @@ async function handleResponseEAR(request, response, apiId, config, authority, br
21423
22751
  }
21424
22752
  const decryptedData = JSON.parse(await invokeAsync(decryptEarResponse, DecryptEarResponse, logger, performanceClient, request.correlationId)(request.earJwk, response.ear_jwe));
21425
22753
  if (decryptedData.accountId) {
21426
- return invokeAsync(handleResponsePlatformBroker, HandleResponsePlatformBroker, logger, performanceClient, request.correlationId)(request, decryptedData.accountId, apiId, config, browserStorage, nativeStorage, eventHandler, logger, performanceClient, platformAuthProvider);
22754
+ return invokeAsync(handleResponsePlatformBroker, HandleResponsePlatformBroker, logger, performanceClient, request.correlationId)(request, decryptedData.accountId, apiId, config, browserStorage, nativeStorage, eventHandler, logger, performanceClient, platformAuthProvider, tokenBindingKeyManager);
21427
22755
  }
21428
- const responseHandler = new ResponseHandler(config.auth.clientId, browserStorage, new CryptoOps(logger, performanceClient), logger, performanceClient, null, null, new TokenBindingKeyManager(logger, performanceClient));
22756
+ const responseHandler = new ResponseHandler(config.auth.clientId, browserStorage, new CryptoOps(logger, performanceClient), logger, performanceClient, null, null, tokenBindingKeyManager);
21429
22757
  // Validate response. This function throws a server error if an error is returned by the server.
21430
22758
  responseHandler.validateTokenResponse(decryptedData, request.correlationId);
21431
22759
  // Temporary until response handler is refactored to be more flow agnostic.
@@ -21687,7 +23015,7 @@ function getHeaderDict(headers) {
21687
23015
  */
21688
23016
  // Default timeout for popup windows and iframes in milliseconds
21689
23017
  const DEFAULT_POPUP_TIMEOUT_MS = 60000;
21690
- const DEFAULT_IFRAME_TIMEOUT_MS = 10000;
23018
+ const DEFAULT_IFRAME_TIMEOUT_MS$1 = 10000;
21691
23019
  const DEFAULT_REDIRECT_TIMEOUT_MS = 30000;
21692
23020
  const DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS = 2000;
21693
23021
  /**
@@ -21728,6 +23056,8 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
21728
23056
  instanceAware: false,
21729
23057
  isMcp: false,
21730
23058
  verifySSO: false,
23059
+ // Legacy polling needs COOP omitted, so it implies asserting pocd=1.
23060
+ originCheck: !userInputSystem?.enableLegacyPolling,
21731
23061
  };
21732
23062
  // Default cache options for browser
21733
23063
  const DEFAULT_CACHE_OPTIONS = {
@@ -21752,7 +23082,7 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
21752
23082
  : StubbedNetworkModule,
21753
23083
  navigationClient: new NavigationClient(),
21754
23084
  popupBridgeTimeout: userInputSystem?.popupBridgeTimeout || DEFAULT_POPUP_TIMEOUT_MS,
21755
- iframeBridgeTimeout: userInputSystem?.iframeBridgeTimeout || DEFAULT_IFRAME_TIMEOUT_MS,
23085
+ iframeBridgeTimeout: userInputSystem?.iframeBridgeTimeout || DEFAULT_IFRAME_TIMEOUT_MS$1,
21756
23086
  redirectNavigationTimeout: DEFAULT_REDIRECT_TIMEOUT_MS,
21757
23087
  allowRedirectInIframe: false,
21758
23088
  navigatePopups: true,
@@ -21761,6 +23091,7 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
21761
23091
  DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS,
21762
23092
  protocolMode: ProtocolMode.AAD,
21763
23093
  serverTelemetryEnabled: false,
23094
+ enableLegacyPolling: false,
21764
23095
  };
21765
23096
  const providedSystemOptions = {
21766
23097
  ...DEFAULT_BROWSER_SYSTEM_OPTIONS,
@@ -21778,11 +23109,17 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
21778
23109
  iframeTimeoutTelemetry: false,
21779
23110
  allowPlatformBrokerWithDOM: false,
21780
23111
  };
23112
+ let logger;
23113
+ const getLogger = () => {
23114
+ if (!logger) {
23115
+ logger = new Logger(providedSystemOptions.loggerOptions, name, version);
23116
+ }
23117
+ return logger;
23118
+ };
21781
23119
  // Throw an error if user has set OIDCOptions without being in OIDC protocol mode
21782
23120
  if (userInputSystem?.protocolMode !== ProtocolMode.OIDC &&
21783
23121
  userInputAuth?.OIDCOptions) {
21784
- const logger = new Logger(providedSystemOptions.loggerOptions, name, version);
21785
- logger.warning(JSON.stringify(createClientConfigurationError(cannotSetOIDCOptions, "")), "");
23122
+ getLogger().warning(JSON.stringify(createClientConfigurationError(cannotSetOIDCOptions, "")), "");
21786
23123
  }
21787
23124
  // Throw an error if user has set allowPlatformBroker to true with OIDC protocol mode
21788
23125
  if (userInputSystem?.protocolMode &&
@@ -21790,6 +23127,24 @@ function buildConfiguration({ auth: userInputAuth, cache: userInputCache, system
21790
23127
  providedSystemOptions?.allowPlatformBroker) {
21791
23128
  throw createClientConfigurationError(cannotAllowPlatformBroker, "");
21792
23129
  }
23130
+ /*
23131
+ * The origin check computes 0 in the embedded contexts legacy polling
23132
+ * serves, so re-enabling it there breaks the flow. Honor it, but warn.
23133
+ */
23134
+ if (userInputSystem?.enableLegacyPolling &&
23135
+ userInputAuth?.originCheck === true) {
23136
+ 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.", "");
23137
+ }
23138
+ /*
23139
+ * Opting out is a deliberate risk transfer, not an error — but the app
23140
+ * cannot know at config time that the risky topology is actually present.
23141
+ */
23142
+ if ((userInputAuth?.originCheck ?? DEFAULT_AUTH_OPTIONS.originCheck) ===
23143
+ false &&
23144
+ typeof window !== "undefined" &&
23145
+ !topOpenerIsSameOriginOrAbsent(window)) {
23146
+ 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.", "");
23147
+ }
21793
23148
  const overlayedConfig = {
21794
23149
  auth: {
21795
23150
  ...DEFAULT_AUTH_OPTIONS,
@@ -21845,6 +23200,7 @@ class PlatformAuthExtensionHandler {
21845
23200
  const extensionRequest = { ...request };
21846
23201
  delete extensionRequest.resourceRequestMethod;
21847
23202
  delete extensionRequest.resourceRequestUri;
23203
+ delete extensionRequest.bindingPreferenceSent;
21848
23204
  const messageBody = {
21849
23205
  method: NativeExtensionMethod.GetToken,
21850
23206
  request: extensionRequest,
@@ -21856,8 +23212,9 @@ class PlatformAuthExtensionHandler {
21856
23212
  body: messageBody,
21857
23213
  };
21858
23214
  this.logger.trace(`1qadfi ${this.platformAuthType}`, correlationId);
21859
- this.logger.tracePii(`1xm533 ${this.platformAuthType} ${JSON.stringify(req)}`, correlationId);
21860
23215
  this.messageChannel.port1.postMessage(req);
23216
+ request.bindingPreferenceSent =
23217
+ extensionRequest.preferBinding !== undefined;
21861
23218
  const response = await new Promise((resolve, reject) => {
21862
23219
  this.resolvers.set(req.responseId, {
21863
23220
  resolve,
@@ -22054,13 +23411,11 @@ class PlatformAuthExtensionHandler {
22054
23411
  try {
22055
23412
  const response = request.body.response;
22056
23413
  this.logger.trace(`19hpgm ${this.platformAuthType}`, correlationId);
22057
- this.logger.tracePii(`179a24 ${this.platformAuthType} ${JSON.stringify(response)}`, correlationId);
22058
23414
  if (response.status !== "Success") {
22059
23415
  resolver.reject(createNativeAuthError(response.code, correlationId, response.description, response.ext));
22060
23416
  }
22061
23417
  else if (response.result) {
22062
- if (response.result["code"] &&
22063
- response.result["description"]) {
23418
+ if (response.result["code"]) {
22064
23419
  resolver.reject(createNativeAuthError(response.result["code"], correlationId, response.result["description"], response.result["ext"]));
22065
23420
  }
22066
23421
  else {
@@ -22141,11 +23496,12 @@ class PlatformAuthExtensionHandler {
22141
23496
  Object.prototype.hasOwnProperty.call(response, "account") &&
22142
23497
  Object.prototype.hasOwnProperty.call(response, "scope") &&
22143
23498
  Object.prototype.hasOwnProperty.call(response, "expires_in")) {
23499
+ const validatedResponse = response;
22144
23500
  validationMeasurement.end({
22145
23501
  success: true,
22146
23502
  platformAuthProviderType: this.platformAuthType,
22147
23503
  });
22148
- return response;
23504
+ return validatedResponse;
22149
23505
  }
22150
23506
  else {
22151
23507
  const error = createAuthError(unexpectedError, responseCorrelationId, "Response missing expected properties.");
@@ -22187,6 +23543,7 @@ class PlatformAuthExtensionHandler {
22187
23543
  * Copyright (c) Microsoft Corporation. All rights reserved.
22188
23544
  * Licensed under the MIT License.
22189
23545
  */
23546
+ const PLATFORM_AUTH_DOM_DPOP_NOT_SUPPORTED = "platform_auth_dom_dpop_not_supported";
22190
23547
  class PlatformAuthDOMHandler {
22191
23548
  constructor(logger, performanceClient, correlationId) {
22192
23549
  this.logger = logger;
@@ -22266,6 +23623,10 @@ class PlatformAuthDOMHandler {
22266
23623
  });
22267
23624
  this.logger.trace(`02bcil ${this.platformAuthType}`, correlationId);
22268
23625
  try {
23626
+ if (request.tokenType?.trim().toLowerCase() ===
23627
+ PlatformAuthTokenType.DPOP_WITH_PROOF) {
23628
+ throw createBrowserAuthError(PLATFORM_AUTH_DOM_DPOP_NOT_SUPPORTED, correlationId);
23629
+ }
22269
23630
  const platformDOMRequest = invoke(this.initializePlatformDOMRequest.bind(this), PlatformAuthDOMInitializeRequest, this.logger, this.performanceClient, correlationId)(request);
22270
23631
  const response =
22271
23632
  // @ts-ignore
@@ -22292,6 +23653,7 @@ class PlatformAuthDOMHandler {
22292
23653
  this.logger.trace(`15d6yv ${this.platformAuthType}`, requestCorrelationId);
22293
23654
  delete remainingProperties.resourceRequestMethod;
22294
23655
  delete remainingProperties.resourceRequestUri;
23656
+ delete remainingProperties.bindingPreferenceSent;
22295
23657
  const validExtraParameters = this.getDOMExtraParams(remainingProperties, requestCorrelationId);
22296
23658
  const platformDOMRequest = {
22297
23659
  accountId: accountId,
@@ -22502,7 +23864,9 @@ function isPlatformAuthAllowed(config, logger, correlationId, platformAuthProvid
22502
23864
  logger.trace("0uko3r", correlationId);
22503
23865
  const schemeSupported = !authenticationScheme ||
22504
23866
  authenticationScheme === AuthenticationScheme.BEARER ||
22505
- authenticationScheme === AuthenticationScheme.POP;
23867
+ authenticationScheme === AuthenticationScheme.POP ||
23868
+ (authenticationScheme === AuthenticationScheme.DPOP &&
23869
+ !(platformAuthProvider instanceof PlatformAuthDOMHandler));
22506
23870
  const fields = {
22507
23871
  allowPlatformBroker: config.system.allowPlatformBroker,
22508
23872
  ...(config.system.allowPlatformBroker && {
@@ -22598,6 +23962,9 @@ class PopupClient extends StandardInteractionClient {
22598
23962
  popupWindowAttributes: logoutRequest?.popupWindowAttributes || {},
22599
23963
  popupWindowParent: logoutRequest?.popupWindowParent ?? window,
22600
23964
  };
23965
+ validLogoutRequest.popupOriginCheckDone =
23966
+ this.getPopupOriginCheckDone(popupParams.popupWindowParent) ??
23967
+ validLogoutRequest.popupOriginCheckDone;
22601
23968
  const authority = logoutRequest && logoutRequest.authority;
22602
23969
  const mainWindowRedirectUri = logoutRequest && logoutRequest.mainWindowRedirectUri;
22603
23970
  // navigatePopups flag set to false. Acquires token without first opening popup. Popup will be opened later asynchronously.
@@ -22662,6 +24029,7 @@ class PopupClient extends StandardInteractionClient {
22662
24029
  ...request,
22663
24030
  codeChallenge: pkce.challenge,
22664
24031
  ...tokenBindingParams,
24032
+ popupOriginCheckDone: this.getPopupOriginCheckDone(popupParams.popupWindowParent),
22665
24033
  };
22666
24034
  try {
22667
24035
  // Initialize the client
@@ -22695,12 +24063,13 @@ class PopupClient extends StandardInteractionClient {
22695
24063
  // Wait for the redirect bridge response
22696
24064
  const responseString = await this.waitForPopupResponse(request, popupWindow, popupParams.popupWindowParent);
22697
24065
  const serverParams = invoke(deserializeResponse, DeserializeResponse, this.logger, this.performanceClient, this.correlationId)(responseString, this.config.auth.OIDCOptions.responseMode, this.logger, this.correlationId);
22698
- 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);
24066
+ 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);
22699
24067
  }
22700
24068
  }
22701
24069
  catch (e) {
22702
24070
  // Close the synchronous popup if an error is thrown before the window unload event is registered
22703
24071
  popupParams.popup?.close();
24072
+ await removeTokenBindingKeyOnFailure(popupRequest, this.tokenBindingKeyManager, this.logger, this.performanceClient);
22704
24073
  if (e instanceof AuthError) {
22705
24074
  e.correlationId = this.correlationId;
22706
24075
  serverTelemetryManager.cacheFailedRequest(e);
@@ -22725,24 +24094,31 @@ class PopupClient extends StandardInteractionClient {
22725
24094
  earJwk: earJwk,
22726
24095
  codeChallenge: pkce.challenge,
22727
24096
  ...tokenBindingParams,
24097
+ popupOriginCheckDone: this.getPopupOriginCheckDone(popupParams.popupWindowParent),
22728
24098
  };
22729
- const popupWindow = await this.openPostFormPopup(popupRequest, discoveredAuthority, popupParams, correlationId, true);
22730
- // Monitor the popup for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.
22731
- const responseString = await invokeAsync(this.waitForPopupResponse.bind(this), SilentHandlerMonitorIframeForHash, this.logger, this.performanceClient, correlationId)(popupRequest, popupWindow, popupParams.popupWindowParent);
22732
- const serverParams = invoke(deserializeResponse, DeserializeResponse, this.logger, this.performanceClient, this.correlationId)(responseString, this.config.auth.OIDCOptions.responseMode, this.logger, this.correlationId);
22733
- if (!serverParams.ear_jwe && serverParams.code) {
22734
- const authClient = await invokeAsync(this.createAuthCodeClient.bind(this), StandardInteractionClientCreateAuthCodeClient, this.logger, this.performanceClient, correlationId)({
22735
- serverTelemetryManager: initializeServerTelemetryManager(ApiId.acquireTokenPopup, this.config.auth.clientId, correlationId, this.browserStorage, this.logger, undefined, this.config.system.serverTelemetryEnabled),
22736
- requestAuthority: request.authority,
22737
- requestAzureCloudOptions: request.azureCloudOptions,
22738
- requestExtraQueryParameters: request.extraQueryParameters,
22739
- account: request.account,
22740
- authority: discoveredAuthority,
22741
- });
22742
- 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);
24099
+ try {
24100
+ const popupWindow = await this.openPostFormPopup(popupRequest, discoveredAuthority, popupParams, correlationId, true);
24101
+ // Monitor the popup for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.
24102
+ const responseString = await invokeAsync(this.waitForPopupResponse.bind(this), SilentHandlerMonitorIframeForHash, this.logger, this.performanceClient, correlationId)(popupRequest, popupWindow, popupParams.popupWindowParent);
24103
+ const serverParams = invoke(deserializeResponse, DeserializeResponse, this.logger, this.performanceClient, this.correlationId)(responseString, this.config.auth.OIDCOptions.responseMode, this.logger, this.correlationId);
24104
+ if (!serverParams.ear_jwe && serverParams.code) {
24105
+ const authClient = await invokeAsync(this.createAuthCodeClient.bind(this), StandardInteractionClientCreateAuthCodeClient, this.logger, this.performanceClient, correlationId)({
24106
+ serverTelemetryManager: initializeServerTelemetryManager(ApiId.acquireTokenPopup, this.config.auth.clientId, correlationId, this.browserStorage, this.logger, undefined, this.config.system.serverTelemetryEnabled),
24107
+ requestAuthority: request.authority,
24108
+ requestAzureCloudOptions: request.azureCloudOptions,
24109
+ requestExtraQueryParameters: request.extraQueryParameters,
24110
+ account: request.account,
24111
+ authority: discoveredAuthority,
24112
+ });
24113
+ 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);
24114
+ }
24115
+ else {
24116
+ 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);
24117
+ }
22743
24118
  }
22744
- else {
22745
- 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);
24119
+ catch (e) {
24120
+ await removeTokenBindingKeyOnFailure(popupRequest, this.tokenBindingKeyManager, this.logger, this.performanceClient);
24121
+ throw e;
22746
24122
  }
22747
24123
  }
22748
24124
  async executeCodeFlowWithPost(request, popupParams, authClient, pkceVerifier) {
@@ -22753,7 +24129,7 @@ class PopupClient extends StandardInteractionClient {
22753
24129
  // Monitor the popup for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.
22754
24130
  const responseString = await invokeAsync(this.waitForPopupResponse.bind(this), SilentHandlerMonitorIframeForHash, this.logger, this.performanceClient, correlationId)(request, popupWindow, popupParams.popupWindowParent);
22755
24131
  const serverParams = invoke(deserializeResponse, DeserializeResponse, this.logger, this.performanceClient, this.correlationId)(responseString, this.config.auth.OIDCOptions.responseMode, this.logger, this.correlationId);
22756
- 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);
24132
+ 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);
22757
24133
  }
22758
24134
  /**
22759
24135
  *
@@ -22997,6 +24373,27 @@ class PopupClient extends StandardInteractionClient {
22997
24373
  getRelayStateId(state, correlationId) {
22998
24374
  return parseRequestState(base64Decode, state, correlationId).libraryState.id;
22999
24375
  }
24376
+ /**
24377
+ * Asserts `pocd=1` for the relay flow. Direct popups also require the
24378
+ * environment of a delegated opening window to pass the origin check.
24379
+ *
24380
+ * With a relay the IdP window is a grandchild popup, which an untrusted
24381
+ * ancestor cannot reach by name — so the topology satisfies the check by
24382
+ * construction. The current window is framed and would otherwise compute
24383
+ * `0`. Without a delegated parent, the standard app check remains unchanged.
24384
+ *
24385
+ * @param popupWindowParent Window that opens the popup.
24386
+ */
24387
+ getPopupOriginCheckDone(popupWindowParent) {
24388
+ if (this.config.auth.popupRelayUri) {
24389
+ return true;
24390
+ }
24391
+ if (popupWindowParent !== window) {
24392
+ return (computePocd(this.config) === 1 &&
24393
+ computePocd(this.config, popupWindowParent) === 1);
24394
+ }
24395
+ return undefined;
24396
+ }
23000
24397
  /**
23001
24398
  * Opens the interactive popup for a POST-form /authorize request. Shared by
23002
24399
  * the auth-code POST and EAR flows, which are identical apart from the form
@@ -23120,8 +24517,11 @@ class RedirectClient extends StandardInteractionClient {
23120
24517
  codeChallenge: pkceCodes.challenge,
23121
24518
  ...tokenBindingParams,
23122
24519
  };
23123
- this.browserStorage.cacheAuthorizeRequest(redirectRequest, this.correlationId, pkceCodes.verifier);
23124
24520
  try {
24521
+ if (!(await isTokenBindingKeyPersistedForRedirect(redirectRequest, this.tokenBindingKeyManager))) {
24522
+ throw createBrowserAuthError(cryptoKeyNotFound, this.correlationId);
24523
+ }
24524
+ this.browserStorage.cacheAuthorizeRequest(redirectRequest, this.correlationId, pkceCodes.verifier);
23125
24525
  if (redirectRequest.httpMethod === HttpMethod$1.POST) {
23126
24526
  return await this.executeCodeFlowWithPost(redirectRequest);
23127
24527
  }
@@ -23141,6 +24541,7 @@ class RedirectClient extends StandardInteractionClient {
23141
24541
  }
23142
24542
  }
23143
24543
  catch (e) {
24544
+ await removeTokenBindingKeyOnFailure(redirectRequest, this.tokenBindingKeyManager, this.logger, this.performanceClient);
23144
24545
  if (e instanceof AuthError) {
23145
24546
  e.correlationId = this.correlationId;
23146
24547
  serverTelemetryManager.cacheFailedRequest(e);
@@ -23165,14 +24566,23 @@ class RedirectClient extends StandardInteractionClient {
23165
24566
  codeChallenge: pkceCodes.challenge,
23166
24567
  ...tokenBindingParams,
23167
24568
  };
23168
- this.browserStorage.cacheAuthorizeRequest(redirectRequest, this.correlationId, pkceCodes.verifier);
23169
- const form = await getEARForm(document, this.config, discoveredAuthority, redirectRequest, this.logger, this.performanceClient);
23170
- form.submit();
23171
- return new Promise((resolve, reject) => {
23172
- setTimeout(() => {
23173
- reject(createBrowserAuthError(timedOut, "", "failed_to_redirect"));
23174
- }, this.config.system.redirectNavigationTimeout);
23175
- });
24569
+ try {
24570
+ if (!(await isTokenBindingKeyPersistedForRedirect(redirectRequest, this.tokenBindingKeyManager))) {
24571
+ throw createBrowserAuthError(cryptoKeyNotFound, this.correlationId);
24572
+ }
24573
+ this.browserStorage.cacheAuthorizeRequest(redirectRequest, this.correlationId, pkceCodes.verifier);
24574
+ const form = await getEARForm(document, this.config, discoveredAuthority, redirectRequest, this.logger, this.performanceClient);
24575
+ form.submit();
24576
+ return await new Promise((resolve, reject) => {
24577
+ setTimeout(() => {
24578
+ reject(createBrowserAuthError(timedOut, "", "failed_to_redirect"));
24579
+ }, this.config.system.redirectNavigationTimeout);
24580
+ });
24581
+ }
24582
+ catch (e) {
24583
+ await removeTokenBindingKeyOnFailure(redirectRequest, this.tokenBindingKeyManager, this.logger, this.performanceClient);
24584
+ throw e;
24585
+ }
23176
24586
  }
23177
24587
  /**
23178
24588
  * Executes classic Authorization Code flow with a POST request.
@@ -23211,6 +24621,7 @@ class RedirectClient extends StandardInteractionClient {
23211
24621
  if (!serverParams) {
23212
24622
  // Not a recognized server response hash or hash not associated with a redirect request
23213
24623
  this.logger.info("1qmv0q", this.correlationId);
24624
+ await removeTokenBindingKeyOnFailure(request, this.tokenBindingKeyManager, this.logger, this.performanceClient);
23214
24625
  this.browserStorage.resetRequestCache(this.correlationId);
23215
24626
  // Do not instrument "no_server_response" if user clicked back button
23216
24627
  if (getNavigationType() !== "back_forward") {
@@ -23280,6 +24691,7 @@ class RedirectClient extends StandardInteractionClient {
23280
24691
  return null;
23281
24692
  }
23282
24693
  catch (e) {
24694
+ await removeTokenBindingKeyOnFailure(request, this.tokenBindingKeyManager, this.logger, this.performanceClient);
23283
24695
  if (e instanceof AuthError) {
23284
24696
  e.correlationId = this.correlationId;
23285
24697
  serverTelemetryManager.cacheFailedRequest(e);
@@ -23319,7 +24731,6 @@ class RedirectClient extends StandardInteractionClient {
23319
24731
  }
23320
24732
  return [null, ""];
23321
24733
  }
23322
- clearHash(window);
23323
24734
  this.logger.verbose("00uvho", this.correlationId);
23324
24735
  return [response, responseString];
23325
24736
  }
@@ -23347,10 +24758,10 @@ class RedirectClient extends StandardInteractionClient {
23347
24758
  const { authority, azureCloudOptions, extraQueryParameters, account } = request;
23348
24759
  if (serverParams.ear_jwe) {
23349
24760
  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);
23350
- 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);
24761
+ 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);
23351
24762
  }
23352
24763
  const authClient = await invokeAsync(this.createAuthCodeClient.bind(this), StandardInteractionClientCreateAuthCodeClient, this.logger, this.performanceClient, this.correlationId)({ serverTelemetryManager, requestAuthority: request.authority });
23353
- 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);
24764
+ 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);
23354
24765
  }
23355
24766
  /**
23356
24767
  * Redirects window to given URL.
@@ -23681,10 +25092,10 @@ class SilentIframeClient extends StandardInteractionClient {
23681
25092
  account: request.account,
23682
25093
  authority: discoveredAuthority,
23683
25094
  });
23684
- 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);
25095
+ 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);
23685
25096
  }
23686
25097
  else {
23687
- 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);
25098
+ 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);
23688
25099
  }
23689
25100
  }
23690
25101
  /**
@@ -23734,7 +25145,13 @@ class SilentIframeClient extends StandardInteractionClient {
23734
25145
  */
23735
25146
  async silentTokenHelper(authClient, request) {
23736
25147
  const { serverParams, pkceCodes, silentRequest } = await this.silentAuthorizeHelper(authClient, request);
23737
- 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);
25148
+ try {
25149
+ 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);
25150
+ }
25151
+ catch (e) {
25152
+ await removeTokenBindingKeyOnFailure(silentRequest, this.tokenBindingKeyManager, this.logger, this.performanceClient);
25153
+ throw e;
25154
+ }
23738
25155
  }
23739
25156
  /**
23740
25157
  * Shared helper that generates PKCE codes, builds the /authorize URL,
@@ -23751,38 +25168,44 @@ class SilentIframeClient extends StandardInteractionClient {
23751
25168
  codeChallenge: pkceCodes.challenge,
23752
25169
  ...tokenBindingParams,
23753
25170
  };
23754
- // Create the iframe, register the response listener, then navigate, so the listener is active before the iframe can respond.
23755
- const iframe = createHiddenIframe();
23756
- const responseType = this.config.auth.OIDCOptions.responseMode;
23757
- // Wait for response from the redirect bridge.
23758
- let responseString;
23759
25171
  try {
23760
- const responsePromise = invokeAsync(this.waitForIframeResponse.bind(this), SilentHandlerMonitorIframeForHash, this.logger, this.performanceClient, correlationId)(iframe, request);
23761
- responsePromise.catch(() => {
23762
- /*
23763
- * If URL creation or navigation below throws before
23764
- * responsePromise is awaited, the listener still rejects on
23765
- * timeout. Swallow it here so it does not surface as an
23766
- * unhandled rejection; the navigation error is propagated
23767
- * instead.
23768
- */
23769
- });
23770
- if (request.httpMethod === HttpMethod$1.POST) {
23771
- await invokeAsync(initiateCodeFlowWithPost, SilentHandlerInitiateAuthRequest, this.logger, this.performanceClient, correlationId)(iframe, this.config, authClient.authority, silentRequest, this.logger, this.performanceClient);
25172
+ // Create the iframe, register the response listener, then navigate, so the listener is active before the iframe can respond.
25173
+ const iframe = createHiddenIframe();
25174
+ const responseType = this.config.auth.OIDCOptions.responseMode;
25175
+ // Wait for response from the redirect bridge.
25176
+ let responseString;
25177
+ try {
25178
+ const responsePromise = invokeAsync(this.waitForIframeResponse.bind(this), SilentHandlerMonitorIframeForHash, this.logger, this.performanceClient, correlationId)(iframe, request);
25179
+ responsePromise.catch(() => {
25180
+ /*
25181
+ * If URL creation or navigation below throws before
25182
+ * responsePromise is awaited, the listener still rejects on
25183
+ * timeout. Swallow it here so it does not surface as an
25184
+ * unhandled rejection; the navigation error is propagated
25185
+ * instead.
25186
+ */
25187
+ });
25188
+ if (request.httpMethod === HttpMethod$1.POST) {
25189
+ await invokeAsync(initiateCodeFlowWithPost, SilentHandlerInitiateAuthRequest, this.logger, this.performanceClient, correlationId)(iframe, this.config, authClient.authority, silentRequest, this.logger, this.performanceClient);
25190
+ }
25191
+ else {
25192
+ // Create authorize request url
25193
+ const navigateUrl = await invokeAsync(getAuthCodeRequestUrl, GetAuthCodeUrl, this.logger, this.performanceClient, correlationId)(this.config, authClient.authority, silentRequest, this.logger, this.performanceClient);
25194
+ // Navigate the iframe to the authorize request url
25195
+ await invokeAsync(initiateCodeRequest, SilentHandlerInitiateAuthRequest, this.logger, this.performanceClient, correlationId)(iframe, navigateUrl, this.logger, correlationId);
25196
+ }
25197
+ responseString = await responsePromise;
23772
25198
  }
23773
- else {
23774
- // Create authorize request url
23775
- const navigateUrl = await invokeAsync(getAuthCodeRequestUrl, GetAuthCodeUrl, this.logger, this.performanceClient, correlationId)(this.config, authClient.authority, silentRequest, this.logger, this.performanceClient);
23776
- // Navigate the iframe to the authorize request url
23777
- await invokeAsync(initiateCodeRequest, SilentHandlerInitiateAuthRequest, this.logger, this.performanceClient, correlationId)(iframe, navigateUrl, this.logger, correlationId);
25199
+ finally {
25200
+ invoke(removeHiddenIframe, RemoveHiddenIframe, this.logger, this.performanceClient, correlationId)(iframe);
23778
25201
  }
23779
- responseString = await responsePromise;
25202
+ const serverParams = invoke(deserializeResponse, DeserializeResponse, this.logger, this.performanceClient, correlationId)(responseString, responseType, this.logger, this.correlationId);
25203
+ return { serverParams, pkceCodes, silentRequest };
23780
25204
  }
23781
- finally {
23782
- invoke(removeHiddenIframe, RemoveHiddenIframe, this.logger, this.performanceClient, correlationId)(iframe);
25205
+ catch (e) {
25206
+ await removeTokenBindingKeyOnFailure(silentRequest, this.tokenBindingKeyManager, this.logger, this.performanceClient);
25207
+ throw e;
23783
25208
  }
23784
- const serverParams = invoke(deserializeResponse, DeserializeResponse, this.logger, this.performanceClient, correlationId)(responseString, responseType, this.logger, this.correlationId);
23785
- return { serverParams, pkceCodes, silentRequest };
23786
25209
  }
23787
25210
  async waitForIframeResponse(iframe, request) {
23788
25211
  if (this.waitForIframeResponseHook) {
@@ -24043,7 +25466,6 @@ function getPlatformSilentRequestKey(request, config) {
24043
25466
  : undefined,
24044
25467
  extraParameters: canonicalizeStringDict(request.extraParameters),
24045
25468
  extraQueryParameters: canonicalizeStringDict(request.extraQueryParameters),
24046
- extraParametersNoCache: canonicalizeStringDict(request.extraParametersNoCache),
24047
25469
  forceRefresh: !!request.forceRefresh,
24048
25470
  cacheLookupPolicy: request.cacheLookupPolicy ?? CacheLookupPolicy.Default,
24049
25471
  });
@@ -24052,8 +25474,12 @@ function getPlatformSilentRequestKey(request, config) {
24052
25474
  * Copies caller-owned mutable inputs before asynchronous broker initialization.
24053
25475
  */
24054
25476
  function snapshotPlatformSilentRequest(request) {
24055
- return {
25477
+ const snapshot = {
24056
25478
  ...request,
25479
+ };
25480
+ delete snapshot.extraParametersNoCache;
25481
+ return {
25482
+ ...snapshot,
24057
25483
  scopes: [...(request.scopes || [])],
24058
25484
  account: { ...request.account },
24059
25485
  azureCloudOptions: request.azureCloudOptions
@@ -24065,9 +25491,6 @@ function snapshotPlatformSilentRequest(request) {
24065
25491
  extraQueryParameters: request.extraQueryParameters
24066
25492
  ? { ...request.extraQueryParameters }
24067
25493
  : undefined,
24068
- extraParametersNoCache: request.extraParametersNoCache
24069
- ? { ...request.extraParametersNoCache }
24070
- : undefined,
24071
25494
  attributeTokens: request.attributeTokens
24072
25495
  ? [...request.attributeTokens]
24073
25496
  : undefined,
@@ -24278,7 +25701,32 @@ class StandardController {
24278
25701
  * @returns
24279
25702
  */
24280
25703
  async handleRedirectPromiseInternal(options) {
24281
- if (!this.browserStorage.isInteractionInProgress(true)) {
25704
+ // Preserve the response for RedirectClient before removing it from the URL.
25705
+ const responseString = options?.hash ||
25706
+ (this.config.auth.OIDCOptions.responseMode ===
25707
+ ResponseMode.QUERY
25708
+ ? window.location.search
25709
+ : window.location.hash);
25710
+ const anyClientInteractionInProgress = this.browserStorage.isInteractionInProgress(false);
25711
+ const currentClientInteraction = this.browserStorage.isInteractionInProgress(true);
25712
+ const isBridgeCallback = isInPopup() ||
25713
+ (isInIframe() &&
25714
+ !this.config.system.allowRedirectInIframe);
25715
+ /*
25716
+ * Clear recognized response fragments for:
25717
+ * - Stale callbacks with no pending interaction.
25718
+ * - This client's login callback, even if request setup or response validation fails.
25719
+ * - This client's logout callback containing state, before the SIGNOUT early return.
25720
+ * Leave another client's callback untouched. clearHash preserves query strings
25721
+ * and application routes, and does nothing when no response fragment is present.
25722
+ * Skip popup and non-redirect iframe callbacks: legacy apps may call HRP
25723
+ * before their redirect bridge reads and broadcasts the response.
25724
+ */
25725
+ if (!isBridgeCallback &&
25726
+ (!anyClientInteractionInProgress || currentClientInteraction)) {
25727
+ clearHash(window);
25728
+ }
25729
+ if (!currentClientInteraction) {
24282
25730
  this.logger.info("0le6uv", "");
24283
25731
  return null;
24284
25732
  }
@@ -24286,7 +25734,7 @@ class StandardController {
24286
25734
  if (interactionType === INTERACTION_TYPE.SIGNOUT) {
24287
25735
  this.logger.verbose("1ywcv2", "");
24288
25736
  this.browserStorage.setInteractionInProgress(false);
24289
- return Promise.resolve(null);
25737
+ return null;
24290
25738
  }
24291
25739
  const loggedInAccounts = this.getAllAccounts();
24292
25740
  const platformBrokerRequest = this.browserStorage.getCachedNativeRequest();
@@ -24316,7 +25764,9 @@ class StandardController {
24316
25764
  rootMeasurement = this.performanceClient.startMeasurement(AcquireTokenRedirect, correlationId);
24317
25765
  this.logger.trace("0znzs5", correlationId);
24318
25766
  const redirectClient = this.createRedirectClient(correlationId);
24319
- redirectResponse = invokeAsync(redirectClient.handleRedirectPromise.bind(redirectClient), HandleRedirectPromiseMeasurement, this.logger, this.performanceClient, rootMeasurement.event.correlationId)(standardRequest, codeVerifier, rootMeasurement, options);
25767
+ redirectResponse = invokeAsync(redirectClient.handleRedirectPromise.bind(redirectClient), HandleRedirectPromiseMeasurement, this.logger, this.performanceClient, rootMeasurement.event.correlationId)(standardRequest, codeVerifier, rootMeasurement, options?.hash
25768
+ ? options
25769
+ : { ...options, hash: responseString });
24320
25770
  }
24321
25771
  }
24322
25772
  catch (e) {
@@ -24405,8 +25855,9 @@ class StandardController {
24405
25855
  let result;
24406
25856
  const platformAuthProvider = this.platformAuthProvider;
24407
25857
  if (this.canUsePlatformBroker(request) && platformAuthProvider) {
25858
+ const nativeRequest = this.sanitizeNativeBrokerRequest(request, correlationId);
24408
25859
  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);
24409
- result = invokeAsync(nativeClient.acquireTokenRedirect.bind(nativeClient), NativeInteractionClientAcquireTokenRedirect, this.logger, this.performanceClient, correlationId)(request, atrMeasurement).catch((e) => {
25860
+ result = invokeAsync(nativeClient.acquireTokenRedirect.bind(nativeClient), NativeInteractionClientAcquireTokenRedirect, this.logger, this.performanceClient, correlationId)(nativeRequest, atrMeasurement).catch((e) => {
24410
25861
  if (e instanceof NativeAuthError &&
24411
25862
  isFatalNativeAuthError(e)) {
24412
25863
  this.platformAuthProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt platform broker calls
@@ -24464,6 +25915,9 @@ class StandardController {
24464
25915
  this.logger.verbose("0ch87b", correlationId);
24465
25916
  preflightCheck(this.initialized, atPopupMeasurement, this.config, request);
24466
25917
  this.browserStorage.setInteractionInProgress(true, INTERACTION_TYPE.SIGNIN, request.overrideInteractionInProgress, correlationId);
25918
+ if (request.overrideInteractionInProgress) {
25919
+ cancelPendingPopupPollingResponse(this.logger);
25920
+ }
24467
25921
  }
24468
25922
  catch (e) {
24469
25923
  // Since this function is syncronous we need to reject
@@ -24948,6 +26402,13 @@ class StandardController {
24948
26402
  const correlationId = this.getRequestCorrelationId(logoutRequest);
24949
26403
  redirectPreflightCheck(this.initialized, this.config);
24950
26404
  this.browserStorage.setInteractionInProgress(true, INTERACTION_TYPE.SIGNOUT);
26405
+ try {
26406
+ await this.clearNativeCache(logoutRequest?.account, correlationId);
26407
+ }
26408
+ catch (error) {
26409
+ this.browserStorage.setInteractionInProgress(false);
26410
+ throw error;
26411
+ }
24951
26412
  const redirectClient = this.createRedirectClient(correlationId);
24952
26413
  return redirectClient.logout(logoutRequest);
24953
26414
  }
@@ -24961,7 +26422,11 @@ class StandardController {
24961
26422
  preflightCheck$1(this.initialized);
24962
26423
  this.browserStorage.setInteractionInProgress(true, INTERACTION_TYPE.SIGNOUT);
24963
26424
  const popupClient = this.createPopupClient(correlationId);
24964
- return popupClient.logout(logoutRequest).finally(() => {
26425
+ const nativeCacheClear = this.clearNativeCache(logoutRequest?.account, correlationId);
26426
+ const popupLogout = popupClient.logout(logoutRequest);
26427
+ return Promise.all([nativeCacheClear, popupLogout])
26428
+ .then(() => undefined)
26429
+ .finally(() => {
24965
26430
  this.browserStorage.setInteractionInProgress(false);
24966
26431
  });
24967
26432
  }
@@ -24980,7 +26445,30 @@ class StandardController {
24980
26445
  }
24981
26446
  const correlationId = this.getRequestCorrelationId(logoutRequest);
24982
26447
  const cacheClient = this.createSilentCacheClient(correlationId);
24983
- return cacheClient.logout(logoutRequest);
26448
+ const nativeCacheClear = this.clearNativeCache(logoutRequest?.account, correlationId);
26449
+ const browserCacheClear = cacheClient.logout(logoutRequest);
26450
+ await Promise.all([nativeCacheClear, browserCacheClear]);
26451
+ }
26452
+ async clearNativeCache(account, correlationId) {
26453
+ const homeAccountId = account?.homeAccountId.toLowerCase();
26454
+ const environment = account?.environment.toLowerCase();
26455
+ const accessTokenKeys = this.nativeInternalStorage
26456
+ .getTokenKeys()
26457
+ .accessToken.filter((key) => {
26458
+ if (!account) {
26459
+ return true;
26460
+ }
26461
+ const accessToken = this.nativeInternalStorage.getAccessTokenCredential(key, correlationId);
26462
+ if (!accessToken) {
26463
+ return false;
26464
+ }
26465
+ return (accessToken.homeAccountId.toLowerCase() === homeAccountId &&
26466
+ accessToken.environment.toLowerCase() === environment);
26467
+ });
26468
+ await Promise.all(accessTokenKeys.map((key) => this.nativeInternalStorage.removeAccessTokenAndTokenBindingKey(key, correlationId)));
26469
+ if (!account) {
26470
+ this.nativeInternalStorage.clear(correlationId);
26471
+ }
24984
26472
  }
24985
26473
  // #endregion
24986
26474
  // #region Account APIs
@@ -25062,6 +26550,19 @@ class StandardController {
25062
26550
  }
25063
26551
  }
25064
26552
  // #region Helpers
26553
+ /**
26554
+ * Removes internal DPoP key state from application-originated broker requests.
26555
+ */
26556
+ sanitizeNativeBrokerRequest(request, correlationId) {
26557
+ if (!request.dpopJkt) {
26558
+ return request;
26559
+ }
26560
+ this.logger.warning("0rh2us", correlationId);
26561
+ return {
26562
+ ...request,
26563
+ dpopJkt: undefined,
26564
+ };
26565
+ }
25065
26566
  /**
25066
26567
  * Acquire a token from native device (e.g. WAM)
25067
26568
  * @param request
@@ -25081,7 +26582,8 @@ class StandardController {
25081
26582
  throw createBrowserAuthError(nativeConnectionNotEstablished, correlationId);
25082
26583
  }
25083
26584
  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);
25084
- return invokeAsync(nativeClient.acquireToken.bind(nativeClient), NativeInteractionClientAcquireToken, this.logger, this.performanceClient, correlationId)(request, cacheLookupPolicy);
26585
+ const nativeRequest = this.sanitizeNativeBrokerRequest(request, correlationId);
26586
+ return invokeAsync(nativeClient.acquireToken.bind(nativeClient), NativeInteractionClientAcquireToken, this.logger, this.performanceClient, correlationId)(nativeRequest, cacheLookupPolicy);
25085
26587
  }
25086
26588
  /**
25087
26589
  * Returns boolean indicating if this request can use the platform broker
@@ -25361,14 +26863,23 @@ class StandardController {
25361
26863
  correlationId,
25362
26864
  config: this.config,
25363
26865
  }, this.platformAuthProvider, this.logger, this.performanceClient);
25364
- const inProgressRequest = this.activeSilentTokenRequests.get(preparedRequest.key);
26866
+ const shouldDeduplicate = preparedRequest.request.authenticationScheme !==
26867
+ AuthenticationScheme.DPOP;
26868
+ const inProgressRequest = shouldDeduplicate
26869
+ ? this.activeSilentTokenRequests.get(preparedRequest.key)
26870
+ : undefined;
25365
26871
  if (typeof inProgressRequest === "undefined") {
25366
- this.logger.verbose("0fcjbk", correlationId);
26872
+ this.logger.verbose(shouldDeduplicate
26873
+ ? "0fcjbk"
26874
+ : "acquireTokenSilent called for DPoP request, starting an independent operation", correlationId);
25367
26875
  this.performanceClient.addFields({ deduped: false }, correlationId);
25368
26876
  const activeRequest = invokeAsync(this.acquireTokenSilentAsync.bind(this), AcquireTokenSilentAsync, this.logger, this.performanceClient, correlationId)({
25369
26877
  ...preparedRequest.request,
25370
26878
  correlationId,
25371
26879
  }, preparedRequest.account);
26880
+ if (!shouldDeduplicate) {
26881
+ return activeRequest;
26882
+ }
25372
26883
  this.activeSilentTokenRequests.set(preparedRequest.key, activeRequest);
25373
26884
  return activeRequest.finally(() => {
25374
26885
  this.activeSilentTokenRequests.delete(preparedRequest.key);
@@ -25961,6 +27472,17 @@ class CustomAuthStandardController extends StandardController {
25961
27472
  cacheClient: this.cacheClient,
25962
27473
  }), undefined, result.continuationState.scenario);
25963
27474
  }
27475
+ if (result.type === FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2) {
27476
+ return new CustomAuthResultV2(new AuthMethodRegistrationRequiredStateV2({
27477
+ correlationId: result.correlationId,
27478
+ logger: this.logger,
27479
+ config: this.customAuthConfig,
27480
+ flowClient: this.flowClientV2,
27481
+ continuationState: result.continuationState,
27482
+ cacheClient: this.cacheClient,
27483
+ methods: result.methods,
27484
+ }), undefined, result.continuationState.scenario);
27485
+ }
25964
27486
  if (result.type === FLOW_CODE_REQUIRED_V2) {
25965
27487
  return new CustomAuthResultV2(new CodeRequiredStateV2({
25966
27488
  correlationId: result.correlationId,
@@ -26562,6 +28084,79 @@ NestedAppOperatingContext.MODULE_NAME = "";
26562
28084
  */
26563
28085
  NestedAppOperatingContext.ID = "NestedAppOperatingContext";
26564
28086
 
28087
+ /*
28088
+ * Copyright (c) Microsoft Corporation. All rights reserved.
28089
+ * Licensed under the MIT License.
28090
+ */
28091
+ const IFRAME_POLL_INTERVAL_MS = 50;
28092
+ const DEFAULT_IFRAME_TIMEOUT_MS = 10000;
28093
+ /**
28094
+ * Monitors an iframe content window until it loads a URL with a known hash, or hits a specified timeout.
28095
+ *
28096
+ * @param iframe - The hidden iframe to monitor.
28097
+ * @param timeout - Maximum time (ms) to wait for navigation before rejecting with
28098
+ * `monitor_window_timeout`.
28099
+ * @param logger - Logger instance.
28100
+ * @param correlationId
28101
+ * @param responseMode - `"query"` or `"fragment"` — determines whether to read
28102
+ * `location.search` or `location.hash`. Any value other than `"query"` is
28103
+ * treated as fragment.
28104
+ */
28105
+ async function monitorIframeForHash(iframe, timeout, logger, correlationId, responseMode) {
28106
+ return new Promise((resolve, reject) => {
28107
+ if (timeout < DEFAULT_IFRAME_TIMEOUT_MS) {
28108
+ logger.warning(`137tec ${timeout} ${DEFAULT_IFRAME_TIMEOUT_MS}`, correlationId);
28109
+ }
28110
+ /*
28111
+ * Polling for iframes can be purely timing based,
28112
+ * since we don't need to account for interaction.
28113
+ */
28114
+ const timeoutId = window.setTimeout(() => {
28115
+ window.clearInterval(intervalId);
28116
+ reject(new AuthError(timedOut, correlationId, undefined, "monitor_window_timeout"));
28117
+ }, timeout);
28118
+ const intervalId = window.setInterval(() => {
28119
+ const contentWindow = iframe.contentWindow;
28120
+ if (!contentWindow) {
28121
+ return;
28122
+ }
28123
+ let href = "";
28124
+ try {
28125
+ /*
28126
+ * Will throw if cross origin,
28127
+ * which should be caught and ignored
28128
+ * since we need the interval to keep running while on STS UI.
28129
+ */
28130
+ href = contentWindow.location.href;
28131
+ }
28132
+ catch (e) { }
28133
+ if (!href || href === "about:blank") {
28134
+ return;
28135
+ }
28136
+ const responseString = responseMode === ResponseMode.QUERY
28137
+ ? contentWindow.location.search
28138
+ : contentWindow.location.hash;
28139
+ window.clearTimeout(timeoutId);
28140
+ window.clearInterval(intervalId);
28141
+ resolve(responseString);
28142
+ }, IFRAME_POLL_INTERVAL_MS);
28143
+ }).finally(() => {
28144
+ /*
28145
+ * Strip auth-response params from the iframe URL. The monitor owns the
28146
+ * iframe for the duration of the poll, mirroring cleanPopup in
28147
+ * PopupMonitor.
28148
+ */
28149
+ try {
28150
+ if (iframe.contentWindow) {
28151
+ clearAuthResponseFromUrl(iframe.contentWindow);
28152
+ }
28153
+ }
28154
+ catch {
28155
+ // Iframe may already be navigated away or cross-origin; ignore.
28156
+ }
28157
+ });
28158
+ }
28159
+
26565
28160
  /*
26566
28161
  * Copyright (c) Microsoft Corporation. All rights reserved.
26567
28162
  * Licensed under the MIT License.
@@ -26604,27 +28199,29 @@ class PublicClientApplication {
26604
28199
  /**
26605
28200
  * Waits for the auth response from a popup window opened by MSAL.
26606
28201
  *
26607
- * The default implementation delegates to MSAL's `BroadcastChannel`-based bridge.
26608
- * Subclasses must return the raw response string (hash/query/fragment), or reject
26609
- * with an `AuthError` on failure.
28202
+ * The default implementation delegates to MSAL's `BroadcastChannel`-based bridge,
28203
+ * or to the v4-style same-origin location poller when
28204
+ * `system.enableLegacyPolling` is set. Subclasses must return the raw response
28205
+ * string (hash/query/fragment), or reject with an `AuthError` on failure.
26610
28206
  *
26611
28207
  * @internal
26612
28208
  * @param request The in-flight authorization or end-session request.
26613
28209
  * @param popupWindow The popup window opened by MSAL.
26614
28210
  * @param popupWindowParent The parent window that opened the popup.
26615
28211
  */
26616
- async waitForPopupResponse(request,
26617
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
26618
- popupWindow,
26619
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
26620
- popupWindowParent) {
28212
+ async waitForPopupResponse(request, popupWindow, popupWindowParent) {
26621
28213
  const controller = this.controller;
26622
- return waitForBridgeResponse(controller.getConfiguration().system.popupBridgeTimeout, controller.getLogger(), request, controller.getPerformanceClient());
28214
+ const config = controller.getConfiguration();
28215
+ if (config.system.enableLegacyPolling) {
28216
+ return waitForPopupPollingResponse(config, controller.getLogger(), controller.getPerformanceClient(), request, popupWindow, popupWindowParent);
28217
+ }
28218
+ return waitForBridgeResponse(config.system.popupBridgeTimeout, controller.getLogger(), request, controller.getPerformanceClient());
26623
28219
  }
26624
28220
  /**
26625
28221
  * Waits for the auth response from a hidden iframe used by MSAL silent flows.
26626
28222
  *
26627
- * The default implementation delegates to MSAL's `BroadcastChannel`-based bridge.
28223
+ * The default implementation delegates to MSAL's `BroadcastChannel`-based bridge,
28224
+ * or to the v4-style location poller when `system.enableLegacyPolling` is set.
26628
28225
  * Subclasses must return the raw response string (hash/query/fragment), or reject
26629
28226
  * with an `AuthError` on failure.
26630
28227
  *
@@ -26632,11 +28229,12 @@ class PublicClientApplication {
26632
28229
  * @param iframe The hidden iframe MSAL attached to the document.
26633
28230
  * @param request The in-flight authorization request.
26634
28231
  */
26635
- async waitForIframeResponse(
26636
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
26637
- iframe, request) {
28232
+ async waitForIframeResponse(iframe, request) {
26638
28233
  const controller = this.controller;
26639
28234
  const config = controller.getConfiguration();
28235
+ if (config.system.enableLegacyPolling) {
28236
+ return waitForIframePollingResponse(config, controller.getLogger(), controller.getPerformanceClient(), iframe, request);
28237
+ }
26640
28238
  return waitForBridgeResponse(config.system.iframeBridgeTimeout, controller.getLogger(), request, controller.getPerformanceClient(), config.experimental);
26641
28239
  }
26642
28240
  /**
@@ -26869,6 +28467,40 @@ class PublicClientApplication {
26869
28467
  clearCache(logoutRequest) {
26870
28468
  return this.controller.clearCache(logoutRequest);
26871
28469
  }
28470
+ }
28471
+ /**
28472
+ * Collects a popup auth response using the v4-style same-origin location
28473
+ * poller instead of the `BroadcastChannel` redirect bridge.
28474
+ */
28475
+ async function waitForPopupPollingResponse(config, logger, performanceClient, request, popupWindow, popupWindowParent) {
28476
+ const responseMode = config.auth.OIDCOptions?.responseMode === ResponseMode.QUERY
28477
+ ? ResponseMode.QUERY
28478
+ : ResponseMode.FRAGMENT;
28479
+ performanceClient.addFields({ usesLegacyPolling: true }, request.correlationId);
28480
+ const unloadHandler = () => {
28481
+ try {
28482
+ if (popupWindow && !popupWindow.closed) {
28483
+ popupWindow.close();
28484
+ }
28485
+ }
28486
+ catch {
28487
+ /* ignore */
28488
+ }
28489
+ };
28490
+ popupWindowParent.addEventListener("beforeunload", unloadHandler);
28491
+ return monitorPopupForHash(popupWindow, popupWindowParent, responseMode, logger, unloadHandler, request.correlationId);
28492
+ }
28493
+ /**
28494
+ * Collects a silent-iframe auth response using the v4-style location poller
28495
+ * instead of the `BroadcastChannel` redirect bridge.
28496
+ */
28497
+ async function waitForIframePollingResponse(config, logger, performanceClient, iframe, request) {
28498
+ const responseMode = config.auth.OIDCOptions?.responseMode === ResponseMode.QUERY
28499
+ ? ResponseMode.QUERY
28500
+ : ResponseMode.FRAGMENT;
28501
+ const iframePollTimeout = config.system.iframeBridgeTimeout;
28502
+ performanceClient.addFields({ usesLegacyPolling: true, iframePollTimeout }, request.correlationId);
28503
+ return monitorIframeForHash(iframe, iframePollTimeout, logger, request.correlationId, responseMode);
26872
28504
  }
26873
28505
 
26874
28506
  /*
@@ -27011,10 +28643,12 @@ exports.AuthMethodRegistrationChallengeMethodResult = AuthMethodRegistrationChal
27011
28643
  exports.AuthMethodRegistrationCompletedState = AuthMethodRegistrationCompletedState;
27012
28644
  exports.AuthMethodRegistrationFailedState = AuthMethodRegistrationFailedState;
27013
28645
  exports.AuthMethodRegistrationRequiredState = AuthMethodRegistrationRequiredState;
28646
+ exports.AuthMethodRegistrationRequiredStateV2 = AuthMethodRegistrationRequiredStateV2;
27014
28647
  exports.AuthMethodRegistrationSubmitChallengeError = AuthMethodRegistrationSubmitChallengeError;
27015
28648
  exports.AuthMethodRegistrationSubmitChallengeResult = AuthMethodRegistrationSubmitChallengeResult;
27016
28649
  exports.AuthMethodSelectionRequiredStateV2 = AuthMethodSelectionRequiredStateV2;
27017
28650
  exports.AuthMethodVerificationRequiredState = AuthMethodVerificationRequiredState;
28651
+ exports.AuthMethodVerificationRequiredStateV2 = AuthMethodVerificationRequiredStateV2;
27018
28652
  exports.CodeRequiredStateV2 = CodeRequiredStateV2;
27019
28653
  exports.CompletedStateV2 = CompletedStateV2;
27020
28654
  exports.CustomAuthAccountData = CustomAuthAccountData;