@azure/msal-browser 5.28.0 → 5.29.1

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 (507) hide show
  1. package/dist/app/IPublicClientApplication.mjs +1 -1
  2. package/dist/app/PublicClientApplication.mjs +1 -1
  3. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  4. package/dist/broker/nativeBroker/PlatformAuthDOMHandler.mjs +1 -1
  5. package/dist/broker/nativeBroker/PlatformAuthExtensionHandler.mjs +1 -1
  6. package/dist/broker/nativeBroker/PlatformAuthProvider.mjs +1 -1
  7. package/dist/broker/nativeBroker/PlatformAuthRequest.mjs +1 -1
  8. package/dist/cache/AccountManager.mjs +1 -1
  9. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  10. package/dist/cache/BrowserCacheManager.mjs +1 -1
  11. package/dist/cache/CacheHelpers.mjs +1 -1
  12. package/dist/cache/CacheKeys.mjs +1 -1
  13. package/dist/cache/CookieStorage.mjs +1 -1
  14. package/dist/cache/DatabaseStorage.mjs +1 -1
  15. package/dist/cache/EncryptedData.mjs +1 -1
  16. package/dist/cache/LocalStorage.mjs +1 -1
  17. package/dist/cache/MemoryStorage.mjs +1 -1
  18. package/dist/cache/SessionStorage.mjs +1 -1
  19. package/dist/cache/TokenCache.mjs +1 -1
  20. package/dist/config/Configuration.mjs +1 -1
  21. package/dist/controllers/NestedAppAuthController.mjs +1 -1
  22. package/dist/controllers/StandardController.mjs +1 -1
  23. package/dist/crypto/BrowserCrypto.mjs +1 -1
  24. package/dist/crypto/CryptoOps.mjs +1 -1
  25. package/dist/crypto/PkceGenerator.mjs +1 -1
  26. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  27. package/dist/crypto/TokenBindingKeyManager.mjs +1 -1
  28. package/dist/custom_auth/CustomAuthConstants.mjs +1 -1
  29. package/dist/custom_auth/CustomAuthPublicClientApplication.mjs +6 -4
  30. package/dist/custom_auth/CustomAuthPublicClientApplication.mjs.map +1 -1
  31. package/dist/custom_auth/controller/CustomAuthStandardController.mjs +58 -62
  32. package/dist/custom_auth/controller/CustomAuthStandardController.mjs.map +1 -1
  33. package/dist/custom_auth/core/CustomAuthAuthority.mjs +1 -1
  34. package/dist/custom_auth/core/auth_flow/AuthFlowErrorBase.mjs +1 -1
  35. package/dist/custom_auth/core/auth_flow/AuthFlowResultBase.mjs +1 -1
  36. package/dist/custom_auth/core/auth_flow/AuthFlowState.mjs +1 -1
  37. package/dist/custom_auth/core/auth_flow/AuthFlowStateTypes.mjs +1 -1
  38. package/dist/custom_auth/core/auth_flow/jit/error_type/AuthMethodRegistrationError.mjs +1 -1
  39. package/dist/custom_auth/core/auth_flow/jit/result/AuthMethodRegistrationChallengeMethodResult.mjs +1 -1
  40. package/dist/custom_auth/core/auth_flow/jit/result/AuthMethodRegistrationSubmitChallengeResult.mjs +1 -1
  41. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationCompletedState.mjs +1 -1
  42. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationFailedState.mjs +1 -1
  43. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationState.mjs +1 -1
  44. package/dist/custom_auth/core/auth_flow/mfa/error_type/MfaError.mjs +1 -1
  45. package/dist/custom_auth/core/auth_flow/mfa/result/MfaRequestChallengeResult.mjs +1 -1
  46. package/dist/custom_auth/core/auth_flow/mfa/result/MfaSubmitChallengeResult.mjs +1 -1
  47. package/dist/custom_auth/core/auth_flow/mfa/state/MfaCompletedState.mjs +1 -1
  48. package/dist/custom_auth/core/auth_flow/mfa/state/MfaFailedState.mjs +1 -1
  49. package/dist/custom_auth/core/auth_flow/mfa/state/MfaState.mjs +1 -1
  50. package/dist/custom_auth/core/auth_flow/v2/CustomAuthFlowScenarioV2.mjs +3 -5
  51. package/dist/custom_auth/core/auth_flow/v2/CustomAuthFlowScenarioV2.mjs.map +1 -1
  52. package/dist/custom_auth/core/auth_flow/v2/CustomAuthResultV2.mjs +19 -13
  53. package/dist/custom_auth/core/auth_flow/v2/CustomAuthResultV2.mjs.map +1 -1
  54. package/dist/custom_auth/core/auth_flow/v2/error/AuthFlowErrorSubcodesV2.mjs +8 -2
  55. package/dist/custom_auth/core/auth_flow/v2/error/AuthFlowErrorSubcodesV2.mjs.map +1 -1
  56. package/dist/custom_auth/core/auth_flow/v2/error/AuthFlowErrorV2.mjs +58 -69
  57. package/dist/custom_auth/core/auth_flow/v2/error/AuthFlowErrorV2.mjs.map +1 -1
  58. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodRegistrationRequiredStateV2.mjs +3 -3
  59. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.mjs +42 -15
  60. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.mjs.map +1 -1
  61. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodVerificationRequiredStateV2.mjs +17 -4
  62. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodVerificationRequiredStateV2.mjs.map +1 -1
  63. package/dist/custom_auth/core/auth_flow/v2/state/ChallengeVerificationStateBaseV2.mjs +1 -1
  64. package/dist/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.mjs +14 -18
  65. package/dist/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.mjs.map +1 -1
  66. package/dist/custom_auth/core/auth_flow/v2/state/CompletedStateV2.mjs +2 -4
  67. package/dist/custom_auth/core/auth_flow/v2/state/CompletedStateV2.mjs.map +1 -1
  68. package/dist/custom_auth/core/auth_flow/v2/state/FailedStateV2.mjs +2 -3
  69. package/dist/custom_auth/core/auth_flow/v2/state/FailedStateV2.mjs.map +1 -1
  70. package/dist/custom_auth/core/auth_flow/v2/state/MFAVerificationRequiredStateV2.mjs +17 -6
  71. package/dist/custom_auth/core/auth_flow/v2/state/MFAVerificationRequiredStateV2.mjs.map +1 -1
  72. package/dist/custom_auth/core/auth_flow/v2/state/PasswordRequiredStateV2.mjs +110 -0
  73. package/dist/custom_auth/core/auth_flow/v2/state/PasswordRequiredStateV2.mjs.map +1 -0
  74. package/dist/custom_auth/core/error/CustomAuthApiError.mjs +1 -1
  75. package/dist/custom_auth/core/error/CustomAuthError.mjs +1 -1
  76. package/dist/custom_auth/core/error/HttpError.mjs +1 -1
  77. package/dist/custom_auth/core/error/HttpErrorCodes.mjs +1 -1
  78. package/dist/custom_auth/core/error/InvalidArgumentError.mjs +2 -1
  79. package/dist/custom_auth/core/error/InvalidArgumentError.mjs.map +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 +256 -150
  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 +2 -6
  100. package/dist/custom_auth/core/interaction_client/v2/InteractionClientBaseV2.mjs.map +1 -1
  101. package/dist/custom_auth/core/interaction_client/v2/result/FlowActionResultV2.mjs +10 -3
  102. package/dist/custom_auth/core/interaction_client/v2/result/FlowActionResultV2.mjs.map +1 -1
  103. package/dist/custom_auth/core/network_client/custom_auth_api/BaseApiClient.mjs +1 -1
  104. package/dist/custom_auth/core/network_client/custom_auth_api/CustomAuthApiClient.mjs +1 -1
  105. package/dist/custom_auth/core/network_client/custom_auth_api/CustomAuthApiEndpoint.mjs +1 -1
  106. package/dist/custom_auth/core/network_client/custom_auth_api/RegisterApiClient.mjs +1 -1
  107. package/dist/custom_auth/core/network_client/custom_auth_api/ResetPasswordApiClient.mjs +1 -1
  108. package/dist/custom_auth/core/network_client/custom_auth_api/SignInApiClient.mjs +1 -1
  109. package/dist/custom_auth/core/network_client/custom_auth_api/SignupApiClient.mjs +1 -1
  110. package/dist/custom_auth/core/network_client/custom_auth_api/types/ApiErrorCodes.mjs +1 -1
  111. package/dist/custom_auth/core/network_client/custom_auth_api/types/ApiSuberrors.mjs +1 -1
  112. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.mjs +1 -7
  113. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.mjs.map +1 -1
  114. package/dist/custom_auth/core/network_client/custom_auth_api/v2/BaseApiClientV2.mjs +1 -1
  115. package/dist/custom_auth/core/network_client/custom_auth_api/v2/CustomAuthApiClientV2.mjs +35 -19
  116. package/dist/custom_auth/core/network_client/custom_auth_api/v2/CustomAuthApiClientV2.mjs.map +1 -1
  117. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ErrorCodesV2.mjs +1 -1
  118. package/dist/custom_auth/core/network_client/custom_auth_api/v2/HrefResolverV2.mjs +1 -1
  119. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.mjs +20 -9
  120. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.mjs.map +1 -1
  121. package/dist/custom_auth/core/network_client/custom_auth_api/v2/response/ErrorNormalizerV2.mjs +1 -1
  122. package/dist/custom_auth/core/network_client/custom_auth_api/v2/result/BaseResultsV2.mjs +1 -1
  123. package/dist/custom_auth/core/network_client/custom_auth_api/v2/result/BaseResultsV2.mjs.map +1 -1
  124. package/dist/custom_auth/core/network_client/custom_auth_api/v2/result/SignUpResultsV2.mjs +1 -2
  125. package/dist/custom_auth/core/network_client/custom_auth_api/v2/result/SignUpResultsV2.mjs.map +1 -1
  126. package/dist/custom_auth/core/network_client/http_client/FetchHttpClient.mjs +1 -1
  127. package/dist/custom_auth/core/network_client/http_client/IHttpClient.mjs +1 -1
  128. package/dist/custom_auth/core/telemetry/FlowApiIdHelperV2.mjs +5 -7
  129. package/dist/custom_auth/core/telemetry/FlowApiIdHelperV2.mjs.map +1 -1
  130. package/dist/custom_auth/core/telemetry/PublicApiId.mjs +3 -2
  131. package/dist/custom_auth/core/telemetry/PublicApiId.mjs.map +1 -1
  132. package/dist/custom_auth/core/utils/ArgumentValidator.mjs +17 -2
  133. package/dist/custom_auth/core/utils/ArgumentValidator.mjs.map +1 -1
  134. package/dist/custom_auth/core/utils/CustomHeaderUtils.mjs +1 -1
  135. package/dist/custom_auth/core/utils/UrlUtils.mjs +1 -1
  136. package/dist/custom_auth/get_account/auth_flow/CustomAuthAccountData.mjs +1 -1
  137. package/dist/custom_auth/get_account/auth_flow/error_type/GetAccountError.mjs +1 -1
  138. package/dist/custom_auth/get_account/auth_flow/result/GetAccessTokenResult.mjs +1 -1
  139. package/dist/custom_auth/get_account/auth_flow/result/GetAccountResult.mjs +1 -1
  140. package/dist/custom_auth/get_account/auth_flow/result/SignOutResult.mjs +1 -1
  141. package/dist/custom_auth/get_account/auth_flow/state/GetAccessTokenState.mjs +1 -1
  142. package/dist/custom_auth/get_account/auth_flow/state/GetAccountState.mjs +1 -1
  143. package/dist/custom_auth/get_account/auth_flow/state/SignOutState.mjs +1 -1
  144. package/dist/custom_auth/get_account/interaction_client/CustomAuthSilentCacheClient.mjs +1 -1
  145. package/dist/custom_auth/index.mjs +4 -3
  146. package/dist/custom_auth/index.mjs.map +1 -1
  147. package/dist/custom_auth/operating_context/CustomAuthOperatingContext.mjs +1 -1
  148. package/dist/custom_auth/reset_password/auth_flow/error_type/ResetPasswordError.mjs +1 -1
  149. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordResendCodeResult.mjs +1 -1
  150. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordStartResult.mjs +1 -1
  151. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordSubmitCodeResult.mjs +1 -1
  152. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordSubmitPasswordResult.mjs +1 -1
  153. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordCodeRequiredState.mjs +1 -1
  154. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordCompletedState.mjs +1 -1
  155. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordFailedState.mjs +1 -1
  156. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordPasswordRequiredState.mjs +1 -1
  157. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordState.mjs +1 -1
  158. package/dist/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.mjs +23 -7
  159. package/dist/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.mjs.map +1 -1
  160. package/dist/custom_auth/reset_password/auth_flow/v2/state/ResetPasswordStateTransitionHandlerV2.mjs +24 -0
  161. package/dist/custom_auth/reset_password/auth_flow/v2/state/ResetPasswordStateTransitionHandlerV2.mjs.map +1 -0
  162. package/dist/custom_auth/reset_password/interaction_client/ResetPasswordClient.mjs +1 -1
  163. package/dist/custom_auth/sign_in/auth_flow/SignInScenario.mjs +1 -1
  164. package/dist/custom_auth/sign_in/auth_flow/error_type/SignInError.mjs +1 -1
  165. package/dist/custom_auth/sign_in/auth_flow/result/SignInResendCodeResult.mjs +1 -1
  166. package/dist/custom_auth/sign_in/auth_flow/result/SignInResult.mjs +1 -1
  167. package/dist/custom_auth/sign_in/auth_flow/result/SignInSubmitCodeResult.mjs +1 -1
  168. package/dist/custom_auth/sign_in/auth_flow/result/SignInSubmitPasswordResult.mjs +1 -1
  169. package/dist/custom_auth/sign_in/auth_flow/state/SignInCodeRequiredState.mjs +1 -1
  170. package/dist/custom_auth/sign_in/auth_flow/state/SignInCompletedState.mjs +1 -1
  171. package/dist/custom_auth/sign_in/auth_flow/state/SignInContinuationState.mjs +1 -1
  172. package/dist/custom_auth/sign_in/auth_flow/state/SignInFailedState.mjs +1 -1
  173. package/dist/custom_auth/sign_in/auth_flow/state/SignInPasswordRequiredState.mjs +1 -1
  174. package/dist/custom_auth/sign_in/auth_flow/state/SignInState.mjs +1 -1
  175. package/dist/custom_auth/sign_in/auth_flow/v2/state/SignInContinuationStateV2.mjs +4 -7
  176. package/dist/custom_auth/sign_in/auth_flow/v2/state/SignInContinuationStateV2.mjs.map +1 -1
  177. package/dist/custom_auth/sign_in/auth_flow/v2/state/SignInStateTransitionHandlerV2.mjs +2 -2
  178. package/dist/custom_auth/sign_in/auth_flow/v2/state/SignInStateTransitionHandlerV2.mjs.map +1 -1
  179. package/dist/custom_auth/sign_in/interaction_client/SignInClient.mjs +1 -1
  180. package/dist/custom_auth/sign_in/interaction_client/result/SignInActionResult.mjs +1 -1
  181. package/dist/custom_auth/sign_up/auth_flow/error_type/SignUpError.mjs +1 -1
  182. package/dist/custom_auth/sign_up/auth_flow/result/SignUpResendCodeResult.mjs +1 -1
  183. package/dist/custom_auth/sign_up/auth_flow/result/SignUpResult.mjs +1 -1
  184. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitAttributesResult.mjs +1 -1
  185. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitCodeResult.mjs +1 -1
  186. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitPasswordResult.mjs +1 -1
  187. package/dist/custom_auth/sign_up/auth_flow/state/SignUpAttributesRequiredState.mjs +1 -1
  188. package/dist/custom_auth/sign_up/auth_flow/state/SignUpCodeRequiredState.mjs +1 -1
  189. package/dist/custom_auth/sign_up/auth_flow/state/SignUpCompletedState.mjs +1 -1
  190. package/dist/custom_auth/sign_up/auth_flow/state/SignUpFailedState.mjs +1 -1
  191. package/dist/custom_auth/sign_up/auth_flow/state/SignUpPasswordRequiredState.mjs +1 -1
  192. package/dist/custom_auth/sign_up/auth_flow/state/SignUpState.mjs +1 -1
  193. package/dist/custom_auth/sign_up/auth_flow/v2/state/AttributesRequiredStateV2.mjs +17 -8
  194. package/dist/custom_auth/sign_up/auth_flow/v2/state/AttributesRequiredStateV2.mjs.map +1 -1
  195. package/dist/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountCodeRequiredStateV2.mjs +78 -0
  196. package/dist/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountCodeRequiredStateV2.mjs.map +1 -0
  197. package/dist/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountPasswordRequiredStateV2.mjs +48 -0
  198. package/dist/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountPasswordRequiredStateV2.mjs.map +1 -0
  199. package/dist/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountStateTransitionHelperV2.mjs +49 -0
  200. package/dist/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountStateTransitionHelperV2.mjs.map +1 -0
  201. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpStateTransitionHandlerV2.mjs +17 -24
  202. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpStateTransitionHandlerV2.mjs.map +1 -1
  203. package/dist/custom_auth/sign_up/interaction_client/SignUpClient.mjs +1 -1
  204. package/dist/custom_auth/sign_up/interaction_client/result/SignUpActionResult.mjs +1 -1
  205. package/dist/encode/Base64Decode.mjs +1 -1
  206. package/dist/encode/Base64Encode.mjs +1 -1
  207. package/dist/error/BrowserAuthError.mjs +1 -1
  208. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  209. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  210. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  211. package/dist/error/NativeAuthError.mjs +1 -1
  212. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  213. package/dist/error/NestedAppAuthError.mjs +1 -1
  214. package/dist/event/EventHandler.mjs +1 -1
  215. package/dist/event/EventMessage.mjs +1 -1
  216. package/dist/event/EventType.mjs +1 -1
  217. package/dist/index.mjs +1 -1
  218. package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
  219. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  220. package/dist/interaction_client/PlatformAuthInteractionClient.mjs +38 -31
  221. package/dist/interaction_client/PlatformAuthInteractionClient.mjs.map +1 -1
  222. package/dist/interaction_client/PopupClient.mjs +1 -1
  223. package/dist/interaction_client/RedirectClient.mjs +6 -2
  224. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  225. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  226. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  227. package/dist/interaction_client/SilentIframeClient.mjs +1 -1
  228. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  229. package/dist/interaction_client/StandardInteractionClient.mjs +5 -1
  230. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  231. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  232. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  233. package/dist/log-strings-mapping.json +21 -9
  234. package/dist/naa/BridgeError.mjs +1 -1
  235. package/dist/naa/BridgeProxy.mjs +1 -1
  236. package/dist/naa/BridgeStatusCode.mjs +1 -1
  237. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  238. package/dist/navigation/NavigationClient.mjs +1 -1
  239. package/dist/network/FetchClient.mjs +1 -1
  240. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  241. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  242. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  243. package/dist/packageMetadata.mjs +2 -2
  244. package/dist/popup_relay/constants.mjs +1 -1
  245. package/dist/popup_relay/index.mjs +1 -1
  246. package/dist/popup_relay/relayClient.mjs +1 -1
  247. package/dist/protocol/Authorize.mjs +1 -1
  248. package/dist/redirect_bridge/index.mjs +1 -1
  249. package/dist/request/RequestHelpers.mjs +1 -1
  250. package/dist/request/SilentRequestHelpers.mjs +1 -1
  251. package/dist/response/ResponseHandler.mjs +1 -1
  252. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  253. package/dist/telemetry/BrowserPerformanceEvents.mjs +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 +1 -1
  260. package/dist/utils/Helpers.mjs +1 -1
  261. package/dist/utils/IframeMonitor.mjs +1 -1
  262. package/dist/utils/MsalFrameStatsUtils.mjs +1 -1
  263. package/dist/utils/PopupMonitor.mjs +1 -1
  264. package/dist/utils/PopupOriginCheck.mjs +1 -1
  265. package/dist/webBrokerBridge/PendingRequestRegistry.mjs +1 -1
  266. package/dist/webBrokerBridge/PerfEventNames.mjs +1 -1
  267. package/dist/webBrokerBridge/WebBrokerBridgeError.mjs +1 -1
  268. package/dist/webBrokerBridge/WebBrokerBridgeErrorMap.mjs +1 -1
  269. package/dist/webBrokerBridge/adapter/CrossVersionRequestAdapter.mjs +1 -1
  270. package/dist/webBrokerBridge/index.mjs +1 -1
  271. package/lib/custom-auth-path/log-strings-mapping.json +21 -9
  272. package/lib/custom-auth-path/msal-custom-auth.cjs +1160 -765
  273. package/lib/custom-auth-path/msal-custom-auth.cjs.map +1 -1
  274. package/lib/custom-auth-path/msal-custom-auth.js +1160 -765
  275. package/lib/custom-auth-path/msal-custom-auth.js.map +1 -1
  276. package/lib/log-strings-mapping.json +7 -3
  277. package/lib/msal-browser.cjs +187 -117
  278. package/lib/msal-browser.cjs.map +1 -1
  279. package/lib/msal-browser.js +187 -117
  280. package/lib/msal-browser.js.map +1 -1
  281. package/lib/msal-browser.min.js +2 -2
  282. package/lib/popup-relay/msal-popup-relay.cjs +2 -2
  283. package/lib/popup-relay/msal-popup-relay.cjs.map +1 -1
  284. package/lib/popup-relay/msal-popup-relay.js +2 -2
  285. package/lib/popup-relay/msal-popup-relay.js.map +1 -1
  286. package/lib/popup-relay/msal-popup-relay.min.js +1 -1
  287. package/lib/redirect-bridge/msal-redirect-bridge.cjs +39 -10
  288. package/lib/redirect-bridge/msal-redirect-bridge.cjs.map +1 -1
  289. package/lib/redirect-bridge/msal-redirect-bridge.js +39 -10
  290. package/lib/redirect-bridge/msal-redirect-bridge.js.map +1 -1
  291. package/lib/redirect-bridge/msal-redirect-bridge.min.js +2 -2
  292. package/lib/web-broker-bridge/msal-web-broker-bridge.cjs +1 -1
  293. package/package.json +2 -2
  294. package/src/custom_auth/CustomAuthActionInputs.ts +12 -5
  295. package/src/custom_auth/CustomAuthPublicClientApplication.ts +5 -3
  296. package/src/custom_auth/ICustomAuthPublicClientApplicationV2.ts +5 -3
  297. package/src/custom_auth/controller/CustomAuthStandardController.ts +79 -110
  298. package/src/custom_auth/core/auth_flow/v2/AuthenticationMethodRegistrationV2.ts +1 -2
  299. package/src/custom_auth/core/auth_flow/v2/AuthenticationMethodV2.ts +1 -4
  300. package/src/custom_auth/core/auth_flow/v2/CustomAuthFlowScenarioV2.ts +5 -4
  301. package/src/custom_auth/core/auth_flow/v2/CustomAuthResultV2.ts +28 -16
  302. package/src/custom_auth/core/auth_flow/v2/error/AuthFlowErrorSubcodesV2.ts +6 -0
  303. package/src/custom_auth/core/auth_flow/v2/error/AuthFlowErrorV2.ts +83 -72
  304. package/src/custom_auth/core/auth_flow/v2/result/AuthMethodRegistrationChallengeResultV2.ts +3 -3
  305. package/src/custom_auth/core/auth_flow/v2/result/AuthMethodVerificationSubmitChallengeResultV2.ts +7 -5
  306. package/src/custom_auth/core/auth_flow/v2/result/MFASubmitChallengeResultV2.ts +10 -6
  307. package/src/custom_auth/core/auth_flow/v2/result/RequestChallengeResultV2.ts +9 -6
  308. package/src/custom_auth/core/auth_flow/v2/result/ResetPasswordStartResultV2.ts +4 -6
  309. package/src/custom_auth/core/auth_flow/v2/result/SubmitPasswordResultV2.ts +36 -0
  310. package/src/custom_auth/core/auth_flow/v2/result/VerifyChallengeResultV2.ts +6 -8
  311. package/src/custom_auth/core/auth_flow/v2/state/AuthMethodRegistrationRequiredStateV2.ts +2 -2
  312. package/src/custom_auth/core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.ts +61 -12
  313. package/src/custom_auth/core/auth_flow/v2/state/AuthMethodVerificationRequiredStateV2.ts +21 -3
  314. package/src/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.ts +30 -24
  315. package/src/custom_auth/core/auth_flow/v2/state/CompletedStateV2.ts +1 -3
  316. package/src/custom_auth/core/auth_flow/v2/state/CustomAuthStateParametersV2.ts +11 -2
  317. package/src/custom_auth/core/auth_flow/v2/state/FailedStateV2.ts +1 -2
  318. package/src/custom_auth/core/auth_flow/v2/state/MFAVerificationRequiredStateV2.ts +26 -7
  319. package/src/custom_auth/core/auth_flow/v2/state/PasswordRequiredStateV2.ts +179 -0
  320. package/src/custom_auth/core/error/InvalidArgumentError.ts +1 -1
  321. package/src/custom_auth/core/interaction_client/v2/FlowContinuationStateV2.ts +12 -12
  322. package/src/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.ts +394 -238
  323. package/src/custom_auth/core/interaction_client/v2/InteractionClientBaseV2.ts +2 -6
  324. package/src/custom_auth/core/interaction_client/v2/parameter/FlowParamsV2.ts +2 -15
  325. package/src/custom_auth/core/interaction_client/v2/result/FlowActionResultV2.ts +63 -26
  326. package/src/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.ts +0 -6
  327. package/src/custom_auth/core/network_client/custom_auth_api/v2/CustomAuthApiClientV2.ts +74 -26
  328. package/src/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.ts +48 -9
  329. package/src/custom_auth/core/network_client/custom_auth_api/v2/request/RequestsV2.ts +4 -6
  330. package/src/custom_auth/core/network_client/custom_auth_api/v2/response/ErrorResponsesV2.ts +0 -6
  331. package/src/custom_auth/core/network_client/custom_auth_api/v2/response/ResponsesV2.ts +14 -53
  332. package/src/custom_auth/core/network_client/custom_auth_api/v2/result/BaseResultsV2.ts +0 -18
  333. package/src/custom_auth/core/network_client/custom_auth_api/v2/result/ResetPasswordResultsV2.ts +32 -13
  334. package/src/custom_auth/core/network_client/custom_auth_api/v2/result/SignUpResultsV2.ts +8 -9
  335. package/src/custom_auth/core/telemetry/FlowApiIdHelperV2.ts +4 -5
  336. package/src/custom_auth/core/telemetry/PublicApiId.ts +1 -0
  337. package/src/custom_auth/core/utils/ArgumentValidator.ts +26 -0
  338. package/src/custom_auth/index.ts +10 -11
  339. package/src/custom_auth/reset_password/auth_flow/v2/result/SubmitNewPasswordResultV2.ts +6 -7
  340. package/src/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.ts +28 -5
  341. package/src/custom_auth/reset_password/auth_flow/v2/state/ResetPasswordStateTransitionHandlerV2.ts +30 -0
  342. package/src/custom_auth/sign_in/auth_flow/v2/result/SignInContinuationResultV2.ts +4 -8
  343. package/src/custom_auth/sign_in/auth_flow/v2/result/SignInStartResultV2.ts +4 -7
  344. package/src/custom_auth/sign_in/auth_flow/v2/state/SignInContinuationStateV2.ts +3 -6
  345. package/src/custom_auth/sign_in/auth_flow/v2/state/SignInStateParametersV2.ts +0 -3
  346. package/src/custom_auth/sign_in/auth_flow/v2/state/SignInStateTransitionHandlerV2.ts +2 -3
  347. package/src/custom_auth/sign_up/auth_flow/v2/result/ExistingAccountActionResultsV2.ts +49 -0
  348. package/src/custom_auth/sign_up/auth_flow/v2/result/SignUpStartResultV2.ts +8 -4
  349. package/src/custom_auth/sign_up/auth_flow/v2/result/SubmitAttributesResultV2.ts +16 -4
  350. package/src/custom_auth/sign_up/auth_flow/v2/state/AttributesRequiredStateV2.ts +26 -5
  351. package/src/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountCodeRequiredStateV2.ts +101 -0
  352. package/src/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountPasswordRequiredStateV2.ts +53 -0
  353. package/src/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountStateTransitionHelperV2.ts +97 -0
  354. package/src/custom_auth/sign_up/auth_flow/v2/state/SignUpStateParametersV2.ts +0 -6
  355. package/src/custom_auth/sign_up/auth_flow/v2/state/SignUpStateTransitionHandlerV2.ts +25 -48
  356. package/src/interaction_client/PlatformAuthInteractionClient.ts +53 -38
  357. package/src/interaction_client/RedirectClient.ts +5 -1
  358. package/src/interaction_client/StandardInteractionClient.ts +4 -0
  359. package/src/packageMetadata.ts +1 -1
  360. package/types/custom_auth/CustomAuthActionInputs.d.ts +12 -5
  361. package/types/custom_auth/CustomAuthActionInputs.d.ts.map +1 -1
  362. package/types/custom_auth/CustomAuthConstants.d.ts +1 -1
  363. package/types/custom_auth/CustomAuthPublicClientApplication.d.ts +5 -3
  364. package/types/custom_auth/CustomAuthPublicClientApplication.d.ts.map +1 -1
  365. package/types/custom_auth/ICustomAuthPublicClientApplicationV2.d.ts +5 -3
  366. package/types/custom_auth/ICustomAuthPublicClientApplicationV2.d.ts.map +1 -1
  367. package/types/custom_auth/controller/CustomAuthStandardController.d.ts +2 -0
  368. package/types/custom_auth/controller/CustomAuthStandardController.d.ts.map +1 -1
  369. package/types/custom_auth/core/auth_flow/v2/AuthenticationMethodRegistrationV2.d.ts +1 -2
  370. package/types/custom_auth/core/auth_flow/v2/AuthenticationMethodRegistrationV2.d.ts.map +1 -1
  371. package/types/custom_auth/core/auth_flow/v2/AuthenticationMethodV2.d.ts +1 -4
  372. package/types/custom_auth/core/auth_flow/v2/AuthenticationMethodV2.d.ts.map +1 -1
  373. package/types/custom_auth/core/auth_flow/v2/CustomAuthFlowScenarioV2.d.ts +5 -4
  374. package/types/custom_auth/core/auth_flow/v2/CustomAuthFlowScenarioV2.d.ts.map +1 -1
  375. package/types/custom_auth/core/auth_flow/v2/CustomAuthResultV2.d.ts +17 -8
  376. package/types/custom_auth/core/auth_flow/v2/CustomAuthResultV2.d.ts.map +1 -1
  377. package/types/custom_auth/core/auth_flow/v2/error/AuthFlowErrorSubcodesV2.d.ts +6 -0
  378. package/types/custom_auth/core/auth_flow/v2/error/AuthFlowErrorSubcodesV2.d.ts.map +1 -1
  379. package/types/custom_auth/core/auth_flow/v2/error/AuthFlowErrorV2.d.ts +23 -44
  380. package/types/custom_auth/core/auth_flow/v2/error/AuthFlowErrorV2.d.ts.map +1 -1
  381. package/types/custom_auth/core/auth_flow/v2/result/AuthMethodRegistrationChallengeResultV2.d.ts +3 -3
  382. package/types/custom_auth/core/auth_flow/v2/result/AuthMethodVerificationSubmitChallengeResultV2.d.ts +7 -6
  383. package/types/custom_auth/core/auth_flow/v2/result/AuthMethodVerificationSubmitChallengeResultV2.d.ts.map +1 -1
  384. package/types/custom_auth/core/auth_flow/v2/result/MFASubmitChallengeResultV2.d.ts +7 -6
  385. package/types/custom_auth/core/auth_flow/v2/result/MFASubmitChallengeResultV2.d.ts.map +1 -1
  386. package/types/custom_auth/core/auth_flow/v2/result/RequestChallengeResultV2.d.ts +8 -7
  387. package/types/custom_auth/core/auth_flow/v2/result/RequestChallengeResultV2.d.ts.map +1 -1
  388. package/types/custom_auth/core/auth_flow/v2/result/ResetPasswordStartResultV2.d.ts +4 -6
  389. package/types/custom_auth/core/auth_flow/v2/result/ResetPasswordStartResultV2.d.ts.map +1 -1
  390. package/types/custom_auth/core/auth_flow/v2/result/SubmitPasswordResultV2.d.ts +20 -0
  391. package/types/custom_auth/core/auth_flow/v2/result/SubmitPasswordResultV2.d.ts.map +1 -0
  392. package/types/custom_auth/core/auth_flow/v2/result/VerifyChallengeResultV2.d.ts +6 -8
  393. package/types/custom_auth/core/auth_flow/v2/result/VerifyChallengeResultV2.d.ts.map +1 -1
  394. package/types/custom_auth/core/auth_flow/v2/state/AuthMethodRegistrationRequiredStateV2.d.ts +2 -2
  395. package/types/custom_auth/core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.d.ts +3 -6
  396. package/types/custom_auth/core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.d.ts.map +1 -1
  397. package/types/custom_auth/core/auth_flow/v2/state/AuthMethodVerificationRequiredStateV2.d.ts +3 -3
  398. package/types/custom_auth/core/auth_flow/v2/state/AuthMethodVerificationRequiredStateV2.d.ts.map +1 -1
  399. package/types/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.d.ts +6 -8
  400. package/types/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.d.ts.map +1 -1
  401. package/types/custom_auth/core/auth_flow/v2/state/CompletedStateV2.d.ts +1 -3
  402. package/types/custom_auth/core/auth_flow/v2/state/CompletedStateV2.d.ts.map +1 -1
  403. package/types/custom_auth/core/auth_flow/v2/state/CustomAuthStateParametersV2.d.ts +9 -2
  404. package/types/custom_auth/core/auth_flow/v2/state/CustomAuthStateParametersV2.d.ts.map +1 -1
  405. package/types/custom_auth/core/auth_flow/v2/state/FailedStateV2.d.ts +1 -2
  406. package/types/custom_auth/core/auth_flow/v2/state/FailedStateV2.d.ts.map +1 -1
  407. package/types/custom_auth/core/auth_flow/v2/state/MFAVerificationRequiredStateV2.d.ts +5 -6
  408. package/types/custom_auth/core/auth_flow/v2/state/MFAVerificationRequiredStateV2.d.ts.map +1 -1
  409. package/types/custom_auth/core/auth_flow/v2/state/PasswordRequiredStateV2.d.ts +23 -0
  410. package/types/custom_auth/core/auth_flow/v2/state/PasswordRequiredStateV2.d.ts.map +1 -0
  411. package/types/custom_auth/core/error/InvalidArgumentError.d.ts +1 -0
  412. package/types/custom_auth/core/error/InvalidArgumentError.d.ts.map +1 -1
  413. package/types/custom_auth/core/interaction_client/v2/FlowContinuationStateV2.d.ts +8 -1
  414. package/types/custom_auth/core/interaction_client/v2/FlowContinuationStateV2.d.ts.map +1 -1
  415. package/types/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.d.ts +12 -10
  416. package/types/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.d.ts.map +1 -1
  417. package/types/custom_auth/core/interaction_client/v2/InteractionClientBaseV2.d.ts +1 -1
  418. package/types/custom_auth/core/interaction_client/v2/InteractionClientBaseV2.d.ts.map +1 -1
  419. package/types/custom_auth/core/interaction_client/v2/parameter/FlowParamsV2.d.ts +2 -5
  420. package/types/custom_auth/core/interaction_client/v2/parameter/FlowParamsV2.d.ts.map +1 -1
  421. package/types/custom_auth/core/interaction_client/v2/result/FlowActionResultV2.d.ts +22 -3
  422. package/types/custom_auth/core/interaction_client/v2/result/FlowActionResultV2.d.ts.map +1 -1
  423. package/types/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.d.ts.map +1 -1
  424. package/types/custom_auth/core/network_client/custom_auth_api/v2/CustomAuthApiClientV2.d.ts.map +1 -1
  425. package/types/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.d.ts +2 -1
  426. package/types/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.d.ts.map +1 -1
  427. package/types/custom_auth/core/network_client/custom_auth_api/v2/request/RequestsV2.d.ts +1 -1
  428. package/types/custom_auth/core/network_client/custom_auth_api/v2/request/RequestsV2.d.ts.map +1 -1
  429. package/types/custom_auth/core/network_client/custom_auth_api/v2/response/ErrorResponsesV2.d.ts.map +1 -1
  430. package/types/custom_auth/core/network_client/custom_auth_api/v2/response/ResponsesV2.d.ts +8 -8
  431. package/types/custom_auth/core/network_client/custom_auth_api/v2/response/ResponsesV2.d.ts.map +1 -1
  432. package/types/custom_auth/core/network_client/custom_auth_api/v2/result/BaseResultsV2.d.ts.map +1 -1
  433. package/types/custom_auth/core/network_client/custom_auth_api/v2/result/ResetPasswordResultsV2.d.ts +18 -6
  434. package/types/custom_auth/core/network_client/custom_auth_api/v2/result/ResetPasswordResultsV2.d.ts.map +1 -1
  435. package/types/custom_auth/core/network_client/custom_auth_api/v2/result/SignUpResultsV2.d.ts +6 -10
  436. package/types/custom_auth/core/network_client/custom_auth_api/v2/result/SignUpResultsV2.d.ts.map +1 -1
  437. package/types/custom_auth/core/telemetry/FlowApiIdHelperV2.d.ts +0 -4
  438. package/types/custom_auth/core/telemetry/FlowApiIdHelperV2.d.ts.map +1 -1
  439. package/types/custom_auth/core/telemetry/PublicApiId.d.ts +1 -0
  440. package/types/custom_auth/core/telemetry/PublicApiId.d.ts.map +1 -1
  441. package/types/custom_auth/core/utils/ArgumentValidator.d.ts +3 -0
  442. package/types/custom_auth/core/utils/ArgumentValidator.d.ts.map +1 -1
  443. package/types/custom_auth/index.d.ts +5 -5
  444. package/types/custom_auth/index.d.ts.map +1 -1
  445. package/types/custom_auth/reset_password/auth_flow/v2/result/SubmitNewPasswordResultV2.d.ts +6 -8
  446. package/types/custom_auth/reset_password/auth_flow/v2/result/SubmitNewPasswordResultV2.d.ts.map +1 -1
  447. package/types/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.d.ts +7 -5
  448. package/types/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.d.ts.map +1 -1
  449. package/types/custom_auth/reset_password/auth_flow/v2/state/ResetPasswordStateTransitionHandlerV2.d.ts +7 -0
  450. package/types/custom_auth/reset_password/auth_flow/v2/state/ResetPasswordStateTransitionHandlerV2.d.ts.map +1 -0
  451. package/types/custom_auth/sign_in/auth_flow/v2/result/SignInContinuationResultV2.d.ts +4 -8
  452. package/types/custom_auth/sign_in/auth_flow/v2/result/SignInContinuationResultV2.d.ts.map +1 -1
  453. package/types/custom_auth/sign_in/auth_flow/v2/result/SignInStartResultV2.d.ts +5 -6
  454. package/types/custom_auth/sign_in/auth_flow/v2/result/SignInStartResultV2.d.ts.map +1 -1
  455. package/types/custom_auth/sign_in/auth_flow/v2/state/SignInContinuationStateV2.d.ts +3 -6
  456. package/types/custom_auth/sign_in/auth_flow/v2/state/SignInContinuationStateV2.d.ts.map +1 -1
  457. package/types/custom_auth/sign_in/auth_flow/v2/state/SignInStateParametersV2.d.ts +0 -1
  458. package/types/custom_auth/sign_in/auth_flow/v2/state/SignInStateParametersV2.d.ts.map +1 -1
  459. package/types/custom_auth/sign_in/auth_flow/v2/state/SignInStateTransitionHandlerV2.d.ts +3 -2
  460. package/types/custom_auth/sign_in/auth_flow/v2/state/SignInStateTransitionHandlerV2.d.ts.map +1 -1
  461. package/types/custom_auth/sign_up/auth_flow/v2/result/ExistingAccountActionResultsV2.d.ts +27 -0
  462. package/types/custom_auth/sign_up/auth_flow/v2/result/ExistingAccountActionResultsV2.d.ts.map +1 -0
  463. package/types/custom_auth/sign_up/auth_flow/v2/result/SignUpStartResultV2.d.ts +6 -3
  464. package/types/custom_auth/sign_up/auth_flow/v2/result/SignUpStartResultV2.d.ts.map +1 -1
  465. package/types/custom_auth/sign_up/auth_flow/v2/result/SubmitAttributesResultV2.d.ts +12 -3
  466. package/types/custom_auth/sign_up/auth_flow/v2/result/SubmitAttributesResultV2.d.ts.map +1 -1
  467. package/types/custom_auth/sign_up/auth_flow/v2/state/AttributesRequiredStateV2.d.ts +8 -3
  468. package/types/custom_auth/sign_up/auth_flow/v2/state/AttributesRequiredStateV2.d.ts.map +1 -1
  469. package/types/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountCodeRequiredStateV2.d.ts +24 -0
  470. package/types/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountCodeRequiredStateV2.d.ts.map +1 -0
  471. package/types/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountPasswordRequiredStateV2.d.ts +18 -0
  472. package/types/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountPasswordRequiredStateV2.d.ts.map +1 -0
  473. package/types/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountStateTransitionHelperV2.d.ts +7 -0
  474. package/types/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountStateTransitionHelperV2.d.ts.map +1 -0
  475. package/types/custom_auth/sign_up/auth_flow/v2/state/SignUpStateParametersV2.d.ts +0 -4
  476. package/types/custom_auth/sign_up/auth_flow/v2/state/SignUpStateParametersV2.d.ts.map +1 -1
  477. package/types/custom_auth/sign_up/auth_flow/v2/state/SignUpStateTransitionHandlerV2.d.ts +5 -4
  478. package/types/custom_auth/sign_up/auth_flow/v2/state/SignUpStateTransitionHandlerV2.d.ts.map +1 -1
  479. package/types/interaction_client/PlatformAuthInteractionClient.d.ts +4 -3
  480. package/types/interaction_client/PlatformAuthInteractionClient.d.ts.map +1 -1
  481. package/types/interaction_client/RedirectClient.d.ts.map +1 -1
  482. package/types/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  483. package/types/packageMetadata.d.ts +1 -1
  484. package/dist/custom_auth/sign_in/auth_flow/v2/state/PasswordRequiredStateV2.mjs +0 -82
  485. package/dist/custom_auth/sign_in/auth_flow/v2/state/PasswordRequiredStateV2.mjs.map +0 -1
  486. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpAttributesRequiredStateBaseV2.mjs +0 -25
  487. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpAttributesRequiredStateBaseV2.mjs.map +0 -1
  488. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpPasswordRequiredStateV2.mjs +0 -45
  489. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpPasswordRequiredStateV2.mjs.map +0 -1
  490. package/src/custom_auth/core/auth_flow/v2/result/MFAResendChallengeResultV2.ts +0 -23
  491. package/src/custom_auth/core/auth_flow/v2/result/ResendCodeResultV2.ts +0 -19
  492. package/src/custom_auth/sign_in/auth_flow/v2/result/SubmitPasswordResultV2.ts +0 -22
  493. package/src/custom_auth/sign_in/auth_flow/v2/state/PasswordRequiredStateV2.ts +0 -115
  494. package/src/custom_auth/sign_up/auth_flow/v2/state/SignUpAttributesRequiredStateBaseV2.ts +0 -34
  495. package/src/custom_auth/sign_up/auth_flow/v2/state/SignUpPasswordRequiredStateV2.ts +0 -61
  496. package/types/custom_auth/core/auth_flow/v2/result/MFAResendChallengeResultV2.d.ts +0 -14
  497. package/types/custom_auth/core/auth_flow/v2/result/MFAResendChallengeResultV2.d.ts.map +0 -1
  498. package/types/custom_auth/core/auth_flow/v2/result/ResendCodeResultV2.d.ts +0 -13
  499. package/types/custom_auth/core/auth_flow/v2/result/ResendCodeResultV2.d.ts.map +0 -1
  500. package/types/custom_auth/sign_in/auth_flow/v2/result/SubmitPasswordResultV2.d.ts +0 -9
  501. package/types/custom_auth/sign_in/auth_flow/v2/result/SubmitPasswordResultV2.d.ts.map +0 -1
  502. package/types/custom_auth/sign_in/auth_flow/v2/state/PasswordRequiredStateV2.d.ts +0 -17
  503. package/types/custom_auth/sign_in/auth_flow/v2/state/PasswordRequiredStateV2.d.ts.map +0 -1
  504. package/types/custom_auth/sign_up/auth_flow/v2/state/SignUpAttributesRequiredStateBaseV2.d.ts +0 -11
  505. package/types/custom_auth/sign_up/auth_flow/v2/state/SignUpAttributesRequiredStateBaseV2.d.ts.map +0 -1
  506. package/types/custom_auth/sign_up/auth_flow/v2/state/SignUpPasswordRequiredStateV2.d.ts +0 -19
  507. package/types/custom_auth/sign_up/auth_flow/v2/state/SignUpPasswordRequiredStateV2.d.ts.map +0 -1
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-browser v5.28.0 2026-11-05 */
1
+ /*! @azure/msal-browser v5.29.1 2026-11-12 */
2
2
  'use strict';
