@azure/msal-browser 5.27.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 (434) hide show
  1. package/dist/app/IPublicClientApplication.mjs +1 -1
  2. package/dist/app/PublicClientApplication.mjs +1 -1
  3. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  4. package/dist/broker/nativeBroker/PlatformAuthDOMHandler.mjs +9 -1
  5. package/dist/broker/nativeBroker/PlatformAuthDOMHandler.mjs.map +1 -1
  6. package/dist/broker/nativeBroker/PlatformAuthExtensionHandler.mjs +7 -6
  7. package/dist/broker/nativeBroker/PlatformAuthExtensionHandler.mjs.map +1 -1
  8. package/dist/broker/nativeBroker/PlatformAuthProvider.mjs +4 -2
  9. package/dist/broker/nativeBroker/PlatformAuthProvider.mjs.map +1 -1
  10. package/dist/broker/nativeBroker/PlatformAuthRequest.mjs +21 -7
  11. package/dist/broker/nativeBroker/PlatformAuthRequest.mjs.map +1 -1
  12. package/dist/cache/AccountManager.mjs +1 -1
  13. package/dist/cache/AsyncMemoryStorage.mjs +14 -1
  14. package/dist/cache/AsyncMemoryStorage.mjs.map +1 -1
  15. package/dist/cache/BrowserCacheManager.mjs +9 -2
  16. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  17. package/dist/cache/CacheHelpers.mjs +1 -1
  18. package/dist/cache/CacheKeys.mjs +1 -1
  19. package/dist/cache/CookieStorage.mjs +1 -1
  20. package/dist/cache/DatabaseStorage.mjs +1 -1
  21. package/dist/cache/EncryptedData.mjs +1 -1
  22. package/dist/cache/LocalStorage.mjs +1 -1
  23. package/dist/cache/MemoryStorage.mjs +1 -1
  24. package/dist/cache/SessionStorage.mjs +1 -1
  25. package/dist/cache/TokenCache.mjs +1 -1
  26. package/dist/config/Configuration.mjs +1 -1
  27. package/dist/controllers/NestedAppAuthController.mjs +1 -1
  28. package/dist/controllers/StandardController.mjs +65 -7
  29. package/dist/controllers/StandardController.mjs.map +1 -1
  30. package/dist/crypto/BrowserCrypto.mjs +1 -1
  31. package/dist/crypto/CryptoOps.mjs +1 -1
  32. package/dist/crypto/PkceGenerator.mjs +1 -1
  33. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  34. package/dist/crypto/TokenBindingKeyManager.mjs +14 -1
  35. package/dist/crypto/TokenBindingKeyManager.mjs.map +1 -1
  36. package/dist/custom_auth/CustomAuthConstants.mjs +1 -1
  37. package/dist/custom_auth/CustomAuthPublicClientApplication.mjs +1 -1
  38. package/dist/custom_auth/controller/CustomAuthStandardController.mjs +14 -2
  39. package/dist/custom_auth/controller/CustomAuthStandardController.mjs.map +1 -1
  40. package/dist/custom_auth/core/CustomAuthAuthority.mjs +1 -1
  41. package/dist/custom_auth/core/auth_flow/AuthFlowErrorBase.mjs +1 -1
  42. package/dist/custom_auth/core/auth_flow/AuthFlowResultBase.mjs +1 -1
  43. package/dist/custom_auth/core/auth_flow/AuthFlowState.mjs +1 -1
  44. package/dist/custom_auth/core/auth_flow/AuthFlowStateTypes.mjs +1 -1
  45. package/dist/custom_auth/core/auth_flow/jit/error_type/AuthMethodRegistrationError.mjs +1 -1
  46. package/dist/custom_auth/core/auth_flow/jit/result/AuthMethodRegistrationChallengeMethodResult.mjs +1 -1
  47. package/dist/custom_auth/core/auth_flow/jit/result/AuthMethodRegistrationSubmitChallengeResult.mjs +1 -1
  48. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationCompletedState.mjs +1 -1
  49. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationFailedState.mjs +1 -1
  50. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationState.mjs +1 -1
  51. package/dist/custom_auth/core/auth_flow/mfa/error_type/MfaError.mjs +1 -1
  52. package/dist/custom_auth/core/auth_flow/mfa/result/MfaRequestChallengeResult.mjs +1 -1
  53. package/dist/custom_auth/core/auth_flow/mfa/result/MfaSubmitChallengeResult.mjs +1 -1
  54. package/dist/custom_auth/core/auth_flow/mfa/state/MfaCompletedState.mjs +1 -1
  55. package/dist/custom_auth/core/auth_flow/mfa/state/MfaFailedState.mjs +1 -1
  56. package/dist/custom_auth/core/auth_flow/mfa/state/MfaState.mjs +1 -1
  57. package/dist/custom_auth/core/auth_flow/v2/CustomAuthFlowScenarioV2.mjs +1 -1
  58. package/dist/custom_auth/core/auth_flow/v2/CustomAuthResultV2.mjs +1 -1
  59. package/dist/custom_auth/core/auth_flow/v2/error/AuthFlowErrorSubcodesV2.mjs +1 -1
  60. package/dist/custom_auth/core/auth_flow/v2/error/AuthFlowErrorV2.mjs +1 -1
  61. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodRegistrationRequiredStateV2.mjs +68 -0
  62. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodRegistrationRequiredStateV2.mjs.map +1 -0
  63. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.mjs +3 -2
  64. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.mjs.map +1 -1
  65. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodVerificationRequiredStateV2.mjs +87 -0
  66. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodVerificationRequiredStateV2.mjs.map +1 -0
  67. package/dist/custom_auth/core/auth_flow/v2/state/ChallengeVerificationStateBaseV2.mjs +5 -3
  68. package/dist/custom_auth/core/auth_flow/v2/state/ChallengeVerificationStateBaseV2.mjs.map +1 -1
  69. package/dist/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.mjs +14 -2
  70. package/dist/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.mjs.map +1 -1
  71. package/dist/custom_auth/core/auth_flow/v2/state/CompletedStateV2.mjs +1 -1
  72. package/dist/custom_auth/core/auth_flow/v2/state/FailedStateV2.mjs +1 -1
  73. package/dist/custom_auth/core/auth_flow/v2/state/MFAVerificationRequiredStateV2.mjs +4 -3
  74. package/dist/custom_auth/core/auth_flow/v2/state/MFAVerificationRequiredStateV2.mjs.map +1 -1
  75. package/dist/custom_auth/core/error/CustomAuthApiError.mjs +1 -1
  76. package/dist/custom_auth/core/error/CustomAuthError.mjs +1 -1
  77. package/dist/custom_auth/core/error/HttpError.mjs +1 -1
  78. package/dist/custom_auth/core/error/HttpErrorCodes.mjs +1 -1
  79. package/dist/custom_auth/core/error/InvalidArgumentError.mjs +1 -1
  80. package/dist/custom_auth/core/error/InvalidConfigurationError.mjs +1 -1
  81. package/dist/custom_auth/core/error/InvalidConfigurationErrorCodes.mjs +1 -1
  82. package/dist/custom_auth/core/error/MethodNotImplementedError.mjs +1 -1
  83. package/dist/custom_auth/core/error/MsalCustomAuthError.mjs +1 -1
  84. package/dist/custom_auth/core/error/NoCachedAccountFoundError.mjs +1 -1
  85. package/dist/custom_auth/core/error/ParsedUrlError.mjs +1 -1
  86. package/dist/custom_auth/core/error/ParsedUrlErrorCodes.mjs +1 -1
  87. package/dist/custom_auth/core/error/UnexpectedError.mjs +1 -1
  88. package/dist/custom_auth/core/error/UnsupportedEnvironmentError.mjs +1 -1
  89. package/dist/custom_auth/core/error/UserAccountAttributeError.mjs +1 -1
  90. package/dist/custom_auth/core/error/UserAlreadySignedInError.mjs +1 -1
  91. package/dist/custom_auth/core/interaction_client/CustomAuthInteractionClientBase.mjs +1 -1
  92. package/dist/custom_auth/core/interaction_client/CustomAuthInterationClientFactory.mjs +1 -1
  93. package/dist/custom_auth/core/interaction_client/jit/JitClient.mjs +1 -1
  94. package/dist/custom_auth/core/interaction_client/jit/result/JitActionResult.mjs +1 -1
  95. package/dist/custom_auth/core/interaction_client/mfa/MfaClient.mjs +1 -1
  96. package/dist/custom_auth/core/interaction_client/mfa/result/MfaActionResult.mjs +1 -1
  97. package/dist/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.mjs +246 -73
  98. package/dist/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.mjs.map +1 -1
  99. package/dist/custom_auth/core/interaction_client/v2/InteractionClientBaseV2.mjs +1 -1
  100. package/dist/custom_auth/core/interaction_client/v2/result/FlowActionResultV2.mjs +10 -2
  101. package/dist/custom_auth/core/interaction_client/v2/result/FlowActionResultV2.mjs.map +1 -1
  102. package/dist/custom_auth/core/network_client/custom_auth_api/BaseApiClient.mjs +1 -1
  103. package/dist/custom_auth/core/network_client/custom_auth_api/CustomAuthApiClient.mjs +1 -1
  104. package/dist/custom_auth/core/network_client/custom_auth_api/CustomAuthApiEndpoint.mjs +1 -1
  105. package/dist/custom_auth/core/network_client/custom_auth_api/RegisterApiClient.mjs +1 -1
  106. package/dist/custom_auth/core/network_client/custom_auth_api/ResetPasswordApiClient.mjs +1 -1
  107. package/dist/custom_auth/core/network_client/custom_auth_api/SignInApiClient.mjs +1 -1
  108. package/dist/custom_auth/core/network_client/custom_auth_api/SignupApiClient.mjs +1 -1
  109. package/dist/custom_auth/core/network_client/custom_auth_api/types/ApiErrorCodes.mjs +1 -1
  110. package/dist/custom_auth/core/network_client/custom_auth_api/types/ApiSuberrors.mjs +1 -1
  111. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.mjs +10 -2
  112. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.mjs.map +1 -1
  113. package/dist/custom_auth/core/network_client/custom_auth_api/v2/BaseApiClientV2.mjs +1 -1
  114. package/dist/custom_auth/core/network_client/custom_auth_api/v2/CustomAuthApiClientV2.mjs +118 -25
  115. package/dist/custom_auth/core/network_client/custom_auth_api/v2/CustomAuthApiClientV2.mjs.map +1 -1
  116. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ErrorCodesV2.mjs +1 -1
  117. package/dist/custom_auth/core/network_client/custom_auth_api/v2/HrefResolverV2.mjs +1 -1
  118. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.mjs +2 -2
  119. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.mjs.map +1 -1
  120. package/dist/custom_auth/core/network_client/custom_auth_api/v2/response/ErrorNormalizerV2.mjs +1 -1
  121. package/dist/custom_auth/core/network_client/custom_auth_api/v2/result/BaseResultsV2.mjs +2 -12
  122. package/dist/custom_auth/core/network_client/custom_auth_api/v2/result/BaseResultsV2.mjs.map +1 -1
  123. package/dist/custom_auth/core/network_client/custom_auth_api/v2/result/SignUpResultsV2.mjs +2 -1
  124. package/dist/custom_auth/core/network_client/custom_auth_api/v2/result/SignUpResultsV2.mjs.map +1 -1
  125. package/dist/custom_auth/core/network_client/http_client/FetchHttpClient.mjs +1 -1
  126. package/dist/custom_auth/core/network_client/http_client/IHttpClient.mjs +1 -1
  127. package/dist/custom_auth/core/telemetry/FlowApiIdHelperV2.mjs +17 -3
  128. package/dist/custom_auth/core/telemetry/FlowApiIdHelperV2.mjs.map +1 -1
  129. package/dist/custom_auth/core/telemetry/PublicApiId.mjs +9 -3
  130. package/dist/custom_auth/core/telemetry/PublicApiId.mjs.map +1 -1
  131. package/dist/custom_auth/core/utils/ArgumentValidator.mjs +1 -1
  132. package/dist/custom_auth/core/utils/CustomHeaderUtils.mjs +1 -1
  133. package/dist/custom_auth/core/utils/UrlUtils.mjs +1 -1
  134. package/dist/custom_auth/get_account/auth_flow/CustomAuthAccountData.mjs +1 -1
  135. package/dist/custom_auth/get_account/auth_flow/error_type/GetAccountError.mjs +1 -1
  136. package/dist/custom_auth/get_account/auth_flow/result/GetAccessTokenResult.mjs +1 -1
  137. package/dist/custom_auth/get_account/auth_flow/result/GetAccountResult.mjs +1 -1
  138. package/dist/custom_auth/get_account/auth_flow/result/SignOutResult.mjs +1 -1
  139. package/dist/custom_auth/get_account/auth_flow/state/GetAccessTokenState.mjs +1 -1
  140. package/dist/custom_auth/get_account/auth_flow/state/GetAccountState.mjs +1 -1
  141. package/dist/custom_auth/get_account/auth_flow/state/SignOutState.mjs +1 -1
  142. package/dist/custom_auth/get_account/interaction_client/CustomAuthSilentCacheClient.mjs +1 -1
  143. package/dist/custom_auth/index.mjs +3 -1
  144. package/dist/custom_auth/index.mjs.map +1 -1
  145. package/dist/custom_auth/operating_context/CustomAuthOperatingContext.mjs +1 -1
  146. package/dist/custom_auth/reset_password/auth_flow/error_type/ResetPasswordError.mjs +1 -1
  147. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordResendCodeResult.mjs +1 -1
  148. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordStartResult.mjs +1 -1
  149. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordSubmitCodeResult.mjs +1 -1
  150. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordSubmitPasswordResult.mjs +1 -1
  151. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordCodeRequiredState.mjs +1 -1
  152. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordCompletedState.mjs +1 -1
  153. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordFailedState.mjs +1 -1
  154. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordPasswordRequiredState.mjs +1 -1
  155. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordState.mjs +1 -1
  156. package/dist/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.mjs +32 -13
  157. package/dist/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.mjs.map +1 -1
  158. package/dist/custom_auth/reset_password/interaction_client/ResetPasswordClient.mjs +1 -1
  159. package/dist/custom_auth/sign_in/auth_flow/SignInScenario.mjs +1 -1
  160. package/dist/custom_auth/sign_in/auth_flow/error_type/SignInError.mjs +1 -1
  161. package/dist/custom_auth/sign_in/auth_flow/result/SignInResendCodeResult.mjs +1 -1
  162. package/dist/custom_auth/sign_in/auth_flow/result/SignInResult.mjs +1 -1
  163. package/dist/custom_auth/sign_in/auth_flow/result/SignInSubmitCodeResult.mjs +1 -1
  164. package/dist/custom_auth/sign_in/auth_flow/result/SignInSubmitPasswordResult.mjs +1 -1
  165. package/dist/custom_auth/sign_in/auth_flow/state/SignInCodeRequiredState.mjs +1 -1
  166. package/dist/custom_auth/sign_in/auth_flow/state/SignInCompletedState.mjs +1 -1
  167. package/dist/custom_auth/sign_in/auth_flow/state/SignInContinuationState.mjs +1 -1
  168. package/dist/custom_auth/sign_in/auth_flow/state/SignInFailedState.mjs +1 -1
  169. package/dist/custom_auth/sign_in/auth_flow/state/SignInPasswordRequiredState.mjs +1 -1
  170. package/dist/custom_auth/sign_in/auth_flow/state/SignInState.mjs +1 -1
  171. package/dist/custom_auth/sign_in/auth_flow/v2/state/PasswordRequiredStateV2.mjs +14 -2
  172. package/dist/custom_auth/sign_in/auth_flow/v2/state/PasswordRequiredStateV2.mjs.map +1 -1
  173. package/dist/custom_auth/sign_in/auth_flow/v2/state/SignInContinuationStateV2.mjs +1 -1
  174. package/dist/custom_auth/sign_in/auth_flow/v2/state/SignInStateTransitionHandlerV2.mjs +1 -1
  175. package/dist/custom_auth/sign_in/interaction_client/SignInClient.mjs +1 -1
  176. package/dist/custom_auth/sign_in/interaction_client/result/SignInActionResult.mjs +1 -1
  177. package/dist/custom_auth/sign_up/auth_flow/error_type/SignUpError.mjs +1 -1
  178. package/dist/custom_auth/sign_up/auth_flow/result/SignUpResendCodeResult.mjs +1 -1
  179. package/dist/custom_auth/sign_up/auth_flow/result/SignUpResult.mjs +1 -1
  180. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitAttributesResult.mjs +1 -1
  181. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitCodeResult.mjs +1 -1
  182. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitPasswordResult.mjs +1 -1
  183. package/dist/custom_auth/sign_up/auth_flow/state/SignUpAttributesRequiredState.mjs +1 -1
  184. package/dist/custom_auth/sign_up/auth_flow/state/SignUpCodeRequiredState.mjs +1 -1
  185. package/dist/custom_auth/sign_up/auth_flow/state/SignUpCompletedState.mjs +1 -1
  186. package/dist/custom_auth/sign_up/auth_flow/state/SignUpFailedState.mjs +1 -1
  187. package/dist/custom_auth/sign_up/auth_flow/state/SignUpPasswordRequiredState.mjs +1 -1
  188. package/dist/custom_auth/sign_up/auth_flow/state/SignUpState.mjs +1 -1
  189. package/dist/custom_auth/sign_up/auth_flow/v2/state/AttributesRequiredStateV2.mjs +1 -1
  190. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpAttributesRequiredStateBaseV2.mjs +1 -1
  191. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpPasswordRequiredStateV2.mjs +1 -1
  192. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpStateTransitionHandlerV2.mjs +9 -2
  193. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpStateTransitionHandlerV2.mjs.map +1 -1
  194. package/dist/custom_auth/sign_up/interaction_client/SignUpClient.mjs +1 -1
  195. package/dist/custom_auth/sign_up/interaction_client/result/SignUpActionResult.mjs +1 -1
  196. package/dist/encode/Base64Decode.mjs +1 -1
  197. package/dist/encode/Base64Encode.mjs +1 -1
  198. package/dist/error/BrowserAuthError.mjs +1 -1
  199. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  200. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  201. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  202. package/dist/error/NativeAuthError.mjs +1 -1
  203. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  204. package/dist/error/NestedAppAuthError.mjs +1 -1
  205. package/dist/event/EventHandler.mjs +1 -1
  206. package/dist/event/EventMessage.mjs +1 -1
  207. package/dist/event/EventType.mjs +1 -1
  208. package/dist/index.mjs +1 -1
  209. package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
  210. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  211. package/dist/interaction_client/PlatformAuthInteractionClient.mjs +504 -75
  212. package/dist/interaction_client/PlatformAuthInteractionClient.mjs.map +1 -1
  213. package/dist/interaction_client/PopupClient.mjs +27 -20
  214. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  215. package/dist/interaction_client/RedirectClient.mjs +29 -14
  216. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  217. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  218. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  219. package/dist/interaction_client/SilentIframeClient.mjs +44 -32
  220. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  221. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  222. package/dist/interaction_client/StandardInteractionClient.mjs +1 -1
  223. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  224. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  225. package/dist/log-strings-mapping.json +59 -19
  226. package/dist/naa/BridgeError.mjs +1 -1
  227. package/dist/naa/BridgeProxy.mjs +1 -1
  228. package/dist/naa/BridgeStatusCode.mjs +1 -1
  229. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  230. package/dist/navigation/NavigationClient.mjs +1 -1
  231. package/dist/network/FetchClient.mjs +1 -1
  232. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  233. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  234. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  235. package/dist/packageMetadata.mjs +2 -2
  236. package/dist/popup_relay/constants.mjs +1 -1
  237. package/dist/popup_relay/index.mjs +1 -1
  238. package/dist/popup_relay/relayClient.mjs +1 -1
  239. package/dist/protocol/Authorize.mjs +21 -13
  240. package/dist/protocol/Authorize.mjs.map +1 -1
  241. package/dist/redirect_bridge/index.mjs +1 -1
  242. package/dist/request/RequestHelpers.mjs +35 -11
  243. package/dist/request/RequestHelpers.mjs.map +1 -1
  244. package/dist/request/SilentRequestHelpers.mjs +6 -6
  245. package/dist/request/SilentRequestHelpers.mjs.map +1 -1
  246. package/dist/response/ResponseHandler.mjs +1 -1
  247. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  248. package/dist/telemetry/BrowserPerformanceEvents.mjs +3 -2
  249. package/dist/telemetry/BrowserPerformanceEvents.mjs.map +1 -1
  250. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  251. package/dist/telemetry/BrowserRootPerformanceEvents.mjs +1 -1
  252. package/dist/utils/BrowserConstants.mjs +1 -1
  253. package/dist/utils/BrowserDetection.mjs +1 -1
  254. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  255. package/dist/utils/BrowserUtils.mjs +1 -1
  256. package/dist/utils/Helpers.mjs +1 -1
  257. package/dist/utils/IframeMonitor.mjs +1 -1
  258. package/dist/utils/MsalFrameStatsUtils.mjs +1 -1
  259. package/dist/utils/PopupMonitor.mjs +1 -1
  260. package/dist/utils/PopupOriginCheck.mjs +1 -1
  261. package/dist/webBrokerBridge/PendingRequestRegistry.mjs +1 -1
  262. package/dist/webBrokerBridge/PerfEventNames.mjs +1 -1
  263. package/dist/webBrokerBridge/WebBrokerBridgeError.mjs +1 -1
  264. package/dist/webBrokerBridge/WebBrokerBridgeErrorMap.mjs +1 -1
  265. package/dist/webBrokerBridge/adapter/CrossVersionRequestAdapter.mjs +1 -1
  266. package/dist/webBrokerBridge/index.mjs +1 -1
  267. package/lib/custom-auth-path/log-strings-mapping.json +51 -11
  268. package/lib/custom-auth-path/msal-custom-auth.cjs +1563 -424
  269. package/lib/custom-auth-path/msal-custom-auth.cjs.map +1 -1
  270. package/lib/custom-auth-path/msal-custom-auth.js +1563 -424
  271. package/lib/custom-auth-path/msal-custom-auth.js.map +1 -1
  272. package/lib/log-strings-mapping.json +19 -11
  273. package/lib/msal-browser.cjs +914 -259
  274. package/lib/msal-browser.cjs.map +1 -1
  275. package/lib/msal-browser.js +914 -259
  276. package/lib/msal-browser.js.map +1 -1
  277. package/lib/msal-browser.min.js +2 -2
  278. package/lib/popup-relay/msal-popup-relay.cjs +2 -2
  279. package/lib/popup-relay/msal-popup-relay.cjs.map +1 -1
  280. package/lib/popup-relay/msal-popup-relay.js +2 -2
  281. package/lib/popup-relay/msal-popup-relay.js.map +1 -1
  282. package/lib/popup-relay/msal-popup-relay.min.js +1 -1
  283. package/lib/redirect-bridge/msal-redirect-bridge.cjs +10 -10
  284. package/lib/redirect-bridge/msal-redirect-bridge.cjs.map +1 -1
  285. package/lib/redirect-bridge/msal-redirect-bridge.js +10 -10
  286. package/lib/redirect-bridge/msal-redirect-bridge.js.map +1 -1
  287. package/lib/redirect-bridge/msal-redirect-bridge.min.js +1 -1
  288. package/lib/web-broker-bridge/msal-web-broker-bridge.cjs +1 -1
  289. package/package.json +2 -2
  290. package/src/broker/nativeBroker/PlatformAuthDOMHandler.ts +15 -0
  291. package/src/broker/nativeBroker/PlatformAuthExtensionHandler.ts +6 -21
  292. package/src/broker/nativeBroker/PlatformAuthProvider.ts +3 -1
  293. package/src/broker/nativeBroker/PlatformAuthRequest.ts +12 -8
  294. package/src/broker/nativeBroker/PlatformAuthResponse.ts +31 -0
  295. package/src/cache/AsyncMemoryStorage.ts +16 -0
  296. package/src/cache/BrowserCacheManager.ts +19 -1
  297. package/src/controllers/StandardController.ts +107 -11
  298. package/src/crypto/TokenBindingKeyManager.ts +21 -0
  299. package/src/custom_auth/controller/CustomAuthStandardController.ts +18 -0
  300. package/src/custom_auth/core/auth_flow/v2/AuthenticationMethodRegistrationV2.ts +15 -0
  301. package/src/custom_auth/core/auth_flow/v2/result/AuthMethodRegistrationChallengeResultV2.ts +23 -0
  302. package/src/custom_auth/core/auth_flow/v2/result/AuthMethodVerificationSubmitChallengeResultV2.ts +26 -0
  303. package/src/custom_auth/core/auth_flow/v2/result/RequestChallengeResultV2.ts +1 -1
  304. package/src/custom_auth/core/auth_flow/v2/result/VerifyChallengeResultV2.ts +2 -0
  305. package/src/custom_auth/core/auth_flow/v2/state/AuthMethodRegistrationRequiredStateV2.ts +94 -0
  306. package/src/custom_auth/core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.ts +7 -2
  307. package/src/custom_auth/core/auth_flow/v2/state/AuthMethodVerificationRequiredStateV2.ts +132 -0
  308. package/src/custom_auth/core/auth_flow/v2/state/ChallengeVerificationStateBaseV2.ts +8 -2
  309. package/src/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.ts +18 -0
  310. package/src/custom_auth/core/auth_flow/v2/state/CustomAuthStateParametersV2.ts +13 -0
  311. package/src/custom_auth/core/auth_flow/v2/state/MFAVerificationRequiredStateV2.ts +8 -2
  312. package/src/custom_auth/core/interaction_client/v2/FlowContinuationStateV2.ts +1 -0
  313. package/src/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.ts +445 -91
  314. package/src/custom_auth/core/interaction_client/v2/parameter/FlowParamsV2.ts +25 -0
  315. package/src/custom_auth/core/interaction_client/v2/result/FlowActionResultV2.ts +34 -0
  316. package/src/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.ts +9 -0
  317. package/src/custom_auth/core/network_client/custom_auth_api/v2/CustomAuthApiClientV2.ts +262 -43
  318. package/src/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.ts +4 -7
  319. package/src/custom_auth/core/network_client/custom_auth_api/v2/request/RequestsV2.ts +21 -0
  320. package/src/custom_auth/core/network_client/custom_auth_api/v2/response/ResponsesV2.ts +41 -2
  321. package/src/custom_auth/core/network_client/custom_auth_api/v2/result/BaseResultsV2.ts +44 -19
  322. package/src/custom_auth/core/network_client/custom_auth_api/v2/result/ResetPasswordResultsV2.ts +4 -6
  323. package/src/custom_auth/core/network_client/custom_auth_api/v2/result/SignUpResultsV2.ts +6 -1
  324. package/src/custom_auth/core/telemetry/FlowApiIdHelperV2.ts +25 -1
  325. package/src/custom_auth/core/telemetry/PublicApiId.ts +6 -0
  326. package/src/custom_auth/index.ts +11 -0
  327. package/src/custom_auth/reset_password/auth_flow/v2/result/SubmitNewPasswordResultV2.ts +6 -7
  328. package/src/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.ts +47 -15
  329. package/src/custom_auth/sign_in/auth_flow/v2/result/SignInStartResultV2.ts +2 -0
  330. package/src/custom_auth/sign_in/auth_flow/v2/result/SubmitPasswordResultV2.ts +2 -0
  331. package/src/custom_auth/sign_in/auth_flow/v2/state/PasswordRequiredStateV2.ts +18 -0
  332. package/src/custom_auth/sign_up/auth_flow/v2/result/SubmitAttributesResultV2.ts +2 -0
  333. package/src/custom_auth/sign_up/auth_flow/v2/state/SignUpStateTransitionHandlerV2.ts +13 -0
  334. package/src/interaction_client/PlatformAuthInteractionClient.ts +851 -128
  335. package/src/interaction_client/PopupClient.ts +104 -83
  336. package/src/interaction_client/RedirectClient.ts +88 -34
  337. package/src/interaction_client/SilentIframeClient.ts +121 -95
  338. package/src/packageMetadata.ts +1 -1
  339. package/src/protocol/Authorize.ts +46 -18
  340. package/src/request/RequestHelpers.ts +64 -11
  341. package/src/request/SilentRequestHelpers.ts +8 -9
  342. package/src/telemetry/BrowserPerformanceEvents.ts +1 -0
  343. package/types/broker/nativeBroker/PlatformAuthDOMHandler.d.ts.map +1 -1
  344. package/types/broker/nativeBroker/PlatformAuthExtensionHandler.d.ts.map +1 -1
  345. package/types/broker/nativeBroker/PlatformAuthProvider.d.ts.map +1 -1
  346. package/types/broker/nativeBroker/PlatformAuthRequest.d.ts +6 -1
  347. package/types/broker/nativeBroker/PlatformAuthRequest.d.ts.map +1 -1
  348. package/types/broker/nativeBroker/PlatformAuthResponse.d.ts +21 -0
  349. package/types/broker/nativeBroker/PlatformAuthResponse.d.ts.map +1 -1
  350. package/types/cache/AsyncMemoryStorage.d.ts +5 -0
  351. package/types/cache/AsyncMemoryStorage.d.ts.map +1 -1
  352. package/types/cache/BrowserCacheManager.d.ts +4 -0
  353. package/types/cache/BrowserCacheManager.d.ts.map +1 -1
  354. package/types/controllers/StandardController.d.ts +5 -0
  355. package/types/controllers/StandardController.d.ts.map +1 -1
  356. package/types/crypto/TokenBindingKeyManager.d.ts +9 -0
  357. package/types/crypto/TokenBindingKeyManager.d.ts.map +1 -1
  358. package/types/custom_auth/CustomAuthConstants.d.ts +1 -1
  359. package/types/custom_auth/controller/CustomAuthStandardController.d.ts.map +1 -1
  360. package/types/custom_auth/core/auth_flow/v2/AuthenticationMethodRegistrationV2.d.ts +11 -0
  361. package/types/custom_auth/core/auth_flow/v2/AuthenticationMethodRegistrationV2.d.ts.map +1 -0
  362. package/types/custom_auth/core/auth_flow/v2/result/AuthMethodRegistrationChallengeResultV2.d.ts +14 -0
  363. package/types/custom_auth/core/auth_flow/v2/result/AuthMethodRegistrationChallengeResultV2.d.ts.map +1 -0
  364. package/types/custom_auth/core/auth_flow/v2/result/AuthMethodVerificationSubmitChallengeResultV2.d.ts +15 -0
  365. package/types/custom_auth/core/auth_flow/v2/result/AuthMethodVerificationSubmitChallengeResultV2.d.ts.map +1 -0
  366. package/types/custom_auth/core/auth_flow/v2/result/RequestChallengeResultV2.d.ts +1 -1
  367. package/types/custom_auth/core/auth_flow/v2/result/VerifyChallengeResultV2.d.ts +2 -1
  368. package/types/custom_auth/core/auth_flow/v2/result/VerifyChallengeResultV2.d.ts.map +1 -1
  369. package/types/custom_auth/core/auth_flow/v2/state/AuthMethodRegistrationRequiredStateV2.d.ts +22 -0
  370. package/types/custom_auth/core/auth_flow/v2/state/AuthMethodRegistrationRequiredStateV2.d.ts.map +1 -0
  371. package/types/custom_auth/core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.d.ts.map +1 -1
  372. package/types/custom_auth/core/auth_flow/v2/state/AuthMethodVerificationRequiredStateV2.d.ts +28 -0
  373. package/types/custom_auth/core/auth_flow/v2/state/AuthMethodVerificationRequiredStateV2.d.ts.map +1 -0
  374. package/types/custom_auth/core/auth_flow/v2/state/ChallengeVerificationStateBaseV2.d.ts +3 -2
  375. package/types/custom_auth/core/auth_flow/v2/state/ChallengeVerificationStateBaseV2.d.ts.map +1 -1
  376. package/types/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.d.ts.map +1 -1
  377. package/types/custom_auth/core/auth_flow/v2/state/CustomAuthStateParametersV2.d.ts +9 -0
  378. package/types/custom_auth/core/auth_flow/v2/state/CustomAuthStateParametersV2.d.ts.map +1 -1
  379. package/types/custom_auth/core/auth_flow/v2/state/MFAVerificationRequiredStateV2.d.ts.map +1 -1
  380. package/types/custom_auth/core/interaction_client/v2/FlowContinuationStateV2.d.ts +1 -0
  381. package/types/custom_auth/core/interaction_client/v2/FlowContinuationStateV2.d.ts.map +1 -1
  382. package/types/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.d.ts +12 -5
  383. package/types/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.d.ts.map +1 -1
  384. package/types/custom_auth/core/interaction_client/v2/parameter/FlowParamsV2.d.ts +17 -0
  385. package/types/custom_auth/core/interaction_client/v2/parameter/FlowParamsV2.d.ts.map +1 -1
  386. package/types/custom_auth/core/interaction_client/v2/result/FlowActionResultV2.d.ts +18 -2
  387. package/types/custom_auth/core/interaction_client/v2/result/FlowActionResultV2.d.ts.map +1 -1
  388. package/types/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.d.ts +8 -0
  389. package/types/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.d.ts.map +1 -1
  390. package/types/custom_auth/core/network_client/custom_auth_api/v2/CustomAuthApiClientV2.d.ts +8 -2
  391. package/types/custom_auth/core/network_client/custom_auth_api/v2/CustomAuthApiClientV2.d.ts.map +1 -1
  392. package/types/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.d.ts +3 -3
  393. package/types/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.d.ts.map +1 -1
  394. package/types/custom_auth/core/network_client/custom_auth_api/v2/request/RequestsV2.d.ts +12 -0
  395. package/types/custom_auth/core/network_client/custom_auth_api/v2/request/RequestsV2.d.ts.map +1 -1
  396. package/types/custom_auth/core/network_client/custom_auth_api/v2/response/ResponsesV2.d.ts +29 -2
  397. package/types/custom_auth/core/network_client/custom_auth_api/v2/response/ResponsesV2.d.ts.map +1 -1
  398. package/types/custom_auth/core/network_client/custom_auth_api/v2/result/BaseResultsV2.d.ts +30 -17
  399. package/types/custom_auth/core/network_client/custom_auth_api/v2/result/BaseResultsV2.d.ts.map +1 -1
  400. package/types/custom_auth/core/network_client/custom_auth_api/v2/result/ResetPasswordResultsV2.d.ts +3 -1
  401. package/types/custom_auth/core/network_client/custom_auth_api/v2/result/ResetPasswordResultsV2.d.ts.map +1 -1
  402. package/types/custom_auth/core/network_client/custom_auth_api/v2/result/SignUpResultsV2.d.ts +3 -2
  403. package/types/custom_auth/core/network_client/custom_auth_api/v2/result/SignUpResultsV2.d.ts.map +1 -1
  404. package/types/custom_auth/core/telemetry/FlowApiIdHelperV2.d.ts +6 -1
  405. package/types/custom_auth/core/telemetry/FlowApiIdHelperV2.d.ts.map +1 -1
  406. package/types/custom_auth/core/telemetry/PublicApiId.d.ts +6 -0
  407. package/types/custom_auth/core/telemetry/PublicApiId.d.ts.map +1 -1
  408. package/types/custom_auth/index.d.ts +5 -0
  409. package/types/custom_auth/index.d.ts.map +1 -1
  410. package/types/custom_auth/reset_password/auth_flow/v2/result/SubmitNewPasswordResultV2.d.ts +6 -8
  411. package/types/custom_auth/reset_password/auth_flow/v2/result/SubmitNewPasswordResultV2.d.ts.map +1 -1
  412. package/types/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.d.ts +4 -4
  413. package/types/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.d.ts.map +1 -1
  414. package/types/custom_auth/sign_in/auth_flow/v2/result/SignInStartResultV2.d.ts +2 -1
  415. package/types/custom_auth/sign_in/auth_flow/v2/result/SignInStartResultV2.d.ts.map +1 -1
  416. package/types/custom_auth/sign_in/auth_flow/v2/result/SubmitPasswordResultV2.d.ts +2 -1
  417. package/types/custom_auth/sign_in/auth_flow/v2/result/SubmitPasswordResultV2.d.ts.map +1 -1
  418. package/types/custom_auth/sign_in/auth_flow/v2/state/PasswordRequiredStateV2.d.ts.map +1 -1
  419. package/types/custom_auth/sign_up/auth_flow/v2/result/SubmitAttributesResultV2.d.ts +2 -1
  420. package/types/custom_auth/sign_up/auth_flow/v2/result/SubmitAttributesResultV2.d.ts.map +1 -1
  421. package/types/custom_auth/sign_up/auth_flow/v2/state/SignUpStateTransitionHandlerV2.d.ts.map +1 -1
  422. package/types/interaction_client/PlatformAuthInteractionClient.d.ts +106 -5
  423. package/types/interaction_client/PlatformAuthInteractionClient.d.ts.map +1 -1
  424. package/types/interaction_client/PopupClient.d.ts.map +1 -1
  425. package/types/interaction_client/RedirectClient.d.ts.map +1 -1
  426. package/types/interaction_client/SilentIframeClient.d.ts.map +1 -1
  427. package/types/packageMetadata.d.ts +1 -1
  428. package/types/protocol/Authorize.d.ts +4 -4
  429. package/types/protocol/Authorize.d.ts.map +1 -1
  430. package/types/request/RequestHelpers.d.ts +21 -3
  431. package/types/request/RequestHelpers.d.ts.map +1 -1
  432. package/types/request/SilentRequestHelpers.d.ts.map +1 -1
  433. package/types/telemetry/BrowserPerformanceEvents.d.ts +1 -0
  434. package/types/telemetry/BrowserPerformanceEvents.d.ts.map +1 -1
