@azure/msal-browser 5.27.0 → 5.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (567) hide show
  1. package/dist/app/IPublicClientApplication.mjs +1 -1
  2. package/dist/app/PublicClientApplication.mjs +1 -1
  3. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  4. package/dist/broker/nativeBroker/PlatformAuthDOMHandler.mjs +9 -1
  5. package/dist/broker/nativeBroker/PlatformAuthDOMHandler.mjs.map +1 -1
  6. package/dist/broker/nativeBroker/PlatformAuthExtensionHandler.mjs +7 -6
  7. package/dist/broker/nativeBroker/PlatformAuthExtensionHandler.mjs.map +1 -1
  8. package/dist/broker/nativeBroker/PlatformAuthProvider.mjs +4 -2
  9. package/dist/broker/nativeBroker/PlatformAuthProvider.mjs.map +1 -1
  10. package/dist/broker/nativeBroker/PlatformAuthRequest.mjs +21 -7
  11. package/dist/broker/nativeBroker/PlatformAuthRequest.mjs.map +1 -1
  12. package/dist/cache/AccountManager.mjs +1 -1
  13. package/dist/cache/AsyncMemoryStorage.mjs +14 -1
  14. package/dist/cache/AsyncMemoryStorage.mjs.map +1 -1
  15. package/dist/cache/BrowserCacheManager.mjs +9 -2
  16. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  17. package/dist/cache/CacheHelpers.mjs +1 -1
  18. package/dist/cache/CacheKeys.mjs +1 -1
  19. package/dist/cache/CookieStorage.mjs +1 -1
  20. package/dist/cache/DatabaseStorage.mjs +1 -1
  21. package/dist/cache/EncryptedData.mjs +1 -1
  22. package/dist/cache/LocalStorage.mjs +1 -1
  23. package/dist/cache/MemoryStorage.mjs +1 -1
  24. package/dist/cache/SessionStorage.mjs +1 -1
  25. package/dist/cache/TokenCache.mjs +1 -1
  26. package/dist/config/Configuration.mjs +1 -1
  27. package/dist/controllers/NestedAppAuthController.mjs +1 -1
  28. package/dist/controllers/StandardController.mjs +65 -7
  29. package/dist/controllers/StandardController.mjs.map +1 -1
  30. package/dist/crypto/BrowserCrypto.mjs +1 -1
  31. package/dist/crypto/CryptoOps.mjs +1 -1
  32. package/dist/crypto/PkceGenerator.mjs +1 -1
  33. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  34. package/dist/crypto/TokenBindingKeyManager.mjs +14 -1
  35. package/dist/crypto/TokenBindingKeyManager.mjs.map +1 -1
  36. package/dist/custom_auth/CustomAuthConstants.mjs +1 -1
  37. package/dist/custom_auth/CustomAuthPublicClientApplication.mjs +6 -4
  38. package/dist/custom_auth/CustomAuthPublicClientApplication.mjs.map +1 -1
  39. package/dist/custom_auth/controller/CustomAuthStandardController.mjs +58 -50
  40. package/dist/custom_auth/controller/CustomAuthStandardController.mjs.map +1 -1
  41. package/dist/custom_auth/core/CustomAuthAuthority.mjs +1 -1
  42. package/dist/custom_auth/core/auth_flow/AuthFlowErrorBase.mjs +1 -1
  43. package/dist/custom_auth/core/auth_flow/AuthFlowResultBase.mjs +1 -1
  44. package/dist/custom_auth/core/auth_flow/AuthFlowState.mjs +1 -1
  45. package/dist/custom_auth/core/auth_flow/AuthFlowStateTypes.mjs +1 -1
  46. package/dist/custom_auth/core/auth_flow/jit/error_type/AuthMethodRegistrationError.mjs +1 -1
  47. package/dist/custom_auth/core/auth_flow/jit/result/AuthMethodRegistrationChallengeMethodResult.mjs +1 -1
  48. package/dist/custom_auth/core/auth_flow/jit/result/AuthMethodRegistrationSubmitChallengeResult.mjs +1 -1
  49. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationCompletedState.mjs +1 -1
  50. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationFailedState.mjs +1 -1
  51. package/dist/custom_auth/core/auth_flow/jit/state/AuthMethodRegistrationState.mjs +1 -1
  52. package/dist/custom_auth/core/auth_flow/mfa/error_type/MfaError.mjs +1 -1
  53. package/dist/custom_auth/core/auth_flow/mfa/result/MfaRequestChallengeResult.mjs +1 -1
  54. package/dist/custom_auth/core/auth_flow/mfa/result/MfaSubmitChallengeResult.mjs +1 -1
  55. package/dist/custom_auth/core/auth_flow/mfa/state/MfaCompletedState.mjs +1 -1
  56. package/dist/custom_auth/core/auth_flow/mfa/state/MfaFailedState.mjs +1 -1
  57. package/dist/custom_auth/core/auth_flow/mfa/state/MfaState.mjs +1 -1
  58. package/dist/custom_auth/core/auth_flow/v2/CustomAuthFlowScenarioV2.mjs +3 -5
  59. package/dist/custom_auth/core/auth_flow/v2/CustomAuthFlowScenarioV2.mjs.map +1 -1
  60. package/dist/custom_auth/core/auth_flow/v2/CustomAuthResultV2.mjs +19 -13
  61. package/dist/custom_auth/core/auth_flow/v2/CustomAuthResultV2.mjs.map +1 -1
  62. package/dist/custom_auth/core/auth_flow/v2/error/AuthFlowErrorSubcodesV2.mjs +8 -2
  63. package/dist/custom_auth/core/auth_flow/v2/error/AuthFlowErrorSubcodesV2.mjs.map +1 -1
  64. package/dist/custom_auth/core/auth_flow/v2/error/AuthFlowErrorV2.mjs +58 -69
  65. package/dist/custom_auth/core/auth_flow/v2/error/AuthFlowErrorV2.mjs.map +1 -1
  66. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodRegistrationRequiredStateV2.mjs +68 -0
  67. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodRegistrationRequiredStateV2.mjs.map +1 -0
  68. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.mjs +44 -16
  69. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.mjs.map +1 -1
  70. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodVerificationRequiredStateV2.mjs +100 -0
  71. package/dist/custom_auth/core/auth_flow/v2/state/AuthMethodVerificationRequiredStateV2.mjs.map +1 -0
  72. package/dist/custom_auth/core/auth_flow/v2/state/ChallengeVerificationStateBaseV2.mjs +5 -3
  73. package/dist/custom_auth/core/auth_flow/v2/state/ChallengeVerificationStateBaseV2.mjs.map +1 -1
  74. package/dist/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.mjs +27 -19
  75. package/dist/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.mjs.map +1 -1
  76. package/dist/custom_auth/core/auth_flow/v2/state/CompletedStateV2.mjs +2 -4
  77. package/dist/custom_auth/core/auth_flow/v2/state/CompletedStateV2.mjs.map +1 -1
  78. package/dist/custom_auth/core/auth_flow/v2/state/FailedStateV2.mjs +2 -3
  79. package/dist/custom_auth/core/auth_flow/v2/state/FailedStateV2.mjs.map +1 -1
  80. package/dist/custom_auth/core/auth_flow/v2/state/MFAVerificationRequiredStateV2.mjs +20 -8
  81. package/dist/custom_auth/core/auth_flow/v2/state/MFAVerificationRequiredStateV2.mjs.map +1 -1
  82. package/dist/custom_auth/core/auth_flow/v2/state/PasswordRequiredStateV2.mjs +110 -0
  83. package/dist/custom_auth/core/auth_flow/v2/state/PasswordRequiredStateV2.mjs.map +1 -0
  84. package/dist/custom_auth/core/error/CustomAuthApiError.mjs +1 -1
  85. package/dist/custom_auth/core/error/CustomAuthError.mjs +1 -1
  86. package/dist/custom_auth/core/error/HttpError.mjs +1 -1
  87. package/dist/custom_auth/core/error/HttpErrorCodes.mjs +1 -1
  88. package/dist/custom_auth/core/error/InvalidArgumentError.mjs +2 -1
  89. package/dist/custom_auth/core/error/InvalidArgumentError.mjs.map +1 -1
  90. package/dist/custom_auth/core/error/InvalidConfigurationError.mjs +1 -1
  91. package/dist/custom_auth/core/error/InvalidConfigurationErrorCodes.mjs +1 -1
  92. package/dist/custom_auth/core/error/MethodNotImplementedError.mjs +1 -1
  93. package/dist/custom_auth/core/error/MsalCustomAuthError.mjs +1 -1
  94. package/dist/custom_auth/core/error/NoCachedAccountFoundError.mjs +1 -1
  95. package/dist/custom_auth/core/error/ParsedUrlError.mjs +1 -1
  96. package/dist/custom_auth/core/error/ParsedUrlErrorCodes.mjs +1 -1
  97. package/dist/custom_auth/core/error/UnexpectedError.mjs +1 -1
  98. package/dist/custom_auth/core/error/UnsupportedEnvironmentError.mjs +1 -1
  99. package/dist/custom_auth/core/error/UserAccountAttributeError.mjs +1 -1
  100. package/dist/custom_auth/core/error/UserAlreadySignedInError.mjs +1 -1
  101. package/dist/custom_auth/core/interaction_client/CustomAuthInteractionClientBase.mjs +1 -1
  102. package/dist/custom_auth/core/interaction_client/CustomAuthInterationClientFactory.mjs +1 -1
  103. package/dist/custom_auth/core/interaction_client/jit/JitClient.mjs +1 -1
  104. package/dist/custom_auth/core/interaction_client/jit/result/JitActionResult.mjs +1 -1
  105. package/dist/custom_auth/core/interaction_client/mfa/MfaClient.mjs +1 -1
  106. package/dist/custom_auth/core/interaction_client/mfa/result/MfaActionResult.mjs +1 -1
  107. package/dist/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.mjs +465 -186
  108. package/dist/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.mjs.map +1 -1
  109. package/dist/custom_auth/core/interaction_client/v2/InteractionClientBaseV2.mjs +2 -6
  110. package/dist/custom_auth/core/interaction_client/v2/InteractionClientBaseV2.mjs.map +1 -1
  111. package/dist/custom_auth/core/interaction_client/v2/result/FlowActionResultV2.mjs +18 -3
  112. package/dist/custom_auth/core/interaction_client/v2/result/FlowActionResultV2.mjs.map +1 -1
  113. package/dist/custom_auth/core/network_client/custom_auth_api/BaseApiClient.mjs +1 -1
  114. package/dist/custom_auth/core/network_client/custom_auth_api/CustomAuthApiClient.mjs +1 -1
  115. package/dist/custom_auth/core/network_client/custom_auth_api/CustomAuthApiEndpoint.mjs +1 -1
  116. package/dist/custom_auth/core/network_client/custom_auth_api/RegisterApiClient.mjs +1 -1
  117. package/dist/custom_auth/core/network_client/custom_auth_api/ResetPasswordApiClient.mjs +1 -1
  118. package/dist/custom_auth/core/network_client/custom_auth_api/SignInApiClient.mjs +1 -1
  119. package/dist/custom_auth/core/network_client/custom_auth_api/SignupApiClient.mjs +1 -1
  120. package/dist/custom_auth/core/network_client/custom_auth_api/types/ApiErrorCodes.mjs +1 -1
  121. package/dist/custom_auth/core/network_client/custom_auth_api/types/ApiSuberrors.mjs +1 -1
  122. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.mjs +10 -8
  123. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.mjs.map +1 -1
  124. package/dist/custom_auth/core/network_client/custom_auth_api/v2/BaseApiClientV2.mjs +1 -1
  125. package/dist/custom_auth/core/network_client/custom_auth_api/v2/CustomAuthApiClientV2.mjs +147 -38
  126. package/dist/custom_auth/core/network_client/custom_auth_api/v2/CustomAuthApiClientV2.mjs.map +1 -1
  127. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ErrorCodesV2.mjs +1 -1
  128. package/dist/custom_auth/core/network_client/custom_auth_api/v2/HrefResolverV2.mjs +1 -1
  129. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.mjs +21 -10
  130. package/dist/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.mjs.map +1 -1
  131. package/dist/custom_auth/core/network_client/custom_auth_api/v2/response/ErrorNormalizerV2.mjs +1 -1
  132. package/dist/custom_auth/core/network_client/custom_auth_api/v2/result/BaseResultsV2.mjs +2 -12
  133. package/dist/custom_auth/core/network_client/custom_auth_api/v2/result/BaseResultsV2.mjs.map +1 -1
  134. package/dist/custom_auth/core/network_client/custom_auth_api/v2/result/SignUpResultsV2.mjs +2 -2
  135. package/dist/custom_auth/core/network_client/custom_auth_api/v2/result/SignUpResultsV2.mjs.map +1 -1
  136. package/dist/custom_auth/core/network_client/http_client/FetchHttpClient.mjs +1 -1
  137. package/dist/custom_auth/core/network_client/http_client/IHttpClient.mjs +1 -1
  138. package/dist/custom_auth/core/telemetry/FlowApiIdHelperV2.mjs +15 -3
  139. package/dist/custom_auth/core/telemetry/FlowApiIdHelperV2.mjs.map +1 -1
  140. package/dist/custom_auth/core/telemetry/PublicApiId.mjs +10 -3
  141. package/dist/custom_auth/core/telemetry/PublicApiId.mjs.map +1 -1
  142. package/dist/custom_auth/core/utils/ArgumentValidator.mjs +17 -2
  143. package/dist/custom_auth/core/utils/ArgumentValidator.mjs.map +1 -1
  144. package/dist/custom_auth/core/utils/CustomHeaderUtils.mjs +1 -1
  145. package/dist/custom_auth/core/utils/UrlUtils.mjs +1 -1
  146. package/dist/custom_auth/get_account/auth_flow/CustomAuthAccountData.mjs +1 -1
  147. package/dist/custom_auth/get_account/auth_flow/error_type/GetAccountError.mjs +1 -1
  148. package/dist/custom_auth/get_account/auth_flow/result/GetAccessTokenResult.mjs +1 -1
  149. package/dist/custom_auth/get_account/auth_flow/result/GetAccountResult.mjs +1 -1
  150. package/dist/custom_auth/get_account/auth_flow/result/SignOutResult.mjs +1 -1
  151. package/dist/custom_auth/get_account/auth_flow/state/GetAccessTokenState.mjs +1 -1
  152. package/dist/custom_auth/get_account/auth_flow/state/GetAccountState.mjs +1 -1
  153. package/dist/custom_auth/get_account/auth_flow/state/SignOutState.mjs +1 -1
  154. package/dist/custom_auth/get_account/interaction_client/CustomAuthSilentCacheClient.mjs +1 -1
  155. package/dist/custom_auth/index.mjs +6 -3
  156. package/dist/custom_auth/index.mjs.map +1 -1
  157. package/dist/custom_auth/operating_context/CustomAuthOperatingContext.mjs +1 -1
  158. package/dist/custom_auth/reset_password/auth_flow/error_type/ResetPasswordError.mjs +1 -1
  159. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordResendCodeResult.mjs +1 -1
  160. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordStartResult.mjs +1 -1
  161. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordSubmitCodeResult.mjs +1 -1
  162. package/dist/custom_auth/reset_password/auth_flow/result/ResetPasswordSubmitPasswordResult.mjs +1 -1
  163. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordCodeRequiredState.mjs +1 -1
  164. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordCompletedState.mjs +1 -1
  165. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordFailedState.mjs +1 -1
  166. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordPasswordRequiredState.mjs +1 -1
  167. package/dist/custom_auth/reset_password/auth_flow/state/ResetPasswordState.mjs +1 -1
  168. package/dist/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.mjs +49 -14
  169. package/dist/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.mjs.map +1 -1
  170. package/dist/custom_auth/reset_password/auth_flow/v2/state/ResetPasswordStateTransitionHandlerV2.mjs +24 -0
  171. package/dist/custom_auth/reset_password/auth_flow/v2/state/ResetPasswordStateTransitionHandlerV2.mjs.map +1 -0
  172. package/dist/custom_auth/reset_password/interaction_client/ResetPasswordClient.mjs +1 -1
  173. package/dist/custom_auth/sign_in/auth_flow/SignInScenario.mjs +1 -1
  174. package/dist/custom_auth/sign_in/auth_flow/error_type/SignInError.mjs +1 -1
  175. package/dist/custom_auth/sign_in/auth_flow/result/SignInResendCodeResult.mjs +1 -1
  176. package/dist/custom_auth/sign_in/auth_flow/result/SignInResult.mjs +1 -1
  177. package/dist/custom_auth/sign_in/auth_flow/result/SignInSubmitCodeResult.mjs +1 -1
  178. package/dist/custom_auth/sign_in/auth_flow/result/SignInSubmitPasswordResult.mjs +1 -1
  179. package/dist/custom_auth/sign_in/auth_flow/state/SignInCodeRequiredState.mjs +1 -1
  180. package/dist/custom_auth/sign_in/auth_flow/state/SignInCompletedState.mjs +1 -1
  181. package/dist/custom_auth/sign_in/auth_flow/state/SignInContinuationState.mjs +1 -1
  182. package/dist/custom_auth/sign_in/auth_flow/state/SignInFailedState.mjs +1 -1
  183. package/dist/custom_auth/sign_in/auth_flow/state/SignInPasswordRequiredState.mjs +1 -1
  184. package/dist/custom_auth/sign_in/auth_flow/state/SignInState.mjs +1 -1
  185. package/dist/custom_auth/sign_in/auth_flow/v2/state/SignInContinuationStateV2.mjs +4 -7
  186. package/dist/custom_auth/sign_in/auth_flow/v2/state/SignInContinuationStateV2.mjs.map +1 -1
  187. package/dist/custom_auth/sign_in/auth_flow/v2/state/SignInStateTransitionHandlerV2.mjs +2 -2
  188. package/dist/custom_auth/sign_in/auth_flow/v2/state/SignInStateTransitionHandlerV2.mjs.map +1 -1
  189. package/dist/custom_auth/sign_in/interaction_client/SignInClient.mjs +1 -1
  190. package/dist/custom_auth/sign_in/interaction_client/result/SignInActionResult.mjs +1 -1
  191. package/dist/custom_auth/sign_up/auth_flow/error_type/SignUpError.mjs +1 -1
  192. package/dist/custom_auth/sign_up/auth_flow/result/SignUpResendCodeResult.mjs +1 -1
  193. package/dist/custom_auth/sign_up/auth_flow/result/SignUpResult.mjs +1 -1
  194. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitAttributesResult.mjs +1 -1
  195. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitCodeResult.mjs +1 -1
  196. package/dist/custom_auth/sign_up/auth_flow/result/SignUpSubmitPasswordResult.mjs +1 -1
  197. package/dist/custom_auth/sign_up/auth_flow/state/SignUpAttributesRequiredState.mjs +1 -1
  198. package/dist/custom_auth/sign_up/auth_flow/state/SignUpCodeRequiredState.mjs +1 -1
  199. package/dist/custom_auth/sign_up/auth_flow/state/SignUpCompletedState.mjs +1 -1
  200. package/dist/custom_auth/sign_up/auth_flow/state/SignUpFailedState.mjs +1 -1
  201. package/dist/custom_auth/sign_up/auth_flow/state/SignUpPasswordRequiredState.mjs +1 -1
  202. package/dist/custom_auth/sign_up/auth_flow/state/SignUpState.mjs +1 -1
  203. package/dist/custom_auth/sign_up/auth_flow/v2/state/AttributesRequiredStateV2.mjs +17 -8
  204. package/dist/custom_auth/sign_up/auth_flow/v2/state/AttributesRequiredStateV2.mjs.map +1 -1
  205. package/dist/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountCodeRequiredStateV2.mjs +78 -0
  206. package/dist/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountCodeRequiredStateV2.mjs.map +1 -0
  207. package/dist/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountPasswordRequiredStateV2.mjs +48 -0
  208. package/dist/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountPasswordRequiredStateV2.mjs.map +1 -0
  209. package/dist/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountStateTransitionHelperV2.mjs +49 -0
  210. package/dist/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountStateTransitionHelperV2.mjs.map +1 -0
  211. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpStateTransitionHandlerV2.mjs +21 -21
  212. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpStateTransitionHandlerV2.mjs.map +1 -1
  213. package/dist/custom_auth/sign_up/interaction_client/SignUpClient.mjs +1 -1
  214. package/dist/custom_auth/sign_up/interaction_client/result/SignUpActionResult.mjs +1 -1
  215. package/dist/encode/Base64Decode.mjs +1 -1
  216. package/dist/encode/Base64Encode.mjs +1 -1
  217. package/dist/error/BrowserAuthError.mjs +1 -1
  218. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  219. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  220. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  221. package/dist/error/NativeAuthError.mjs +1 -1
  222. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  223. package/dist/error/NestedAppAuthError.mjs +1 -1
  224. package/dist/event/EventHandler.mjs +1 -1
  225. package/dist/event/EventMessage.mjs +1 -1
  226. package/dist/event/EventType.mjs +1 -1
  227. package/dist/index.mjs +1 -1
  228. package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
  229. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  230. package/dist/interaction_client/PlatformAuthInteractionClient.mjs +526 -90
  231. package/dist/interaction_client/PlatformAuthInteractionClient.mjs.map +1 -1
  232. package/dist/interaction_client/PopupClient.mjs +27 -20
  233. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  234. package/dist/interaction_client/RedirectClient.mjs +29 -14
  235. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  236. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  237. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  238. package/dist/interaction_client/SilentIframeClient.mjs +44 -32
  239. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  240. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  241. package/dist/interaction_client/StandardInteractionClient.mjs +1 -1
  242. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  243. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  244. package/dist/log-strings-mapping.json +77 -25
  245. package/dist/naa/BridgeError.mjs +1 -1
  246. package/dist/naa/BridgeProxy.mjs +1 -1
  247. package/dist/naa/BridgeStatusCode.mjs +1 -1
  248. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  249. package/dist/navigation/NavigationClient.mjs +1 -1
  250. package/dist/network/FetchClient.mjs +1 -1
  251. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  252. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  253. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  254. package/dist/packageMetadata.mjs +2 -2
  255. package/dist/popup_relay/constants.mjs +1 -1
  256. package/dist/popup_relay/index.mjs +1 -1
  257. package/dist/popup_relay/relayClient.mjs +1 -1
  258. package/dist/protocol/Authorize.mjs +21 -13
  259. package/dist/protocol/Authorize.mjs.map +1 -1
  260. package/dist/redirect_bridge/index.mjs +1 -1
  261. package/dist/request/RequestHelpers.mjs +35 -11
  262. package/dist/request/RequestHelpers.mjs.map +1 -1
  263. package/dist/request/SilentRequestHelpers.mjs +6 -6
  264. package/dist/request/SilentRequestHelpers.mjs.map +1 -1
  265. package/dist/response/ResponseHandler.mjs +1 -1
  266. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  267. package/dist/telemetry/BrowserPerformanceEvents.mjs +3 -2
  268. package/dist/telemetry/BrowserPerformanceEvents.mjs.map +1 -1
  269. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  270. package/dist/telemetry/BrowserRootPerformanceEvents.mjs +1 -1
  271. package/dist/utils/BrowserConstants.mjs +1 -1
  272. package/dist/utils/BrowserDetection.mjs +1 -1
  273. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  274. package/dist/utils/BrowserUtils.mjs +1 -1
  275. package/dist/utils/Helpers.mjs +1 -1
  276. package/dist/utils/IframeMonitor.mjs +1 -1
  277. package/dist/utils/MsalFrameStatsUtils.mjs +1 -1
  278. package/dist/utils/PopupMonitor.mjs +1 -1
  279. package/dist/utils/PopupOriginCheck.mjs +1 -1
  280. package/dist/webBrokerBridge/PendingRequestRegistry.mjs +1 -1
  281. package/dist/webBrokerBridge/PerfEventNames.mjs +1 -1
  282. package/dist/webBrokerBridge/WebBrokerBridgeError.mjs +1 -1
  283. package/dist/webBrokerBridge/WebBrokerBridgeErrorMap.mjs +1 -1
  284. package/dist/webBrokerBridge/adapter/CrossVersionRequestAdapter.mjs +1 -1
  285. package/dist/webBrokerBridge/index.mjs +1 -1
  286. package/lib/custom-auth-path/log-strings-mapping.json +69 -17
  287. package/lib/custom-auth-path/msal-custom-auth.cjs +2394 -920
  288. package/lib/custom-auth-path/msal-custom-auth.cjs.map +1 -1
  289. package/lib/custom-auth-path/msal-custom-auth.js +2394 -920
  290. package/lib/custom-auth-path/msal-custom-auth.js.map +1 -1
  291. package/lib/log-strings-mapping.json +23 -11
  292. package/lib/msal-browser.cjs +943 -278
  293. package/lib/msal-browser.cjs.map +1 -1
  294. package/lib/msal-browser.js +943 -278
  295. package/lib/msal-browser.js.map +1 -1
  296. package/lib/msal-browser.min.js +2 -2
  297. package/lib/popup-relay/msal-popup-relay.cjs +2 -2
  298. package/lib/popup-relay/msal-popup-relay.cjs.map +1 -1
  299. package/lib/popup-relay/msal-popup-relay.js +2 -2
  300. package/lib/popup-relay/msal-popup-relay.js.map +1 -1
  301. package/lib/popup-relay/msal-popup-relay.min.js +1 -1
  302. package/lib/redirect-bridge/msal-redirect-bridge.cjs +10 -10
  303. package/lib/redirect-bridge/msal-redirect-bridge.cjs.map +1 -1
  304. package/lib/redirect-bridge/msal-redirect-bridge.js +10 -10
  305. package/lib/redirect-bridge/msal-redirect-bridge.js.map +1 -1
  306. package/lib/redirect-bridge/msal-redirect-bridge.min.js +1 -1
  307. package/lib/web-broker-bridge/msal-web-broker-bridge.cjs +1 -1
  308. package/package.json +2 -2
  309. package/src/broker/nativeBroker/PlatformAuthDOMHandler.ts +15 -0
  310. package/src/broker/nativeBroker/PlatformAuthExtensionHandler.ts +6 -21
  311. package/src/broker/nativeBroker/PlatformAuthProvider.ts +3 -1
  312. package/src/broker/nativeBroker/PlatformAuthRequest.ts +12 -8
  313. package/src/broker/nativeBroker/PlatformAuthResponse.ts +31 -0
  314. package/src/cache/AsyncMemoryStorage.ts +16 -0
  315. package/src/cache/BrowserCacheManager.ts +19 -1
  316. package/src/controllers/StandardController.ts +107 -11
  317. package/src/crypto/TokenBindingKeyManager.ts +21 -0
  318. package/src/custom_auth/CustomAuthActionInputs.ts +12 -5
  319. package/src/custom_auth/CustomAuthPublicClientApplication.ts +5 -3
  320. package/src/custom_auth/ICustomAuthPublicClientApplicationV2.ts +5 -3
  321. package/src/custom_auth/controller/CustomAuthStandardController.ts +79 -92
  322. package/src/custom_auth/core/auth_flow/v2/AuthenticationMethodRegistrationV2.ts +14 -0
  323. package/src/custom_auth/core/auth_flow/v2/AuthenticationMethodV2.ts +1 -4
  324. package/src/custom_auth/core/auth_flow/v2/CustomAuthFlowScenarioV2.ts +5 -4
  325. package/src/custom_auth/core/auth_flow/v2/CustomAuthResultV2.ts +28 -16
  326. package/src/custom_auth/core/auth_flow/v2/error/AuthFlowErrorSubcodesV2.ts +6 -0
  327. package/src/custom_auth/core/auth_flow/v2/error/AuthFlowErrorV2.ts +83 -72
  328. package/src/custom_auth/core/auth_flow/v2/result/AuthMethodRegistrationChallengeResultV2.ts +23 -0
  329. package/src/custom_auth/core/auth_flow/v2/result/AuthMethodVerificationSubmitChallengeResultV2.ts +28 -0
  330. package/src/custom_auth/core/auth_flow/v2/result/MFASubmitChallengeResultV2.ts +10 -6
  331. package/src/custom_auth/core/auth_flow/v2/result/RequestChallengeResultV2.ts +9 -6
  332. package/src/custom_auth/core/auth_flow/v2/result/ResetPasswordStartResultV2.ts +4 -6
  333. package/src/custom_auth/core/auth_flow/v2/result/SubmitPasswordResultV2.ts +36 -0
  334. package/src/custom_auth/core/auth_flow/v2/result/VerifyChallengeResultV2.ts +8 -8
  335. package/src/custom_auth/core/auth_flow/v2/state/AuthMethodRegistrationRequiredStateV2.ts +94 -0
  336. package/src/custom_auth/core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.ts +68 -14
  337. package/src/custom_auth/core/auth_flow/v2/state/AuthMethodVerificationRequiredStateV2.ts +150 -0
  338. package/src/custom_auth/core/auth_flow/v2/state/ChallengeVerificationStateBaseV2.ts +8 -2
  339. package/src/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.ts +48 -24
  340. package/src/custom_auth/core/auth_flow/v2/state/CompletedStateV2.ts +1 -3
  341. package/src/custom_auth/core/auth_flow/v2/state/CustomAuthStateParametersV2.ts +24 -2
  342. package/src/custom_auth/core/auth_flow/v2/state/FailedStateV2.ts +1 -2
  343. package/src/custom_auth/core/auth_flow/v2/state/MFAVerificationRequiredStateV2.ts +34 -9
  344. package/src/custom_auth/core/auth_flow/v2/state/PasswordRequiredStateV2.ts +179 -0
  345. package/src/custom_auth/core/error/InvalidArgumentError.ts +1 -1
  346. package/src/custom_auth/core/interaction_client/v2/FlowContinuationStateV2.ts +13 -12
  347. package/src/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.ts +771 -261
  348. package/src/custom_auth/core/interaction_client/v2/InteractionClientBaseV2.ts +2 -6
  349. package/src/custom_auth/core/interaction_client/v2/parameter/FlowParamsV2.ts +27 -15
  350. package/src/custom_auth/core/interaction_client/v2/result/FlowActionResultV2.ts +97 -26
  351. package/src/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.ts +9 -6
  352. package/src/custom_auth/core/network_client/custom_auth_api/v2/CustomAuthApiClientV2.ts +330 -63
  353. package/src/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.ts +51 -15
  354. package/src/custom_auth/core/network_client/custom_auth_api/v2/request/RequestsV2.ts +25 -6
  355. package/src/custom_auth/core/network_client/custom_auth_api/v2/response/ErrorResponsesV2.ts +0 -6
  356. package/src/custom_auth/core/network_client/custom_auth_api/v2/response/ResponsesV2.ts +48 -48
  357. package/src/custom_auth/core/network_client/custom_auth_api/v2/result/BaseResultsV2.ts +44 -37
  358. package/src/custom_auth/core/network_client/custom_auth_api/v2/result/ResetPasswordResultsV2.ts +32 -15
  359. package/src/custom_auth/core/network_client/custom_auth_api/v2/result/SignUpResultsV2.ts +14 -10
  360. package/src/custom_auth/core/telemetry/FlowApiIdHelperV2.ts +24 -1
  361. package/src/custom_auth/core/telemetry/PublicApiId.ts +7 -0
  362. package/src/custom_auth/core/utils/ArgumentValidator.ts +26 -0
  363. package/src/custom_auth/index.ts +21 -11
  364. package/src/custom_auth/reset_password/auth_flow/v2/result/SubmitNewPasswordResultV2.ts +8 -10
  365. package/src/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.ts +71 -16
  366. package/src/custom_auth/reset_password/auth_flow/v2/state/ResetPasswordStateTransitionHandlerV2.ts +30 -0
  367. package/src/custom_auth/sign_in/auth_flow/v2/result/SignInContinuationResultV2.ts +4 -8
  368. package/src/custom_auth/sign_in/auth_flow/v2/result/SignInStartResultV2.ts +4 -5
  369. package/src/custom_auth/sign_in/auth_flow/v2/state/SignInContinuationStateV2.ts +3 -6
  370. package/src/custom_auth/sign_in/auth_flow/v2/state/SignInStateParametersV2.ts +0 -3
  371. package/src/custom_auth/sign_in/auth_flow/v2/state/SignInStateTransitionHandlerV2.ts +2 -3
  372. package/src/custom_auth/sign_up/auth_flow/v2/result/ExistingAccountActionResultsV2.ts +49 -0
  373. package/src/custom_auth/sign_up/auth_flow/v2/result/SignUpStartResultV2.ts +8 -4
  374. package/src/custom_auth/sign_up/auth_flow/v2/result/SubmitAttributesResultV2.ts +18 -4
  375. package/src/custom_auth/sign_up/auth_flow/v2/state/AttributesRequiredStateV2.ts +26 -5
  376. package/src/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountCodeRequiredStateV2.ts +101 -0
  377. package/src/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountPasswordRequiredStateV2.ts +53 -0
  378. package/src/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountStateTransitionHelperV2.ts +97 -0
  379. package/src/custom_auth/sign_up/auth_flow/v2/state/SignUpStateParametersV2.ts +0 -6
  380. package/src/custom_auth/sign_up/auth_flow/v2/state/SignUpStateTransitionHandlerV2.ts +33 -43
  381. package/src/interaction_client/PlatformAuthInteractionClient.ts +886 -148
  382. package/src/interaction_client/PopupClient.ts +104 -83
  383. package/src/interaction_client/RedirectClient.ts +88 -34
  384. package/src/interaction_client/SilentIframeClient.ts +121 -95
  385. package/src/packageMetadata.ts +1 -1
  386. package/src/protocol/Authorize.ts +46 -18
  387. package/src/request/RequestHelpers.ts +64 -11
  388. package/src/request/SilentRequestHelpers.ts +8 -9
  389. package/src/telemetry/BrowserPerformanceEvents.ts +1 -0
  390. package/types/broker/nativeBroker/PlatformAuthDOMHandler.d.ts.map +1 -1
  391. package/types/broker/nativeBroker/PlatformAuthExtensionHandler.d.ts.map +1 -1
  392. package/types/broker/nativeBroker/PlatformAuthProvider.d.ts.map +1 -1
  393. package/types/broker/nativeBroker/PlatformAuthRequest.d.ts +6 -1
  394. package/types/broker/nativeBroker/PlatformAuthRequest.d.ts.map +1 -1
  395. package/types/broker/nativeBroker/PlatformAuthResponse.d.ts +21 -0
  396. package/types/broker/nativeBroker/PlatformAuthResponse.d.ts.map +1 -1
  397. package/types/cache/AsyncMemoryStorage.d.ts +5 -0
  398. package/types/cache/AsyncMemoryStorage.d.ts.map +1 -1
  399. package/types/cache/BrowserCacheManager.d.ts +4 -0
  400. package/types/cache/BrowserCacheManager.d.ts.map +1 -1
  401. package/types/controllers/StandardController.d.ts +5 -0
  402. package/types/controllers/StandardController.d.ts.map +1 -1
  403. package/types/crypto/TokenBindingKeyManager.d.ts +9 -0
  404. package/types/crypto/TokenBindingKeyManager.d.ts.map +1 -1
  405. package/types/custom_auth/CustomAuthActionInputs.d.ts +12 -5
  406. package/types/custom_auth/CustomAuthActionInputs.d.ts.map +1 -1
  407. package/types/custom_auth/CustomAuthConstants.d.ts +1 -1
  408. package/types/custom_auth/CustomAuthPublicClientApplication.d.ts +5 -3
  409. package/types/custom_auth/CustomAuthPublicClientApplication.d.ts.map +1 -1
  410. package/types/custom_auth/ICustomAuthPublicClientApplicationV2.d.ts +5 -3
  411. package/types/custom_auth/ICustomAuthPublicClientApplicationV2.d.ts.map +1 -1
  412. package/types/custom_auth/controller/CustomAuthStandardController.d.ts +2 -0
  413. package/types/custom_auth/controller/CustomAuthStandardController.d.ts.map +1 -1
  414. package/types/custom_auth/core/auth_flow/v2/AuthenticationMethodRegistrationV2.d.ts +10 -0
  415. package/types/custom_auth/core/auth_flow/v2/AuthenticationMethodRegistrationV2.d.ts.map +1 -0
  416. package/types/custom_auth/core/auth_flow/v2/AuthenticationMethodV2.d.ts +1 -4
  417. package/types/custom_auth/core/auth_flow/v2/AuthenticationMethodV2.d.ts.map +1 -1
  418. package/types/custom_auth/core/auth_flow/v2/CustomAuthFlowScenarioV2.d.ts +5 -4
  419. package/types/custom_auth/core/auth_flow/v2/CustomAuthFlowScenarioV2.d.ts.map +1 -1
  420. package/types/custom_auth/core/auth_flow/v2/CustomAuthResultV2.d.ts +17 -8
  421. package/types/custom_auth/core/auth_flow/v2/CustomAuthResultV2.d.ts.map +1 -1
  422. package/types/custom_auth/core/auth_flow/v2/error/AuthFlowErrorSubcodesV2.d.ts +6 -0
  423. package/types/custom_auth/core/auth_flow/v2/error/AuthFlowErrorSubcodesV2.d.ts.map +1 -1
  424. package/types/custom_auth/core/auth_flow/v2/error/AuthFlowErrorV2.d.ts +23 -44
  425. package/types/custom_auth/core/auth_flow/v2/error/AuthFlowErrorV2.d.ts.map +1 -1
  426. package/types/custom_auth/core/auth_flow/v2/result/AuthMethodRegistrationChallengeResultV2.d.ts +14 -0
  427. package/types/custom_auth/core/auth_flow/v2/result/AuthMethodRegistrationChallengeResultV2.d.ts.map +1 -0
  428. package/types/custom_auth/core/auth_flow/v2/result/AuthMethodVerificationSubmitChallengeResultV2.d.ts +16 -0
  429. package/types/custom_auth/core/auth_flow/v2/result/AuthMethodVerificationSubmitChallengeResultV2.d.ts.map +1 -0
  430. package/types/custom_auth/core/auth_flow/v2/result/MFASubmitChallengeResultV2.d.ts +7 -6
  431. package/types/custom_auth/core/auth_flow/v2/result/MFASubmitChallengeResultV2.d.ts.map +1 -1
  432. package/types/custom_auth/core/auth_flow/v2/result/RequestChallengeResultV2.d.ts +8 -7
  433. package/types/custom_auth/core/auth_flow/v2/result/RequestChallengeResultV2.d.ts.map +1 -1
  434. package/types/custom_auth/core/auth_flow/v2/result/ResetPasswordStartResultV2.d.ts +4 -6
  435. package/types/custom_auth/core/auth_flow/v2/result/ResetPasswordStartResultV2.d.ts.map +1 -1
  436. package/types/custom_auth/core/auth_flow/v2/result/SubmitPasswordResultV2.d.ts +20 -0
  437. package/types/custom_auth/core/auth_flow/v2/result/SubmitPasswordResultV2.d.ts.map +1 -0
  438. package/types/custom_auth/core/auth_flow/v2/result/VerifyChallengeResultV2.d.ts +7 -8
  439. package/types/custom_auth/core/auth_flow/v2/result/VerifyChallengeResultV2.d.ts.map +1 -1
  440. package/types/custom_auth/core/auth_flow/v2/state/AuthMethodRegistrationRequiredStateV2.d.ts +22 -0
  441. package/types/custom_auth/core/auth_flow/v2/state/AuthMethodRegistrationRequiredStateV2.d.ts.map +1 -0
  442. package/types/custom_auth/core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.d.ts +3 -6
  443. package/types/custom_auth/core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.d.ts.map +1 -1
  444. package/types/custom_auth/core/auth_flow/v2/state/AuthMethodVerificationRequiredStateV2.d.ts +28 -0
  445. package/types/custom_auth/core/auth_flow/v2/state/AuthMethodVerificationRequiredStateV2.d.ts.map +1 -0
  446. package/types/custom_auth/core/auth_flow/v2/state/ChallengeVerificationStateBaseV2.d.ts +3 -2
  447. package/types/custom_auth/core/auth_flow/v2/state/ChallengeVerificationStateBaseV2.d.ts.map +1 -1
  448. package/types/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.d.ts +6 -8
  449. package/types/custom_auth/core/auth_flow/v2/state/CodeRequiredStateV2.d.ts.map +1 -1
  450. package/types/custom_auth/core/auth_flow/v2/state/CompletedStateV2.d.ts +1 -3
  451. package/types/custom_auth/core/auth_flow/v2/state/CompletedStateV2.d.ts.map +1 -1
  452. package/types/custom_auth/core/auth_flow/v2/state/CustomAuthStateParametersV2.d.ts +18 -2
  453. package/types/custom_auth/core/auth_flow/v2/state/CustomAuthStateParametersV2.d.ts.map +1 -1
  454. package/types/custom_auth/core/auth_flow/v2/state/FailedStateV2.d.ts +1 -2
  455. package/types/custom_auth/core/auth_flow/v2/state/FailedStateV2.d.ts.map +1 -1
  456. package/types/custom_auth/core/auth_flow/v2/state/MFAVerificationRequiredStateV2.d.ts +5 -6
  457. package/types/custom_auth/core/auth_flow/v2/state/MFAVerificationRequiredStateV2.d.ts.map +1 -1
  458. package/types/custom_auth/core/auth_flow/v2/state/PasswordRequiredStateV2.d.ts +23 -0
  459. package/types/custom_auth/core/auth_flow/v2/state/PasswordRequiredStateV2.d.ts.map +1 -0
  460. package/types/custom_auth/core/error/InvalidArgumentError.d.ts +1 -0
  461. package/types/custom_auth/core/error/InvalidArgumentError.d.ts.map +1 -1
  462. package/types/custom_auth/core/interaction_client/v2/FlowContinuationStateV2.d.ts +9 -1
  463. package/types/custom_auth/core/interaction_client/v2/FlowContinuationStateV2.d.ts.map +1 -1
  464. package/types/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.d.ts +19 -10
  465. package/types/custom_auth/core/interaction_client/v2/FlowInteractionClientV2.d.ts.map +1 -1
  466. package/types/custom_auth/core/interaction_client/v2/InteractionClientBaseV2.d.ts +1 -1
  467. package/types/custom_auth/core/interaction_client/v2/InteractionClientBaseV2.d.ts.map +1 -1
  468. package/types/custom_auth/core/interaction_client/v2/parameter/FlowParamsV2.d.ts +19 -5
  469. package/types/custom_auth/core/interaction_client/v2/parameter/FlowParamsV2.d.ts.map +1 -1
  470. package/types/custom_auth/core/interaction_client/v2/result/FlowActionResultV2.d.ts +39 -4
  471. package/types/custom_auth/core/interaction_client/v2/result/FlowActionResultV2.d.ts.map +1 -1
  472. package/types/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.d.ts +8 -0
  473. package/types/custom_auth/core/network_client/custom_auth_api/v2/ApiClientConstantsV2.d.ts.map +1 -1
  474. package/types/custom_auth/core/network_client/custom_auth_api/v2/CustomAuthApiClientV2.d.ts +8 -2
  475. package/types/custom_auth/core/network_client/custom_auth_api/v2/CustomAuthApiClientV2.d.ts.map +1 -1
  476. package/types/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.d.ts +4 -3
  477. package/types/custom_auth/core/network_client/custom_auth_api/v2/ResponseHandlerV2.d.ts.map +1 -1
  478. package/types/custom_auth/core/network_client/custom_auth_api/v2/request/RequestsV2.d.ts +13 -1
  479. package/types/custom_auth/core/network_client/custom_auth_api/v2/request/RequestsV2.d.ts.map +1 -1
  480. package/types/custom_auth/core/network_client/custom_auth_api/v2/response/ErrorResponsesV2.d.ts.map +1 -1
  481. package/types/custom_auth/core/network_client/custom_auth_api/v2/response/ResponsesV2.d.ts +36 -9
  482. package/types/custom_auth/core/network_client/custom_auth_api/v2/response/ResponsesV2.d.ts.map +1 -1
  483. package/types/custom_auth/core/network_client/custom_auth_api/v2/result/BaseResultsV2.d.ts +30 -17
  484. package/types/custom_auth/core/network_client/custom_auth_api/v2/result/BaseResultsV2.d.ts.map +1 -1
  485. package/types/custom_auth/core/network_client/custom_auth_api/v2/result/ResetPasswordResultsV2.d.ts +18 -4
  486. package/types/custom_auth/core/network_client/custom_auth_api/v2/result/ResetPasswordResultsV2.d.ts.map +1 -1
  487. package/types/custom_auth/core/network_client/custom_auth_api/v2/result/SignUpResultsV2.d.ts +8 -11
  488. package/types/custom_auth/core/network_client/custom_auth_api/v2/result/SignUpResultsV2.d.ts.map +1 -1
  489. package/types/custom_auth/core/telemetry/FlowApiIdHelperV2.d.ts +2 -1
  490. package/types/custom_auth/core/telemetry/FlowApiIdHelperV2.d.ts.map +1 -1
  491. package/types/custom_auth/core/telemetry/PublicApiId.d.ts +7 -0
  492. package/types/custom_auth/core/telemetry/PublicApiId.d.ts.map +1 -1
  493. package/types/custom_auth/core/utils/ArgumentValidator.d.ts +3 -0
  494. package/types/custom_auth/core/utils/ArgumentValidator.d.ts.map +1 -1
  495. package/types/custom_auth/index.d.ts +10 -5
  496. package/types/custom_auth/index.d.ts.map +1 -1
  497. package/types/custom_auth/reset_password/auth_flow/v2/result/SubmitNewPasswordResultV2.d.ts +7 -11
  498. package/types/custom_auth/reset_password/auth_flow/v2/result/SubmitNewPasswordResultV2.d.ts.map +1 -1
  499. package/types/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.d.ts +7 -5
  500. package/types/custom_auth/reset_password/auth_flow/v2/state/NewPasswordRequiredStateV2.d.ts.map +1 -1
  501. package/types/custom_auth/reset_password/auth_flow/v2/state/ResetPasswordStateTransitionHandlerV2.d.ts +7 -0
  502. package/types/custom_auth/reset_password/auth_flow/v2/state/ResetPasswordStateTransitionHandlerV2.d.ts.map +1 -0
  503. package/types/custom_auth/sign_in/auth_flow/v2/result/SignInContinuationResultV2.d.ts +4 -8
  504. package/types/custom_auth/sign_in/auth_flow/v2/result/SignInContinuationResultV2.d.ts.map +1 -1
  505. package/types/custom_auth/sign_in/auth_flow/v2/result/SignInStartResultV2.d.ts +5 -5
  506. package/types/custom_auth/sign_in/auth_flow/v2/result/SignInStartResultV2.d.ts.map +1 -1
  507. package/types/custom_auth/sign_in/auth_flow/v2/state/SignInContinuationStateV2.d.ts +3 -6
  508. package/types/custom_auth/sign_in/auth_flow/v2/state/SignInContinuationStateV2.d.ts.map +1 -1
  509. package/types/custom_auth/sign_in/auth_flow/v2/state/SignInStateParametersV2.d.ts +0 -1
  510. package/types/custom_auth/sign_in/auth_flow/v2/state/SignInStateParametersV2.d.ts.map +1 -1
  511. package/types/custom_auth/sign_in/auth_flow/v2/state/SignInStateTransitionHandlerV2.d.ts +3 -2
  512. package/types/custom_auth/sign_in/auth_flow/v2/state/SignInStateTransitionHandlerV2.d.ts.map +1 -1
  513. package/types/custom_auth/sign_up/auth_flow/v2/result/ExistingAccountActionResultsV2.d.ts +27 -0
  514. package/types/custom_auth/sign_up/auth_flow/v2/result/ExistingAccountActionResultsV2.d.ts.map +1 -0
  515. package/types/custom_auth/sign_up/auth_flow/v2/result/SignUpStartResultV2.d.ts +6 -3
  516. package/types/custom_auth/sign_up/auth_flow/v2/result/SignUpStartResultV2.d.ts.map +1 -1
  517. package/types/custom_auth/sign_up/auth_flow/v2/result/SubmitAttributesResultV2.d.ts +13 -3
  518. package/types/custom_auth/sign_up/auth_flow/v2/result/SubmitAttributesResultV2.d.ts.map +1 -1
  519. package/types/custom_auth/sign_up/auth_flow/v2/state/AttributesRequiredStateV2.d.ts +8 -3
  520. package/types/custom_auth/sign_up/auth_flow/v2/state/AttributesRequiredStateV2.d.ts.map +1 -1
  521. package/types/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountCodeRequiredStateV2.d.ts +24 -0
  522. package/types/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountCodeRequiredStateV2.d.ts.map +1 -0
  523. package/types/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountPasswordRequiredStateV2.d.ts +18 -0
  524. package/types/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountPasswordRequiredStateV2.d.ts.map +1 -0
  525. package/types/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountStateTransitionHelperV2.d.ts +7 -0
  526. package/types/custom_auth/sign_up/auth_flow/v2/state/ExistingAccountStateTransitionHelperV2.d.ts.map +1 -0
  527. package/types/custom_auth/sign_up/auth_flow/v2/state/SignUpStateParametersV2.d.ts +0 -4
  528. package/types/custom_auth/sign_up/auth_flow/v2/state/SignUpStateParametersV2.d.ts.map +1 -1
  529. package/types/custom_auth/sign_up/auth_flow/v2/state/SignUpStateTransitionHandlerV2.d.ts +5 -4
  530. package/types/custom_auth/sign_up/auth_flow/v2/state/SignUpStateTransitionHandlerV2.d.ts.map +1 -1
  531. package/types/interaction_client/PlatformAuthInteractionClient.d.ts +110 -8
  532. package/types/interaction_client/PlatformAuthInteractionClient.d.ts.map +1 -1
  533. package/types/interaction_client/PopupClient.d.ts.map +1 -1
  534. package/types/interaction_client/RedirectClient.d.ts.map +1 -1
  535. package/types/interaction_client/SilentIframeClient.d.ts.map +1 -1
  536. package/types/packageMetadata.d.ts +1 -1
  537. package/types/protocol/Authorize.d.ts +4 -4
  538. package/types/protocol/Authorize.d.ts.map +1 -1
  539. package/types/request/RequestHelpers.d.ts +21 -3
  540. package/types/request/RequestHelpers.d.ts.map +1 -1
  541. package/types/request/SilentRequestHelpers.d.ts.map +1 -1
  542. package/types/telemetry/BrowserPerformanceEvents.d.ts +1 -0
  543. package/types/telemetry/BrowserPerformanceEvents.d.ts.map +1 -1
  544. package/dist/custom_auth/sign_in/auth_flow/v2/state/PasswordRequiredStateV2.mjs +0 -70
  545. package/dist/custom_auth/sign_in/auth_flow/v2/state/PasswordRequiredStateV2.mjs.map +0 -1
  546. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpAttributesRequiredStateBaseV2.mjs +0 -25
  547. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpAttributesRequiredStateBaseV2.mjs.map +0 -1
  548. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpPasswordRequiredStateV2.mjs +0 -45
  549. package/dist/custom_auth/sign_up/auth_flow/v2/state/SignUpPasswordRequiredStateV2.mjs.map +0 -1
  550. package/src/custom_auth/core/auth_flow/v2/result/MFAResendChallengeResultV2.ts +0 -23
  551. package/src/custom_auth/core/auth_flow/v2/result/ResendCodeResultV2.ts +0 -19
  552. package/src/custom_auth/sign_in/auth_flow/v2/result/SubmitPasswordResultV2.ts +0 -20
  553. package/src/custom_auth/sign_in/auth_flow/v2/state/PasswordRequiredStateV2.ts +0 -97
  554. package/src/custom_auth/sign_up/auth_flow/v2/state/SignUpAttributesRequiredStateBaseV2.ts +0 -34
  555. package/src/custom_auth/sign_up/auth_flow/v2/state/SignUpPasswordRequiredStateV2.ts +0 -61
  556. package/types/custom_auth/core/auth_flow/v2/result/MFAResendChallengeResultV2.d.ts +0 -14
  557. package/types/custom_auth/core/auth_flow/v2/result/MFAResendChallengeResultV2.d.ts.map +0 -1
  558. package/types/custom_auth/core/auth_flow/v2/result/ResendCodeResultV2.d.ts +0 -13
  559. package/types/custom_auth/core/auth_flow/v2/result/ResendCodeResultV2.d.ts.map +0 -1
  560. package/types/custom_auth/sign_in/auth_flow/v2/result/SubmitPasswordResultV2.d.ts +0 -8
  561. package/types/custom_auth/sign_in/auth_flow/v2/result/SubmitPasswordResultV2.d.ts.map +0 -1
  562. package/types/custom_auth/sign_in/auth_flow/v2/state/PasswordRequiredStateV2.d.ts +0 -17
  563. package/types/custom_auth/sign_in/auth_flow/v2/state/PasswordRequiredStateV2.d.ts.map +0 -1
  564. package/types/custom_auth/sign_up/auth_flow/v2/state/SignUpAttributesRequiredStateBaseV2.d.ts +0 -11
  565. package/types/custom_auth/sign_up/auth_flow/v2/state/SignUpAttributesRequiredStateBaseV2.d.ts.map +0 -1
  566. package/types/custom_auth/sign_up/auth_flow/v2/state/SignUpPasswordRequiredStateV2.d.ts +0 -19
  567. package/types/custom_auth/sign_up/auth_flow/v2/state/SignUpPasswordRequiredStateV2.d.ts.map +0 -1