3
3
  (function (global, factory) {
4
4
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
@@ -6,7 +6,7 @@
6
6
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.msalCustomAuth = {}));
7
7
  })(this, (function (exports) { 'use strict';
8
8
 
9
- /*! @azure/msal-common v16.16.0 2026-11-05 */
9
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
10
10
  /*
11
11
  * Copyright (c) Microsoft Corporation. All rights reserved.
12
12
  * Licensed under the MIT License.
@@ -66,7 +66,7 @@
66
66
  */
67
67
  const POPUP_ORIGIN_CHECK_DONE = "pocd";
68
68
 
69
- /*! @azure/msal-common v16.16.0 2026-11-05 */
69
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
70
70
  /*
71
71
  * Copyright (c) Microsoft Corporation. All rights reserved.
72
72
  * Licensed under the MIT License.
@@ -300,7 +300,7 @@
300
300
  // Token renewal offset default in seconds
301
301
  const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
302
302
 
303
- /*! @azure/msal-common v16.16.0 2026-11-05 */
303
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
304
304
  /*
305
305
  * Copyright (c) Microsoft Corporation. All rights reserved.
306
306
  * Licensed under the MIT License.
@@ -329,7 +329,7 @@
329
329
  return new AuthError(code, correlationId, additionalMessage || getDefaultErrorMessage$1(code));
330
330
  }
331
331
 
332
- /*! @azure/msal-common v16.16.0 2026-11-05 */
332
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
333
333
 
334
334
  /*
335
335
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -352,7 +352,7 @@
352
352
  return new ClientAuthError(errorCode, correlationId, additionalMessage);
353
353
  }
354
354
 
355
- /*! @azure/msal-common v16.16.0 2026-11-05 */
355
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
356
356
  /*
357
357
  * Copyright (c) Microsoft Corporation. All rights reserved.
358
358
  * Licensed under the MIT License.
@@ -390,7 +390,7 @@
390
390
  const resourceParameterRequired = "resource_parameter_required";
391
391
  const misplacedResourceParam = "misplaced_resource_parameter";
392
392
 
393
- /*! @azure/msal-common v16.16.0 2026-11-05 */
393
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
394
394
 
395
395
  /*
396
396
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -428,7 +428,7 @@
428
428
  };
429
429
  }
430
430
 
431
- /*! @azure/msal-common v16.16.0 2026-11-05 */
431
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
432
432
 
433
433
  /*
434
434
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -494,7 +494,7 @@
494
494
  return matches[2];
495
495
  }
496
496
 
497
- /*! @azure/msal-common v16.16.0 2026-11-05 */
497
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
498
498
 
499
499
  /*
500
500
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -582,7 +582,7 @@
582
582
  return updatedAccountInfo;
583
583
  }
584
584
 
585
- /*! @azure/msal-common v16.16.0 2026-11-05 */
585
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
586
586
  /*
587
587
  * Copyright (c) Microsoft Corporation. All rights reserved.
588
588
  * Licensed under the MIT License.
@@ -596,7 +596,7 @@
596
596
  Ciam: 3,
597
597
  };
598
598
 
599
- /*! @azure/msal-common v16.16.0 2026-11-05 */
599
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
600
600
  /*
601
601
  * Copyright (c) Microsoft Corporation. All rights reserved.
602
602
  * Licensed under the MIT License.
@@ -618,7 +618,7 @@
618
618
  return null;
619
619
  }
620
620
 
621
- /*! @azure/msal-common v16.16.0 2026-11-05 */
621
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
622
622
  /*
623
623
  * Copyright (c) Microsoft Corporation. All rights reserved.
624
624
  * Licensed under the MIT License.
@@ -642,7 +642,7 @@
642
642
  EAR: "EAR",
643
643
  };
644
644
 
645
- /*! @azure/msal-common v16.16.0 2026-11-05 */
645
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
646
646
  /**
647
647
  * Returns the AccountInfo interface for this account.
648
648
  * @internal
@@ -831,7 +831,7 @@
831
831
  entity.hasOwnProperty("authorityType"));
832
832
  }
833
833
 
834
- /*! @azure/msal-common v16.16.0 2026-11-05 */
834
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
835
835
  /*
836
836
  * Copyright (c) Microsoft Corporation. All rights reserved.
837
837
  * Licensed under the MIT License.
@@ -841,7 +841,7 @@
841
841
  */
842
842
  const unexpectedError = "unexpected_error";
843
843
 
844
- /*! @azure/msal-common v16.16.0 2026-11-05 */
844
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
845
845
 
846
846
  /*
847
847
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -861,7 +861,7 @@
861
861
  return new ClientConfigurationError(errorCode, correlationId);
862
862
  }
863
863
 
864
- /*! @azure/msal-common v16.16.0 2026-11-05 */
864
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
865
865
  /*
866
866
  * Copyright (c) Microsoft Corporation. All rights reserved.
867
867
  * Licensed under the MIT License.
@@ -901,7 +901,7 @@
901
901
  return headerName === undefined ? undefined : headers[headerName];
902
902
  }
903
903
 
904
- /*! @azure/msal-common v16.16.0 2026-11-05 */
904
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
905
905
  /*
906
906
  * Copyright (c) Microsoft Corporation. All rights reserved.
907
907
  * Licensed under the MIT License.
@@ -932,7 +932,7 @@
932
932
  const invalidDpopNonce = "invalid_dpop_nonce";
933
933
  const dpopMissingResourceContext = "dpop_missing_resource_context";
934
934
 
935
- /*! @azure/msal-common v16.16.0 2026-11-05 */
935
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
936
936
  /*
937
937
  * Copyright (c) Microsoft Corporation. All rights reserved.
938
938
  * Licensed under the MIT License.
@@ -944,7 +944,7 @@
944
944
  response.hasOwnProperty("jwks_uri"));
945
945
  }
946
946
 
947
- /*! @azure/msal-common v16.16.0 2026-11-05 */
947
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
948
948
  /*
949
949
  * Copyright (c) Microsoft Corporation. All rights reserved.
950
950
  * Licensed under the MIT License.
@@ -1024,12 +1024,18 @@
1024
1024
  }
1025
1025
  }
1026
1026
 
1027
- /*! @azure/msal-common v16.16.0 2026-11-05 */
1027
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
1028
1028
 
1029
1029
  /*
1030
1030
  * Copyright (c) Microsoft Corporation. All rights reserved.
1031
1031
  * Licensed under the MIT License.
1032
1032
  */
1033
+ // Matches ASCII controls, space, DEL, backslash, or the userinfo separator (@).
1034
+ const UNSAFE_AUTHORITY = /[\x00-\x20\x7f\\@]/;
1035
+ const DEFAULT_PORTS = {
1036
+ "https:": ":443",
1037
+ "http:": ":80",
1038
+ };
1033
1039
  /**
1034
1040
  * Url object class which can perform various transformations on url strings.
1035
1041
  */
@@ -1145,6 +1151,29 @@
1145
1151
  AbsolutePath: match[5],
1146
1152
  QueryString: match[7],
1147
1153
  };
1154
+ let parsedUrl;
1155
+ try {
1156
+ parsedUrl = new URL(this.urlString);
1157
+ }
1158
+ catch {
1159
+ throw createClientConfigurationError(urlParseError, this.correlationId);
1160
+ }
1161
+ const host = urlComponents.HostNameAndPort?.toLowerCase();
1162
+ const schemeAndAuthority = `${urlComponents.Protocol}//${host}`;
1163
+ const defaultPort = DEFAULT_PORTS[parsedUrl.protocol] ?? "";
1164
+ /*
1165
+ * Cross-check the original host; reparsing parsedUrl would hide parser differences.
1166
+ * URL has validated IPv6 syntax, so only bracketed hosts need a normalization comparison.
1167
+ */
1168
+ const hostMatches = host === parsedUrl.host ||
1169
+ host === `${parsedUrl.host}${defaultPort}` ||
1170
+ (host?.startsWith("[") &&
1171
+ new URL(`${urlComponents.Protocol}//${host}`).host ===
1172
+ parsedUrl.host);
1173
+ // Check authority ambiguity without restricting resource paths, queries, or fragments.
1174
+ if (UNSAFE_AUTHORITY.test(schemeAndAuthority) || !hostMatches) {
1175
+ throw createClientConfigurationError(urlParseError, this.correlationId);
1176
+ }
1148
1177
  let pathSegments = urlComponents.AbsolutePath.split("/");
1149
1178
  pathSegments = pathSegments.filter((val) => val && val.length > 0); // remove empty elements
1150
1179
  urlComponents.PathSegments = pathSegments;
@@ -1182,7 +1211,7 @@
1182
1211
  }
1183
1212
  }
