@azure/msal-node 3.8.0 → 3.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cache/CacheHelpers.mjs +1 -1
- package/dist/cache/NodeStorage.d.ts.map +1 -1
- package/dist/cache/NodeStorage.mjs +2 -2
- package/dist/cache/NodeStorage.mjs.map +1 -1
- package/dist/cache/TokenCache.mjs +1 -1
- package/dist/cache/distributed/DistributedCachePlugin.mjs +1 -1
- package/dist/cache/serializer/Deserializer.mjs +1 -1
- package/dist/cache/serializer/Serializer.mjs +1 -1
- package/dist/client/ClientApplication.mjs +1 -1
- package/dist/client/ClientAssertion.mjs +1 -1
- package/dist/client/ClientCredentialClient.mjs +1 -1
- package/dist/client/ConfidentialClientApplication.mjs +1 -1
- package/dist/client/DeviceCodeClient.mjs +1 -1
- package/dist/client/ManagedIdentityApplication.mjs +1 -1
- package/dist/client/ManagedIdentityClient.mjs +1 -1
- package/dist/client/ManagedIdentitySources/AppService.d.ts +54 -0
- package/dist/client/ManagedIdentitySources/AppService.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/AppService.mjs +55 -1
- package/dist/client/ManagedIdentitySources/AppService.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/AzureArc.d.ts +81 -0
- package/dist/client/ManagedIdentitySources/AzureArc.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/AzureArc.mjs +82 -1
- package/dist/client/ManagedIdentitySources/AzureArc.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +93 -2
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +81 -1
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/CloudShell.d.ts +54 -0
- package/dist/client/ManagedIdentitySources/CloudShell.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/CloudShell.mjs +55 -1
- package/dist/client/ManagedIdentitySources/CloudShell.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/Imds.d.ts +44 -22
- package/dist/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/Imds.mjs +44 -22
- package/dist/client/ManagedIdentitySources/Imds.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/MachineLearning.d.ts +65 -0
- package/dist/client/ManagedIdentitySources/MachineLearning.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/MachineLearning.mjs +66 -1
- package/dist/client/ManagedIdentitySources/MachineLearning.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts +56 -22
- package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/ServiceFabric.mjs +57 -23
- package/dist/client/ManagedIdentitySources/ServiceFabric.mjs.map +1 -1
- package/dist/client/OnBehalfOfClient.mjs +1 -1
- package/dist/client/PublicClientApplication.mjs +1 -1
- package/dist/client/UsernamePasswordClient.mjs +1 -1
- package/dist/config/Configuration.mjs +1 -1
- package/dist/config/ManagedIdentityId.mjs +1 -1
- package/dist/config/ManagedIdentityRequestParameters.mjs +1 -1
- package/dist/crypto/CryptoProvider.mjs +1 -1
- package/dist/crypto/GuidGenerator.mjs +1 -1
- package/dist/crypto/HashUtils.mjs +1 -1
- package/dist/crypto/PkceGenerator.mjs +1 -1
- package/dist/error/ManagedIdentityError.mjs +1 -1
- package/dist/error/ManagedIdentityErrorCodes.mjs +1 -1
- package/dist/error/NodeAuthError.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/internals.mjs +1 -1
- package/dist/network/HttpClient.mjs +1 -1
- package/dist/network/HttpClientWithRetries.mjs +1 -1
- package/dist/network/LoopbackClient.mjs +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/protocol/Authorize.mjs +1 -1
- package/dist/retry/DefaultManagedIdentityRetryPolicy.mjs +1 -1
- package/dist/retry/ExponentialRetryStrategy.mjs +1 -1
- package/dist/retry/ImdsRetryPolicy.mjs +1 -1
- package/dist/retry/LinearRetryStrategy.mjs +1 -1
- package/dist/utils/Constants.mjs +1 -1
- package/dist/utils/EncodingUtils.mjs +1 -1
- package/dist/utils/NetworkUtils.mjs +1 -1
- package/dist/utils/TimeUtils.mjs +1 -1
- package/lib/msal-node.cjs +914 -503
- package/lib/msal-node.cjs.map +1 -1
- package/lib/types/cache/NodeStorage.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/AppService.d.ts +54 -0
- package/lib/types/client/ManagedIdentitySources/AppService.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/AzureArc.d.ts +81 -0
- package/lib/types/client/ManagedIdentitySources/AzureArc.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +93 -2
- package/lib/types/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/CloudShell.d.ts +54 -0
- package/lib/types/client/ManagedIdentitySources/CloudShell.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/Imds.d.ts +44 -22
- package/lib/types/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/MachineLearning.d.ts +65 -0
- package/lib/types/client/ManagedIdentitySources/MachineLearning.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/ServiceFabric.d.ts +56 -22
- package/lib/types/client/ManagedIdentitySources/ServiceFabric.d.ts.map +1 -1
- package/lib/types/packageMetadata.d.ts +1 -1
- package/package.json +2 -2
- package/src/cache/NodeStorage.ts +3 -1
- package/src/client/ManagedIdentitySources/AppService.ts +54 -0
- package/src/client/ManagedIdentitySources/AzureArc.ts +81 -0
- package/src/client/ManagedIdentitySources/BaseManagedIdentitySource.ts +92 -2
- package/src/client/ManagedIdentitySources/CloudShell.ts +54 -0
- package/src/client/ManagedIdentitySources/Imds.ts +43 -21
- package/src/client/ManagedIdentitySources/MachineLearning.ts +65 -0
- package/src/client/ManagedIdentitySources/ServiceFabric.ts +56 -22
- package/src/packageMetadata.ts +1 -1
package/lib/msal-node.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-node v3.8.
|
|
1
|
+
/*! @azure/msal-node v3.8.1 2025-10-29 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -153,7 +153,7 @@ class Serializer {
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
/*! @azure/msal-common v15.13.
|
|
156
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
157
157
|
/*
|
|
158
158
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
159
159
|
* Licensed under the MIT License.
|
|
@@ -433,7 +433,7 @@ const EncodingTypes = {
|
|
|
433
433
|
UTF8: "utf-8",
|
|
434
434
|
};
|
|
435
435
|
|
|
436
|
-
/*! @azure/msal-common v15.13.
|
|
436
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
437
437
|
/*
|
|
438
438
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
439
439
|
* Licensed under the MIT License.
|
|
@@ -450,7 +450,7 @@ var AuthErrorCodes = /*#__PURE__*/Object.freeze({
|
|
|
450
450
|
unexpectedError: unexpectedError
|
|
451
451
|
});
|
|
452
452
|
|
|
453
|
-
/*! @azure/msal-common v15.13.
|
|
453
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
454
454
|
|
|
455
455
|
/*
|
|
456
456
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -499,7 +499,7 @@ function createAuthError(code, additionalMessage) {
|
|
|
499
499
|
: AuthErrorMessages[code]);
|
|
500
500
|
}
|
|
501
501
|
|
|
502
|
-
/*! @azure/msal-common v15.13.
|
|
502
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
503
503
|
/*
|
|
504
504
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
505
505
|
* Licensed under the MIT License.
|
|
@@ -597,7 +597,7 @@ var ClientAuthErrorCodes = /*#__PURE__*/Object.freeze({
|
|
|
597
597
|
userTimeoutReached: userTimeoutReached
|
|
598
598
|
});
|
|
599
599
|
|
|
600
|
-
/*! @azure/msal-common v15.13.
|
|
600
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
601
601
|
|
|
602
602
|
/*
|
|
603
603
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -849,7 +849,7 @@ function createClientAuthError(errorCode, additionalMessage) {
|
|
|
849
849
|
return new ClientAuthError(errorCode, additionalMessage);
|
|
850
850
|
}
|
|
851
851
|
|
|
852
|
-
/*! @azure/msal-common v15.13.
|
|
852
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
853
853
|
|
|
854
854
|
/*
|
|
855
855
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -888,7 +888,7 @@ const DEFAULT_CRYPTO_IMPLEMENTATION = {
|
|
|
888
888
|
},
|
|
889
889
|
};
|
|
890
890
|
|
|
891
|
-
/*! @azure/msal-common v15.13.
|
|
891
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
892
892
|
|
|
893
893
|
/*
|
|
894
894
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1079,12 +1079,12 @@ class Logger {
|
|
|
1079
1079
|
}
|
|
1080
1080
|
}
|
|
1081
1081
|
|
|
1082
|
-
/*! @azure/msal-common v15.13.
|
|
1082
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
1083
1083
|
/* eslint-disable header/header */
|
|
1084
1084
|
const name$1 = "@azure/msal-common";
|
|
1085
|
-
const version$1 = "15.13.
|
|
1085
|
+
const version$1 = "15.13.1";
|
|
1086
1086
|
|
|
1087
|
-
/*! @azure/msal-common v15.13.
|
|
1087
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
1088
1088
|
/*
|
|
1089
1089
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1090
1090
|
* Licensed under the MIT License.
|
|
@@ -1104,7 +1104,7 @@ const AzureCloudInstance = {
|
|
|
1104
1104
|
AzureUsGovernment: "https://login.microsoftonline.us",
|
|
1105
1105
|
};
|
|
1106
1106
|
|
|
1107
|
-
/*! @azure/msal-common v15.13.
|
|
1107
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
1108
1108
|
/*
|
|
1109
1109
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1110
1110
|
* Licensed under the MIT License.
|
|
@@ -1160,7 +1160,7 @@ var ClientConfigurationErrorCodes = /*#__PURE__*/Object.freeze({
|
|
|
1160
1160
|
urlParseError: urlParseError
|
|
1161
1161
|
});
|
|
1162
1162
|
|
|
1163
|
-
/*! @azure/msal-common v15.13.
|
|
1163
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
1164
1164
|
|
|
1165
1165
|
/*
|
|
1166
1166
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1303,7 +1303,7 @@ function createClientConfigurationError(errorCode) {
|
|
|
1303
1303
|
return new ClientConfigurationError(errorCode);
|
|
1304
1304
|
}
|
|
1305
1305
|
|
|
1306
|
-
/*! @azure/msal-common v15.13.
|
|
1306
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
1307
1307
|
/*
|
|
1308
1308
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1309
1309
|
* Licensed under the MIT License.
|
|
@@ -1400,7 +1400,7 @@ class StringUtils {
|
|
|
1400
1400
|
}
|
|
1401
1401
|
}
|
|
1402
1402
|
|
|
1403
|
-
/*! @azure/msal-common v15.13.
|
|
1403
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
1404
1404
|
|
|
1405
1405
|
/*
|
|
1406
1406
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1595,7 +1595,47 @@ class ScopeSet {
|
|
|
1595
1595
|
}
|
|
1596
1596
|
}
|
|
1597
1597
|
|
|
1598
|
-
/*! @azure/msal-common v15.13.
|
|
1598
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
1599
|
+
|
|
1600
|
+
/*
|
|
1601
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1602
|
+
* Licensed under the MIT License.
|
|
1603
|
+
*/
|
|
1604
|
+
/**
|
|
1605
|
+
* Function to build a client info object from server clientInfo string
|
|
1606
|
+
* @param rawClientInfo
|
|
1607
|
+
* @param crypto
|
|
1608
|
+
*/
|
|
1609
|
+
function buildClientInfo(rawClientInfo, base64Decode) {
|
|
1610
|
+
if (!rawClientInfo) {
|
|
1611
|
+
throw createClientAuthError(clientInfoEmptyError);
|
|
1612
|
+
}
|
|
1613
|
+
try {
|
|
1614
|
+
const decodedClientInfo = base64Decode(rawClientInfo);
|
|
1615
|
+
return JSON.parse(decodedClientInfo);
|
|
1616
|
+
}
|
|
1617
|
+
catch (e) {
|
|
1618
|
+
throw createClientAuthError(clientInfoDecodingError);
|
|
1619
|
+
}
|
|
1620
|
+
}
|
|
1621
|
+
/**
|
|
1622
|
+
* Function to build a client info object from cached homeAccountId string
|
|
1623
|
+
* @param homeAccountId
|
|
1624
|
+
*/
|
|
1625
|
+
function buildClientInfoFromHomeAccountId(homeAccountId) {
|
|
1626
|
+
if (!homeAccountId) {
|
|
1627
|
+
throw createClientAuthError(clientInfoDecodingError);
|
|
1628
|
+
}
|
|
1629
|
+
const clientInfoParts = homeAccountId.split(Separators.CLIENT_INFO_SEPARATOR, 2);
|
|
1630
|
+
return {
|
|
1631
|
+
uid: clientInfoParts[0],
|
|
1632
|
+
utid: clientInfoParts.length < 2
|
|
1633
|
+
? Constants$1.EMPTY_STRING
|
|
1634
|
+
: clientInfoParts[1],
|
|
1635
|
+
};
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
1599
1639
|
/*
|
|
1600
1640
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1601
1641
|
* Licensed under the MIT License.
|
|
@@ -1677,7 +1717,289 @@ function updateAccountTenantProfileData(baseAccountInfo, tenantProfile, idTokenC
|
|
|
1677
1717
|
return updatedAccountInfo;
|
|
1678
1718
|
}
|
|
1679
1719
|
|
|
1680
|
-
/*! @azure/msal-common v15.13.
|
|
1720
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
1721
|
+
/*
|
|
1722
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1723
|
+
* Licensed under the MIT License.
|
|
1724
|
+
*/
|
|
1725
|
+
/**
|
|
1726
|
+
* Authority types supported by MSAL.
|
|
1727
|
+
*/
|
|
1728
|
+
const AuthorityType = {
|
|
1729
|
+
Default: 0,
|
|
1730
|
+
Adfs: 1,
|
|
1731
|
+
Dsts: 2,
|
|
1732
|
+
Ciam: 3,
|
|
1733
|
+
};
|
|
1734
|
+
|
|
1735
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
1736
|
+
/*
|
|
1737
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1738
|
+
* Licensed under the MIT License.
|
|
1739
|
+
*/
|
|
1740
|
+
/**
|
|
1741
|
+
* Gets tenantId from available ID token claims to set as credential realm with the following precedence:
|
|
1742
|
+
* 1. tid - if the token is acquired from an Azure AD tenant tid will be present
|
|
1743
|
+
* 2. tfp - if the token is acquired from a modern B2C tenant tfp should be present
|
|
1744
|
+
* 3. acr - if the token is acquired from a legacy B2C tenant acr should be present
|
|
1745
|
+
* Downcased to match the realm case-insensitive comparison requirements
|
|
1746
|
+
* @param idTokenClaims
|
|
1747
|
+
* @returns
|
|
1748
|
+
*/
|
|
1749
|
+
function getTenantIdFromIdTokenClaims(idTokenClaims) {
|
|
1750
|
+
if (idTokenClaims) {
|
|
1751
|
+
const tenantId = idTokenClaims.tid || idTokenClaims.tfp || idTokenClaims.acr;
|
|
1752
|
+
return tenantId || null;
|
|
1753
|
+
}
|
|
1754
|
+
return null;
|
|
1755
|
+
}
|
|
1756
|
+
|
|
1757
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
1758
|
+
/*
|
|
1759
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1760
|
+
* Licensed under the MIT License.
|
|
1761
|
+
*/
|
|
1762
|
+
/**
|
|
1763
|
+
* Protocol modes supported by MSAL.
|
|
1764
|
+
*/
|
|
1765
|
+
const ProtocolMode = {
|
|
1766
|
+
/**
|
|
1767
|
+
* Auth Code + PKCE with Entra ID (formerly AAD) specific optimizations and features
|
|
1768
|
+
*/
|
|
1769
|
+
AAD: "AAD",
|
|
1770
|
+
/**
|
|
1771
|
+
* Auth Code + PKCE without Entra ID specific optimizations and features. For use only with non-Microsoft owned authorities.
|
|
1772
|
+
* Support is limited for this mode.
|
|
1773
|
+
*/
|
|
1774
|
+
OIDC: "OIDC",
|
|
1775
|
+
/**
|
|
1776
|
+
* Encrypted Authorize Response (EAR) with Entra ID specific optimizations and features
|
|
1777
|
+
*/
|
|
1778
|
+
EAR: "EAR",
|
|
1779
|
+
};
|
|
1780
|
+
|
|
1781
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
1782
|
+
|
|
1783
|
+
/*
|
|
1784
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1785
|
+
* Licensed under the MIT License.
|
|
1786
|
+
*/
|
|
1787
|
+
/**
|
|
1788
|
+
* Type that defines required and optional parameters for an Account field (based on universal cache schema implemented by all MSALs).
|
|
1789
|
+
*
|
|
1790
|
+
* Key : Value Schema
|
|
1791
|
+
*
|
|
1792
|
+
* Key: <home_account_id>-<environment>-<realm*>
|
|
1793
|
+
*
|
|
1794
|
+
* Value Schema:
|
|
1795
|
+
* {
|
|
1796
|
+
* homeAccountId: home account identifier for the auth scheme,
|
|
1797
|
+
* environment: entity that issued the token, represented as a full host
|
|
1798
|
+
* realm: Full tenant or organizational identifier that the account belongs to
|
|
1799
|
+
* localAccountId: Original tenant-specific accountID, usually used for legacy cases
|
|
1800
|
+
* username: primary username that represents the user, usually corresponds to preferred_username in the v2 endpt
|
|
1801
|
+
* authorityType: Accounts authority type as a string
|
|
1802
|
+
* name: Full name for the account, including given name and family name,
|
|
1803
|
+
* lastModificationTime: last time this entity was modified in the cache
|
|
1804
|
+
* lastModificationApp:
|
|
1805
|
+
* nativeAccountId: Account identifier on the native device
|
|
1806
|
+
* tenantProfiles: Array of tenant profile objects for each tenant that the account has authenticated with in the browser
|
|
1807
|
+
* }
|
|
1808
|
+
* @internal
|
|
1809
|
+
*/
|
|
1810
|
+
class AccountEntity {
|
|
1811
|
+
/**
|
|
1812
|
+
* Returns the AccountInfo interface for this account.
|
|
1813
|
+
*/
|
|
1814
|
+
static getAccountInfo(accountEntity) {
|
|
1815
|
+
return {
|
|
1816
|
+
homeAccountId: accountEntity.homeAccountId,
|
|
1817
|
+
environment: accountEntity.environment,
|
|
1818
|
+
tenantId: accountEntity.realm,
|
|
1819
|
+
username: accountEntity.username,
|
|
1820
|
+
localAccountId: accountEntity.localAccountId,
|
|
1821
|
+
loginHint: accountEntity.loginHint,
|
|
1822
|
+
name: accountEntity.name,
|
|
1823
|
+
nativeAccountId: accountEntity.nativeAccountId,
|
|
1824
|
+
authorityType: accountEntity.authorityType,
|
|
1825
|
+
// Deserialize tenant profiles array into a Map
|
|
1826
|
+
tenantProfiles: new Map((accountEntity.tenantProfiles || []).map((tenantProfile) => {
|
|
1827
|
+
return [tenantProfile.tenantId, tenantProfile];
|
|
1828
|
+
})),
|
|
1829
|
+
dataBoundary: accountEntity.dataBoundary,
|
|
1830
|
+
};
|
|
1831
|
+
}
|
|
1832
|
+
/**
|
|
1833
|
+
* Returns true if the account entity is in single tenant format (outdated), false otherwise
|
|
1834
|
+
*/
|
|
1835
|
+
isSingleTenant() {
|
|
1836
|
+
return !this.tenantProfiles;
|
|
1837
|
+
}
|
|
1838
|
+
/**
|
|
1839
|
+
* Build Account cache from IdToken, clientInfo and authority/policy. Associated with AAD.
|
|
1840
|
+
* @param accountDetails
|
|
1841
|
+
*/
|
|
1842
|
+
static createAccount(accountDetails, authority, base64Decode) {
|
|
1843
|
+
const account = new AccountEntity();
|
|
1844
|
+
if (authority.authorityType === AuthorityType.Adfs) {
|
|
1845
|
+
account.authorityType = CacheAccountType.ADFS_ACCOUNT_TYPE;
|
|
1846
|
+
}
|
|
1847
|
+
else if (authority.protocolMode === ProtocolMode.OIDC) {
|
|
1848
|
+
account.authorityType = CacheAccountType.GENERIC_ACCOUNT_TYPE;
|
|
1849
|
+
}
|
|
1850
|
+
else {
|
|
1851
|
+
account.authorityType = CacheAccountType.MSSTS_ACCOUNT_TYPE;
|
|
1852
|
+
}
|
|
1853
|
+
let clientInfo;
|
|
1854
|
+
if (accountDetails.clientInfo && base64Decode) {
|
|
1855
|
+
clientInfo = buildClientInfo(accountDetails.clientInfo, base64Decode);
|
|
1856
|
+
if (clientInfo.xms_tdbr) {
|
|
1857
|
+
account.dataBoundary =
|
|
1858
|
+
clientInfo.xms_tdbr === "EU" ? "EU" : "None";
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
account.clientInfo = accountDetails.clientInfo;
|
|
1862
|
+
account.homeAccountId = accountDetails.homeAccountId;
|
|
1863
|
+
account.nativeAccountId = accountDetails.nativeAccountId;
|
|
1864
|
+
const env = accountDetails.environment ||
|
|
1865
|
+
(authority && authority.getPreferredCache());
|
|
1866
|
+
if (!env) {
|
|
1867
|
+
throw createClientAuthError(invalidCacheEnvironment);
|
|
1868
|
+
}
|
|
1869
|
+
account.environment = env;
|
|
1870
|
+
// non AAD scenarios can have empty realm
|
|
1871
|
+
account.realm =
|
|
1872
|
+
clientInfo?.utid ||
|
|
1873
|
+
getTenantIdFromIdTokenClaims(accountDetails.idTokenClaims) ||
|
|
1874
|
+
"";
|
|
1875
|
+
// How do you account for MSA CID here?
|
|
1876
|
+
account.localAccountId =
|
|
1877
|
+
clientInfo?.uid ||
|
|
1878
|
+
accountDetails.idTokenClaims?.oid ||
|
|
1879
|
+
accountDetails.idTokenClaims?.sub ||
|
|
1880
|
+
"";
|
|
1881
|
+
/*
|
|
1882
|
+
* In B2C scenarios the emails claim is used instead of preferred_username and it is an array.
|
|
1883
|
+
* In most cases it will contain a single email. This field should not be relied upon if a custom
|
|
1884
|
+
* policy is configured to return more than 1 email.
|
|
1885
|
+
*/
|
|
1886
|
+
const preferredUsername = accountDetails.idTokenClaims?.preferred_username ||
|
|
1887
|
+
accountDetails.idTokenClaims?.upn;
|
|
1888
|
+
const email = accountDetails.idTokenClaims?.emails
|
|
1889
|
+
? accountDetails.idTokenClaims.emails[0]
|
|
1890
|
+
: null;
|
|
1891
|
+
account.username = preferredUsername || email || "";
|
|
1892
|
+
account.loginHint = accountDetails.idTokenClaims?.login_hint;
|
|
1893
|
+
account.name = accountDetails.idTokenClaims?.name || "";
|
|
1894
|
+
account.cloudGraphHostName = accountDetails.cloudGraphHostName;
|
|
1895
|
+
account.msGraphHost = accountDetails.msGraphHost;
|
|
1896
|
+
if (accountDetails.tenantProfiles) {
|
|
1897
|
+
account.tenantProfiles = accountDetails.tenantProfiles;
|
|
1898
|
+
}
|
|
1899
|
+
else {
|
|
1900
|
+
const tenantProfile = buildTenantProfile(accountDetails.homeAccountId, account.localAccountId, account.realm, accountDetails.idTokenClaims);
|
|
1901
|
+
account.tenantProfiles = [tenantProfile];
|
|
1902
|
+
}
|
|
1903
|
+
return account;
|
|
1904
|
+
}
|
|
1905
|
+
/**
|
|
1906
|
+
* Creates an AccountEntity object from AccountInfo
|
|
1907
|
+
* @param accountInfo
|
|
1908
|
+
* @param cloudGraphHostName
|
|
1909
|
+
* @param msGraphHost
|
|
1910
|
+
* @returns
|
|
1911
|
+
*/
|
|
1912
|
+
static createFromAccountInfo(accountInfo, cloudGraphHostName, msGraphHost) {
|
|
1913
|
+
const account = new AccountEntity();
|
|
1914
|
+
account.authorityType =
|
|
1915
|
+
accountInfo.authorityType || CacheAccountType.GENERIC_ACCOUNT_TYPE;
|
|
1916
|
+
account.homeAccountId = accountInfo.homeAccountId;
|
|
1917
|
+
account.localAccountId = accountInfo.localAccountId;
|
|
1918
|
+
account.nativeAccountId = accountInfo.nativeAccountId;
|
|
1919
|
+
account.realm = accountInfo.tenantId;
|
|
1920
|
+
account.environment = accountInfo.environment;
|
|
1921
|
+
account.username = accountInfo.username;
|
|
1922
|
+
account.name = accountInfo.name;
|
|
1923
|
+
account.loginHint = accountInfo.loginHint;
|
|
1924
|
+
account.cloudGraphHostName = cloudGraphHostName;
|
|
1925
|
+
account.msGraphHost = msGraphHost;
|
|
1926
|
+
// Serialize tenant profiles map into an array
|
|
1927
|
+
account.tenantProfiles = Array.from(accountInfo.tenantProfiles?.values() || []);
|
|
1928
|
+
account.dataBoundary = accountInfo.dataBoundary;
|
|
1929
|
+
return account;
|
|
1930
|
+
}
|
|
1931
|
+
/**
|
|
1932
|
+
* Generate HomeAccountId from server response
|
|
1933
|
+
* @param serverClientInfo
|
|
1934
|
+
* @param authType
|
|
1935
|
+
*/
|
|
1936
|
+
static generateHomeAccountId(serverClientInfo, authType, logger, cryptoObj, idTokenClaims) {
|
|
1937
|
+
// since ADFS/DSTS do not have tid and does not set client_info
|
|
1938
|
+
if (!(authType === AuthorityType.Adfs ||
|
|
1939
|
+
authType === AuthorityType.Dsts)) {
|
|
1940
|
+
// for cases where there is clientInfo
|
|
1941
|
+
if (serverClientInfo) {
|
|
1942
|
+
try {
|
|
1943
|
+
const clientInfo = buildClientInfo(serverClientInfo, cryptoObj.base64Decode);
|
|
1944
|
+
if (clientInfo.uid && clientInfo.utid) {
|
|
1945
|
+
return `${clientInfo.uid}.${clientInfo.utid}`;
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
catch (e) { }
|
|
1949
|
+
}
|
|
1950
|
+
logger.warning("No client info in response");
|
|
1951
|
+
}
|
|
1952
|
+
// default to "sub" claim
|
|
1953
|
+
return idTokenClaims?.sub || "";
|
|
1954
|
+
}
|
|
1955
|
+
/**
|
|
1956
|
+
* Validates an entity: checks for all expected params
|
|
1957
|
+
* @param entity
|
|
1958
|
+
*/
|
|
1959
|
+
static isAccountEntity(entity) {
|
|
1960
|
+
if (!entity) {
|
|
1961
|
+
return false;
|
|
1962
|
+
}
|
|
1963
|
+
return (entity.hasOwnProperty("homeAccountId") &&
|
|
1964
|
+
entity.hasOwnProperty("environment") &&
|
|
1965
|
+
entity.hasOwnProperty("realm") &&
|
|
1966
|
+
entity.hasOwnProperty("localAccountId") &&
|
|
1967
|
+
entity.hasOwnProperty("username") &&
|
|
1968
|
+
entity.hasOwnProperty("authorityType"));
|
|
1969
|
+
}
|
|
1970
|
+
/**
|
|
1971
|
+
* Helper function to determine whether 2 accountInfo objects represent the same account
|
|
1972
|
+
* @param accountA
|
|
1973
|
+
* @param accountB
|
|
1974
|
+
* @param compareClaims - If set to true idTokenClaims will also be compared to determine account equality
|
|
1975
|
+
*/
|
|
1976
|
+
static accountInfoIsEqual(accountA, accountB, compareClaims) {
|
|
1977
|
+
if (!accountA || !accountB) {
|
|
1978
|
+
return false;
|
|
1979
|
+
}
|
|
1980
|
+
let claimsMatch = true; // default to true so as to not fail comparison below if compareClaims: false
|
|
1981
|
+
if (compareClaims) {
|
|
1982
|
+
const accountAClaims = (accountA.idTokenClaims ||
|
|
1983
|
+
{});
|
|
1984
|
+
const accountBClaims = (accountB.idTokenClaims ||
|
|
1985
|
+
{});
|
|
1986
|
+
// issued at timestamp and nonce are expected to change each time a new id token is acquired
|
|
1987
|
+
claimsMatch =
|
|
1988
|
+
accountAClaims.iat === accountBClaims.iat &&
|
|
1989
|
+
accountAClaims.nonce === accountBClaims.nonce;
|
|
1990
|
+
}
|
|
1991
|
+
return (accountA.homeAccountId === accountB.homeAccountId &&
|
|
1992
|
+
accountA.localAccountId === accountB.localAccountId &&
|
|
1993
|
+
accountA.username === accountB.username &&
|
|
1994
|
+
accountA.tenantId === accountB.tenantId &&
|
|
1995
|
+
accountA.loginHint === accountB.loginHint &&
|
|
1996
|
+
accountA.environment === accountB.environment &&
|
|
1997
|
+
accountA.nativeAccountId === accountB.nativeAccountId &&
|
|
1998
|
+
claimsMatch);
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
|
|
2002
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
1681
2003
|
|
|
1682
2004
|
/*
|
|
1683
2005
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1700,6 +2022,26 @@ function extractTokenClaims(encodedToken, base64Decode) {
|
|
|
1700
2022
|
throw createClientAuthError(tokenParsingError);
|
|
1701
2023
|
}
|
|
1702
2024
|
}
|
|
2025
|
+
/**
|
|
2026
|
+
* Check if the signin_state claim contains "kmsi"
|
|
2027
|
+
* @param idTokenClaims
|
|
2028
|
+
* @returns
|
|
2029
|
+
*/
|
|
2030
|
+
function isKmsi(idTokenClaims) {
|
|
2031
|
+
if (!idTokenClaims.signin_state) {
|
|
2032
|
+
return false;
|
|
2033
|
+
}
|
|
2034
|
+
/**
|
|
2035
|
+
* Signin_state claim known values:
|
|
2036
|
+
* dvc_mngd - device is managed
|
|
2037
|
+
* dvc_dmjd - device is domain joined
|
|
2038
|
+
* kmsi - user opted to "keep me signed in"
|
|
2039
|
+
* inknownntwk - Request made inside a known network. Don't use this, use CAE instead.
|
|
2040
|
+
*/
|
|
2041
|
+
const kmsiClaims = ["kmsi", "dvc_dmjd"]; // There are some cases where kmsi may not be returned but persistent storage is still OK - allow dvc_dmjd as well
|
|
2042
|
+
const kmsi = idTokenClaims.signin_state.some((value) => kmsiClaims.includes(value.trim().toLowerCase()));
|
|
2043
|
+
return kmsi;
|
|
2044
|
+
}
|
|
1703
2045
|
/**
|
|
1704
2046
|
* decode a JWT
|
|
1705
2047
|
*
|
|
@@ -1738,7 +2080,7 @@ function checkMaxAge(authTime, maxAge) {
|
|
|
1738
2080
|
}
|
|
1739
2081
|
}
|
|
1740
2082
|
|
|
1741
|
-
/*! @azure/msal-common v15.13.
|
|
2083
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
1742
2084
|
/**
|
|
1743
2085
|
* Parses hash string from given string. Returns empty string if no hash symbol is found.
|
|
1744
2086
|
* @param hashString
|
|
@@ -1798,7 +2140,7 @@ function mapToQueryString(parameters, encodeExtraParams = true, extraQueryParame
|
|
|
1798
2140
|
return queryParameterArray.join("&");
|
|
1799
2141
|
}
|
|
1800
2142
|
|
|
1801
|
-
/*! @azure/msal-common v15.13.
|
|
2143
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
1802
2144
|
|
|
1803
2145
|
/*
|
|
1804
2146
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1962,7 +2304,7 @@ class UrlString {
|
|
|
1962
2304
|
}
|
|
1963
2305
|
}
|
|
1964
2306
|
|
|
1965
|
-
/*! @azure/msal-common v15.13.
|
|
2307
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
1966
2308
|
|
|
1967
2309
|
/*
|
|
1968
2310
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2101,7 +2443,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
|
|
|
2101
2443
|
return null;
|
|
2102
2444
|
}
|
|
2103
2445
|
|
|
2104
|
-
/*! @azure/msal-common v15.13.
|
|
2446
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
2105
2447
|
/*
|
|
2106
2448
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2107
2449
|
* Licensed under the MIT License.
|
|
@@ -2109,7 +2451,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
|
|
|
2109
2451
|
const cacheQuotaExceeded = "cache_quota_exceeded";
|
|
2110
2452
|
const cacheErrorUnknown = "cache_error_unknown";
|
|
2111
2453
|
|
|
2112
|
-
/*! @azure/msal-common v15.13.
|
|
2454
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
2113
2455
|
|
|
2114
2456
|
/*
|
|
2115
2457
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2154,7 +2496,7 @@ function createCacheError(e) {
|
|
|
2154
2496
|
}
|
|
2155
2497
|
}
|
|
2156
2498
|
|
|
2157
|
-
/*! @azure/msal-common v15.13.
|
|
2499
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
2158
2500
|
|
|
2159
2501
|
/*
|
|
2160
2502
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2213,7 +2555,7 @@ class CacheManager {
|
|
|
2213
2555
|
getBaseAccountInfo(accountFilter, correlationId) {
|
|
2214
2556
|
const accountEntities = this.getAccountsFilteredBy(accountFilter, correlationId);
|
|
2215
2557
|
if (accountEntities.length > 0) {
|
|
2216
|
-
return accountEntities[0]
|
|
2558
|
+
return AccountEntity.getAccountInfo(accountEntities[0]);
|
|
2217
2559
|
}
|
|
2218
2560
|
else {
|
|
2219
2561
|
return null;
|
|
@@ -2252,7 +2594,7 @@ class CacheManager {
|
|
|
2252
2594
|
return tenantedAccountInfo;
|
|
2253
2595
|
}
|
|
2254
2596
|
getTenantProfilesFromAccountEntity(accountEntity, correlationId, targetTenantId, tenantProfileFilter) {
|
|
2255
|
-
const accountInfo =
|
|
2597
|
+
const accountInfo = AccountEntity.getAccountInfo(accountEntity);
|
|
2256
2598
|
let searchTenantProfiles = accountInfo.tenantProfiles || new Map();
|
|
2257
2599
|
const tokenKeys = this.getTokenKeys();
|
|
2258
2600
|
// If a tenant ID was provided, only return the tenant profile for that tenant ID if it exists
|
|
@@ -2322,27 +2664,28 @@ class CacheManager {
|
|
|
2322
2664
|
/**
|
|
2323
2665
|
* saves a cache record
|
|
2324
2666
|
* @param cacheRecord {CacheRecord}
|
|
2325
|
-
* @param storeInCache {?StoreInCache}
|
|
2326
2667
|
* @param correlationId {?string} correlation id
|
|
2668
|
+
* @param kmsi - Keep Me Signed In
|
|
2669
|
+
* @param storeInCache {?StoreInCache}
|
|
2327
2670
|
*/
|
|
2328
|
-
async saveCacheRecord(cacheRecord, correlationId, storeInCache) {
|
|
2671
|
+
async saveCacheRecord(cacheRecord, correlationId, kmsi, storeInCache) {
|
|
2329
2672
|
if (!cacheRecord) {
|
|
2330
2673
|
throw createClientAuthError(invalidCacheRecord);
|
|
2331
2674
|
}
|
|
2332
2675
|
try {
|
|
2333
2676
|
if (!!cacheRecord.account) {
|
|
2334
|
-
await this.setAccount(cacheRecord.account, correlationId);
|
|
2677
|
+
await this.setAccount(cacheRecord.account, correlationId, kmsi);
|
|
2335
2678
|
}
|
|
2336
2679
|
if (!!cacheRecord.idToken && storeInCache?.idToken !== false) {
|
|
2337
|
-
await this.setIdTokenCredential(cacheRecord.idToken, correlationId);
|
|
2680
|
+
await this.setIdTokenCredential(cacheRecord.idToken, correlationId, kmsi);
|
|
2338
2681
|
}
|
|
2339
2682
|
if (!!cacheRecord.accessToken &&
|
|
2340
2683
|
storeInCache?.accessToken !== false) {
|
|
2341
|
-
await this.saveAccessToken(cacheRecord.accessToken, correlationId);
|
|
2684
|
+
await this.saveAccessToken(cacheRecord.accessToken, correlationId, kmsi);
|
|
2342
2685
|
}
|
|
2343
2686
|
if (!!cacheRecord.refreshToken &&
|
|
2344
2687
|
storeInCache?.refreshToken !== false) {
|
|
2345
|
-
await this.setRefreshTokenCredential(cacheRecord.refreshToken, correlationId);
|
|
2688
|
+
await this.setRefreshTokenCredential(cacheRecord.refreshToken, correlationId, kmsi);
|
|
2346
2689
|
}
|
|
2347
2690
|
if (!!cacheRecord.appMetadata) {
|
|
2348
2691
|
this.setAppMetadata(cacheRecord.appMetadata, correlationId);
|
|
@@ -2362,7 +2705,7 @@ class CacheManager {
|
|
|
2362
2705
|
* saves access token credential
|
|
2363
2706
|
* @param credential
|
|
2364
2707
|
*/
|
|
2365
|
-
async saveAccessToken(credential, correlationId) {
|
|
2708
|
+
async saveAccessToken(credential, correlationId, kmsi) {
|
|
2366
2709
|
const accessTokenFilter = {
|
|
2367
2710
|
clientId: credential.clientId,
|
|
2368
2711
|
credentialType: credential.credentialType,
|
|
@@ -2387,7 +2730,7 @@ class CacheManager {
|
|
|
2387
2730
|
}
|
|
2388
2731
|
}
|
|
2389
2732
|
});
|
|
2390
|
-
await this.setAccessTokenCredential(credential, correlationId);
|
|
2733
|
+
await this.setAccessTokenCredential(credential, correlationId, kmsi);
|
|
2391
2734
|
}
|
|
2392
2735
|
/**
|
|
2393
2736
|
* Retrieve account entities matching all provided tenant-agnostic filters; if no filter is set, get all account entities in the cache
|
|
@@ -3262,31 +3605,7 @@ class DefaultStorageClass extends CacheManager {
|
|
|
3262
3605
|
}
|
|
3263
3606
|
}
|
|
3264
3607
|
|
|
3265
|
-
/*! @azure/msal-common v15.13.
|
|
3266
|
-
/*
|
|
3267
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3268
|
-
* Licensed under the MIT License.
|
|
3269
|
-
*/
|
|
3270
|
-
/**
|
|
3271
|
-
* Protocol modes supported by MSAL.
|
|
3272
|
-
*/
|
|
3273
|
-
const ProtocolMode = {
|
|
3274
|
-
/**
|
|
3275
|
-
* Auth Code + PKCE with Entra ID (formerly AAD) specific optimizations and features
|
|
3276
|
-
*/
|
|
3277
|
-
AAD: "AAD",
|
|
3278
|
-
/**
|
|
3279
|
-
* Auth Code + PKCE without Entra ID specific optimizations and features. For use only with non-Microsoft owned authorities.
|
|
3280
|
-
* Support is limited for this mode.
|
|
3281
|
-
*/
|
|
3282
|
-
OIDC: "OIDC",
|
|
3283
|
-
/**
|
|
3284
|
-
* Encrypted Authorize Response (EAR) with Entra ID specific optimizations and features
|
|
3285
|
-
*/
|
|
3286
|
-
EAR: "EAR",
|
|
3287
|
-
};
|
|
3288
|
-
|
|
3289
|
-
/*! @azure/msal-common v15.13.0 2025-09-24 */
|
|
3608
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
3290
3609
|
/*
|
|
3291
3610
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3292
3611
|
* Licensed under the MIT License.
|
|
@@ -3553,7 +3872,7 @@ const PerformanceEvents = {
|
|
|
3553
3872
|
const PerformanceEventStatus = {
|
|
3554
3873
|
InProgress: 1};
|
|
3555
3874
|
|
|
3556
|
-
/*! @azure/msal-common v15.13.
|
|
3875
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
3557
3876
|
|
|
3558
3877
|
/*
|
|
3559
3878
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3632,7 +3951,7 @@ class StubPerformanceClient {
|
|
|
3632
3951
|
}
|
|
3633
3952
|
}
|
|
3634
3953
|
|
|
3635
|
-
/*! @azure/msal-common v15.13.
|
|
3954
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
3636
3955
|
|
|
3637
3956
|
/*
|
|
3638
3957
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3732,57 +4051,17 @@ function isOidcProtocolMode(config) {
|
|
|
3732
4051
|
return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
|
|
3733
4052
|
}
|
|
3734
4053
|
|
|
3735
|
-
/*! @azure/msal-common v15.13.
|
|
3736
|
-
/*
|
|
3737
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3738
|
-
* Licensed under the MIT License.
|
|
3739
|
-
*/
|
|
3740
|
-
const CcsCredentialType = {
|
|
3741
|
-
HOME_ACCOUNT_ID: "home_account_id",
|
|
3742
|
-
UPN: "UPN",
|
|
3743
|
-
};
|
|
3744
|
-
|
|
3745
|
-
/*! @azure/msal-common v15.13.0 2025-09-24 */
|
|
3746
|
-
|
|
4054
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
3747
4055
|
/*
|
|
3748
4056
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3749
4057
|
* Licensed under the MIT License.
|
|
3750
4058
|
*/
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
*/
|
|
3756
|
-
function buildClientInfo(rawClientInfo, base64Decode) {
|
|
3757
|
-
if (!rawClientInfo) {
|
|
3758
|
-
throw createClientAuthError(clientInfoEmptyError);
|
|
3759
|
-
}
|
|
3760
|
-
try {
|
|
3761
|
-
const decodedClientInfo = base64Decode(rawClientInfo);
|
|
3762
|
-
return JSON.parse(decodedClientInfo);
|
|
3763
|
-
}
|
|
3764
|
-
catch (e) {
|
|
3765
|
-
throw createClientAuthError(clientInfoDecodingError);
|
|
3766
|
-
}
|
|
3767
|
-
}
|
|
3768
|
-
/**
|
|
3769
|
-
* Function to build a client info object from cached homeAccountId string
|
|
3770
|
-
* @param homeAccountId
|
|
3771
|
-
*/
|
|
3772
|
-
function buildClientInfoFromHomeAccountId(homeAccountId) {
|
|
3773
|
-
if (!homeAccountId) {
|
|
3774
|
-
throw createClientAuthError(clientInfoDecodingError);
|
|
3775
|
-
}
|
|
3776
|
-
const clientInfoParts = homeAccountId.split(Separators.CLIENT_INFO_SEPARATOR, 2);
|
|
3777
|
-
return {
|
|
3778
|
-
uid: clientInfoParts[0],
|
|
3779
|
-
utid: clientInfoParts.length < 2
|
|
3780
|
-
? Constants$1.EMPTY_STRING
|
|
3781
|
-
: clientInfoParts[1],
|
|
3782
|
-
};
|
|
3783
|
-
}
|
|
4059
|
+
const CcsCredentialType = {
|
|
4060
|
+
HOME_ACCOUNT_ID: "home_account_id",
|
|
4061
|
+
UPN: "UPN",
|
|
4062
|
+
};
|
|
3784
4063
|
|
|
3785
|
-
/*! @azure/msal-common v15.13.
|
|
4064
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
3786
4065
|
/*
|
|
3787
4066
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3788
4067
|
* Licensed under the MIT License.
|
|
@@ -3833,7 +4112,7 @@ const BROKER_CLIENT_ID = "brk_client_id";
|
|
|
3833
4112
|
const BROKER_REDIRECT_URI = "brk_redirect_uri";
|
|
3834
4113
|
const INSTANCE_AWARE = "instance_aware";
|
|
3835
4114
|
|
|
3836
|
-
/*! @azure/msal-common v15.13.
|
|
4115
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
3837
4116
|
|
|
3838
4117
|
/*
|
|
3839
4118
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4219,22 +4498,7 @@ function addBrokerParameters(parameters, brokerClientId, brokerRedirectUri) {
|
|
|
4219
4498
|
}
|
|
4220
4499
|
}
|
|
4221
4500
|
|
|
4222
|
-
/*! @azure/msal-common v15.13.
|
|
4223
|
-
/*
|
|
4224
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4225
|
-
* Licensed under the MIT License.
|
|
4226
|
-
*/
|
|
4227
|
-
/**
|
|
4228
|
-
* Authority types supported by MSAL.
|
|
4229
|
-
*/
|
|
4230
|
-
const AuthorityType = {
|
|
4231
|
-
Default: 0,
|
|
4232
|
-
Adfs: 1,
|
|
4233
|
-
Dsts: 2,
|
|
4234
|
-
Ciam: 3,
|
|
4235
|
-
};
|
|
4236
|
-
|
|
4237
|
-
/*! @azure/msal-common v15.13.0 2025-09-24 */
|
|
4501
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
4238
4502
|
/*
|
|
4239
4503
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4240
4504
|
* Licensed under the MIT License.
|
|
@@ -4246,7 +4510,7 @@ function isOpenIdConfigResponse(response) {
|
|
|
4246
4510
|
response.hasOwnProperty("jwks_uri"));
|
|
4247
4511
|
}
|
|
4248
4512
|
|
|
4249
|
-
/*! @azure/msal-common v15.13.
|
|
4513
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
4250
4514
|
/*
|
|
4251
4515
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4252
4516
|
* Licensed under the MIT License.
|
|
@@ -4256,7 +4520,7 @@ function isCloudInstanceDiscoveryResponse(response) {
|
|
|
4256
4520
|
response.hasOwnProperty("metadata"));
|
|
4257
4521
|
}
|
|
4258
4522
|
|
|
4259
|
-
/*! @azure/msal-common v15.13.
|
|
4523
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
4260
4524
|
/*
|
|
4261
4525
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4262
4526
|
* Licensed under the MIT License.
|
|
@@ -4266,7 +4530,7 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
|
|
|
4266
4530
|
response.hasOwnProperty("error_description"));
|
|
4267
4531
|
}
|
|
4268
4532
|
|
|
4269
|
-
/*! @azure/msal-common v15.13.
|
|
4533
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
4270
4534
|
/*
|
|
4271
4535
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4272
4536
|
* Licensed under the MIT License.
|
|
@@ -4362,7 +4626,7 @@ const invokeAsync = (callback, eventName, logger, telemetryClient, correlationId
|
|
|
4362
4626
|
};
|
|
4363
4627
|
};
|
|
4364
4628
|
|
|
4365
|
-
/*! @azure/msal-common v15.13.
|
|
4629
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
4366
4630
|
|
|
4367
4631
|
/*
|
|
4368
4632
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4468,7 +4732,7 @@ RegionDiscovery.IMDS_OPTIONS = {
|
|
|
4468
4732
|
},
|
|
4469
4733
|
};
|
|
4470
4734
|
|
|
4471
|
-
/*! @azure/msal-common v15.13.
|
|
4735
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
4472
4736
|
/*
|
|
4473
4737
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4474
4738
|
* Licensed under the MIT License.
|
|
@@ -4523,7 +4787,7 @@ function delay(t, value) {
|
|
|
4523
4787
|
return new Promise((resolve) => setTimeout(() => resolve(value), t));
|
|
4524
4788
|
}
|
|
4525
4789
|
|
|
4526
|
-
/*! @azure/msal-common v15.13.
|
|
4790
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
4527
4791
|
|
|
4528
4792
|
/*
|
|
4529
4793
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4785,7 +5049,7 @@ function isAuthorityMetadataExpired(metadata) {
|
|
|
4785
5049
|
return metadata.expiresAt <= nowSeconds();
|
|
4786
5050
|
}
|
|
4787
5051
|
|
|
4788
|
-
/*! @azure/msal-common v15.13.
|
|
5052
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
4789
5053
|
|
|
4790
5054
|
/*
|
|
4791
5055
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5624,7 +5888,7 @@ function buildStaticAuthorityOptions(authOptions) {
|
|
|
5624
5888
|
};
|
|
5625
5889
|
}
|
|
5626
5890
|
|
|
5627
|
-
/*! @azure/msal-common v15.13.
|
|
5891
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
5628
5892
|
|
|
5629
5893
|
/*
|
|
5630
5894
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5655,7 +5919,7 @@ async function createDiscoveredInstance(authorityUri, networkClient, cacheManage
|
|
|
5655
5919
|
}
|
|
5656
5920
|
}
|
|
5657
5921
|
|
|
5658
|
-
/*! @azure/msal-common v15.13.
|
|
5922
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
5659
5923
|
|
|
5660
5924
|
/*
|
|
5661
5925
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5674,7 +5938,7 @@ class ServerError extends AuthError {
|
|
|
5674
5938
|
}
|
|
5675
5939
|
}
|
|
5676
5940
|
|
|
5677
|
-
/*! @azure/msal-common v15.13.
|
|
5941
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
5678
5942
|
/*
|
|
5679
5943
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5680
5944
|
* Licensed under the MIT License.
|
|
@@ -5695,7 +5959,7 @@ function getRequestThumbprint(clientId, request, homeAccountId) {
|
|
|
5695
5959
|
};
|
|
5696
5960
|
}
|
|
5697
5961
|
|
|
5698
|
-
/*! @azure/msal-common v15.13.
|
|
5962
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
5699
5963
|
|
|
5700
5964
|
/*
|
|
5701
5965
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5782,7 +6046,7 @@ class ThrottlingUtils {
|
|
|
5782
6046
|
}
|
|
5783
6047
|
}
|
|
5784
6048
|
|
|
5785
|
-
/*! @azure/msal-common v15.13.
|
|
6049
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
5786
6050
|
|
|
5787
6051
|
/*
|
|
5788
6052
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5802,7 +6066,7 @@ class NetworkError extends AuthError {
|
|
|
5802
6066
|
}
|
|
5803
6067
|
}
|
|
5804
6068
|
|
|
5805
|
-
/*! @azure/msal-common v15.13.
|
|
6069
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
5806
6070
|
|
|
5807
6071
|
/*
|
|
5808
6072
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5869,331 +6133,88 @@ class BaseClient {
|
|
|
5869
6133
|
}
|
|
5870
6134
|
const response = await this.sendPostRequest(thumbprint, tokenEndpoint, { body: queryString, headers: headers }, correlationId);
|
|
5871
6135
|
if (this.config.serverTelemetryManager &&
|
|
5872
|
-
response.status < 500 &&
|
|
5873
|
-
response.status !== 429) {
|
|
5874
|
-
// Telemetry data successfully logged by server, clear Telemetry cache
|
|
5875
|
-
this.config.serverTelemetryManager.clearTelemetryCache();
|
|
5876
|
-
}
|
|
5877
|
-
return response;
|
|
5878
|
-
}
|
|
5879
|
-
/**
|
|
5880
|
-
* Wraps sendPostRequestAsync with necessary preflight and postflight logic
|
|
5881
|
-
* @param thumbprint - Request thumbprint for throttling
|
|
5882
|
-
* @param tokenEndpoint - Endpoint to make the POST to
|
|
5883
|
-
* @param options - Body and Headers to include on the POST request
|
|
5884
|
-
* @param correlationId - CorrelationId for telemetry
|
|
5885
|
-
*/
|
|
5886
|
-
async sendPostRequest(thumbprint, tokenEndpoint, options, correlationId) {
|
|
5887
|
-
ThrottlingUtils.preProcess(this.cacheManager, thumbprint, correlationId);
|
|
5888
|
-
let response;
|
|
5889
|
-
try {
|
|
5890
|
-
response = await invokeAsync((this.networkClient.sendPostRequestAsync.bind(this.networkClient)), PerformanceEvents.NetworkClientSendPostRequestAsync, this.logger, this.performanceClient, correlationId)(tokenEndpoint, options);
|
|
5891
|
-
const responseHeaders = response.headers || {};
|
|
5892
|
-
this.performanceClient?.addFields({
|
|
5893
|
-
refreshTokenSize: response.body.refresh_token?.length || 0,
|
|
5894
|
-
httpVerToken: responseHeaders[HeaderNames.X_MS_HTTP_VERSION] || "",
|
|
5895
|
-
requestId: responseHeaders[HeaderNames.X_MS_REQUEST_ID] || "",
|
|
5896
|
-
}, correlationId);
|
|
5897
|
-
}
|
|
5898
|
-
catch (e) {
|
|
5899
|
-
if (e instanceof NetworkError) {
|
|
5900
|
-
const responseHeaders = e.responseHeaders;
|
|
5901
|
-
if (responseHeaders) {
|
|
5902
|
-
this.performanceClient?.addFields({
|
|
5903
|
-
httpVerToken: responseHeaders[HeaderNames.X_MS_HTTP_VERSION] || "",
|
|
5904
|
-
requestId: responseHeaders[HeaderNames.X_MS_REQUEST_ID] ||
|
|
5905
|
-
"",
|
|
5906
|
-
contentTypeHeader: responseHeaders[HeaderNames.CONTENT_TYPE] ||
|
|
5907
|
-
undefined,
|
|
5908
|
-
contentLengthHeader: responseHeaders[HeaderNames.CONTENT_LENGTH] ||
|
|
5909
|
-
undefined,
|
|
5910
|
-
httpStatus: e.httpStatus,
|
|
5911
|
-
}, correlationId);
|
|
5912
|
-
}
|
|
5913
|
-
throw e.error;
|
|
5914
|
-
}
|
|
5915
|
-
if (e instanceof AuthError) {
|
|
5916
|
-
throw e;
|
|
5917
|
-
}
|
|
5918
|
-
else {
|
|
5919
|
-
throw createClientAuthError(networkError);
|
|
5920
|
-
}
|
|
5921
|
-
}
|
|
5922
|
-
ThrottlingUtils.postProcess(this.cacheManager, thumbprint, response, correlationId);
|
|
5923
|
-
return response;
|
|
5924
|
-
}
|
|
5925
|
-
/**
|
|
5926
|
-
* Updates the authority object of the client. Endpoint discovery must be completed.
|
|
5927
|
-
* @param updatedAuthority
|
|
5928
|
-
*/
|
|
5929
|
-
async updateAuthority(cloudInstanceHostname, correlationId) {
|
|
5930
|
-
this.performanceClient?.addQueueMeasurement(PerformanceEvents.UpdateTokenEndpointAuthority, correlationId);
|
|
5931
|
-
const cloudInstanceAuthorityUri = `https://${cloudInstanceHostname}/${this.authority.tenant}/`;
|
|
5932
|
-
const cloudInstanceAuthority = await createDiscoveredInstance(cloudInstanceAuthorityUri, this.networkClient, this.cacheManager, this.authority.options, this.logger, correlationId, this.performanceClient);
|
|
5933
|
-
this.authority = cloudInstanceAuthority;
|
|
5934
|
-
}
|
|
5935
|
-
/**
|
|
5936
|
-
* Creates query string for the /token request
|
|
5937
|
-
* @param request
|
|
5938
|
-
*/
|
|
5939
|
-
createTokenQueryParameters(request) {
|
|
5940
|
-
const parameters = new Map();
|
|
5941
|
-
if (request.embeddedClientId) {
|
|
5942
|
-
addBrokerParameters(parameters, this.config.authOptions.clientId, this.config.authOptions.redirectUri);
|
|
5943
|
-
}
|
|
5944
|
-
if (request.tokenQueryParameters) {
|
|
5945
|
-
addExtraQueryParameters(parameters, request.tokenQueryParameters);
|
|
5946
|
-
}
|
|
5947
|
-
addCorrelationId(parameters, request.correlationId);
|
|
5948
|
-
instrumentBrokerParams(parameters, request.correlationId, this.performanceClient);
|
|
5949
|
-
return mapToQueryString(parameters);
|
|
5950
|
-
}
|
|
5951
|
-
}
|
|
5952
|
-
|
|
5953
|
-
/*! @azure/msal-common v15.13.0 2025-09-24 */
|
|
5954
|
-
/*
|
|
5955
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5956
|
-
* Licensed under the MIT License.
|
|
5957
|
-
*/
|
|
5958
|
-
/**
|
|
5959
|
-
* Gets tenantId from available ID token claims to set as credential realm with the following precedence:
|
|
5960
|
-
* 1. tid - if the token is acquired from an Azure AD tenant tid will be present
|
|
5961
|
-
* 2. tfp - if the token is acquired from a modern B2C tenant tfp should be present
|
|
5962
|
-
* 3. acr - if the token is acquired from a legacy B2C tenant acr should be present
|
|
5963
|
-
* Downcased to match the realm case-insensitive comparison requirements
|
|
5964
|
-
* @param idTokenClaims
|
|
5965
|
-
* @returns
|
|
5966
|
-
*/
|
|
5967
|
-
function getTenantIdFromIdTokenClaims(idTokenClaims) {
|
|
5968
|
-
if (idTokenClaims) {
|
|
5969
|
-
const tenantId = idTokenClaims.tid || idTokenClaims.tfp || idTokenClaims.acr;
|
|
5970
|
-
return tenantId || null;
|
|
5971
|
-
}
|
|
5972
|
-
return null;
|
|
5973
|
-
}
|
|
5974
|
-
|
|
5975
|
-
/*! @azure/msal-common v15.13.0 2025-09-24 */
|
|
5976
|
-
|
|
5977
|
-
/*
|
|
5978
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5979
|
-
* Licensed under the MIT License.
|
|
5980
|
-
*/
|
|
5981
|
-
/**
|
|
5982
|
-
* Type that defines required and optional parameters for an Account field (based on universal cache schema implemented by all MSALs).
|
|
5983
|
-
*
|
|
5984
|
-
* Key : Value Schema
|
|
5985
|
-
*
|
|
5986
|
-
* Key: <home_account_id>-<environment>-<realm*>
|
|
5987
|
-
*
|
|
5988
|
-
* Value Schema:
|
|
5989
|
-
* {
|
|
5990
|
-
* homeAccountId: home account identifier for the auth scheme,
|
|
5991
|
-
* environment: entity that issued the token, represented as a full host
|
|
5992
|
-
* realm: Full tenant or organizational identifier that the account belongs to
|
|
5993
|
-
* localAccountId: Original tenant-specific accountID, usually used for legacy cases
|
|
5994
|
-
* username: primary username that represents the user, usually corresponds to preferred_username in the v2 endpt
|
|
5995
|
-
* authorityType: Accounts authority type as a string
|
|
5996
|
-
* name: Full name for the account, including given name and family name,
|
|
5997
|
-
* lastModificationTime: last time this entity was modified in the cache
|
|
5998
|
-
* lastModificationApp:
|
|
5999
|
-
* nativeAccountId: Account identifier on the native device
|
|
6000
|
-
* tenantProfiles: Array of tenant profile objects for each tenant that the account has authenticated with in the browser
|
|
6001
|
-
* }
|
|
6002
|
-
* @internal
|
|
6003
|
-
*/
|
|
6004
|
-
class AccountEntity {
|
|
6005
|
-
/**
|
|
6006
|
-
* Returns the AccountInfo interface for this account.
|
|
6007
|
-
*/
|
|
6008
|
-
getAccountInfo() {
|
|
6009
|
-
return {
|
|
6010
|
-
homeAccountId: this.homeAccountId,
|
|
6011
|
-
environment: this.environment,
|
|
6012
|
-
tenantId: this.realm,
|
|
6013
|
-
username: this.username,
|
|
6014
|
-
localAccountId: this.localAccountId,
|
|
6015
|
-
loginHint: this.loginHint,
|
|
6016
|
-
name: this.name,
|
|
6017
|
-
nativeAccountId: this.nativeAccountId,
|
|
6018
|
-
authorityType: this.authorityType,
|
|
6019
|
-
// Deserialize tenant profiles array into a Map
|
|
6020
|
-
tenantProfiles: new Map((this.tenantProfiles || []).map((tenantProfile) => {
|
|
6021
|
-
return [tenantProfile.tenantId, tenantProfile];
|
|
6022
|
-
})),
|
|
6023
|
-
dataBoundary: this.dataBoundary,
|
|
6024
|
-
};
|
|
6025
|
-
}
|
|
6026
|
-
/**
|
|
6027
|
-
* Returns true if the account entity is in single tenant format (outdated), false otherwise
|
|
6028
|
-
*/
|
|
6029
|
-
isSingleTenant() {
|
|
6030
|
-
return !this.tenantProfiles;
|
|
6031
|
-
}
|
|
6032
|
-
/**
|
|
6033
|
-
* Build Account cache from IdToken, clientInfo and authority/policy. Associated with AAD.
|
|
6034
|
-
* @param accountDetails
|
|
6035
|
-
*/
|
|
6036
|
-
static createAccount(accountDetails, authority, base64Decode) {
|
|
6037
|
-
const account = new AccountEntity();
|
|
6038
|
-
if (authority.authorityType === AuthorityType.Adfs) {
|
|
6039
|
-
account.authorityType = CacheAccountType.ADFS_ACCOUNT_TYPE;
|
|
6040
|
-
}
|
|
6041
|
-
else if (authority.protocolMode === ProtocolMode.OIDC) {
|
|
6042
|
-
account.authorityType = CacheAccountType.GENERIC_ACCOUNT_TYPE;
|
|
6043
|
-
}
|
|
6044
|
-
else {
|
|
6045
|
-
account.authorityType = CacheAccountType.MSSTS_ACCOUNT_TYPE;
|
|
6046
|
-
}
|
|
6047
|
-
let clientInfo;
|
|
6048
|
-
if (accountDetails.clientInfo && base64Decode) {
|
|
6049
|
-
clientInfo = buildClientInfo(accountDetails.clientInfo, base64Decode);
|
|
6050
|
-
if (clientInfo.xms_tdbr) {
|
|
6051
|
-
account.dataBoundary =
|
|
6052
|
-
clientInfo.xms_tdbr === "EU" ? "EU" : "None";
|
|
6053
|
-
}
|
|
6054
|
-
}
|
|
6055
|
-
account.clientInfo = accountDetails.clientInfo;
|
|
6056
|
-
account.homeAccountId = accountDetails.homeAccountId;
|
|
6057
|
-
account.nativeAccountId = accountDetails.nativeAccountId;
|
|
6058
|
-
const env = accountDetails.environment ||
|
|
6059
|
-
(authority && authority.getPreferredCache());
|
|
6060
|
-
if (!env) {
|
|
6061
|
-
throw createClientAuthError(invalidCacheEnvironment);
|
|
6062
|
-
}
|
|
6063
|
-
account.environment = env;
|
|
6064
|
-
// non AAD scenarios can have empty realm
|
|
6065
|
-
account.realm =
|
|
6066
|
-
clientInfo?.utid ||
|
|
6067
|
-
getTenantIdFromIdTokenClaims(accountDetails.idTokenClaims) ||
|
|
6068
|
-
"";
|
|
6069
|
-
// How do you account for MSA CID here?
|
|
6070
|
-
account.localAccountId =
|
|
6071
|
-
clientInfo?.uid ||
|
|
6072
|
-
accountDetails.idTokenClaims?.oid ||
|
|
6073
|
-
accountDetails.idTokenClaims?.sub ||
|
|
6074
|
-
"";
|
|
6075
|
-
/*
|
|
6076
|
-
* In B2C scenarios the emails claim is used instead of preferred_username and it is an array.
|
|
6077
|
-
* In most cases it will contain a single email. This field should not be relied upon if a custom
|
|
6078
|
-
* policy is configured to return more than 1 email.
|
|
6079
|
-
*/
|
|
6080
|
-
const preferredUsername = accountDetails.idTokenClaims?.preferred_username ||
|
|
6081
|
-
accountDetails.idTokenClaims?.upn;
|
|
6082
|
-
const email = accountDetails.idTokenClaims?.emails
|
|
6083
|
-
? accountDetails.idTokenClaims.emails[0]
|
|
6084
|
-
: null;
|
|
6085
|
-
account.username = preferredUsername || email || "";
|
|
6086
|
-
account.loginHint = accountDetails.idTokenClaims?.login_hint;
|
|
6087
|
-
account.name = accountDetails.idTokenClaims?.name || "";
|
|
6088
|
-
account.cloudGraphHostName = accountDetails.cloudGraphHostName;
|
|
6089
|
-
account.msGraphHost = accountDetails.msGraphHost;
|
|
6090
|
-
if (accountDetails.tenantProfiles) {
|
|
6091
|
-
account.tenantProfiles = accountDetails.tenantProfiles;
|
|
6092
|
-
}
|
|
6093
|
-
else {
|
|
6094
|
-
const tenantProfile = buildTenantProfile(accountDetails.homeAccountId, account.localAccountId, account.realm, accountDetails.idTokenClaims);
|
|
6095
|
-
account.tenantProfiles = [tenantProfile];
|
|
6096
|
-
}
|
|
6097
|
-
return account;
|
|
6098
|
-
}
|
|
6099
|
-
/**
|
|
6100
|
-
* Creates an AccountEntity object from AccountInfo
|
|
6101
|
-
* @param accountInfo
|
|
6102
|
-
* @param cloudGraphHostName
|
|
6103
|
-
* @param msGraphHost
|
|
6104
|
-
* @returns
|
|
6105
|
-
*/
|
|
6106
|
-
static createFromAccountInfo(accountInfo, cloudGraphHostName, msGraphHost) {
|
|
6107
|
-
const account = new AccountEntity();
|
|
6108
|
-
account.authorityType =
|
|
6109
|
-
accountInfo.authorityType || CacheAccountType.GENERIC_ACCOUNT_TYPE;
|
|
6110
|
-
account.homeAccountId = accountInfo.homeAccountId;
|
|
6111
|
-
account.localAccountId = accountInfo.localAccountId;
|
|
6112
|
-
account.nativeAccountId = accountInfo.nativeAccountId;
|
|
6113
|
-
account.realm = accountInfo.tenantId;
|
|
6114
|
-
account.environment = accountInfo.environment;
|
|
6115
|
-
account.username = accountInfo.username;
|
|
6116
|
-
account.name = accountInfo.name;
|
|
6117
|
-
account.loginHint = accountInfo.loginHint;
|
|
6118
|
-
account.cloudGraphHostName = cloudGraphHostName;
|
|
6119
|
-
account.msGraphHost = msGraphHost;
|
|
6120
|
-
// Serialize tenant profiles map into an array
|
|
6121
|
-
account.tenantProfiles = Array.from(accountInfo.tenantProfiles?.values() || []);
|
|
6122
|
-
account.dataBoundary = accountInfo.dataBoundary;
|
|
6123
|
-
return account;
|
|
6136
|
+
response.status < 500 &&
|
|
6137
|
+
response.status !== 429) {
|
|
6138
|
+
// Telemetry data successfully logged by server, clear Telemetry cache
|
|
6139
|
+
this.config.serverTelemetryManager.clearTelemetryCache();
|
|
6140
|
+
}
|
|
6141
|
+
return response;
|
|
6124
6142
|
}
|
|
6125
6143
|
/**
|
|
6126
|
-
*
|
|
6127
|
-
* @param
|
|
6128
|
-
* @param
|
|
6144
|
+
* Wraps sendPostRequestAsync with necessary preflight and postflight logic
|
|
6145
|
+
* @param thumbprint - Request thumbprint for throttling
|
|
6146
|
+
* @param tokenEndpoint - Endpoint to make the POST to
|
|
6147
|
+
* @param options - Body and Headers to include on the POST request
|
|
6148
|
+
* @param correlationId - CorrelationId for telemetry
|
|
6129
6149
|
*/
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6150
|
+
async sendPostRequest(thumbprint, tokenEndpoint, options, correlationId) {
|
|
6151
|
+
ThrottlingUtils.preProcess(this.cacheManager, thumbprint, correlationId);
|
|
6152
|
+
let response;
|
|
6153
|
+
try {
|
|
6154
|
+
response = await invokeAsync((this.networkClient.sendPostRequestAsync.bind(this.networkClient)), PerformanceEvents.NetworkClientSendPostRequestAsync, this.logger, this.performanceClient, correlationId)(tokenEndpoint, options);
|
|
6155
|
+
const responseHeaders = response.headers || {};
|
|
6156
|
+
this.performanceClient?.addFields({
|
|
6157
|
+
refreshTokenSize: response.body.refresh_token?.length || 0,
|
|
6158
|
+
httpVerToken: responseHeaders[HeaderNames.X_MS_HTTP_VERSION] || "",
|
|
6159
|
+
requestId: responseHeaders[HeaderNames.X_MS_REQUEST_ID] || "",
|
|
6160
|
+
}, correlationId);
|
|
6161
|
+
}
|
|
6162
|
+
catch (e) {
|
|
6163
|
+
if (e instanceof NetworkError) {
|
|
6164
|
+
const responseHeaders = e.responseHeaders;
|
|
6165
|
+
if (responseHeaders) {
|
|
6166
|
+
this.performanceClient?.addFields({
|
|
6167
|
+
httpVerToken: responseHeaders[HeaderNames.X_MS_HTTP_VERSION] || "",
|
|
6168
|
+
requestId: responseHeaders[HeaderNames.X_MS_REQUEST_ID] ||
|
|
6169
|
+
"",
|
|
6170
|
+
contentTypeHeader: responseHeaders[HeaderNames.CONTENT_TYPE] ||
|
|
6171
|
+
undefined,
|
|
6172
|
+
contentLengthHeader: responseHeaders[HeaderNames.CONTENT_LENGTH] ||
|
|
6173
|
+
undefined,
|
|
6174
|
+
httpStatus: e.httpStatus,
|
|
6175
|
+
}, correlationId);
|
|
6141
6176
|
}
|
|
6142
|
-
|
|
6177
|
+
throw e.error;
|
|
6178
|
+
}
|
|
6179
|
+
if (e instanceof AuthError) {
|
|
6180
|
+
throw e;
|
|
6181
|
+
}
|
|
6182
|
+
else {
|
|
6183
|
+
throw createClientAuthError(networkError);
|
|
6143
6184
|
}
|
|
6144
|
-
logger.warning("No client info in response");
|
|
6145
6185
|
}
|
|
6146
|
-
|
|
6147
|
-
return
|
|
6186
|
+
ThrottlingUtils.postProcess(this.cacheManager, thumbprint, response, correlationId);
|
|
6187
|
+
return response;
|
|
6148
6188
|
}
|
|
6149
6189
|
/**
|
|
6150
|
-
*
|
|
6151
|
-
* @param
|
|
6190
|
+
* Updates the authority object of the client. Endpoint discovery must be completed.
|
|
6191
|
+
* @param updatedAuthority
|
|
6152
6192
|
*/
|
|
6153
|
-
|
|
6154
|
-
|
|
6155
|
-
|
|
6156
|
-
|
|
6157
|
-
|
|
6158
|
-
entity.hasOwnProperty("environment") &&
|
|
6159
|
-
entity.hasOwnProperty("realm") &&
|
|
6160
|
-
entity.hasOwnProperty("localAccountId") &&
|
|
6161
|
-
entity.hasOwnProperty("username") &&
|
|
6162
|
-
entity.hasOwnProperty("authorityType"));
|
|
6193
|
+
async updateAuthority(cloudInstanceHostname, correlationId) {
|
|
6194
|
+
this.performanceClient?.addQueueMeasurement(PerformanceEvents.UpdateTokenEndpointAuthority, correlationId);
|
|
6195
|
+
const cloudInstanceAuthorityUri = `https://${cloudInstanceHostname}/${this.authority.tenant}/`;
|
|
6196
|
+
const cloudInstanceAuthority = await createDiscoveredInstance(cloudInstanceAuthorityUri, this.networkClient, this.cacheManager, this.authority.options, this.logger, correlationId, this.performanceClient);
|
|
6197
|
+
this.authority = cloudInstanceAuthority;
|
|
6163
6198
|
}
|
|
6164
6199
|
/**
|
|
6165
|
-
*
|
|
6166
|
-
* @param
|
|
6167
|
-
* @param accountB
|
|
6168
|
-
* @param compareClaims - If set to true idTokenClaims will also be compared to determine account equality
|
|
6200
|
+
* Creates query string for the /token request
|
|
6201
|
+
* @param request
|
|
6169
6202
|
*/
|
|
6170
|
-
|
|
6171
|
-
|
|
6172
|
-
|
|
6203
|
+
createTokenQueryParameters(request) {
|
|
6204
|
+
const parameters = new Map();
|
|
6205
|
+
if (request.embeddedClientId) {
|
|
6206
|
+
addBrokerParameters(parameters, this.config.authOptions.clientId, this.config.authOptions.redirectUri);
|
|
6173
6207
|
}
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
const accountAClaims = (accountA.idTokenClaims ||
|
|
6177
|
-
{});
|
|
6178
|
-
const accountBClaims = (accountB.idTokenClaims ||
|
|
6179
|
-
{});
|
|
6180
|
-
// issued at timestamp and nonce are expected to change each time a new id token is acquired
|
|
6181
|
-
claimsMatch =
|
|
6182
|
-
accountAClaims.iat === accountBClaims.iat &&
|
|
6183
|
-
accountAClaims.nonce === accountBClaims.nonce;
|
|
6208
|
+
if (request.tokenQueryParameters) {
|
|
6209
|
+
addExtraQueryParameters(parameters, request.tokenQueryParameters);
|
|
6184
6210
|
}
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
accountA.tenantId === accountB.tenantId &&
|
|
6189
|
-
accountA.loginHint === accountB.loginHint &&
|
|
6190
|
-
accountA.environment === accountB.environment &&
|
|
6191
|
-
accountA.nativeAccountId === accountB.nativeAccountId &&
|
|
6192
|
-
claimsMatch);
|
|
6211
|
+
addCorrelationId(parameters, request.correlationId);
|
|
6212
|
+
instrumentBrokerParams(parameters, request.correlationId, this.performanceClient);
|
|
6213
|
+
return mapToQueryString(parameters);
|
|
6193
6214
|
}
|
|
6194
6215
|
}
|
|
6195
6216
|
|
|
6196
|
-
/*! @azure/msal-common v15.13.
|
|
6217
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
6197
6218
|
/*
|
|
6198
6219
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6199
6220
|
* Licensed under the MIT License.
|
|
@@ -6221,7 +6242,7 @@ var InteractionRequiredAuthErrorCodes = /*#__PURE__*/Object.freeze({
|
|
|
6221
6242
|
uxNotAllowed: uxNotAllowed
|
|
6222
6243
|
});
|
|
6223
6244
|
|
|
6224
|
-
/*! @azure/msal-common v15.13.
|
|
6245
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
6225
6246
|
|
|
6226
6247
|
/*
|
|
6227
6248
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6311,7 +6332,7 @@ function createInteractionRequiredAuthError(errorCode) {
|
|
|
6311
6332
|
return new InteractionRequiredAuthError(errorCode, InteractionRequiredAuthErrorMessages[errorCode]);
|
|
6312
6333
|
}
|
|
6313
6334
|
|
|
6314
|
-
/*! @azure/msal-common v15.13.
|
|
6335
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
6315
6336
|
|
|
6316
6337
|
/*
|
|
6317
6338
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6383,7 +6404,7 @@ class ProtocolUtils {
|
|
|
6383
6404
|
}
|
|
6384
6405
|
}
|
|
6385
6406
|
|
|
6386
|
-
/*! @azure/msal-common v15.13.
|
|
6407
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
6387
6408
|
|
|
6388
6409
|
/*
|
|
6389
6410
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6465,7 +6486,7 @@ class PopTokenGenerator {
|
|
|
6465
6486
|
}
|
|
6466
6487
|
}
|
|
6467
6488
|
|
|
6468
|
-
/*! @azure/msal-common v15.13.
|
|
6489
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
6469
6490
|
/*
|
|
6470
6491
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6471
6492
|
* Licensed under the MIT License.
|
|
@@ -6492,7 +6513,7 @@ class PopTokenGenerator {
|
|
|
6492
6513
|
}
|
|
6493
6514
|
}
|
|
6494
6515
|
|
|
6495
|
-
/*! @azure/msal-common v15.13.
|
|
6516
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
6496
6517
|
|
|
6497
6518
|
/*
|
|
6498
6519
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6604,14 +6625,14 @@ class ResponseHandler {
|
|
|
6604
6625
|
if (handlingRefreshTokenResponse &&
|
|
6605
6626
|
!forceCacheRefreshTokenResponse &&
|
|
6606
6627
|
cacheRecord.account) {
|
|
6607
|
-
const key = this.cacheStorage.generateAccountKey(cacheRecord.account
|
|
6628
|
+
const key = this.cacheStorage.generateAccountKey(AccountEntity.getAccountInfo(cacheRecord.account));
|
|
6608
6629
|
const account = this.cacheStorage.getAccount(key, request.correlationId);
|
|
6609
6630
|
if (!account) {
|
|
6610
6631
|
this.logger.warning("Account used to refresh tokens not in persistence, refreshed tokens will not be stored in the cache");
|
|
6611
6632
|
return await ResponseHandler.generateAuthenticationResult(this.cryptoObj, authority, cacheRecord, false, request, idTokenClaims, requestStateObj, undefined, serverRequestId);
|
|
6612
6633
|
}
|
|
6613
6634
|
}
|
|
6614
|
-
await this.cacheStorage.saveCacheRecord(cacheRecord, request.correlationId, request.storeInCache);
|
|
6635
|
+
await this.cacheStorage.saveCacheRecord(cacheRecord, request.correlationId, isKmsi(idTokenClaims || {}), request.storeInCache);
|
|
6615
6636
|
}
|
|
6616
6637
|
finally {
|
|
6617
6638
|
if (this.persistencePlugin &&
|
|
@@ -6758,7 +6779,7 @@ class ResponseHandler {
|
|
|
6758
6779
|
serverTokenResponse?.spa_accountid;
|
|
6759
6780
|
}
|
|
6760
6781
|
const accountInfo = cacheRecord.account
|
|
6761
|
-
? updateAccountTenantProfileData(cacheRecord.account
|
|
6782
|
+
? updateAccountTenantProfileData(AccountEntity.getAccountInfo(cacheRecord.account), undefined, // tenantProfile optional
|
|
6762
6783
|
idTokenClaims, cacheRecord.idToken?.secret)
|
|
6763
6784
|
: null;
|
|
6764
6785
|
return {
|
|
@@ -6823,7 +6844,7 @@ function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decod
|
|
|
6823
6844
|
return baseAccount;
|
|
6824
6845
|
}
|
|
6825
6846
|
|
|
6826
|
-
/*! @azure/msal-common v15.13.
|
|
6847
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
6827
6848
|
/*
|
|
6828
6849
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6829
6850
|
* Licensed under the MIT License.
|
|
@@ -6841,7 +6862,7 @@ async function getClientAssertion(clientAssertion, clientId, tokenEndpoint) {
|
|
|
6841
6862
|
}
|
|
6842
6863
|
}
|
|
6843
6864
|
|
|
6844
|
-
/*! @azure/msal-common v15.13.
|
|
6865
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
6845
6866
|
|
|
6846
6867
|
/*
|
|
6847
6868
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7076,7 +7097,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
7076
7097
|
}
|
|
7077
7098
|
}
|
|
7078
7099
|
|
|
7079
|
-
/*! @azure/msal-common v15.13.
|
|
7100
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
7080
7101
|
|
|
7081
7102
|
/*
|
|
7082
7103
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7285,7 +7306,7 @@ class RefreshTokenClient extends BaseClient {
|
|
|
7285
7306
|
}
|
|
7286
7307
|
}
|
|
7287
7308
|
|
|
7288
|
-
/*! @azure/msal-common v15.13.
|
|
7309
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
7289
7310
|
|
|
7290
7311
|
/*
|
|
7291
7312
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7383,7 +7404,7 @@ class SilentFlowClient extends BaseClient {
|
|
|
7383
7404
|
}
|
|
7384
7405
|
}
|
|
7385
7406
|
|
|
7386
|
-
/*! @azure/msal-common v15.13.
|
|
7407
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
7387
7408
|
|
|
7388
7409
|
/*
|
|
7389
7410
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7533,7 +7554,7 @@ function extractLoginHint(account) {
|
|
|
7533
7554
|
return account.loginHint || account.idTokenClaims?.login_hint || null;
|
|
7534
7555
|
}
|
|
7535
7556
|
|
|
7536
|
-
/*! @azure/msal-common v15.13.
|
|
7557
|
+
/*! @azure/msal-common v15.13.1 2025-10-29 */
|
|
7537
7558
|
|
|
7538
7559
|
/*
|
|
7539
7560
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -9216,7 +9237,7 @@ class NodeStorage extends CacheManager {
|
|
|
9216
9237
|
* @param account - cache value to be set of type AccountEntity
|
|
9217
9238
|
*/
|
|
9218
9239
|
async setAccount(account) {
|
|
9219
|
-
const accountKey = this.generateAccountKey(
|
|
9240
|
+
const accountKey = this.generateAccountKey(AccountEntity.getAccountInfo(account));
|
|
9220
9241
|
this.setItem(accountKey, account);
|
|
9221
9242
|
}
|
|
9222
9243
|
/**
|
|
@@ -9890,7 +9911,7 @@ class ClientAssertion {
|
|
|
9890
9911
|
|
|
9891
9912
|
/* eslint-disable header/header */
|
|
9892
9913
|
const name = "@azure/msal-node";
|
|
9893
|
-
const version = "3.8.
|
|
9914
|
+
const version = "3.8.1";
|
|
9894
9915
|
|
|
9895
9916
|
/*
|
|
9896
9917
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -11596,7 +11617,24 @@ const ManagedIdentityUserAssignedIdQueryParameterNames = {
|
|
|
11596
11617
|
MANAGED_IDENTITY_RESOURCE_ID_IMDS: "msi_res_id",
|
|
11597
11618
|
MANAGED_IDENTITY_RESOURCE_ID_NON_IMDS: "mi_res_id",
|
|
11598
11619
|
};
|
|
11620
|
+
/**
|
|
11621
|
+
* Base class for all Managed Identity sources. Provides common functionality for
|
|
11622
|
+
* authenticating with Azure Managed Identity endpoints across different Azure services
|
|
11623
|
+
* including IMDS, App Service, Azure Arc, Service Fabric, Cloud Shell, and Machine Learning.
|
|
11624
|
+
*
|
|
11625
|
+
* This abstract class handles token acquisition, response processing, and network communication
|
|
11626
|
+
* while allowing concrete implementations to define source-specific request creation logic.
|
|
11627
|
+
*/
|
|
11599
11628
|
class BaseManagedIdentitySource {
|
|
11629
|
+
/**
|
|
11630
|
+
* Creates an instance of BaseManagedIdentitySource.
|
|
11631
|
+
*
|
|
11632
|
+
* @param logger - Logger instance for diagnostic information
|
|
11633
|
+
* @param nodeStorage - Storage interface for caching tokens
|
|
11634
|
+
* @param networkClient - Network client for making HTTP requests
|
|
11635
|
+
* @param cryptoProvider - Cryptographic provider for token operations
|
|
11636
|
+
* @param disableInternalRetries - Whether to disable automatic retry logic
|
|
11637
|
+
*/
|
|
11600
11638
|
constructor(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries) {
|
|
11601
11639
|
this.logger = logger;
|
|
11602
11640
|
this.nodeStorage = nodeStorage;
|
|
@@ -11604,6 +11642,18 @@ class BaseManagedIdentitySource {
|
|
|
11604
11642
|
this.cryptoProvider = cryptoProvider;
|
|
11605
11643
|
this.disableInternalRetries = disableInternalRetries;
|
|
11606
11644
|
}
|
|
11645
|
+
/**
|
|
11646
|
+
* Processes the network response and converts it to a standardized server token response.
|
|
11647
|
+
* This async version allows for source-specific response processing logic while maintaining
|
|
11648
|
+
* backward compatibility with the synchronous version.
|
|
11649
|
+
*
|
|
11650
|
+
* @param response - The network response containing the managed identity token
|
|
11651
|
+
* @param _networkClient - Network client used for the request (unused in base implementation)
|
|
11652
|
+
* @param _networkRequest - The original network request parameters (unused in base implementation)
|
|
11653
|
+
* @param _networkRequestOptions - The network request options (unused in base implementation)
|
|
11654
|
+
*
|
|
11655
|
+
* @returns Promise resolving to a standardized server authorization token response
|
|
11656
|
+
*/
|
|
11607
11657
|
async getServerTokenResponseAsync(response,
|
|
11608
11658
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11609
11659
|
_networkClient,
|
|
@@ -11613,6 +11663,15 @@ class BaseManagedIdentitySource {
|
|
|
11613
11663
|
_networkRequestOptions) {
|
|
11614
11664
|
return this.getServerTokenResponse(response);
|
|
11615
11665
|
}
|
|
11666
|
+
/**
|
|
11667
|
+
* Converts a managed identity token response to a standardized server authorization token response.
|
|
11668
|
+
* Handles time format conversion, expiration calculation, and error mapping to ensure
|
|
11669
|
+
* compatibility with the MSAL response handling pipeline.
|
|
11670
|
+
*
|
|
11671
|
+
* @param response - The network response containing the managed identity token
|
|
11672
|
+
*
|
|
11673
|
+
* @returns Standardized server authorization token response with normalized fields
|
|
11674
|
+
*/
|
|
11616
11675
|
getServerTokenResponse(response) {
|
|
11617
11676
|
let refreshIn, expiresIn;
|
|
11618
11677
|
if (response.body.expires_on) {
|
|
@@ -11650,6 +11709,21 @@ class BaseManagedIdentitySource {
|
|
|
11650
11709
|
};
|
|
11651
11710
|
return serverTokenResponse;
|
|
11652
11711
|
}
|
|
11712
|
+
/**
|
|
11713
|
+
* Acquires an access token using the managed identity endpoint for the specified resource.
|
|
11714
|
+
* This is the primary method for token acquisition, handling the complete flow from
|
|
11715
|
+
* request creation through response processing and token caching.
|
|
11716
|
+
*
|
|
11717
|
+
* @param managedIdentityRequest - The managed identity request containing resource and optional parameters
|
|
11718
|
+
* @param managedIdentityId - The managed identity configuration (system or user-assigned)
|
|
11719
|
+
* @param fakeAuthority - Authority instance used for token caching (managed identity uses a placeholder authority)
|
|
11720
|
+
* @param refreshAccessToken - Whether this is a token refresh operation
|
|
11721
|
+
*
|
|
11722
|
+
* @returns Promise resolving to an authentication result containing the access token and metadata
|
|
11723
|
+
*
|
|
11724
|
+
* @throws {AuthError} When network requests fail or token validation fails
|
|
11725
|
+
* @throws {ClientAuthError} When network errors occur during the request
|
|
11726
|
+
*/
|
|
11653
11727
|
async acquireTokenWithManagedIdentity(managedIdentityRequest, managedIdentityId, fakeAuthority, refreshAccessToken) {
|
|
11654
11728
|
const networkRequest = this.createRequest(managedIdentityRequest.resource, managedIdentityId);
|
|
11655
11729
|
if (managedIdentityRequest.revokedTokenSha256Hash) {
|
|
@@ -11704,6 +11778,19 @@ class BaseManagedIdentitySource {
|
|
|
11704
11778
|
// caches the token
|
|
11705
11779
|
return responseHandler.handleServerTokenResponse(serverTokenResponse, fakeAuthority, reqTimestamp, managedIdentityRequest);
|
|
11706
11780
|
}
|
|
11781
|
+
/**
|
|
11782
|
+
* Determines the appropriate query parameter name for user-assigned managed identity
|
|
11783
|
+
* based on the identity type, API version, and endpoint characteristics.
|
|
11784
|
+
* Different Azure services and API versions use different parameter names for the same identity types.
|
|
11785
|
+
*
|
|
11786
|
+
* @param managedIdentityIdType - The type of user-assigned managed identity (client ID, object ID, or resource ID)
|
|
11787
|
+
* @param isImds - Whether the request is being made to the IMDS (Instance Metadata Service) endpoint
|
|
11788
|
+
* @param usesApi2017 - Whether the endpoint uses the 2017-09-01 API version (affects client ID parameter name)
|
|
11789
|
+
*
|
|
11790
|
+
* @returns The correct query parameter name for the specified identity type and endpoint
|
|
11791
|
+
*
|
|
11792
|
+
* @throws {ManagedIdentityError} When an invalid managed identity ID type is provided
|
|
11793
|
+
*/
|
|
11707
11794
|
getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityIdType, isImds, usesApi2017) {
|
|
11708
11795
|
switch (managedIdentityIdType) {
|
|
11709
11796
|
case ManagedIdentityIdType.USER_ASSIGNED_CLIENT_ID:
|
|
@@ -11725,6 +11812,20 @@ class BaseManagedIdentitySource {
|
|
|
11725
11812
|
}
|
|
11726
11813
|
}
|
|
11727
11814
|
}
|
|
11815
|
+
/**
|
|
11816
|
+
* Validates and normalizes an environment variable containing a URL string.
|
|
11817
|
+
* This static utility method ensures that environment variables used for managed identity
|
|
11818
|
+
* endpoints contain properly formatted URLs and provides informative error messages when validation fails.
|
|
11819
|
+
*
|
|
11820
|
+
* @param envVariableStringName - The name of the environment variable being validated (for error reporting)
|
|
11821
|
+
* @param envVariable - The environment variable value containing the URL string
|
|
11822
|
+
* @param sourceName - The name of the managed identity source (for error reporting)
|
|
11823
|
+
* @param logger - Logger instance for diagnostic information
|
|
11824
|
+
*
|
|
11825
|
+
* @returns The validated and normalized URL string
|
|
11826
|
+
*
|
|
11827
|
+
* @throws {ManagedIdentityError} When the environment variable contains a malformed URL
|
|
11828
|
+
*/
|
|
11728
11829
|
BaseManagedIdentitySource.getValidatedEnvVariableUrlString = (envVariableStringName, envVariable, sourceName, logger) => {
|
|
11729
11830
|
try {
|
|
11730
11831
|
return new UrlString(envVariable).urlString;
|
|
@@ -11847,19 +11948,61 @@ class ManagedIdentityRequestParameters {
|
|
|
11847
11948
|
// MSI Constants. Docs for MSI are available here https://docs.microsoft.com/azure/app-service/overview-managed-identity
|
|
11848
11949
|
const APP_SERVICE_MSI_API_VERSION = "2019-08-01";
|
|
11849
11950
|
/**
|
|
11951
|
+
* Azure App Service Managed Identity Source implementation.
|
|
11952
|
+
*
|
|
11953
|
+
* This class provides managed identity authentication for applications running in Azure App Service.
|
|
11954
|
+
* It uses the local metadata service endpoint available within App Service environments to obtain
|
|
11955
|
+
* access tokens without requiring explicit credentials.
|
|
11956
|
+
*
|
|
11850
11957
|
* Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/AppServiceManagedIdentitySource.cs
|
|
11851
11958
|
*/
|
|
11852
11959
|
class AppService extends BaseManagedIdentitySource {
|
|
11960
|
+
/**
|
|
11961
|
+
* Creates a new instance of the AppService managed identity source.
|
|
11962
|
+
*
|
|
11963
|
+
* @param logger - Logger instance for diagnostic output
|
|
11964
|
+
* @param nodeStorage - Node.js storage implementation for caching
|
|
11965
|
+
* @param networkClient - Network client for making HTTP requests
|
|
11966
|
+
* @param cryptoProvider - Cryptographic operations provider
|
|
11967
|
+
* @param disableInternalRetries - Whether to disable internal retry logic
|
|
11968
|
+
* @param identityEndpoint - The App Service identity endpoint URL
|
|
11969
|
+
* @param identityHeader - The secret header value required for authentication
|
|
11970
|
+
*/
|
|
11853
11971
|
constructor(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, identityEndpoint, identityHeader) {
|
|
11854
11972
|
super(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries);
|
|
11855
11973
|
this.identityEndpoint = identityEndpoint;
|
|
11856
11974
|
this.identityHeader = identityHeader;
|
|
11857
11975
|
}
|
|
11976
|
+
/**
|
|
11977
|
+
* Retrieves the required environment variables for App Service managed identity.
|
|
11978
|
+
*
|
|
11979
|
+
* App Service managed identity requires two environment variables:
|
|
11980
|
+
* - IDENTITY_ENDPOINT: The URL of the local metadata service
|
|
11981
|
+
* - IDENTITY_HEADER: A secret header value for authentication
|
|
11982
|
+
*
|
|
11983
|
+
* @returns An array containing [identityEndpoint, identityHeader] values from environment variables.
|
|
11984
|
+
* Either value may be undefined if the environment variable is not set.
|
|
11985
|
+
*/
|
|
11858
11986
|
static getEnvironmentVariables() {
|
|
11859
11987
|
const identityEndpoint = process.env[ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT];
|
|
11860
11988
|
const identityHeader = process.env[ManagedIdentityEnvironmentVariableNames.IDENTITY_HEADER];
|
|
11861
11989
|
return [identityEndpoint, identityHeader];
|
|
11862
11990
|
}
|
|
11991
|
+
/**
|
|
11992
|
+
* Attempts to create an AppService managed identity source if the environment supports it.
|
|
11993
|
+
*
|
|
11994
|
+
* This method checks for the presence of required environment variables and validates
|
|
11995
|
+
* the identity endpoint URL. If the environment is not suitable for App Service managed
|
|
11996
|
+
* identity (missing environment variables or invalid endpoint), it returns null.
|
|
11997
|
+
*
|
|
11998
|
+
* @param logger - Logger instance for diagnostic output
|
|
11999
|
+
* @param nodeStorage - Node.js storage implementation for caching
|
|
12000
|
+
* @param networkClient - Network client for making HTTP requests
|
|
12001
|
+
* @param cryptoProvider - Cryptographic operations provider
|
|
12002
|
+
* @param disableInternalRetries - Whether to disable internal retry logic
|
|
12003
|
+
*
|
|
12004
|
+
* @returns A new AppService instance if the environment is suitable, null otherwise
|
|
12005
|
+
*/
|
|
11863
12006
|
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries) {
|
|
11864
12007
|
const [identityEndpoint, identityHeader] = AppService.getEnvironmentVariables();
|
|
11865
12008
|
// if either of the identity endpoint or identity header variables are undefined, this MSI provider is unavailable.
|
|
@@ -11871,6 +12014,18 @@ class AppService extends BaseManagedIdentitySource {
|
|
|
11871
12014
|
logger.info(`[Managed Identity] Environment variables validation passed for ${ManagedIdentitySourceNames.APP_SERVICE} managed identity. Endpoint URI: ${validatedIdentityEndpoint}. Creating ${ManagedIdentitySourceNames.APP_SERVICE} managed identity.`);
|
|
11872
12015
|
return new AppService(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, identityEndpoint, identityHeader);
|
|
11873
12016
|
}
|
|
12017
|
+
/**
|
|
12018
|
+
* Creates a managed identity token request for the App Service environment.
|
|
12019
|
+
*
|
|
12020
|
+
* This method constructs an HTTP GET request to the App Service identity endpoint
|
|
12021
|
+
* with the required headers, query parameters, and managed identity configuration.
|
|
12022
|
+
* The request includes the secret header for authentication and appropriate API version.
|
|
12023
|
+
*
|
|
12024
|
+
* @param resource - The target resource/scope for which to request an access token (e.g., "https://graph.microsoft.com/.default")
|
|
12025
|
+
* @param managedIdentityId - The managed identity configuration specifying whether to use system-assigned or user-assigned identity
|
|
12026
|
+
*
|
|
12027
|
+
* @returns A configured ManagedIdentityRequestParameters object ready for network execution
|
|
12028
|
+
*/
|
|
11874
12029
|
createRequest(resource, managedIdentityId) {
|
|
11875
12030
|
const request = new ManagedIdentityRequestParameters(HttpMethod.GET, this.identityEndpoint);
|
|
11876
12031
|
request.headers[ManagedIdentityHeaders.APP_SERVICE_SECRET_HEADER_NAME] =
|
|
@@ -11903,13 +12058,40 @@ const AZURE_ARC_FILE_DETECTION = {
|
|
|
11903
12058
|
linux: "/opt/azcmagent/bin/himds",
|
|
11904
12059
|
};
|
|
11905
12060
|
/**
|
|
12061
|
+
* Azure Arc managed identity source implementation for acquiring tokens from Azure Arc-enabled servers.
|
|
12062
|
+
*
|
|
12063
|
+
* This class provides managed identity authentication for applications running on Azure Arc-enabled servers
|
|
12064
|
+
* by communicating with the local Hybrid Instance Metadata Service (HIMDS). It supports both environment
|
|
12065
|
+
* variable-based configuration and automatic detection through the HIMDS executable.
|
|
12066
|
+
*
|
|
11906
12067
|
* Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/AzureArcManagedIdentitySource.cs
|
|
11907
12068
|
*/
|
|
11908
12069
|
class AzureArc extends BaseManagedIdentitySource {
|
|
12070
|
+
/**
|
|
12071
|
+
* Creates a new instance of the AzureArc managed identity source.
|
|
12072
|
+
*
|
|
12073
|
+
* @param logger - Logger instance for capturing telemetry and diagnostic information
|
|
12074
|
+
* @param nodeStorage - Storage implementation for caching tokens and metadata
|
|
12075
|
+
* @param networkClient - Network client for making HTTP requests to the identity endpoint
|
|
12076
|
+
* @param cryptoProvider - Cryptographic operations provider for token validation and encryption
|
|
12077
|
+
* @param disableInternalRetries - Flag to disable automatic retry logic for failed requests
|
|
12078
|
+
* @param identityEndpoint - The Azure Arc identity endpoint URL for token requests
|
|
12079
|
+
*/
|
|
11909
12080
|
constructor(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, identityEndpoint) {
|
|
11910
12081
|
super(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries);
|
|
11911
12082
|
this.identityEndpoint = identityEndpoint;
|
|
11912
12083
|
}
|
|
12084
|
+
/**
|
|
12085
|
+
* Retrieves and validates Azure Arc environment variables for managed identity configuration.
|
|
12086
|
+
*
|
|
12087
|
+
* This method checks for IDENTITY_ENDPOINT and IMDS_ENDPOINT environment variables.
|
|
12088
|
+
* If either is missing, it attempts to detect the Azure Arc environment by checking for
|
|
12089
|
+
* the HIMDS executable at platform-specific paths. On successful detection, it returns
|
|
12090
|
+
* the default identity endpoint and a helper string indicating file-based detection.
|
|
12091
|
+
*
|
|
12092
|
+
* @returns An array containing [identityEndpoint, imdsEndpoint] where both values are
|
|
12093
|
+
* strings if Azure Arc is available, or undefined if not available.
|
|
12094
|
+
*/
|
|
11913
12095
|
static getEnvironmentVariables() {
|
|
11914
12096
|
let identityEndpoint = process.env[ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT];
|
|
11915
12097
|
let imdsEndpoint = process.env[ManagedIdentityEnvironmentVariableNames.IMDS_ENDPOINT];
|
|
@@ -11935,6 +12117,25 @@ class AzureArc extends BaseManagedIdentitySource {
|
|
|
11935
12117
|
}
|
|
11936
12118
|
return [identityEndpoint, imdsEndpoint];
|
|
11937
12119
|
}
|
|
12120
|
+
/**
|
|
12121
|
+
* Attempts to create an AzureArc managed identity source instance.
|
|
12122
|
+
*
|
|
12123
|
+
* Validates the Azure Arc environment by checking environment variables
|
|
12124
|
+
* and performing file-based detection. It ensures that only system-assigned managed identities
|
|
12125
|
+
* are supported for Azure Arc scenarios. The method performs comprehensive validation of
|
|
12126
|
+
* endpoint URLs and logs detailed information about the detection process.
|
|
12127
|
+
*
|
|
12128
|
+
* @param logger - Logger instance for capturing creation and validation steps
|
|
12129
|
+
* @param nodeStorage - Storage implementation for the managed identity source
|
|
12130
|
+
* @param networkClient - Network client for HTTP communication
|
|
12131
|
+
* @param cryptoProvider - Cryptographic operations provider
|
|
12132
|
+
* @param disableInternalRetries - Whether to disable automatic retry mechanisms
|
|
12133
|
+
* @param managedIdentityId - The managed identity configuration, must be system-assigned
|
|
12134
|
+
*
|
|
12135
|
+
* @returns AzureArc instance if the environment supports Azure Arc managed identity, null otherwise
|
|
12136
|
+
*
|
|
12137
|
+
* @throws {ManagedIdentityError} When a user-assigned managed identity is specified (not supported for Azure Arc)
|
|
12138
|
+
*/
|
|
11938
12139
|
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, managedIdentityId) {
|
|
11939
12140
|
const [identityEndpoint, imdsEndpoint] = AzureArc.getEnvironmentVariables();
|
|
11940
12141
|
// if either of the identity or imds endpoints are undefined (even after himds file detection)
|
|
@@ -11961,6 +12162,17 @@ class AzureArc extends BaseManagedIdentitySource {
|
|
|
11961
12162
|
}
|
|
11962
12163
|
return new AzureArc(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, identityEndpoint);
|
|
11963
12164
|
}
|
|
12165
|
+
/**
|
|
12166
|
+
* Creates a properly formatted HTTP request for acquiring tokens from the Azure Arc identity endpoint.
|
|
12167
|
+
*
|
|
12168
|
+
* This method constructs a GET request to the Azure Arc HIMDS endpoint with the required metadata header
|
|
12169
|
+
* and query parameters. The endpoint URL is normalized to use 127.0.0.1 instead of localhost for
|
|
12170
|
+
* consistency. Additional body parameters are calculated by the base class during token acquisition.
|
|
12171
|
+
*
|
|
12172
|
+
* @param resource - The target resource/scope for which to request an access token (e.g., "https://graph.microsoft.com/.default")
|
|
12173
|
+
*
|
|
12174
|
+
* @returns A configured ManagedIdentityRequestParameters object ready for network execution
|
|
12175
|
+
*/
|
|
11964
12176
|
createRequest(resource) {
|
|
11965
12177
|
const request = new ManagedIdentityRequestParameters(HttpMethod.GET, this.identityEndpoint.replace("localhost", "127.0.0.1"));
|
|
11966
12178
|
request.headers[ManagedIdentityHeaders.METADATA_HEADER_NAME] = "true";
|
|
@@ -11971,6 +12183,30 @@ class AzureArc extends BaseManagedIdentitySource {
|
|
|
11971
12183
|
// bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
|
|
11972
12184
|
return request;
|
|
11973
12185
|
}
|
|
12186
|
+
/**
|
|
12187
|
+
* Processes the server response and handles Azure Arc-specific authentication challenges.
|
|
12188
|
+
*
|
|
12189
|
+
* This method implements the Azure Arc authentication flow which may require reading a secret file
|
|
12190
|
+
* for authorization. When the initial request returns HTTP 401 Unauthorized, it extracts the file
|
|
12191
|
+
* path from the WWW-Authenticate header, validates the file location and size, reads the secret,
|
|
12192
|
+
* and retries the request with Basic authentication. The method includes comprehensive security
|
|
12193
|
+
* validations to prevent path traversal and ensure file integrity.
|
|
12194
|
+
*
|
|
12195
|
+
* @param originalResponse - The initial HTTP response from the identity endpoint
|
|
12196
|
+
* @param networkClient - Network client for making the retry request if needed
|
|
12197
|
+
* @param networkRequest - The original request parameters (modified with auth header for retry)
|
|
12198
|
+
* @param networkRequestOptions - Additional options for network requests
|
|
12199
|
+
*
|
|
12200
|
+
* @returns A promise that resolves to the server token response with access token and metadata
|
|
12201
|
+
*
|
|
12202
|
+
* @throws {ManagedIdentityError} When:
|
|
12203
|
+
* - WWW-Authenticate header is missing or has unsupported format
|
|
12204
|
+
* - Platform is not supported (not Windows or Linux)
|
|
12205
|
+
* - Secret file has invalid extension (not .key)
|
|
12206
|
+
* - Secret file path doesn't match expected platform path
|
|
12207
|
+
* - Secret file cannot be read or is too large (>4096 bytes)
|
|
12208
|
+
* @throws {ClientAuthError} When network errors occur during retry request
|
|
12209
|
+
*/
|
|
11974
12210
|
async getServerTokenResponseAsync(originalResponse, networkClient, networkRequest, networkRequestOptions) {
|
|
11975
12211
|
let retryResponse;
|
|
11976
12212
|
if (originalResponse.status === HttpStatus.UNAUTHORIZED) {
|
|
@@ -12046,17 +12282,60 @@ class AzureArc extends BaseManagedIdentitySource {
|
|
|
12046
12282
|
* Licensed under the MIT License.
|
|
12047
12283
|
*/
|
|
12048
12284
|
/**
|
|
12285
|
+
* Azure Cloud Shell managed identity source implementation.
|
|
12286
|
+
*
|
|
12287
|
+
* This class handles authentication for applications running in Azure Cloud Shell environment.
|
|
12288
|
+
* Cloud Shell provides a browser-accessible shell for managing Azure resources and includes
|
|
12289
|
+
* a pre-configured managed identity for authentication.
|
|
12290
|
+
*
|
|
12049
12291
|
* Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/CloudShellManagedIdentitySource.cs
|
|
12050
12292
|
*/
|
|
12051
12293
|
class CloudShell extends BaseManagedIdentitySource {
|
|
12294
|
+
/**
|
|
12295
|
+
* Creates a new CloudShell managed identity source instance.
|
|
12296
|
+
*
|
|
12297
|
+
* @param logger - Logger instance for diagnostic logging
|
|
12298
|
+
* @param nodeStorage - Node.js storage implementation for caching
|
|
12299
|
+
* @param networkClient - HTTP client for making requests to the managed identity endpoint
|
|
12300
|
+
* @param cryptoProvider - Cryptographic operations provider
|
|
12301
|
+
* @param disableInternalRetries - Whether to disable automatic retry logic for failed requests
|
|
12302
|
+
* @param msiEndpoint - The MSI endpoint URL obtained from environment variables
|
|
12303
|
+
*/
|
|
12052
12304
|
constructor(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, msiEndpoint) {
|
|
12053
12305
|
super(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries);
|
|
12054
12306
|
this.msiEndpoint = msiEndpoint;
|
|
12055
12307
|
}
|
|
12308
|
+
/**
|
|
12309
|
+
* Retrieves the required environment variables for Cloud Shell managed identity.
|
|
12310
|
+
*
|
|
12311
|
+
* Cloud Shell requires the MSI_ENDPOINT environment variable to be set, which
|
|
12312
|
+
* contains the URL of the managed identity service endpoint.
|
|
12313
|
+
*
|
|
12314
|
+
* @returns An array containing the MSI_ENDPOINT environment variable value (or undefined if not set)
|
|
12315
|
+
*/
|
|
12056
12316
|
static getEnvironmentVariables() {
|
|
12057
12317
|
const msiEndpoint = process.env[ManagedIdentityEnvironmentVariableNames.MSI_ENDPOINT];
|
|
12058
12318
|
return [msiEndpoint];
|
|
12059
12319
|
}
|
|
12320
|
+
/**
|
|
12321
|
+
* Attempts to create a CloudShell managed identity source instance.
|
|
12322
|
+
*
|
|
12323
|
+
* This method validates that the required environment variables are present and
|
|
12324
|
+
* creates a CloudShell instance if the environment is properly configured.
|
|
12325
|
+
* Cloud Shell only supports system-assigned managed identities.
|
|
12326
|
+
*
|
|
12327
|
+
* @param logger - Logger instance for diagnostic logging
|
|
12328
|
+
* @param nodeStorage - Node.js storage implementation for caching
|
|
12329
|
+
* @param networkClient - HTTP client for making requests
|
|
12330
|
+
* @param cryptoProvider - Cryptographic operations provider
|
|
12331
|
+
* @param disableInternalRetries - Whether to disable automatic retry logic
|
|
12332
|
+
* @param managedIdentityId - The managed identity configuration (must be system-assigned)
|
|
12333
|
+
*
|
|
12334
|
+
* @returns A CloudShell instance if the environment is valid, null otherwise
|
|
12335
|
+
*
|
|
12336
|
+
* @throws {ManagedIdentityError} When a user-assigned managed identity is requested,
|
|
12337
|
+
* as Cloud Shell only supports system-assigned identities
|
|
12338
|
+
*/
|
|
12060
12339
|
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, managedIdentityId) {
|
|
12061
12340
|
const [msiEndpoint] = CloudShell.getEnvironmentVariables();
|
|
12062
12341
|
// if the msi endpoint environment variable is undefined, this MSI provider is unavailable.
|
|
@@ -12071,6 +12350,17 @@ class CloudShell extends BaseManagedIdentitySource {
|
|
|
12071
12350
|
}
|
|
12072
12351
|
return new CloudShell(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, msiEndpoint);
|
|
12073
12352
|
}
|
|
12353
|
+
/**
|
|
12354
|
+
* Creates an HTTP request to acquire an access token from the Cloud Shell managed identity endpoint.
|
|
12355
|
+
*
|
|
12356
|
+
* This method constructs a POST request to the MSI endpoint with the required headers and
|
|
12357
|
+
* body parameters for Cloud Shell authentication. The request includes the target resource
|
|
12358
|
+
* for which the access token is being requested.
|
|
12359
|
+
*
|
|
12360
|
+
* @param resource - The target resource/scope for which to request an access token (e.g., "https://graph.microsoft.com/.default")
|
|
12361
|
+
*
|
|
12362
|
+
* @returns A configured ManagedIdentityRequestParameters object ready for network execution
|
|
12363
|
+
*/
|
|
12074
12364
|
createRequest(resource) {
|
|
12075
12365
|
const request = new ManagedIdentityRequestParameters(HttpMethod.POST, this.msiEndpoint);
|
|
12076
12366
|
request.headers[ManagedIdentityHeaders.METADATA_HEADER_NAME] = "true";
|
|
@@ -12208,33 +12498,44 @@ const IMDS_TOKEN_PATH = "/metadata/identity/oauth2/token";
|
|
|
12208
12498
|
const DEFAULT_IMDS_ENDPOINT = `http://169.254.169.254${IMDS_TOKEN_PATH}`;
|
|
12209
12499
|
const IMDS_API_VERSION = "2018-02-01";
|
|
12210
12500
|
/**
|
|
12501
|
+
* Managed Identity source implementation for Azure Instance Metadata Service (IMDS).
|
|
12502
|
+
*
|
|
12503
|
+
* IMDS is available on Azure Virtual Machines and Virtual Machine Scale Sets and provides
|
|
12504
|
+
* a REST endpoint to obtain OAuth tokens for managed identities. This implementation
|
|
12505
|
+
* handles both system-assigned and user-assigned managed identities.
|
|
12506
|
+
*
|
|
12211
12507
|
* Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/ImdsManagedIdentitySource.cs
|
|
12212
12508
|
*/
|
|
12213
12509
|
class Imds extends BaseManagedIdentitySource {
|
|
12214
12510
|
/**
|
|
12215
|
-
* Constructs an Imds instance.
|
|
12216
|
-
*
|
|
12217
|
-
* @param
|
|
12218
|
-
* @param
|
|
12219
|
-
* @param
|
|
12220
|
-
* @param
|
|
12221
|
-
* @param
|
|
12511
|
+
* Constructs an Imds instance with the specified configuration.
|
|
12512
|
+
*
|
|
12513
|
+
* @param logger - Logger instance for recording debug information and errors
|
|
12514
|
+
* @param nodeStorage - NodeStorage instance used for token caching operations
|
|
12515
|
+
* @param networkClient - Network client implementation for making HTTP requests to IMDS
|
|
12516
|
+
* @param cryptoProvider - CryptoProvider for generating correlation IDs and other cryptographic operations
|
|
12517
|
+
* @param disableInternalRetries - When true, disables the built-in retry logic for IMDS requests
|
|
12518
|
+
* @param identityEndpoint - The complete IMDS endpoint URL including the token path
|
|
12222
12519
|
*/
|
|
12223
12520
|
constructor(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, identityEndpoint) {
|
|
12224
12521
|
super(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries);
|
|
12225
12522
|
this.identityEndpoint = identityEndpoint;
|
|
12226
12523
|
}
|
|
12227
12524
|
/**
|
|
12228
|
-
*
|
|
12229
|
-
* If the AZURE_POD_IDENTITY_AUTHORITY_HOST environment variable is set, it uses that as the endpoint.
|
|
12230
|
-
* Otherwise, it falls back to the default IMDS endpoint.
|
|
12525
|
+
* Creates an Imds instance with the appropriate endpoint configuration.
|
|
12231
12526
|
*
|
|
12232
|
-
*
|
|
12233
|
-
*
|
|
12234
|
-
*
|
|
12235
|
-
*
|
|
12236
|
-
*
|
|
12237
|
-
* @
|
|
12527
|
+
* This method checks for the presence of the AZURE_POD_IDENTITY_AUTHORITY_HOST environment
|
|
12528
|
+
* variable, which is used in Azure Kubernetes Service (AKS) environments with Azure AD
|
|
12529
|
+
* Pod Identity. If found, it uses that endpoint; otherwise, it falls back to the standard
|
|
12530
|
+
* IMDS endpoint (169.254.169.254).
|
|
12531
|
+
*
|
|
12532
|
+
* @param logger - Logger instance for recording endpoint discovery and validation
|
|
12533
|
+
* @param nodeStorage - NodeStorage instance for token caching
|
|
12534
|
+
* @param networkClient - Network client for HTTP requests
|
|
12535
|
+
* @param cryptoProvider - CryptoProvider for cryptographic operations
|
|
12536
|
+
* @param disableInternalRetries - Whether to disable built-in retry logic
|
|
12537
|
+
*
|
|
12538
|
+
* @returns A configured Imds instance ready to make token requests
|
|
12238
12539
|
*/
|
|
12239
12540
|
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries) {
|
|
12240
12541
|
let validatedIdentityEndpoint;
|
|
@@ -12252,12 +12553,23 @@ class Imds extends BaseManagedIdentitySource {
|
|
|
12252
12553
|
return new Imds(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, validatedIdentityEndpoint);
|
|
12253
12554
|
}
|
|
12254
12555
|
/**
|
|
12255
|
-
* Creates a
|
|
12256
|
-
*
|
|
12556
|
+
* Creates a properly configured HTTP request for acquiring an access token from IMDS.
|
|
12557
|
+
*
|
|
12558
|
+
* This method builds a complete request object with all necessary headers, query parameters,
|
|
12559
|
+
* and retry policies required by the Azure Instance Metadata Service.
|
|
12560
|
+
*
|
|
12561
|
+
* Key request components:
|
|
12562
|
+
* - HTTP GET method to the IMDS token endpoint
|
|
12563
|
+
* - Metadata header set to "true" (required by IMDS)
|
|
12564
|
+
* - API version parameter (currently "2018-02-01")
|
|
12565
|
+
* - Resource parameter specifying the target audience
|
|
12566
|
+
* - Identity-specific parameters for user-assigned managed identities
|
|
12567
|
+
* - IMDS-specific retry policy
|
|
12257
12568
|
*
|
|
12258
|
-
* @param resource - The resource
|
|
12259
|
-
* @param managedIdentityId - The managed identity
|
|
12260
|
-
*
|
|
12569
|
+
* @param resource - The target resource/scope for which to request an access token (e.g., "https://graph.microsoft.com/.default")
|
|
12570
|
+
* @param managedIdentityId - The managed identity configuration specifying whether to use system-assigned or user-assigned identity
|
|
12571
|
+
*
|
|
12572
|
+
* @returns A configured ManagedIdentityRequestParameters object ready for network execution
|
|
12261
12573
|
*/
|
|
12262
12574
|
createRequest(resource, managedIdentityId) {
|
|
12263
12575
|
const request = new ManagedIdentityRequestParameters(HttpMethod.GET, this.identityEndpoint);
|
|
@@ -12286,14 +12598,19 @@ const SERVICE_FABRIC_MSI_API_VERSION = "2019-07-01-preview";
|
|
|
12286
12598
|
*/
|
|
12287
12599
|
class ServiceFabric extends BaseManagedIdentitySource {
|
|
12288
12600
|
/**
|
|
12289
|
-
* Constructs a new ServiceFabric managed identity source.
|
|
12290
|
-
*
|
|
12291
|
-
*
|
|
12292
|
-
*
|
|
12293
|
-
*
|
|
12294
|
-
*
|
|
12295
|
-
* @param
|
|
12296
|
-
* @param
|
|
12601
|
+
* Constructs a new ServiceFabric managed identity source for acquiring tokens from Azure Service Fabric clusters.
|
|
12602
|
+
*
|
|
12603
|
+
* Service Fabric managed identity allows applications running in Service Fabric clusters to authenticate
|
|
12604
|
+
* without storing credentials in code. This source handles token acquisition using the Service Fabric
|
|
12605
|
+
* Managed Identity Token Service (MITS).
|
|
12606
|
+
*
|
|
12607
|
+
* @param logger - Logger instance for logging authentication events and debugging information
|
|
12608
|
+
* @param nodeStorage - NodeStorage instance for caching tokens and other authentication artifacts
|
|
12609
|
+
* @param networkClient - Network client for making HTTP requests to the Service Fabric identity endpoint
|
|
12610
|
+
* @param cryptoProvider - Crypto provider for cryptographic operations like token validation
|
|
12611
|
+
* @param disableInternalRetries - Whether to disable internal retry logic for failed requests
|
|
12612
|
+
* @param identityEndpoint - The Service Fabric managed identity endpoint URL
|
|
12613
|
+
* @param identityHeader - The Service Fabric managed identity secret header value
|
|
12297
12614
|
*/
|
|
12298
12615
|
constructor(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, identityEndpoint, identityHeader) {
|
|
12299
12616
|
super(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries);
|
|
@@ -12301,8 +12618,16 @@ class ServiceFabric extends BaseManagedIdentitySource {
|
|
|
12301
12618
|
this.identityHeader = identityHeader;
|
|
12302
12619
|
}
|
|
12303
12620
|
/**
|
|
12304
|
-
* Retrieves the environment variables required for Service Fabric managed identity.
|
|
12305
|
-
*
|
|
12621
|
+
* Retrieves the environment variables required for Service Fabric managed identity authentication.
|
|
12622
|
+
*
|
|
12623
|
+
* Service Fabric managed identity requires three specific environment variables to be set by the
|
|
12624
|
+
* Service Fabric runtime:
|
|
12625
|
+
* - IDENTITY_ENDPOINT: The endpoint URL for the Managed Identity Token Service (MITS)
|
|
12626
|
+
* - IDENTITY_HEADER: A secret value used for authentication with the MITS
|
|
12627
|
+
* - IDENTITY_SERVER_THUMBPRINT: The thumbprint of the MITS server certificate for secure communication
|
|
12628
|
+
*
|
|
12629
|
+
* @returns An array containing the identity endpoint, identity header, and identity server thumbprint values.
|
|
12630
|
+
* Elements will be undefined if the corresponding environment variables are not set.
|
|
12306
12631
|
*/
|
|
12307
12632
|
static getEnvironmentVariables() {
|
|
12308
12633
|
const identityEndpoint = process.env[ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT];
|
|
@@ -12312,14 +12637,23 @@ class ServiceFabric extends BaseManagedIdentitySource {
|
|
|
12312
12637
|
return [identityEndpoint, identityHeader, identityServerThumbprint];
|
|
12313
12638
|
}
|
|
12314
12639
|
/**
|
|
12315
|
-
* Attempts to create a ServiceFabric managed identity source if
|
|
12316
|
-
*
|
|
12317
|
-
*
|
|
12318
|
-
*
|
|
12319
|
-
*
|
|
12320
|
-
*
|
|
12321
|
-
*
|
|
12322
|
-
*
|
|
12640
|
+
* Attempts to create a ServiceFabric managed identity source if the runtime environment supports it.
|
|
12641
|
+
*
|
|
12642
|
+
* Checks for the presence of all required Service Fabric environment variables
|
|
12643
|
+
* and validates the endpoint URL format. It will only create a ServiceFabric instance if the application
|
|
12644
|
+
* is running in a properly configured Service Fabric cluster with managed identity enabled.
|
|
12645
|
+
*
|
|
12646
|
+
* Note: User-assigned managed identities must be configured at the cluster level, not at runtime.
|
|
12647
|
+
* This method will log a warning if a user-assigned identity is requested.
|
|
12648
|
+
*
|
|
12649
|
+
* @param logger - Logger instance for logging creation events and validation results
|
|
12650
|
+
* @param nodeStorage - NodeStorage instance for caching tokens and authentication artifacts
|
|
12651
|
+
* @param networkClient - Network client for making HTTP requests to the identity endpoint
|
|
12652
|
+
* @param cryptoProvider - Crypto provider for cryptographic operations
|
|
12653
|
+
* @param disableInternalRetries - Whether to disable internal retry logic for failed requests
|
|
12654
|
+
* @param managedIdentityId - Managed identity identifier specifying system-assigned or user-assigned identity
|
|
12655
|
+
*
|
|
12656
|
+
* @returns A ServiceFabric instance if all environment variables are valid and present, otherwise null
|
|
12323
12657
|
*/
|
|
12324
12658
|
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, managedIdentityId) {
|
|
12325
12659
|
const [identityEndpoint, identityHeader, identityServerThumbprint] = ServiceFabric.getEnvironmentVariables();
|
|
@@ -12335,10 +12669,22 @@ class ServiceFabric extends BaseManagedIdentitySource {
|
|
|
12335
12669
|
return new ServiceFabric(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, identityEndpoint, identityHeader);
|
|
12336
12670
|
}
|
|
12337
12671
|
/**
|
|
12338
|
-
* Creates
|
|
12339
|
-
*
|
|
12340
|
-
*
|
|
12341
|
-
*
|
|
12672
|
+
* Creates HTTP request parameters for acquiring an access token from the Service Fabric Managed Identity Token Service (MITS).
|
|
12673
|
+
*
|
|
12674
|
+
* This method constructs a properly formatted HTTP GET request that includes:
|
|
12675
|
+
* - The secret header for authentication with MITS
|
|
12676
|
+
* - API version parameter for the Service Fabric MSI endpoint
|
|
12677
|
+
* - Resource parameter specifying the target Azure service
|
|
12678
|
+
* - Optional identity parameters for user-assigned managed identities
|
|
12679
|
+
*
|
|
12680
|
+
* The request follows the Service Fabric managed identity protocol and uses the 2019-07-01-preview API version.
|
|
12681
|
+
* For user-assigned identities, the appropriate query parameter (client_id, object_id, or resource_id) is added
|
|
12682
|
+
* based on the identity type.
|
|
12683
|
+
*
|
|
12684
|
+
* @param resource - The Azure resource URI for which the access token is requested (e.g., "https://vault.azure.net/")
|
|
12685
|
+
* @param managedIdentityId - The managed identity configuration specifying system-assigned or user-assigned identity details
|
|
12686
|
+
*
|
|
12687
|
+
* @returns A configured ManagedIdentityRequestParameters object ready for network execution
|
|
12342
12688
|
*/
|
|
12343
12689
|
createRequest(resource, managedIdentityId) {
|
|
12344
12690
|
const request = new ManagedIdentityRequestParameters(HttpMethod.GET, this.identityEndpoint);
|
|
@@ -12362,17 +12708,62 @@ class ServiceFabric extends BaseManagedIdentitySource {
|
|
|
12362
12708
|
*/
|
|
12363
12709
|
const MACHINE_LEARNING_MSI_API_VERSION = "2017-09-01";
|
|
12364
12710
|
const MANAGED_IDENTITY_MACHINE_LEARNING_UNSUPPORTED_ID_TYPE_ERROR = `Only client id is supported for user-assigned managed identity in ${ManagedIdentitySourceNames.MACHINE_LEARNING}.`; // referenced in unit test
|
|
12711
|
+
/**
|
|
12712
|
+
* Machine Learning Managed Identity Source implementation for Azure Machine Learning environments.
|
|
12713
|
+
*
|
|
12714
|
+
* This class handles managed identity authentication specifically for Azure Machine Learning services.
|
|
12715
|
+
* It supports both system-assigned and user-assigned managed identities, using the MSI_ENDPOINT
|
|
12716
|
+
* and MSI_SECRET environment variables that are automatically provided in Azure ML environments.
|
|
12717
|
+
*/
|
|
12365
12718
|
class MachineLearning extends BaseManagedIdentitySource {
|
|
12719
|
+
/**
|
|
12720
|
+
* Creates a new MachineLearning managed identity source instance.
|
|
12721
|
+
*
|
|
12722
|
+
* @param logger - Logger instance for diagnostic information
|
|
12723
|
+
* @param nodeStorage - Node storage implementation for caching
|
|
12724
|
+
* @param networkClient - Network client for making HTTP requests
|
|
12725
|
+
* @param cryptoProvider - Cryptographic operations provider
|
|
12726
|
+
* @param disableInternalRetries - Whether to disable automatic request retries
|
|
12727
|
+
* @param msiEndpoint - The MSI endpoint URL from environment variables
|
|
12728
|
+
* @param secret - The MSI secret from environment variables
|
|
12729
|
+
*/
|
|
12366
12730
|
constructor(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, msiEndpoint, secret) {
|
|
12367
12731
|
super(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries);
|
|
12368
12732
|
this.msiEndpoint = msiEndpoint;
|
|
12369
12733
|
this.secret = secret;
|
|
12370
12734
|
}
|
|
12735
|
+
/**
|
|
12736
|
+
* Retrieves the required environment variables for Azure Machine Learning managed identity.
|
|
12737
|
+
*
|
|
12738
|
+
* This method checks for the presence of MSI_ENDPOINT and MSI_SECRET environment variables
|
|
12739
|
+
* that are automatically set by the Azure Machine Learning platform when managed identity
|
|
12740
|
+
* is enabled for the compute instance or cluster.
|
|
12741
|
+
*
|
|
12742
|
+
* @returns An array containing [msiEndpoint, secret] where either value may be undefined
|
|
12743
|
+
* if the corresponding environment variable is not set
|
|
12744
|
+
*/
|
|
12371
12745
|
static getEnvironmentVariables() {
|
|
12372
12746
|
const msiEndpoint = process.env[ManagedIdentityEnvironmentVariableNames.MSI_ENDPOINT];
|
|
12373
12747
|
const secret = process.env[ManagedIdentityEnvironmentVariableNames.MSI_SECRET];
|
|
12374
12748
|
return [msiEndpoint, secret];
|
|
12375
12749
|
}
|
|
12750
|
+
/**
|
|
12751
|
+
* Attempts to create a MachineLearning managed identity source.
|
|
12752
|
+
*
|
|
12753
|
+
* This method validates the Azure Machine Learning environment by checking for the required
|
|
12754
|
+
* MSI_ENDPOINT and MSI_SECRET environment variables. If both are present and valid,
|
|
12755
|
+
* it creates and returns a MachineLearning instance. If either is missing or invalid,
|
|
12756
|
+
* it returns null, indicating that this managed identity source is not available
|
|
12757
|
+
* in the current environment.
|
|
12758
|
+
*
|
|
12759
|
+
* @param logger - Logger instance for diagnostic information
|
|
12760
|
+
* @param nodeStorage - Node storage implementation for caching
|
|
12761
|
+
* @param networkClient - Network client for making HTTP requests
|
|
12762
|
+
* @param cryptoProvider - Cryptographic operations provider
|
|
12763
|
+
* @param disableInternalRetries - Whether to disable automatic request retries
|
|
12764
|
+
*
|
|
12765
|
+
* @returns A new MachineLearning instance if the environment is valid, null otherwise
|
|
12766
|
+
*/
|
|
12376
12767
|
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries) {
|
|
12377
12768
|
const [msiEndpoint, secret] = MachineLearning.getEnvironmentVariables();
|
|
12378
12769
|
// if either of the MSI endpoint or MSI secret variables are undefined, this MSI provider is unavailable.
|
|
@@ -12384,6 +12775,26 @@ class MachineLearning extends BaseManagedIdentitySource {
|
|
|
12384
12775
|
logger.info(`[Managed Identity] Environment variables validation passed for ${ManagedIdentitySourceNames.MACHINE_LEARNING} managed identity. Endpoint URI: ${validatedMsiEndpoint}. Creating ${ManagedIdentitySourceNames.MACHINE_LEARNING} managed identity.`);
|
|
12385
12776
|
return new MachineLearning(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, msiEndpoint, secret);
|
|
12386
12777
|
}
|
|
12778
|
+
/**
|
|
12779
|
+
* Creates a managed identity token request for Azure Machine Learning environments.
|
|
12780
|
+
*
|
|
12781
|
+
* This method constructs the HTTP request parameters needed to acquire an access token
|
|
12782
|
+
* from the Azure Machine Learning managed identity endpoint. It handles both system-assigned
|
|
12783
|
+
* and user-assigned managed identities with specific logic for each type:
|
|
12784
|
+
*
|
|
12785
|
+
* - System-assigned: Uses the DEFAULT_IDENTITY_CLIENT_ID environment variable
|
|
12786
|
+
* - User-assigned: Only supports client ID-based identification (not object ID or resource ID)
|
|
12787
|
+
*
|
|
12788
|
+
* The request uses the 2017-09-01 API version and includes the required secret header
|
|
12789
|
+
* for authentication with the MSI endpoint.
|
|
12790
|
+
*
|
|
12791
|
+
* @param resource - The target resource/scope for which to request an access token (e.g., "https://graph.microsoft.com/.default")
|
|
12792
|
+
* @param managedIdentityId - The managed identity configuration specifying whether to use system-assigned or user-assigned identity
|
|
12793
|
+
*
|
|
12794
|
+
* @returns A configured ManagedIdentityRequestParameters object ready for network execution
|
|
12795
|
+
*
|
|
12796
|
+
* @throws Error if an unsupported managed identity ID type is specified (only client ID is supported for user-assigned)
|
|
12797
|
+
*/
|
|
12387
12798
|
createRequest(resource, managedIdentityId) {
|
|
12388
12799
|
const request = new ManagedIdentityRequestParameters(HttpMethod.GET, this.msiEndpoint);
|
|
12389
12800
|
request.headers[ManagedIdentityHeaders.METADATA_HEADER_NAME] = "true";
|