@@ -5,22 +5,25 @@
5
5
 
6
6
  import {
7
7
  AADServerParamKeys,
8
- AccessTokenEntity,
9
8
  AccountEntity,
10
9
  AccountEntityUtils,
11
10
  AccountInfo,
12
11
  AuthError,
12
+ AuthErrorCodes,
13
13
  AuthToken,
14
14
  AuthorityType,
15
15
  CacheHelpers,
16
16
  ClientAuthErrorCodes,
17
+ ClientConfigurationErrorCodes,
17
18
  CommonSilentFlowRequest,
18
19
  Constants,
20
+ DpopProofGenerator,
19
21
  ICrypto,
20
22
  IPerformanceClient,
21
23
  IdTokenEntity,
22
24
  InProgressPerformanceEvent,
23
25
  Logger,
26
+ JsonWebTokenAlgorithms,
24
27
  PerformanceEvents,
25
28
  PopTokenGenerator,
26
29
  RequestParameterBuilder,
@@ -33,19 +36,27 @@ import {
33
36
  ITokenBindingKeyManager,
34
37
  UrlString,
35
38
  buildAccountToCache,
39
+ createAuthError,
36
40
  createClientAuthError,
41
+ createClientConfigurationError,
37
42
  invokeAsync,
43
+ normalizeDpopResourceRequestContext,
38
44
  updateAccountTenantProfileData,
39
45
  } from "@azure/msal-common/browser";
40
46
  import { IPlatformAuthHandler } from "../broker/nativeBroker/IPlatformAuthHandler.js";
41
47
  import {
42
48
  createPlatformAuthExtraParametersNoCache,
43
- isProofOfPossessionTokenType,
44
- PlatformAuthExtraParametersNoCache,
49
+ PlatformAuthBindingPreference,
50
+ PlatformAuthEnclave,
45
51
  PlatformAuthRequest,
52
+ PlatformAuthTokenType,
46
53
  } from "../broker/nativeBroker/PlatformAuthRequest.js";
47
54
  import {
55
+ BrokerDpopFailureReason,
56
+ BrokerDpopOutcome,
48
57
  MATS,
58
+ NativeResponseProperties,
59
+ NormalizedDpopBrokerResponse,
49
60
  PlatformAuthResponse,
50
61
  } from "../broker/nativeBroker/PlatformAuthResponse.js";
51
62
  import { BrowserCacheManager } from "../cache/BrowserCacheManager.js";
@@ -70,6 +81,7 @@ import { PopupRequest } from "../request/PopupRequest.js";
70
81
  import { RedirectRequest } from "../request/RedirectRequest.js";
71
82
  import { SilentRequest } from "../request/SilentRequest.js";
72
83
  import { SsoSilentRequest } from "../request/SsoSilentRequest.js";
84
+ import { isTokenBindingKeyPersistedForRedirect } from "../request/RequestHelpers.js";
73
85
  import { AuthenticationResult } from "../response/AuthenticationResult.js";
74
86
  import * as BrowserPerformanceEvents from "../telemetry/BrowserPerformanceEvents.js";
75
87
  import {
@@ -88,6 +100,8 @@ import {
88
100
  } from "./BaseInteractionClient.js";
89
101
  import { SilentCacheClient } from "./SilentCacheClient.js";
90
102
 
103
+ const DPOP_POP_KID_NOT_SUPPORTED = "dpop_pop_kid_not_supported";
104
+
91
105
  export class PlatformAuthInteractionClient extends BaseInteractionClient {
92
106
  protected apiId: ApiId;
93
107
  protected accountId: string;
@@ -96,6 +110,13 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
96
110
  protected nativeStorageManager: BrowserCacheManager;
97
111
  protected skus: string;
98
112
 
113
+ /**
114
+ * Storage location reported for MSAL-owned browser DPoP keys in reqCnf.
115
+ * This does not constrain the binding selected by the platform broker.
116
+ */
117
+ private static readonly MSAL_DPOP_KEY_STORAGE_LOCATION =
118
+ PlatformAuthEnclave.SOFTWARE;
119
+
99
120
  constructor(
100
121
  config: BrowserConfiguration,
101
122
  browserStorage: BrowserCacheManager,
@@ -222,20 +243,12 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
222
243
  }
223
244
 
224
245
  // check if the tokens can be retrieved from internal cache
246
+ let cachedResult: AuthenticationResult | undefined;
225
247
  try {
226
- const result = await this.acquireTokensFromCache(
248
+ cachedResult = await this.acquireTokensFromCache(
227
249
  this.accountId,
228
250
  nativeRequest
229
251
  );
230
- // Served from the native internal cache; token did not come directly from the broker
231
- nativeATMeasurement.add({
232
- isNativeBroker: false,
233
- });
234
- nativeATMeasurement.end({
235
- success: true,
236
- fromCache: true,
237
- });
238
- return result;
239
252
  } catch (e) {
240
253
  if (cacheLookupPolicy === CacheLookupPolicy.AccessToken) {
241
254
  this.logger.info(
@@ -248,6 +261,9 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
248
261
  nativeATMeasurement.end({
249
262
  success: false,
250
263
  });
264
+ await this.resetGeneratedDpopRequestKeyBestEffort(
265
+ nativeRequest
266
+ );
251
267
  throw e;
252
268
  }
253
269
  // continue with a native call for any and all errors
@@ -257,8 +273,23 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
257
273
  );
258
274
  }
259
275
 
276
+ if (cachedResult) {
277
+ // Served from the native internal cache; token did not come directly from the broker
278
+ nativeATMeasurement.add({
279
+ isNativeBroker: false,
280
+ });
281
+ nativeATMeasurement.end({
282
+ success: true,
283
+ fromCache: true,
284
+ });
285
+ await this.resetGeneratedDpopRequestKey(nativeRequest);
286
+ return cachedResult;
287
+ }
288
+
260
289
  // dispatch the request to the broker
261
290
  try {
291
+ await this.prepareDpopBrokerRequest(nativeRequest);
292
+ this.addDpopBrokerAttemptTelemetry(nativeRequest);
262
293
  const validatedResponse: PlatformAuthResponse =
263
294
  await this.platformAuthProvider.sendMessage(nativeRequest);
264
295
 
@@ -291,6 +322,7 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
291
322
  e
292
323
  );
293
324
  this.setBrokerErrorTelemetry(e);
325
+ await this.resetGeneratedDpopRequestKeyBestEffort(nativeRequest);
294
326
  throw e;
295
327
  }
296
328
  }
@@ -336,6 +368,7 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
336
368
  ).asArray(),
337
369
  account: cachedAccount,
338
370
  forceRefresh: false,
371
+ ...this.createSilentCacheTokenBindingParameters(request),
339
372
  resource: request.extraParameters?.resource,
340
373
  };