1184
1213
 
1185
- /*! @azure/msal-common v16.16.0 2026-11-05 */
1214
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
1186
1215
 
1187
1216
  /*
1188
1217
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1336,7 +1365,7 @@
1336
1365
  return null;
1337
1366
  }
1338
1367
 
1339
- /*! @azure/msal-common v16.16.0 2026-11-05 */
1368
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
1340
1369
  /*
1341
1370
  * Copyright (c) Microsoft Corporation. All rights reserved.
1342
1371
  * Licensed under the MIT License.
@@ -1345,7 +1374,7 @@
1345
1374
  // AzureCloudInstance is not specified.
1346
1375
  None: "none"};
1347
1376
 
1348
- /*! @azure/msal-common v16.16.0 2026-11-05 */
1377
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
1349
1378
  /*
1350
1379
  * Copyright (c) Microsoft Corporation. All rights reserved.
1351
1380
  * Licensed under the MIT License.
@@ -1355,7 +1384,7 @@
1355
1384
  response.hasOwnProperty("metadata"));
1356
1385
  }
1357
1386
 
1358
- /*! @azure/msal-common v16.16.0 2026-11-05 */
1387
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
1359
1388
  /*
1360
1389
  * Copyright (c) Microsoft Corporation. All rights reserved.
1361
1390
  * Licensed under the MIT License.
@@ -1365,7 +1394,7 @@
1365
1394
  response.hasOwnProperty("error_description"));
1366
1395
  }
1367
1396
 
1368
- /*! @azure/msal-common v16.16.0 2026-11-05 */
1397
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
1369
1398
  /*
1370
1399
  * Copyright (c) Microsoft Corporation. All rights reserved.
1371
1400
  * Licensed under the MIT License.
@@ -1436,7 +1465,7 @@
1436
1465
  const CacheManagerGetRefreshToken = "cacheManagerGetRefreshToken";
1437
1466
  const SetUserData = "setUserData";
1438
1467
 
1439
- /*! @azure/msal-common v16.16.0 2026-11-05 */
1468
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
1440
1469
  /*
1441
1470
  * Copyright (c) Microsoft Corporation. All rights reserved.
1442
1471
  * Licensed under the MIT License.
@@ -1472,7 +1501,8 @@
1472
1501
  catch (e) {
1473
1502
  logger.trace(`0cfd8i ${eventName}`, correlationId);
1474
1503
  try {
1475
- logger.trace(JSON.stringify(e), correlationId);
1504
+ // Prevent numeric error details from being treated as minified log hashes.
1505
+ logger.tracePii(`028ef8 ${JSON.stringify(e)}`, correlationId);
1476
1506
  }
1477
1507
  catch (e) {
1478
1508
  logger.trace("00dty7", correlationId);
@@ -1516,7 +1546,7 @@
1516
1546
  .catch((e) => {
1517
1547
  logger.trace(`0cfd8i ${eventName}`, correlationId);
1518
1548
  try {
1519
- logger.trace(JSON.stringify(e), correlationId);
1549
+ logger.tracePii(`028ef8 ${JSON.stringify(e)}`, correlationId);
1520
1550
  }
1521
1551
  catch (e) {
1522
1552
  logger.trace("00dty7", correlationId);
@@ -1529,12 +1559,26 @@
1529
1559
  };
1530
1560
  };
1531
1561
 
1532
- /*! @azure/msal-common v16.16.0 2026-11-05 */
1562
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
1533
1563
 
1534
1564
  /*
1535
1565
  * Copyright (c) Microsoft Corporation. All rights reserved.
1536
1566
  * Licensed under the MIT License.
1537
1567
  */
1568
+ // Starts with an ASCII letter; remaining characters are ASCII letters, digits, or hyphens.
1569
+ const REGION_NAME_PATTERN = /^[a-z][a-z0-9-]*$/i;
1570
+ // A region becomes a DNS label, limited to 63 octets by RFC 1035 section 2.3.4.
1571
+ const MAX_REGION_NAME_LENGTH = 63;
1572
+ /**
1573
+ * Whether a region can safely be used as a single DNS label.
1574
+ */
1575
+ function isValidRegion(region) {
1576
+ return (typeof region === "string" &&
1577
+ region.length <= MAX_REGION_NAME_LENGTH &&
1578
+ REGION_NAME_PATTERN.test(region) &&
1579
+ // Keep the trailing-hyphen rule explicit rather than complicating the pattern.
1580
+ !region.endsWith("-"));
1581
+ }
1538
1582
  class RegionDiscovery {
1539
1583
  constructor(networkInterface, logger, performanceClient, correlationId) {
1540
1584
  this.networkInterface = networkInterface;
@@ -1594,12 +1638,16 @@
1594
1638
  regionDiscoveryMetadata.region_source =
1595
1639
  RegionDiscoverySources.ENVIRONMENT_VARIABLE;
1596
1640
  }
1597
- // If no region was auto detected from the environment or from the IMDS endpoint, mark the attempt as a FAILED_AUTO_DETECTION
1598
- if (!autodetectedRegionName) {
1641
+ // Untrusted discovery values must be a single DNS label before becoming a host prefix.
1642
+ if (!autodetectedRegionName || !isValidRegion(autodetectedRegionName)) {
1643
+ if (autodetectedRegionName) {
1644
+ this.logger.warning("0n83q0", this.correlationId);
1645
+ }
1599
1646
  regionDiscoveryMetadata.region_source =
1600
1647
  RegionDiscoverySources.FAILED_AUTO_DETECTION;
1648
+ return null;
1601
1649
  }
1602
- return autodetectedRegionName || null;
1650
+ return autodetectedRegionName;
1603
1651
  }
1604
1652
  /**
1605
1653
  * Make the call to the IMDS endpoint
@@ -1640,7 +1688,7 @@
1640
1688
  },
1641
1689
  };
1642
1690
 
1643
- /*! @azure/msal-common v16.16.0 2026-11-05 */
1691
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
1644
1692
  /*
1645
1693
  * Copyright (c) Microsoft Corporation. All rights reserved.
1646
1694
  * Licensed under the MIT License.
@@ -1705,7 +1753,7 @@
1705
1753
  return cachedAtSec > nowSeconds();
1706
1754
  }
1707
1755
 
1708
- /*! @azure/msal-common v16.16.0 2026-11-05 */
1756
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
1709
1757
 
1710
1758
  /*
1711
1759
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1992,7 +2040,7 @@
1992
2040
  return [...attributeTokens].sort().join(" ");
1993
2041
  }
1994
2042
 
1995
- /*! @azure/msal-common v16.16.0 2026-11-05 */
2043
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
1996
2044
 
1997
2045
  /*
1998
2046
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2845,6 +2893,9 @@
2845
2893
  * @param region string
2846
2894
  */
2847
2895
  static buildRegionalAuthorityString(host, region, correlationId, queryString) {
2896
+ if (!isValidRegion(region)) {
2897
+ throw createClientConfigurationError(urlParseError, correlationId);
2898
+ }
2848
2899
  // Create and validate a Url string object with the initial authority string
2849
2900
  const authorityUrlInstance = new UrlString(host, correlationId);
2850
2901
  authorityUrlInstance.validateAsUri();
@@ -2855,7 +2906,7 @@
2855
2906
  }
2856
2907
  // Include the query string portion of the url
2857
2908
  const url = UrlString.constructAuthorityUriFromObject({
2858
- ...authorityUrlInstance.getUrlComponents(),
2909
+ ...authorityUrlParts,
2859
2910
  HostNameAndPort: hostNameAndPort,
2860
2911
  }, correlationId).urlString;
2861
2912
  // Add the query string if a query string was provided
@@ -2960,7 +3011,7 @@
2960
3011
  };
2961
3012
  }
2962
3013
 
2963
- /*! @azure/msal-common v16.16.0 2026-11-05 */
3014
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
2964
3015
 
2965
3016
  /*
2966
3017
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2994,7 +3045,7 @@
2994
3045
  }
2995
3046
  }
2996
3047
 
2997
- /*! @azure/msal-common v16.16.0 2026-11-05 */
3048
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
2998
3049
 
2999
3050
  /*
3000
3051
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3190,7 +3241,7 @@
3190
3241
  }
3191
3242
  }
3192
3243
 
3193
- /*! @azure/msal-common v16.16.0 2026-11-05 */
3244
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
3194
3245
 
3195
3246
  /*
3196
3247
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3690,7 +3741,7 @@
3690
3741
  }
3691
3742
  }
3692
3743
 
3693
- /*! @azure/msal-common v16.16.0 2026-11-05 */
3744
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
3694
3745
 
3695
3746
  /*
3696
3747
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3821,7 +3872,7 @@
3821
3872
  }
3822
3873
  }
3823
3874
 
3824
- /*! @azure/msal-common v16.16.0 2026-11-05 */
3875
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
3825
3876
 
3826
3877
  /*
3827
3878
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3869,7 +3920,7 @@
3869
3920
  },
3870
3921
  };
3871
3922
 
3872
- /*! @azure/msal-common v16.16.0 2026-11-05 */
3923
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
3873
3924
 
3874
3925
  /*
3875
3926
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3892,7 +3943,7 @@
3892
3943
  },
3893
3944
  };
3894
3945
 
3895
- /*! @azure/msal-common v16.16.0 2026-11-05 */
3946
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
3896
3947
  /*
3897
3948
  * Copyright (c) Microsoft Corporation. All rights reserved.
3898
3949
  * Licensed under the MIT License.
@@ -4167,12 +4218,12 @@
4167
4218
  }
4168
4219
  }
4169
4220
 
4170
- /*! @azure/msal-common v16.16.0 2026-11-05 */
4221
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
4171
4222
  /* eslint-disable header/header */
4172
4223
  const name$1 = "@azure/msal-common";
4173
- const version$1 = "16.16.0";
4224
+ const version$1 = "16.16.2";
4174
4225
 
4175
- /*! @azure/msal-common v16.16.0 2026-11-05 */
4226
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
4176
4227
  /*
4177
4228
  * Copyright (c) Microsoft Corporation. All rights reserved.
4178
4229
  * Licensed under the MIT License.
@@ -4180,7 +4231,7 @@
4180
4231
  const cacheQuotaExceeded = "cache_quota_exceeded";
4181
4232
  const cacheErrorUnknown = "cache_error_unknown";
4182
4233
 
4183
- /*! @azure/msal-common v16.16.0 2026-11-05 */
4234
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
4184
4235
 
4185
4236
  /*
4186
4237
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4218,7 +4269,7 @@
4218
4269
  }
4219
4270
  }
4220
4271
 
4221
- /*! @azure/msal-common v16.16.0 2026-11-05 */
4272
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
4222
4273
 
4223
4274
  /*
4224
4275
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4682,19 +4733,25 @@
4682
4733
  * @param account
4683
4734
  */
4684
4735
  removeAccount(account, correlationId) {
4685
- this.removeAccountContext(account, correlationId);
4686
4736
  const accountKeys = this.getAccountKeys();
4687
4737
  const keyFilter = (key) => {
4688
4738
  return (key.includes(account.homeAccountId) &&
4689
4739
  key.includes(account.environment));
4690
4740
  };
4741
+ this.getTokenKeys()
4742
+ .idToken.filter(keyFilter)
4743
+ .forEach((key) => {
4744
+ this.removeIdToken(key, correlationId);
4745
+ });
4746
+ this.removeAccountContext(account, correlationId);
4691
4747
  accountKeys.filter(keyFilter).forEach((key) => {
4692
4748
  this.removeItem(key, correlationId);
4693
4749
  this.performanceClient.incrementFields({ accountsRemoved: 1 }, correlationId);
4694
4750
  });
4695
4751
  }
4696
4752
  /**
4697
- * Removes credentials associated with the provided account
4753
+ * Removes access and refresh tokens associated with the provided account,
4754
+ * preserving the account and its ID tokens.
4698
4755
  * @param account
4699
4756
  */
4700
4757
  removeAccountContext(account, correlationId) {
@@ -4703,9 +4760,6 @@
4703
4760
  return (key.includes(account.homeAccountId) &&
4704
4761
  key.includes(account.environment));
4705
4762
  };
4706
- allTokenKeys.idToken.filter(keyFilter).forEach((key) => {
4707
- this.removeIdToken(key, correlationId);
4708
- });
4709
4763
  allTokenKeys.accessToken.filter(keyFilter).forEach((key) => {
4710
4764
  this.removeAccessToken(key, correlationId);
4711
4765
  });
@@ -5442,7 +5496,7 @@
5442
5496
  }
5443
5497
  }
5444
5498
 
5445
- /*! @azure/msal-common v16.16.0 2026-11-05 */
5499
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
5446
5500
  /*
5447
5501
  * Copyright (c) Microsoft Corporation. All rights reserved.
5448
5502
  * Licensed under the MIT License.
@@ -5456,7 +5510,7 @@
5456
5510
  const PerformanceEventStatus = {
5457
5511
  InProgress: 1};
5458
5512
 
5459
- /*! @azure/msal-common v16.16.0 2026-11-05 */
5513
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
5460
5514
 
5461
5515
  /*
5462
5516
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5514,7 +5568,7 @@
5514
5568
  }
5515
5569
  }
5516
5570
 
5517
- /*! @azure/msal-common v16.16.0 2026-11-05 */
5571
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
5518
5572
 
5519
5573
  /*
5520
5574
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5612,7 +5666,7 @@
5612
5666
  return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
5613
5667
  }
5614
5668
 
5615
- /*! @azure/msal-common v16.16.0 2026-11-05 */
5669
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
5616
5670
  /*
5617
5671
  * Copyright (c) Microsoft Corporation. All rights reserved.
5618
5672
  * Licensed under the MIT License.
@@ -5639,7 +5693,7 @@
5639
5693
  }
5640
5694
  }
5641
5695
 
5642
- /*! @azure/msal-common v16.16.0 2026-11-05 */
5696
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
5643
5697
 
5644
5698
  /*
5645
5699
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5660,7 +5714,7 @@
5660
5714
  return new JoseHeaderError(code, correlationId);
5661
5715
  }
5662
5716
 
5663
- /*! @azure/msal-common v16.16.0 2026-11-05 */
5717
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
5664
5718
  /*
5665
5719
  * Copyright (c) Microsoft Corporation. All rights reserved.
5666
5720
  * Licensed under the MIT License.
@@ -5685,7 +5739,7 @@
5685
5739
  return Object.getPrototypeOf(value) === proto;
5686
5740
  }
5687
5741
 
5688
- /*! @azure/msal-common v16.16.0 2026-11-05 */
5742
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
5689
5743
  /*
5690
5744
  * Copyright (c) Microsoft Corporation. All rights reserved.
5691
5745
  * Licensed under the MIT License.
@@ -5695,7 +5749,7 @@
5695
5749
  const missingJwkError = "missing_jwk_error";
5696
5750
  const invalidJwkError = "invalid_jwk_error";
5697
5751
 
5698
- /*! @azure/msal-common v16.16.0 2026-11-05 */
5752
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
5699
5753
 
5700
5754
  /*
5701
5755
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5761,7 +5815,7 @@
5761
5815
  }
5762
5816
  }
5763
5817
 
5764
- /*! @azure/msal-common v16.16.0 2026-11-05 */
5818
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
5765
5819
 
5766
5820
  /*
5767
5821
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5862,7 +5916,7 @@
5862
5916
  }
5863
5917
  }
5864
5918
 
5865
- /*! @azure/msal-common v16.16.0 2026-11-05 */
5919
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
5866
5920
 
5867
5921
  /*
5868
5922
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6017,7 +6071,7 @@
6017
6071
  }
6018
6072
  }
6019
6073
 
6020
- /*! @azure/msal-common v16.16.0 2026-11-05 */
6074
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
6021
6075
  /*
6022
6076
  * Copyright (c) Microsoft Corporation. All rights reserved.
6023
6077
  * Licensed under the MIT License.
@@ -6068,7 +6122,7 @@
6068
6122
  */
6069
6123
  const interruptedUser = "interrupted_user";
6070
6124
 
6071
- /*! @azure/msal-common v16.16.0 2026-11-05 */
6125
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
6072
6126
 
6073
6127
  /*
6074
6128
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6135,7 +6189,7 @@
6135
6189
  return new InteractionRequiredAuthError(errorCode, correlationId, errorMessage);
6136
6190
  }
6137
6191
 
6138
- /*! @azure/msal-common v16.16.0 2026-11-05 */
6192
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
6139
6193
 
6140
6194
  /*
6141
6195
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6154,7 +6208,7 @@
6154
6208
  }
6155
6209
  }
6156
6210
 
6157
- /*! @azure/msal-common v16.16.0 2026-11-05 */
6211
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
6158
6212
 
6159
6213
  /*
6160
6214
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6225,7 +6279,7 @@
6225
6279
  }
6226
6280
  }
6227
6281
 
6228
- /*! @azure/msal-common v16.16.0 2026-11-05 */
6282
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
6229
6283
 
6230
6284
  /*
6231
6285
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6653,7 +6707,7 @@
6653
6707
  return baseAccount;
6654
6708
  }
6655
6709
 
6656
- /*! @azure/msal-common v16.16.0 2026-11-05 */
6710
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
6657
6711
  /*
6658
6712
  * Copyright (c) Microsoft Corporation. All rights reserved.
6659
6713
  * Licensed under the MIT License.
@@ -6663,7 +6717,7 @@
6663
6717
  UPN: "UPN",
6664
6718
  };
6665
6719
 
6666
- /*! @azure/msal-common v16.16.0 2026-11-05 */
6720
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
6667
6721
  /*
6668
6722
  * Copyright (c) Microsoft Corporation. All rights reserved.
6669
6723
  * Licensed under the MIT License.
@@ -6682,7 +6736,7 @@
6682
6736
  }
6683
6737
  }
6684
6738
 
6685
- /*! @azure/msal-common v16.16.0 2026-11-05 */
6739
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
6686
6740
 
6687
6741
  /*
6688
6742
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6706,7 +6760,7 @@
6706
6760
  };
6707
6761
  }
6708
6762
 
6709
- /*! @azure/msal-common v16.16.0 2026-11-05 */
6763
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
6710
6764
 
6711
6765
  /*
6712
6766
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6796,7 +6850,7 @@
6796
6850
  return undefined;
6797
6851
  }
6798
6852
 
6799
- /*! @azure/msal-common v16.16.0 2026-11-05 */
6853
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
6800
6854
 
6801
6855
  /*
6802
6856
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6827,7 +6881,7 @@
6827
6881
  return new NetworkError(error, httpStatus, responseHeaders);
6828
6882
  }
6829
6883
 
6830
- /*! @azure/msal-common v16.16.0 2026-11-05 */
6884
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
6831
6885
 
6832
6886
  /*
6833
6887
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6961,7 +7015,7 @@
6961
7015
  return response;
6962
7016
  }
6963
7017
 
6964
- /*! @azure/msal-common v16.16.0 2026-11-05 */
7018
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
6965
7019
 
6966
7020
  /*
6967
7021
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7004,7 +7058,8 @@
7004
7058
  throw createClientAuthError(requestCannotBeMade, request.correlationId);
7005
7059
  }
7006
7060
  // Check for new cloud instance
7007
- if (authCodePayload && authCodePayload.cloud_instance_host_name) {
7061
+ if (this.config.authOptions.instanceAware === true &&
7062
+ authCodePayload?.cloud_instance_host_name) {
7008
7063
  await invokeAsync(this.updateTokenEndpointAuthority.bind(this), UpdateTokenEndpointAuthority, this.logger, this.performanceClient, request.correlationId)(authCodePayload.cloud_instance_host_name, request.correlationId);
7009
7064
  }
7010
7065
  const reqTimestamp = nowSeconds();
@@ -7228,7 +7283,7 @@
7228
7283
  }
7229
7284
  }
7230
7285
 
7231
- /*! @azure/msal-common v16.16.0 2026-11-05 */
7286
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
7232
7287
 
7233
7288
  /*
7234
7289
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7413,13 +7468,13 @@
7413
7468
  decodedServerResponseState = decodeURIComponent(serverResponse.state);
7414
7469
  }
7415
7470
  catch (e) {
7416
- throw createClientAuthError(invalidState, correlationId, serverResponse.state);
7471
+ throw createClientAuthError(invalidState, correlationId);
7417
7472
  }
7418
7473
  try {
7419
7474
  decodedRequestState = decodeURIComponent(requestState);
7420
7475
  }
7421
7476
  catch (e) {
7422
- throw createClientAuthError(invalidState, correlationId, serverResponse.state);
7477
+ throw createClientAuthError(invalidState, correlationId);
7423
7478
  }
7424
7479
  if (decodedServerResponseState !== decodedRequestState) {
7425
7480
  throw createClientAuthError(stateMismatch, correlationId);
@@ -7458,7 +7513,7 @@
7458
7513
  return account.loginHint || account.idTokenClaims?.login_hint || null;
7459
7514
  }
7460
7515
 
7461
- /*! @azure/msal-common v16.16.0 2026-11-05 */
7516
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
7462
7517
 
7463
7518
  /*
7464
7519
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7693,7 +7748,7 @@
7693
7748
  }
7694
7749
  }
7695
7750
 
7696
- /*! @azure/msal-common v16.16.0 2026-11-05 */
7751
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
7697
7752
 
7698
7753
  /*
7699
7754
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7986,7 +8041,7 @@
7986
8041
  clearNativeBrokerErrorCode() { }
7987
8042
  }
7988
8043
 
7989
- /*! @azure/msal-common v16.16.0 2026-11-05 */
8044
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
7990
8045
 
7991
8046
  /*
7992
8047
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8113,7 +8168,7 @@
8113
8168
  }
8114
8169
  }
8115
8170
 
8116
- /*! @azure/msal-common v16.16.0 2026-11-05 */
8171
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
8117
8172
 
8118
8173
  /*
8119
8174
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8129,7 +8184,7 @@
8129
8184
  },
8130
8185
  };
8131
8186
 
8132
- /*! @azure/msal-common v16.16.0 2026-11-05 */
8187
+ /*! @azure/msal-common v16.16.2 2026-11-12 */
8133
8188
 
8134
8189
  /*
8135
8190
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8315,6 +8370,7 @@
8315
8370
  constructor(argName, correlationId) {
8316
8371
  const errorDescription = `The argument '${argName}' is invalid.`;
8317
8372
  super("invalid_argument", errorDescription, correlationId);
8373
+ this.argName = argName;
8318
8374
  Object.setPrototypeOf(this, InvalidArgumentError.prototype);
8319
8375
  }
8320
8376
  }
@@ -8350,11 +8406,11 @@
8350
8406
  * Licensed under the MIT License.
8351
8407
  */
8352
8408
  const PASSWORD_TOO_WEAK$1 = "password_too_weak";
8353
- const PASSWORD_TOO_SHORT = "password_too_short";
8354
- const PASSWORD_TOO_LONG = "password_too_long";
8355
- const PASSWORD_RECENTLY_USED = "password_recently_used";
8356
- const PASSWORD_BANNED = "password_banned";
8357
- const PASSWORD_IS_INVALID = "password_is_invalid";
8409
+ const PASSWORD_TOO_SHORT$1 = "password_too_short";
8410
+ const PASSWORD_TOO_LONG$1 = "password_too_long";
8411
+ const PASSWORD_RECENTLY_USED$1 = "password_recently_used";
8412
+ const PASSWORD_BANNED$1 = "password_banned";
8413
+ const PASSWORD_IS_INVALID$1 = "password_is_invalid";
8358
8414
  const INVALID_OOB_VALUE = "invalid_oob_value";
8359
8415
  const ATTRIBUTE_VALIATION_FAILED = "attribute_validation_failed";
8360
8416
  const REGISTRATION_REQUIRED = "registration_required";
@@ -8412,11 +8468,11 @@
8412
8468
  }
8413
8469
  isInvalidNewPasswordError() {
8414
8470
  const invalidPasswordSubErrors = new Set([
8415
- PASSWORD_BANNED,
8416
- PASSWORD_IS_INVALID,
8417
- PASSWORD_RECENTLY_USED,
8418
- PASSWORD_TOO_LONG,
8419
- PASSWORD_TOO_SHORT,
8471
+ PASSWORD_BANNED$1,
8472
+ PASSWORD_IS_INVALID$1,
8473
+ PASSWORD_RECENTLY_USED$1,
8474
+ PASSWORD_TOO_LONG$1,
8475
+ PASSWORD_TOO_SHORT$1,
8420
8476
  PASSWORD_TOO_WEAK$1,
8421
8477
  ]);
8422
8478
  return (this.errorData instanceof CustomAuthApiError &&
@@ -8561,11 +8617,26 @@
8561
8617
  !argValue.every((value) => typeof value === "string")) {
8562
8618
  throw new InvalidArgumentError(argName, correlationId);
8563
8619
  }
8620
+ }
8621
+ function filterReservedSignUpAttributesV2(attributes, logger, correlationId) {
8622
+ const reservedSignUpAttributeNames = new Set(["email", "password"]);
8623
+ const reservedSignUpAttributeWarning = "Ignoring app-supplied sign-up attribute because it uses a reserved SDK attribute name.";
8624
+ const filteredAttributes = [];
8625
+ for (const [attributeId, value] of Object.entries(attributes ?? {})) {
8626
+ if (reservedSignUpAttributeNames.has(attributeId.toLowerCase())) {
8627
+ logger.warning(reservedSignUpAttributeWarning, correlationId);
8628
+ continue;
8629
+ }
8630
+ if (value !== undefined) {
8631
+ filteredAttributes.push([attributeId, value]);
8632
+ }
8633
+ }
8634
+ return Object.fromEntries(filteredAttributes);
8564
8635
  }
8565
8636
 
8566
8637
  /* eslint-disable header/header */
8567
8638
  const name = "@azure/msal-browser";
8568
- const version = "5.28.0";
8639
+ const version = "5.29.1";
8569
8640
 
8570
8641
  /*
8571
8642
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -11489,6 +11560,10 @@
11489
11560
  clientId: this.config.auth.clientId,
11490
11561
  authority: discoveredAuthority,
11491
11562
  clientCapabilities: this.config.auth.clientCapabilities,
11563
+ instanceAware: requestExtraQueryParameters?.instance_aware
11564
+ ?.length
11565
+ ? requestExtraQueryParameters.instance_aware === "true"
11566
+ : this.config.auth.instanceAware,
11492
11567
  redirectUri: this.config.auth.redirectUri,
11493
11568
  isMcp: this.config.auth.isMcp,
11494
11569
  },
@@ -11713,6 +11788,7 @@
11713
11788
  const SIGN_IN_V2_SUBMIT_CODE = 100210;
11714
11789
  const SIGN_UP_V2_START = 100211;
11715
11790
  const SIGN_UP_V2_CHALLENGE = 100212;
11791
+ const SIGN_UP_V2_SUBMIT_PASSWORD = 100223;
11716
11792
  const SIGN_UP_V2_SUBMIT_CODE = 100213;
11717
11793
  const SIGN_UP_V2_SUBMIT_ATTRIBUTES = 100214;
11718
11794
  const SIGN_UP_V2_RESEND_CODE = 100215;
@@ -12516,12 +12592,7 @@
12516
12592
  * Licensed under the MIT License.
12517
12593
  */
