Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
2e88a03
Add scopes and claims to V2 authorization entry
yongdiw Oct 8, 2026
915ab7d
Allow email fallback for V2 password input
yongdiw Oct 9, 2026
29c0f2f
Remove V2 code-length validation
yongdiw Oct 9, 2026
a1f023c
Fix Native Auth V2 formatting
yongdiw Oct 12, 2026
7acba6e
Add changefile for Native Auth V2 fixes
yongdiw Oct 12, 2026
d3bafde
update CODEOWNERS
yongdiw Oct 12, 2026
b74b901
Update changefile author email
yongdiw Oct 12, 2026
dc41a62
Merge branch 'dev' into yongdi/native-auth-v2-fixes
yongdiw Oct 12, 2026
236ed56
Remove inputs from V2 continuation sign-in
yongdiw Oct 12, 2026
29af15d
Update V2 MFA continuation fixtures
yongdiw Oct 12, 2026
d101e31
Merge branch 'dev' into yongdi/native-auth-v2-fixes
yongdiw Oct 13, 2026
b90f6fd
Fix native auth V2 token response scope fallback
yongdiw Oct 14, 2026
cf87471
Merge branch 'dev' into yongdi/native-auth-v2-fixes
yongdiw Oct 14, 2026
1a4e3cb
Merge branch 'dev' into yongdi/native-auth-v2-fixes
yongdiw Oct 14, 2026
d1812dd
Merge branch 'dev' into yongdi/native-auth-v2-fixes
yongdiw Oct 14, 2026
8a30db9
Merge branch 'dev' into yongdi/native-auth-v2-fixes
yongdiw Oct 15, 2026
47fdcbc
Define Native Auth V2 entry inputs explicitly
yongdiw Oct 15, 2026
0f2dffb
Merge branch 'dev' into yongdi/native-auth-v2-fixes
yongdiw Oct 15, 2026
074bb69
Merge branch 'dev' into yongdi/native-auth-v2-fixes
yongdiw Oct 19, 2026
c8b7661
Unify Native Auth V2 authentication method selection (#8899)
yongdiw Oct 19, 2026
c6d8235
Fix Native Auth V2 error mocks in state tests
yongdiw Oct 19, 2026
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
6 changes: 3 additions & 3 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
* @AzureAD/msal-js-public-client

# MSAL Browser
/lib/msal-browser/src/custom_auth/ @shenj @yongdiw @nilo-ms @spetrescu84 @mustafamizrak
/lib/msal-browser/test/custom_auth/ @shenj @yongdiw @nilo-ms @spetrescu84 @mustafamizrak
/samples/msal-browser-samples/NativeAuthSample @shenj @yongdiw @spetrescu84 @mustafamizrak
/lib/msal-browser/src/custom_auth/ @shenj @yongdiw @spetrescu84 @antrix1989
/lib/msal-browser/test/custom_auth/ @shenj @yongdiw @spetrescu84 @antrix1989
/samples/msal-browser-samples/NativeAuthSample @shenj @yongdiw @spetrescu84 @antrix1989

# MSAL Node
/lib/msal-node/ @AzureAD/msal-js-public-client @AzureAD/id4s-msal-team
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Add Native Auth V2 authorization inputs and challenge validation fixes [#8898](https://github.com/AzureAD/microsoft-authentication-library-for-js/pull/8898)",
"packageName": "@azure/msal-browser",
"email": "yongdiwang@microsoft.com",
"dependentChangeType": "patch"
}
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
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Expose required and invalid Native Auth V2 attribute IDs [#8900](https://github.com/AzureAD/microsoft-authentication-library-for-js/pull/8900)",
"packageName": "@azure/msal-browser",
"email": "yongdiwang@microsoft.com",
"dependentChangeType": "patch"
}
2 changes: 1 addition & 1 deletion docs/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -1165,7 +1165,7 @@ const msalConfig = {

- The HTTP request to the authentication server failed.

#### `redirect_to_web`
#### `web_redirect_required`

- The native authentication flow must continue in a web browser.

Expand Down
22 changes: 16 additions & 6 deletions lib/msal-browser/src/custom_auth/CustomAuthActionInputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,23 @@ export type SignInWithContinuationTokenInputs = {
claims?: string;
};

export type SignInInputsV2 = SignInInputs;

export type ResetPasswordInputsV2 = ResetPasswordInputs;
export type SignInInputsV2 = CustomAuthActionInputs & {
username: string;
password?: string;
scopes?: Array<string> | null;
Comment thread
spetrescu84 marked this conversation as resolved.
Resolved
claims?: string;
};

export type SignUpInputsV2 = SignUpInputs & {
scopes?: Array<string>;
export type ResetPasswordInputsV2 = CustomAuthActionInputs & {
username: string;
scopes?: Array<string> | null;
claims?: string;
};

export type SignInContinuationInputsV2 = SignInWithContinuationTokenInputs;
export type SignUpInputsV2 = CustomAuthActionInputs & {
username: string;
password?: string;
attributes?: UserAccountAttributes;
scopes?: Array<string> | null;
claims?: string;
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,29 +30,28 @@ 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 +107,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 @@ -652,6 +653,20 @@ export class CustomAuthStandardController
inputs.username,
correlationId
);
if (inputs.scopes !== undefined && inputs.scopes !== null) {
ArgumentValidator.ensureArgumentIsStringArray(
"inputs.scopes",
inputs.scopes,
correlationId
);
}
if (inputs.claims) {
ArgumentValidator.ensureArgumentIsJSONString(
"inputs.claims",
inputs.claims,
correlationId
);
}
this.ensureUserNotSignedIn(correlationId);

this.logger.verbose(
Expand All @@ -662,6 +677,8 @@ export class CustomAuthStandardController
const result = await this.flowClientV2.resetPassword({
correlationId,
username: inputs.username,
scopes: inputs.scopes,
claims: inputs.claims,
});

this.logger.verbose(
Expand Down Expand Up @@ -697,6 +714,7 @@ export class CustomAuthStandardController
continuationState: result.continuationState,
cacheClient: this.cacheClient,
methods: result.methods,
authenticationFactor: AuthenticationFactorV2.SINGLE_FACTOR,
}),
undefined,
result.continuationState.scenario
Expand All @@ -708,7 +726,6 @@ export class CustomAuthStandardController
);

return CustomAuthResultV2.createWithError(error, {
errorType: ResetPasswordStartErrorV2,
scenario: CustomAuthFlowScenarioV2.PasswordReset,
correlationId,
});
Expand All @@ -729,6 +746,13 @@ export class CustomAuthStandardController
inputs.username,
correlationId
);
if (inputs.scopes !== undefined && inputs.scopes !== null) {
ArgumentValidator.ensureArgumentIsStringArray(
"inputs.scopes",
inputs.scopes,
correlationId
);
}
if (inputs.claims) {
ArgumentValidator.ensureArgumentIsJSONString(
"inputs.claims",
Expand All @@ -748,6 +772,7 @@ export class CustomAuthStandardController
username: inputs.username,
password: inputs.password,
scopes: inputs.scopes,
claims: inputs.claims,
});

if (result.type === FLOW_COMPLETED_V2) {
Expand All @@ -764,16 +789,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 @@ -789,6 +813,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 @@ -799,15 +825,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 All @@ -825,7 +874,6 @@ export class CustomAuthStandardController
);

return CustomAuthResultV2.createWithError(error, {
errorType: SignInStartErrorV2,
scenario: CustomAuthFlowScenarioV2.SignIn,
correlationId,
});
Expand Down Expand Up @@ -858,6 +906,20 @@ export class CustomAuthStandardController
correlationId
);
}
if (inputs.scopes !== undefined && inputs.scopes !== null) {
ArgumentValidator.ensureArgumentIsStringArray(
"inputs.scopes",
inputs.scopes,
correlationId
);
}
if (inputs.claims) {
ArgumentValidator.ensureArgumentIsJSONString(
"inputs.claims",
inputs.claims,
correlationId
);
}
this.ensureUserNotSignedIn(correlationId);