341
374
 
@@ -347,6 +380,43 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
347
380
  return silentRequest;
348
381
  }
349
382
 
383
+ /**
384
+ * Maps platform-broker token-binding state to silent-cache request fields.
385
+ * @param request
386
+ */
387
+ private createSilentCacheTokenBindingParameters(
388
+ request: PlatformAuthRequest
389
+ ): Pick<
390
+ CommonSilentFlowRequest,
391
+ | "authenticationScheme"
392
+ | "popKid"
393
+ | "dpopJkt"
394
+ | "resourceRequestMethod"
395
+ | "resourceRequestUri"
396
+ > {
397
+ const authenticationScheme = this.isDpopBrokerRequest(request)
398
+ ? Constants.AuthenticationScheme.DPOP
399
+ : (request.tokenType as Constants.AuthenticationScheme);
400
+
401
+ if (
402
+ authenticationScheme !== Constants.AuthenticationScheme.DPOP &&
403
+ authenticationScheme !== Constants.AuthenticationScheme.POP
404
+ ) {
405
+ return { authenticationScheme };
406
+ }
407
+
408
+ return {
409
+ authenticationScheme,
410
+ ...(authenticationScheme === Constants.AuthenticationScheme.DPOP &&
411
+ request.keyId && { dpopJkt: request.keyId }),
412
+ ...(authenticationScheme === Constants.AuthenticationScheme.POP &&
413
+ request.signPopToken === false &&
414
+ request.keyId && { popKid: request.keyId }),
415
+ resourceRequestMethod: request.resourceRequestMethod,
416
+ resourceRequestUri: request.resourceRequestUri,
417
+ };
418
+ }
419
+
350
420
  /**
351
421
  * Fetches the tokens from the cache if un-expired
352
422
  * @param nativeAccountId
@@ -450,9 +520,26 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
450
520
  options?.navigateToLoginRequestUrl ?? true;
451
521
 
452
522
  try {
453
- await this.platformAuthProvider.sendMessage(nativeRequest);
523
+ await this.prepareDpopBrokerRequest(nativeRequest);
524
+ this.addDpopBrokerAttemptTelemetry(nativeRequest);
525
+ const response = await this.platformAuthProvider.sendMessage(
526
+ nativeRequest
527
+ );
528
+ const dpopBrokerOutcome = this.validateDpopBrokerOutcome(
529
+ response,
530
+ nativeRequest
531
+ );
532
+ if (dpopBrokerOutcome === "L3") {
533
+ await this.resetGeneratedDpopRequestKey(nativeRequest);
534
+ }
454
535
  } catch (e) {
455
- // Only throw fatal errors here to allow application to fallback to regular redirect. Otherwise proceed and the error will be thrown in handleRedirectPromise
536
+ /*
537
+ * Raw persistent/transient broker errors are retrieved again in
538
+ * phase two. Availability errors are thrown for controller-managed
539
+ * web fallback, while translated cancellation, network, and
540
+ * interaction-required errors are surfaced without being swallowed.
541
+ */
542
+ await this.resetGeneratedDpopRequestKeyBestEffort(nativeRequest);
456
543
  if (e instanceof NativeAuthError) {
457
544
  const serverTelemetryManager = initializeServerTelemetryManager(
458
545
  this.apiId,
@@ -474,8 +561,16 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
474
561
  this.setBrokerErrorTelemetry(e);
475
562
  throw e;
476
563
  }
564
+ } else if (this.isDpopBrokerRequest(nativeRequest)) {
565
+ throw e;
477
566
  }
