Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Unify Native Auth V2 authentication method selection [#8899](https://github.com/AzureAD/microsoft-authentication-library-for-js/pull/8899)",
"packageName": "@azure/msal-browser",
"email": "yongdiwang@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,31 @@ import { ResetPasswordStartResult } from "../reset_password/auth_flow/result/Res
import { ResetPasswordStartResultV2 } from "../core/auth_flow/v2/result/ResetPasswordStartResultV2.js";
import { CustomAuthApiClientV2 } from "../core/network_client/custom_auth_api/v2/CustomAuthApiClientV2.js";
import { FlowInteractionClientV2 } from "../core/interaction_client/v2/FlowInteractionClientV2.js";
import { AuthMethodSelectionRequiredStateV2 } from "../core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.js";
import { ResetPasswordStartErrorV2 } from "../core/auth_flow/v2/error/ResetPasswordStartErrorV2.js";
import { CustomAuthResultV2 } from "../core/auth_flow/v2/CustomAuthResultV2.js";
import { CustomAuthFlowScenarioV2 } from "../core/auth_flow/v2/CustomAuthFlowScenarioV2.js";
import { SignInStartErrorV2 } from "../sign_in/auth_flow/v2/error_type/SignInStartErrorV2.js";
import { SignInStartResultV2 } from "../sign_in/auth_flow/v2/result/SignInStartResultV2.js";
import { SignUpStartErrorV2 } from "../sign_up/auth_flow/v2/error_type/SignUpStartErrorV2.js";
import { SignUpStartResultV2 } from "../sign_up/auth_flow/v2/result/SignUpStartResultV2.js";
import { CompletedStateV2 } from "../core/auth_flow/v2/state/CompletedStateV2.js";
import {
FLOW_COMPLETED_V2,
FLOW_ATTRIBUTES_REQUIRED_V2,
FLOW_CODE_REQUIRED_V2,
FLOW_METHOD_SELECTION_REQUIRED_V2,
FLOW_MFA_REQUIRED_V2,
FLOW_PASSWORD_REQUIRED_V2,
FLOW_SIGN_UP_PASSWORD_REQUIRED_V2,
} from "../core/interaction_client/v2/result/FlowActionResultV2.js";
import { PasswordRequiredStateV2 } from "../sign_in/auth_flow/v2/state/PasswordRequiredStateV2.js";
import { AuthenticationFactorV2 } from "../core/network_client/custom_auth_api/v2/result/BaseResultsV2.js";
import { CodeRequiredStateV2 } from "../core/auth_flow/v2/state/CodeRequiredStateV2.js";
import { MFARequiredStateV2 } from "../core/auth_flow/v2/state/MFARequiredStateV2.js";
import { AttributesRequiredStateV2 } from "../sign_up/auth_flow/v2/state/AttributesRequiredStateV2.js";
import { SignUpPasswordRequiredStateV2 } from "../sign_up/auth_flow/v2/state/SignUpPasswordRequiredStateV2.js";
import { AuthMethodSelectionRequiredStateV2 } from "../core/auth_flow/v2/state/AuthMethodSelectionRequiredStateV2.js";
import { CompletedStateV2 } from "../core/auth_flow/v2/state/CompletedStateV2.js";
import { SignInStateTransitionHandlerV2 } from "../sign_in/auth_flow/v2/state/SignInStateTransitionHandlerV2.js";
import { PasswordRequiredStateV2 } from "../sign_in/auth_flow/v2/state/PasswordRequiredStateV2.js";
import { SignUpStateTransitionHandlerV2 } from "../sign_up/auth_flow/v2/state/SignUpStateTransitionHandlerV2.js";
import { SignUpPasswordRequiredStateV2 } from "../sign_up/auth_flow/v2/state/SignUpPasswordRequiredStateV2.js";
import { AttributesRequiredStateV2 } from "../sign_up/auth_flow/v2/state/AttributesRequiredStateV2.js";
import { CustomAuthAuthority } from "../core/CustomAuthAuthority.js";
import { DefaultPackageInfo } from "../CustomAuthConstants.js";
import {
Expand Down Expand Up @@ -108,6 +110,8 @@ export class CustomAuthStandardController
private readonly flowClientV2: FlowInteractionClientV2;
private readonly signUpStateTransitionHandlerV2 =
new SignUpStateTransitionHandlerV2();
private readonly signInStateTransitionHandlerV2 =
new SignInStateTransitionHandlerV2();

/*
* Constructor for CustomAuthStandardController.
Expand Down Expand Up @@ -713,6 +717,7 @@ export class CustomAuthStandardController
continuationState: result.continuationState,
cacheClient: this.cacheClient,
methods: result.methods,
authenticationFactor: AuthenticationFactorV2.SINGLE_FACTOR,
}),
undefined,
result.continuationState.scenario
Expand Down Expand Up @@ -788,16 +793,15 @@ export class CustomAuthStandardController
);
}

if (result.type === FLOW_MFA_REQUIRED_V2) {
if (result.type === FLOW_PASSWORD_REQUIRED_V2) {
return new CustomAuthResultV2(
new MFARequiredStateV2({
new PasswordRequiredStateV2({
correlationId: result.correlationId,
logger: this.logger,
config: this.customAuthConfig,
flowClient: this.flowClientV2,
continuationState: result.continuationState,
cacheClient: this.cacheClient,
methods: result.methods,
}),
undefined,
result.continuationState.scenario
Expand All @@ -813,6 +817,8 @@ export class CustomAuthStandardController
flowClient: this.flowClientV2,
continuationState: result.continuationState,
cacheClient: this.cacheClient,
signInStateTransitionHandler:
this.signInStateTransitionHandlerV2,
method: result.method,
sentTo: result.sentTo,
channel: result.channel,
Expand All @@ -823,15 +829,38 @@ export class CustomAuthStandardController
);
}

if (result.type === FLOW_PASSWORD_REQUIRED_V2) {
if (result.type === FLOW_METHOD_SELECTION_REQUIRED_V2) {
return new CustomAuthResultV2(
new PasswordRequiredStateV2({
new AuthMethodSelectionRequiredStateV2({
correlationId: result.correlationId,
logger: this.logger,
config: this.customAuthConfig,
flowClient: this.flowClientV2,
continuationState: result.continuationState,
cacheClient: this.cacheClient,
methods: result.methods,
authenticationFactor:
AuthenticationFactorV2.SINGLE_FACTOR,
signInStateTransitionHandler:
this.signInStateTransitionHandlerV2,
}),
undefined,
result.continuationState.scenario
);
}

if (result.type === FLOW_MFA_REQUIRED_V2) {
return new CustomAuthResultV2(
new AuthMethodSelectionRequiredStateV2({
correlationId: result.correlationId,
logger: this.logger,
config: this.customAuthConfig,
flowClient: this.flowClientV2,
continuationState: result.continuationState,
cacheClient: this.cacheClient,
methods: result.methods,
authenticationFactor:
AuthenticationFactorV2.MULTI_FACTOR,
}),
undefined,
result.continuationState.scenario
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@ import { CustomAuthResultV2 } from "../CustomAuthResultV2.js";
import type { RequestChallengeErrorV2 } from "../error/RequestChallengeErrorV2.js";
import type { CodeRequiredStateV2 } from "../state/CodeRequiredStateV2.js";
import type { FailedStateV2 } from "../state/FailedStateV2.js";
import type { MFAVerificationRequiredStateV2 } from "../state/MFAVerificationRequiredStateV2.js";
import type { PasswordRequiredStateV2 } from "../../../../sign_in/auth_flow/v2/state/PasswordRequiredStateV2.js";

/**
* The states a password-reset request-challenge action can resolve to.
* Password reset supports email one-time-code verification only.
* The states a request-challenge action can resolve to. Trusted server response
* context determines whether primary or MFA verification is required.
*/
export type RequestChallengeResultStateV2 = CodeRequiredStateV2 | FailedStateV2;
export type RequestChallengeResultStateV2 =
| CodeRequiredStateV2
| MFAVerificationRequiredStateV2
| PasswordRequiredStateV2
| FailedStateV2;

/**
* Result of requesting (or resending) a challenge. It wraps one of
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/

import { CustomAuthResultV2 } from "../CustomAuthResultV2.js";
import type { RequestChallengeErrorV2 } from "../error/RequestChallengeErrorV2.js";
import type { CodeRequiredStateV2 } from "../state/CodeRequiredStateV2.js";
import type { FailedStateV2 } from "../state/FailedStateV2.js";

/**
* The states a resend-code action can resolve to.
*/
export type ResendCodeResultStateV2 = CodeRequiredStateV2 | FailedStateV2;

/**
* Result of requesting a replacement first-factor code.
*/
export type ResendCodeResultV2 = CustomAuthResultV2<
ResendCodeResultStateV2,
RequestChallengeErrorV2
>;
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { CustomAuthAccountData } from "../../../../get_account/auth_flow/Cu
import type { AttributesRequiredStateV2 } from "../../../../sign_up/auth_flow/v2/state/AttributesRequiredStateV2.js";
import type { SignInContinuationStateV2 } from "../../../../sign_in/auth_flow/v2/state/SignInContinuationStateV2.js";
import type { SignUpPasswordRequiredStateV2 } from "../../../../sign_up/auth_flow/v2/state/SignUpPasswordRequiredStateV2.js";
import type { MFARequiredStateV2 } from "../state/MFARequiredStateV2.js";
import type { AuthMethodSelectionRequiredStateV2 } from "../state/AuthMethodSelectionRequiredStateV2.js";

/**
* The states a verify-challenge action can resolve to. Verifying the one-time
Expand All @@ -24,7 +24,7 @@ export type VerifyChallengeResultStateV2 =
| SignUpPasswordRequiredStateV2
| AttributesRequiredStateV2
| SignInContinuationStateV2
| MFARequiredStateV2
| AuthMethodSelectionRequiredStateV2
| CompletedStateV2
| FailedStateV2;

Expand Down
Loading