@azure/msal-browser
Version:
Microsoft Authentication Library for js
50 lines (47 loc) • 2.94 kB
JavaScript
/*! @azure/msal-browser v5.30.0 2026-11-18 */
;
import { CustomAuthAccountData } from '../../../../get_account/auth_flow/CustomAuthAccountData.mjs';
import { CustomAuthError } from '../../../../core/error/CustomAuthError.mjs';
import { UNSUPPORTED_FLOW_TRANSITION } from '../../../../core/network_client/custom_auth_api/v2/ErrorCodesV2.mjs';
import { FLOW_COMPLETED_V2, FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2, FLOW_MFA_REQUIRED_V2 } from '../../../../core/interaction_client/v2/result/FlowActionResultV2.mjs';
import { CustomAuthResultV2 } from '../../../../core/auth_flow/v2/CustomAuthResultV2.mjs';
import { AuthMethodRegistrationRequiredStateV2 } from '../../../../core/auth_flow/v2/state/AuthMethodRegistrationRequiredStateV2.mjs';
import { CompletedStateV2 } from '../../../../core/auth_flow/v2/state/CompletedStateV2.mjs';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
function handleExistingAccountVerificationResultV2(result, stateParameters) {
const commonStateParameters = {
correlationId: result.correlationId,
logger: stateParameters.logger,
config: stateParameters.config,
flowClient: stateParameters.flowClient,
continuationState: "continuationState" in result
? result.continuationState
: stateParameters.continuationState,
cacheClient: stateParameters.cacheClient,
};
if (result.type === FLOW_COMPLETED_V2) {
const account = new CustomAuthAccountData(result.authenticationResult.account, stateParameters.config, stateParameters.cacheClient, stateParameters.logger, result.correlationId);
return new CustomAuthResultV2(new CompletedStateV2(), account, stateParameters.continuationState.scenario);
}
if (result.type === FLOW_AUTH_METHOD_REGISTRATION_REQUIRED_V2) {
return new CustomAuthResultV2(new AuthMethodRegistrationRequiredStateV2({
...commonStateParameters,
continuationState: result.continuationState,
methods: result.methods,
}), undefined, result.continuationState.scenario);
}
if (result.type === FLOW_MFA_REQUIRED_V2) {
const signInStateTransitionHandler = stateParameters.signInStateTransitionHandler;
if (!signInStateTransitionHandler) {
throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, "Sign-in state transition handler is missing.", stateParameters.correlationId);
}
return signInStateTransitionHandler.handleMfaRequired(result, stateParameters);
}
const resultType = result.type;
throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, `Existing-account verification result type '${resultType}' is not supported.`, stateParameters.correlationId);
}
export { handleExistingAccountVerificationResultV2 };
//# sourceMappingURL=ExistingAccountStateTransitionHelperV2.mjs.map