478
567
  }
568
+ try {
569
+ await this.ensureRedirectDpopKeyIsPersisted(nativeRequest);
570
+ } catch (e) {
571
+ await this.resetGeneratedDpopRequestKeyBestEffort(nativeRequest);
572
+ throw e;
573
+ }
479
574
  this.browserStorage.setTemporaryCache(
480
575
  TemporaryCacheKeys.NATIVE_REQUEST,
481
576
  JSON.stringify({
@@ -503,10 +598,20 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
503
598
  this.correlationId
504
599
  );
505
600
  rootMeasurement.end({ success: true });
506
- await this.navigationClient.navigateExternal(
507
- redirectUri,
508
- navigationOptions
509
- ); // Need to treat this as external to ensure handleRedirectPromise is run again
601
+ try {
602
+ await this.navigationClient.navigateExternal(
603
+ redirectUri,
604
+ navigationOptions
605
+ ); // Need to treat this as external to ensure handleRedirectPromise is run again
606
+ } catch (e) {
607
+ this.browserStorage.removeItem(
608
+ this.browserStorage.generateCacheKey(
609
+ TemporaryCacheKeys.NATIVE_REQUEST
610
+ )
611
+ );
612
+ await this.resetGeneratedDpopRequestKeyBestEffort(nativeRequest);
613
+ throw e;
614
+ }
510
615
  }
511
616
 
512
617
  /**
@@ -567,6 +672,8 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
567
672
  const reqTimestamp = TimeUtils.nowSeconds();
568
673
 
569
674
  try {
675
+ await this.prepareDpopBrokerRequest(request, true);
676
+ this.addDpopBrokerAttemptTelemetry(request);
570
677
  this.logger.verbose(
571
678
  "NativeInteractionClient - handleRedirectPromise sending message to native broker.",
572
679
  this.correlationId
@@ -593,7 +700,20 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
593
700
  serverTelemetryManager.clearNativeBrokerErrorCode();
594
701
  return authResult;
595
702
  } catch (e) {
703
+ if (e instanceof NativeAuthError) {
704
+ const serverTelemetryManager = initializeServerTelemetryManager(
705
+ this.apiId,
706
+ this.config.auth.clientId,
707
+ this.correlationId,
708
+ this.browserStorage,
709
+ this.logger,
710
+ undefined,
711
+ this.config.system.serverTelemetryEnabled
712
+ );
713
+ serverTelemetryManager.setNativeBrokerErrorCode(e.errorCode);
714
+ }
596
715
  this.setBrokerErrorTelemetry(e);
716
+ await this.resetGeneratedDpopRequestKeyBestEffort(request);
597
717
  throw e;
598
718
  }
599
719
  }
@@ -627,6 +747,11 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
627
747
  this.correlationId
628
748
  );
629
749
 
750
+ const dpopBrokerOutcome = this.validateDpopBrokerOutcome(
751
+ response,
752
+ request
753
+ );
754
+
630
755
  // generate identifiers
631
756
  const idTokenClaims = AuthToken.extractTokenClaims(
632
757
  response.id_token,
@@ -712,14 +837,23 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
712
837
  reqTimestamp
713
838
  );
714
839
 
840
+ const isL3DpopResponse = dpopBrokerOutcome === "L3";
715
841
  // cache accounts and tokens in the appropriate storage
842
+ const shouldRemoveGeneratedDpopKey =
843
+ isL3DpopResponse ||
844
+ (this.isDpopBrokerRequest(request) &&
845
+ storeInCache?.accessToken === false);
846
+ if (shouldRemoveGeneratedDpopKey) {
847
+ await this.resetGeneratedDpopRequestKey(request);
848
+ }
849
+
716
850
  await invokeAsync(
717
851
  this.cacheAccount.bind(this),
718
852
  BrowserPerformanceEvents.PlatformAuthCacheAccount,
719
853
  this.logger,
720
854
  this.performanceClient,
721
855
  this.correlationId
722
- )(baseAccount, AuthToken.isKmsi(idTokenClaims));
856
+ )(baseAccount, AuthToken.isKmsi(idTokenClaims), !isL3DpopResponse);
723
857
  await invokeAsync(
724
858
  this.cacheNativeTokens.bind(this),
725
859
  BrowserPerformanceEvents.PlatformAuthCacheNativeTokens,
@@ -734,7 +868,8 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
734
868
  result.tenantId,
735
869
  reqTimestamp,
736
870
  authority.getPreferredCache(), // environment
737
- storeInCache
871
+ storeInCache,
872
+ dpopBrokerOutcome
738
873
  );
739
874
 
740
875
  return result;
@@ -856,7 +991,7 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
856
991
  ): Promise<AuthenticationResult> {
857
992
  // Add Native Broker fields to Telemetry
858
993
  const mats = this.addTelemetryFromNativeResponse(
859
- response.properties.MATS
994
+ response.properties?.MATS
860
995
  );
861
996
 
862
997
  // If scopes not returned in server response, use request scopes
@@ -900,10 +1035,17 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
900
1035
  response,
901
1036
  request
902
1037
  );
903
- const tokenType =
904
- request.tokenType === Constants.AuthenticationScheme.POP
905
- ? Constants.AuthenticationScheme.POP
906
- : Constants.AuthenticationScheme.BEARER;
1038
+ const isDpopRequest = this.isDpopBrokerRequest(request);
1039
+ let tokenType: Constants.AuthenticationScheme =
1040
+ Constants.AuthenticationScheme.BEARER;
1041
+ if (isDpopRequest) {
1042
+ tokenType = Constants.AuthenticationScheme.DPOP;
1043
+ } else if (request.tokenType === Constants.AuthenticationScheme.POP) {
1044
+ tokenType = Constants.AuthenticationScheme.POP;
1045
+ }
1046
+ const dpopProof = isDpopRequest
1047
+ ? await this.generateDpopProof(response, request)
1048
+ : undefined;
907
1049
 
908
1050
  const result: AuthenticationResult = {
909
1051
  authority: authority,
@@ -920,6 +1062,7 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
920
1062
  reqTimestamp + response.expires_in
921
1063
  ),
922
1064
  tokenType: tokenType,
1065
+ dpopProof,
923
1066
  correlationId: this.correlationId,
924
1067
  state: response.state,
925
1068
  fromPlatformBroker: true,
@@ -937,7 +1080,8 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
937
1080
  */
938
1081
  async cacheAccount(
939
1082
  accountEntity: AccountEntity,
940
- kmsi: boolean
1083
+ kmsi: boolean,
1084
+ clearExistingTokens: boolean = true
941
1085
  ): Promise<void> {
942
1086
  // Store the account info and hence `nativeAccountId` in browser cache
943
1087
  await this.browserStorage.setAccount(
@@ -947,10 +1091,12 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
947
1091
  this.apiId
948
1092
  );
949
1093
  // Remove any existing cached tokens for this account in browser storage
950
- this.browserStorage.removeAccountContext(
951
- AccountEntityUtils.getAccountInfo(accountEntity),
952
- this.correlationId
953
- );
1094
+ if (clearExistingTokens) {
1095
+ this.browserStorage.removeAccountContext(
1096
+ AccountEntityUtils.getAccountInfo(accountEntity),
1097
+ this.correlationId
1098
+ );
1099
+ }
954
1100
  }
955
1101
 
956
1102
  /**
@@ -971,7 +1117,8 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
971
1117
  tenantId: string,
972
1118
  reqTimestamp: number,
973
1119
  environment: string,
974
- storeInCache?: StoreInCache
1120
+ storeInCache?: StoreInCache,
1121
+ dpopBrokerOutcome: "none" | "L1" | "L3" = "none"
975
1122
  ): Promise<void> {
976
1123
  const cachedIdToken: IdTokenEntity | null =
977
1124
  CacheHelpers.createIdTokenEntity(
@@ -982,6 +1129,23 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
982
1129
  idTokenClaims.tid || ""
983
1130
  );
984
1131
 
1132
+ // save idtoken credential in configured browser storage
1133
+ if (!!cachedIdToken && storeInCache?.idToken !== false) {
1134
+ await this.browserStorage.setIdTokenCredential(
1135
+ cachedIdToken,
1136
+ this.correlationId,
1137
+ AuthToken.isKmsi(idTokenClaims)
1138
+ );
1139
+ }
1140
+
1141
+ if (dpopBrokerOutcome === "L3") {
1142
+ return;
1143
+ }
1144
+
1145
+ if (storeInCache?.accessToken === false) {
1146
+ return;
1147
+ }
1148
+
985
1149
  // cache accessToken in inmemory storage
986
1150
  const expiresIn: number =
987
1151
  request.tokenType === Constants.AuthenticationScheme.POP
@@ -994,45 +1158,32 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
994
1158
  response.scope,
995
1159
  request.scope
996
1160
  );
997
-
998
1161
  const additionalCacheKeyComponents = request.attributeTokens
999
- ? {
1000
- attribute_tokens: request.attributeTokens,
1001
- }
1162
+ ? { attribute_tokens: request.attributeTokens }
1002
1163
  : undefined;
1003
-
1004
- const cachedAccessToken: AccessTokenEntity | null =
1005
- CacheHelpers.createAccessTokenEntity(
1006
- homeAccountIdentifier,
1007
- environment,
1008
- response.access_token,
1009
- request.clientId,
1010
- idTokenClaims.tid || tenantId,
1011
- responseScopes.printScopes(),
1012
- tokenExpirationSeconds,
1013
- 0,
1014
- base64Decode,
1015
- request.correlationId,
1016
- undefined,
1017
- request.tokenType as Constants.AuthenticationScheme,
1018
- undefined,
1019
- request.keyId,
1020
- additionalCacheKeyComponents
1021
- );
1022
-
1164
+ const cachedAccessToken = CacheHelpers.createAccessTokenEntity(
1165
+ homeAccountIdentifier,
1166
+ environment,
1167
+ response.access_token,
1168
+ request.clientId,
1169
+ idTokenClaims.tid || tenantId,
1170
+ responseScopes.printScopes(),
1171
+ tokenExpirationSeconds,
1172
+ 0,
1173
+ base64Decode,
1174
+ request.correlationId,
1175
+ undefined,
1176
+ this.isDpopBrokerRequest(request)
1177
+ ? Constants.AuthenticationScheme.DPOP
1178
+ : (request.tokenType as Constants.AuthenticationScheme),
1179
+ undefined,
1180
+ request.keyId,
1181
+ additionalCacheKeyComponents
1182
+ );
1023
1183
  if (request.extraParameters?.resource) {
1024
1184
  cachedAccessToken.resource = request.extraParameters.resource;
1025
1185
  }
1026
1186
 
1027
- // save idtoken credential in configured browser storage
1028
- if (!!cachedIdToken && storeInCache?.idToken !== false) {
1029
- await this.browserStorage.setIdTokenCredential(
1030
- cachedIdToken,
1031
- this.correlationId,
1032
- AuthToken.isKmsi(idTokenClaims)
1033
- );
1034
- }
1035
-
1036
1187
  // save access token credential in memory storage
1037
1188
  const nativeCacheRecord = {
1038
1189
  accessToken: cachedAccessToken,
@@ -1149,15 +1300,12 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
1149
1300
  ? undefined
1150
1301
  : this.config.auth.clientCapabilities;
1151
1302
 
1152
- /*
1153
- * 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.
1154
- * attributeTokens is destructured out because PlatformAuthRequest represents it as a pre-serialized string, not the caller-provided Array<string>.
1155
- */
1156
- const { scopes, claims, extraParametersNoCache, dpopNonce } =
1157
- request as (PopupRequest | SsoSilentRequest) & {
1158
- extraParametersNoCache?: PlatformAuthExtraParametersNoCache;
1159
- dpopNonce?: string;
1160
- };
1303
+ const { scopes, claims, dpopNonce } = request as (
1304
+ | PopupRequest
1305
+ | SsoSilentRequest
1306
+ ) & {
1307
+ dpopNonce?: string;
1308
+ };
1161
1309
  const scopeSet = new ScopeSet(
1162
1310
  [...(scopes || []), ...Constants.OIDC_DEFAULT_SCOPES],
1163
1311
  this.correlationId
@@ -1198,36 +1346,16 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
1198
1346
  loginHint: request.loginHint,
1199
1347
  extraParameters: {
1200
1348
  ...request.extraParameters,
1201
- ...(request.resource && { resource: request.resource }), // resource is set for MCP scenarios
1349
+ // Native broker resource is set for MCP scenarios.
1350
+ ...(request.resource && { resource: request.resource }),
1202
1351
  },
1203
1352
  extendedExpiryToken: false, // Make this configurable?
1204
1353
  keyId: request.popKid,
1205
- resourceRequestMethod: request.resourceRequestMethod,
1206
- resourceRequestUri: request.resourceRequestUri,
1207
- shrClaims: request.shrClaims,
1208
- shrNonce: request.shrNonce,
1209
- extraParametersNoCache: createPlatformAuthExtraParametersNoCache(
1210
- extraParametersNoCache,
1211
- isProofOfPossessionTokenType(request.authenticationScheme),
1212
- request.resourceRequestMethod,
1213
- request.resourceRequestUri,
1214
- dpopNonce
1215
- ),
1216
1354
  };
1217
1355
 
1218
1356
  if (hasAttributeTokens) {
1219
1357
  validatedRequest.attributeTokens =
1220
- CacheHelpers.serializeAttributeTokens(
1221
- request.attributeTokens as Array<string>
1222
- );
1223
- }
1224
-
1225
- // Check for PoP token requests: signPopToken should only be set to true if popKid is not set
1226
- if (validatedRequest.signPopToken && !!request.popKid) {
1227
- throw createBrowserAuthError(
1228
- BrowserAuthErrorCodes.invalidPopTokenRequest,
1229
- this.correlationId
1230
- );
1358
+ CacheHelpers.serializeAttributeTokens(request.attributeTokens);
1231
1359
  }
1232
1360
 
1233
1361
  this.handleExtraBrokerParams(
@@ -1242,23 +1370,19 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
1242
1370
  if (
1243
1371
  request.authenticationScheme === Constants.AuthenticationScheme.POP
1244
1372
  ) {
1245
- // add POP request type
1246
1373
  const shrParameters: SignedHttpRequestParameters = {
1247
- resourceRequestUri: request.resourceRequestUri,
1248
1374
  resourceRequestMethod: request.resourceRequestMethod,
1375
+ resourceRequestUri: request.resourceRequestUri,
1249
1376
  shrClaims: request.shrClaims,
1250
1377
  shrNonce: request.shrNonce,
1251
1378
  correlationId: this.correlationId,
1252
1379
  };
1253
-
1254
1380
  const popTokenGenerator = new PopTokenGenerator(
1255
1381
  this.browserCrypto,
1256
1382
  this.tokenBindingKeyManager,
1257
1383
  this.performanceClient
1258
1384
  );
1259
1385
 
1260
- // generate reqCnf if not provided in the request
1261
- let reqCnfData;
1262
1386
  if (!validatedRequest.keyId) {
1263
1387
  const generatedReqCnfData = await invokeAsync(
1264
1388
  popTokenGenerator.generateCnf.bind(popTokenGenerator),
@@ -1267,24 +1391,625 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
1267
1391
  this.performanceClient,
1268
1392
  this.correlationId
1269
1393
  )(shrParameters, this.logger);
1270
- reqCnfData = generatedReqCnfData.reqCnfString;
1394
+ validatedRequest.reqCnf = generatedReqCnfData.reqCnfString;
1271
1395
  validatedRequest.keyId = generatedReqCnfData.kid;
1272
1396
  validatedRequest.signPopToken = true;
1273
1397
  } else {
1274
- reqCnfData = this.browserCrypto.base64UrlEncode(
1398
+ validatedRequest.reqCnf = this.browserCrypto.base64UrlEncode(
1275
1399
  JSON.stringify({ kid: validatedRequest.keyId })
1276
1400
  );
1277
1401
  validatedRequest.signPopToken = false;
1278
1402
  }
1279
1403
 
1280
- // SPAs require whole string to be passed to broker
1281
- validatedRequest.reqCnf = reqCnfData;
1404
+ validatedRequest.resourceRequestMethod =
1405
+ request.resourceRequestMethod;
1406
+ validatedRequest.resourceRequestUri = request.resourceRequestUri;
1407
+ validatedRequest.shrClaims = request.shrClaims;
1408
+ validatedRequest.shrNonce = request.shrNonce;
1409
+ } else if (
1410
+ request.authenticationScheme === Constants.AuthenticationScheme.DPOP
1411
+ ) {
1412
+ Object.assign(
1413
+ validatedRequest,
1414
+ this.createDpopRequestParameters(request)
1415
+ );
1282
1416
  }
1417
+
1418
+ validatedRequest.extraParametersNoCache =
1419
+ createPlatformAuthExtraParametersNoCache(
1420
+ validatedRequest.tokenType,
1421
+ validatedRequest.resourceRequestMethod,
1422
+ validatedRequest.resourceRequestUri,
1423
+ dpopNonce
1424
+ );
1283
1425
  this.addRequestSKUs(validatedRequest);
1284
1426
 
1285
1427
  return validatedRequest;
1286
1428
  }
1287
1429
 
1430
+ /**
1431
+ * Creates and validates the broker-specific parameters for a DPoP request.
1432
+ * @param request - Developer-provided token request.
1433
+ * @returns Broker parameters for a DPoP token and resource proof.
1434
+ */
1435
+ private createDpopRequestParameters(
1436
+ request: PopupRequest | SsoSilentRequest
1437
+ ): Partial<PlatformAuthRequest> {
1438
+ if (request.popKid) {
1439
+ throw createBrowserAuthError(
1440
+ DPOP_POP_KID_NOT_SUPPORTED,
1441
+ this.correlationId
1442
+ );
1443
+ }
1444
+
1445
+ if (
1446
+ !request.resourceRequestMethod?.trim() ||
1447
+ !request.resourceRequestUri?.trim()
1448
+ ) {
1449
+ throw createClientConfigurationError(
1450
+ ClientConfigurationErrorCodes.dpopMissingResourceContext,
1451
+ this.correlationId
1452
+ );
1453
+ }
1454
+
1455
+ const resourceContext = normalizeDpopResourceRequestContext(
1456
+ {
1457
+ htm: request.resourceRequestMethod,
1458
+ htu: request.resourceRequestUri,
1459
+ },
1460
+ this.correlationId
1461
+ );
1462
+
1463
+ return {
1464
+ tokenType: PlatformAuthTokenType.DPOP_WITH_PROOF,
1465
+ preferBinding: PlatformAuthBindingPreference.ATTESTED,
1466
+ keyId: request.dpopJkt,
1467
+ resourceRequestMethod: resourceContext.htm,
1468
+ resourceRequestUri: resourceContext.htu,
1469
+ };
1470
+ }
1471
+
1472
+ /**
1473
+ * Provisions the local key and confirmation data for a DPoP broker request.
1474
+ * @param request - Broker request to prepare.
1475
+ * @param reuseExistingKey - Whether a complete existing key binding may be reused.
1476
+ */
1477
+ private async prepareDpopBrokerRequest(
1478
+ request: PlatformAuthRequest,
1479
+ reuseExistingKey: boolean = false
1480
+ ): Promise<void> {
1481
+ if (request.tokenType !== PlatformAuthTokenType.DPOP_WITH_PROOF) {
1482
+ return;
1483
+ }
1484
+
1485
+ /*
1486
+ * Phase one clears both fields after an L3 response or non-fatal broker
1487
+ * error. In that case phase two must provision a replacement. If either
1488
+ * field remains, treat it as a retained binding and validate it fully.
1489
+ */
1490
+ if (reuseExistingKey && (request.keyId || request.reqCnf)) {
1491
+ if (!request.keyId || !request.reqCnf) {
1492
+ throw createAuthError(
1493
+ AuthErrorCodes.unexpectedError,
1494
+ this.correlationId,
1495
+ "DPoP request key binding is incomplete after redirect."
1496
+ );
1497
+ }
1498
+
1499
+ const expectedReqCnf = this.createDpopBrokerReqCnf(request.keyId);
1500
+ if (request.reqCnf !== expectedReqCnf) {
1501
+ throw createAuthError(
1502
+ AuthErrorCodes.unexpectedError,
1503
+ this.correlationId,
1504
+ "DPoP request key binding is invalid after redirect."
1505
+ );
1506
+ }
1507
+ const hasKey =
1508
+ this.tokenBindingKeyManager.hasTokenBindingKey !== undefined
1509
+ ? await this.tokenBindingKeyManager.hasTokenBindingKey(
1510
+ request.keyId,
1511
+ this.correlationId
1512
+ )
1513
+ : await this.tokenBindingKeyManager
1514
+ .getTokenBindingPublicKeyJwk(
1515
+ request.keyId,
1516
+ this.correlationId
1517
+ )
1518
+ .then(
1519
+ () => true,
1520
+ () => false
1521
+ );
1522
+ if (!hasKey) {
1523
+ throw createAuthError(
1524
+ AuthErrorCodes.unexpectedError,
1525
+ this.correlationId,
1526
+ "DPoP request key is unavailable after redirect."
1527
+ );
1528
+ }
1529
+ return;
1530
+ }
1531
+
1532
+ if (request.reqCnf) {
1533
+ throw createAuthError(
1534
+ AuthErrorCodes.unexpectedError,
1535
+ this.correlationId,
1536
+ "Unexpected preexisting DPoP request key."
1537
+ );
1538
+ }
1539
+
1540
+ if (!request.keyId) {
1541
+ request.keyId =
1542
+ await this.tokenBindingKeyManager.provisionTokenBindingKey({
1543
+ tokenBindingKeyType:
1544
+ Constants.AuthenticationScheme.DPOP.toLowerCase(),
1545
+ tokenBindingKeyAlgorithm: JsonWebTokenAlgorithms.ES256,
1546
+ correlationId: this.correlationId,
1547
+ });
1548
+ }
1549
+ request.reqCnf = this.createDpopBrokerReqCnf(request.keyId);
1550
+ }
1551
+
1552
+ /**
1553
+ * Creates the confirmation claim for an MSAL-owned broker DPoP key.
1554
+ * @param keyId - Browser-managed DPoP key identifier.
1555
+ * @returns Encoded broker confirmation claim.
1556
+ */
1557
+ private createDpopBrokerReqCnf(keyId: string): string {
1558
+ return this.browserCrypto.base64UrlEncode(
1559
+ JSON.stringify({
1560
+ kid: keyId,
1561
+ xms_ksl:
1562
+ PlatformAuthInteractionClient.MSAL_DPOP_KEY_STORAGE_LOCATION,
1563
+ })
1564
+ );
1565
+ }
1566
+
1567
+ /**
1568
+ * Ensures an owned DPoP key can survive redirect navigation before the
1569
+ * request metadata is persisted for phase two.
1570
+ */
1571
+ private async ensureRedirectDpopKeyIsPersisted(
1572
+ request: PlatformAuthRequest
1573
+ ): Promise<void> {
1574
+ if (!this.isDpopBrokerRequest(request) || !request.keyId) {
1575
+ return;
1576
+ }
1577
+
1578
+ if (
1579
+ !(await isTokenBindingKeyPersistedForRedirect(
1580
+ request,
1581
+ this.tokenBindingKeyManager
1582
+ ))
1583
+ ) {
1584
+ throw createAuthError(
1585
+ AuthErrorCodes.unexpectedError,
1586
+ this.correlationId,
1587
+ "DPoP request key could not be persisted for redirect."
1588
+ );
1589
+ }
1590
+ }
1591
+
1592
+ /**
1593
+ * Validates and normalizes the DPoP binding outcome returned by the broker.
1594
+ * @param response - Broker response to validate.
1595
+ * @param request - Broker request associated with the response.
1596
+ * @returns The validated DPoP binding level, or `none` for non-DPoP requests.
1597
+ */
1598
+ private validateDpopBrokerOutcome(
1599
+ response: PlatformAuthResponse,
1600
+ request: PlatformAuthRequest
1601
+ ): BrokerDpopOutcome {
1602
+ const isDpopRequest = this.isDpopBrokerRequest(request);
1603
+ const normalizedResponse = this.normalizeDpopBrokerResponse(response);
1604
+ const normalizedRequestTokenType = request.tokenType
1605
+ ?.trim()
1606
+ .toLowerCase();
1607
+ const bindingPreferenceSent =
1608
+ request.bindingPreferenceSent ??
1609
+ request.preferBinding !== undefined;
1610
+ const hasDpopResponse =
1611
+ this.isDpopBrokerTokenType(normalizedResponse.tokenType) ||
1612
+ normalizedResponse.proof !== undefined ||
1613
+ normalizedResponse.hasBindingAttested;
1614
+
1615
+ if (!isDpopRequest) {
1616
+ if (hasDpopResponse) {
1617
+ this.throwInvalidDpopResponse(
1618
+ "unexpected_response",
1619
+ "Unexpected DPoP broker response."
1620
+ );
1621
+ }
1622
+ return "none";
1623
+ }
1624
+
1625
+ if (!this.isDpopBrokerTokenType(normalizedResponse.tokenType)) {
1626
+ this.throwInvalidDpopResponse(
1627
+ "unknown_token_type",
1628
+ "Unknown DPoP broker response."
1629
+ );
1630
+ }
1631
+
1632
+ this.validateNormalizedDpopBrokerResponse(
1633
+ normalizedResponse,
1634
+ bindingPreferenceSent
1635
+ );
1636
+
1637
+ if (
1638
+ normalizedResponse.tokenType ===
1639
+ PlatformAuthTokenType.DPOP_WITH_PROOF.toLowerCase()
1640
+ ) {
1641
+ return this.validateDpopBrokerL3Outcome(
1642
+ normalizedRequestTokenType,
1643
+ normalizedResponse
1644
+ );
1645
+ }
1646
+
1647
+ return this.validateDpopBrokerL1Outcome(
1648
+ request,
1649
+ normalizedRequestTokenType,
1650
+ normalizedResponse,
1651
+ bindingPreferenceSent
1652
+ );
1653
+ }
1654
+
1655
+ /**
1656
+ * Normalizes the canonical DPoP fields returned under response properties.
1657
+ */
1658
+ private normalizeDpopBrokerResponse(
1659
+ response: PlatformAuthResponse
1660
+ ): NormalizedDpopBrokerResponse {
1661
+ const responseProperties = response.properties as
1662
+ | NativeResponseProperties
1663
+ | undefined;
1664
+ const rawTokenType = responseProperties?.token_type;
1665
+ const tokenType =
1666
+ typeof rawTokenType === "string"
1667
+ ? rawTokenType.trim().toLowerCase()
1668
+ : undefined;
1669
+ const rawBindingAttested = responseProperties?.binding_attested;
1670
+ let bindingAttested: boolean | undefined;
1671
+
1672
+ if (typeof rawBindingAttested === "string") {
1673
+ const normalizedBindingAttested = rawBindingAttested
1674
+ .trim()
1675
+ .toLowerCase();
1676
+ if (normalizedBindingAttested === "true") {
1677
+ bindingAttested = true;
1678
+ } else if (normalizedBindingAttested === "false") {
1679
+ bindingAttested = false;
1680
+ }
1681
+ }
1682
+
1683
+ return {
1684
+ tokenType,
1685
+ proof: responseProperties?.DPoP,
1686
+ bindingAttested,
1687
+ hasBindingAttested: rawBindingAttested !== undefined,
1688
+ hasMalformedBindingAttested:
1689
+ rawBindingAttested !== undefined &&
1690
+ bindingAttested === undefined,
1691
+ };
1692
+ }
1693
+
1694
+ /**
1695
+ * Validates normalized fields shared by L1 and L3 broker DPoP responses.
1696
+ */
1697
+ private validateNormalizedDpopBrokerResponse(
1698
+ normalizedResponse: NormalizedDpopBrokerResponse,
1699
+ bindingPreferenceSent: boolean
1700
+ ): void {
1701
+ if (normalizedResponse.hasMalformedBindingAttested) {
1702
+ this.throwInvalidDpopResponse(
1703
+ "invalid_attestation",
1704
+ "Conflicting DPoP broker response."
1705
+ );
1706
+ }
1707
+
1708
+ if (
1709
+ bindingPreferenceSent &&
1710
+ normalizedResponse.bindingAttested === undefined
1711
+ ) {
1712
+ this.throwInvalidDpopResponse(
1713
+ "missing_attestation",
1714
+ "Conflicting DPoP broker response."
1715
+ );
1716
+ }
1717
+ }
1718
+
1719
+ /**
1720
+ * Validates a broker-returned L3 DPoP proof outcome.
1721
+ */
1722
+ private validateDpopBrokerL3Outcome(
1723
+ normalizedRequestTokenType: string | undefined,
1724
+ normalizedResponse: NormalizedDpopBrokerResponse
1725
+ ): "L3" {
1726
+ const dpopWithProofTokenType =
1727
+ PlatformAuthTokenType.DPOP_WITH_PROOF.toLowerCase();
1728
+
1729
+ if (
1730
+ typeof normalizedResponse.proof !== "string" ||
1731
+ normalizedResponse.proof.trim().length === 0
1732
+ ) {
1733
+ this.throwInvalidDpopResponse(
1734
+ "missing_proof",
1735
+ "Malformed DPoP broker response."
1736
+ );
1737
+ }
1738
+
1739
+ if (normalizedResponse.bindingAttested !== true) {
1740
+ this.throwInvalidDpopResponse(
1741
+ "invalid_attestation",
1742
+ "Malformed DPoP broker response."
1743
+ );
1744
+ }
1745
+ if (
1746
+ normalizedRequestTokenType !== dpopWithProofTokenType ||
1747
+ normalizedResponse.tokenType !== dpopWithProofTokenType
1748
+ ) {
1749
+ this.throwInvalidDpopResponse(
1750
+ "conflicting_fields",
1751
+ "Malformed DPoP broker response."
1752
+ );
1753
+ }
1754
+
1755
+ this.performanceClient.addFields(
1756
+ {
1757
+ "ext.brokerDpopOutcome": "l3",
1758
+ "ext.brokerDpopBindingLevel": "L3",
1759
+ },
1760
+ this.correlationId
1761
+ );
1762
+ return "L3";
1763
+ }
1764
+
1765
+ /**
1766
+ * Validates an L1 DPoP outcome that MSAL will sign with its local key.
1767
+ */
1768
+ private validateDpopBrokerL1Outcome(
1769
+ request: PlatformAuthRequest,
1770
+ normalizedRequestTokenType: string | undefined,
1771
+ normalizedResponse: NormalizedDpopBrokerResponse,
1772
+ bindingPreferenceSent: boolean
1773
+ ): "L1" {
1774
+ if (normalizedResponse.proof !== undefined) {
1775
+ this.throwInvalidDpopResponse(
1776
+ "conflicting_fields",
1777
+ "Malformed DPoP broker L1 response."
1778
+ );
1779
+ }
1780
+
1781
+ if (
1782
+ normalizedRequestTokenType !==
1783
+ PlatformAuthTokenType.DPOP_WITH_PROOF.toLowerCase()
1784
+ ) {
1785
+ this.throwInvalidDpopResponse(
1786
+ "conflicting_fields",
1787
+ "Malformed DPoP broker L1 response."
1788
+ );
1789
+ }
1790
+
1791
+ if (
1792
+ normalizedResponse.bindingAttested !== false &&
1793
+ !(
1794
+ !bindingPreferenceSent &&
1795
+ normalizedResponse.bindingAttested === undefined
1796
+ )
1797
+ ) {
1798
+ this.throwInvalidDpopResponse(
1799
+ "invalid_attestation",
1800
+ "Malformed DPoP broker L1 response."
1801
+ );
1802
+ }
1803
+
1804
+ if (!request.reqCnf || !request.keyId) {
1805
+ this.throwInvalidDpopResponse(
1806
+ "missing_l1_binding",
1807
+ "Malformed DPoP broker L1 response."
1808
+ );
1809
+ }
1810
+
1811
+ this.performanceClient.addFields(
1812
+ {
1813
+ "ext.brokerDpopOutcome": "l1",
1814
+ "ext.brokerDpopBindingLevel": "L1",
1815
+ },
1816
+ this.correlationId
1817
+ );
1818
+ return "L1";
1819
+ }
1820
+
1821
+ /**
1822
+ * Emits bounded failure telemetry and rejects an invalid DPoP response.
1823
+ */
1824
+ private throwInvalidDpopResponse(
1825
+ failureReason: BrokerDpopFailureReason,
1826
+ message: string
1827
+ ): never {
1828
+ this.performanceClient.addFields(
1829
+ {
1830
+ "ext.brokerDpopOutcome": "invalid_response",
1831
+ "ext.brokerDpopFailureReason": failureReason,
1832
+ },
1833
+ this.correlationId
1834
+ );
1835
+ throw createAuthError(
1836
+ AuthErrorCodes.unexpectedError,
1837
+ this.correlationId,
1838
+ message
1839
+ );
1840
+ }
1841
+
1842
+ /**
1843
+ * Returns the broker proof or signs an L1 resource proof with the local key.
1844
+ * @param response - Broker response containing the access token and optional proof.
1845
+ * @param request - Broker request containing the proof context and local key.
1846
+ * @returns The resource proof for the broker access token.
1847
+ */
1848
+ private async generateDpopProof(
1849
+ response: PlatformAuthResponse,
1850
+ request: PlatformAuthRequest
1851
+ ): Promise<string> {
1852
+ const brokerProof = response.properties?.DPoP;
1853
+ if (brokerProof !== undefined) {
1854
+ return brokerProof;
1855
+ }
1856
+
1857
+ const dpopProofGenerator = new DpopProofGenerator(
1858
+ this.browserCrypto,
1859
+ this.tokenBindingKeyManager
1860
+ );
1861
+ return dpopProofGenerator.generateResourceProof(
1862
+ {
1863
+ htu: request.resourceRequestUri,
1864
+ htm: request.resourceRequestMethod,
1865
+ accessToken: response.access_token,
1866
+ nonce: request.extraParametersNoCache?.pop_nonce,
1867
+ },
1868
+ request.keyId as string,
1869
+ this.correlationId
1870
+ );
1871
+ }
1872
+
1873
+ /**
1874
+ * Removes a generated DPoP request key and clears its request metadata.
1875
+ * @param request - Broker request whose generated key should be removed.
1876
+ */
1877
+ private async resetGeneratedDpopRequestKey(
1878
+ request: PlatformAuthRequest
1879
+ ): Promise<void> {
1880
+ if (!this.isDpopBrokerRequest(request) || !request.keyId) {
1881
+ return;
1882
+ }
1883
+
1884
+ const cleanupMeasurement = this.performanceClient.startMeasurement(
1885
+ BrowserPerformanceEvents.PlatformAuthDpopKeyCleanup,
1886
+ this.correlationId
1887
+ );
1888
+ this.performanceClient.incrementFields(
1889
+ { "ext.brokerDpopKeyCleanupAttemptCount": 1 },
1890
+ this.correlationId
1891
+ );
1892
+
1893
+ try {
1894
+ if (request.keyId && !(await this.removeDpopKey(request.keyId))) {
1895
+ throw createAuthError(
1896
+ AuthErrorCodes.unexpectedError,
1897
+ this.correlationId,
1898
+ "Failed to remove generated DPoP request key."
1899
+ );
1900
+ }
1901
+
1902
+ this.performanceClient.addFields(
1903
+ {
1904
+ "ext.brokerDpopKeyCleanupOutcome": "succeeded",
1905
+ },
1906
+ this.correlationId
1907
+ );
1908
+ cleanupMeasurement.end({ success: true });
1909
+ request.keyId = undefined;
1910
+ request.reqCnf = undefined;
1911
+ } catch (error) {
1912
+ this.performanceClient.addFields(
1913
+ {
1914
+ "ext.brokerDpopKeyCleanupOutcome": "failed",
1915
+ },
1916
+ this.correlationId
1917
+ );
1918
+ this.performanceClient.incrementFields(
1919
+ { "ext.brokerDpopKeyCleanupFailureCount": 1 },
1920
+ this.correlationId
1921
+ );
1922
+ cleanupMeasurement.end({ success: false }, error);
1923
+ throw error;
1924
+ }
1925
+ }
1926
+
1927
+ /**
1928
+ * Attempts to remove a generated DPoP request key without replacing an
1929
+ * existing operation error with a cleanup failure.
1930
+ * @param request - Broker request whose generated key should be removed.
1931
+ */
1932
+ private async resetGeneratedDpopRequestKeyBestEffort(
1933
+ request: PlatformAuthRequest
1934
+ ): Promise<void> {
1935
+ try {
1936
+ await this.resetGeneratedDpopRequestKey(request);
1937
+ } catch {
1938
+ this.logger.error(
1939
+ "Failed to remove generated DPoP request key after an operation error.",
1940
+ this.correlationId
1941
+ );
1942
+ this.performanceClient.incrementFields(
1943
+ { removeTokenBindingKeyFailure: 1 },
1944
+ this.correlationId
1945
+ );
1946
+
1947
+ request.keyId = undefined;
1948
+ request.reqCnf = undefined;
1949
+ }
1950
+ }
1951
+
1952
+ /**
1953
+ * Records that a DPoP request is about to be dispatched to the platform broker.
1954
+ * @param request - Broker request about to cross the provider boundary.
1955
+ */
1956
+ private addDpopBrokerAttemptTelemetry(request: PlatformAuthRequest): void {
1957
+ if (!this.isDpopBrokerRequest(request)) {
1958
+ return;
1959
+ }
1960
+
1961
+ this.performanceClient.addFields(
1962
+ {
1963
+ "ext.brokerDpopAttempted": 1,
1964
+ },
1965
+ this.correlationId
1966
+ );
1967
+ }
1968
+
1969
+ /**
1970
+ * Determines whether a request uses the DPoP broker protocol.
1971
+ * @param request - Broker request to inspect.
1972
+ * @returns Whether the request uses a DPoP token type.
1973
+ */
1974
+ private isDpopBrokerRequest(request: PlatformAuthRequest): boolean {
1975
+ return this.isDpopBrokerTokenType(request.tokenType);
1976
+ }
1977
+
1978
+ /**
1979
+ * Determines whether a token type represents a DPoP broker request.
1980
+ * @param tokenType - Token type to inspect.
1981
+ * @returns Whether the token type is a supported DPoP broker token type.
1982
+ */
1983
+ private isDpopBrokerTokenType(tokenType: string | undefined): boolean {
1984
+ const normalizedTokenType = tokenType?.trim().toLowerCase();
1985
+ return (
1986
+ normalizedTokenType === PlatformAuthTokenType.DPOP_WITH_PROOF ||
1987
+ normalizedTokenType ===
1988
+ Constants.AuthenticationScheme.DPOP.toLowerCase()
1989
+ );
1990
+ }
1991
+
1992
+ /**
1993
+ * Removes a DPoP key while reporting cleanup failures.
1994
+ * @param keyId - Identifier of the DPoP key to remove.
1995
+ * @returns Whether the key was removed successfully.
1996
+ */
1997
+ private async removeDpopKey(keyId: string): Promise<boolean> {
1998
+ try {
1999
+ await this.tokenBindingKeyManager.removeTokenBindingKey(
2000
+ keyId,
2001
+ this.correlationId
2002
+ );
2003
+ return true;
2004
+ } catch {
2005
+ this.logger.error(
2006
+ "Failed to remove unused DPoP key",
2007
+ this.correlationId
2008
+ );
2009
+ return false;
2010
+ }
2011
+ }
2012
+
1288
2013
  private async getCanonicalAuthority(
1289
2014
  request: PopupRequest | SsoSilentRequest
1290
2015
  ): Promise<UrlString> {
@@ -1362,41 +2087,39 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
1362
2087
  }
1363
2088
 
1364
2089
  /**
1365
- * Handles extra broker request parameters
1366
- * @param request {PlatformAuthRequest}
1367
- * @private
2090
+ * Handles extra broker request parameters.
2091
+ * @param request - Platform broker request.
2092
+ * @param embeddedClientId - Embedded application client identifier.
1368
2093
  */
1369
2094
  private handleExtraBrokerParams(
1370
2095
  request: PlatformAuthRequest,
1371
2096
  embeddedClientId?: string
1372
2097
  ): void {
1373
- const hasExtraBrokerParams =
1374
- request.extraParameters &&
1375
- request.extraParameters.hasOwnProperty(
1376
- AADServerParamKeys.BROKER_CLIENT_ID
1377
- ) &&
1378
- request.extraParameters.hasOwnProperty(
1379
- AADServerParamKeys.BROKER_REDIRECT_URI
1380
- ) &&
1381
- request.extraParameters.hasOwnProperty(
1382
- AADServerParamKeys.CLIENT_ID
2098
+ const hasOwnParameter = (parameter: string): boolean =>
2099
+ Object.prototype.hasOwnProperty.call(
2100
+ request.extraParameters,
2101
+ parameter
1383
2102
  );
2103
+ const hasExtraBrokerParams =
2104
+ hasOwnParameter(AADServerParamKeys.BROKER_CLIENT_ID) &&
2105
+ hasOwnParameter(AADServerParamKeys.BROKER_REDIRECT_URI) &&
2106
+ hasOwnParameter(AADServerParamKeys.CLIENT_ID);
1384
2107
 
1385
2108
  if (!embeddedClientId && !hasExtraBrokerParams) {
1386
2109
  return;
1387
2110
  }
1388
2111
 
1389
- let child_client_id: string = "";
1390
- const child_redirect_uri = request.redirectUri;
2112
+ const childRedirectUri = request.redirectUri;
2113
+ const childClientId =
2114
+ embeddedClientId ||
2115
+ request.extraParameters?.[AADServerParamKeys.CLIENT_ID] ||
2116
+ "";
1391
2117
 
1392
2118
  if (embeddedClientId) {
1393
2119
  request.redirectUri = this.config.auth.redirectUri;
1394
- child_client_id = embeddedClientId;
1395
2120
  } else if (request.extraParameters) {
1396
2121
  request.redirectUri =
1397
2122
  request.extraParameters[AADServerParamKeys.BROKER_REDIRECT_URI];
1398
- child_client_id =
1399
- request.extraParameters[AADServerParamKeys.CLIENT_ID];
1400
2123
  }
1401
2124
 
1402
2125
  const {
@@ -1411,14 +2134,14 @@ export class PlatformAuthInteractionClient extends BaseInteractionClient {
1411
2134
 
1412
2135
  request.extraParameters = {
1413
2136
  ...remainingExtraParameters,
1414
- child_client_id,
1415
- child_redirect_uri,
2137
+ child_client_id: childClientId,
2138
+ child_redirect_uri: childRedirectUri,
1416
2139
  };
1417
2140
 
1418
2141
  this.performanceClient?.addFields(
1419
2142
  {
1420
- embeddedClientId: child_client_id,
1421
- embeddedRedirectUri: child_redirect_uri,
2143
+ embeddedClientId: childClientId,
2144
+ embeddedRedirectUri: childRedirectUri,
1422
2145
  },
1423
2146
  this.correlationId
1424
2147
  );