12518
12594
  /*
12519
- * Turns a raw HTTP response from a V2 endpoint into a typed, checked envelope, and validates HAL
12520
- * relations. Raw-preserving: the body keeps its HAL `_links`/`_embedded` shape so the api-client
12521
- * navigates typed hrefs directly. Parsing never throws on a non-200 status - every V2 response
12522
- * (including the entry response) carries a meaningful body, so only a non-object body is a hard
12523
- * failure; the wire error is normalized onto the envelope (`error`). Required response values use
12524
- * shared guards after callers read their strongly typed response properties directly.
12595
+ * Parses V2 HTTP responses and validates required response values.
12525
12596
  */
12526
12597
  class ResponseHandlerV2 {
12527
12598
  constructor(logger) {
@@ -12539,7 +12610,6 @@
12539
12610
  : undefined);
12540
12611
  const error = normalizeServerErrorV2(json);
12541
12612
  const isWebFallbackRequired = error?.subError === WEB_REDIRECT_REQUIRED;
12542
- // Surface the header correlation id on the body (HalResponseBaseV2.correlationId).
12543
12613
  json.correlationId = correlationId;
12544
12614
  return {
12545
12615
  statusCode: response.status,
@@ -12569,6 +12639,24 @@
12569
12639
  }
12570
12640
  return continuationToken;
12571
12641
  }
12642
+ resolveSignUpAttributes(attributes, correlationId) {
12643
+ const resolved = attributes === undefined ? [] : attributes;
12644
+ if (!Array.isArray(resolved) ||
12645
+ resolved.some((attribute) => typeof attribute !== "object" ||
12646
+ attribute === null ||
12647
+ typeof attribute.attributeId !== "string" ||
12648
+ !attribute.attributeId.trim())) {
12649
+ const message = "Invalid HAL response: sign-up attributes must be an array of objects with nonempty string attributeId values";
12650
+ this.logger?.error(message, correlationId);
12651
+ throw new CustomAuthApiError(INVALID_HAL_RESPONSE, message, correlationId);
12652
+ }
12653
+ if (resolved.some((attribute) => attribute.attributeId.toLowerCase() === "email")) {
12654
+ const message = "Invalid HAL response: email cannot be collected as a sign-up attribute";
12655
+ this.logger?.error(message, correlationId);
12656
+ throw new CustomAuthApiError(INVALID_HAL_RESPONSE, message, correlationId);
12657
+ }
12658
+ return resolved;
12659
+ }
12572
12660
  // Required embedded auth methods; throws when `_embedded.methods` is absent or empty.