this.logger.verbose(
Expand Down Expand Up @@ -933,7 +995,6 @@ export class CustomAuthStandardController
);

return CustomAuthResultV2.createWithError(error, {
errorType: SignUpStartErrorV2,
scenario: CustomAuthFlowScenarioV2.SignUp,
correlationId,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ import { CustomAuthError } from "../../error/CustomAuthError.js";
import { MsalCustomAuthError } from "../../error/MsalCustomAuthError.js";
import { UnexpectedError } from "../../error/UnexpectedError.js";
import { FailedStateV2 } from "./state/FailedStateV2.js";
import { AuthFlowErrorBaseV2 } from "./error/AuthFlowErrorBaseV2.js";
import { AuthFlowErrorV2 } from "./error/AuthFlowErrorV2.js";
import { CustomAuthFlowScenarioV2 } from "./CustomAuthFlowScenarioV2.js";

type CreateWithErrorOptions<TError extends AuthFlowErrorBaseV2> = {
errorType: new (
errorData: CustomAuthError,
scenario?: CustomAuthFlowScenarioV2
) => TError;
type CreateWithErrorOptions = {
scenario?: CustomAuthFlowScenarioV2;
correlationId?: string;
};
Expand All @@ -27,7 +23,6 @@ type CreateWithErrorOptions<TError extends AuthFlowErrorBaseV2> = {
*/
export class CustomAuthResultV2<
TState extends AuthFlowStateBase,
TError extends AuthFlowErrorBaseV2,
TData = void
> {
constructor(
Expand All @@ -36,7 +31,7 @@ export class CustomAuthResultV2<
public readonly scenario: CustomAuthFlowScenarioV2 = CustomAuthFlowScenarioV2.Unknown
) {}

error?: TError;
error?: AuthFlowErrorV2;

/**
* Narrows the result to a specific state by its `stateType` discriminator.
Expand All @@ -52,7 +47,7 @@ export class CustomAuthResultV2<

/**
* Checks whether the result is in the terminal failed state. A failed result
* contains the flow-specific error.
* contains the unified V2 flow error.
* @returns True (and narrows `state`) when the operation failed.
*/
isFailed(): this is this & {
Expand All @@ -63,35 +58,28 @@ export class CustomAuthResultV2<

/**
* Creates a failed result from the supplied error. The result uses the
* shared {@link FailedStateV2} terminal state.
* shared {@link FailedStateV2} terminal state and unified V2 flow error.
* @param error - The error that occurred.
* @param options - The flow-error type and error context.
* @returns A failed result carrying the flow-specific error.
* @param options - The flow-error context.
* @returns A failed result carrying the unified V2 flow error.
*/
static createWithError<
TState extends AuthFlowStateBase,
TError extends AuthFlowErrorBaseV2,
TData = void
>(
static createWithError<TState extends AuthFlowStateBase, TData = void>(
error: unknown,
options: CreateWithErrorOptions<TError>
): CustomAuthResultV2<TState | FailedStateV2, TError, TData> {
const {
errorType: ErrorType,
scenario = CustomAuthFlowScenarioV2.Unknown,
correlationId,
} = options;
options: CreateWithErrorOptions
): CustomAuthResultV2<TState | FailedStateV2, TData> {
const { scenario = CustomAuthFlowScenarioV2.Unknown, correlationId } =
options;
const errorData = CustomAuthResultV2.createErrorData(
error,
correlationId
);
const flowError = new ErrorType(errorData, scenario);
const flowError = new AuthFlowErrorV2(errorData, scenario);

const result = new CustomAuthResultV2<
TState | FailedStateV2,
TError,
TData
>(new FailedStateV2(), undefined, scenario);
const result = new CustomAuthResultV2<TState | FailedStateV2, TData>(
new FailedStateV2(),
undefined,
scenario
);
result.error = flowError;

return result;
Expand Down
Loading