@azure/msal-browser
Version:
Microsoft Authentication Library for js
71 lines (68 loc) • 3.46 kB
JavaScript
/*! @azure/msal-browser v5.25.0 2026-10-06 */
;
import { AuthFlowActionRequiredStateBase } from '../../../../core/auth_flow/AuthFlowState.mjs';
import { CustomAuthResultV2 } from '../../../../core/auth_flow/v2/CustomAuthResultV2.mjs';
import { CompletedStateV2 } from '../../../../core/auth_flow/v2/state/CompletedStateV2.mjs';
import { CustomAuthAccountData } from '../../../../get_account/auth_flow/CustomAuthAccountData.mjs';
import { SubmitPasswordErrorV2 } from '../error_type/SubmitPasswordErrorV2.mjs';
import { MFARequiredStateV2 } from '../../../../core/auth_flow/v2/state/MFARequiredStateV2.mjs';
import { FLOW_COMPLETED_V2, FLOW_MFA_REQUIRED_V2 } from '../../../../core/interaction_client/v2/result/FlowActionResultV2.mjs';
import { CustomAuthError } from '../../../../core/error/CustomAuthError.mjs';
import { UNSUPPORTED_FLOW_TRANSITION } from '../../../../core/network_client/custom_auth_api/v2/ErrorCodesV2.mjs';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
/**
* State returned when the selected sign-in method requires the user's
* password.
*/
class PasswordRequiredStateV2 extends AuthFlowActionRequiredStateBase {
constructor() {
super(...arguments);
this.stateType = "passwordRequired";
}
/**
* Submits the password and advances sign-in.
* @param password - The account password.
* @returns A completed sign-in, MFA selection, or password submission error.
*/
async submitPassword(password) {
const { correlationId, logger, continuationState, flowClient } = this.stateParameters;
try {
this.ensurePasswordIsNotEmpty(password);
const result = await flowClient.submitSignInPassword({
correlationId,
continuationState,
password,
});
const resultType = result.type;
if (result.type === FLOW_COMPLETED_V2) {
const account = new CustomAuthAccountData(result.authenticationResult.account, this.stateParameters.config, this.stateParameters.cacheClient, logger, correlationId);
return new CustomAuthResultV2(new CompletedStateV2(), account, continuationState.scenario);
}
if (result.type === FLOW_MFA_REQUIRED_V2) {
return new CustomAuthResultV2(new MFARequiredStateV2({
correlationId: result.correlationId,
logger,
config: this.stateParameters.config,
flowClient,
continuationState: result.continuationState,
cacheClient: this.stateParameters.cacheClient,
methods: result.methods,
}), undefined, result.continuationState.scenario);
}
throw new CustomAuthError(UNSUPPORTED_FLOW_TRANSITION, `Password verification result type '${resultType}' is not supported.`, correlationId);
}
catch (error) {
logger.errorPii(`0qvjzk ${error}`, correlationId);
return CustomAuthResultV2.createWithError(error, {
errorType: SubmitPasswordErrorV2,
scenario: continuationState.scenario,
correlationId,
});
}
}
}
export { PasswordRequiredStateV2 };
//# sourceMappingURL=PasswordRequiredStateV2.mjs.map