Skip to content

Commit 800c131

Browse files
authored
Merge branch 'dev' into feat/e2e-affected-package-gating
2 parents 668a915 + a800fd2 commit 800c131

5 files changed

Lines changed: 142 additions & 107 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": "Fix unstable sort that can result in returning guest account instead of home account [#8477](https://github.com/AzureAD/microsoft-authentication-library-for-js/pull/8477)",
4+
"packageName": "@azure/msal-common",
5+
"email": "ruijungao@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}

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

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4828,44 +4828,44 @@ const X_MS_LIB_CAPABILITY_VALUE: string;
48284828
// src/authority/Authority.ts:802:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
48294829
// src/authority/Authority.ts:1000:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
48304830
// src/authority/AuthorityOptions.ts:25:5 - (ae-forgotten-export) The symbol "CloudInstanceDiscoveryResponse" needs to be exported by the entry point index.d.ts
4831-
// src/cache/CacheManager.ts:353:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4832-
// src/cache/CacheManager.ts:354:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4833-
// src/cache/CacheManager.ts:669:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4834-
// src/cache/CacheManager.ts:1629:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4835-
// src/cache/CacheManager.ts:1630:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4836-
// src/cache/CacheManager.ts:1644:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4837-
// src/cache/CacheManager.ts:1645:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4838-
// src/cache/CacheManager.ts:1665:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4839-
// src/cache/CacheManager.ts:1666:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4840-
// src/cache/CacheManager.ts:1675:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4841-
// src/cache/CacheManager.ts:1676:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4842-
// src/cache/CacheManager.ts:1692:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4843-
// src/cache/CacheManager.ts:1693:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4844-
// src/cache/CacheManager.ts:1709:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4845-
// src/cache/CacheManager.ts:1710:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4846-
// src/cache/CacheManager.ts:1724:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4847-
// src/cache/CacheManager.ts:1725:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4848-
// src/cache/CacheManager.ts:1763:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4849-
// src/cache/CacheManager.ts:1764:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4850-
// src/cache/CacheManager.ts:1778:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4851-
// src/cache/CacheManager.ts:1779:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4852-
// src/cache/CacheManager.ts:1790:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4853-
// src/cache/CacheManager.ts:1791:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4854-
// src/cache/CacheManager.ts:1802:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4855-
// src/cache/CacheManager.ts:1803:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4856-
// src/cache/CacheManager.ts:1814:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4857-
// src/cache/CacheManager.ts:1815:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4858-
// src/cache/CacheManager.ts:1832:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4859-
// src/cache/CacheManager.ts:1833:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4860-
// src/cache/CacheManager.ts:1862:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4861-
// src/cache/CacheManager.ts:1863:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4862-
// src/cache/CacheManager.ts:1882:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4863-
// src/cache/CacheManager.ts:1883:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4864-
// src/cache/CacheManager.ts:1902:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4865-
// src/cache/CacheManager.ts:1903:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4866-
// src/cache/CacheManager.ts:1914:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4867-
// src/cache/CacheManager.ts:1915:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4868-
// src/cache/CacheManager.ts:1923:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4831+
// src/cache/CacheManager.ts:355:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4832+
// src/cache/CacheManager.ts:356:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4833+
// src/cache/CacheManager.ts:671:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4834+
// src/cache/CacheManager.ts:1631:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4835+
// src/cache/CacheManager.ts:1632:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4836+
// src/cache/CacheManager.ts:1646:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4837+
// src/cache/CacheManager.ts:1647:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4838+
// src/cache/CacheManager.ts:1667:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4839+
// src/cache/CacheManager.ts:1668:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4840+
// src/cache/CacheManager.ts:1677:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4841+
// src/cache/CacheManager.ts:1678:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4842+
// src/cache/CacheManager.ts:1694:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4843+
// src/cache/CacheManager.ts:1695:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4844+
// src/cache/CacheManager.ts:1711:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4845+
// src/cache/CacheManager.ts:1712:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4846+
// src/cache/CacheManager.ts:1726:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4847+
// src/cache/CacheManager.ts:1727:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4848+
// src/cache/CacheManager.ts:1765:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4849+
// src/cache/CacheManager.ts:1766:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4850+
// src/cache/CacheManager.ts:1780:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4851+
// src/cache/CacheManager.ts:1781:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4852+
// src/cache/CacheManager.ts:1792:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4853+
// src/cache/CacheManager.ts:1793:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4854+
// src/cache/CacheManager.ts:1804:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4855+
// src/cache/CacheManager.ts:1805:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4856+
// src/cache/CacheManager.ts:1816:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4857+
// src/cache/CacheManager.ts:1817:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4858+
// src/cache/CacheManager.ts:1834:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4859+
// src/cache/CacheManager.ts:1835:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4860+
// src/cache/CacheManager.ts:1864:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4861+
// src/cache/CacheManager.ts:1865:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4862+
// src/cache/CacheManager.ts:1884:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4863+
// src/cache/CacheManager.ts:1885:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4864+
// src/cache/CacheManager.ts:1904:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4865+
// src/cache/CacheManager.ts:1905:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4866+
// src/cache/CacheManager.ts:1916:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4867+
// src/cache/CacheManager.ts:1917:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
4868+
// src/cache/CacheManager.ts:1925:8 - (tsdoc-param-tag-missing-hyphen) The @param block should be followed by a parameter name and then a hyphen
48694869
// src/cache/entities/AccountEntity.ts:49:5 - (ae-forgotten-export) The symbol "DataBoundary" needs to be exported by the entry point index.d.ts
48704870
// src/cache/utils/CacheTypes.ts:94:53 - (tsdoc-escape-greater-than) The ">" character should be escaped using a backslash to avoid confusion with an HTML tag
48714871
// src/cache/utils/CacheTypes.ts:94:43 - (tsdoc-malformed-html-name) Invalid HTML element: An HTML name must be an ASCII letter followed by zero or more letters, digits, or hyphens

lib/msal-common/src/cache/CacheManager.ts

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,50 @@
33
* Licensed under the MIT License.
44
*/
55

6-
import {
7-
AccountFilter,
8-
CredentialFilter,
9-
ValidCredentialType,
10-
AppMetadataFilter,
11-
AppMetadataCache,
12-
TokenKeys,
13-
TenantProfileFilter,
14-
} from "./utils/CacheTypes.js";
15-
import { CacheRecord } from "./entities/CacheRecord.js";
16-
import * as Constants from "../utils/Constants.js";
17-
import { CredentialEntity } from "./entities/CredentialEntity.js";
18-
import { ScopeSet } from "../request/ScopeSet.js";
19-
import { AccountEntity } from "./entities/AccountEntity.js";
20-
import { AccessTokenEntity } from "./entities/AccessTokenEntity.js";
21-
import { IdTokenEntity } from "./entities/IdTokenEntity.js";
22-
import { RefreshTokenEntity } from "./entities/RefreshTokenEntity.js";
23-
import { ICacheManager } from "./interface/ICacheManager.js";
24-
import {
25-
createClientAuthError,
26-
ClientAuthErrorCodes,
27-
} from "../error/ClientAuthError.js";
286
import {
297
AccountInfo,
308
TenantProfile,
319
updateAccountTenantProfileData,
3210
} from "../account/AccountInfo.js";
33-
import { AppMetadataEntity } from "./entities/AppMetadataEntity.js";
34-
import { ServerTelemetryEntity } from "./entities/ServerTelemetryEntity.js";
35-
import { ThrottlingEntity } from "./entities/ThrottlingEntity.js";
3611
import { extractTokenClaims } from "../account/AuthToken.js";
12+
import { TokenClaims } from "../account/TokenClaims.js";
13+
import { getAliasesFromStaticSources } from "../authority/AuthorityMetadata.js";
14+
import { StaticAuthorityOptions } from "../authority/AuthorityOptions.js";
3715
import { ICrypto } from "../crypto/ICrypto.js";
38-
import { AuthorityMetadataEntity } from "./entities/AuthorityMetadataEntity.js";
39-
import { BaseAuthRequest } from "../request/BaseAuthRequest.js";
16+
import { AuthError } from "../error/AuthError.js";
17+
import { createCacheError } from "../error/CacheError.js";
18+
import {
19+
ClientAuthErrorCodes,
20+
createClientAuthError,
21+
} from "../error/ClientAuthError.js";
4022
import { Logger } from "../logger/Logger.js";
4123
import { name, version } from "../packageMetadata.js";
24+
import { BaseAuthRequest } from "../request/BaseAuthRequest.js";
25+
import { ScopeSet } from "../request/ScopeSet.js";
4226
import { StoreInCache } from "../request/StoreInCache.js";
43-
import { getAliasesFromStaticSources } from "../authority/AuthorityMetadata.js";
44-
import { StaticAuthorityOptions } from "../authority/AuthorityOptions.js";
45-
import { TokenClaims } from "../account/TokenClaims.js";
4627
import { IPerformanceClient } from "../telemetry/performance/IPerformanceClient.js";
47-
import { createCacheError } from "../error/CacheError.js";
28+
import * as Constants from "../utils/Constants.js";
29+
import { AccessTokenEntity } from "./entities/AccessTokenEntity.js";
30+
import { AccountEntity } from "./entities/AccountEntity.js";
31+
import { AppMetadataEntity } from "./entities/AppMetadataEntity.js";
32+
import { AuthorityMetadataEntity } from "./entities/AuthorityMetadataEntity.js";
33+
import { CacheRecord } from "./entities/CacheRecord.js";
34+
import { CredentialEntity } from "./entities/CredentialEntity.js";
35+
import { IdTokenEntity } from "./entities/IdTokenEntity.js";
36+
import { RefreshTokenEntity } from "./entities/RefreshTokenEntity.js";
37+
import { ServerTelemetryEntity } from "./entities/ServerTelemetryEntity.js";
38+
import { ThrottlingEntity } from "./entities/ThrottlingEntity.js";
39+
import { ICacheManager } from "./interface/ICacheManager.js";
4840
import * as AccountEntityUtils from "./utils/AccountEntityUtils.js";
49-
import { AuthError } from "../error/AuthError.js";
41+
import {
42+
AccountFilter,
43+
AppMetadataCache,
44+
AppMetadataFilter,
45+
CredentialFilter,
46+
TenantProfileFilter,
47+
TokenKeys,
48+
ValidCredentialType,
49+
} from "./utils/CacheTypes.js";
5050

5151
/**
5252
* Interface class which implement cache storage functions used by MSAL to perform validity checks, and store tokens.
@@ -315,8 +315,10 @@ export abstract class CacheManager implements ICacheManager {
315315
const allAccounts = this.getAllAccounts(accountFilter, correlationId);
316316
if (allAccounts.length > 1) {
317317
// If one or more accounts are found, prioritize accounts that have an ID token
318-
const sortedAccounts = allAccounts.sort((account) => {
319-
return account.idTokenClaims ? -1 : 1;
318+
const sortedAccounts = allAccounts.sort((a, b) => {
319+
const aHasClaims = a.idTokenClaims ? 1 : 0;
320+
const bHasClaims = b.idTokenClaims ? 1 : 0;
321+
return bHasClaims - aHasClaims;
320322
});
321323
return sortedAccounts[0];
322324
} else if (allAccounts.length === 1) {

0 commit comments

Comments
 (0)