@@ -19,10 +19,15 @@ import {
19
19
  FlowSubmitSignInPasswordParamsV2,
20
20
  FlowSubmitSignUpAttributesParamsV2,
21
21
  FlowSignInWithContinuationParamsV2,
22
+ FlowAuthMethodRegistrationRequiredParamsV2,
23
+ FlowRegisterAuthMethodParamsV2,
24
+ FlowVerifyAuthMethodRegistrationParamsV2,
22
25
  } from "./parameter/FlowParamsV2.js";
23
26
  import {
24
27
  createFlowMethodSelectionRequiredResultV2,
25
28
  createFlowCodeRequiredResultV2,
29
+ createFlowExistingAccountCodeRequiredResultV2,
30
+ createFlowExistingAccountPasswordRequiredResultV2,
26
31
  createFlowPasswordRequiredResultV2,
27
32
  createFlowSignUpPasswordRequiredResultV2,
28
33
  createFlowMFARequiredResultV2,
@@ -30,22 +35,27 @@ import {
30
35
  createFlowAttributesRequiredResultV2,
31
36
  createFlowSignInContinuationRequiredResultV2,
32
37
  createFlowCompletedResultV2,
38
+ createFlowAuthMethodRegistrationRequiredResultV2,
39
+ createFlowAuthMethodVerificationRequiredResultV2,
33
40
  FLOW_CODE_REQUIRED_V2,
34
- FLOW_SIGN_IN_CONTINUATION_REQUIRED_V2,
41
+ FLOW_PASSWORD_REQUIRED_V2,
35
42
  } from "./result/FlowActionResultV2.js";
36
43
  import type {
37
- FlowMethodSelectionRequiredResultV2,
38
44
  FlowCodeRequiredResultV2,
39
- FlowSignInCodeRequiredResultV2,
40
- FlowResetPasswordCodeRequiredResultV2,
41
- FlowPasswordRequiredResultV2,
42
- FlowSignUpPasswordRequiredResultV2,
43
- FlowMFARequiredResultV2,
44
- FlowAttributesRequiredResultV2,
45
- FlowSignInContinuationRequiredResultV2,
45
+ FlowExistingAccountChallengeResultV2,
46
46
  FlowCompletedResultV2,
47
- FlowSignUpActionResultV2,
47
+ FlowSignInContinuationRequiredResultV2,
48
+ FlowSignInStartResultV2,
49
+ FlowSignUpStartResultV2,
50
+ FlowResetPasswordStartResultV2,
51
+ FlowRequestChallengeResultV2,
52
+ FlowSubmitNewPasswordResultV2,
53
+ FlowSubmitSignInPasswordResultV2,
54
+ FlowSignUpSubmitAttributesResultV2,
55
+ FlowSignUpVerificationResultV2,
48
56
  FlowSubmitCodeResultV2,
57
+ FlowAuthMethodRegistrationRequiredResultV2,
58
+ FlowAuthMethodVerificationRequiredResultV2,
49
59
  } from "./result/FlowActionResultV2.js";
50
60
  import { BrowserConfiguration } from "../../../../config/Configuration.js";
51
61
  import { BrowserCacheManager } from "../../../../cache/BrowserCacheManager.js";
@@ -71,23 +81,35 @@ import {
71
81
  } from "../../telemetry/FlowApiIdHelperV2.js";
72
82
  import {
73
83
  AuthenticationFactorV2,
74
- ChallengeNextActionV2,
75
84
  type ChallengeVerificationResultV2,
76
- VerifyNextActionV2,
85
+ type EnrollmentResultV2,
77
86
  type VerifyResultV2,
78
87
  } from "../../network_client/custom_auth_api/v2/result/BaseResultsV2.js";
79
- import { AuthenticationMethodTypeV2 } from "../../network_client/custom_auth_api/v2/ApiClientConstantsV2.js";
88
+ import {
89
+ AuthenticationMethodTypeV2,
90
+ CHALLENGE_RELATION,
91
+ COLLECT_ATTRIBUTES_RELATION,
92
+ ENROLL_RELATION,
93
+ POLL_RELATION,
94
+ PhoneRegistrationChannelV2,
95
+ RISK_VERIFY_RELATION,
96
+ UPDATE_RELATION,
97
+ VERIFY_RELATION,
98
+ ResponseStateV2,
99
+ } from "../../network_client/custom_auth_api/v2/ApiClientConstantsV2.js";
80
100
  import type { FlowContinuationStateV2 } from "./FlowContinuationStateV2.js";
81
101
  import type { AuthenticationMethodV2 } from "../../auth_flow/v2/AuthenticationMethodV2.js";
102
+ import type { AuthenticationMethodRegistrationV2 } from "../../auth_flow/v2/AuthenticationMethodRegistrationV2.js";
82
103
  import {
83
104
  SignUpSubmitAttributesNextActionV2,
105
+ type SignUpAttributeV2,
84
106
  type SignUpSubmitAttributesApiResultV2,
85
107
  } from "../../network_client/custom_auth_api/v2/result/SignUpResultsV2.js";
108
+ import type { AuthMethodRegistrationRequestV2 } from "../../network_client/custom_auth_api/v2/request/RequestsV2.js";
109
+ import { InvalidArgumentError } from "../../error/InvalidArgumentError.js";
110
+ import type { ResetPasswordPollResultV2 } from "../../network_client/custom_auth_api/v2/result/ResetPasswordResultsV2.js";
111
+ import * as ArgumentValidator from "../../utils/ArgumentValidator.js";
86
112
 
87
- /*
88
- * Polls up to five times for password-update completion, waiting 1.5 seconds
89
- * between attempts. The first request runs immediately.
90
- */
91
113
  const POLL_MAX_ATTEMPTS = 5;
92
114
  // TODO: Replace this fallback with the server-provided polling interval once available.
93
115
  const POLL_INTERVAL_MS = 1500;
@@ -96,8 +118,7 @@ const delay = (ms: number): Promise<void> =>
96
118
  new Promise((resolve) => setTimeout(resolve, ms));
97
119
 
98
120
  /*
99
- * Drives server-directed Native Auth V2 flows using opaque continuation state
100
- * and HAL links. Each operation returns only its valid discriminated results.
121
+ * Drives server-directed Native Auth V2 flows.
101
122
  */
102
123
  export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
103
124
  constructor(
@@ -124,18 +145,11 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
124
145
  }
125
146
 
126
147
  /*
127
- * Starts sign-in by automatically using a sole supported method or returning
128
- * multiple supported methods for user selection.
148
+ * Starts native auth V2 sign-in.
129
149
  */
130
150
  async signIn(
131
151
  parameters: FlowSignInStartParamsV2
132
- ): Promise<
133
- | FlowMethodSelectionRequiredResultV2
134
- | FlowPasswordRequiredResultV2
135
- | FlowSignInCodeRequiredResultV2
136
- | FlowMFARequiredResultV2
137
- | FlowCompletedResultV2
138
- > {
152
+ ): Promise<FlowSignInStartResultV2> {
139
153
  const correlationId = parameters.correlationId;
140
154
  const context = this.createRequestContext(
141
155
  PublicApiId.SIGN_IN_V2_START,
@@ -214,28 +228,22 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
214
228
  };
215
229
  }
216
230
 
217
- if (parameters.password) {
218
- return this.submitSignInPassword({
219
- correlationId,
220
- continuationState: challengeResult.continuationState,
221
- password: parameters.password,
222
- });
223
- }
224
-
225
231
  return challengeResult;
226
232
  }
