Skip to content

Commit 2b78625

Browse files
authored
[v5] Add interrupted_user to InteractionRequired Error list (#8322)
This pull request enhances the `@azure/msal-common` package by improving the documentation and public exposure of several error codes, and by adding support for a new error code (`interrupted_user`) to the list of interaction required errors. These changes make error handling more robust and transparent for consumers of the library. **Error code improvements and additions:** * Added a new error code, `interrupted_user`, to the `InteractionRequiredAuthErrorCodes` enum and included it in the lists of interaction required errors. This code indicates that the user is in an interrupted state and requires interaction to proceed. [[1]](diffhunk://#diff-7f0fe7571801f31eb8b7836af2cc65e994162a583145a4469ce94d92b1d3ac03R1-R7) [[2]](diffhunk://#diff-09087b913ebbfa828e5f36b7476a400328e0a7131db84f622cc5f6994759a117L2663-R2665) [[3]](diffhunk://#diff-175e2da3fd2f20fd01bf24622c10e9a9a44b468507420611113b1917ea47f00bR19) [[4]](diffhunk://#diff-175e2da3fd2f20fd01bf24622c10e9a9a44b468507420611113b1917ea47f00bR30) [[5]](diffhunk://#diff-9b9e373ecd25242838c370efe898168af89089ced090e293f571d816f02e8cf0L6-R51) * Improved documentation and made the following error codes explicitly public: `badToken`, `consentRequired`, `interactionRequired`, `loginRequired`, `nativeAccountUnavailable`, `noTokensFound`, `refreshTokenExpired`, and `uxNotAllowed`. This clarifies their usage and ensures they are part of the package's public API. [[1]](diffhunk://#diff-09087b913ebbfa828e5f36b7476a400328e0a7131db84f622cc5f6994759a117L944-R944) [[2]](diffhunk://#diff-09087b913ebbfa828e5f36b7476a400328e0a7131db84f622cc5f6994759a117L1701-R1699) [[3]](diffhunk://#diff-09087b913ebbfa828e5f36b7476a400328e0a7131db84f622cc5f6994759a117L2638-R2634) [[4]](diffhunk://#diff-09087b913ebbfa828e5f36b7476a400328e0a7131db84f622cc5f6994759a117L2993-R2991) [[5]](diffhunk://#diff-09087b913ebbfa828e5f36b7476a400328e0a7131db84f622cc5f6994759a117L3069-R3065) [[6]](diffhunk://#diff-09087b913ebbfa828e5f36b7476a400328e0a7131db84f622cc5f6994759a117L3195-R3189) [[7]](diffhunk://#diff-09087b913ebbfa828e5f36b7476a400328e0a7131db84f622cc5f6994759a117L3749-R3741) [[8]](diffhunk://#diff-09087b913ebbfa828e5f36b7476a400328e0a7131db84f622cc5f6994759a117L4638-R4628) [[9]](diffhunk://#diff-9b9e373ecd25242838c370efe898168af89089ced090e293f571d816f02e8cf0L6-R51) **Documentation enhancements:** * Added or improved JSDoc comments for all error code exports in `InteractionRequiredAuthErrorCodes.ts`, providing clear descriptions for each code and marking them as `@public`.
1 parent c008898 commit 2b78625

6 files changed

Lines changed: 87 additions & 27 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Add interrupted_user to InteractionRequired Error list (#8322)",
4+
"packageName": "@azure/msal-common",
5+
"email": "hemoral@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}

docs/errors.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,11 @@ This error occurs when MSAL.js surpasses the allotted storage limit when attempt
302302

303303
- `canShowUI` flag in Edge was set to false. User interaction required on web page. Please invoke an interactive API to resolve.
304304

305+
306+
### `interrupted_user`
307+
308+
- The user could not be authenticated due to an interrupted state. Please invoke an interactive API to resolve.
309+
305310
## JOSE header errors
306311

307312
### `missing_kid_error`

lib/msal-common/apiReview/msal-common.api.md

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -941,9 +941,7 @@ export type AzureRegionConfiguration = {
941941
environmentRegion: string | undefined;
942942
};
943943

944-
// Warning: (ae-missing-release-tag) "badToken" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
945-
//
946-
// @public (undocumented)
944+
// @public
947945
const badToken = "bad_token";
948946

949947
// Warning: (ae-missing-release-tag) "BaseAuthRequest" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
@@ -1698,9 +1696,7 @@ export type CommonSilentFlowRequest = BaseAuthRequest & {
16981696
refreshTokenExpirationOffsetSeconds?: number;
16991697
};
17001698

1701-
// Warning: (ae-missing-release-tag) "consentRequired" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
1702-
//
1703-
// @public (undocumented)
1699+
// @public
17041700
const consentRequired = "consent_required";
17051701

17061702
declare namespace Constants {
@@ -2635,9 +2631,7 @@ const INSTANCE_AWARE = "instance_aware";
26352631
// @public (undocumented)
26362632
function instrumentBrokerParams(parameters: Map<string, string>, correlationId?: string, performanceClient?: IPerformanceClient): void;
26372633

2638-
// Warning: (ae-missing-release-tag) "interactionRequired" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
2639-
//
2640-
// @public (undocumented)
2634+
// @public
26412635
const interactionRequired = "interaction_required";
26422636

26432637
// Warning: (ae-missing-release-tag) "InteractionRequiredAuthError" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
@@ -2660,11 +2654,15 @@ declare namespace InteractionRequiredAuthErrorCodes {
26602654
interactionRequired,
26612655
consentRequired,
26622656
loginRequired,
2663-
badToken
2657+
badToken,
2658+
interruptedUser
26642659
}
26652660
}
26662661
export { InteractionRequiredAuthErrorCodes }
26672662

2663+
// @public
2664+
const interruptedUser = "interrupted_user";
2665+
26682666
// Warning: (ae-missing-release-tag) "IntFields" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
26692667
//
26702668
// @public (undocumented)
@@ -2990,9 +2988,7 @@ export type LoggerOptions = {
29902988
// @public (undocumented)
29912989
const LOGIN_HINT = "login_hint";
29922990

2993-
// Warning: (ae-missing-release-tag) "loginRequired" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
2994-
//
2995-
// @public (undocumented)
2991+
// @public
29962992
const loginRequired = "login_required";
29972993

29982994
// Warning: (ae-missing-release-tag) "LogLevel" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
@@ -3066,9 +3062,7 @@ const multipleMatchingTokens = "multiple_matching_tokens";
30663062
// @public (undocumented)
30673063
const NATIVE_BROKER = "nativebroker";
30683064

3069-
// Warning: (ae-missing-release-tag) "nativeAccountUnavailable" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
3070-
//
3071-
// @public (undocumented)
3065+
// @public
30723066
const nativeAccountUnavailable = "native_account_unavailable";
30733067

30743068
// Warning: (ae-missing-release-tag) "NativeRequest" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
@@ -3192,9 +3186,7 @@ const NOT_APPLICABLE = "N/A";
31923186
// @public (undocumented)
31933187
const NOT_AVAILABLE = "Not Available";
31943188

3195-
// Warning: (ae-missing-release-tag) "noTokensFound" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
3196-
//
3197-
// @public (undocumented)
3189+
// @public
31983190
const noTokensFound = "no_tokens_found";
31993191

32003192
// Warning: (ae-missing-release-tag) "nowSeconds" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
@@ -3746,9 +3738,7 @@ export type RefreshTokenEntity = CredentialEntity & {
37463738
expiresOn?: string;
37473739
};
37483740

3749-
// Warning: (ae-missing-release-tag) "refreshTokenExpired" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
3750-
//
3751-
// @public (undocumented)
3741+
// @public
37523742
const refreshTokenExpired = "refresh_token_expired";
37533743

37543744
// Warning: (ae-missing-release-tag) "REGIONAL_AUTH_PUBLIC_CLOUD_SUFFIX" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
@@ -4635,9 +4625,7 @@ export { UrlUtils }
46354625
// @public (undocumented)
46364626
const userCanceled = "user_canceled";
46374627

4638-
// Warning: (ae-missing-release-tag) "uxNotAllowed" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
4639-
//
4640-
// @public (undocumented)
4628+
// @public
46414629
const uxNotAllowed = "ux_not_allowed";
46424630

46434631
// Warning: (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen

lib/msal-common/src/error/InteractionRequiredAuthError.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const InteractionRequiredServerErrorMessage = [
1616
InteractionRequiredAuthErrorCodes.loginRequired,
1717
InteractionRequiredAuthErrorCodes.badToken,
1818
InteractionRequiredAuthErrorCodes.uxNotAllowed,
19+
InteractionRequiredAuthErrorCodes.interruptedUser,
1920
];
2021

2122
export const InteractionRequiredAuthSubErrorMessage = [
@@ -26,6 +27,7 @@ export const InteractionRequiredAuthSubErrorMessage = [
2627
"consent_required",
2728
"bad_token",
2829
"ux_not_allowed",
30+
"interrupted_user",
2931
];
3032

3133
/**

lib/msal-common/src/error/InteractionRequiredAuthErrorCodes.ts

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,49 @@
33
* Licensed under the MIT License.
44
*/
55

6-
// Codes defined by MSAL
6+
/**
7+
* MSAL-defined interaction required error code indicating no tokens are found in cache.
8+
* @public
9+
*/
710
export const noTokensFound = "no_tokens_found";
11+
/**
12+
* MSAL-defined error code indicating a native account is unavailable on the platform.
13+
* @public
14+
*/
815
export const nativeAccountUnavailable = "native_account_unavailable";
16+
/**
17+
* MSAL-defined error code indicating the refresh token has expired and user interaction is needed.
18+
* @public
19+
*/
920
export const refreshTokenExpired = "refresh_token_expired";
21+
/**
22+
* MSAL-defined error code indicating UI/UX is not allowed (e.g., blocked by policy), requiring alternate interaction.
23+
* @public
24+
*/
1025
export const uxNotAllowed = "ux_not_allowed";
1126

12-
// Codes potentially returned by server
27+
/**
28+
* Server-originated error code indicating interaction is required to complete the request.
29+
* @public
30+
*/
1331
export const interactionRequired = "interaction_required";
32+
/**
33+
* Server-originated error code indicating user consent is required.
34+
* @public
35+
*/
1436
export const consentRequired = "consent_required";
37+
/**
38+
* Server-originated error code indicating user login is required.
39+
* @public
40+
*/
1541
export const loginRequired = "login_required";
42+
/**
43+
* Server-originated error code indicating the token is invalid or corrupted.
44+
* @public
45+
*/
1646
export const badToken = "bad_token";
47+
/**
48+
* Server-originated error code indicating the user is in an interrupted state and interaction is required.
49+
* @public
50+
*/
51+
export const interruptedUser = "interrupted_user";

lib/msal-common/test/error/InteractionRequiredAuthError.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import {
33
InteractionRequiredAuthSubErrorMessage,
44
InteractionRequiredServerErrorMessage,
55
isInteractionRequiredError,
6+
createInteractionRequiredAuthError,
7+
InteractionRequiredAuthErrorCodes,
68
} from "../../src/error/InteractionRequiredAuthError";
79
import { AuthError } from "../../src/error/AuthError";
810

@@ -95,4 +97,25 @@ describe("InteractionRequiredAuthError.ts Class Unit Tests", () => {
9597
).toBe(false);
9698
});
9799
});
100+
101+
describe("createInteractionRequiredAuthError()", () => {
102+
it("produces non-empty messages for all mapped codes", () => {
103+
const codes = [
104+
InteractionRequiredAuthErrorCodes.noTokensFound,
105+
InteractionRequiredAuthErrorCodes.nativeAccountUnavailable,
106+
InteractionRequiredAuthErrorCodes.refreshTokenExpired,
107+
InteractionRequiredAuthErrorCodes.badToken,
108+
InteractionRequiredAuthErrorCodes.uxNotAllowed,
109+
InteractionRequiredAuthErrorCodes.interruptedUser,
110+
];
111+
112+
codes.forEach((code) => {
113+
const err = createInteractionRequiredAuthError(code);
114+
expect(err instanceof InteractionRequiredAuthError).toBe(true);
115+
expect(err.errorCode).toBe(code);
116+
expect(typeof err.errorMessage).toBe("string");
117+
expect(err.errorMessage.length).toBeGreaterThan(0);
118+
});
119+
});
120+
});
98121
});

0 commit comments

Comments
 (0)