12573
12661
  requireMethods(methods, correlationId) {
12574
12662
  if (!methods?.length) {
@@ -12586,7 +12674,6 @@
12586
12674
  this.logger?.error("V2 response serialization failed: body is not valid JSON", correlationId);
12587
12675
  throw new CustomAuthApiError(INVALID_RESPONSE_BODY, `V2 response body is not valid JSON: '${e}'`, correlationId);
12588
12676
  }
12589
- // response.json() accepts primitives/arrays; every V2 body must be a JSON object.
12590
12677
  if (typeof json !== "object" || json === null || Array.isArray(json)) {
12591
12678
  this.logger?.error("V2 response serialization failed: body is not a JSON object", correlationId);
12592
12679
  throw new CustomAuthApiError(INVALID_RESPONSE_BODY, "V2 response body is not a JSON object", correlationId);
@@ -12658,9 +12745,7 @@
12658
12745
  * Copyright (c) Microsoft Corporation. All rights reserved.
12659
12746
  * Licensed under the MIT License.
12660
12747
  */
12661
- // Content type used by V2 JSON `/api` requests.
12662
12748
  const JSON_CONTENT_TYPE = "application/json";
12663
- // Server action returned after successful credential verification.
12664
12749
  const UPDATE_RELATION = "update";
12665
12750
  const CHALLENGE_RELATION = "challenge";
12666
12751
  const VERIFY_RELATION = "verify";
@@ -12679,10 +12764,6 @@
12679
12764
  const PhoneRegistrationChannelV2 = {
12680
12765
  SMS: "sms",
12681
12766
  };
12682
- /*
12683
- * Known `state` values on a HAL response. Kept open (the body field is typed as string) because
12684
- * the server may introduce new values; response parsing and flow logic branch on these constants.
12685
- */
12686
12767
  const ResponseStateV2 = {
12687
12768
  CONTINUE: "continue",
12688
12769
  };
@@ -12901,7 +12982,6 @@
12901
12982
  * Licensed under the MIT License.
12902
12983
  */
12903
12984
  const SignUpSubmitAttributesNextActionV2 = {
12904
- VERIFY: "verify",
12905
12985
  COLLECT_ATTRIBUTES: "collectAttributes",
12906
12986
  CONTINUE: "continue",
12907
12987
  ENROLL: "enroll",
@@ -12913,7 +12993,6 @@
12913
12993
  */
12914
12994
  /*
12915
12995
  * Native Auth V2 network client that follows server-provided HAL links.
12916
- * Flow-specific entry methods reuse shared challenge, verification, and token operations.
12917
12996
  */
12918
12997
  class CustomAuthApiClientV2 extends BaseApiClientV2 {
12919
12998
  /*
@@ -12934,15 +13013,30 @@
12934
13013
  */
12935
13014
  async signUpStart(signUpHref, request, context) {
12936
13015
  const parsedResponse = await this.sendActionRequest(signUpHref, HttpMethod.POST, request, context);
12937
- return {
12938
- continuationToken: this.handler.requireContinuationToken(parsedResponse.continuationToken, parsedResponse.correlationId),
12939
- submitAttributesHref: this.handler.requireHref(parsedResponse.body._links?.submitAttributes?.href, "submitAttributes", parsedResponse.correlationId),
12940
- attributes: parsedResponse.body.attributes,
12941
- };
13016
+ const challengeType = parsedResponse.body.action === VERIFY_RELATION
13017
+ ? parsedResponse.body.type
13018
+ : undefined;
13019
+ const isEmailChallenge = typeof challengeType === "string" &&
13020
+ challengeType.toLowerCase() === AuthenticationMethodTypeV2.EMAIL;
13021
+ if (parsedResponse.body.action === VERIFY_RELATION &&
13022
+ isEmailChallenge) {
13023
+ return this.toChallengeVerificationResult(parsedResponse);
13024
+ }
13025
+ if (parsedResponse.body.action === CHALLENGE_RELATION) {
13026
+ return {
13027
+ nextAction: CHALLENGE_RELATION,
13028
+ continuationToken: this.handler.requireContinuationToken(parsedResponse.continuationToken, parsedResponse.correlationId),
13029
+ methods: this.resolveMethods(this.handler.requireMethods(parsedResponse.body._embedded?.methods, parsedResponse.correlationId), parsedResponse.correlationId),
13030
+ authenticationFactor: this.resolveAuthenticationFactor(parsedResponse.body.challengeContext?.authenticationFactor, parsedResponse.correlationId),
13031
+ scenario: parsedResponse.body.scenario,
13032
+ };
13033
+ }
13034
+ const message = "Invalid HAL response: sign-up start did not return an email verification or authentication challenge";
13035
+ this.logger?.error(message, parsedResponse.correlationId);
13036
+ throw new CustomAuthApiError(INVALID_HAL_RESPONSE, message, parsedResponse.correlationId);
12942
13037
  }
12943
13038
  /*
12944
- * Submits the initial sign-up attributes. A successful response has already
12945
- * sent the email code and supplies the links needed to verify or resend it.
13039
+ * Submits the initial sign-up attributes.
12946
13040
  */
12947
13041
  async submitSignUpAttributes(submitAttributesHref, request, context) {
12948
13042
  const parsedResponse = await this.sendActionRequest(submitAttributesHref, HttpMethod.POST, request, context);
@@ -12958,16 +13052,10 @@
12958
13052
  return {
12959
13053
  nextAction: SignUpSubmitAttributesNextActionV2.COLLECT_ATTRIBUTES,
12960
13054
  continuationToken,
12961
- attributes: parsedResponse.body.attributes ?? [],
13055
+ attributes: this.handler.resolveSignUpAttributes(parsedResponse.body.attributes, correlationId),
12962
13056
  submitAttributesHref: this.handler.requireHref(parsedResponse.body._links?.submitAttributes?.href, "submitAttributes", correlationId),
12963
13057
  };
12964
13058
  }
12965
- if (parsedResponse.body.action === VERIFY_RELATION) {
12966
- return {
12967
- ...this.toChallengeVerificationResult(parsedResponse),
12968
- attributes: parsedResponse.body.attributes,
12969
- };
12970
- }
12971
13059
  if (parsedResponse.body.action === ENROLL_RELATION) {
12972
13060
  return {
12973
13061
  nextAction: ENROLL_RELATION,
@@ -13060,7 +13148,15 @@
13060
13148
  return {
13061
13149
  nextAction,
13062
13150
  continuationToken,
13063
- enrollmentMethods: this.resolveEnrollmentMethods(this.handler.requireMethods(parsedResponse.body._embedded?.methods, correlationId), correlationId),
13151
+ methods: this.resolveEnrollmentMethods(this.handler.requireMethods(parsedResponse.body._embedded?.methods, correlationId), correlationId),
13152
+ };
13153
+ }
13154
+ if (nextAction === CHALLENGE_RELATION) {
13155
+ return {
13156
+ nextAction,
13157
+ continuationToken,
13158
+ authenticationFactor: this.resolveAuthenticationFactor(parsedResponse.body.challengeContext?.authenticationFactor, correlationId),
13159
+ methods: this.resolveMethods(this.handler.requireMethods(parsedResponse.body._embedded?.methods, correlationId), correlationId),
13064
13160
  };
13065
13161
  }
13066
13162
  if (nextAction === POLL_RELATION) {
@@ -13103,7 +13199,7 @@
13103
13199
  return {
13104
13200
  nextAction: COLLECT_ATTRIBUTES_RELATION,
13105
13201
  continuationToken,
13106
- attributes: parsedResponse.body.attributes ?? [],
13202
+ attributes: this.handler.resolveSignUpAttributes(parsedResponse.body.attributes, correlationId),
13107
13203
  submitAttributesHref: this.handler.requireHref(parsedResponse.body._links?.submitAttributes?.href, "submitAttributes", correlationId),
13108
13204
  };
13109
13205
  }
@@ -13229,9 +13325,7 @@
13229
13325
  * Licensed under the MIT License.
13230
13326
  */
13231
13327
  /*
13232
- * Shared base for Native Auth V2 interaction clients. It extends
13233
- * `StandardInteractionClient` for common browser infrastructure while keeping
13234
- * V1 and V2 token handling independent.
13328
+ * Shared base for Native Auth V2 interaction clients.
13235
13329
  */
13236
13330
  class InteractionClientBaseV2 extends StandardInteractionClient {
13237
13331
  constructor(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, customAuthAuthority) {
@@ -13239,13 +13333,11 @@
13239
13333
  this.customAuthAuthority = customAuthAuthority;
13240
13334
  this.tokenResponseHandler = new ResponseHandler(this.config.auth.clientId, this.browserStorage, this.browserCrypto, this.logger, this.performanceClient, null, null);
13241
13335
  }
13242
- // Required by the base contract. After sign-in, use CustomAuthAccountData.getAccessToken().
13243
13336
  acquireToken(
13244
13337
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
13245
13338
  request) {
13246
13339
  throw new MethodNotImplementedError("InteractionClientBaseV2.acquireToken");
13247
13340
  }
13248
- // Required by the base contract. After sign-in, use CustomAuthAccountData.signOut().
13249
13341
  logout(
13250
13342
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
13251
13343
  request) {
@@ -13289,9 +13381,10 @@
13289
13381
  * Copyright (c) Microsoft Corporation. All rights reserved.
13290
13382
  * Licensed under the MIT License.
13291
13383
  */
13292
- // Result type discriminators.
13293
13384
  const FLOW_METHOD_SELECTION_REQUIRED_V2 = "FlowMethodSelectionRequiredResultV2";
13294
13385
  const FLOW_CODE_REQUIRED_V2 = "FlowCodeRequiredResultV2";
13386
+ const FLOW_EXISTING_ACCOUNT_CODE_REQUIRED_V2 = "FlowExistingAccountCodeRequiredResultV2";
13387
+ const FLOW_EXISTING_ACCOUNT_PASSWORD_REQUIRED_V2 = "FlowExistingAccountPasswordRequiredResultV2";
13295
13388
  const FLOW_PASSWORD_REQUIRED_V2 = "FlowPasswordRequiredResultV2";
13296
13389
  const FLOW_SIGN_UP_PASSWORD_REQUIRED_V2 = "FlowSignUpPasswordRequiredResultV2";
13297
13390
  const FLOW_MFA_REQUIRED_V2 = "FlowMFARequiredResultV2";
@@ -13307,6 +13400,12 @@
13307
13400
  function createFlowCodeRequiredResultV2(input) {
13308
13401
  return { type: FLOW_CODE_REQUIRED_V2, ...input };
13309
13402
  }
13403
+ function createFlowExistingAccountCodeRequiredResultV2(input) {
13404
+ return { type: FLOW_EXISTING_ACCOUNT_CODE_REQUIRED_V2, ...input };
13405
+ }
13406
+ function createFlowExistingAccountPasswordRequiredResultV2(input) {
13407
+ return { type: FLOW_EXISTING_ACCOUNT_PASSWORD_REQUIRED_V2, ...input };
13408
+ }
13310
13409
  function createFlowPasswordRequiredResultV2(input) {
13311
13410
  return { type: FLOW_PASSWORD_REQUIRED_V2, ...input };
13312
13411
  }
@@ -13340,10 +13439,8 @@
13340
13439
  * Licensed under the MIT License.
13341
13440
  */
13342
13441
  /**
13343
- * The native auth V2 flow that a result or error originates from (sign-in,
13344
- * sign-up, or password reset). It lets a shared result or error type report
13345
- * which entry flow produced it; `Unknown` is used when the flow cannot be
13346
- * determined.
13442
+ * The native auth V2 flow that a result or error originates from.
13443
+ * @warning This API is experimental. It may be changed in the future without notice. Do not use in production applications.
13347
13444
  */
13348
13445
  const CustomAuthFlowScenarioV2 = {
13349
13446
  SignIn: "signIn",
@@ -13374,6 +13471,7 @@
13374
13471
  [CustomAuthFlowScenarioV2.SignUp]: {
13375
13472
  requestChallenge: SIGN_UP_V2_CHALLENGE,
13376
13473
  submitCode: SIGN_UP_V2_SUBMIT_CODE,
13474
+ submitPassword: SIGN_UP_V2_SUBMIT_PASSWORD,
13377
13475
  resendCode: SIGN_UP_V2_RESEND_CODE,
13378
13476
  submitAttributes: SIGN_UP_V2_SUBMIT_ATTRIBUTES,
13379
13477
  signInWithContinuation: SIGN_UP_V2_COMPLETE,
@@ -13384,12 +13482,9 @@
13384
13482
  submitCode: MFA_V2_SUBMIT_CHALLENGE,
13385
13483
  resendCode: MFA_V2_RESEND_CHALLENGE,
13386
13484
  };
13387
- /**
13388
- * Resolves the telemetry API ID for a flow step. MFA challenge operations use
13389
- * distinct IDs when the sign-in caller identifies the second factor.
13390
- */
13391
13485
  function getPublicApiIdV2(scenario, step, authenticationFactor) {
13392
- if (scenario === CustomAuthFlowScenarioV2.SignIn &&
13486
+ if ((scenario === CustomAuthFlowScenarioV2.SignIn ||
13487
+ scenario === CustomAuthFlowScenarioV2.PasswordReset) &&
13393
13488
  authenticationFactor === AuthenticationFactorV2.MULTI_FACTOR) {
13394
13489
  return (MFA_STEP_API_IDS_V2[step] ?? FLOW_STEP_API_IDS_V2[scenario]?.[step]);
13395
13490
  }
@@ -13400,17 +13495,12 @@
13400
13495
  * Copyright (c) Microsoft Corporation. All rights reserved.
13401
13496
  * Licensed under the MIT License.
13402
13497
  */
13403
- /*
13404
- * Polls up to five times for password-update completion, waiting 1.5 seconds
13405
- * between attempts. The first request runs immediately.
13406
- */
13407
13498
  const POLL_MAX_ATTEMPTS = 5;
13408
13499
  // TODO: Replace this fallback with the server-provided polling interval once available.
13409
13500
  const POLL_INTERVAL_MS = 1500;
13410
13501
  const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
13411
13502
  /*
13412
- * Drives server-directed Native Auth V2 flows using opaque continuation state
13413
- * and HAL links. Each operation returns only its valid discriminated results.
13503
+ * Drives server-directed Native Auth V2 flows.
13414
13504
  */
13415
13505
  class FlowInteractionClientV2 extends InteractionClientBaseV2 {
13416
13506
  constructor(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, customAuthAuthority, apiClient) {
@@ -13418,8 +13508,7 @@
13418
13508
  this.apiClient = apiClient;
13419
13509
  }
13420
13510
  /*
13421
- * Starts sign-in by automatically using a sole supported method or returning
13422
- * multiple supported methods for user selection.
13511
+ * Starts native auth V2 sign-in.
13423
13512
  */
13424
13513
  async signIn(parameters) {
13425
13514
  const correlationId = parameters.correlationId;
@@ -13472,20 +13561,14 @@
13472
13561
  method: selectedMethod,
13473
13562
  };
13474
13563
  }
13475
- if (parameters.password) {
13476
- return this.submitSignInPassword({
13477
- correlationId,
13478
- continuationState: challengeResult.continuationState,
13479
- password: parameters.password,
13480
- });
13481
- }
13482
13564
  return challengeResult;
13483
13565
  }
13484
13566
  /*
13485
- * Starts sign-up and resolves the server-provided attribute-submission transition.
13567
+ * Starts native auth V2 sign-up.
13486
13568
  */
13487
13569
  async signUp(parameters) {
13488
13570
  const correlationId = parameters.correlationId;
13571
+ const pendingProfileAttributes = filterReservedSignUpAttributesV2(parameters.attributes, this.logger, correlationId);
13489
13572
  const context = this.createRequestContext(SIGN_UP_V2_START, correlationId);
13490
13573
  this.logger.verbose("Starting V2 sign-up.", correlationId);
13491
13574
  const scopes = this.getScopes(parameters.scopes);
@@ -13495,38 +13578,82 @@
13495
13578
  message: "The authorize-challenge entry response did not include a sign-up link.",
13496
13579
  }), {
13497
13580
  continuationToken: entryResult.continuationToken,
13581
+ username: parameters.username,
13498
13582
  }, context);
13499
- const attributes = Object.fromEntries(Object.entries(parameters.attributes ?? {}).filter(([name]) => name.toLowerCase() !== "email" &&
13500
- name.toLowerCase() !== "password"));
13501
- attributes.email = parameters.username;
13502
- if (parameters.password !== undefined) {
13503
- attributes.password = parameters.password;
13583
+ if (startResult.nextAction === VERIFY_RELATION) {
13584
+ if (startResult.type?.toLowerCase() !==
13585
+ AuthenticationMethodTypeV2.EMAIL) {
13586
+ const message = "New-account sign-up requires an email code challenge.";
13587
+ this.logger.error(message, correlationId);
13588
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13589
+ }
13590
+ return createFlowCodeRequiredResultV2({
13591
+ correlationId,
13592
+ continuationState: {
13593
+ continuationToken: startResult.continuationToken,
13594
+ scenario: CustomAuthFlowScenarioV2.SignUp,
13595
+ scopes,
13596
+ links: {
13597
+ verify: startResult.verifyHref,
13598
+ resend: startResult.resendHref,
13599
+ },
13600
+ signUp: {
13601
+ purpose: "newAccount",
13602
+ pendingProfileAttributes,
13603
+ submittedAttributeIds: [],
13604
+ },
13605
+ },
13606
+ channel: startResult.type,
13607
+ sentTo: startResult.hint,
13608
+ codeLength: startResult.codeLength,
13609
+ });
13504
13610
  }
13505
- const submitResult = await this.apiClient.submitSignUpAttributes(startResult.submitAttributesHref, {
13506
- continuationToken: startResult.continuationToken,
13507
- attributes,
13508
- }, context);
13509
13611
  const continuationState = {
13510
13612
  continuationToken: startResult.continuationToken,
13511
13613
  scenario: CustomAuthFlowScenarioV2.SignUp,
13512
13614
  scopes,
13513
13615
  links: {},
13514
13616
  signUp: {
13515
- passwordWasSupplied: attributes.password !== undefined,
13617
+ purpose: "existingAccount",
13516
13618
  },
13517
13619
  };
13518
- const result = this.toSignUpActionResult(submitResult, continuationState, correlationId);
13519
- if (result.type === FLOW_SIGN_IN_CONTINUATION_REQUIRED_V2 ||
13520
- result.type === FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2) {
13521
- const message = `Initial sign-up attribute submission returned unsupported next action '${submitResult.nextAction}'.`;
13522
- this.logger.error(message, correlationId);
13523
- throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13620
+ this.ensureAuthenticationFactor(startResult.authenticationFactor, AuthenticationFactorV2.SINGLE_FACTOR, "existing-account sign-up", correlationId);
13621
+ const supportedMethods = startResult.methods
13622
+ .map((method) => ({
13623
+ id: method.id,
13624
+ type: method.type ?? "",
13625
+ hint: method.hint,
13626
+ challengeHref: method.challengeHref,
13627
+ }))
13628
+ .filter((method) => {
13629
+ const methodType = method.type.toLowerCase();
13630
+ return (methodType === AuthenticationMethodTypeV2.EMAIL ||
13631
+ methodType === AuthenticationMethodTypeV2.PASSWORD);
13632
+ });
13633
+ if (supportedMethods.length === 0) {
13634
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, "The existing-account sign-up response must include an email or password method.", correlationId);
13524
13635
  }
13525
- return result;
13636
+ if (supportedMethods.length > 1) {
13637
+ return createFlowMethodSelectionRequiredResultV2({
13638
+ correlationId,
13639
+ continuationState,
13640
+ methods: supportedMethods,
13641
+ });
13642
+ }
13643
+ const selectedMethod = supportedMethods[0];
13644
+ const challengeResult = await this.requestChallenge({
13645
+ correlationId,
13646
+ continuationState: {
13647
+ ...continuationState,
13648
+ links: {
13649
+ challenge: selectedMethod.challengeHref,
13650
+ },
13651
+ },
13652
+ });
13653
+ return this.toExistingAccountChallengeResult(challengeResult, selectedMethod, correlationId);
13526
13654
  }
13527
13655
  /*
13528
- * Starts password reset, automatically challenging a sole method or
13529
- * returning multiple methods for selection.
13656
+ * Starts native auth V2 password reset.
13530
13657
  */
13531
13658
  async resetPassword(parameters) {
13532
13659
  const correlationId = parameters.correlationId;
@@ -13559,44 +13686,43 @@
13559
13686
  this.logger.error(message, correlationId);
13560
13687
  throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13561
13688
  }
13562
- if (methods.length === 1) {
13563
- const selectedMethod = methods[0];
13564
- const challengeResult = await this.requestChallenge({
13689
+ if (methods.length > 1) {
13690
+ this.logger.verbose("V2 self-service password reset method selection required.", correlationId);
13691
+ return createFlowMethodSelectionRequiredResultV2({
13565
13692
  correlationId,
13566
- continuationState: {
13567
- ...continuationState,
13568
- links: {
13569
- challenge: selectedMethod.challengeHref,
13570
- },
13571
- },
13693
+ continuationState,
13694
+ methods,
13572
13695
  });
13573
- if (challengeResult.type === FLOW_CODE_REQUIRED_V2 &&
13574
- (challengeResult.channel?.toLowerCase() ===
13575
- AuthenticationMethodTypeV2.EMAIL ||
13576
- challengeResult.channel?.toLowerCase() ===
13577
- AuthenticationMethodTypeV2.SMS)) {
13578
- return {
13579
- ...challengeResult,
13580
- method: selectedMethod,
13581
- };
13582
- }
13583
- const channel = challengeResult.type === FLOW_CODE_REQUIRED_V2
13584
- ? challengeResult.channel
13585
- : AuthenticationMethodTypeV2.PASSWORD;
13586
- const message = `Challenge type '${challengeResult.type}' with channel '${channel}' is not supported for password reset.`;
13587
- this.logger.error(message, correlationId);
13588
- throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13589
13696
  }
13590
- this.logger.verbose("V2 self-service password reset method selection required.", correlationId);
13591
- return createFlowMethodSelectionRequiredResultV2({
13697
+ const selectedMethod = methods[0];
13698
+ const challengeResult = await this.requestChallenge({
13592
13699
  correlationId,
13593
- continuationState,
13594
- methods,
13700
+ continuationState: {
13701
+ ...continuationState,
13702
+ links: {
13703
+ challenge: selectedMethod.challengeHref,
13704
+ },
13705
+ },
13595
13706
  });
13707
+ if (challengeResult.type === FLOW_CODE_REQUIRED_V2 &&
13708
+ (challengeResult.channel?.toLowerCase() ===
13709
+ AuthenticationMethodTypeV2.EMAIL ||
13710
+ challengeResult.channel?.toLowerCase() ===
13711
+ AuthenticationMethodTypeV2.SMS)) {
13712
+ return {
13713
+ ...challengeResult,
13714
+ method: selectedMethod,
13715
+ };
13716
+ }
13717
+ const channel = challengeResult.type === FLOW_CODE_REQUIRED_V2
13718
+ ? challengeResult.channel
13719
+ : AuthenticationMethodTypeV2.PASSWORD;
13720
+ const message = `Challenge type '${challengeResult.type}' with channel '${channel}' is not supported for password reset.`;
13721
+ this.logger.error(message, correlationId);
13722
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13596
13723
  }
13597
13724
  /*
13598
- * Requests a one-time code for the selected authentication method. Returns
13599
- * the continuation state and code metadata needed for verification.
13725
+ * Requests a challenge for the selected authentication method.
13600
13726
  */
13601
13727
  async requestChallenge(parameters) {
13602
13728
  const challengeResult = await this.sendMethodChallenge(parameters, "requestChallenge");
@@ -13626,7 +13752,7 @@
13626
13752
  throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, parameters.correlationId);
13627
13753
  }
13628
13754
  /*
13629
- * Registers the selected offered method and returns activation metadata.
13755
+ * Registers the selected authentication method.
13630
13756
  */
13631
13757
  async registerAuthMethod(parameters) {
13632
13758
  const { continuationState, correlationId } = parameters;
@@ -13640,8 +13766,7 @@
13640
13766
  return this.createAuthMethodVerificationRequiredResult(continuationState, result, correlationId);
13641
13767
  }
13642
13768
  /*
13643
- * Activates the registered method and redeems the resulting continuation
13644
- * for tokens.
13769
+ * Activates the registered authentication method.
13645
13770
  */
13646
13771
  async verifyAuthMethodRegistration(parameters) {
13647
13772
  const { continuationState, correlationId } = parameters;
@@ -13651,11 +13776,22 @@
13651
13776
  continuationToken: continuationState.continuationToken,
13652
13777
  otp: parameters.code,
13653
13778
  }, context);
13779
+ if (continuationState.scenario === CustomAuthFlowScenarioV2.SignUp ||
13780
+ continuationState.scenario ===
13781
+ CustomAuthFlowScenarioV2.PasswordReset) {
13782
+ return createFlowSignInContinuationRequiredResultV2({
13783
+ correlationId,
13784
+ continuationState: {
13785
+ ...continuationState,
13786
+ continuationToken: result.continuationToken,
13787
+ links: {},
13788
+ },
13789
+ });
13790
+ }
13654
13791
  return this.completeSignInAfterVerification(continuationState, result.continuationToken, correlationId);
13655
13792
  }
13656
13793
  /*
13657
- * Requests a replacement activation challenge through the server-provided
13658
- * resend link using the latest continuation token.
13794
+ * Requests a replacement authentication-method activation challenge.
13659
13795
  */
13660
13796
  async resendAuthMethodRegistrationChallenge(parameters) {
13661
13797
  const { continuationState, correlationId } = parameters;
@@ -13667,8 +13803,7 @@
13667
13803
  return this.createAuthMethodVerificationRequiredResult(continuationState, result, correlationId);
13668
13804
  }
13669
13805
  /*
13670
- * Verifies the submitted one-time code using the server-provided link. The
13671
- * response determines the next required action.
13806
+ * Verifies the submitted one-time code.
13672
13807
  */
13673
13808
  async submitCode(parameters) {
13674
13809
  const continuationState = parameters.continuationState;
@@ -13683,6 +13818,22 @@
13683
13818
  const verifyResult = await this.apiClient.verifyChallenge(verifyHref, verifyRequest, context);
13684
13819
  if (continuationState.scenario ===
13685
13820
  CustomAuthFlowScenarioV2.PasswordReset &&
13821
+ parameters.authenticationFactor ===
13822
+ AuthenticationFactorV2.MULTI_FACTOR &&
13823
+ verifyResult.nextAction === ResponseStateV2.CONTINUE) {
13824
+ return createFlowSignInContinuationRequiredResultV2({
13825
+ correlationId,
13826
+ continuationState: {
13827
+ ...continuationState,
13828
+ continuationToken: verifyResult.continuationToken,
13829
+ links: {},
13830
+ },
13831
+ });
13832
+ }
13833
+ if (continuationState.scenario ===
13834
+ CustomAuthFlowScenarioV2.PasswordReset &&
13835
+ parameters.authenticationFactor !==
13836
+ AuthenticationFactorV2.MULTI_FACTOR &&
13686
13837
  verifyResult.nextAction === UPDATE_RELATION) {
13687
13838
  return createFlowNewPasswordRequiredResultV2({
13688
13839
  correlationId,
@@ -13697,6 +13848,10 @@
13697
13848
  if (continuationState.scenario === CustomAuthFlowScenarioV2.SignIn) {
13698
13849
  return this.handleSignInVerification(continuationState, verifyResult, correlationId);
13699
13850
  }
13851
+ if (continuationState.scenario === CustomAuthFlowScenarioV2.SignUp &&
13852
+ continuationState.signUp?.purpose === "existingAccount") {
13853
+ return this.handleSignInVerification(continuationState, verifyResult, correlationId);
13854
+ }
13700
13855
  if (continuationState.scenario === CustomAuthFlowScenarioV2.SignUp) {
13701
13856
  return this.handleSignUpVerification(continuationState, verifyResult, correlationId);
13702
13857
  }
@@ -13705,11 +13860,17 @@
13705
13860
  throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13706
13861
  }
13707
13862
  /*
13708
- * Requests a new one-time code using the server-provided resend link.
13709
- * Returns refreshed continuation state and code metadata.
13863
+ * Requests a replacement one-time code.
13710
13864
  */
13711
13865
  async resendCode(parameters) {
13712
13866
  const challengeResult = await this.sendMethodChallenge(parameters, "resendCode");
13867
+ const challengeType = challengeResult.type?.toLowerCase();
13868
+ if (challengeType !== AuthenticationMethodTypeV2.EMAIL &&
13869
+ challengeType !== AuthenticationMethodTypeV2.SMS) {
13870
+ const message = "A replacement code requires an email or SMS code challenge.";
13871
+ this.logger.error(message, parameters.correlationId);
13872
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, parameters.correlationId);
13873
+ }
13713
13874
  return createFlowCodeRequiredResultV2({
13714
13875
  correlationId: parameters.correlationId,
13715
13876
  continuationState: this.createChallengeContinuationState(parameters.continuationState, challengeResult),
@@ -13719,24 +13880,31 @@
13719
13880
  });
13720
13881
  }
13721
13882
  async submitSignUpAttributes(parameters) {
13722
- const { continuationState, correlationId, attributes } = parameters;
13883
+ const { continuationState, correlationId, attributes: submittedAttributes, } = parameters;
13723
13884
  const context = this.createRequestContext(this.resolveStepApiId(continuationState.scenario, "submitAttributes", correlationId), correlationId);
13724
13885
  this.logger.verbose("Submitting additional V2 sign-up attributes.", correlationId);
13886
+ const submittedAttributeIds = Object.keys(submittedAttributes);
13725
13887
  const submitResult = await this.apiClient.submitSignUpAttributes(this.requireLink(correlationId, continuationState.links.submitAttributes), {
13726
13888
  continuationToken: continuationState.continuationToken,
13727
- attributes,
13889
+ attributes: submittedAttributes,
13728
13890
  }, context);
13729
- return this.toSignUpActionResult(submitResult, {
13891
+ return this.toSignUpSubmitAttributesResult(submitResult, {
13730
13892
  ...continuationState,
13731
13893
  signUp: {
13732
- passwordWasSupplied: continuationState.signUp?.passwordWasSupplied ===
13733
- true || attributes.password !== undefined,
13894
+ purpose: "newAccount",
13895
+ submittedAttributeIds: [
13896
+ ...new Set([
13897
+ ...(continuationState.signUp
13898
+ ?.submittedAttributeIds ?? []),
13899
+ ...submittedAttributeIds,
13900
+ ]),
13901
+ ],
13734
13902
  },
13735
13903
  }, correlationId);
13736
13904
  }
13737
13905
  /*
13738
- * Submits the new password and polls until the reset completes. The result
13739
- * contains the continuation state required for explicit sign-in.
13906
+ * Submits the new password and polls for the next action: method registration,
13907
+ * MFA, or a continuation for explicit sign-in.
13740
13908
  */
13741
13909
  async submitNewPassword(parameters) {
13742
13910
  const continuationState = parameters.continuationState;
@@ -13754,7 +13922,7 @@
13754
13922
  for (let attempt = 1; attempt <= POLL_MAX_ATTEMPTS; attempt++) {
13755
13923
  pollResult = await this.apiClient.poll(pollHref, { continuationToken: pollToken }, context);
13756
13924
  isPolling = pollResult.nextAction === POLL_RELATION;
13757
- if (!isPolling) {
13925
+ if (pollResult.nextAction !== POLL_RELATION) {
13758
13926
  break;
13759
13927
  }
13760
13928
  pollToken = pollResult.continuationToken;
@@ -13768,8 +13936,7 @@
13768
13936
  this.logger.error(message, correlationId);
13769
13937
  throw new CustomAuthError(RESET_PASSWORD_TIMEOUT, message, correlationId);
13770
13938
  }
13771
- if (pollResult.nextAction === ENROLL_RELATION &&
13772
- pollResult.enrollmentMethods) {
13939
+ if (pollResult.nextAction === ENROLL_RELATION && pollResult.methods) {
13773
13940
  return this.createAuthMethodRegistrationRequiredResult({
13774
13941
  correlationId,
13775
13942
  continuationState: {
@@ -13777,7 +13944,30 @@
13777
13944
  continuationToken: pollResult.continuationToken,
13778
13945
  links: {},
13779
13946
  },
13780
- methods: pollResult.enrollmentMethods,
13947
+ methods: pollResult.methods,
13948
+ });
13949
+ }
13950
+ if (pollResult.nextAction === CHALLENGE_RELATION) {
13951
+ if (!pollResult.authenticationFactor) {
13952
+ const message = "Password-reset MFA challenge is missing its authentication factor.";
13953
+ this.logger.error(message, correlationId);
13954
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13955
+ }
13956
+ this.ensureAuthenticationFactor(pollResult.authenticationFactor, AuthenticationFactorV2.MULTI_FACTOR, "after password reset", correlationId);
13957
+ return createFlowMFARequiredResultV2({
13958
+ correlationId,
13959
+ continuationState: {
13960
+ continuationToken: pollResult.continuationToken,
13961
+ scenario: continuationState.scenario,
13962
+ scopes: continuationState.scopes,
13963
+ links: {},
13964
+ },
13965
+ methods: pollResult.methods.map((method) => ({
13966
+ id: method.id,
13967
+ type: method.type ?? "",
13968
+ hint: method.hint,
13969
+ challengeHref: method.challengeHref,
13970
+ })),
13781
13971
  });
13782
13972
  }
13783
13973
  if (pollResult.nextAction === ResponseStateV2.CONTINUE) {
@@ -13797,15 +13987,14 @@
13797
13987
  throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13798
13988
  }
13799
13989
  /*
13800
- * Verifies a sign-in password and returns the next sign-in action.
13990
+ * Verifies the sign-in password.
13801
13991
  */
13802
13992
  async submitSignInPassword(parameters) {
13803
13993
  const verifyResult = await this.verifySignInPassword(parameters);
13804
13994
  return this.handleSignInVerification(parameters.continuationState, verifyResult, parameters.correlationId);
13805
13995
  }
13806
13996
  /*
13807
- * Redeems the completed flow continuation for tokens. Returns the
13808
- * authentication result after validating and caching the response.
13997
+ * Signs the user in from a completed flow.
13809
13998
  */
13810
13999
  async signInWithContinuation(parameters) {
13811
14000
  const continuationState = parameters.continuationState;
@@ -13836,13 +14025,12 @@
13836
14025
  });
13837
14026
  }
13838
14027
  if (verifyResult.nextAction === CHALLENGE_RELATION) {
13839
- this.ensureAuthenticationFactor(verifyResult.authenticationFactor, AuthenticationFactorV2.MULTI_FACTOR, "after sign-in verification", correlationId);
14028
+ this.ensureAuthenticationFactor(verifyResult.authenticationFactor, AuthenticationFactorV2.MULTI_FACTOR, "after authentication verification", correlationId);
13840
14029
  return createFlowMFARequiredResultV2({
13841
14030
  correlationId,
13842
14031
  continuationState: {
14032
+ ...continuationState,
13843
14033
  continuationToken: verifyResult.continuationToken,
13844
- scenario: continuationState.scenario,
13845
- scopes: continuationState.scopes,
13846
14034
  links: {},
13847
14035
  },
13848
14036
  methods: verifyResult.methods.map((method) => ({
@@ -13856,37 +14044,41 @@
13856
14044
  if (verifyResult.nextAction === ResponseStateV2.CONTINUE) {
13857
14045
  return this.completeSignInAfterVerification(continuationState, verifyResult.continuationToken, correlationId);
13858
14046
  }
13859
- const message = `Verification next action '${verifyResult.nextAction}' is not supported for sign-in.`;
14047
+ const message = `Verification next action '${verifyResult.nextAction}' is not supported for authentication.`;
13860
14048
  this.logger.error(message, correlationId);
13861
14049
  throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
13862
14050
  }
13863
- handleSignUpVerification(continuationState, verifyResult, correlationId) {
14051
+ async handleSignUpVerification(continuationState, verifyResult, correlationId) {
13864
14052
  if (verifyResult.nextAction === COLLECT_ATTRIBUTES_RELATION) {
13865
- const requiredPasswordAttribute = verifyResult.attributes.find((attribute) => attribute.attributeId.toLowerCase() === "password" &&
13866
- attribute.required === true);
14053
+ const requestedAttributes = verifyResult.attributes;
14054
+ const requestedPasswordAttribute = requestedAttributes.find((attribute) => attribute.attributeId.toLowerCase() === "password");
13867
14055
  const nextContinuationState = {
14056
+ ...continuationState,
13868
14057
  continuationToken: verifyResult.continuationToken,
13869
- scenario: continuationState.scenario,
13870
- scopes: continuationState.scopes,
13871
14058
  links: {
13872
14059
  submitAttributes: verifyResult.submitAttributesHref,
13873
14060
  },
13874
- signUp: continuationState.signUp,
13875
14061
  };
13876
- const attributes = verifyResult.attributes.filter((attribute) => attribute.attributeId.toLowerCase() !== "password");
13877
- if (requiredPasswordAttribute &&
13878
- continuationState.signUp?.passwordWasSupplied !== true) {
14062
+ const pendingProfileAttributes = continuationState.signUp?.pendingProfileAttributes;
14063
+ if (pendingProfileAttributes &&
14064
+ Object.keys(pendingProfileAttributes).length > 0) {
14065
+ return this.submitSignUpAttributes({
14066
+ correlationId,
14067
+ continuationState: nextContinuationState,
14068
+ attributes: pendingProfileAttributes,
14069
+ });
14070
+ }
14071
+ if (requestedPasswordAttribute) {
13879
14072
  return createFlowSignUpPasswordRequiredResultV2({
13880
14073
  correlationId,
13881
14074
  continuationState: nextContinuationState,
13882
- attributes,
13883
- requiredPasswordAttribute,
14075
+ requestedPasswordAttribute,
13884
14076
  });
13885
14077
  }
13886
14078
  return createFlowAttributesRequiredResultV2({
13887
14079
  correlationId,
13888
14080
  continuationState: nextContinuationState,
13889
- attributes,
14081
+ attributes: requestedAttributes,
13890
14082
  });
13891
14083
  }
13892
14084
  if (verifyResult.nextAction === ENROLL_RELATION) {
@@ -13904,9 +14096,8 @@
13904
14096
  return createFlowSignInContinuationRequiredResultV2({
13905
14097
  correlationId,
13906
14098
  continuationState: {
14099
+ ...continuationState,
13907
14100
  continuationToken: verifyResult.continuationToken,
13908
- scenario: continuationState.scenario,
13909
- scopes: continuationState.scopes,
13910
14101
  links: {},
13911
14102
  },
13912
14103
  });
@@ -14002,26 +14193,8 @@
14002
14193
  codeLength: result.codeLength,
14003
14194
  });
14004
14195
  }
14005
- toSignUpActionResult(result, continuationState, correlationId) {
14196
+ toSignUpSubmitAttributesResult(result, continuationState, correlationId) {
14006
14197
  const nextAction = result.nextAction;
14007
- if (result.nextAction === SignUpSubmitAttributesNextActionV2.VERIFY) {
14008
- return createFlowCodeRequiredResultV2({
14009
- correlationId,
14010
- continuationState: {
14011
- continuationToken: result.continuationToken,
14012
- scenario: continuationState.scenario,
14013
- scopes: continuationState.scopes,
14014
- links: {
14015
- verify: result.verifyHref,
14016
- resend: result.resendHref,
14017
- },
14018
- signUp: continuationState.signUp,
14019
- },
14020
- channel: result.type,
14021
- sentTo: result.hint,
14022
- codeLength: result.codeLength,
14023
- });
14024
- }
14025
14198
  if (result.nextAction === SignUpSubmitAttributesNextActionV2.ENROLL) {
14026
14199
  return this.createAuthMethodRegistrationRequiredResult({
14027
14200
  correlationId,
@@ -14035,40 +14208,35 @@
14035
14208
  }
14036
14209
  if (result.nextAction ===
14037
14210
  SignUpSubmitAttributesNextActionV2.COLLECT_ATTRIBUTES) {
14038
- const requiredPasswordAttribute = result.attributes.find((attribute) => attribute.attributeId.toLowerCase() === "password" &&
14039
- attribute.required === true);
14211
+ const requestedAttributes = result.attributes;
14212
+ this.ensureValidSignUpAttributeCollectionAfterSubmission(requestedAttributes, continuationState, correlationId);
14040
14213
  const nextContinuationState = {
14214
+ ...continuationState,
14041
14215
  continuationToken: result.continuationToken,
14042
- scenario: continuationState.scenario,
14043
- scopes: continuationState.scopes,
14044
14216
  links: {
14045
14217
  submitAttributes: result.submitAttributesHref,
14046
14218
  },
14047
- signUp: continuationState.signUp,
14048
14219
  };
14049
- const attributes = result.attributes.filter((attribute) => attribute.attributeId.toLowerCase() !== "password");
14050
- if (requiredPasswordAttribute &&
14051
- continuationState.signUp?.passwordWasSupplied !== true) {
14220
+ const requestedPasswordAttribute = requestedAttributes.find((attribute) => attribute.attributeId.toLowerCase() === "password");
14221
+ if (requestedPasswordAttribute) {
14052
14222
  return createFlowSignUpPasswordRequiredResultV2({
14053
14223
  correlationId,
14054
14224
  continuationState: nextContinuationState,
14055
- attributes,
14056
- requiredPasswordAttribute,
14225
+ requestedPasswordAttribute,
14057
14226
  });
14058
14227
  }
14059
14228
  return createFlowAttributesRequiredResultV2({
14060
14229
  correlationId,
14061
14230
  continuationState: nextContinuationState,
14062
- attributes,
14231
+ attributes: requestedAttributes,
14063
14232
  });
14064
14233
  }
14065
14234
  if (result.nextAction === SignUpSubmitAttributesNextActionV2.CONTINUE) {
14066
14235
  return createFlowSignInContinuationRequiredResultV2({
14067
14236
  correlationId,
14068
14237
  continuationState: {
14238
+ ...continuationState,
14069
14239
  continuationToken: result.continuationToken,
14070
- scenario: continuationState.scenario,
14071
- scopes: continuationState.scopes,
14072
14240
  links: {},
14073
14241
  },
14074
14242
  });
@@ -14077,6 +14245,20 @@
14077
14245
  this.logger.error(message, correlationId);
14078
14246
  throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
14079
14247
  }
14248
+ ensureValidSignUpAttributeCollectionAfterSubmission(requestedAttributes, continuationState, correlationId) {
14249
+ const submittedAttributeIds = continuationState.signUp?.submittedAttributeIds ?? [];
14250
+ const hasSubmittedPassword = submittedAttributeIds.some((attributeId) => attributeId.toLowerCase() === "password");
14251
+ const invalidAttribute = requestedAttributes.find((requestedAttribute) => requestedAttribute.attributeId.toLowerCase() === "password"
14252
+ ? hasSubmittedPassword
14253
+ : submittedAttributeIds.includes(requestedAttribute.attributeId));
14254
+ if (invalidAttribute) {
14255
+ const message = invalidAttribute.attributeId.toLowerCase() === "password"
14256
+ ? "The sign-up API cannot request password collection after attribute submission."
14257
+ : "The sign-up API requested an attribute that was already successfully submitted.";
14258
+ this.logger.error(message, correlationId);
14259
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
14260
+ }
14261
+ }
14080
14262
  ensureAuthenticationFactor(authenticationFactor, expectedFactor, transition, correlationId) {
14081
14263
  if (authenticationFactor === expectedFactor) {
14082
14264
  return;
@@ -14085,10 +14267,33 @@
14085
14267
  this.logger.error(message, correlationId);
14086
14268
  throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
14087
14269
  }
14270
+ toExistingAccountChallengeResult(challengeResult, method, correlationId) {
14271
+ if (challengeResult.type === FLOW_CODE_REQUIRED_V2 &&
14272
+ challengeResult.channel?.toLowerCase() ===
14273
+ AuthenticationMethodTypeV2.EMAIL) {
14274
+ return createFlowExistingAccountCodeRequiredResultV2({
14275
+ correlationId,
14276
+ continuationState: challengeResult.continuationState,
14277
+ method,
14278
+ channel: challengeResult.channel,
14279
+ sentTo: challengeResult.sentTo,
14280
+ codeLength: challengeResult.codeLength,
14281
+ });
14282
+ }
14283
+ if (challengeResult.type === FLOW_PASSWORD_REQUIRED_V2) {
14284
+ return createFlowExistingAccountPasswordRequiredResultV2({
14285
+ correlationId,
14286
+ continuationState: challengeResult.continuationState,
14287
+ });
14288
+ }
14289
+ const message = "Existing-account sign-up requires an email code challenge or a password challenge.";
14290
+ this.logger.error(message, correlationId);
14291
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, message, correlationId);
14292
+ }
14088
14293
  async verifySignInPassword(parameters) {
14089
14294
  const { continuationState, correlationId } = parameters;
14090
14295
  const context = this.createRequestContext(this.resolveStepApiId(continuationState.scenario, "submitPassword", correlationId), correlationId);
14091
- this.logger.verbose("Submitting V2 sign-in password.", correlationId);
14296
+ this.logger.verbose("Submitting V2 authentication password.", correlationId);
14092
14297
  return this.apiClient.verifyChallenge(this.requireLink(correlationId, continuationState.links.verify), {
14093
14298
  continuationToken: continuationState.continuationToken,
14094
14299
  password: parameters.password,
@@ -14098,9 +14303,8 @@
14098
14303
  return this.signInWithContinuation({
14099
14304
  correlationId,
14100
14305
  continuationState: {
14306
+ ...continuationState,
14101
14307
  continuationToken,
14102
- scenario: continuationState.scenario,
14103
- scopes: continuationState.scopes,
14104
14308
  links: {},
14105
14309
  },
14106
14310
  });
@@ -14129,18 +14333,14 @@
14129
14333
  }
14130
14334
  createChallengeContinuationState(continuationState, challengeResult) {
14131
14335
  return {
14336
+ ...continuationState,
14132
14337
  continuationToken: challengeResult.continuationToken,
14133
- scenario: continuationState.scenario,
14134
- scopes: continuationState.scopes,
14135
14338
  links: {
14136
14339
  challenge: continuationState.links.challenge,
14137
14340
  verify: challengeResult.verifyHref,
14138
14341
  resend: challengeResult.resendHref ??
14139
14342
  continuationState.links.resend,
14140
14343
  },
14141
- ...(continuationState.signUp && {
14142
- signUp: continuationState.signUp,
14143
- }),
14144
14344
  };
14145
14345
  }
14146
14346
  resolveStepApiId(scenario, step, correlationId, authenticationFactor) {
@@ -14170,8 +14370,7 @@
14170
14370
  */
14171
14371
  /**
14172
14372
  * Terminal state indicating the operation failed.
14173
- *
14174
- * The error is carried by the result's `error` payload, not by this state.
14373
+ * @warning This API is experimental. It may be changed in the future without notice. Do not use in production applications.
14175
14374
  */
14176
14375
  class FailedStateV2 extends AuthFlowStateBase {
14177
14376
  constructor() {
@@ -14184,8 +14383,14 @@
14184
14383
  * Copyright (c) Microsoft Corporation. All rights reserved.
14185
14384
  * Licensed under the MIT License.
14186
14385
  */
14386
+ const ATTRIBUTE_VALIDATION_ERROR = "attributeValidationError";
14187
14387
  const INVALID_ONE_TIME_CODE = "invalidOneTimeCode";
14188
14388
  const INVALID_USERNAME_OR_PASSWORD = "invalidUserNameOrPassword";
14389
+ const PASSWORD_BANNED = "passwordBanned";
14390
+ const PASSWORD_IS_INVALID = "passwordIsInvalid";
14391
+ const PASSWORD_RECENTLY_USED = "passwordRecentlyUsed";
14392
+ const PASSWORD_TOO_LONG = "passwordTooLong";
14393
+ const PASSWORD_TOO_SHORT = "passwordTooShort";
14189
14394
  const PASSWORD_TOO_WEAK = "passwordTooWeak";
14190
14395
  const USER_NOT_FOUND = "userNotFound";
14191
14396
 
@@ -14194,12 +14399,13 @@
14194
14399
  * Licensed under the MIT License.
14195
14400
  */
14196
14401
  /**
14197
- * Error returned by a native authentication V2 operation. Use its classifiers
14198
- * to handle known failures while retaining raw diagnostics through `errorData`.
14402
+ * Error returned by a native authentication V2 operation.
14403
+ * @warning This API is experimental. It may be changed in the future without notice. Do not use in production applications.
14199
14404
  */
14200
14405
  class AuthFlowErrorV2 {
14201
- constructor(errorData, scenario = CustomAuthFlowScenarioV2.Unknown) {
14406
+ constructor(errorData, scenario = CustomAuthFlowScenarioV2.Unknown, errorContext = "default") {
14202
14407
  this.errorData = errorData;
14408
+ this.errorContext = errorContext;
14203
14409
  this.scenario = scenario;
14204
14410
  }
14205
14411
  get correlationId() {
@@ -14216,123 +14422,111 @@
14216
14422
  ? this.errorData.innerErrorCode
14217
14423
  : undefined;
14218
14424
  }
14219
- /**
14220
- * Gets the attribute ids that the service reports as required.
14221
- */
14222
14425
  get requiredAttributes() {
14223
14426
  return this.getAttributeIdsByCode("attributeRequired");
14224
14427
  }
14225
- /**
14226
- * Gets the attribute ids whose submitted values failed validation.
14227
- */
14228
14428
  get invalidAttributes() {
14229
14429
  return this.getAttributeIdsByCode("attributeValidationFailed");
14230
14430
  }
14231
14431
  /**
14232
- * Checks if the error requires the flow to continue in the browser. The
14233
- * server surfaces this as the `web_redirect_required` OAuth suberror, so a
14234
- * browser hand-off arrives as a `FailedStateV2` on which this detector
14235
- * returns true.
14432
+ * Checks whether the flow must continue in the browser.
14236
14433
  * @returns True if the browser is required, false otherwise.
14237
14434
  */
14238
14435
  isBrowserRequired() {
14239
- return this.errorData.subError === WEB_REDIRECT_REQUIRED;
14436
+ return (this.errorData.error === "invalid_grant" &&
14437
+ this.errorData.subError === WEB_REDIRECT_REQUIRED);
14240
14438
  }
14241
14439
  /**
14242
- * Checks if the error is due to a caller-supplied argument failing
14243
- * client-side validation before the request was issued (for example an empty
14244
- * username, code, or password, or an unknown method id). Use it to prompt the
14245
- * user to correct the input rather than treating it as a server failure.
14440
+ * Checks whether a caller-supplied argument failed client-side validation.
14246
14441
  * @returns True if the input was invalid, false otherwise.
14247
14442
  */
14248
14443
  isInvalidInput() {
14249
14444
  return this.errorData instanceof InvalidArgumentError;
14250
14445
  }
14251
14446
  /**
14252
- * Checks whether the service rejected the username parameter. Use it to ask
14253
- * the user to correct the supplied username.
14254
- * @returns True when the username is invalid, otherwise false.
14447
+ * Checks whether the supplied username failed local validation.
14448
+ * @returns True when local username validation failed.
14255
14449
  */
14256
14450
  isInvalidUsername() {
14257
- return this.isUserInvalidError();
14451
+ return (this.errorData instanceof InvalidArgumentError &&
14452
+ this.errorData.argName === "inputs.username");
14258
14453
  }
14259
14454
  /**
14260
- * Checks whether the supplied username does not identify an account. Use it
14261
- * to distinguish a missing account from other request failures.
14455
+ * Checks whether the supplied username does not identify an account.
14262
14456
  * @returns True when the service reports that the user was not found.
14263
14457
  */
14264
14458
  isUserNotFound() {
14265
14459
  return this.isUserNotFoundError();
14266
14460
  }
14267
14461
  /**
14268
- * Checks whether the service rejected the supplied sign-in credentials. This
14269
- * classifier does not identify new-password policy failures.
14270
- * @returns True when the username or password is incorrect.
14271
- */
14272
- isInvalidCredentials() {
14273
- return this.isPasswordIncorrectError();
14274
- }
14275
- /**
14276
- * Checks whether the service rejected a one-time code. Use it to prompt the
14277
- * user to re-enter the code or request a new one.
14462
+ * Checks whether the service rejected a one-time code.
14278
14463
  * @returns True when the one-time code is invalid, otherwise false.
14279
14464
  */
14280
14465
  isInvalidCode() {
14281
- return this.isInvalidCodeError();
14466
+ return this.errorContext === "default" && this.isInvalidCodeError();
14282
14467
  }
14283
14468
  /**
14284
- * Checks whether a new password violates password policy. It recognizes
14285
- * both weak-password responses and password-targeted validation details.
14286
- * @returns True when the new password is invalid, otherwise false.
14469
+ * Checks whether the service rejected an MFA or registration challenge.
14470
+ * @returns True when the verification challenge is invalid.
14287
14471
  */
14288
- isInvalidPassword() {
14289
- return (this.isInvalidPasswordError() ||
14290
- this.isPasswordPolicyViolationError());
14472
+ isInvalidChallenge() {
14473
+ return ((this.errorContext === "mfaVerification" ||
14474
+ this.errorContext === "authMethodRegistration") &&
14475
+ this.isInvalidCodeError());
14291
14476
  }
14292
14477
  /**
14293
- * Checks whether an account already exists for the supplied identifier.
14294
- * This can occur at different stages while completing sign-up.
14295
- * @returns True if the account already exists, otherwise false.
14478
+ * Checks whether the service rejected non-password attributes.
14479
+ * Password-targeted validation is reported only by isInvalidPassword().
14480
+ * @returns True when at least one non-password attribute is invalid.
14296
14481
  */
14297
- isUserAlreadyExists() {
14298
- return this.getAttributeValidationDetails().some((detail) => detail.code === "userAlreadyExists");
14482
+ isInvalidAttributes() {
14483
+ if (!this.isAttributeValidationError() ||
14484
+ this.isPasswordAttributeValidationError()) {
14485
+ return false;
14486
+ }
14487
+ const attributeIds = this.getAttributeValidationDetails()
14488
+ .flatMap((detail) => Array.isArray(detail.attributeIds) ? detail.attributeIds : [])
14489
+ .filter((attributeId) => typeof attributeId === "string");
14490
+ return attributeIds.some((attributeId) => attributeId.length > 0);
14299
14491
  }
14300
14492
  /**
14301
- * Checks whether the service requires attributes omitted from the request.
14302
- * Use it to collect the required attributes before resubmitting.
14303
- * @returns True when required attributes are missing, otherwise false.
14493
+ * Checks whether the service rejected a supplied password.
14494
+ * @returns True when the supplied password is invalid, otherwise false.
14304
14495
  */
14305
- isMissingRequiredAttributes() {
14306
- return this.requiredAttributes.length > 0;
14496
+ isInvalidPassword() {
14497
+ return (this.isPasswordIncorrectError() ||
14498
+ this.isInvalidPasswordError() ||
14499
+ this.isPasswordAttributeValidationError());
14307
14500
  }
14308
- isUserNotFoundError() {
14501
+ isAttributeValidationError() {
14309
14502
  return (this.errorData.error === "invalidRequest" &&
14310
- (this.innerErrorCode === USER_NOT_FOUND ||
14311
- this.errorData.errorDescription?.includes("AADSTS50034") ===
14312
- true));
14503
+ this.innerErrorCode === ATTRIBUTE_VALIDATION_ERROR);
14313
14504
  }
14314
- isUserInvalidError() {
14505
+ isUserNotFoundError() {
14315
14506
  return (this.errorData.error === "invalidRequest" &&
14316
- this.errorData.errorDescription?.includes("AADSTS90100") === true &&
14317
- this.errorData.errorDescription
14318
- .toLowerCase()
14319
- .includes("username parameter"));
14507
+ this.innerErrorCode === USER_NOT_FOUND);
14320
14508
  }
14321
14509
  isInvalidCodeError() {
14322
14510
  return (this.errorData.error === "invalidGrant" &&
14323
14511
  this.innerErrorCode === INVALID_ONE_TIME_CODE);
14324
14512
  }
14325
14513
  isInvalidPasswordError() {
14514
+ const innerErrorCode = this.innerErrorCode;
14326
14515
  return (this.errorData.error === "invalidRequest" &&
14327
- this.innerErrorCode === PASSWORD_TOO_WEAK);
14328
- }
14329
- isPasswordPolicyViolationError() {
14330
- return this.getAttributeValidationDetails().some((detail) => {
14516
+ (innerErrorCode === PASSWORD_TOO_WEAK ||
14517
+ innerErrorCode === PASSWORD_TOO_SHORT ||
14518
+ innerErrorCode === PASSWORD_TOO_LONG ||
14519
+ innerErrorCode === PASSWORD_IS_INVALID ||
14520
+ innerErrorCode === PASSWORD_RECENTLY_USED ||
14521
+ innerErrorCode === PASSWORD_BANNED));
14522
+ }
14523
+ isPasswordAttributeValidationError() {
14524
+ if (!this.isAttributeValidationError()) {
14525
+ return false;
14526
+ }
14527
+ return this.getAttributeValidationDetails().some((detail) => {
14331
14528
  const attributeIds = detail.attributeIds;
14332
- return (detail.code === "passwordPolicyViolation" &&
14333
- Array.isArray(attributeIds) &&
14334
- attributeIds.some((attributeId) => typeof attributeId === "string" &&
14335
- attributeId.toLowerCase() === "password"));
14529
+ return (Array.isArray(attributeIds) && attributeIds.includes("password"));
14336
14530
  });
14337
14531
  }
14338
14532
  isPasswordIncorrectError() {
@@ -14358,8 +14552,8 @@
14358
14552
  * Licensed under the MIT License.
14359
14553
  */
14360
14554
  /**
14361
- * Result of a native auth V2 operation. Use {@link CustomAuthResultV2.isState}
14362
- * to narrow the state before accessing its members.
14555
+ * Result of a native auth V2 operation.
14556
+ * @warning This API is experimental. It may be changed in the future without notice. Do not use in production applications.
14363
14557
  */
14364
14558
  class CustomAuthResultV2 {
14365
14559
  constructor(state, data, scenario = CustomAuthFlowScenarioV2.Unknown) {
@@ -14368,8 +14562,7 @@
14368
14562
  this.scenario = scenario;
14369
14563
  }
14370
14564
  /**
14371
- * Narrows the result to a specific state by its `stateType` discriminator.
14372
- * A successful match makes the state's properties available without a cast.
14565
+ * Checks whether the result matches a state type and narrows its state.
14373
14566
  * @param stateType - The state type to test for.
14374
14567
  * @returns True (and narrows `state`) when the current state matches `stateType`.
14375
14568
  */
@@ -14377,25 +14570,32 @@
14377
14570
  return this.state.stateType === stateType;
14378
14571
  }
14379
14572
  /**
14380
- * Checks whether the result is in the terminal failed state. A failed result
14381
- * contains the unified V2 flow error.
14573
+ * Checks whether the operation failed.
14382
14574
  * @returns True (and narrows `state`) when the operation failed.
14383
14575
  */
14384
14576
  isFailed() {
14385
14577
  return this.state.stateType === "failed";
14386
14578
  }
14387
14579
  /**
14388
- * Creates a failed result from the supplied error. The result uses the
14389
- * shared {@link FailedStateV2} terminal state and unified V2 flow error.
14580
+ * Checks whether the current state requires a password.
14581
+ * @returns True (and narrows `state`) when a password is required.
14582
+ */
14583
+ isPasswordRequired() {
14584
+ return this.state.stateType === "passwordRequired";
14585
+ }
14586
+ /**
14587
+ * Creates a failed result from the supplied error.
14588
+ * Optional error context identifies MFA verification or authentication-method registration.
14390
14589
  * @param error - The error that occurred.
14391
14590
  * @param options - The flow-error context.
14392
14591
  * @returns A failed result carrying the unified V2 flow error.
14393
14592
  */
14394
14593
  static createWithError(error, options) {
14395
- const { scenario = CustomAuthFlowScenarioV2.Unknown, correlationId } = options;
14396
- const errorData = CustomAuthResultV2.createErrorData(error, correlationId);
14397
- const flowError = new AuthFlowErrorV2(errorData, scenario);
14398
- const result = new CustomAuthResultV2(new FailedStateV2(), undefined, scenario);
14594
+ const { correlationId } = options;
14595
+ const flowError = error instanceof AuthFlowErrorV2
14596
+ ? error
14597
+ : new AuthFlowErrorV2(CustomAuthResultV2.createErrorData(error, correlationId), options.scenario ?? CustomAuthFlowScenarioV2.Unknown, options.errorContext);
14598
+ const result = new CustomAuthResultV2(new FailedStateV2(), undefined, flowError.scenario);
14399
14599
  result.error = flowError;
14400
14600
  return result;
14401
14601
  }
@@ -14428,9 +14628,7 @@
14428
14628
  */
14429
14629
  /**
14430
14630
  * Terminal state indicating the operation completed successfully.
14431
- *
14432
- * Completion data (for example the signed-in account) is carried by the
14433
- * result's `data` payload, not by this state.
14631
+ * @warning This API is experimental. It may be changed in the future without notice. Do not use in production applications.
14434
14632
  */
14435
14633
  class CompletedStateV2 extends AuthFlowStateBase {
14436
14634
  constructor() {
@@ -14439,6 +14637,74 @@
14439
14637
  }
14440
14638
  }
14441
14639
 
14640
+ /*
14641
+ * Copyright (c) Microsoft Corporation. All rights reserved.
14642
+ * Licensed under the MIT License.
14643
+ */
14644
+ /**
14645
+ * State returned when a completed V2 flow can sign the user in.
14646
+ * @warning This API is experimental. It may be changed in the future without notice. Do not use in production applications.
14647
+ */
14648
+ class SignInContinuationStateV2 extends AuthFlowActionRequiredStateBase {
14649
+ constructor() {
14650
+ super(...arguments);
14651
+ this.stateType = "signInContinuation";
14652
+ }
14653
+ /**
14654
+ * Signs the user in after completing the V2 flow.
14655
+ * @returns The result of completing the continuation sign-in.
14656
+ */
14657
+ async signIn() {
14658
+ const { correlationId, logger, continuationState, flowClient } = this.stateParameters;
14659
+ try {
14660
+ logger.verbose("Signing in with a V2 continuation.", correlationId);
14661
+ const result = await flowClient.signInWithContinuation({
14662
+ correlationId,
14663
+ continuationState,
14664
+ });
14665
+ const account = new CustomAuthAccountData(result.authenticationResult.account, this.stateParameters.config, this.stateParameters.cacheClient, logger, correlationId);
14666
+ return new CustomAuthResultV2(new CompletedStateV2(), account, continuationState.scenario);
14667
+ }
14668
+ catch (error) {
14669
+ logger.errorPii(`Failed to sign in with a V2 continuation. Error: '${error}'.`, correlationId);
14670
+ return CustomAuthResultV2.createWithError(error, {
14671
+ scenario: continuationState.scenario,
14672
+ correlationId,
14673
+ });
14674
+ }
14675
+ }
14676
+ }
14677
+
14678
+ /*
14679
+ * Copyright (c) Microsoft Corporation. All rights reserved.
14680
+ * Licensed under the MIT License.
14681
+ */
14682
+ class ChallengeVerificationStateBaseV2 extends AuthFlowActionRequiredStateBase {
14683
+ constructor(stateParameters) {
14684
+ super(stateParameters);
14685
+ this.method = stateParameters.method;
14686
+ this.sentTo = stateParameters.sentTo;
14687
+ this.channel = stateParameters.channel;
14688
+ this.codeLength = stateParameters.codeLength;
14689
+ }
14690
+ async submitCodeCore(code, authenticationFactor) {
14691
+ ensureArgumentIsNotNullOrUndefined("code", code, this.stateParameters.correlationId);
14692
+ return this.stateParameters.flowClient.submitCode({
14693
+ correlationId: this.stateParameters.correlationId,
14694
+ continuationState: this.stateParameters.continuationState,
14695
+ authenticationFactor,
14696
+ code,
14697
+ });
14698
+ }
14699
+ async resendCodeCore(authenticationFactor) {
14700
+ return this.stateParameters.flowClient.resendCode({
14701
+ correlationId: this.stateParameters.correlationId,
14702
+ continuationState: this.stateParameters.continuationState,
14703
+ authenticationFactor,
14704
+ });
14705
+ }
14706
+ }
14707
+
14442
14708
  /*
14443
14709
  * Copyright (c) Microsoft Corporation. All rights reserved.
14444
14710
  * Licensed under the MIT License.
@@ -14446,6 +14712,7 @@
14446
14712
  /**
14447
14713
  * State returned when a newly registered authentication method must be
14448
14714
  * activated with the challenge sent by the service.
14715
+ * @warning This API is experimental. It may be changed in the future without notice. Do not use in production applications.
14449
14716
  */
14450
14717
  class AuthMethodVerificationRequiredStateV2 extends AuthFlowActionRequiredStateBase {
14451
14718
  constructor(stateParameters) {
@@ -14458,7 +14725,7 @@
14458
14725
  /**
14459
14726
  * Submits the activation challenge for the registered method.
14460
14727
  * @param challenge - The activation challenge to submit.
14461
- * @returns The completed authentication result or a failed state.
14728
+ * @returns A sign-in continuation, completed authentication result, or failed state.
14462
14729
  */
14463
14730
  async submitChallenge(challenge) {
14464
14731
  const { correlationId, continuationState, flowClient, logger } = this.stateParameters;
@@ -14470,6 +14737,16 @@
14470
14737
  continuationState,
14471
14738
  code: challenge,
14472
14739
  });
14740
+ if (result.type === FLOW_SIGN_IN_CONTINUATION_REQUIRED_V2) {
14741
+ return new CustomAuthResultV2(new SignInContinuationStateV2({
14742
+ correlationId: result.correlationId,
14743
+ logger,
14744
+ config: this.stateParameters.config,
14745
+ flowClient,
14746
+ continuationState: result.continuationState,
14747
+ cacheClient: this.stateParameters.cacheClient,
14748
+ }), undefined, result.continuationState.scenario);
14749
+ }
14473
14750
  const account = new CustomAuthAccountData(result.authenticationResult.account, this.stateParameters.config, this.stateParameters.cacheClient, logger, correlationId);
14474
14751
  return new CustomAuthResultV2(new CompletedStateV2(), account, continuationState.scenario);
14475
14752
  }
@@ -14478,12 +14755,12 @@
14478
14755
  return CustomAuthResultV2.createWithError(error, {
14479
14756
  scenario: continuationState.scenario,
14480
14757
  correlationId,
14758
+ errorContext: "authMethodRegistration",
14481
14759
  });
14482
14760
  }
14483
14761
  }
14484
14762
  /**
14485
- * Requests a replacement activation challenge using the retained server
14486
- * resend link.
14763
+ * Requests a replacement activation challenge for the registered method.
14487
14764
  * @returns Refreshed activation metadata or a failed state.
14488
14765
  */
14489
14766
  async resendChallenge() {
@@ -14521,8 +14798,8 @@
14521
14798
  * Licensed under the MIT License.
14522
14799
  */
14523
14800
  /**
14524
- * State returned when an authentication method must be registered. Applications
14525
- * select one of the sanitized offered methods and provide its contact value.
14801
+ * State returned when an authentication method must be registered.
14802
+ * @warning This API is experimental. It may be changed in the future without notice. Do not use in production applications.
14526
14803
  */
14527
14804
  class AuthMethodRegistrationRequiredStateV2 extends AuthFlowActionRequiredStateBase {
14528
14805
  constructor(stateParameters) {
@@ -14579,143 +14856,8 @@
14579
14856
  * Licensed under the MIT License.
14580
14857
  */
14581
14858
  /**
14582
- * Shared state returned when a completed V2 flow can sign the user in by
14583
- * redeeming its continuation. Password reset and sign-up can both surface this
14584
- * state without duplicating the token-acquisition behavior.
14585
- */
14586
- class SignInContinuationStateV2 extends AuthFlowActionRequiredStateBase {
14587
- constructor() {
14588
- super(...arguments);
14589
- this.stateType = "signInContinuation";
14590
- }
14591
- /**
14592
- * Signs the user in using the continuation established by the completed V2
14593
- * flow. The result either reaches the completed state with the signed-in
14594
- * account data or reports why the follow-up sign-in could not complete.
14595
- * @returns The result of completing the continuation sign-in.
14596
- */
14597
- async signIn() {
14598
- const { correlationId, logger, continuationState, flowClient } = this.stateParameters;
14599
- try {
14600
- logger.verbose("Signing in with a V2 continuation.", correlationId);
14601
- const result = await flowClient.signInWithContinuation({
14602
- correlationId,
14603
- continuationState,
14604
- });
14605
- const account = new CustomAuthAccountData(result.authenticationResult.account, this.stateParameters.config, this.stateParameters.cacheClient, logger, correlationId);
14606
- return new CustomAuthResultV2(new CompletedStateV2(), account, continuationState.scenario);
14607
- }
14608
- catch (error) {
14609
- logger.errorPii(`Failed to sign in with a V2 continuation. Error: '${error}'.`, correlationId);
14610
- return CustomAuthResultV2.createWithError(error, {
14611
- scenario: continuationState.scenario,
14612
- correlationId,
14613
- });
14614
- }
14615
- }
14616
- }
14617
-
14618
- /*
14619
- * Copyright (c) Microsoft Corporation. All rights reserved.
14620
- * Licensed under the MIT License.
14621
- */
14622
- /**
14623
- * State returned when the user must supply a new password to complete the flow.
14624
- * A successful submission can require registration or return a continuation
14625
- * for sign-in.
14626
- */
14627
- class NewPasswordRequiredStateV2 extends AuthFlowActionRequiredStateBase {
14628
- constructor() {
14629
- super(...arguments);
14630
- this.stateType = "newPasswordRequired";
14631
- }
14632
- /**
14633
- * Submits the new password to complete the reset. Enrollment may be
14634
- * required before sign-in; a rejected password returns an error.
14635
- * @param password - The new password to set.
14636
- * @returns The result of submitting the new password.
14637
- */
14638
- async submitNewPassword(password) {
14639
- const { correlationId, logger, continuationState, flowClient } = this.stateParameters;
14640
- try {
14641
- this.ensurePasswordIsNotEmpty(password);
14642
- logger.verbose("Submitting V2 new password.", correlationId);
14643
- const result = await flowClient.submitNewPassword({
14644
- correlationId,
14645
- continuationState,
14646
- newPassword: password,
14647
- });
14648
- const resultType = result.type;
14649
- if (result.type === FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2) {
14650
- return new CustomAuthResultV2(new AuthMethodRegistrationRequiredStateV2({
14651
- correlationId: result.correlationId,
14652
- logger,
14653
- config: this.stateParameters.config,
14654
- flowClient,
14655
- continuationState: result.continuationState,
14656
- cacheClient: this.stateParameters.cacheClient,
14657
- methods: result.methods,
14658
- }), undefined, result.continuationState.scenario);
14659
- }
14660
- if (result.type === FLOW_SIGN_IN_CONTINUATION_REQUIRED_V2) {
14661
- return new CustomAuthResultV2(new SignInContinuationStateV2({
14662
- correlationId: result.correlationId,
14663
- logger,
14664
- config: this.stateParameters.config,
14665
- flowClient,
14666
- continuationState: result.continuationState,
14667
- cacheClient: this.stateParameters.cacheClient,
14668
- }), undefined, result.continuationState.scenario);
14669
- }
14670
- throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, `Password submission result type '${resultType}' is not supported.`, correlationId);
14671
- }
14672
- catch (error) {
14673
- logger.errorPii(`Failed to submit V2 new password. Error: '${error}'.`, correlationId);
14674
- return CustomAuthResultV2.createWithError(error, {
14675
- scenario: continuationState.scenario,
14676
- correlationId,
14677
- });
14678
- }
14679
- }
14680
- }
14681
-
14682
- /*
14683
- * Copyright (c) Microsoft Corporation. All rights reserved.
14684
- * Licensed under the MIT License.
14685
- */
14686
- class ChallengeVerificationStateBaseV2 extends AuthFlowActionRequiredStateBase {
14687
- constructor(stateParameters) {
14688
- super(stateParameters);
14689
- this.method = stateParameters.method;
14690
- this.sentTo = stateParameters.sentTo;
14691
- this.channel = stateParameters.channel;
14692
- this.codeLength = stateParameters.codeLength;
14693
- }
14694
- async submitCodeCore(code, authenticationFactor) {
14695
- ensureArgumentIsNotNullOrUndefined("code", code, this.stateParameters.correlationId);
14696
- return this.stateParameters.flowClient.submitCode({
14697
- correlationId: this.stateParameters.correlationId,
14698
- continuationState: this.stateParameters.continuationState,
14699
- authenticationFactor,
14700
- code,
14701
- });
14702
- }
14703
- async resendCodeCore(authenticationFactor) {
14704
- return this.stateParameters.flowClient.resendCode({
14705
- correlationId: this.stateParameters.correlationId,
14706
- continuationState: this.stateParameters.continuationState,
14707
- authenticationFactor,
14708
- });
14709
- }
14710
- }
14711
-
14712
- /*
14713
- * Copyright (c) Microsoft Corporation. All rights reserved.
14714
- * Licensed under the MIT License.
14715
- */
14716
- /**
14717
- * State returned when first-factor email authentication requires a one-time
14718
- * code. It allows the app to submit the code or request a replacement.
14859
+ * State returned when first-factor authentication requires a one-time code.
14860
+ * @warning This API is experimental. It may be changed in the future without notice. Do not use in production applications.
14719
14861
  */
14720
14862
  class CodeRequiredStateV2 extends ChallengeVerificationStateBaseV2 {
14721
14863
  constructor() {
@@ -14723,8 +14865,7 @@
14723
14865
  this.stateType = "codeRequired";
14724
14866
  }
14725
14867
  /**
14726
- * Submits the first-factor email code and advances the active flow. The
14727
- * result may complete the operation or require another flow-specific step.
14868
+ * Submits the first-factor code.
14728
14869
  * @param code - The code to submit.
14729
14870
  * @returns The result of submitting the first-factor code.
14730
14871
  */
@@ -14735,14 +14876,11 @@
14735
14876
  const result = await this.submitCodeCore(code);
14736
14877
  const resultType = result.type;
14737
14878
  if (result.type === FLOW_NEW_PASSWORD_REQUIRED_V2) {
14738
- return new CustomAuthResultV2(new NewPasswordRequiredStateV2({
14739
- correlationId: result.correlationId,
14740
- logger,
14741
- config: this.stateParameters.config,
14742
- flowClient: this.stateParameters.flowClient,
14743
- continuationState: result.continuationState,
14744
- cacheClient: this.stateParameters.cacheClient,
14745
- }), undefined, result.continuationState.scenario);
14879
+ const resetPasswordStateTransitionHandler = this.stateParameters.resetPasswordStateTransitionHandler;
14880
+ if (!resetPasswordStateTransitionHandler) {
14881
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, "Password-reset state transition handler is missing.", correlationId);
14882
+ }
14883
+ return resetPasswordStateTransitionHandler.handleNewPasswordRequired(result, this.stateParameters);
14746
14884
  }
14747
14885
  if (result.type === FLOW_ATTRIBUTES_REQUIRED_V2 ||
14748
14886
  result.type === FLOW_SIGN_UP_PASSWORD_REQUIRED_V2) {
@@ -14750,10 +14888,10 @@
14750
14888
  if (!signUpStateTransitionHandler) {
14751
14889
  throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, "Sign-up state transition handler is missing.", correlationId);
14752
14890
  }
14753
- return signUpStateTransitionHandler.handleVerification(result, {
14891
+ return signUpStateTransitionHandler.handleAttributeSubmission(result, {
14754
14892
  ...this.stateParameters,
14755
14893
  signUpStateTransitionHandler,
14756
- });
14894
+ }, "attribute");
14757
14895
  }
14758
14896
  if (result.type === FLOW_SIGN_IN_CONTINUATION_REQUIRED_V2) {
14759
14897
  return new CustomAuthResultV2(new SignInContinuationStateV2({
@@ -14798,8 +14936,7 @@
14798
14936
  }
14799
14937
  }
14800
14938
  /**
14801
- * Requests a replacement first-factor email code. The returned state
14802
- * contains the refreshed challenge metadata.
14939
+ * Requests a replacement first-factor code.
14803
14940
  * @returns The result of requesting a replacement code.
14804
14941
  */
14805
14942
  async resendCode() {
@@ -14816,6 +14953,8 @@
14816
14953
  cacheClient: this.stateParameters.cacheClient,
14817
14954
  signUpStateTransitionHandler: this.stateParameters.signUpStateTransitionHandler,
14818
14955
  signInStateTransitionHandler: this.stateParameters.signInStateTransitionHandler,
14956
+ resetPasswordStateTransitionHandler: this.stateParameters
14957
+ .resetPasswordStateTransitionHandler,
14819
14958
  method: this.method,
14820
14959
  sentTo: result.sentTo,
14821
14960
  channel: result.channel,
@@ -14837,8 +14976,9 @@
14837
14976
  * Licensed under the MIT License.
14838
14977
  */
14839
14978
  /**
14840
- * State returned when sign-in requires verification of an email or SMS MFA
14979
+ * State returned when authentication requires verification of an email or SMS MFA
14841
14980
  * challenge. It allows the app to submit the challenge or request a replacement.
14981
+ * @warning This API is experimental. It may be changed in the future without notice. Do not use in production applications.
14842
14982
  */
14843
14983
  class MFAVerificationRequiredStateV2 extends ChallengeVerificationStateBaseV2 {
14844
14984
  constructor() {
@@ -14847,7 +14987,6 @@
14847
14987
  }
14848
14988
  /**
14849
14989
  * Submits the email or SMS challenge as the second authentication factor.
14850
- * Successful verification completes sign-in.
14851
14990
  * @param challenge - The challenge value to submit.
14852
14991
  * @returns The result of submitting the MFA challenge.
14853
14992
  */
@@ -14856,6 +14995,16 @@
14856
14995
  try {
14857
14996
  logger.verbose("Submitting V2 MFA challenge.", correlationId);
14858
14997
  const result = await this.submitCodeCore(challenge, AuthenticationFactorV2.MULTI_FACTOR);
14998
+ if (result.type === FLOW_SIGN_IN_CONTINUATION_REQUIRED_V2) {
14999
+ return new CustomAuthResultV2(new SignInContinuationStateV2({
15000
+ correlationId: result.correlationId,
15001
+ logger,
15002
+ config: this.stateParameters.config,
15003
+ flowClient: this.stateParameters.flowClient,
15004
+ continuationState: result.continuationState,
15005
+ cacheClient: this.stateParameters.cacheClient,
15006
+ }), undefined, result.continuationState.scenario);
15007
+ }
14859
15008
  if (result.type !== FLOW_COMPLETED_V2) {
14860
15009
  throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, `MFA challenge submission result type '${result.type}' is not supported.`, correlationId);
14861
15010
  }
@@ -14867,12 +15016,12 @@
14867
15016
  return CustomAuthResultV2.createWithError(error, {
14868
15017
  scenario: continuationState.scenario,
14869
15018
  correlationId,
15019
+ errorContext: "mfaVerification",
14870
15020
  });
14871
15021
  }
14872
15022
  }
14873
15023
  /**
14874
- * Requests a replacement challenge for the selected MFA method. The
14875
- * returned state contains the refreshed email or SMS challenge metadata.
15024
+ * Requests a replacement challenge for the selected MFA method.
14876
15025
  * @returns The result of requesting a replacement MFA challenge.
14877
15026
  */
14878
15027
  async resendChallenge() {
@@ -14903,15 +15052,157 @@
14903
15052
  }
14904
15053
  }
14905
15054
 
15055
+ /*
15056
+ * Copyright (c) Microsoft Corporation. All rights reserved.
15057
+ * Licensed under the MIT License.
15058
+ */
15059
+ function handleExistingAccountVerificationResultV2(result, stateParameters) {
15060
+ const commonStateParameters = {
15061
+ correlationId: result.correlationId,
15062
+ logger: stateParameters.logger,
15063
+ config: stateParameters.config,
15064
+ flowClient: stateParameters.flowClient,
15065
+ continuationState: "continuationState" in result
15066
+ ? result.continuationState
15067
+ : stateParameters.continuationState,
15068
+ cacheClient: stateParameters.cacheClient,
15069
+ };
15070
+ if (result.type === FLOW_COMPLETED_V2) {
15071
+ const account = new CustomAuthAccountData(result.authenticationResult.account, stateParameters.config, stateParameters.cacheClient, stateParameters.logger, result.correlationId);
15072
+ return new CustomAuthResultV2(new CompletedStateV2(), account, stateParameters.continuationState.scenario);
15073
+ }
15074
+ if (result.type === FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2) {
15075
+ return new CustomAuthResultV2(new AuthMethodRegistrationRequiredStateV2({
15076
+ ...commonStateParameters,
15077
+ continuationState: result.continuationState,
15078
+ methods: result.methods,
15079
+ }), undefined, result.continuationState.scenario);
15080
+ }
15081
+ if (result.type === FLOW_MFA_REQUIRED_V2) {
15082
+ const signInStateTransitionHandler = stateParameters.signInStateTransitionHandler;
15083
+ if (!signInStateTransitionHandler) {
15084
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, "Sign-in state transition handler is missing.", stateParameters.correlationId);
15085
+ }
15086
+ return signInStateTransitionHandler.handleMfaRequired(result, stateParameters);
15087
+ }
15088
+ const resultType = result.type;
15089
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, `Existing-account verification result type '${resultType}' is not supported.`, stateParameters.correlationId);
15090
+ }
15091
+
15092
+ /*
15093
+ * Copyright (c) Microsoft Corporation. All rights reserved.
15094
+ * Licensed under the MIT License.
15095
+ */
15096
+ /**
15097
+ * State returned when sign-up discovers an existing account that requires an
15098
+ * email code. Submitting or resending the code preserves existing-account authentication.
15099
+ */
15100
+ class ExistingAccountCodeRequiredStateV2 extends ChallengeVerificationStateBaseV2 {
15101
+ constructor() {
15102
+ super(...arguments);
15103
+ this.stateType = "existingAccountCodeRequired";
15104
+ }
15105
+ /**
15106
+ * Submits the existing account's email code and continues authentication.
15107
+ * The result can complete authentication or require enrollment or MFA.
15108
+ * @param code - The email code to verify.
15109
+ * @returns The next existing-account authentication result.
15110
+ */
15111
+ async submitCode(code) {
15112
+ const { correlationId, logger, continuationState } = this.stateParameters;
15113
+ try {
15114
+ const result = await this.submitCodeCore(code);
15115
+ if (result.type === FLOW_COMPLETED_V2 ||
15116
+ result.type === FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2 ||
15117
+ result.type === FLOW_MFA_REQUIRED_V2) {
15118
+ return handleExistingAccountVerificationResultV2(result, this.stateParameters);
15119
+ }
15120
+ const resultType = result.type;
15121
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, `Existing-account code submission result type '${resultType}' is not supported.`, correlationId);
15122
+ }
15123
+ catch (error) {
15124
+ logger.errorPii(`Failed to submit V2 existing-account code. Error: '${error}'.`, correlationId);
15125
+ return CustomAuthResultV2.createWithError(error, {
15126
+ scenario: continuationState.scenario,
15127
+ correlationId,
15128
+ });
15129
+ }
15130
+ }
15131
+ /**
15132
+ * Requests a replacement email code for the existing account. The returned
15133
+ * state contains the fresh continuation token and challenge metadata.
15134
+ * @returns The refreshed existing-account code state or an error.
15135
+ */
15136
+ async resendCode() {
15137
+ const { correlationId, logger, continuationState } = this.stateParameters;
15138
+ try {
15139
+ const result = await this.resendCodeCore();
15140
+ return new CustomAuthResultV2(new ExistingAccountCodeRequiredStateV2({
15141
+ ...this.stateParameters,
15142
+ correlationId: result.correlationId,
15143
+ continuationState: result.continuationState,
15144
+ sentTo: result.sentTo,
15145
+ channel: result.channel,
15146
+ codeLength: result.codeLength,
15147
+ }), undefined, result.continuationState.scenario);
15148
+ }
15149
+ catch (error) {
15150
+ logger.errorPii(`Failed to resend V2 existing-account code. Error: '${error}'.`, correlationId);
15151
+ return CustomAuthResultV2.createWithError(error, {
15152
+ scenario: continuationState.scenario,
15153
+ correlationId,
15154
+ });
15155
+ }
15156
+ }
15157
+ }
15158
+
15159
+ /*
15160
+ * Copyright (c) Microsoft Corporation. All rights reserved.
15161
+ * Licensed under the MIT License.
15162
+ */
15163
+ /**
15164
+ * State returned when sign-up discovers an existing account that requires its
15165
+ * current password. The password is verified as an authentication credential.
15166
+ */
15167
+ class ExistingAccountPasswordRequiredStateV2 extends AuthFlowActionRequiredStateBase {
15168
+ constructor() {
15169
+ super(...arguments);
15170
+ this.stateType = "existingAccountPasswordRequired";
15171
+ }
15172
+ /**
15173
+ * Verifies the existing account's current password and continues authentication.
15174
+ * The result can complete authentication or require enrollment or MFA.
15175
+ * @param password - The existing account password.
15176
+ * @returns The next existing-account authentication result.
15177
+ */
15178
+ async submitPassword(password) {
15179
+ const { correlationId, logger, continuationState, flowClient } = this.stateParameters;
15180
+ try {
15181
+ this.ensurePasswordIsNotEmpty(password);
15182
+ const result = await flowClient.submitSignInPassword({
15183
+ correlationId,
15184
+ continuationState,
15185
+ password,
15186
+ });
15187
+ return handleExistingAccountVerificationResultV2(result, this.stateParameters);
15188
+ }
15189
+ catch (error) {
15190
+ logger.errorPii(`Failed to submit V2 existing-account password. Error: '${error}'.`, correlationId);
15191
+ return CustomAuthResultV2.createWithError(error, {
15192
+ scenario: continuationState.scenario,
15193
+ correlationId,
15194
+ });
15195
+ }
15196
+ }
15197
+ }
15198
+
14906
15199
  /*
14907
15200
  * Copyright (c) Microsoft Corporation. All rights reserved.
14908
15201
  * Licensed under the MIT License.
14909
15202
  */
14910
15203
  /**
14911
- * State returned when the user must select one of several authentication
14912
- * methods before a challenge can be issued. It exposes the list of offered
14913
- * methods and lets the app request a challenge for the chosen one. The flow
14914
- * stays on this state until a challenge is successfully requested.
15204
+ * State returned when the user must select an authentication method.
15205
+ * @warning This API is experimental. It may be changed in the future without notice. Do not use in production applications.
14915
15206
  */
14916
15207
  class AuthMethodSelectionRequiredStateV2 extends AuthFlowActionRequiredStateBase {
14917
15208
  constructor(stateParameters) {
@@ -14920,13 +15211,12 @@
14920
15211
  this.methods = stateParameters.methods;
14921
15212
  }
14922
15213
  /**
14923
- * Selects an authentication method and requests its challenge. The returned
14924
- * state identifies the credential the application must collect.
15214
+ * Selects an authentication method and requests its challenge.
14925
15215
  * @param method - The method to select, from {@link methods}.
14926
15216
  * @returns The result of selecting the method and requesting its challenge.
14927
15217
  */
14928
15218
  async selectAuthMethod(method) {
14929
- const { authenticationFactor, correlationId, logger, continuationState, flowClient, signInStateTransitionHandler, } = this.stateParameters;
15219
+ const { authenticationFactor, correlationId, logger, continuationState, flowClient, signInStateTransitionHandler, resetPasswordStateTransitionHandler, } = this.stateParameters;
14930
15220
  try {
14931
15221
  logger.verbose("Requesting challenge for the selected V2 method.", correlationId);
14932
15222
  const { result, selectedMethod } = await this.requestSelectedMethodChallenge(method);
@@ -14937,22 +15227,45 @@
14937
15227
  flowClient,
14938
15228
  continuationState: result.continuationState,
14939
15229
  cacheClient: this.stateParameters.cacheClient,
15230
+ signInStateTransitionHandler,
14940
15231
  };
14941
- if (authenticationFactor === AuthenticationFactorV2.SINGLE_FACTOR &&
15232
+ const isExistingAccountSignUp = continuationState.scenario ===
15233
+ CustomAuthFlowScenarioV2.SignUp &&
15234
+ continuationState.signUp?.purpose === "existingAccount";
15235
+ const channel = result.type === FLOW_CODE_REQUIRED_V2
15236
+ ? result.channel?.toLowerCase()
15237
+ : undefined;
15238
+ if (isExistingAccountSignUp &&
15239
+ authenticationFactor === AuthenticationFactorV2.SINGLE_FACTOR &&
14942
15240
  result.type === FLOW_CODE_REQUIRED_V2 &&
14943
- (result.channel?.toLowerCase() ===
14944
- AuthenticationMethodTypeV2.EMAIL ||
14945
- result.channel?.toLowerCase() ===
14946
- AuthenticationMethodTypeV2.SMS)) {
15241
+ channel === AuthenticationMethodTypeV2.EMAIL) {
15242
+ return new CustomAuthResultV2(new ExistingAccountCodeRequiredStateV2({
15243
+ ...commonStateParameters,
15244
+ method: selectedMethod,
15245
+ sentTo: result.sentTo,
15246
+ channel: result.channel,
15247
+ codeLength: result.codeLength,
15248
+ }), undefined, result.continuationState.scenario);
15249
+ }
15250
+ if (!isExistingAccountSignUp &&
15251
+ authenticationFactor === AuthenticationFactorV2.SINGLE_FACTOR &&
15252
+ result.type === FLOW_CODE_REQUIRED_V2 &&
15253
+ (channel === AuthenticationMethodTypeV2.EMAIL ||
15254
+ channel === AuthenticationMethodTypeV2.SMS)) {
14947
15255
  return new CustomAuthResultV2(new CodeRequiredStateV2({
14948
15256
  ...commonStateParameters,
14949
- signInStateTransitionHandler,
15257
+ resetPasswordStateTransitionHandler,
14950
15258
  method: selectedMethod,
14951
15259
  sentTo: result.sentTo,
14952
15260
  channel: result.channel,
14953
15261
  codeLength: result.codeLength,
14954
15262
  }), undefined, result.continuationState.scenario);
14955
15263
  }
15264
+ if (isExistingAccountSignUp &&
15265
+ authenticationFactor === AuthenticationFactorV2.SINGLE_FACTOR &&
15266
+ result.type === FLOW_PASSWORD_REQUIRED_V2) {
15267
+ return new CustomAuthResultV2(new ExistingAccountPasswordRequiredStateV2(commonStateParameters), undefined, result.continuationState.scenario);
15268
+ }
14956
15269
  if (continuationState.scenario ===
14957
15270
  CustomAuthFlowScenarioV2.SignIn &&
14958
15271
  authenticationFactor === AuthenticationFactorV2.SINGLE_FACTOR &&
@@ -14972,12 +15285,17 @@
14972
15285
  codeLength: result.codeLength,
14973
15286
  }), undefined, result.continuationState.scenario);
14974
15287
  }
14975
- const expectedChallenge = authenticationFactor === AuthenticationFactorV2.SINGLE_FACTOR
15288
+ let expectedChallenge = authenticationFactor === AuthenticationFactorV2.SINGLE_FACTOR
14976
15289
  ? continuationState.scenario ===
14977
15290
  CustomAuthFlowScenarioV2.SignIn
14978
15291
  ? "an email or SMS code challenge or a password challenge for single-factor sign-in"
14979
15292
  : "an email or SMS code challenge for single-factor authentication"
14980
15293
  : "a code challenge for multi-factor authentication";
15294
+ if (isExistingAccountSignUp &&
15295
+ authenticationFactor === AuthenticationFactorV2.SINGLE_FACTOR) {
15296
+ expectedChallenge =
15297
+ "an email code challenge or a password challenge for existing-account sign-up";
15298
+ }
14981
15299
  const returnedChallenge = result.type === FLOW_CODE_REQUIRED_V2
14982
15300
  ? result.channel
14983
15301
  ? `a '${result.channel}' code challenge`
@@ -14993,24 +15311,143 @@
14993
15311
  });
14994
15312
  }
14995
15313
  }
14996
- async requestSelectedMethodChallenge(method) {
14997
- const { correlationId, continuationState, flowClient, authenticationFactor, } = this.stateParameters;
14998
- const selectedMethod = this.methods.find((candidate) => candidate.id === method.id);
14999
- if (!selectedMethod) {
15000
- throw new InvalidArgumentError("method", correlationId);
15001
- }
15002
- const result = await flowClient.requestChallenge({
15003
- correlationId,
15004
- authenticationFactor,
15005
- continuationState: {
15006
- ...continuationState,
15007
- links: {
15008
- ...continuationState.links,
15009
- challenge: selectedMethod.challengeHref,
15010
- },
15011
- },
15012
- });
15013
- return { result, selectedMethod };
15314
+ async requestSelectedMethodChallenge(method) {
15315
+ const { correlationId, continuationState, flowClient, authenticationFactor, } = this.stateParameters;
15316
+ const selectedMethod = this.methods.find((candidate) => candidate.id === method.id);
15317
+ if (!selectedMethod) {
15318
+ throw new InvalidArgumentError("method", correlationId);
15319
+ }
15320
+ const result = await flowClient.requestChallenge({
15321
+ correlationId,
15322
+ authenticationFactor,
15323
+ continuationState: {
15324
+ ...continuationState,
15325
+ links: {
15326
+ ...continuationState.links,
15327
+ challenge: selectedMethod.challengeHref,
15328
+ },
15329
+ },
15330
+ });
15331
+ return { result, selectedMethod };
15332
+ }
15333
+ }
15334
+
15335
+ /*
15336
+ * Copyright (c) Microsoft Corporation. All rights reserved.
15337
+ * Licensed under the MIT License.
15338
+ */
15339
+ /**
15340
+ * State returned when sign-in or sign-up requires a password.
15341
+ * @warning This API is experimental. It may be changed in the future without notice. Do not use in production applications.
15342
+ */
15343
+ class PasswordRequiredStateV2 extends AuthFlowActionRequiredStateBase {
15344
+ constructor(stateParameters) {
15345
+ super(stateParameters);
15346
+ this.stateType = "passwordRequired";
15347
+ this.requestedPasswordAttribute =
15348
+ stateParameters.requestedPasswordAttribute;
15349
+ }
15350
+ /**
15351
+ * Submits the password and advances the active flow. Use the returned result
15352
+ * to continue the flow.
15353
+ * @param password - The account password.
15354
+ * @returns The result containing the next state or an error.
15355
+ */
15356
+ async submitPassword(password) {
15357
+ const { correlationId, logger, continuationState } = this.stateParameters;
15358
+ try {
15359
+ this.ensurePasswordIsNotEmpty(password);
15360
+ if (continuationState.scenario === CustomAuthFlowScenarioV2.SignUp) {
15361
+ return await this.submitSignUpPassword(password);
15362
+ }
15363
+ if (continuationState.scenario === CustomAuthFlowScenarioV2.SignIn) {
15364
+ return await this.submitSignInPassword(password);
15365
+ }
15366
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, `Password submission is not supported for the '${continuationState.scenario}' flow.`, correlationId);
15367
+ }
15368
+ catch (error) {
15369
+ logger.errorPii(`Failed to submit V2 password. Error: '${error}'.`, correlationId);
15370
+ return CustomAuthResultV2.createWithError(error, {
15371
+ scenario: continuationState.scenario,
15372
+ correlationId,
15373
+ });
15374
+ }
15375
+ }
15376
+ async submitSignUpPassword(password) {
15377
+ const { correlationId, continuationState, flowClient } = this.stateParameters;
15378
+ const signUpStateTransitionHandler = this.stateParameters.signUpStateTransitionHandler;
15379
+ if (!signUpStateTransitionHandler) {
15380
+ throw new UnexpectedError("Sign-up state transition handler is missing.", correlationId);
15381
+ }
15382
+ const result = await flowClient.submitSignUpAttributes({
15383
+ correlationId,
15384
+ continuationState,
15385
+ attributes: { password },
15386
+ });
15387
+ return signUpStateTransitionHandler.handleAttributeSubmission(result, { ...this.stateParameters, signUpStateTransitionHandler }, "password");
15388
+ }
15389
+ async submitSignInPassword(password) {
15390
+ const { correlationId, logger, continuationState, flowClient } = this.stateParameters;
15391
+ const result = await flowClient.submitSignInPassword({
15392
+ correlationId,
15393
+ continuationState,
15394
+ password,
15395
+ });
15396
+ const resultType = result.type;
15397
+ if (result.type === FLOW_COMPLETED_V2) {
15398
+ const account = new CustomAuthAccountData(result.authenticationResult.account, this.stateParameters.config, this.stateParameters.cacheClient, logger, correlationId);
15399
+ return new CustomAuthResultV2(new CompletedStateV2(), account, continuationState.scenario);
15400
+ }
15401
+ if (result.type === FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2) {
15402
+ return new CustomAuthResultV2(new AuthMethodRegistrationRequiredStateV2({
15403
+ correlationId: result.correlationId,
15404
+ logger,
15405
+ config: this.stateParameters.config,
15406
+ flowClient,
15407
+ continuationState: result.continuationState,
15408
+ cacheClient: this.stateParameters.cacheClient,
15409
+ methods: result.methods,
15410
+ }), undefined, result.continuationState.scenario);
15411
+ }
15412
+ if (result.type === FLOW_MFA_REQUIRED_V2) {
15413
+ return new CustomAuthResultV2(new AuthMethodSelectionRequiredStateV2({
15414
+ correlationId: result.correlationId,
15415
+ logger,
15416
+ config: this.stateParameters.config,
15417
+ flowClient,
15418
+ continuationState: result.continuationState,
15419
+ cacheClient: this.stateParameters.cacheClient,
15420
+ methods: result.methods,
15421
+ authenticationFactor: AuthenticationFactorV2.MULTI_FACTOR,
15422
+ }), undefined, result.continuationState.scenario);
15423
+ }
15424
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, `Password verification result type '${resultType}' is not supported.`, correlationId);
15425
+ }
15426
+ }
15427
+
15428
+ /*
15429
+ * Copyright (c) Microsoft Corporation. All rights reserved.
15430
+ * Licensed under the MIT License.
15431
+ */
15432
+ class SignInStateTransitionHandlerV2 {
15433
+ handlePasswordRequired(result, stateParameters) {
15434
+ return new CustomAuthResultV2(new PasswordRequiredStateV2({
15435
+ ...stateParameters,
15436
+ correlationId: result.correlationId,
15437
+ continuationState: result.continuationState,
15438
+ }), undefined, result.continuationState.scenario);
15439
+ }
15440
+ handleMfaRequired(result, stateParameters) {
15441
+ return new CustomAuthResultV2(new AuthMethodSelectionRequiredStateV2({
15442
+ correlationId: result.correlationId,
15443
+ logger: stateParameters.logger,
15444
+ config: stateParameters.config,
15445
+ flowClient: stateParameters.flowClient,
15446
+ continuationState: result.continuationState,
15447
+ cacheClient: stateParameters.cacheClient,
15448
+ methods: result.methods,
15449
+ authenticationFactor: AuthenticationFactorV2.MULTI_FACTOR,
15450
+ }), undefined, result.continuationState.scenario);
15014
15451
  }
15015
15452
  }
15016
15453
 
@@ -15019,33 +15456,34 @@
15019
15456
  * Licensed under the MIT License.
15020
15457
  */
15021
15458
  /**
15022
- * State returned when the selected sign-in method requires the user's
15023
- * password.
15459
+ * State returned when the user must supply a new password. Submission can
15460
+ * require method registration or MFA, and the flow is not complete until any
15461
+ * subsequent required actions finish.
15462
+ * @warning This API is experimental. It may be changed in the future without notice. Do not use in production applications.
15024
15463
  */
15025
- class PasswordRequiredStateV2 extends AuthFlowActionRequiredStateBase {
15464
+ class NewPasswordRequiredStateV2 extends AuthFlowActionRequiredStateBase {
15026
15465
  constructor() {
15027
15466
  super(...arguments);
15028
- this.stateType = "passwordRequired";
15467
+ this.stateType = "newPasswordRequired";
15029
15468
  }
15030
15469
  /**
15031
- * Submits the password and advances sign-in.
15032
- * @param password - The account password.
15033
- * @returns A completed sign-in, MFA selection, or password submission error.
15470
+ * Submits the new password. The result can require method registration or
15471
+ * MFA, and completion is not final until any subsequent required actions
15472
+ * finish.
15473
+ * @param password - The new password to set.
15474
+ * @returns The result of submitting the new password.
15034
15475
  */
15035
- async submitPassword(password) {
15476
+ async submitNewPassword(password) {
15036
15477
  const { correlationId, logger, continuationState, flowClient } = this.stateParameters;
15037
15478
  try {
15038
15479
  this.ensurePasswordIsNotEmpty(password);
15039
- const result = await flowClient.submitSignInPassword({
15480
+ logger.verbose("Submitting V2 new password.", correlationId);
15481
+ const result = await flowClient.submitNewPassword({
15040
15482
  correlationId,
15041
15483
  continuationState,
15042
- password,
15484
+ newPassword: password,
15043
15485
  });
15044
15486
  const resultType = result.type;
15045
- if (result.type === FLOW_COMPLETED_V2) {
15046
- const account = new CustomAuthAccountData(result.authenticationResult.account, this.stateParameters.config, this.stateParameters.cacheClient, logger, correlationId);
15047
- return new CustomAuthResultV2(new CompletedStateV2(), account, continuationState.scenario);
15048
- }
15049
15487
  if (result.type === FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2) {
15050
15488
  return new CustomAuthResultV2(new AuthMethodRegistrationRequiredStateV2({
15051
15489
  correlationId: result.correlationId,
@@ -15069,10 +15507,20 @@
15069
15507
  authenticationFactor: AuthenticationFactorV2.MULTI_FACTOR,
15070
15508
  }), undefined, result.continuationState.scenario);
15071
15509
  }
15072
- throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, `Password verification result type '${resultType}' is not supported.`, correlationId);
15510
+ if (result.type === FLOW_SIGN_IN_CONTINUATION_REQUIRED_V2) {
15511
+ return new CustomAuthResultV2(new SignInContinuationStateV2({
15512
+ correlationId: result.correlationId,
15513
+ logger,
15514
+ config: this.stateParameters.config,
15515
+ flowClient,
15516
+ continuationState: result.continuationState,
15517
+ cacheClient: this.stateParameters.cacheClient,
15518
+ }), undefined, result.continuationState.scenario);
15519
+ }
15520
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, `Password submission result type '${resultType}' is not supported.`, correlationId);
15073
15521
  }
15074
15522
  catch (error) {
15075
- logger.errorPii(`Failed to submit V2 sign-in password. Error: '${error}'.`, correlationId);
15523
+ logger.errorPii(`Failed to submit V2 new password. Error: '${error}'.`, correlationId);
15076
15524
  return CustomAuthResultV2.createWithError(error, {
15077
15525
  scenario: continuationState.scenario,
15078
15526
  correlationId,
@@ -15085,66 +15533,46 @@
15085
15533
  * Copyright (c) Microsoft Corporation. All rights reserved.
15086
15534
  * Licensed under the MIT License.
15087
15535
  */
15088
- class SignInStateTransitionHandlerV2 {
15089
- handlePasswordRequired(result, stateParameters) {
15090
- return new CustomAuthResultV2(new PasswordRequiredStateV2({
15091
- ...stateParameters,
15092
- correlationId: result.correlationId,
15093
- continuationState: result.continuationState,
15094
- }), undefined, result.continuationState.scenario);
15095
- }
15096
- handleMfaRequired(result, stateParameters) {
15097
- return new CustomAuthResultV2(new AuthMethodSelectionRequiredStateV2({
15536
+ class ResetPasswordStateTransitionHandlerV2 {
15537
+ handleNewPasswordRequired(result, stateParameters) {
15538
+ return new CustomAuthResultV2(new NewPasswordRequiredStateV2({
15098
15539
  correlationId: result.correlationId,
15099
15540
  logger: stateParameters.logger,
15100
15541
  config: stateParameters.config,
15101
15542
  flowClient: stateParameters.flowClient,
15102
15543
  continuationState: result.continuationState,
15103
15544
  cacheClient: stateParameters.cacheClient,
15104
- methods: result.methods,
15105
- authenticationFactor: AuthenticationFactorV2.MULTI_FACTOR,
15106
15545
  }), undefined, result.continuationState.scenario);
15107
15546
  }
15108
15547
  }
15109
15548
 
15110
- /*
15111
- * Copyright (c) Microsoft Corporation. All rights reserved.
15112
- * Licensed under the MIT License.
15113
- */
15114
- class SignUpAttributesRequiredStateBaseV2 extends AuthFlowActionRequiredStateBase {
15115
- constructor(stateParameters) {
15116
- super(stateParameters);
15117
- this.attributes = stateParameters.attributes;
15118
- }
15119
- async submitAttributesAction(attributes) {
15120
- const { correlationId, continuationState, flowClient } = this.stateParameters;
15121
- return flowClient.submitSignUpAttributes({
15122
- correlationId,
15123
- continuationState,
15124
- attributes,
15125
- });
15126
- }
15127
- }
15128
-
15129
15549
  /*
15130
15550
  * Copyright (c) Microsoft Corporation. All rights reserved.
15131
15551
  * Licensed under the MIT License.
15132
15552
  */
15133
15553
  /**
15134
15554
  * State returned when sign-up requires profile or custom attributes.
15555
+ * @warning This API is experimental. It may be changed in the future without notice. Do not use in production applications.
15135
15556
  */
15136
- class AttributesRequiredStateV2 extends SignUpAttributesRequiredStateBaseV2 {
15137
- constructor() {
15138
- super(...arguments);
15557
+ class AttributesRequiredStateV2 extends AuthFlowActionRequiredStateBase {
15558
+ constructor(stateParameters) {
15559
+ super(stateParameters);
15139
15560
  this.stateType = "attributesRequired";
15561
+ this.attributes = stateParameters.attributes;
15140
15562
  }
15141
15563
  /**
15142
- * Submits the attributes requested by the latest server response.
15564
+ * Submits the supplied attributes, including an empty object, to the service.
15565
+ * The returned result identifies the next step or a submission failure.
15143
15566
  */
15144
15567
  async submitAttributes(attributes) {
15145
- const { correlationId, logger, continuationState } = this.stateParameters;
15568
+ const { correlationId, logger, continuationState, flowClient } = this.stateParameters;
15146
15569
  try {
15147
- const result = await this.submitAttributesAction(attributes);
15570
+ const filteredAttributes = filterReservedSignUpAttributesV2(attributes, logger, correlationId);
15571
+ const result = await flowClient.submitSignUpAttributes({
15572
+ correlationId,
15573
+ continuationState,
15574
+ attributes: filteredAttributes,
15575
+ });
15148
15576
  return this.stateParameters.signUpStateTransitionHandler.handleAttributeSubmission(result, this.stateParameters, "attribute");
15149
15577
  }
15150
15578
  catch (error) {
@@ -15161,53 +15589,23 @@
15161
15589
  * Copyright (c) Microsoft Corporation. All rights reserved.
15162
15590
  * Licensed under the MIT License.
15163
15591
  */
15164
- /**
15165
- * State returned when sign-up requires a password that was not submitted with
15166
- * an earlier attribute request.
15167
- */
15168
- class SignUpPasswordRequiredStateV2 extends SignUpAttributesRequiredStateBaseV2 {
15169
- constructor(stateParameters) {
15170
- super(stateParameters);
15171
- this.stateType = "passwordRequired";
15172
- this.requiredPasswordAttribute =
15173
- stateParameters.requiredPasswordAttribute;
15174
- }
15592
+ class SignUpStateTransitionHandlerV2 {
15175
15593
  /**
15176
- * Submits the password and any profile attributes requested alongside it.
15594
+ * Maps new-account verification and attribute-submission outcomes to public states.
15177
15595
  */
15178
- async submitPassword(password, attributes = {}) {
15179
- const { correlationId, logger, continuationState } = this.stateParameters;
15180
- try {
15181
- this.ensurePasswordIsNotEmpty(password);
15182
- const result = await this.submitAttributesAction({
15183
- ...attributes,
15184
- password,
15185
- });
15186
- return this.stateParameters.signUpStateTransitionHandler.handleAttributeSubmission(result, this.stateParameters, "password");
15187
- }
15188
- catch (error) {
15189
- logger.errorPii(`Failed to submit V2 sign-up password. Error: '${error}'.`, correlationId);
15190
- return CustomAuthResultV2.createWithError(error, {
15191
- scenario: continuationState.scenario,
15192
- correlationId,
15193
- });
15194
- }
15195
- }
15196
- }
15197
-
15198
- /*
15199
- * Copyright (c) Microsoft Corporation. All rights reserved.
15200
- * Licensed under the MIT License.
15201
- */
15202
- class SignUpStateTransitionHandlerV2 {
15203
15596
  handleAttributeSubmission(result, stateParameters, submission) {
15597
+ const resultType = result.type;
15204
15598
  const commonStateParameters = this.createCommonStateParameters(result, stateParameters);
15205
- if (result.type === FLOW_CODE_REQUIRED_V2) {
15206
- return new CustomAuthResultV2(new CodeRequiredStateV2({
15599
+ if (result.type === FLOW_SIGN_UP_PASSWORD_REQUIRED_V2) {
15600
+ return new CustomAuthResultV2(new PasswordRequiredStateV2({
15207
15601
  ...commonStateParameters,
15208
- sentTo: result.sentTo,
15209
- channel: result.channel,
15210
- codeLength: result.codeLength,
15602
+ requestedPasswordAttribute: result.requestedPasswordAttribute,
15603
+ }), undefined, result.continuationState.scenario);
15604
+ }
15605
+ if (result.type === FLOW_ATTRIBUTES_REQUIRED_V2) {
15606
+ return new CustomAuthResultV2(new AttributesRequiredStateV2({
15607
+ ...commonStateParameters,
15608
+ attributes: result.attributes,
15211
15609
  }), undefined, result.continuationState.scenario);
15212
15610
  }
15213
15611
  if (result.type === FLOW_SIGN_IN_CONTINUATION_REQUIRED_V2) {
@@ -15219,21 +15617,7 @@
15219
15617
  methods: result.methods,
15220
15618
  }), undefined, result.continuationState.scenario);
15221
15619
  }
15222
- throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, `Sign-up ${submission} submission result type '${result.type}' is not supported.`, stateParameters.correlationId);
15223
- }
15224
- handleVerification(result, stateParameters) {
15225
- const commonStateParameters = this.createCommonStateParameters(result, stateParameters);
15226
- if (result.type === FLOW_ATTRIBUTES_REQUIRED_V2) {
15227
- return new CustomAuthResultV2(new AttributesRequiredStateV2({
15228
- ...commonStateParameters,
15229
- attributes: result.attributes,
15230
- }), undefined, result.continuationState.scenario);
15231
- }
15232
- return new CustomAuthResultV2(new SignUpPasswordRequiredStateV2({
15233
- ...commonStateParameters,
15234
- attributes: result.attributes,
15235
- requiredPasswordAttribute: result.requiredPasswordAttribute,
15236
- }), undefined, result.continuationState.scenario);
15620
+ throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, `Sign-up ${submission} submission result type '${resultType}' is not supported.`, stateParameters.correlationId);
15237
15621
  }
15238
15622
  createCommonStateParameters(result, stateParameters) {
15239
15623
  return {
@@ -21357,37 +21741,38 @@
21357
21741
  }, e);
21358
21742
  throw e;
21359
21743
  }
21360
- // check if the tokens can be retrieved from internal cache
21361
- let cachedResult;
21362
- try {
21363
- cachedResult = await this.acquireTokensFromCache(this.accountId, nativeRequest);
21364
- }
21365
- catch (e) {
21366
- if (cacheLookupPolicy === CacheLookupPolicy.AccessToken) {
21367
- this.logger.info("MSAL internal Cache does not contain tokens, return error as per cache policy", this.correlationId);
21744
+ if (this.apiId === ApiId.acquireTokenSilent_silentFlow) {
21745
+ let cachedResult;
21746
+ try {
21747
+ cachedResult = await this.acquireTokensFromCache(this.accountId, nativeRequest, cacheLookupPolicy);
21748
+ }
21749
+ catch (e) {
21750
+ if (cacheLookupPolicy === CacheLookupPolicy.AccessToken) {
21751
+ this.logger.info("MSAL internal Cache does not contain tokens, return error as per cache policy", this.correlationId);
21752
+ nativeATMeasurement.add({
21753
+ isNativeBroker: false,
21754
+ });
21755
+ nativeATMeasurement.end({
21756
+ success: false,
21757
+ });
21758
+ await this.resetGeneratedDpopRequestKeyBestEffort(nativeRequest);
21759
+ throw e;
21760
+ }
21761
+ // continue with a native call for any and all errors
21762
+ this.logger.info("MSAL internal Cache does not contain tokens, proceed to make a native call", this.correlationId);
21763
+ }
21764
+ if (cachedResult) {
21765
+ // Served from the native internal cache; token did not come directly from the broker
21368
21766
  nativeATMeasurement.add({
21369
21767
  isNativeBroker: false,
21370
21768
  });
21371
21769
  nativeATMeasurement.end({
21372
- success: false,
21770
+ success: true,
21771
+ fromCache: true,
21373
21772
  });
21374
- await this.resetGeneratedDpopRequestKeyBestEffort(nativeRequest);
21375
- throw e;
21773
+ await this.resetGeneratedDpopRequestKey(nativeRequest);
21774
+ return cachedResult;
21376
21775
  }
21377
- // continue with a native call for any and all errors
21378
- this.logger.info("MSAL internal Cache does not contain tokens, proceed to make a native call", this.correlationId);
21379
- }
21380
- if (cachedResult) {
21381
- // Served from the native internal cache; token did not come directly from the broker
21382
- nativeATMeasurement.add({
21383
- isNativeBroker: false,
21384
- });
21385
- nativeATMeasurement.end({
21386
- success: true,
21387
- fromCache: true,
21388
- });
21389
- await this.resetGeneratedDpopRequestKey(nativeRequest);
21390
- return cachedResult;
21391
21776
  }
21392
21777
  // dispatch the request to the broker
21393
21778
  try {
@@ -21478,12 +21863,18 @@
21478
21863
  };
21479
21864
  }
21480
21865
  /**
21481
- * Fetches the tokens from the cache if un-expired
21866
+ * Fetches unexpired tokens when allowed by cache policy.
21482
21867
  * @param nativeAccountId
21483
21868
  * @param request
21484
- * @returns authenticationResult
21869
+ * @param cacheLookupPolicy
21870
+ * @returns Cached result, or undefined when cache policy bypasses lookup.
21485
21871
  */
21486
- async acquireTokensFromCache(nativeAccountId, request) {
21872
+ async acquireTokensFromCache(nativeAccountId, request, cacheLookupPolicy = CacheLookupPolicy.Default) {
21873
+ if (cacheLookupPolicy === CacheLookupPolicy.RefreshTokenAndNetwork ||
21874
+ cacheLookupPolicy === CacheLookupPolicy.Skip) {
21875
+ this.logger.verbose("Native cache lookup bypassed for cache policy", this.correlationId);
21876
+ return undefined;
21877
+ }
21487
21878
  if (!nativeAccountId) {
21488
21879
  this.logger.warning("NativeInteractionClient:acquireTokensFromCache - No nativeAccountId provided", this.correlationId);
21489
21880
  throw createClientAuthError(noAccountFound, this.correlationId);
@@ -21833,7 +22224,7 @@
21833
22224
  async cacheAccount(accountEntity, kmsi, clearExistingTokens = true) {
21834
22225
  // Store the account info and hence `nativeAccountId` in browser cache
21835
22226
  await this.browserStorage.setAccount(accountEntity, this.correlationId, kmsi, this.apiId);
21836
- // Remove any existing cached tokens for this account in browser storage
22227
+ // Remove cached web access and refresh tokens, preserving ID tokens.
21837
22228
  if (clearExistingTokens) {
21838
22229
  this.browserStorage.removeAccountContext(getAccountInfo(accountEntity), this.correlationId);
21839
22230
  }
@@ -24764,7 +25155,11 @@
24764
25155
  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);
24765
25156
  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);
24766
25157
  }
24767
- const authClient = await invokeAsync(this.createAuthCodeClient.bind(this), StandardInteractionClientCreateAuthCodeClient, this.logger, this.performanceClient, this.correlationId)({ serverTelemetryManager, requestAuthority: request.authority });
25158
+ const authClient = await invokeAsync(this.createAuthCodeClient.bind(this), StandardInteractionClientCreateAuthCodeClient, this.logger, this.performanceClient, this.correlationId)({
25159
+ serverTelemetryManager,
25160
+ requestAuthority: request.authority,
25161
+ requestExtraQueryParameters: request.extraQueryParameters,
25162
+ });
24768
25163
  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);
24769
25164
  }
24770
25165
  /**
@@ -27118,6 +27513,7 @@
27118
27513
  super(operatingContext);
27119
27514
  this.signUpStateTransitionHandlerV2 = new SignUpStateTransitionHandlerV2();
27120
27515
  this.signInStateTransitionHandlerV2 = new SignInStateTransitionHandlerV2();
27516
+ this.resetPasswordStateTransitionHandlerV2 = new ResetPasswordStateTransitionHandlerV2();
27121
27517
  if (!this.isBrowserEnvironment) {
27122
27518
  this.logger.verbose("The SDK can only be used in a browser environment.", "");
27123
27519
  throw new UnsupportedEnvironmentError();
@@ -27394,7 +27790,7 @@
27394
27790
  const correlationId = this.getCorrelationId(inputs);
27395
27791
  try {
27396
27792
  ensureArgumentIsNotNullOrUndefined("inputs", inputs, correlationId);
27397
- ensureArgumentIsNotEmptyString("inputs.username", inputs.username, correlationId);
27793
+ this.ensureUsernameIsValidV2(inputs.username, correlationId);
27398
27794
  if (inputs.scopes !== undefined && inputs.scopes !== null) {
27399
27795
  ensureArgumentIsStringArray("inputs.scopes", inputs.scopes, correlationId);
27400
27796
  }
@@ -27418,6 +27814,7 @@
27418
27814
  flowClient: this.flowClientV2,
27419
27815
  continuationState: result.continuationState,
27420
27816
  cacheClient: this.cacheClient,
27817
+ resetPasswordStateTransitionHandler: this.resetPasswordStateTransitionHandlerV2,
27421
27818
  method: result.method,
27422
27819
  sentTo: result.sentTo,
27423
27820
  channel: result.channel,
@@ -27433,6 +27830,7 @@
27433
27830
  cacheClient: this.cacheClient,
27434
27831
  methods: result.methods,
27435
27832
  authenticationFactor: AuthenticationFactorV2.SINGLE_FACTOR,
27833
+ resetPasswordStateTransitionHandler: this.resetPasswordStateTransitionHandlerV2,
27436
27834
  }), undefined, result.continuationState.scenario);
27437
27835
  }
27438
27836
  catch (error) {
@@ -27447,7 +27845,7 @@
27447
27845
  const correlationId = this.getCorrelationId(inputs);
27448
27846
  try {
27449
27847
  ensureArgumentIsNotNullOrUndefined("inputs", inputs, correlationId);
27450
- ensureArgumentIsNotEmptyString("inputs.username", inputs.username, correlationId);
27848
+ this.ensureUsernameIsValidV2(inputs.username, correlationId);
27451
27849
  if (inputs.scopes !== undefined && inputs.scopes !== null) {
27452
27850
  ensureArgumentIsStringArray("inputs.scopes", inputs.scopes, correlationId);
27453
27851
  }
@@ -27459,13 +27857,9 @@
27459
27857
  const result = await this.flowClientV2.signIn({
27460
27858
  correlationId,
27461
27859
  username: inputs.username,
27462
- password: inputs.password,
27463
27860
  scopes: inputs.scopes,
27464
27861
  claims: inputs.claims,
27465
27862
  });
27466
- if (result.type === FLOW_COMPLETED_V2) {
27467
- return new CustomAuthResultV2(new CompletedStateV2(), new CustomAuthAccountData(result.authenticationResult.account, this.customAuthConfig, this.cacheClient, this.logger, correlationId), CustomAuthFlowScenarioV2.SignIn);
27468
- }
27469
27863
  if (result.type === FLOW_PASSWORD_REQUIRED_V2) {
27470
27864
  return new CustomAuthResultV2(new PasswordRequiredStateV2({
27471
27865
  correlationId: result.correlationId,
@@ -27476,17 +27870,6 @@
27476
27870
  cacheClient: this.cacheClient,
27477
27871
  }), undefined, result.continuationState.scenario);
27478
27872
  }
27479
- if (result.type === FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2) {
27480
- return new CustomAuthResultV2(new AuthMethodRegistrationRequiredStateV2({
27481
- correlationId: result.correlationId,
27482
- logger: this.logger,
27483
- config: this.customAuthConfig,
27484
- flowClient: this.flowClientV2,
27485
- continuationState: result.continuationState,
27486
- cacheClient: this.cacheClient,
27487
- methods: result.methods,
27488
- }), undefined, result.continuationState.scenario);
27489
- }
27490
27873
  if (result.type === FLOW_CODE_REQUIRED_V2) {
27491
27874
  return new CustomAuthResultV2(new CodeRequiredStateV2({
27492
27875
  correlationId: result.correlationId,
@@ -27515,18 +27898,6 @@
27515
27898
  signInStateTransitionHandler: this.signInStateTransitionHandlerV2,
27516
27899
  }), undefined, result.continuationState.scenario);
27517
27900
  }
27518
- if (result.type === FLOW_MFA_REQUIRED_V2) {
27519
- return new CustomAuthResultV2(new AuthMethodSelectionRequiredStateV2({
27520
- correlationId: result.correlationId,
27521
- logger: this.logger,
27522
- config: this.customAuthConfig,
27523
- flowClient: this.flowClientV2,
27524
- continuationState: result.continuationState,
27525
- cacheClient: this.cacheClient,
27526
- methods: result.methods,
27527
- authenticationFactor: AuthenticationFactorV2.MULTI_FACTOR,
27528
- }), undefined, result.continuationState.scenario);
27529
- }
27530
27901
  throw new UnexpectedError("Unsupported native auth V2 sign-in result type.", correlationId);
27531
27902
  }
27532
27903
  catch (error) {
@@ -27541,11 +27912,7 @@
27541
27912
  const correlationId = this.getCorrelationId(inputs);
27542
27913
  try {
27543
27914
  ensureArgumentIsNotNullOrUndefined("inputs", inputs, correlationId);
27544
- ensureArgumentIsNotEmptyString("inputs.username", inputs.username, correlationId);
27545
- if (Object.prototype.hasOwnProperty.call(inputs, "password")) {
27546
- ensureArgumentIsNotNullOrUndefined("inputs.password", inputs.password, correlationId);
27547
- ensureArgumentIsNotEmptyString("inputs.password", inputs.password, correlationId);
27548
- }
27915
+ this.ensureUsernameIsValidV2(inputs.username, correlationId);
27549
27916
  if (inputs.scopes !== undefined && inputs.scopes !== null) {
27550
27917
  ensureArgumentIsStringArray("inputs.scopes", inputs.scopes, correlationId);
27551
27918
  }
@@ -27557,39 +27924,61 @@
27557
27924
  const result = await this.flowClientV2.signUp({
27558
27925
  correlationId,
27559
27926
  username: inputs.username,
27560
- password: inputs.password,
27561
- attributes: inputs.attributes,
27562
27927
  scopes: inputs.scopes,
27563
27928
  claims: inputs.claims,
27929
+ attributes: inputs.attributes,
27564
27930
  });
27565
- const commonStateParameters = {
27566
- correlationId: result.correlationId,
27567
- logger: this.logger,
27568
- config: this.customAuthConfig,
27569
- flowClient: this.flowClientV2,
27570
- continuationState: result.continuationState,
27571
- cacheClient: this.cacheClient,
27572
- signUpStateTransitionHandler: this.signUpStateTransitionHandlerV2,
27573
- };
27574
27931
  if (result.type === FLOW_CODE_REQUIRED_V2) {
27575
27932
  return new CustomAuthResultV2(new CodeRequiredStateV2({
27576
- ...commonStateParameters,
27933
+ correlationId: result.correlationId,
27934
+ logger: this.logger,
27935
+ config: this.customAuthConfig,
27936
+ flowClient: this.flowClientV2,
27937
+ continuationState: result.continuationState,
27938
+ cacheClient: this.cacheClient,
27939
+ signUpStateTransitionHandler: this.signUpStateTransitionHandlerV2,
27577
27940
  sentTo: result.sentTo,
27578
27941
  channel: result.channel,
27579
27942
  codeLength: result.codeLength,
27580
27943
  }), undefined, result.continuationState.scenario);
27581
27944
  }
27582
- if (result.type === FLOW_SIGN_UP_PASSWORD_REQUIRED_V2) {
27583
- return new CustomAuthResultV2(new SignUpPasswordRequiredStateV2({
27584
- ...commonStateParameters,
27585
- attributes: result.attributes,
27586
- requiredPasswordAttribute: result.requiredPasswordAttribute,
27945
+ if (result.type === FLOW_EXISTING_ACCOUNT_CODE_REQUIRED_V2) {
27946
+ return new CustomAuthResultV2(new ExistingAccountCodeRequiredStateV2({
27947
+ correlationId: result.correlationId,
27948
+ logger: this.logger,
27949
+ config: this.customAuthConfig,
27950
+ flowClient: this.flowClientV2,
27951
+ continuationState: result.continuationState,
27952
+ cacheClient: this.cacheClient,
27953
+ signInStateTransitionHandler: this.signInStateTransitionHandlerV2,
27954
+ method: result.method,
27955
+ sentTo: result.sentTo,
27956
+ channel: result.channel,
27957
+ codeLength: result.codeLength,
27587
27958
  }), undefined, result.continuationState.scenario);
27588
27959
  }
27589
- if (result.type === FLOW_ATTRIBUTES_REQUIRED_V2) {
27590
- return new CustomAuthResultV2(new AttributesRequiredStateV2({
27591
- ...commonStateParameters,
27592
- attributes: result.attributes,
27960
+ if (result.type === FLOW_EXISTING_ACCOUNT_PASSWORD_REQUIRED_V2) {
27961
+ return new CustomAuthResultV2(new ExistingAccountPasswordRequiredStateV2({
27962
+ correlationId: result.correlationId,
27963
+ logger: this.logger,
27964
+ config: this.customAuthConfig,
27965
+ flowClient: this.flowClientV2,
27966
+ continuationState: result.continuationState,
27967
+ cacheClient: this.cacheClient,
27968
+ signInStateTransitionHandler: this.signInStateTransitionHandlerV2,
27969
+ }), undefined, result.continuationState.scenario);
27970
+ }
27971
+ if (result.type === FLOW_METHOD_SELECTION_REQUIRED_V2) {
27972
+ return new CustomAuthResultV2(new AuthMethodSelectionRequiredStateV2({
27973
+ correlationId: result.correlationId,
27974
+ logger: this.logger,
27975
+ config: this.customAuthConfig,
27976
+ flowClient: this.flowClientV2,
27977
+ continuationState: result.continuationState,
27978
+ cacheClient: this.cacheClient,
27979
+ methods: result.methods,
27980
+ authenticationFactor: AuthenticationFactorV2.SINGLE_FACTOR,
27981
+ signInStateTransitionHandler: this.signInStateTransitionHandlerV2,
27593
27982
  }), undefined, result.continuationState.scenario);
27594
27983
  }
27595
27984
  throw new UnexpectedError("Unsupported native auth V2 sign-up result type.", correlationId);
@@ -27602,6 +27991,9 @@
27602
27991
  });
27603
27992
  }
27604
27993
  }
27994
+ ensureUsernameIsValidV2(username, correlationId) {
27995
+ ensureArgumentIsNotEmptyString("inputs.username", username, correlationId);
27996
+ }
27605
27997
  getCorrelationId(actionInputs) {
27606
27998
  return (actionInputs?.correlationId || this.browserCrypto.createNewGuid());
27607
27999
  }
@@ -28575,8 +28967,8 @@
28575
28967
  return this.customAuthController.resetPassword(resetPasswordInputs);
28576
28968
  }
28577
28969
  /**
28578
- * Starts native auth V2 sign-in and returns the authentication methods
28579
- * offered for the first factor.
28970
+ * Starts native auth V2 sign-in.
28971
+ * @warning This API is experimental. It may be changed in the future without notice. Do not use in production applications.
28580
28972
  * @param inputs - Inputs for the sign-in V2 flow.
28581
28973
  * @returns A promise that resolves to the sign-in start result.
28582
28974
  */
@@ -28585,6 +28977,7 @@
28585
28977
  }
28586
28978
  /**
28587
28979
  * Starts native auth V2 sign-up.
28980
+ * @warning This API is experimental. It may be changed in the future without notice. Do not use in production applications.
28588
28981
  * @param inputs - Inputs for the sign-up V2 flow.
28589
28982
  * @returns A promise that resolves to the sign-up start result.
28590
28983
  */
@@ -28592,7 +28985,8 @@
28592
28985
  return this.customAuthController.signUpV2(inputs);
28593
28986
  }
28594
28987
  /**
28595
- * Initiates the native auth V2 self-service password reset flow.
28988
+ * Starts native auth V2 self-service password reset.
28989
+ * @warning This API is experimental. It may be changed in the future without notice. Do not use in production applications.
28596
28990
  * @param {ResetPasswordInputsV2} inputs - Inputs for the reset-password V2 flow
28597
28991
  * @returns {Promise<ResetPasswordStartResultV2>} - A promise that resolves to ResetPasswordStartResultV2
28598
28992
  */
@@ -28661,6 +29055,8 @@
28661
29055
  exports.CustomAuthFlowScenarioV2 = CustomAuthFlowScenarioV2;
28662
29056
  exports.CustomAuthPublicClientApplication = CustomAuthPublicClientApplication;
28663
29057
  exports.CustomAuthResultV2 = CustomAuthResultV2;
29058
+ exports.ExistingAccountCodeRequiredStateV2 = ExistingAccountCodeRequiredStateV2;
29059
+ exports.ExistingAccountPasswordRequiredStateV2 = ExistingAccountPasswordRequiredStateV2;
28664
29060
  exports.FailedStateV2 = FailedStateV2;
28665
29061
  exports.GetAccessTokenResult = GetAccessTokenResult;
28666
29062
  exports.GetAccountError = GetAccountError;
@@ -28720,7 +29116,6 @@
28720
29116
  exports.SignUpError = SignUpError;
28721
29117
  exports.SignUpFailedState = SignUpFailedState;
28722
29118
  exports.SignUpPasswordRequiredState = SignUpPasswordRequiredState;
28723
- exports.SignUpPasswordRequiredStateV2 = SignUpPasswordRequiredStateV2;
28724
29119
  exports.SignUpResendCodeError = SignUpResendCodeError;
28725
29120
  exports.SignUpResendCodeResult = SignUpResendCodeResult;
28726
29121
  exports.SignUpResult = SignUpResult;