227
233
 
228
234
  /*
229
- * Starts sign-up and resolves the server-provided attribute-submission transition.
235
+ * Starts native auth V2 sign-up.
230
236
  */
231
237
  async signUp(
232
238
  parameters: FlowSignUpStartParamsV2
233
- ): Promise<
234
- | FlowCodeRequiredResultV2
235
- | FlowSignUpPasswordRequiredResultV2
236
- | FlowAttributesRequiredResultV2
237
- > {
239
+ ): Promise<FlowSignUpStartResultV2> {
238
240
  const correlationId = parameters.correlationId;
241
+ const pendingProfileAttributes =
242
+ ArgumentValidator.filterReservedSignUpAttributesV2(
243
+ parameters.attributes,
244
+ this.logger,
245
+ correlationId
246
+ );
239
247
  const context = this.createRequestContext(
240
248
  PublicApiId.SIGN_UP_V2_START,
241
249
  correlationId
@@ -257,68 +265,117 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
257
265
  }),
258
266
  {
259
267
  continuationToken: entryResult.continuationToken,
268
+ username: parameters.username,
260
269
  },
261
270
  context
262
271
  );
263
- const attributes = Object.fromEntries(
264
- Object.entries(parameters.attributes ?? {}).filter(
265
- ([name]) =>
266
- name.toLowerCase() !== "email" &&
267
- name.toLowerCase() !== "password"
268
- )
269
- );
270
- attributes.email = parameters.username;
271
- if (parameters.password !== undefined) {
272
- attributes.password = parameters.password;
272
+ if (startResult.nextAction === VERIFY_RELATION) {
273
+ if (
274
+ startResult.type?.toLowerCase() !==
275
+ AuthenticationMethodTypeV2.EMAIL
276
+ ) {
277
+ const message =
278
+ "New-account sign-up requires an email code challenge.";
279
+ this.logger.error(message, correlationId);
280
+ throw new CustomAuthError(
281
+ UNSUPPORTED_FLOW_TRANSITION,
282
+ message,
283
+ correlationId
284
+ );
285
+ }
286
+
287
+ return createFlowCodeRequiredResultV2({
288
+ correlationId,
289
+ continuationState: {
290
+ continuationToken: startResult.continuationToken,
291
+ scenario: CustomAuthFlowScenarioV2.SignUp,
292
+ scopes,
293
+ links: {
294
+ verify: startResult.verifyHref,
295
+ resend: startResult.resendHref,
296
+ },
297
+ signUp: {
298
+ purpose: "newAccount",
299
+ pendingProfileAttributes,
300
+ submittedAttributeIds: [],
301
+ },
302
+ },
303
+ channel: startResult.type,
304
+ sentTo: startResult.hint,
305
+ codeLength: startResult.codeLength,
306
+ });
273
307
  }
274
- const submitResult = await this.apiClient.submitSignUpAttributes(
275
- startResult.submitAttributesHref,
276
- {
277
- continuationToken: startResult.continuationToken,
278
- attributes,
279
- },
280
- context
281
- );
308
+
282
309
  const continuationState: FlowContinuationStateV2 = {
283
310
  continuationToken: startResult.continuationToken,
284
311
  scenario: CustomAuthFlowScenarioV2.SignUp,
285
312
  scopes,
286
313
  links: {},
287
314
  signUp: {
288
- passwordWasSupplied: attributes.password !== undefined,
315
+ purpose: "existingAccount",
289
316
  },
290
317
  };
291
-
292
- const result = this.toSignUpActionResult(
293
- submitResult,
294
- continuationState,
318
+ this.ensureAuthenticationFactor(
319
+ startResult.authenticationFactor,
320
+ AuthenticationFactorV2.SINGLE_FACTOR,
321
+ "existing-account sign-up",
295
322
  correlationId
296
323
  );
324
+ const supportedMethods = startResult.methods
325
+ .map((method) => ({
326
+ id: method.id,
327
+ type: method.type ?? "",
328
+ hint: method.hint,
329
+ challengeHref: method.challengeHref,
330
+ }))
331
+ .filter((method) => {
332
+ const methodType = method.type.toLowerCase();
333
+ return (
334
+ methodType === AuthenticationMethodTypeV2.EMAIL ||
335
+ methodType === AuthenticationMethodTypeV2.PASSWORD
336
+ );
337
+ });
297
338
 
298
- if (result.type === FLOW_SIGN_IN_CONTINUATION_REQUIRED_V2) {
299
- const message =
300
- "Initial sign-up attribute submission cannot complete without code verification or additional attributes.";
301
- this.logger.error(message, correlationId);
339
+ if (supportedMethods.length === 0) {
302
340
  throw new CustomAuthError(
303
341
  UNSUPPORTED_FLOW_TRANSITION,
304
- message,
342
+ "The existing-account sign-up response must include an email or password method.",
305
343
  correlationId
306
344
  );
307
345
  }
308
346
 
309
- return result;
347
+ if (supportedMethods.length > 1) {
348
+ return createFlowMethodSelectionRequiredResultV2({
349
+ correlationId,
350
+ continuationState,
351
+ methods: supportedMethods,
352
+ });
353
+ }
354
+
355
+ const selectedMethod = supportedMethods[0];
356
+ const challengeResult = await this.requestChallenge({
357
+ correlationId,
358
+ continuationState: {
359
+ ...continuationState,
360
+ links: {
361
+ challenge: selectedMethod.challengeHref,
362
+ },
363
+ },
364
+ });
365
+
366
+ return this.toExistingAccountChallengeResult(
367
+ challengeResult,
368
+ selectedMethod,
369
+ correlationId
370
+ );
310
371
  }
311
372
 
312
373
  /*
313
- * Starts password reset, automatically challenging a sole method or
314
- * returning multiple methods for selection.
374
+ * Starts native auth V2 password reset.
315
375
  */
316
376
  async resetPassword(
317
377
  parameters: FlowStartParamsV2
318
- ): Promise<
319
- | FlowMethodSelectionRequiredResultV2
320
- | FlowResetPasswordCodeRequiredResultV2
321
- > {
378
+ ): Promise<FlowResetPasswordStartResultV2> {
322
379
  const correlationId = parameters.correlationId;
323
380
  const context = this.createRequestContext(
324
381
  PublicApiId.RESET_PASSWORD_V2_START,
@@ -378,63 +435,62 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
378
435
  );
379
436
  }
380
437
 
381
- if (methods.length === 1) {
382
- const selectedMethod = methods[0];
383
- const challengeResult = await this.requestChallenge({
438
+ if (methods.length > 1) {
439
+ this.logger.verbose(
440
+ "V2 self-service password reset method selection required.",
441
+ correlationId
442
+ );
443
+
444
+ return createFlowMethodSelectionRequiredResultV2({
384
445
  correlationId,
385
- continuationState: {
386
- ...continuationState,
387
- links: {
388
- challenge: selectedMethod.challengeHref,
389
- },
390
- },
446
+ continuationState,
447
+ methods,
391
448
  });
449
+ }
392
450
 
393
- if (
394
- challengeResult.type === FLOW_CODE_REQUIRED_V2 &&
395
- (challengeResult.channel?.toLowerCase() ===
396
- AuthenticationMethodTypeV2.EMAIL ||
397
- challengeResult.channel?.toLowerCase() ===
398
- AuthenticationMethodTypeV2.SMS)
399
- ) {
400
- return {
401
- ...challengeResult,
402
- method: selectedMethod,
403
- };
404
- }
451
+ const selectedMethod = methods[0];
452
+ const challengeResult = await this.requestChallenge({
453
+ correlationId,
454
+ continuationState: {
455
+ ...continuationState,
456
+ links: {
457
+ challenge: selectedMethod.challengeHref,
458
+ },
459
+ },
460
+ });
405
461
 
406
- const channel =
407
- challengeResult.type === FLOW_CODE_REQUIRED_V2
408
- ? challengeResult.channel
409
- : AuthenticationMethodTypeV2.PASSWORD;
410
- const message = `Challenge type '${challengeResult.type}' with channel '${channel}' is not supported for password reset.`;
411
- this.logger.error(message, correlationId);
412
- throw new CustomAuthError(
413
- UNSUPPORTED_FLOW_TRANSITION,
414
- message,
415
- correlationId
416
- );
462
+ if (
463
+ challengeResult.type === FLOW_CODE_REQUIRED_V2 &&
464
+ (challengeResult.channel?.toLowerCase() ===
465
+ AuthenticationMethodTypeV2.EMAIL ||
466
+ challengeResult.channel?.toLowerCase() ===
467
+ AuthenticationMethodTypeV2.SMS)
468
+ ) {
469
+ return {
470
+ ...challengeResult,
471
+ method: selectedMethod,
472
+ };
417
473
  }
418
474
 
419
- this.logger.verbose(
420
- "V2 self-service password reset method selection required.",
475
+ const channel =
476
+ challengeResult.type === FLOW_CODE_REQUIRED_V2
477
+ ? challengeResult.channel
478
+ : AuthenticationMethodTypeV2.PASSWORD;
479
+ const message = `Challenge type '${challengeResult.type}' with channel '${channel}' is not supported for password reset.`;
480
+ this.logger.error(message, correlationId);
481
+ throw new CustomAuthError(
482
+ UNSUPPORTED_FLOW_TRANSITION,
483
+ message,
421
484
  correlationId
422
485
  );
423
-
424
- return createFlowMethodSelectionRequiredResultV2({
425
- correlationId,
426
- continuationState,
427
- methods,
428
- });
429
486
  }
430
487
 
431
488
  /*
432
- * Requests a one-time code for the selected authentication method. Returns
433
- * the continuation state and code metadata needed for verification.
489
+ * Requests a challenge for the selected authentication method.
434
490
  */
435
491
  async requestChallenge(
436
492
  parameters: FlowChallengeParamsV2
437
- ): Promise<FlowCodeRequiredResultV2 | FlowPasswordRequiredResultV2> {
493
+ ): Promise<FlowRequestChallengeResultV2> {
438
494
  const challengeResult = await this.sendMethodChallenge(
439
495
  parameters,
440
496
  "requestChallenge"
@@ -478,8 +534,127 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
478
534
  }
479
535
 
480
536
  /*
481
- * Verifies the submitted one-time code using the server-provided link. The
482
- * response determines the next required action.
537
+ * Registers the selected authentication method.
538
+ */
539
+ async registerAuthMethod(
540
+ parameters: FlowRegisterAuthMethodParamsV2
541
+ ): Promise<FlowAuthMethodVerificationRequiredResultV2> {
542
+ const { continuationState, correlationId } = parameters;
543
+ if (!parameters.verificationContact?.trim()) {
544
+ throw new InvalidArgumentError(
545
+ "verificationContact",
546
+ correlationId
547
+ );
548
+ }
549
+
550
+ const registrationRequest = this.createRegistrationRequest(
551
+ parameters.method,
552
+ parameters.verificationContact,
553
+ continuationState.continuationToken,
554
+ correlationId
555
+ );
556
+ const context = this.createRequestContext(
557
+ PublicApiId.JIT_V2_ENROLL_AUTH_METHOD,
558
+ correlationId
559
+ );
560
+
561
+ this.logger.verbose(
562
+ "Registering a V2 authentication method.",
563
+ correlationId
564
+ );
565
+ const result = await this.apiClient.enrollAuthMethod(
566
+ this.requireLink(correlationId, parameters.method.enrollHref),
567
+ registrationRequest,
568
+ context
569
+ );
570
+
571
+ return this.createAuthMethodVerificationRequiredResult(
572
+ continuationState,
573
+ result,
574
+ correlationId
575
+ );
576
+ }
577
+
578
+ /*
579
+ * Activates the registered authentication method.
580
+ */
581
+ async verifyAuthMethodRegistration(
582
+ parameters: FlowVerifyAuthMethodRegistrationParamsV2
583
+ ): Promise<FlowCompletedResultV2 | FlowSignInContinuationRequiredResultV2> {
584
+ const { continuationState, correlationId } = parameters;
585
+
586
+ const context = this.createRequestContext(
587
+ PublicApiId.JIT_V2_SUBMIT_CHALLENGE,
588
+ correlationId
589
+ );
590
+ this.logger.verbose(
591
+ "Activating a V2 authentication method.",
592
+ correlationId
593
+ );
594
+ const result = await this.apiClient.activateAuthMethod(
595
+ this.requireLink(correlationId, continuationState.links.activate),
596
+ {
597
+ continuationToken: continuationState.continuationToken,
598
+ otp: parameters.code,
599
+ },
600
+ context
601
+ );
602
+
603
+ if (
604
+ continuationState.scenario === CustomAuthFlowScenarioV2.SignUp ||
605
+ continuationState.scenario ===
606
+ CustomAuthFlowScenarioV2.PasswordReset
607
+ ) {
608
+ return createFlowSignInContinuationRequiredResultV2({
609
+ correlationId,
610
+ continuationState: {
611
+ ...continuationState,
612
+ continuationToken: result.continuationToken,
613
+ links: {},
614
+ },
615
+ });
616
+ }
617
+
618
+ return this.completeSignInAfterVerification(
619
+ continuationState,
620
+ result.continuationToken,
621
+ correlationId
622
+ );
623
+ }
624
+
625
+ /*
626
+ * Requests a replacement authentication-method activation challenge.
627
+ */
628
+ async resendAuthMethodRegistrationChallenge(
629
+ parameters: FlowChallengeParamsV2
630
+ ): Promise<FlowAuthMethodVerificationRequiredResultV2> {
631
+ const { continuationState, correlationId } = parameters;
632
+ const context = this.createRequestContext(
633
+ PublicApiId.JIT_V2_RESEND_CHALLENGE,
634
+ correlationId
635
+ );
636
+ this.logger.verbose(
637
+ "Resending a V2 authentication-method activation challenge.",
638
+ correlationId
639
+ );
640
+ const result =
641
+ await this.apiClient.resendAuthMethodRegistrationChallenge(
642
+ this.requireLink(correlationId, continuationState.links.resend),
643
+ {
644
+ continuationToken: continuationState.continuationToken,
645
+ },
646
+ context
647
+ );
648
+
649
+ return this.createAuthMethodVerificationRequiredResult(
650
+ continuationState,
651
+ result,
652
+ correlationId
653
+ );
654
+ }
655
+
656
+ /*
657
+ * Verifies the submitted one-time code.
483
658
  */
484
659
  async submitCode(
485
660
  parameters: FlowSubmitCodeParamsV2
@@ -490,7 +665,8 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
490
665
  this.resolveStepApiId(
491
666
  continuationState.scenario,
492
667
  "submitCode",
493
- correlationId
668
+ correlationId,
669
+ parameters.authenticationFactor
494
670
  ),
495
671
  correlationId
496
672
  );
@@ -514,7 +690,26 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
514
690
  if (
515
691
  continuationState.scenario ===
516
692
  CustomAuthFlowScenarioV2.PasswordReset &&
517
- verifyResult.nextAction === VerifyNextActionV2.UPDATE
693
+ parameters.authenticationFactor ===
694
+ AuthenticationFactorV2.MULTI_FACTOR &&
695
+ verifyResult.nextAction === ResponseStateV2.CONTINUE
696
+ ) {
697
+ return createFlowSignInContinuationRequiredResultV2({
698
+ correlationId,
699
+ continuationState: {
700
+ ...continuationState,
701
+ continuationToken: verifyResult.continuationToken,
702
+ links: {},
703
+ },
704
+ });
705
+ }
706
+
707
+ if (
708
+ continuationState.scenario ===
709
+ CustomAuthFlowScenarioV2.PasswordReset &&
710
+ parameters.authenticationFactor !==
711
+ AuthenticationFactorV2.MULTI_FACTOR &&
712
+ verifyResult.nextAction === UPDATE_RELATION
518
713
  ) {
519
714
  return createFlowNewPasswordRequiredResultV2({
520
715
  correlationId,
@@ -537,59 +732,21 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
537
732
 
538
733
  if (
539
734
  continuationState.scenario === CustomAuthFlowScenarioV2.SignUp &&
540
- verifyResult.nextAction === VerifyNextActionV2.COLLECT_ATTRIBUTES
735
+ continuationState.signUp?.purpose === "existingAccount"
541
736
  ) {
542
- const requiredPasswordAttribute = verifyResult.attributes.find(
543
- (attribute) =>
544
- attribute.attributeId.toLowerCase() === "password" &&
545
- attribute.required === true
546
- );
547
- const nextContinuationState: FlowContinuationStateV2 = {
548
- continuationToken: verifyResult.continuationToken,
549
- scenario: continuationState.scenario,
550
- scopes: continuationState.scopes,
551
- links: {
552
- submitAttributes: verifyResult.submitAttributesHref,
553
- },
554
- signUp: continuationState.signUp,
555
- };
556
- const attributes = verifyResult.attributes.filter(
557
- (attribute) =>
558
- attribute.attributeId.toLowerCase() !== "password"
737
+ return this.handleSignInVerification(
738
+ continuationState,
739
+ verifyResult,
740
+ correlationId
559
741
  );
560
-
561
- if (
562
- requiredPasswordAttribute &&
563
- continuationState.signUp?.passwordWasSupplied !== true
564
- ) {
565
- return createFlowSignUpPasswordRequiredResultV2({
566
- correlationId,
567
- continuationState: nextContinuationState,
568
- attributes,
569
- requiredPasswordAttribute,
570
- });
571
- }
572
-
573
- return createFlowAttributesRequiredResultV2({
574
- correlationId,
575
- continuationState: nextContinuationState,
576
- attributes,
577
- });
578
742
  }
579
743
 
580
- if (
581
- continuationState.scenario === CustomAuthFlowScenarioV2.SignUp &&
582
- verifyResult.nextAction === VerifyNextActionV2.CONTINUE
583
- ) {
584
- return createFlowSignInContinuationRequiredResultV2({
585
- correlationId,
586
- continuationState: {
587
- continuationToken: verifyResult.continuationToken,
588
- scenario: continuationState.scenario,
589
- scopes: continuationState.scopes,
590
- links: {},
591
- },
592
- });
744
+ if (continuationState.scenario === CustomAuthFlowScenarioV2.SignUp) {
745
+ return this.handleSignUpVerification(
746
+ continuationState,
747
+ verifyResult,
748
+ correlationId
749
+ );
593
750
  }
594
751
 
595
752
  const message = `Verification next action '${verifyResult.nextAction}' is not supported for the '${continuationState.scenario}' flow.`;
@@ -603,8 +760,7 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
603
760
  }
604
761
 
605
762
  /*
606
- * Requests a new one-time code using the server-provided resend link.
607
- * Returns refreshed continuation state and code metadata.
763
+ * Requests a replacement one-time code.
608
764
  */
609
765
  async resendCode(
610
766
  parameters: FlowChallengeParamsV2
@@ -613,6 +769,20 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
613
769
  parameters,
614
770
  "resendCode"
615
771
  );
772
+ const challengeType = challengeResult.type?.toLowerCase();
773
+ if (
774
+ challengeType !== AuthenticationMethodTypeV2.EMAIL &&
775
+ challengeType !== AuthenticationMethodTypeV2.SMS
776
+ ) {
777
+ const message =
778
+ "A replacement code requires an email or SMS code challenge.";
779
+ this.logger.error(message, parameters.correlationId);
780
+ throw new CustomAuthError(
781
+ UNSUPPORTED_FLOW_TRANSITION,
782
+ message,
783
+ parameters.correlationId
784
+ );
785
+ }
616
786
 
617
787
  return createFlowCodeRequiredResultV2({
618
788
  correlationId: parameters.correlationId,
@@ -628,8 +798,12 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
628
798
 
629
799
  async submitSignUpAttributes(
630
800
  parameters: FlowSubmitSignUpAttributesParamsV2
631
- ): Promise<FlowSignUpActionResultV2> {
632
- const { continuationState, correlationId, attributes } = parameters;
801
+ ): Promise<FlowSignUpSubmitAttributesResultV2> {
802
+ const {
803
+ continuationState,
804
+ correlationId,
805
+ attributes: submittedAttributes,
806
+ } = parameters;
633
807
  const context = this.createRequestContext(
634
808
  this.resolveStepApiId(
635
809
  continuationState.scenario,
@@ -644,6 +818,7 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
644
818
  correlationId
645
819
  );
646
820
 
821
+ const submittedAttributeIds = Object.keys(submittedAttributes);
647
822
  const submitResult = await this.apiClient.submitSignUpAttributes(
648
823
  this.requireLink(
649
824
  correlationId,
@@ -651,19 +826,24 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
651
826
  ),
652
827
  {
653
828
  continuationToken: continuationState.continuationToken,
654
- attributes,
829
+ attributes: submittedAttributes,
655
830
  },
656
831
  context
657
832
  );
658
833
 
659
- return this.toSignUpActionResult(
834
+ return this.toSignUpSubmitAttributesResult(
660
835
  submitResult,
661
836
  {
662
837
  ...continuationState,
663
838
  signUp: {
664
- passwordWasSupplied:
665
- continuationState.signUp?.passwordWasSupplied ===
666
- true || attributes.password !== undefined,
839
+ purpose: "newAccount",
840
+ submittedAttributeIds: [
841
+ ...new Set([
842
+ ...(continuationState.signUp
843
+ ?.submittedAttributeIds ?? []),
844
+ ...submittedAttributeIds,
845
+ ]),
846
+ ],
667
847
  },
668
848
  },
669
849
  correlationId
@@ -671,12 +851,12 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
671
851
  }
672
852
 
673
853
  /*
674
- * Submits the new password and polls until the reset completes. The result
675
- * contains the continuation state required for explicit sign-in.
854
+ * Submits the new password and polls for the next action: method registration,
855
+ * MFA, or a continuation for explicit sign-in.
676
856
  */
677
857
  async submitNewPassword(
678
858
  parameters: FlowSubmitNewPasswordParamsV2
679
- ): Promise<FlowSignInContinuationRequiredResultV2> {
859
+ ): Promise<FlowSubmitNewPasswordResultV2> {
680
860
  const continuationState = parameters.continuationState;
681
861
  const correlationId = parameters.correlationId;
682
862
  const context = this.createRequestContext(
@@ -701,29 +881,30 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
701
881
 
702
882
  let pollToken = updateResult.continuationToken;
703
883
  let pollHref = updateResult.pollHref;
704
- let completionToken: string | undefined;
884
+ let pollResult: ResetPasswordPollResultV2 | undefined;
885
+ let isPolling = false;
705
886
 
706
887
  for (let attempt = 1; attempt <= POLL_MAX_ATTEMPTS; attempt++) {
707
- const pollResult = await this.apiClient.poll(
888
+ pollResult = await this.apiClient.poll(
708
889
  pollHref,
709
890
  { continuationToken: pollToken },
710
891
  context
711
892
  );
712
893
 
713
- if (pollResult.isCompleted) {
714
- completionToken = pollResult.continuationToken;
894
+ isPolling = pollResult.nextAction === POLL_RELATION;
895
+ if (pollResult.nextAction !== POLL_RELATION) {
715
896
  break;
716
897
  }
717
898
 
718
899
  pollToken = pollResult.continuationToken;
719
- pollHref = pollResult.pollHref ?? pollHref;
900
+ pollHref = this.requireLink(correlationId, pollResult.pollHref);
720
901
 
721
902
  if (attempt < POLL_MAX_ATTEMPTS) {
722
903
  await delay(POLL_INTERVAL_MS);
723
904
  }
724
905
  }
725
906
 
726
- if (!completionToken) {
907
+ if (!pollResult || isPolling) {
727
908
  const message =
728
909
  "The password reset did not complete within the allotted number of polling attempts.";
729
910
  this.logger.error(message, correlationId);
@@ -735,28 +916,86 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
735
916
  );
736
917
  }
737
918
 
738
- this.logger.verbose(
739
- "V2 password reset applied; sign-in required.",
919
+ if (pollResult.nextAction === ENROLL_RELATION && pollResult.methods) {
920
+ return this.createAuthMethodRegistrationRequiredResult({
921
+ correlationId,
922
+ continuationState: {
923
+ ...continuationState,
924
+ continuationToken: pollResult.continuationToken,
925
+ links: {},
926
+ },
927
+ methods: pollResult.methods,
928
+ });
929
+ }
930
+
931
+ if (pollResult.nextAction === CHALLENGE_RELATION) {
932
+ if (!pollResult.authenticationFactor) {
933
+ const message =
934
+ "Password-reset MFA challenge is missing its authentication factor.";
935
+ this.logger.error(message, correlationId);
936
+ throw new CustomAuthError(
937
+ UNSUPPORTED_FLOW_TRANSITION,
938
+ message,
939
+ correlationId
940
+ );
941
+ }
942
+
943
+ this.ensureAuthenticationFactor(
944
+ pollResult.authenticationFactor,
945
+ AuthenticationFactorV2.MULTI_FACTOR,
946
+ "after password reset",
947
+ correlationId
948
+ );
949
+
950
+ return createFlowMFARequiredResultV2({
951
+ correlationId,
952
+ continuationState: {
953
+ continuationToken: pollResult.continuationToken,
954
+ scenario: continuationState.scenario,
955
+ scopes: continuationState.scopes,
956
+ links: {},
957
+ },
958
+ methods: pollResult.methods.map((method) => ({
959
+ id: method.id,
960
+ type: method.type ?? "",
961
+ hint: method.hint,
962
+ challengeHref: method.challengeHref,
963
+ })),
964
+ });
965
+ }
966
+
967
+ if (pollResult.nextAction === ResponseStateV2.CONTINUE) {
968
+ this.logger.verbose(
969
+ "V2 password reset applied; sign-in required.",
970
+ correlationId
971
+ );
972
+
973
+ return createFlowSignInContinuationRequiredResultV2({
974
+ correlationId,
975
+ continuationState: {
976
+ continuationToken: pollResult.continuationToken,
977
+ scenario: continuationState.scenario,
978
+ scopes: continuationState.scopes,
979
+ links: {},
980
+ },
981
+ });
982
+ }
983
+
984
+ const message = `Password reset poll next action '${pollResult.nextAction}' is not supported.`;
985
+ this.logger.error(message, correlationId);
986
+ throw new CustomAuthError(
987
+ UNSUPPORTED_FLOW_TRANSITION,
988
+ message,
740
989
  correlationId
741
990
  );
742
-
743
- return createFlowSignInContinuationRequiredResultV2({
744
- correlationId,
745
- continuationState: {
746
- continuationToken: completionToken,
747
- scenario: continuationState.scenario,
748
- scopes: continuationState.scopes,
749
- links: {},
750
- },
751
- });
752
991
  }
753
992
 
754
993
  /*
755
- * Verifies a sign-in password and returns the next sign-in action.
994
+ * Verifies the sign-in password.
756
995
  */
757
996
  async submitSignInPassword(
758
997
  parameters: FlowSubmitSignInPasswordParamsV2
759
- ): Promise<FlowMFARequiredResultV2 | FlowCompletedResultV2> {
998
+ ): Promise<FlowSubmitSignInPasswordResultV2> {
760
999
  const verifyResult = await this.verifySignInPassword(parameters);
761
1000
 
762
1001
  return this.handleSignInVerification(
@@ -767,8 +1006,7 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
767
1006
  }
768
1007
 
769
1008
  /*
770
- * Redeems the completed flow continuation for tokens. Returns the
771
- * authentication result after validating and caching the response.
1009
+ * Signs the user in from a completed flow.
772
1010
  */
773
1011
  async signInWithContinuation(
774
1012
  parameters: FlowSignInWithContinuationParamsV2
@@ -816,21 +1054,32 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
816
1054
  continuationState: FlowContinuationStateV2,
817
1055
  verifyResult: VerifyResultV2,
818
1056
  correlationId: string
819
- ): Promise<FlowMFARequiredResultV2 | FlowCompletedResultV2> {
820
- if (verifyResult.nextAction === VerifyNextActionV2.CHALLENGE) {
1057
+ ): Promise<FlowSubmitSignInPasswordResultV2> {
1058
+ if (verifyResult.nextAction === ENROLL_RELATION) {
1059
+ return this.createAuthMethodRegistrationRequiredResult({
1060
+ correlationId,
1061
+ continuationState: {
1062
+ ...continuationState,
1063
+ continuationToken: verifyResult.continuationToken,
1064
+ links: {},
1065
+ },
1066
+ methods: verifyResult.methods,
1067
+ });
1068
+ }
1069
+
1070
+ if (verifyResult.nextAction === CHALLENGE_RELATION) {
821
1071
  this.ensureAuthenticationFactor(
822
1072
  verifyResult.authenticationFactor,
823
1073
  AuthenticationFactorV2.MULTI_FACTOR,
824
- "after sign-in verification",
1074
+ "after authentication verification",
825
1075
  correlationId
826
1076
  );
827
1077
 
828
1078
  return createFlowMFARequiredResultV2({
829
1079
  correlationId,
830
1080
  continuationState: {
1081
+ ...continuationState,
831
1082
  continuationToken: verifyResult.continuationToken,
832
- scenario: continuationState.scenario,
833
- scopes: continuationState.scopes,
834
1083
  links: {},
835
1084
  },
836
1085
  methods: verifyResult.methods.map((method) => ({
@@ -842,7 +1091,7 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
842
1091
  });
843
1092
  }
844
1093
 
845
- if (verifyResult.nextAction === VerifyNextActionV2.CONTINUE) {
1094
+ if (verifyResult.nextAction === ResponseStateV2.CONTINUE) {
846
1095
  return this.completeSignInAfterVerification(
847
1096
  continuationState,
848
1097
  verifyResult.continuationToken,
@@ -850,7 +1099,86 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
850
1099
  );
851
1100
  }
852
1101
 
853
- const message = `Verification next action '${verifyResult.nextAction}' is not supported for sign-in.`;
1102
+ const message = `Verification next action '${verifyResult.nextAction}' is not supported for authentication.`;
1103
+ this.logger.error(message, correlationId);
1104
+ throw new CustomAuthError(
1105
+ UNSUPPORTED_FLOW_TRANSITION,
1106
+ message,
1107
+ correlationId
1108
+ );
1109
+ }
1110
+
1111
+ private async handleSignUpVerification(
1112
+ continuationState: FlowContinuationStateV2,
1113
+ verifyResult: VerifyResultV2,
1114
+ correlationId: string
1115
+ ): Promise<FlowSignUpVerificationResultV2> {
1116
+ if (verifyResult.nextAction === COLLECT_ATTRIBUTES_RELATION) {
1117
+ const requestedAttributes = verifyResult.attributes;
1118
+ const requestedPasswordAttribute = requestedAttributes.find(
1119
+ (attribute) =>
1120
+ attribute.attributeId.toLowerCase() === "password"
1121
+ );
1122
+ const nextContinuationState: FlowContinuationStateV2 = {
1123
+ ...continuationState,
1124
+ continuationToken: verifyResult.continuationToken,
1125
+ links: {
1126
+ submitAttributes: verifyResult.submitAttributesHref,
1127
+ },
1128
+ };
1129
+ const pendingProfileAttributes =
1130
+ continuationState.signUp?.pendingProfileAttributes;
1131
+
1132
+ if (
1133
+ pendingProfileAttributes &&
1134
+ Object.keys(pendingProfileAttributes).length > 0
1135
+ ) {
1136
+ return this.submitSignUpAttributes({
1137
+ correlationId,
1138
+ continuationState: nextContinuationState,
1139
+ attributes: pendingProfileAttributes,
1140
+ });
1141
+ }
1142
+
1143
+ if (requestedPasswordAttribute) {
1144
+ return createFlowSignUpPasswordRequiredResultV2({
1145
+ correlationId,
1146
+ continuationState: nextContinuationState,
1147
+ requestedPasswordAttribute,
1148
+ });
1149
+ }
1150
+
1151
+ return createFlowAttributesRequiredResultV2({
1152
+ correlationId,
1153
+ continuationState: nextContinuationState,
1154
+ attributes: requestedAttributes,
1155
+ });
1156
+ }
1157
+
1158
+ if (verifyResult.nextAction === ENROLL_RELATION) {
1159
+ return this.createAuthMethodRegistrationRequiredResult({
1160
+ correlationId,
1161
+ continuationState: {
1162
+ ...continuationState,
1163
+ continuationToken: verifyResult.continuationToken,
1164
+ links: {},
1165
+ },
1166
+ methods: verifyResult.methods,
1167
+ });
1168
+ }
1169
+
1170
+ if (verifyResult.nextAction === ResponseStateV2.CONTINUE) {
1171
+ return createFlowSignInContinuationRequiredResultV2({
1172
+ correlationId,
1173
+ continuationState: {
1174
+ ...continuationState,
1175
+ continuationToken: verifyResult.continuationToken,
1176
+ links: {},
1177
+ },
1178
+ });
1179
+ }
1180
+
1181
+ const message = `Verification next action '${verifyResult.nextAction}' is not supported for the '${continuationState.scenario}' flow.`;
854
1182
  this.logger.error(message, correlationId);
855
1183
  throw new CustomAuthError(
856
1184
  UNSUPPORTED_FLOW_TRANSITION,
@@ -886,29 +1214,148 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
886
1214
  );
887
1215
  }
888
1216
 
889
- private toSignUpActionResult(
1217
+ private createRegistrationRequest(
1218
+ method: AuthenticationMethodRegistrationV2,
1219
+ verificationContact: string,
1220
+ continuationToken: string,
1221
+ correlationId: string
1222
+ ): AuthMethodRegistrationRequestV2 {
1223
+ if (method.type === AuthenticationMethodTypeV2.EMAIL) {
1224
+ return {
1225
+ continuationToken,
1226
+ email: verificationContact,
1227
+ };
1228
+ }
1229
+
1230
+ const [channel] = method.channels ?? [];
1231
+ if (
1232
+ method.type === AuthenticationMethodTypeV2.PHONE &&
1233
+ channel === PhoneRegistrationChannelV2.SMS
1234
+ ) {
1235
+ return {
1236
+ continuationToken,
1237
+ phoneNumber: verificationContact,
1238
+ channel,
1239
+ };
1240
+ }
1241
+
1242
+ throw new CustomAuthError(
1243
+ UNSUPPORTED_FLOW_TRANSITION,
1244
+ "The selected authentication method is not supported for registration.",
1245
+ correlationId
1246
+ );
1247
+ }
1248
+
1249
+ private createAuthMethodRegistrationRequiredResult(
1250
+ parameters: FlowAuthMethodRegistrationRequiredParamsV2
1251
+ ): FlowAuthMethodRegistrationRequiredResultV2 {
1252
+ const { correlationId, continuationState } = parameters;
1253
+ const supportedMethods = parameters.methods.filter((method) => {
1254
+ const methodType = method.type.trim().toLowerCase();
1255
+ return (
1256
+ methodType === AuthenticationMethodTypeV2.EMAIL ||
1257
+ (methodType === AuthenticationMethodTypeV2.PHONE &&
1258
+ method.channels?.includes(PhoneRegistrationChannelV2.SMS))
1259
+ );
1260
+ });
1261
+
1262
+ if (supportedMethods.length === 0) {
1263
+ const message =
1264
+ "The enrollment response did not include a supported registration method.";
1265
+ this.logger.error(message, correlationId);
1266
+ throw new CustomAuthError(
1267
+ UNSUPPORTED_FLOW_TRANSITION,
1268
+ message,
1269
+ correlationId
1270
+ );
1271
+ }
1272
+
1273
+ const methods = supportedMethods.map((method) => {
1274
+ const methodType = method.type.trim().toLowerCase();
1275
+ const channel = method.channels?.find(
1276
+ (candidate) => candidate === PhoneRegistrationChannelV2.SMS
1277
+ );
1278
+
1279
+ if (methodType === AuthenticationMethodTypeV2.EMAIL) {
1280
+ return {
1281
+ type: AuthenticationMethodTypeV2.EMAIL,
1282
+ enrollHref: this.requireLink(
1283
+ correlationId,
1284
+ method.enrollHref
1285
+ ),
1286
+ };
1287
+ }
1288
+
1289
+ if (
1290
+ methodType === AuthenticationMethodTypeV2.PHONE &&
1291
+ channel === PhoneRegistrationChannelV2.SMS
1292
+ ) {
1293
+ return {
1294
+ type: AuthenticationMethodTypeV2.PHONE,
1295
+ channels: [channel],
1296
+ enrollHref: this.requireLink(
1297
+ correlationId,
1298
+ method.enrollHref
1299
+ ),
1300
+ };
1301
+ }
1302
+
1303
+ const message =
1304
+ "The enrollment response included an unsupported registration method.";
1305
+ this.logger.error(message, correlationId);
1306
+ throw new CustomAuthError(
1307
+ UNSUPPORTED_FLOW_TRANSITION,
1308
+ message,
1309
+ correlationId
1310
+ );
1311
+ });
1312
+
1313
+ return createFlowAuthMethodRegistrationRequiredResultV2({
1314
+ correlationId,
1315
+ continuationState,
1316
+ methods,
1317
+ });
1318
+ }
1319
+
1320
+ private createAuthMethodVerificationRequiredResult(
1321
+ continuationState: FlowContinuationStateV2,
1322
+ result: EnrollmentResultV2,
1323
+ correlationId: string
1324
+ ): FlowAuthMethodVerificationRequiredResultV2 {
1325
+ return createFlowAuthMethodVerificationRequiredResultV2({
1326
+ correlationId,
1327
+ continuationState: {
1328
+ ...continuationState,
1329
+ continuationToken: result.continuationToken,
1330
+ links: {
1331
+ activate: this.requireLink(
1332
+ correlationId,
1333
+ result.activateHref
1334
+ ),
1335
+ resend: result.resendHref,
1336
+ },
1337
+ },
1338
+ sentTo: result.hint,
1339
+ codeLength: result.codeLength,
1340
+ });
1341
+ }
1342
+
1343
+ private toSignUpSubmitAttributesResult(
890
1344
  result: SignUpSubmitAttributesApiResultV2,
891
1345
  continuationState: FlowContinuationStateV2,
892
1346
  correlationId: string
893
- ): FlowSignUpActionResultV2 {
1347
+ ): FlowSignUpSubmitAttributesResultV2 {
894
1348
  const nextAction: string = result.nextAction;
895
1349
 
896
- if (result.nextAction === SignUpSubmitAttributesNextActionV2.VERIFY) {
897
- return createFlowCodeRequiredResultV2({
1350
+ if (result.nextAction === SignUpSubmitAttributesNextActionV2.ENROLL) {
1351
+ return this.createAuthMethodRegistrationRequiredResult({
898
1352
  correlationId,
899
1353
  continuationState: {
1354
+ ...continuationState,
900
1355
  continuationToken: result.continuationToken,
901
- scenario: continuationState.scenario,
902
- scopes: continuationState.scopes,
903
- links: {
904
- verify: result.verifyHref,
905
- resend: result.resendHref,
906
- },
907
- signUp: continuationState.signUp,
1356
+ links: {},
908
1357
  },
909
- channel: result.type,
910
- sentTo: result.hint,
911
- codeLength: result.codeLength,
1358
+ methods: result.methods,
912
1359
  });
913
1360
  }
914
1361
 
@@ -916,41 +1363,36 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
916
1363
  result.nextAction ===
917
1364
  SignUpSubmitAttributesNextActionV2.COLLECT_ATTRIBUTES
918
1365
  ) {
919
- const requiredPasswordAttribute = result.attributes.find(
920
- (attribute) =>
921
- attribute.attributeId.toLowerCase() === "password" &&
922
- attribute.required === true
1366
+ const requestedAttributes = result.attributes;
1367
+ this.ensureValidSignUpAttributeCollectionAfterSubmission(
1368
+ requestedAttributes,
1369
+ continuationState,
1370
+ correlationId
923
1371
  );
924
1372
  const nextContinuationState: FlowContinuationStateV2 = {
1373
+ ...continuationState,
925
1374
  continuationToken: result.continuationToken,
926
- scenario: continuationState.scenario,
927
- scopes: continuationState.scopes,
928
1375
  links: {
929
1376
  submitAttributes: result.submitAttributesHref,
930
1377
  },
931
- signUp: continuationState.signUp,
932
1378
  };
933
- const attributes = result.attributes.filter(
1379
+
1380
+ const requestedPasswordAttribute = requestedAttributes.find(
934
1381
  (attribute) =>
935
- attribute.attributeId.toLowerCase() !== "password"
1382
+ attribute.attributeId.toLowerCase() === "password"
936
1383
  );
937
-
938
- if (
939
- requiredPasswordAttribute &&
940
- continuationState.signUp?.passwordWasSupplied !== true
941
- ) {
1384
+ if (requestedPasswordAttribute) {
942
1385
  return createFlowSignUpPasswordRequiredResultV2({
943
1386
  correlationId,
944
1387
  continuationState: nextContinuationState,
945
- attributes,
946
- requiredPasswordAttribute,
1388
+ requestedPasswordAttribute,
947
1389
  });
948
1390
  }
949
1391
 
950
1392
  return createFlowAttributesRequiredResultV2({
951
1393
  correlationId,
952
1394
  continuationState: nextContinuationState,
953
- attributes,
1395
+ attributes: requestedAttributes,
954
1396
  });
955
1397
  }
956
1398
 
@@ -958,9 +1400,8 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
958
1400
  return createFlowSignInContinuationRequiredResultV2({
959
1401
  correlationId,
960
1402
  continuationState: {
1403
+ ...continuationState,
961
1404
  continuationToken: result.continuationToken,
962
- scenario: continuationState.scenario,
963
- scopes: continuationState.scopes,
964
1405
  links: {},
965
1406
  },
966
1407
  });
@@ -975,6 +1416,38 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
975
1416
  );
976
1417
  }
977
1418
 
1419
+ private ensureValidSignUpAttributeCollectionAfterSubmission(
1420
+ requestedAttributes: SignUpAttributeV2[],
1421
+ continuationState: FlowContinuationStateV2,
1422
+ correlationId: string
1423
+ ): void {
1424
+ const submittedAttributeIds =
1425
+ continuationState.signUp?.submittedAttributeIds ?? [];
1426
+ const hasSubmittedPassword = submittedAttributeIds.some(
1427
+ (attributeId) => attributeId.toLowerCase() === "password"
1428
+ );
1429
+ const invalidAttribute = requestedAttributes.find(
1430
+ (requestedAttribute) =>
1431
+ requestedAttribute.attributeId.toLowerCase() === "password"
1432
+ ? hasSubmittedPassword
1433
+ : submittedAttributeIds.includes(
1434
+ requestedAttribute.attributeId
1435
+ )
1436
+ );
1437
+ if (invalidAttribute) {
1438
+ const message =
1439
+ invalidAttribute.attributeId.toLowerCase() === "password"
1440
+ ? "The sign-up API cannot request password collection after attribute submission."
1441
+ : "The sign-up API requested an attribute that was already successfully submitted.";
1442
+ this.logger.error(message, correlationId);
1443
+ throw new CustomAuthError(
1444
+ UNSUPPORTED_FLOW_TRANSITION,
1445
+ message,
1446
+ correlationId
1447
+ );
1448
+ }
1449
+ }
1450
+
978
1451
  private ensureAuthenticationFactor(
979
1452
  authenticationFactor: AuthenticationFactorV2,
980
1453
  expectedFactor: AuthenticationFactorV2,
@@ -994,6 +1467,43 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
994
1467
  );
995
1468
  }
996
1469
 
1470
+ private toExistingAccountChallengeResult(
1471
+ challengeResult: FlowRequestChallengeResultV2,
1472
+ method: AuthenticationMethodV2,
1473
+ correlationId: string
1474
+ ): FlowExistingAccountChallengeResultV2 {
1475
+ if (
1476
+ challengeResult.type === FLOW_CODE_REQUIRED_V2 &&
1477
+ challengeResult.channel?.toLowerCase() ===
1478
+ AuthenticationMethodTypeV2.EMAIL
1479
+ ) {
1480
+ return createFlowExistingAccountCodeRequiredResultV2({
1481
+ correlationId,
1482
+ continuationState: challengeResult.continuationState,
1483
+ method,
1484
+ channel: challengeResult.channel,
1485
+ sentTo: challengeResult.sentTo,
1486
+ codeLength: challengeResult.codeLength,
1487
+ });
1488
+ }
1489
+
1490
+ if (challengeResult.type === FLOW_PASSWORD_REQUIRED_V2) {
1491
+ return createFlowExistingAccountPasswordRequiredResultV2({
1492
+ correlationId,
1493
+ continuationState: challengeResult.continuationState,
1494
+ });
1495
+ }
1496
+
1497
+ const message =
1498
+ "Existing-account sign-up requires an email code challenge or a password challenge.";
1499
+ this.logger.error(message, correlationId);
1500
+ throw new CustomAuthError(
1501
+ UNSUPPORTED_FLOW_TRANSITION,
1502
+ message,
1503
+ correlationId
1504
+ );
1505
+ }
1506
+
997
1507
  private async verifySignInPassword(
998
1508
  parameters: FlowSubmitSignInPasswordParamsV2
999
1509
  ): Promise<VerifyResultV2> {
@@ -1007,7 +1517,10 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
1007
1517
  correlationId
1008
1518
  );
1009
1519
 
1010
- this.logger.verbose("Submitting V2 sign-in password.", correlationId);
1520
+ this.logger.verbose(
1521
+ "Submitting V2 authentication password.",
1522
+ correlationId
1523
+ );
1011
1524
 
1012
1525
  return this.apiClient.verifyChallenge(
1013
1526
  this.requireLink(correlationId, continuationState.links.verify),
@@ -1027,9 +1540,8 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
1027
1540
  return this.signInWithContinuation({
1028
1541
  correlationId,
1029
1542
  continuationState: {
1543
+ ...continuationState,
1030
1544
  continuationToken,
1031
- scenario: continuationState.scenario,
1032
- scopes: continuationState.scopes,
1033
1545
  links: {},
1034
1546
  },
1035
1547
  });
@@ -1049,7 +1561,8 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
1049
1561
  this.resolveStepApiId(
1050
1562
  continuationState.scenario,
1051
1563
  step,
1052
- correlationId
1564
+ correlationId,
1565
+ parameters.authenticationFactor
1053
1566
  ),
1054
1567
  correlationId
1055
1568
  );
@@ -1068,11 +1581,11 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
1068
1581
  );
1069
1582
  const nextAction: string = challengeResult.nextAction;
1070
1583
 
1071
- if (challengeResult.nextAction === ChallengeNextActionV2.VERIFY) {
1584
+ if (challengeResult.nextAction === VERIFY_RELATION) {
1072
1585
  return challengeResult;
1073
1586
  }
1074
1587
 
1075
- if (challengeResult.nextAction === ChallengeNextActionV2.RISK_VERIFY) {
1588
+ if (challengeResult.nextAction === RISK_VERIFY_RELATION) {
1076
1589
  return this.apiClient.verifyRisk(
1077
1590
  challengeResult.riskVerifyHref,
1078
1591
  { continuationToken: challengeResult.continuationToken },
@@ -1094,9 +1607,8 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
1094
1607
  challengeResult: ChallengeVerificationResultV2
1095
1608
  ): FlowContinuationStateV2 {
1096
1609
  return {
1610
+ ...continuationState,
1097
1611
  continuationToken: challengeResult.continuationToken,
1098
- scenario: continuationState.scenario,
1099
- scopes: continuationState.scopes,
1100
1612
  links: {
1101
1613
  challenge: continuationState.links.challenge,
1102
1614
  verify: challengeResult.verifyHref,
@@ -1104,18 +1616,16 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
1104
1616
  challengeResult.resendHref ??
1105
1617
  continuationState.links.resend,
1106
1618
  },
1107
- ...(continuationState.signUp && {
1108
- signUp: continuationState.signUp,
1109
- }),
1110
1619
  };
1111
1620
  }
1112
1621
 
1113
1622
  private resolveStepApiId(
1114
1623
  scenario: CustomAuthFlowScenarioV2,
1115
1624
  step: FlowStepV2,
1116
- correlationId: string
1625
+ correlationId: string,
1626
+ authenticationFactor?: AuthenticationFactorV2
1117
1627
  ): number {
1118
- const apiId = getPublicApiIdV2(scenario, step);
1628
+ const apiId = getPublicApiIdV2(scenario, step, authenticationFactor);
1119
1629
 
1120
1630
  if (apiId === undefined) {
1121
1631
  const message = `No telemetry API id is registered for step '${step}' of the '${scenario}' flow.`;
@@ -1136,7 +1646,7 @@ export class FlowInteractionClientV2 extends InteractionClientBaseV2 {
1136
1646
  href: string | undefined,
1137
1647
  missingLinkError?: { code: string; message: string }
1138
1648
  ): string {
1139
- if (!href) {
1649
+ if (typeof href !== "string" || !href.trim()) {
1140
1650
  const errorCode =
1141
1651
  missingLinkError?.code ?? CONTINUATION_LINK_MISSING;
1142
1652
  const message =