@azure/msal-node 3.8.0 → 3.8.2
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.d.ts +29 -2
- package/dist/network/HttpClient.d.ts.map +1 -1
- package/dist/network/HttpClient.mjs +296 -250
- package/dist/network/HttpClient.mjs.map +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 +1155 -699
- 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/network/HttpClient.d.ts +29 -2
- package/lib/types/network/HttpClient.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/network/HttpClient.ts +399 -314
- 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.2 2025-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
3636
3955
|
|
|
3637
3956
|
/*
|
|
3638
3957
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -3728,61 +4047,21 @@ function buildAuthOptions(authOptions) {
|
|
|
3728
4047
|
* Returns true if config has protocolMode set to ProtocolMode.OIDC, false otherwise
|
|
3729
4048
|
* @param ClientConfiguration
|
|
3730
4049
|
*/
|
|
3731
|
-
function isOidcProtocolMode(config) {
|
|
3732
|
-
return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
|
|
3733
|
-
}
|
|
3734
|
-
|
|
3735
|
-
/*! @azure/msal-common v15.13.0 2025-09-24 */
|
|
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
|
-
|
|
3747
|
-
/*
|
|
3748
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3749
|
-
* Licensed under the MIT License.
|
|
3750
|
-
*/
|
|
3751
|
-
/**
|
|
3752
|
-
* Function to build a client info object from server clientInfo string
|
|
3753
|
-
* @param rawClientInfo
|
|
3754
|
-
* @param crypto
|
|
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
|
-
};
|
|
4050
|
+
function isOidcProtocolMode(config) {
|
|
4051
|
+
return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
|
|
3783
4052
|
}
|
|
3784
4053
|
|
|
3785
|
-
/*! @azure/msal-common v15.13.
|
|
4054
|
+
/*! @azure/msal-common v15.13.1 2025-11-11 */
|
|
4055
|
+
/*
|
|
4056
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4057
|
+
* Licensed under the MIT License.
|
|
4058
|
+
*/
|
|
4059
|
+
const CcsCredentialType = {
|
|
4060
|
+
HOME_ACCOUNT_ID: "home_account_id",
|
|
4061
|
+
UPN: "UPN",
|
|
4062
|
+
};
|
|
4063
|
+
|
|
4064
|
+
/*! @azure/msal-common v15.13.1 2025-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
5806
6070
|
|
|
5807
6071
|
/*
|
|
5808
6072
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5945,255 +6209,12 @@ class BaseClient {
|
|
|
5945
6209
|
addExtraQueryParameters(parameters, request.tokenQueryParameters);
|
|
5946
6210
|
}
|
|
5947
6211
|
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;
|
|
6124
|
-
}
|
|
6125
|
-
/**
|
|
6126
|
-
* Generate HomeAccountId from server response
|
|
6127
|
-
* @param serverClientInfo
|
|
6128
|
-
* @param authType
|
|
6129
|
-
*/
|
|
6130
|
-
static generateHomeAccountId(serverClientInfo, authType, logger, cryptoObj, idTokenClaims) {
|
|
6131
|
-
// since ADFS/DSTS do not have tid and does not set client_info
|
|
6132
|
-
if (!(authType === AuthorityType.Adfs ||
|
|
6133
|
-
authType === AuthorityType.Dsts)) {
|
|
6134
|
-
// for cases where there is clientInfo
|
|
6135
|
-
if (serverClientInfo) {
|
|
6136
|
-
try {
|
|
6137
|
-
const clientInfo = buildClientInfo(serverClientInfo, cryptoObj.base64Decode);
|
|
6138
|
-
if (clientInfo.uid && clientInfo.utid) {
|
|
6139
|
-
return `${clientInfo.uid}.${clientInfo.utid}`;
|
|
6140
|
-
}
|
|
6141
|
-
}
|
|
6142
|
-
catch (e) { }
|
|
6143
|
-
}
|
|
6144
|
-
logger.warning("No client info in response");
|
|
6145
|
-
}
|
|
6146
|
-
// default to "sub" claim
|
|
6147
|
-
return idTokenClaims?.sub || "";
|
|
6148
|
-
}
|
|
6149
|
-
/**
|
|
6150
|
-
* Validates an entity: checks for all expected params
|
|
6151
|
-
* @param entity
|
|
6152
|
-
*/
|
|
6153
|
-
static isAccountEntity(entity) {
|
|
6154
|
-
if (!entity) {
|
|
6155
|
-
return false;
|
|
6156
|
-
}
|
|
6157
|
-
return (entity.hasOwnProperty("homeAccountId") &&
|
|
6158
|
-
entity.hasOwnProperty("environment") &&
|
|
6159
|
-
entity.hasOwnProperty("realm") &&
|
|
6160
|
-
entity.hasOwnProperty("localAccountId") &&
|
|
6161
|
-
entity.hasOwnProperty("username") &&
|
|
6162
|
-
entity.hasOwnProperty("authorityType"));
|
|
6163
|
-
}
|
|
6164
|
-
/**
|
|
6165
|
-
* Helper function to determine whether 2 accountInfo objects represent the same account
|
|
6166
|
-
* @param accountA
|
|
6167
|
-
* @param accountB
|
|
6168
|
-
* @param compareClaims - If set to true idTokenClaims will also be compared to determine account equality
|
|
6169
|
-
*/
|
|
6170
|
-
static accountInfoIsEqual(accountA, accountB, compareClaims) {
|
|
6171
|
-
if (!accountA || !accountB) {
|
|
6172
|
-
return false;
|
|
6173
|
-
}
|
|
6174
|
-
let claimsMatch = true; // default to true so as to not fail comparison below if compareClaims: false
|
|
6175
|
-
if (compareClaims) {
|
|
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;
|
|
6184
|
-
}
|
|
6185
|
-
return (accountA.homeAccountId === accountB.homeAccountId &&
|
|
6186
|
-
accountA.localAccountId === accountB.localAccountId &&
|
|
6187
|
-
accountA.username === accountB.username &&
|
|
6188
|
-
accountA.tenantId === accountB.tenantId &&
|
|
6189
|
-
accountA.loginHint === accountB.loginHint &&
|
|
6190
|
-
accountA.environment === accountB.environment &&
|
|
6191
|
-
accountA.nativeAccountId === accountB.nativeAccountId &&
|
|
6192
|
-
claimsMatch);
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
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-11-11 */
|
|
7537
7558
|
|
|
7538
7559
|
/*
|
|
7539
7560
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8170,6 +8191,10 @@ class NetworkUtils {
|
|
|
8170
8191
|
}
|
|
8171
8192
|
}
|
|
8172
8193
|
|
|
8194
|
+
/* eslint-disable header/header */
|
|
8195
|
+
const name = "@azure/msal-node";
|
|
8196
|
+
const version = "3.8.2";
|
|
8197
|
+
|
|
8173
8198
|
/*
|
|
8174
8199
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8175
8200
|
* Licensed under the MIT License.
|
|
@@ -8178,9 +8203,296 @@ class NetworkUtils {
|
|
|
8178
8203
|
* This class implements the API for network requests.
|
|
8179
8204
|
*/
|
|
8180
8205
|
class HttpClient {
|
|
8181
|
-
constructor(proxyUrl, customAgentOptions) {
|
|
8206
|
+
constructor(proxyUrl, customAgentOptions, loggerOptions) {
|
|
8207
|
+
this.networkRequestViaProxy = (httpMethod, destinationUrlString, options, timeout) => {
|
|
8208
|
+
const destinationUrl = new URL(destinationUrlString);
|
|
8209
|
+
const proxyUrl = new URL(this.proxyUrl);
|
|
8210
|
+
// "method: connect" must be used to establish a connection to the proxy
|
|
8211
|
+
const headers = options?.headers || {};
|
|
8212
|
+
const tunnelRequestOptions = {
|
|
8213
|
+
host: proxyUrl.hostname,
|
|
8214
|
+
port: proxyUrl.port,
|
|
8215
|
+
method: "CONNECT",
|
|
8216
|
+
path: destinationUrl.hostname,
|
|
8217
|
+
headers: headers,
|
|
8218
|
+
};
|
|
8219
|
+
if (this.customAgentOptions &&
|
|
8220
|
+
Object.keys(this.customAgentOptions).length) {
|
|
8221
|
+
tunnelRequestOptions.agent = new http.Agent(this.customAgentOptions);
|
|
8222
|
+
}
|
|
8223
|
+
// compose a request string for the socket
|
|
8224
|
+
let postRequestStringContent = "";
|
|
8225
|
+
if (httpMethod === HttpMethod.POST) {
|
|
8226
|
+
const body = options?.body || "";
|
|
8227
|
+
postRequestStringContent =
|
|
8228
|
+
"Content-Type: application/x-www-form-urlencoded\r\n" +
|
|
8229
|
+
`Content-Length: ${body.length}\r\n` +
|
|
8230
|
+
`\r\n${body}`;
|
|
8231
|
+
}
|
|
8232
|
+
else {
|
|
8233
|
+
// optional timeout is only for get requests (regionDiscovery, for example)
|
|
8234
|
+
if (timeout) {
|
|
8235
|
+
tunnelRequestOptions.timeout = timeout;
|
|
8236
|
+
}
|
|
8237
|
+
}
|
|
8238
|
+
const outgoingRequestString = `${httpMethod.toUpperCase()} ${destinationUrl.href} HTTP/1.1\r\n` +
|
|
8239
|
+
`Host: ${destinationUrl.host}\r\n` +
|
|
8240
|
+
"Connection: close\r\n" +
|
|
8241
|
+
postRequestStringContent +
|
|
8242
|
+
"\r\n";
|
|
8243
|
+
return new Promise((resolve, reject) => {
|
|
8244
|
+
const request = http.request(tunnelRequestOptions);
|
|
8245
|
+
if (timeout) {
|
|
8246
|
+
request.on("timeout", () => {
|
|
8247
|
+
this.logUrlWithPiiAwareness(`Request timeout after ${timeout}ms for URL`, destinationUrlString);
|
|
8248
|
+
request.destroy();
|
|
8249
|
+
reject(new Error(`Request time out after ${timeout}ms`));
|
|
8250
|
+
});
|
|
8251
|
+
}
|
|
8252
|
+
request.end();
|
|
8253
|
+
// establish connection to the proxy
|
|
8254
|
+
request.on("connect", (response, socket) => {
|
|
8255
|
+
const proxyStatusCode = response?.statusCode || ProxyStatus.SERVER_ERROR;
|
|
8256
|
+
if (proxyStatusCode < ProxyStatus.SUCCESS_RANGE_START ||
|
|
8257
|
+
proxyStatusCode > ProxyStatus.SUCCESS_RANGE_END) {
|
|
8258
|
+
request.destroy();
|
|
8259
|
+
socket.destroy();
|
|
8260
|
+
reject(new Error(`Error connecting to proxy. Http status code: ${response.statusCode}. Http status message: ${response?.statusMessage || "Unknown"}`));
|
|
8261
|
+
}
|
|
8262
|
+
// make a request over an HTTP tunnel
|
|
8263
|
+
socket.write(outgoingRequestString);
|
|
8264
|
+
const data = [];
|
|
8265
|
+
socket.on("data", (chunk) => {
|
|
8266
|
+
data.push(chunk);
|
|
8267
|
+
});
|
|
8268
|
+
socket.on("end", () => {
|
|
8269
|
+
// combine all received buffer streams into one buffer, and then into a string
|
|
8270
|
+
const dataString = Buffer.concat([...data]).toString();
|
|
8271
|
+
// separate each line into it's own entry in an arry
|
|
8272
|
+
const dataStringArray = dataString.split("\r\n");
|
|
8273
|
+
// the first entry will contain the statusCode and statusMessage
|
|
8274
|
+
const httpStatusCode = parseInt(dataStringArray[0].split(" ")[1]);
|
|
8275
|
+
// remove "HTTP/1.1" and the status code to get the status message
|
|
8276
|
+
const statusMessage = dataStringArray[0]
|
|
8277
|
+
.split(" ")
|
|
8278
|
+
.slice(2)
|
|
8279
|
+
.join(" ");
|
|
8280
|
+
// the last entry will contain the body
|
|
8281
|
+
const body = dataStringArray[dataStringArray.length - 1];
|
|
8282
|
+
// everything in between the first and last entries are the headers
|
|
8283
|
+
const headersArray = dataStringArray.slice(1, dataStringArray.length - 2);
|
|
8284
|
+
// build an object out of all the headers
|
|
8285
|
+
const entries = new Map();
|
|
8286
|
+
headersArray.forEach((header) => {
|
|
8287
|
+
/**
|
|
8288
|
+
* the header might look like "Content-Length: 1531", but that is just a string
|
|
8289
|
+
* it needs to be converted to a key/value pair
|
|
8290
|
+
* split the string at the first instance of ":"
|
|
8291
|
+
* there may be more than one ":" if the value of the header is supposed to be a JSON object
|
|
8292
|
+
*/
|
|
8293
|
+
const headerKeyValue = header.split(new RegExp(/:\s(.*)/s));
|
|
8294
|
+
const headerKey = headerKeyValue[0];
|
|
8295
|
+
let headerValue = headerKeyValue[1];
|
|
8296
|
+
// check if the value of the header is supposed to be a JSON object
|
|
8297
|
+
try {
|
|
8298
|
+
const object = JSON.parse(headerValue);
|
|
8299
|
+
// if it is, then convert it from a string to a JSON object
|
|
8300
|
+
if (object && typeof object === "object") {
|
|
8301
|
+
headerValue = object;
|
|
8302
|
+
}
|
|
8303
|
+
}
|
|
8304
|
+
catch (e) {
|
|
8305
|
+
// otherwise, leave it as a string
|
|
8306
|
+
}
|
|
8307
|
+
entries.set(headerKey, headerValue);
|
|
8308
|
+
});
|
|
8309
|
+
const headers = Object.fromEntries(entries);
|
|
8310
|
+
const parsedHeaders = headers;
|
|
8311
|
+
const networkResponse = NetworkUtils.getNetworkResponse(parsedHeaders, this.parseBody(httpStatusCode, statusMessage, parsedHeaders, body), httpStatusCode);
|
|
8312
|
+
if (this.shouldDestroyRequest(httpStatusCode, networkResponse)) {
|
|
8313
|
+
request.destroy();
|
|
8314
|
+
}
|
|
8315
|
+
resolve(networkResponse);
|
|
8316
|
+
});
|
|
8317
|
+
socket.on("error", (chunk) => {
|
|
8318
|
+
request.destroy();
|
|
8319
|
+
socket.destroy();
|
|
8320
|
+
reject(new Error(chunk.toString()));
|
|
8321
|
+
});
|
|
8322
|
+
});
|
|
8323
|
+
request.on("error", (chunk) => {
|
|
8324
|
+
this.logger.error(`HttpClient - Proxy request error: ${chunk.toString()}`, "");
|
|
8325
|
+
this.logUrlWithPiiAwareness("Destination URL", destinationUrlString);
|
|
8326
|
+
this.logUrlWithPiiAwareness("Proxy URL", this.proxyUrl);
|
|
8327
|
+
this.logger.error(`HttpClient - Method: ${httpMethod}`, "");
|
|
8328
|
+
this.logger.errorPii(`HttpClient - Headers: ${JSON.stringify(headers)}`, "");
|
|
8329
|
+
request.destroy();
|
|
8330
|
+
reject(new Error(chunk.toString()));
|
|
8331
|
+
});
|
|
8332
|
+
});
|
|
8333
|
+
};
|
|
8334
|
+
this.networkRequestViaHttps = (httpMethod, urlString, options, timeout) => {
|
|
8335
|
+
const isPostRequest = httpMethod === HttpMethod.POST;
|
|
8336
|
+
const body = options?.body || "";
|
|
8337
|
+
const url = new URL(urlString);
|
|
8338
|
+
const headers = options?.headers || {};
|
|
8339
|
+
const customOptions = {
|
|
8340
|
+
method: httpMethod,
|
|
8341
|
+
headers: headers,
|
|
8342
|
+
...NetworkUtils.urlToHttpOptions(url),
|
|
8343
|
+
};
|
|
8344
|
+
if (this.customAgentOptions &&
|
|
8345
|
+
Object.keys(this.customAgentOptions).length) {
|
|
8346
|
+
customOptions.agent = new https.Agent(this.customAgentOptions);
|
|
8347
|
+
}
|
|
8348
|
+
if (isPostRequest) {
|
|
8349
|
+
// needed for post request to work
|
|
8350
|
+
customOptions.headers = {
|
|
8351
|
+
...customOptions.headers,
|
|
8352
|
+
"Content-Length": body.length,
|
|
8353
|
+
};
|
|
8354
|
+
}
|
|
8355
|
+
else {
|
|
8356
|
+
// optional timeout is only for get requests (regionDiscovery, for example)
|
|
8357
|
+
if (timeout) {
|
|
8358
|
+
customOptions.timeout = timeout;
|
|
8359
|
+
}
|
|
8360
|
+
}
|
|
8361
|
+
return new Promise((resolve, reject) => {
|
|
8362
|
+
let request;
|
|
8363
|
+
// managed identity sources use http instead of https
|
|
8364
|
+
if (customOptions.protocol === "http:") {
|
|
8365
|
+
request = http.request(customOptions);
|
|
8366
|
+
}
|
|
8367
|
+
else {
|
|
8368
|
+
request = https.request(customOptions);
|
|
8369
|
+
}
|
|
8370
|
+
if (isPostRequest) {
|
|
8371
|
+
request.write(body);
|
|
8372
|
+
}
|
|
8373
|
+
if (timeout) {
|
|
8374
|
+
request.on("timeout", () => {
|
|
8375
|
+
this.logUrlWithPiiAwareness(`HTTPS request timeout after ${timeout}ms for URL`, urlString);
|
|
8376
|
+
request.destroy();
|
|
8377
|
+
reject(new Error(`Request time out after ${timeout}ms`));
|
|
8378
|
+
});
|
|
8379
|
+
}
|
|
8380
|
+
request.end();
|
|
8381
|
+
request.on("response", (response) => {
|
|
8382
|
+
const headers = response.headers;
|
|
8383
|
+
const statusCode = response.statusCode;
|
|
8384
|
+
const statusMessage = response.statusMessage;
|
|
8385
|
+
const data = [];
|
|
8386
|
+
response.on("data", (chunk) => {
|
|
8387
|
+
data.push(chunk);
|
|
8388
|
+
});
|
|
8389
|
+
response.on("end", () => {
|
|
8390
|
+
// combine all received buffer streams into one buffer, and then into a string
|
|
8391
|
+
const body = Buffer.concat([...data]).toString();
|
|
8392
|
+
const parsedHeaders = headers;
|
|
8393
|
+
const networkResponse = NetworkUtils.getNetworkResponse(parsedHeaders, this.parseBody(statusCode, statusMessage, parsedHeaders, body), statusCode);
|
|
8394
|
+
if (this.shouldDestroyRequest(statusCode, networkResponse)) {
|
|
8395
|
+
request.destroy();
|
|
8396
|
+
}
|
|
8397
|
+
resolve(networkResponse);
|
|
8398
|
+
});
|
|
8399
|
+
});
|
|
8400
|
+
request.on("error", (chunk) => {
|
|
8401
|
+
this.logger.error(`HttpClient - HTTPS request error: ${chunk.toString()}`, "");
|
|
8402
|
+
this.logUrlWithPiiAwareness("URL", urlString);
|
|
8403
|
+
this.logger.error(`HttpClient - Method: ${httpMethod}`, "");
|
|
8404
|
+
this.logger.errorPii(`HttpClient - Headers: ${JSON.stringify(headers)}`, "");
|
|
8405
|
+
request.destroy();
|
|
8406
|
+
reject(new Error(chunk.toString()));
|
|
8407
|
+
});
|
|
8408
|
+
});
|
|
8409
|
+
};
|
|
8410
|
+
/**
|
|
8411
|
+
* Check if extra parsing is needed on the repsonse from the server
|
|
8412
|
+
* @param statusCode {number} the status code of the response from the server
|
|
8413
|
+
* @param statusMessage {string | undefined} the status message of the response from the server
|
|
8414
|
+
* @param headers {Record<string, string>} the headers of the response from the server
|
|
8415
|
+
* @param body {string} the body from the response of the server
|
|
8416
|
+
* @returns {Object} JSON parsed body or error object
|
|
8417
|
+
*/
|
|
8418
|
+
this.parseBody = (statusCode, statusMessage, headers, body) => {
|
|
8419
|
+
/*
|
|
8420
|
+
* Informational responses (100 – 199)
|
|
8421
|
+
* Successful responses (200 – 299)
|
|
8422
|
+
* Redirection messages (300 – 399)
|
|
8423
|
+
* Client error responses (400 – 499)
|
|
8424
|
+
* Server error responses (500 – 599)
|
|
8425
|
+
*/
|
|
8426
|
+
let parsedBody;
|
|
8427
|
+
try {
|
|
8428
|
+
parsedBody = JSON.parse(body);
|
|
8429
|
+
}
|
|
8430
|
+
catch (error) {
|
|
8431
|
+
let errorType;
|
|
8432
|
+
let errorDescriptionHelper;
|
|
8433
|
+
if (statusCode >= HttpStatus.CLIENT_ERROR_RANGE_START &&
|
|
8434
|
+
statusCode <= HttpStatus.CLIENT_ERROR_RANGE_END) {
|
|
8435
|
+
errorType = "client_error";
|
|
8436
|
+
errorDescriptionHelper = "A client";
|
|
8437
|
+
}
|
|
8438
|
+
else if (statusCode >= HttpStatus.SERVER_ERROR_RANGE_START &&
|
|
8439
|
+
statusCode <= HttpStatus.SERVER_ERROR_RANGE_END) {
|
|
8440
|
+
errorType = "server_error";
|
|
8441
|
+
errorDescriptionHelper = "A server";
|
|
8442
|
+
}
|
|
8443
|
+
else {
|
|
8444
|
+
errorType = "unknown_error";
|
|
8445
|
+
errorDescriptionHelper = "An unknown";
|
|
8446
|
+
}
|
|
8447
|
+
parsedBody = {
|
|
8448
|
+
error: errorType,
|
|
8449
|
+
error_description: `${errorDescriptionHelper} error occured.\nHttp status code: ${statusCode}\nHttp status message: ${statusMessage || "Unknown"}\nHeaders: ${JSON.stringify(headers)}`,
|
|
8450
|
+
};
|
|
8451
|
+
}
|
|
8452
|
+
return parsedBody;
|
|
8453
|
+
};
|
|
8454
|
+
/**
|
|
8455
|
+
* Helper function to log a formatted message containing URLs, with PII-aware sanitization
|
|
8456
|
+
* @param label {string} the label for the log message
|
|
8457
|
+
* @param urlString {string} the URL to log
|
|
8458
|
+
*/
|
|
8459
|
+
this.logUrlWithPiiAwareness = (label, urlString) => {
|
|
8460
|
+
if (this.isPiiEnabled) {
|
|
8461
|
+
this.logger.errorPii(`HttpClient - ${label}: ${urlString}`, "");
|
|
8462
|
+
}
|
|
8463
|
+
else {
|
|
8464
|
+
let urlHelper;
|
|
8465
|
+
try {
|
|
8466
|
+
const url = new URL(urlString);
|
|
8467
|
+
urlHelper = `${url.protocol}//${url.host}${url.pathname}`;
|
|
8468
|
+
}
|
|
8469
|
+
catch {
|
|
8470
|
+
urlHelper = urlString.split("?")[0] || "unknown";
|
|
8471
|
+
}
|
|
8472
|
+
this.logger.error(`HttpClient - ${label}: ${urlHelper} [Enable PII logging to see additional details]`, "");
|
|
8473
|
+
}
|
|
8474
|
+
};
|
|
8475
|
+
/**
|
|
8476
|
+
* Helper function to determine if a request should be destroyed based on status code and response body.
|
|
8477
|
+
* Checks if the response is an error and not part of the device code flow (authorization_pending).
|
|
8478
|
+
* @param statusCode {number} the status code of the response
|
|
8479
|
+
* @param networkResponse {NetworkResponse<T>} the network response object
|
|
8480
|
+
* @returns {boolean} true if the request should be destroyed, false otherwise
|
|
8481
|
+
*/
|
|
8482
|
+
this.shouldDestroyRequest = (statusCode, networkResponse) => {
|
|
8483
|
+
return ((statusCode < HttpStatus.SUCCESS_RANGE_START ||
|
|
8484
|
+
statusCode > HttpStatus.SUCCESS_RANGE_END) &&
|
|
8485
|
+
// do not destroy the request for the device code flow
|
|
8486
|
+
!(networkResponse.body &&
|
|
8487
|
+
typeof networkResponse.body === "object" &&
|
|
8488
|
+
"error" in networkResponse.body &&
|
|
8489
|
+
networkResponse.body.error ===
|
|
8490
|
+
Constants.AUTHORIZATION_PENDING));
|
|
8491
|
+
};
|
|
8182
8492
|
this.proxyUrl = proxyUrl || "";
|
|
8183
8493
|
this.customAgentOptions = customAgentOptions || {};
|
|
8494
|
+
this.logger = new Logger(loggerOptions || {}, name, version);
|
|
8495
|
+
this.isPiiEnabled = this.logger.isPiiLoggingEnabled();
|
|
8184
8496
|
}
|
|
8185
8497
|
/**
|
|
8186
8498
|
* Http Get request
|
|
@@ -8189,10 +8501,10 @@ class HttpClient {
|
|
|
8189
8501
|
*/
|
|
8190
8502
|
async sendGetRequestAsync(url, options, timeout) {
|
|
8191
8503
|
if (this.proxyUrl) {
|
|
8192
|
-
return networkRequestViaProxy(
|
|
8504
|
+
return this.networkRequestViaProxy(HttpMethod.GET, url, options, timeout);
|
|
8193
8505
|
}
|
|
8194
8506
|
else {
|
|
8195
|
-
return networkRequestViaHttps(
|
|
8507
|
+
return this.networkRequestViaHttps(HttpMethod.GET, url, options, timeout);
|
|
8196
8508
|
}
|
|
8197
8509
|
}
|
|
8198
8510
|
/**
|
|
@@ -8202,255 +8514,13 @@ class HttpClient {
|
|
|
8202
8514
|
*/
|
|
8203
8515
|
async sendPostRequestAsync(url, options) {
|
|
8204
8516
|
if (this.proxyUrl) {
|
|
8205
|
-
return networkRequestViaProxy(
|
|
8206
|
-
}
|
|
8207
|
-
else {
|
|
8208
|
-
return networkRequestViaHttps(url, HttpMethod.POST, options, this.customAgentOptions);
|
|
8209
|
-
}
|
|
8210
|
-
}
|
|
8211
|
-
}
|
|
8212
|
-
const networkRequestViaProxy = (destinationUrlString, proxyUrlString, httpMethod, options, agentOptions, timeout) => {
|
|
8213
|
-
const destinationUrl = new URL(destinationUrlString);
|
|
8214
|
-
const proxyUrl = new URL(proxyUrlString);
|
|
8215
|
-
// "method: connect" must be used to establish a connection to the proxy
|
|
8216
|
-
const headers = options?.headers || {};
|
|
8217
|
-
const tunnelRequestOptions = {
|
|
8218
|
-
host: proxyUrl.hostname,
|
|
8219
|
-
port: proxyUrl.port,
|
|
8220
|
-
method: "CONNECT",
|
|
8221
|
-
path: destinationUrl.hostname,
|
|
8222
|
-
headers: headers,
|
|
8223
|
-
};
|
|
8224
|
-
if (agentOptions && Object.keys(agentOptions).length) {
|
|
8225
|
-
tunnelRequestOptions.agent = new http.Agent(agentOptions);
|
|
8226
|
-
}
|
|
8227
|
-
// compose a request string for the socket
|
|
8228
|
-
let postRequestStringContent = "";
|
|
8229
|
-
if (httpMethod === HttpMethod.POST) {
|
|
8230
|
-
const body = options?.body || "";
|
|
8231
|
-
postRequestStringContent =
|
|
8232
|
-
"Content-Type: application/x-www-form-urlencoded\r\n" +
|
|
8233
|
-
`Content-Length: ${body.length}\r\n` +
|
|
8234
|
-
`\r\n${body}`;
|
|
8235
|
-
}
|
|
8236
|
-
else {
|
|
8237
|
-
// optional timeout is only for get requests (regionDiscovery, for example)
|
|
8238
|
-
if (timeout) {
|
|
8239
|
-
tunnelRequestOptions.timeout = timeout;
|
|
8240
|
-
}
|
|
8241
|
-
}
|
|
8242
|
-
const outgoingRequestString = `${httpMethod.toUpperCase()} ${destinationUrl.href} HTTP/1.1\r\n` +
|
|
8243
|
-
`Host: ${destinationUrl.host}\r\n` +
|
|
8244
|
-
"Connection: close\r\n" +
|
|
8245
|
-
postRequestStringContent +
|
|
8246
|
-
"\r\n";
|
|
8247
|
-
return new Promise((resolve, reject) => {
|
|
8248
|
-
const request = http.request(tunnelRequestOptions);
|
|
8249
|
-
if (timeout) {
|
|
8250
|
-
request.on("timeout", () => {
|
|
8251
|
-
request.destroy();
|
|
8252
|
-
reject(new Error("Request time out"));
|
|
8253
|
-
});
|
|
8254
|
-
}
|
|
8255
|
-
request.end();
|
|
8256
|
-
// establish connection to the proxy
|
|
8257
|
-
request.on("connect", (response, socket) => {
|
|
8258
|
-
const proxyStatusCode = response?.statusCode || ProxyStatus.SERVER_ERROR;
|
|
8259
|
-
if (proxyStatusCode < ProxyStatus.SUCCESS_RANGE_START ||
|
|
8260
|
-
proxyStatusCode > ProxyStatus.SUCCESS_RANGE_END) {
|
|
8261
|
-
request.destroy();
|
|
8262
|
-
socket.destroy();
|
|
8263
|
-
reject(new Error(`Error connecting to proxy. Http status code: ${response.statusCode}. Http status message: ${response?.statusMessage || "Unknown"}`));
|
|
8264
|
-
}
|
|
8265
|
-
// make a request over an HTTP tunnel
|
|
8266
|
-
socket.write(outgoingRequestString);
|
|
8267
|
-
const data = [];
|
|
8268
|
-
socket.on("data", (chunk) => {
|
|
8269
|
-
data.push(chunk);
|
|
8270
|
-
});
|
|
8271
|
-
socket.on("end", () => {
|
|
8272
|
-
// combine all received buffer streams into one buffer, and then into a string
|
|
8273
|
-
const dataString = Buffer.concat([...data]).toString();
|
|
8274
|
-
// separate each line into it's own entry in an arry
|
|
8275
|
-
const dataStringArray = dataString.split("\r\n");
|
|
8276
|
-
// the first entry will contain the statusCode and statusMessage
|
|
8277
|
-
const httpStatusCode = parseInt(dataStringArray[0].split(" ")[1]);
|
|
8278
|
-
// remove "HTTP/1.1" and the status code to get the status message
|
|
8279
|
-
const statusMessage = dataStringArray[0]
|
|
8280
|
-
.split(" ")
|
|
8281
|
-
.slice(2)
|
|
8282
|
-
.join(" ");
|
|
8283
|
-
// the last entry will contain the body
|
|
8284
|
-
const body = dataStringArray[dataStringArray.length - 1];
|
|
8285
|
-
// everything in between the first and last entries are the headers
|
|
8286
|
-
const headersArray = dataStringArray.slice(1, dataStringArray.length - 2);
|
|
8287
|
-
// build an object out of all the headers
|
|
8288
|
-
const entries = new Map();
|
|
8289
|
-
headersArray.forEach((header) => {
|
|
8290
|
-
/**
|
|
8291
|
-
* the header might look like "Content-Length: 1531", but that is just a string
|
|
8292
|
-
* it needs to be converted to a key/value pair
|
|
8293
|
-
* split the string at the first instance of ":"
|
|
8294
|
-
* there may be more than one ":" if the value of the header is supposed to be a JSON object
|
|
8295
|
-
*/
|
|
8296
|
-
const headerKeyValue = header.split(new RegExp(/:\s(.*)/s));
|
|
8297
|
-
const headerKey = headerKeyValue[0];
|
|
8298
|
-
let headerValue = headerKeyValue[1];
|
|
8299
|
-
// check if the value of the header is supposed to be a JSON object
|
|
8300
|
-
try {
|
|
8301
|
-
const object = JSON.parse(headerValue);
|
|
8302
|
-
// if it is, then convert it from a string to a JSON object
|
|
8303
|
-
if (object && typeof object === "object") {
|
|
8304
|
-
headerValue = object;
|
|
8305
|
-
}
|
|
8306
|
-
}
|
|
8307
|
-
catch (e) {
|
|
8308
|
-
// otherwise, leave it as a string
|
|
8309
|
-
}
|
|
8310
|
-
entries.set(headerKey, headerValue);
|
|
8311
|
-
});
|
|
8312
|
-
const headers = Object.fromEntries(entries);
|
|
8313
|
-
const parsedHeaders = headers;
|
|
8314
|
-
const networkResponse = NetworkUtils.getNetworkResponse(parsedHeaders, parseBody(httpStatusCode, statusMessage, parsedHeaders, body), httpStatusCode);
|
|
8315
|
-
if ((httpStatusCode < HttpStatus.SUCCESS_RANGE_START ||
|
|
8316
|
-
httpStatusCode > HttpStatus.SUCCESS_RANGE_END) &&
|
|
8317
|
-
// do not destroy the request for the device code flow
|
|
8318
|
-
networkResponse.body["error"] !==
|
|
8319
|
-
Constants.AUTHORIZATION_PENDING) {
|
|
8320
|
-
request.destroy();
|
|
8321
|
-
}
|
|
8322
|
-
resolve(networkResponse);
|
|
8323
|
-
});
|
|
8324
|
-
socket.on("error", (chunk) => {
|
|
8325
|
-
request.destroy();
|
|
8326
|
-
socket.destroy();
|
|
8327
|
-
reject(new Error(chunk.toString()));
|
|
8328
|
-
});
|
|
8329
|
-
});
|
|
8330
|
-
request.on("error", (chunk) => {
|
|
8331
|
-
request.destroy();
|
|
8332
|
-
reject(new Error(chunk.toString()));
|
|
8333
|
-
});
|
|
8334
|
-
});
|
|
8335
|
-
};
|
|
8336
|
-
const networkRequestViaHttps = (urlString, httpMethod, options, agentOptions, timeout) => {
|
|
8337
|
-
const isPostRequest = httpMethod === HttpMethod.POST;
|
|
8338
|
-
const body = options?.body || "";
|
|
8339
|
-
const url = new URL(urlString);
|
|
8340
|
-
const headers = options?.headers || {};
|
|
8341
|
-
const customOptions = {
|
|
8342
|
-
method: httpMethod,
|
|
8343
|
-
headers: headers,
|
|
8344
|
-
...NetworkUtils.urlToHttpOptions(url),
|
|
8345
|
-
};
|
|
8346
|
-
if (agentOptions && Object.keys(agentOptions).length) {
|
|
8347
|
-
customOptions.agent = new https.Agent(agentOptions);
|
|
8348
|
-
}
|
|
8349
|
-
if (isPostRequest) {
|
|
8350
|
-
// needed for post request to work
|
|
8351
|
-
customOptions.headers = {
|
|
8352
|
-
...customOptions.headers,
|
|
8353
|
-
"Content-Length": body.length,
|
|
8354
|
-
};
|
|
8355
|
-
}
|
|
8356
|
-
else {
|
|
8357
|
-
// optional timeout is only for get requests (regionDiscovery, for example)
|
|
8358
|
-
if (timeout) {
|
|
8359
|
-
customOptions.timeout = timeout;
|
|
8360
|
-
}
|
|
8361
|
-
}
|
|
8362
|
-
return new Promise((resolve, reject) => {
|
|
8363
|
-
let request;
|
|
8364
|
-
// managed identity sources use http instead of https
|
|
8365
|
-
if (customOptions.protocol === "http:") {
|
|
8366
|
-
request = http.request(customOptions);
|
|
8367
|
-
}
|
|
8368
|
-
else {
|
|
8369
|
-
request = https.request(customOptions);
|
|
8370
|
-
}
|
|
8371
|
-
if (isPostRequest) {
|
|
8372
|
-
request.write(body);
|
|
8373
|
-
}
|
|
8374
|
-
if (timeout) {
|
|
8375
|
-
request.on("timeout", () => {
|
|
8376
|
-
request.destroy();
|
|
8377
|
-
reject(new Error("Request time out"));
|
|
8378
|
-
});
|
|
8379
|
-
}
|
|
8380
|
-
request.end();
|
|
8381
|
-
request.on("response", (response) => {
|
|
8382
|
-
const headers = response.headers;
|
|
8383
|
-
const statusCode = response.statusCode;
|
|
8384
|
-
const statusMessage = response.statusMessage;
|
|
8385
|
-
const data = [];
|
|
8386
|
-
response.on("data", (chunk) => {
|
|
8387
|
-
data.push(chunk);
|
|
8388
|
-
});
|
|
8389
|
-
response.on("end", () => {
|
|
8390
|
-
// combine all received buffer streams into one buffer, and then into a string
|
|
8391
|
-
const body = Buffer.concat([...data]).toString();
|
|
8392
|
-
const parsedHeaders = headers;
|
|
8393
|
-
const networkResponse = NetworkUtils.getNetworkResponse(parsedHeaders, parseBody(statusCode, statusMessage, parsedHeaders, body), statusCode);
|
|
8394
|
-
if ((statusCode < HttpStatus.SUCCESS_RANGE_START ||
|
|
8395
|
-
statusCode > HttpStatus.SUCCESS_RANGE_END) &&
|
|
8396
|
-
// do not destroy the request for the device code flow
|
|
8397
|
-
networkResponse.body["error"] !==
|
|
8398
|
-
Constants.AUTHORIZATION_PENDING) {
|
|
8399
|
-
request.destroy();
|
|
8400
|
-
}
|
|
8401
|
-
resolve(networkResponse);
|
|
8402
|
-
});
|
|
8403
|
-
});
|
|
8404
|
-
request.on("error", (chunk) => {
|
|
8405
|
-
request.destroy();
|
|
8406
|
-
reject(new Error(chunk.toString()));
|
|
8407
|
-
});
|
|
8408
|
-
});
|
|
8409
|
-
};
|
|
8410
|
-
/**
|
|
8411
|
-
* Check if extra parsing is needed on the repsonse from the server
|
|
8412
|
-
* @param statusCode {number} the status code of the response from the server
|
|
8413
|
-
* @param statusMessage {string | undefined} the status message of the response from the server
|
|
8414
|
-
* @param headers {Record<string, string>} the headers of the response from the server
|
|
8415
|
-
* @param body {string} the body from the response of the server
|
|
8416
|
-
* @returns {Object} JSON parsed body or error object
|
|
8417
|
-
*/
|
|
8418
|
-
const parseBody = (statusCode, statusMessage, headers, body) => {
|
|
8419
|
-
/*
|
|
8420
|
-
* Informational responses (100 – 199)
|
|
8421
|
-
* Successful responses (200 – 299)
|
|
8422
|
-
* Redirection messages (300 – 399)
|
|
8423
|
-
* Client error responses (400 – 499)
|
|
8424
|
-
* Server error responses (500 – 599)
|
|
8425
|
-
*/
|
|
8426
|
-
let parsedBody;
|
|
8427
|
-
try {
|
|
8428
|
-
parsedBody = JSON.parse(body);
|
|
8429
|
-
}
|
|
8430
|
-
catch (error) {
|
|
8431
|
-
let errorType;
|
|
8432
|
-
let errorDescriptionHelper;
|
|
8433
|
-
if (statusCode >= HttpStatus.CLIENT_ERROR_RANGE_START &&
|
|
8434
|
-
statusCode <= HttpStatus.CLIENT_ERROR_RANGE_END) {
|
|
8435
|
-
errorType = "client_error";
|
|
8436
|
-
errorDescriptionHelper = "A client";
|
|
8437
|
-
}
|
|
8438
|
-
else if (statusCode >= HttpStatus.SERVER_ERROR_RANGE_START &&
|
|
8439
|
-
statusCode <= HttpStatus.SERVER_ERROR_RANGE_END) {
|
|
8440
|
-
errorType = "server_error";
|
|
8441
|
-
errorDescriptionHelper = "A server";
|
|
8517
|
+
return this.networkRequestViaProxy(HttpMethod.POST, url, options);
|
|
8442
8518
|
}
|
|
8443
8519
|
else {
|
|
8444
|
-
|
|
8445
|
-
errorDescriptionHelper = "An unknown";
|
|
8520
|
+
return this.networkRequestViaHttps(HttpMethod.POST, url, options);
|
|
8446
8521
|
}
|
|
8447
|
-
parsedBody = {
|
|
8448
|
-
error: errorType,
|
|
8449
|
-
error_description: `${errorDescriptionHelper} error occured.\nHttp status code: ${statusCode}\nHttp status message: ${statusMessage || "Unknown"}\nHeaders: ${JSON.stringify(headers)}`,
|
|
8450
|
-
};
|
|
8451
8522
|
}
|
|
8452
|
-
|
|
8453
|
-
};
|
|
8523
|
+
}
|
|
8454
8524
|
|
|
8455
8525
|
/*
|
|
8456
8526
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -9216,7 +9286,7 @@ class NodeStorage extends CacheManager {
|
|
|
9216
9286
|
* @param account - cache value to be set of type AccountEntity
|
|
9217
9287
|
*/
|
|
9218
9288
|
async setAccount(account) {
|
|
9219
|
-
const accountKey = this.generateAccountKey(
|
|
9289
|
+
const accountKey = this.generateAccountKey(AccountEntity.getAccountInfo(account));
|
|
9220
9290
|
this.setItem(accountKey, account);
|
|
9221
9291
|
}
|
|
9222
9292
|
/**
|
|
@@ -9888,10 +9958,6 @@ class ClientAssertion {
|
|
|
9888
9958
|
}
|
|
9889
9959
|
}
|
|
9890
9960
|
|
|
9891
|
-
/* eslint-disable header/header */
|
|
9892
|
-
const name = "@azure/msal-node";
|
|
9893
|
-
const version = "3.8.0";
|
|
9894
|
-
|
|
9895
9961
|
/*
|
|
9896
9962
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
9897
9963
|
* Licensed under the MIT License.
|
|
@@ -11596,7 +11662,24 @@ const ManagedIdentityUserAssignedIdQueryParameterNames = {
|
|
|
11596
11662
|
MANAGED_IDENTITY_RESOURCE_ID_IMDS: "msi_res_id",
|
|
11597
11663
|
MANAGED_IDENTITY_RESOURCE_ID_NON_IMDS: "mi_res_id",
|
|
11598
11664
|
};
|
|
11665
|
+
/**
|
|
11666
|
+
* Base class for all Managed Identity sources. Provides common functionality for
|
|
11667
|
+
* authenticating with Azure Managed Identity endpoints across different Azure services
|
|
11668
|
+
* including IMDS, App Service, Azure Arc, Service Fabric, Cloud Shell, and Machine Learning.
|
|
11669
|
+
*
|
|
11670
|
+
* This abstract class handles token acquisition, response processing, and network communication
|
|
11671
|
+
* while allowing concrete implementations to define source-specific request creation logic.
|
|
11672
|
+
*/
|
|
11599
11673
|
class BaseManagedIdentitySource {
|
|
11674
|
+
/**
|
|
11675
|
+
* Creates an instance of BaseManagedIdentitySource.
|
|
11676
|
+
*
|
|
11677
|
+
* @param logger - Logger instance for diagnostic information
|
|
11678
|
+
* @param nodeStorage - Storage interface for caching tokens
|
|
11679
|
+
* @param networkClient - Network client for making HTTP requests
|
|
11680
|
+
* @param cryptoProvider - Cryptographic provider for token operations
|
|
11681
|
+
* @param disableInternalRetries - Whether to disable automatic retry logic
|
|
11682
|
+
*/
|
|
11600
11683
|
constructor(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries) {
|
|
11601
11684
|
this.logger = logger;
|
|
11602
11685
|
this.nodeStorage = nodeStorage;
|
|
@@ -11604,6 +11687,18 @@ class BaseManagedIdentitySource {
|
|
|
11604
11687
|
this.cryptoProvider = cryptoProvider;
|
|
11605
11688
|
this.disableInternalRetries = disableInternalRetries;
|
|
11606
11689
|
}
|
|
11690
|
+
/**
|
|
11691
|
+
* Processes the network response and converts it to a standardized server token response.
|
|
11692
|
+
* This async version allows for source-specific response processing logic while maintaining
|
|
11693
|
+
* backward compatibility with the synchronous version.
|
|
11694
|
+
*
|
|
11695
|
+
* @param response - The network response containing the managed identity token
|
|
11696
|
+
* @param _networkClient - Network client used for the request (unused in base implementation)
|
|
11697
|
+
* @param _networkRequest - The original network request parameters (unused in base implementation)
|
|
11698
|
+
* @param _networkRequestOptions - The network request options (unused in base implementation)
|
|
11699
|
+
*
|
|
11700
|
+
* @returns Promise resolving to a standardized server authorization token response
|
|
11701
|
+
*/
|
|
11607
11702
|
async getServerTokenResponseAsync(response,
|
|
11608
11703
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11609
11704
|
_networkClient,
|
|
@@ -11613,6 +11708,15 @@ class BaseManagedIdentitySource {
|
|
|
11613
11708
|
_networkRequestOptions) {
|
|
11614
11709
|
return this.getServerTokenResponse(response);
|
|
11615
11710
|
}
|
|
11711
|
+
/**
|
|
11712
|
+
* Converts a managed identity token response to a standardized server authorization token response.
|
|
11713
|
+
* Handles time format conversion, expiration calculation, and error mapping to ensure
|
|
11714
|
+
* compatibility with the MSAL response handling pipeline.
|
|
11715
|
+
*
|
|
11716
|
+
* @param response - The network response containing the managed identity token
|
|
11717
|
+
*
|
|
11718
|
+
* @returns Standardized server authorization token response with normalized fields
|
|
11719
|
+
*/
|
|
11616
11720
|
getServerTokenResponse(response) {
|
|
11617
11721
|
let refreshIn, expiresIn;
|
|
11618
11722
|
if (response.body.expires_on) {
|
|
@@ -11650,6 +11754,21 @@ class BaseManagedIdentitySource {
|
|
|
11650
11754
|
};
|
|
11651
11755
|
return serverTokenResponse;
|
|
11652
11756
|
}
|
|
11757
|
+
/**
|
|
11758
|
+
* Acquires an access token using the managed identity endpoint for the specified resource.
|
|
11759
|
+
* This is the primary method for token acquisition, handling the complete flow from
|
|
11760
|
+
* request creation through response processing and token caching.
|
|
11761
|
+
*
|
|
11762
|
+
* @param managedIdentityRequest - The managed identity request containing resource and optional parameters
|
|
11763
|
+
* @param managedIdentityId - The managed identity configuration (system or user-assigned)
|
|
11764
|
+
* @param fakeAuthority - Authority instance used for token caching (managed identity uses a placeholder authority)
|
|
11765
|
+
* @param refreshAccessToken - Whether this is a token refresh operation
|
|
11766
|
+
*
|
|
11767
|
+
* @returns Promise resolving to an authentication result containing the access token and metadata
|
|
11768
|
+
*
|
|
11769
|
+
* @throws {AuthError} When network requests fail or token validation fails
|
|
11770
|
+
* @throws {ClientAuthError} When network errors occur during the request
|
|
11771
|
+
*/
|
|
11653
11772
|
async acquireTokenWithManagedIdentity(managedIdentityRequest, managedIdentityId, fakeAuthority, refreshAccessToken) {
|
|
11654
11773
|
const networkRequest = this.createRequest(managedIdentityRequest.resource, managedIdentityId);
|
|
11655
11774
|
if (managedIdentityRequest.revokedTokenSha256Hash) {
|
|
@@ -11704,6 +11823,19 @@ class BaseManagedIdentitySource {
|
|
|
11704
11823
|
// caches the token
|
|
11705
11824
|
return responseHandler.handleServerTokenResponse(serverTokenResponse, fakeAuthority, reqTimestamp, managedIdentityRequest);
|
|
11706
11825
|
}
|
|
11826
|
+
/**
|
|
11827
|
+
* Determines the appropriate query parameter name for user-assigned managed identity
|
|
11828
|
+
* based on the identity type, API version, and endpoint characteristics.
|
|
11829
|
+
* Different Azure services and API versions use different parameter names for the same identity types.
|
|
11830
|
+
*
|
|
11831
|
+
* @param managedIdentityIdType - The type of user-assigned managed identity (client ID, object ID, or resource ID)
|
|
11832
|
+
* @param isImds - Whether the request is being made to the IMDS (Instance Metadata Service) endpoint
|
|
11833
|
+
* @param usesApi2017 - Whether the endpoint uses the 2017-09-01 API version (affects client ID parameter name)
|
|
11834
|
+
*
|
|
11835
|
+
* @returns The correct query parameter name for the specified identity type and endpoint
|
|
11836
|
+
*
|
|
11837
|
+
* @throws {ManagedIdentityError} When an invalid managed identity ID type is provided
|
|
11838
|
+
*/
|
|
11707
11839
|
getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityIdType, isImds, usesApi2017) {
|
|
11708
11840
|
switch (managedIdentityIdType) {
|
|
11709
11841
|
case ManagedIdentityIdType.USER_ASSIGNED_CLIENT_ID:
|
|
@@ -11725,6 +11857,20 @@ class BaseManagedIdentitySource {
|
|
|
11725
11857
|
}
|
|
11726
11858
|
}
|
|
11727
11859
|
}
|
|
11860
|
+
/**
|
|
11861
|
+
* Validates and normalizes an environment variable containing a URL string.
|
|
11862
|
+
* This static utility method ensures that environment variables used for managed identity
|
|
11863
|
+
* endpoints contain properly formatted URLs and provides informative error messages when validation fails.
|
|
11864
|
+
*
|
|
11865
|
+
* @param envVariableStringName - The name of the environment variable being validated (for error reporting)
|
|
11866
|
+
* @param envVariable - The environment variable value containing the URL string
|
|
11867
|
+
* @param sourceName - The name of the managed identity source (for error reporting)
|
|
11868
|
+
* @param logger - Logger instance for diagnostic information
|
|
11869
|
+
*
|
|
11870
|
+
* @returns The validated and normalized URL string
|
|
11871
|
+
*
|
|
11872
|
+
* @throws {ManagedIdentityError} When the environment variable contains a malformed URL
|
|
11873
|
+
*/
|
|
11728
11874
|
BaseManagedIdentitySource.getValidatedEnvVariableUrlString = (envVariableStringName, envVariable, sourceName, logger) => {
|
|
11729
11875
|
try {
|
|
11730
11876
|
return new UrlString(envVariable).urlString;
|
|
@@ -11847,19 +11993,61 @@ class ManagedIdentityRequestParameters {
|
|
|
11847
11993
|
// MSI Constants. Docs for MSI are available here https://docs.microsoft.com/azure/app-service/overview-managed-identity
|
|
11848
11994
|
const APP_SERVICE_MSI_API_VERSION = "2019-08-01";
|
|
11849
11995
|
/**
|
|
11996
|
+
* Azure App Service Managed Identity Source implementation.
|
|
11997
|
+
*
|
|
11998
|
+
* This class provides managed identity authentication for applications running in Azure App Service.
|
|
11999
|
+
* It uses the local metadata service endpoint available within App Service environments to obtain
|
|
12000
|
+
* access tokens without requiring explicit credentials.
|
|
12001
|
+
*
|
|
11850
12002
|
* Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/AppServiceManagedIdentitySource.cs
|
|
11851
12003
|
*/
|
|
11852
12004
|
class AppService extends BaseManagedIdentitySource {
|
|
12005
|
+
/**
|
|
12006
|
+
* Creates a new instance of the AppService managed identity source.
|
|
12007
|
+
*
|
|
12008
|
+
* @param logger - Logger instance for diagnostic output
|
|
12009
|
+
* @param nodeStorage - Node.js storage implementation for caching
|
|
12010
|
+
* @param networkClient - Network client for making HTTP requests
|
|
12011
|
+
* @param cryptoProvider - Cryptographic operations provider
|
|
12012
|
+
* @param disableInternalRetries - Whether to disable internal retry logic
|
|
12013
|
+
* @param identityEndpoint - The App Service identity endpoint URL
|
|
12014
|
+
* @param identityHeader - The secret header value required for authentication
|
|
12015
|
+
*/
|
|
11853
12016
|
constructor(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, identityEndpoint, identityHeader) {
|
|
11854
12017
|
super(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries);
|
|
11855
12018
|
this.identityEndpoint = identityEndpoint;
|
|
11856
12019
|
this.identityHeader = identityHeader;
|
|
11857
12020
|
}
|
|
12021
|
+
/**
|
|
12022
|
+
* Retrieves the required environment variables for App Service managed identity.
|
|
12023
|
+
*
|
|
12024
|
+
* App Service managed identity requires two environment variables:
|
|
12025
|
+
* - IDENTITY_ENDPOINT: The URL of the local metadata service
|
|
12026
|
+
* - IDENTITY_HEADER: A secret header value for authentication
|
|
12027
|
+
*
|
|
12028
|
+
* @returns An array containing [identityEndpoint, identityHeader] values from environment variables.
|
|
12029
|
+
* Either value may be undefined if the environment variable is not set.
|
|
12030
|
+
*/
|
|
11858
12031
|
static getEnvironmentVariables() {
|
|
11859
12032
|
const identityEndpoint = process.env[ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT];
|
|
11860
12033
|
const identityHeader = process.env[ManagedIdentityEnvironmentVariableNames.IDENTITY_HEADER];
|
|
11861
12034
|
return [identityEndpoint, identityHeader];
|
|
11862
12035
|
}
|
|
12036
|
+
/**
|
|
12037
|
+
* Attempts to create an AppService managed identity source if the environment supports it.
|
|
12038
|
+
*
|
|
12039
|
+
* This method checks for the presence of required environment variables and validates
|
|
12040
|
+
* the identity endpoint URL. If the environment is not suitable for App Service managed
|
|
12041
|
+
* identity (missing environment variables or invalid endpoint), it returns null.
|
|
12042
|
+
*
|
|
12043
|
+
* @param logger - Logger instance for diagnostic output
|
|
12044
|
+
* @param nodeStorage - Node.js storage implementation for caching
|
|
12045
|
+
* @param networkClient - Network client for making HTTP requests
|
|
12046
|
+
* @param cryptoProvider - Cryptographic operations provider
|
|
12047
|
+
* @param disableInternalRetries - Whether to disable internal retry logic
|
|
12048
|
+
*
|
|
12049
|
+
* @returns A new AppService instance if the environment is suitable, null otherwise
|
|
12050
|
+
*/
|
|
11863
12051
|
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries) {
|
|
11864
12052
|
const [identityEndpoint, identityHeader] = AppService.getEnvironmentVariables();
|
|
11865
12053
|
// if either of the identity endpoint or identity header variables are undefined, this MSI provider is unavailable.
|
|
@@ -11871,6 +12059,18 @@ class AppService extends BaseManagedIdentitySource {
|
|
|
11871
12059
|
logger.info(`[Managed Identity] Environment variables validation passed for ${ManagedIdentitySourceNames.APP_SERVICE} managed identity. Endpoint URI: ${validatedIdentityEndpoint}. Creating ${ManagedIdentitySourceNames.APP_SERVICE} managed identity.`);
|
|
11872
12060
|
return new AppService(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, identityEndpoint, identityHeader);
|
|
11873
12061
|
}
|
|
12062
|
+
/**
|
|
12063
|
+
* Creates a managed identity token request for the App Service environment.
|
|
12064
|
+
*
|
|
12065
|
+
* This method constructs an HTTP GET request to the App Service identity endpoint
|
|
12066
|
+
* with the required headers, query parameters, and managed identity configuration.
|
|
12067
|
+
* The request includes the secret header for authentication and appropriate API version.
|
|
12068
|
+
*
|
|
12069
|
+
* @param resource - The target resource/scope for which to request an access token (e.g., "https://graph.microsoft.com/.default")
|
|
12070
|
+
* @param managedIdentityId - The managed identity configuration specifying whether to use system-assigned or user-assigned identity
|
|
12071
|
+
*
|
|
12072
|
+
* @returns A configured ManagedIdentityRequestParameters object ready for network execution
|
|
12073
|
+
*/
|
|
11874
12074
|
createRequest(resource, managedIdentityId) {
|
|
11875
12075
|
const request = new ManagedIdentityRequestParameters(HttpMethod.GET, this.identityEndpoint);
|
|
11876
12076
|
request.headers[ManagedIdentityHeaders.APP_SERVICE_SECRET_HEADER_NAME] =
|
|
@@ -11903,13 +12103,40 @@ const AZURE_ARC_FILE_DETECTION = {
|
|
|
11903
12103
|
linux: "/opt/azcmagent/bin/himds",
|
|
11904
12104
|
};
|
|
11905
12105
|
/**
|
|
12106
|
+
* Azure Arc managed identity source implementation for acquiring tokens from Azure Arc-enabled servers.
|
|
12107
|
+
*
|
|
12108
|
+
* This class provides managed identity authentication for applications running on Azure Arc-enabled servers
|
|
12109
|
+
* by communicating with the local Hybrid Instance Metadata Service (HIMDS). It supports both environment
|
|
12110
|
+
* variable-based configuration and automatic detection through the HIMDS executable.
|
|
12111
|
+
*
|
|
11906
12112
|
* Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/AzureArcManagedIdentitySource.cs
|
|
11907
12113
|
*/
|
|
11908
12114
|
class AzureArc extends BaseManagedIdentitySource {
|
|
12115
|
+
/**
|
|
12116
|
+
* Creates a new instance of the AzureArc managed identity source.
|
|
12117
|
+
*
|
|
12118
|
+
* @param logger - Logger instance for capturing telemetry and diagnostic information
|
|
12119
|
+
* @param nodeStorage - Storage implementation for caching tokens and metadata
|
|
12120
|
+
* @param networkClient - Network client for making HTTP requests to the identity endpoint
|
|
12121
|
+
* @param cryptoProvider - Cryptographic operations provider for token validation and encryption
|
|
12122
|
+
* @param disableInternalRetries - Flag to disable automatic retry logic for failed requests
|
|
12123
|
+
* @param identityEndpoint - The Azure Arc identity endpoint URL for token requests
|
|
12124
|
+
*/
|
|
11909
12125
|
constructor(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, identityEndpoint) {
|
|
11910
12126
|
super(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries);
|
|
11911
12127
|
this.identityEndpoint = identityEndpoint;
|
|
11912
12128
|
}
|
|
12129
|
+
/**
|
|
12130
|
+
* Retrieves and validates Azure Arc environment variables for managed identity configuration.
|
|
12131
|
+
*
|
|
12132
|
+
* This method checks for IDENTITY_ENDPOINT and IMDS_ENDPOINT environment variables.
|
|
12133
|
+
* If either is missing, it attempts to detect the Azure Arc environment by checking for
|
|
12134
|
+
* the HIMDS executable at platform-specific paths. On successful detection, it returns
|
|
12135
|
+
* the default identity endpoint and a helper string indicating file-based detection.
|
|
12136
|
+
*
|
|
12137
|
+
* @returns An array containing [identityEndpoint, imdsEndpoint] where both values are
|
|
12138
|
+
* strings if Azure Arc is available, or undefined if not available.
|
|
12139
|
+
*/
|
|
11913
12140
|
static getEnvironmentVariables() {
|
|
11914
12141
|
let identityEndpoint = process.env[ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT];
|
|
11915
12142
|
let imdsEndpoint = process.env[ManagedIdentityEnvironmentVariableNames.IMDS_ENDPOINT];
|
|
@@ -11935,6 +12162,25 @@ class AzureArc extends BaseManagedIdentitySource {
|
|
|
11935
12162
|
}
|
|
11936
12163
|
return [identityEndpoint, imdsEndpoint];
|
|
11937
12164
|
}
|
|
12165
|
+
/**
|
|
12166
|
+
* Attempts to create an AzureArc managed identity source instance.
|
|
12167
|
+
*
|
|
12168
|
+
* Validates the Azure Arc environment by checking environment variables
|
|
12169
|
+
* and performing file-based detection. It ensures that only system-assigned managed identities
|
|
12170
|
+
* are supported for Azure Arc scenarios. The method performs comprehensive validation of
|
|
12171
|
+
* endpoint URLs and logs detailed information about the detection process.
|
|
12172
|
+
*
|
|
12173
|
+
* @param logger - Logger instance for capturing creation and validation steps
|
|
12174
|
+
* @param nodeStorage - Storage implementation for the managed identity source
|
|
12175
|
+
* @param networkClient - Network client for HTTP communication
|
|
12176
|
+
* @param cryptoProvider - Cryptographic operations provider
|
|
12177
|
+
* @param disableInternalRetries - Whether to disable automatic retry mechanisms
|
|
12178
|
+
* @param managedIdentityId - The managed identity configuration, must be system-assigned
|
|
12179
|
+
*
|
|
12180
|
+
* @returns AzureArc instance if the environment supports Azure Arc managed identity, null otherwise
|
|
12181
|
+
*
|
|
12182
|
+
* @throws {ManagedIdentityError} When a user-assigned managed identity is specified (not supported for Azure Arc)
|
|
12183
|
+
*/
|
|
11938
12184
|
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, managedIdentityId) {
|
|
11939
12185
|
const [identityEndpoint, imdsEndpoint] = AzureArc.getEnvironmentVariables();
|
|
11940
12186
|
// if either of the identity or imds endpoints are undefined (even after himds file detection)
|
|
@@ -11961,6 +12207,17 @@ class AzureArc extends BaseManagedIdentitySource {
|
|
|
11961
12207
|
}
|
|
11962
12208
|
return new AzureArc(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, identityEndpoint);
|
|
11963
12209
|
}
|
|
12210
|
+
/**
|
|
12211
|
+
* Creates a properly formatted HTTP request for acquiring tokens from the Azure Arc identity endpoint.
|
|
12212
|
+
*
|
|
12213
|
+
* This method constructs a GET request to the Azure Arc HIMDS endpoint with the required metadata header
|
|
12214
|
+
* and query parameters. The endpoint URL is normalized to use 127.0.0.1 instead of localhost for
|
|
12215
|
+
* consistency. Additional body parameters are calculated by the base class during token acquisition.
|
|
12216
|
+
*
|
|
12217
|
+
* @param resource - The target resource/scope for which to request an access token (e.g., "https://graph.microsoft.com/.default")
|
|
12218
|
+
*
|
|
12219
|
+
* @returns A configured ManagedIdentityRequestParameters object ready for network execution
|
|
12220
|
+
*/
|
|
11964
12221
|
createRequest(resource) {
|
|
11965
12222
|
const request = new ManagedIdentityRequestParameters(HttpMethod.GET, this.identityEndpoint.replace("localhost", "127.0.0.1"));
|
|
11966
12223
|
request.headers[ManagedIdentityHeaders.METADATA_HEADER_NAME] = "true";
|
|
@@ -11971,6 +12228,30 @@ class AzureArc extends BaseManagedIdentitySource {
|
|
|
11971
12228
|
// bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
|
|
11972
12229
|
return request;
|
|
11973
12230
|
}
|
|
12231
|
+
/**
|
|
12232
|
+
* Processes the server response and handles Azure Arc-specific authentication challenges.
|
|
12233
|
+
*
|
|
12234
|
+
* This method implements the Azure Arc authentication flow which may require reading a secret file
|
|
12235
|
+
* for authorization. When the initial request returns HTTP 401 Unauthorized, it extracts the file
|
|
12236
|
+
* path from the WWW-Authenticate header, validates the file location and size, reads the secret,
|
|
12237
|
+
* and retries the request with Basic authentication. The method includes comprehensive security
|
|
12238
|
+
* validations to prevent path traversal and ensure file integrity.
|
|
12239
|
+
*
|
|
12240
|
+
* @param originalResponse - The initial HTTP response from the identity endpoint
|
|
12241
|
+
* @param networkClient - Network client for making the retry request if needed
|
|
12242
|
+
* @param networkRequest - The original request parameters (modified with auth header for retry)
|
|
12243
|
+
* @param networkRequestOptions - Additional options for network requests
|
|
12244
|
+
*
|
|
12245
|
+
* @returns A promise that resolves to the server token response with access token and metadata
|
|
12246
|
+
*
|
|
12247
|
+
* @throws {ManagedIdentityError} When:
|
|
12248
|
+
* - WWW-Authenticate header is missing or has unsupported format
|
|
12249
|
+
* - Platform is not supported (not Windows or Linux)
|
|
12250
|
+
* - Secret file has invalid extension (not .key)
|
|
12251
|
+
* - Secret file path doesn't match expected platform path
|
|
12252
|
+
* - Secret file cannot be read or is too large (>4096 bytes)
|
|
12253
|
+
* @throws {ClientAuthError} When network errors occur during retry request
|
|
12254
|
+
*/
|
|
11974
12255
|
async getServerTokenResponseAsync(originalResponse, networkClient, networkRequest, networkRequestOptions) {
|
|
11975
12256
|
let retryResponse;
|
|
11976
12257
|
if (originalResponse.status === HttpStatus.UNAUTHORIZED) {
|
|
@@ -12046,17 +12327,60 @@ class AzureArc extends BaseManagedIdentitySource {
|
|
|
12046
12327
|
* Licensed under the MIT License.
|
|
12047
12328
|
*/
|
|
12048
12329
|
/**
|
|
12330
|
+
* Azure Cloud Shell managed identity source implementation.
|
|
12331
|
+
*
|
|
12332
|
+
* This class handles authentication for applications running in Azure Cloud Shell environment.
|
|
12333
|
+
* Cloud Shell provides a browser-accessible shell for managing Azure resources and includes
|
|
12334
|
+
* a pre-configured managed identity for authentication.
|
|
12335
|
+
*
|
|
12049
12336
|
* Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/CloudShellManagedIdentitySource.cs
|
|
12050
12337
|
*/
|
|
12051
12338
|
class CloudShell extends BaseManagedIdentitySource {
|
|
12339
|
+
/**
|
|
12340
|
+
* Creates a new CloudShell managed identity source instance.
|
|
12341
|
+
*
|
|
12342
|
+
* @param logger - Logger instance for diagnostic logging
|
|
12343
|
+
* @param nodeStorage - Node.js storage implementation for caching
|
|
12344
|
+
* @param networkClient - HTTP client for making requests to the managed identity endpoint
|
|
12345
|
+
* @param cryptoProvider - Cryptographic operations provider
|
|
12346
|
+
* @param disableInternalRetries - Whether to disable automatic retry logic for failed requests
|
|
12347
|
+
* @param msiEndpoint - The MSI endpoint URL obtained from environment variables
|
|
12348
|
+
*/
|
|
12052
12349
|
constructor(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, msiEndpoint) {
|
|
12053
12350
|
super(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries);
|
|
12054
12351
|
this.msiEndpoint = msiEndpoint;
|
|
12055
12352
|
}
|
|
12353
|
+
/**
|
|
12354
|
+
* Retrieves the required environment variables for Cloud Shell managed identity.
|
|
12355
|
+
*
|
|
12356
|
+
* Cloud Shell requires the MSI_ENDPOINT environment variable to be set, which
|
|
12357
|
+
* contains the URL of the managed identity service endpoint.
|
|
12358
|
+
*
|
|
12359
|
+
* @returns An array containing the MSI_ENDPOINT environment variable value (or undefined if not set)
|
|
12360
|
+
*/
|
|
12056
12361
|
static getEnvironmentVariables() {
|
|
12057
12362
|
const msiEndpoint = process.env[ManagedIdentityEnvironmentVariableNames.MSI_ENDPOINT];
|
|
12058
12363
|
return [msiEndpoint];
|
|
12059
12364
|
}
|
|
12365
|
+
/**
|
|
12366
|
+
* Attempts to create a CloudShell managed identity source instance.
|
|
12367
|
+
*
|
|
12368
|
+
* This method validates that the required environment variables are present and
|
|
12369
|
+
* creates a CloudShell instance if the environment is properly configured.
|
|
12370
|
+
* Cloud Shell only supports system-assigned managed identities.
|
|
12371
|
+
*
|
|
12372
|
+
* @param logger - Logger instance for diagnostic logging
|
|
12373
|
+
* @param nodeStorage - Node.js storage implementation for caching
|
|
12374
|
+
* @param networkClient - HTTP client for making requests
|
|
12375
|
+
* @param cryptoProvider - Cryptographic operations provider
|
|
12376
|
+
* @param disableInternalRetries - Whether to disable automatic retry logic
|
|
12377
|
+
* @param managedIdentityId - The managed identity configuration (must be system-assigned)
|
|
12378
|
+
*
|
|
12379
|
+
* @returns A CloudShell instance if the environment is valid, null otherwise
|
|
12380
|
+
*
|
|
12381
|
+
* @throws {ManagedIdentityError} When a user-assigned managed identity is requested,
|
|
12382
|
+
* as Cloud Shell only supports system-assigned identities
|
|
12383
|
+
*/
|
|
12060
12384
|
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, managedIdentityId) {
|
|
12061
12385
|
const [msiEndpoint] = CloudShell.getEnvironmentVariables();
|
|
12062
12386
|
// if the msi endpoint environment variable is undefined, this MSI provider is unavailable.
|
|
@@ -12071,6 +12395,17 @@ class CloudShell extends BaseManagedIdentitySource {
|
|
|
12071
12395
|
}
|
|
12072
12396
|
return new CloudShell(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, msiEndpoint);
|
|
12073
12397
|
}
|
|
12398
|
+
/**
|
|
12399
|
+
* Creates an HTTP request to acquire an access token from the Cloud Shell managed identity endpoint.
|
|
12400
|
+
*
|
|
12401
|
+
* This method constructs a POST request to the MSI endpoint with the required headers and
|
|
12402
|
+
* body parameters for Cloud Shell authentication. The request includes the target resource
|
|
12403
|
+
* for which the access token is being requested.
|
|
12404
|
+
*
|
|
12405
|
+
* @param resource - The target resource/scope for which to request an access token (e.g., "https://graph.microsoft.com/.default")
|
|
12406
|
+
*
|
|
12407
|
+
* @returns A configured ManagedIdentityRequestParameters object ready for network execution
|
|
12408
|
+
*/
|
|
12074
12409
|
createRequest(resource) {
|
|
12075
12410
|
const request = new ManagedIdentityRequestParameters(HttpMethod.POST, this.msiEndpoint);
|
|
12076
12411
|
request.headers[ManagedIdentityHeaders.METADATA_HEADER_NAME] = "true";
|
|
@@ -12208,33 +12543,44 @@ const IMDS_TOKEN_PATH = "/metadata/identity/oauth2/token";
|
|
|
12208
12543
|
const DEFAULT_IMDS_ENDPOINT = `http://169.254.169.254${IMDS_TOKEN_PATH}`;
|
|
12209
12544
|
const IMDS_API_VERSION = "2018-02-01";
|
|
12210
12545
|
/**
|
|
12546
|
+
* Managed Identity source implementation for Azure Instance Metadata Service (IMDS).
|
|
12547
|
+
*
|
|
12548
|
+
* IMDS is available on Azure Virtual Machines and Virtual Machine Scale Sets and provides
|
|
12549
|
+
* a REST endpoint to obtain OAuth tokens for managed identities. This implementation
|
|
12550
|
+
* handles both system-assigned and user-assigned managed identities.
|
|
12551
|
+
*
|
|
12211
12552
|
* Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/ImdsManagedIdentitySource.cs
|
|
12212
12553
|
*/
|
|
12213
12554
|
class Imds extends BaseManagedIdentitySource {
|
|
12214
12555
|
/**
|
|
12215
|
-
* Constructs an Imds instance.
|
|
12216
|
-
*
|
|
12217
|
-
* @param
|
|
12218
|
-
* @param
|
|
12219
|
-
* @param
|
|
12220
|
-
* @param
|
|
12221
|
-
* @param
|
|
12556
|
+
* Constructs an Imds instance with the specified configuration.
|
|
12557
|
+
*
|
|
12558
|
+
* @param logger - Logger instance for recording debug information and errors
|
|
12559
|
+
* @param nodeStorage - NodeStorage instance used for token caching operations
|
|
12560
|
+
* @param networkClient - Network client implementation for making HTTP requests to IMDS
|
|
12561
|
+
* @param cryptoProvider - CryptoProvider for generating correlation IDs and other cryptographic operations
|
|
12562
|
+
* @param disableInternalRetries - When true, disables the built-in retry logic for IMDS requests
|
|
12563
|
+
* @param identityEndpoint - The complete IMDS endpoint URL including the token path
|
|
12222
12564
|
*/
|
|
12223
12565
|
constructor(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, identityEndpoint) {
|
|
12224
12566
|
super(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries);
|
|
12225
12567
|
this.identityEndpoint = identityEndpoint;
|
|
12226
12568
|
}
|
|
12227
12569
|
/**
|
|
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.
|
|
12570
|
+
* Creates an Imds instance with the appropriate endpoint configuration.
|
|
12231
12571
|
*
|
|
12232
|
-
*
|
|
12233
|
-
*
|
|
12234
|
-
*
|
|
12235
|
-
*
|
|
12236
|
-
*
|
|
12237
|
-
* @
|
|
12572
|
+
* This method checks for the presence of the AZURE_POD_IDENTITY_AUTHORITY_HOST environment
|
|
12573
|
+
* variable, which is used in Azure Kubernetes Service (AKS) environments with Azure AD
|
|
12574
|
+
* Pod Identity. If found, it uses that endpoint; otherwise, it falls back to the standard
|
|
12575
|
+
* IMDS endpoint (169.254.169.254).
|
|
12576
|
+
*
|
|
12577
|
+
* @param logger - Logger instance for recording endpoint discovery and validation
|
|
12578
|
+
* @param nodeStorage - NodeStorage instance for token caching
|
|
12579
|
+
* @param networkClient - Network client for HTTP requests
|
|
12580
|
+
* @param cryptoProvider - CryptoProvider for cryptographic operations
|
|
12581
|
+
* @param disableInternalRetries - Whether to disable built-in retry logic
|
|
12582
|
+
*
|
|
12583
|
+
* @returns A configured Imds instance ready to make token requests
|
|
12238
12584
|
*/
|
|
12239
12585
|
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries) {
|
|
12240
12586
|
let validatedIdentityEndpoint;
|
|
@@ -12252,12 +12598,23 @@ class Imds extends BaseManagedIdentitySource {
|
|
|
12252
12598
|
return new Imds(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, validatedIdentityEndpoint);
|
|
12253
12599
|
}
|
|
12254
12600
|
/**
|
|
12255
|
-
* Creates a
|
|
12256
|
-
*
|
|
12601
|
+
* Creates a properly configured HTTP request for acquiring an access token from IMDS.
|
|
12602
|
+
*
|
|
12603
|
+
* This method builds a complete request object with all necessary headers, query parameters,
|
|
12604
|
+
* and retry policies required by the Azure Instance Metadata Service.
|
|
12605
|
+
*
|
|
12606
|
+
* Key request components:
|
|
12607
|
+
* - HTTP GET method to the IMDS token endpoint
|
|
12608
|
+
* - Metadata header set to "true" (required by IMDS)
|
|
12609
|
+
* - API version parameter (currently "2018-02-01")
|
|
12610
|
+
* - Resource parameter specifying the target audience
|
|
12611
|
+
* - Identity-specific parameters for user-assigned managed identities
|
|
12612
|
+
* - IMDS-specific retry policy
|
|
12257
12613
|
*
|
|
12258
|
-
* @param resource - The resource
|
|
12259
|
-
* @param managedIdentityId - The managed identity
|
|
12260
|
-
*
|
|
12614
|
+
* @param resource - The target resource/scope for which to request an access token (e.g., "https://graph.microsoft.com/.default")
|
|
12615
|
+
* @param managedIdentityId - The managed identity configuration specifying whether to use system-assigned or user-assigned identity
|
|
12616
|
+
*
|
|
12617
|
+
* @returns A configured ManagedIdentityRequestParameters object ready for network execution
|
|
12261
12618
|
*/
|
|
12262
12619
|
createRequest(resource, managedIdentityId) {
|
|
12263
12620
|
const request = new ManagedIdentityRequestParameters(HttpMethod.GET, this.identityEndpoint);
|
|
@@ -12286,14 +12643,19 @@ const SERVICE_FABRIC_MSI_API_VERSION = "2019-07-01-preview";
|
|
|
12286
12643
|
*/
|
|
12287
12644
|
class ServiceFabric extends BaseManagedIdentitySource {
|
|
12288
12645
|
/**
|
|
12289
|
-
* Constructs a new ServiceFabric managed identity source.
|
|
12290
|
-
*
|
|
12291
|
-
*
|
|
12292
|
-
*
|
|
12293
|
-
*
|
|
12294
|
-
*
|
|
12295
|
-
* @param
|
|
12296
|
-
* @param
|
|
12646
|
+
* Constructs a new ServiceFabric managed identity source for acquiring tokens from Azure Service Fabric clusters.
|
|
12647
|
+
*
|
|
12648
|
+
* Service Fabric managed identity allows applications running in Service Fabric clusters to authenticate
|
|
12649
|
+
* without storing credentials in code. This source handles token acquisition using the Service Fabric
|
|
12650
|
+
* Managed Identity Token Service (MITS).
|
|
12651
|
+
*
|
|
12652
|
+
* @param logger - Logger instance for logging authentication events and debugging information
|
|
12653
|
+
* @param nodeStorage - NodeStorage instance for caching tokens and other authentication artifacts
|
|
12654
|
+
* @param networkClient - Network client for making HTTP requests to the Service Fabric identity endpoint
|
|
12655
|
+
* @param cryptoProvider - Crypto provider for cryptographic operations like token validation
|
|
12656
|
+
* @param disableInternalRetries - Whether to disable internal retry logic for failed requests
|
|
12657
|
+
* @param identityEndpoint - The Service Fabric managed identity endpoint URL
|
|
12658
|
+
* @param identityHeader - The Service Fabric managed identity secret header value
|
|
12297
12659
|
*/
|
|
12298
12660
|
constructor(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, identityEndpoint, identityHeader) {
|
|
12299
12661
|
super(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries);
|
|
@@ -12301,8 +12663,16 @@ class ServiceFabric extends BaseManagedIdentitySource {
|
|
|
12301
12663
|
this.identityHeader = identityHeader;
|
|
12302
12664
|
}
|
|
12303
12665
|
/**
|
|
12304
|
-
* Retrieves the environment variables required for Service Fabric managed identity.
|
|
12305
|
-
*
|
|
12666
|
+
* Retrieves the environment variables required for Service Fabric managed identity authentication.
|
|
12667
|
+
*
|
|
12668
|
+
* Service Fabric managed identity requires three specific environment variables to be set by the
|
|
12669
|
+
* Service Fabric runtime:
|
|
12670
|
+
* - IDENTITY_ENDPOINT: The endpoint URL for the Managed Identity Token Service (MITS)
|
|
12671
|
+
* - IDENTITY_HEADER: A secret value used for authentication with the MITS
|
|
12672
|
+
* - IDENTITY_SERVER_THUMBPRINT: The thumbprint of the MITS server certificate for secure communication
|
|
12673
|
+
*
|
|
12674
|
+
* @returns An array containing the identity endpoint, identity header, and identity server thumbprint values.
|
|
12675
|
+
* Elements will be undefined if the corresponding environment variables are not set.
|
|
12306
12676
|
*/
|
|
12307
12677
|
static getEnvironmentVariables() {
|
|
12308
12678
|
const identityEndpoint = process.env[ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT];
|
|
@@ -12312,14 +12682,23 @@ class ServiceFabric extends BaseManagedIdentitySource {
|
|
|
12312
12682
|
return [identityEndpoint, identityHeader, identityServerThumbprint];
|
|
12313
12683
|
}
|
|
12314
12684
|
/**
|
|
12315
|
-
* Attempts to create a ServiceFabric managed identity source if
|
|
12316
|
-
*
|
|
12317
|
-
*
|
|
12318
|
-
*
|
|
12319
|
-
*
|
|
12320
|
-
*
|
|
12321
|
-
*
|
|
12322
|
-
*
|
|
12685
|
+
* Attempts to create a ServiceFabric managed identity source if the runtime environment supports it.
|
|
12686
|
+
*
|
|
12687
|
+
* Checks for the presence of all required Service Fabric environment variables
|
|
12688
|
+
* and validates the endpoint URL format. It will only create a ServiceFabric instance if the application
|
|
12689
|
+
* is running in a properly configured Service Fabric cluster with managed identity enabled.
|
|
12690
|
+
*
|
|
12691
|
+
* Note: User-assigned managed identities must be configured at the cluster level, not at runtime.
|
|
12692
|
+
* This method will log a warning if a user-assigned identity is requested.
|
|
12693
|
+
*
|
|
12694
|
+
* @param logger - Logger instance for logging creation events and validation results
|
|
12695
|
+
* @param nodeStorage - NodeStorage instance for caching tokens and authentication artifacts
|
|
12696
|
+
* @param networkClient - Network client for making HTTP requests to the identity endpoint
|
|
12697
|
+
* @param cryptoProvider - Crypto provider for cryptographic operations
|
|
12698
|
+
* @param disableInternalRetries - Whether to disable internal retry logic for failed requests
|
|
12699
|
+
* @param managedIdentityId - Managed identity identifier specifying system-assigned or user-assigned identity
|
|
12700
|
+
*
|
|
12701
|
+
* @returns A ServiceFabric instance if all environment variables are valid and present, otherwise null
|
|
12323
12702
|
*/
|
|
12324
12703
|
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, managedIdentityId) {
|
|
12325
12704
|
const [identityEndpoint, identityHeader, identityServerThumbprint] = ServiceFabric.getEnvironmentVariables();
|
|
@@ -12335,10 +12714,22 @@ class ServiceFabric extends BaseManagedIdentitySource {
|
|
|
12335
12714
|
return new ServiceFabric(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, identityEndpoint, identityHeader);
|
|
12336
12715
|
}
|
|
12337
12716
|
/**
|
|
12338
|
-
* Creates
|
|
12339
|
-
*
|
|
12340
|
-
*
|
|
12341
|
-
*
|
|
12717
|
+
* Creates HTTP request parameters for acquiring an access token from the Service Fabric Managed Identity Token Service (MITS).
|
|
12718
|
+
*
|
|
12719
|
+
* This method constructs a properly formatted HTTP GET request that includes:
|
|
12720
|
+
* - The secret header for authentication with MITS
|
|
12721
|
+
* - API version parameter for the Service Fabric MSI endpoint
|
|
12722
|
+
* - Resource parameter specifying the target Azure service
|
|
12723
|
+
* - Optional identity parameters for user-assigned managed identities
|
|
12724
|
+
*
|
|
12725
|
+
* The request follows the Service Fabric managed identity protocol and uses the 2019-07-01-preview API version.
|
|
12726
|
+
* For user-assigned identities, the appropriate query parameter (client_id, object_id, or resource_id) is added
|
|
12727
|
+
* based on the identity type.
|
|
12728
|
+
*
|
|
12729
|
+
* @param resource - The Azure resource URI for which the access token is requested (e.g., "https://vault.azure.net/")
|
|
12730
|
+
* @param managedIdentityId - The managed identity configuration specifying system-assigned or user-assigned identity details
|
|
12731
|
+
*
|
|
12732
|
+
* @returns A configured ManagedIdentityRequestParameters object ready for network execution
|
|
12342
12733
|
*/
|
|
12343
12734
|
createRequest(resource, managedIdentityId) {
|
|
12344
12735
|
const request = new ManagedIdentityRequestParameters(HttpMethod.GET, this.identityEndpoint);
|
|
@@ -12362,17 +12753,62 @@ class ServiceFabric extends BaseManagedIdentitySource {
|
|
|
12362
12753
|
*/
|
|
12363
12754
|
const MACHINE_LEARNING_MSI_API_VERSION = "2017-09-01";
|
|
12364
12755
|
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
|
|
12756
|
+
/**
|
|
12757
|
+
* Machine Learning Managed Identity Source implementation for Azure Machine Learning environments.
|
|
12758
|
+
*
|
|
12759
|
+
* This class handles managed identity authentication specifically for Azure Machine Learning services.
|
|
12760
|
+
* It supports both system-assigned and user-assigned managed identities, using the MSI_ENDPOINT
|
|
12761
|
+
* and MSI_SECRET environment variables that are automatically provided in Azure ML environments.
|
|
12762
|
+
*/
|
|
12365
12763
|
class MachineLearning extends BaseManagedIdentitySource {
|
|
12764
|
+
/**
|
|
12765
|
+
* Creates a new MachineLearning managed identity source instance.
|
|
12766
|
+
*
|
|
12767
|
+
* @param logger - Logger instance for diagnostic information
|
|
12768
|
+
* @param nodeStorage - Node storage implementation for caching
|
|
12769
|
+
* @param networkClient - Network client for making HTTP requests
|
|
12770
|
+
* @param cryptoProvider - Cryptographic operations provider
|
|
12771
|
+
* @param disableInternalRetries - Whether to disable automatic request retries
|
|
12772
|
+
* @param msiEndpoint - The MSI endpoint URL from environment variables
|
|
12773
|
+
* @param secret - The MSI secret from environment variables
|
|
12774
|
+
*/
|
|
12366
12775
|
constructor(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, msiEndpoint, secret) {
|
|
12367
12776
|
super(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries);
|
|
12368
12777
|
this.msiEndpoint = msiEndpoint;
|
|
12369
12778
|
this.secret = secret;
|
|
12370
12779
|
}
|
|
12780
|
+
/**
|
|
12781
|
+
* Retrieves the required environment variables for Azure Machine Learning managed identity.
|
|
12782
|
+
*
|
|
12783
|
+
* This method checks for the presence of MSI_ENDPOINT and MSI_SECRET environment variables
|
|
12784
|
+
* that are automatically set by the Azure Machine Learning platform when managed identity
|
|
12785
|
+
* is enabled for the compute instance or cluster.
|
|
12786
|
+
*
|
|
12787
|
+
* @returns An array containing [msiEndpoint, secret] where either value may be undefined
|
|
12788
|
+
* if the corresponding environment variable is not set
|
|
12789
|
+
*/
|
|
12371
12790
|
static getEnvironmentVariables() {
|
|
12372
12791
|
const msiEndpoint = process.env[ManagedIdentityEnvironmentVariableNames.MSI_ENDPOINT];
|
|
12373
12792
|
const secret = process.env[ManagedIdentityEnvironmentVariableNames.MSI_SECRET];
|
|
12374
12793
|
return [msiEndpoint, secret];
|
|
12375
12794
|
}
|
|
12795
|
+
/**
|
|
12796
|
+
* Attempts to create a MachineLearning managed identity source.
|
|
12797
|
+
*
|
|
12798
|
+
* This method validates the Azure Machine Learning environment by checking for the required
|
|
12799
|
+
* MSI_ENDPOINT and MSI_SECRET environment variables. If both are present and valid,
|
|
12800
|
+
* it creates and returns a MachineLearning instance. If either is missing or invalid,
|
|
12801
|
+
* it returns null, indicating that this managed identity source is not available
|
|
12802
|
+
* in the current environment.
|
|
12803
|
+
*
|
|
12804
|
+
* @param logger - Logger instance for diagnostic information
|
|
12805
|
+
* @param nodeStorage - Node storage implementation for caching
|
|
12806
|
+
* @param networkClient - Network client for making HTTP requests
|
|
12807
|
+
* @param cryptoProvider - Cryptographic operations provider
|
|
12808
|
+
* @param disableInternalRetries - Whether to disable automatic request retries
|
|
12809
|
+
*
|
|
12810
|
+
* @returns A new MachineLearning instance if the environment is valid, null otherwise
|
|
12811
|
+
*/
|
|
12376
12812
|
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries) {
|
|
12377
12813
|
const [msiEndpoint, secret] = MachineLearning.getEnvironmentVariables();
|
|
12378
12814
|
// if either of the MSI endpoint or MSI secret variables are undefined, this MSI provider is unavailable.
|
|
@@ -12384,6 +12820,26 @@ class MachineLearning extends BaseManagedIdentitySource {
|
|
|
12384
12820
|
logger.info(`[Managed Identity] Environment variables validation passed for ${ManagedIdentitySourceNames.MACHINE_LEARNING} managed identity. Endpoint URI: ${validatedMsiEndpoint}. Creating ${ManagedIdentitySourceNames.MACHINE_LEARNING} managed identity.`);
|
|
12385
12821
|
return new MachineLearning(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, msiEndpoint, secret);
|
|
12386
12822
|
}
|
|
12823
|
+
/**
|
|
12824
|
+
* Creates a managed identity token request for Azure Machine Learning environments.
|
|
12825
|
+
*
|
|
12826
|
+
* This method constructs the HTTP request parameters needed to acquire an access token
|
|
12827
|
+
* from the Azure Machine Learning managed identity endpoint. It handles both system-assigned
|
|
12828
|
+
* and user-assigned managed identities with specific logic for each type:
|
|
12829
|
+
*
|
|
12830
|
+
* - System-assigned: Uses the DEFAULT_IDENTITY_CLIENT_ID environment variable
|
|
12831
|
+
* - User-assigned: Only supports client ID-based identification (not object ID or resource ID)
|
|
12832
|
+
*
|
|
12833
|
+
* The request uses the 2017-09-01 API version and includes the required secret header
|
|
12834
|
+
* for authentication with the MSI endpoint.
|
|
12835
|
+
*
|
|
12836
|
+
* @param resource - The target resource/scope for which to request an access token (e.g., "https://graph.microsoft.com/.default")
|
|
12837
|
+
* @param managedIdentityId - The managed identity configuration specifying whether to use system-assigned or user-assigned identity
|
|
12838
|
+
*
|
|
12839
|
+
* @returns A configured ManagedIdentityRequestParameters object ready for network execution
|
|
12840
|
+
*
|
|
12841
|
+
* @throws Error if an unsupported managed identity ID type is specified (only client ID is supported for user-assigned)
|
|
12842
|
+
*/
|
|
12387
12843
|
createRequest(resource, managedIdentityId) {
|
|
12388
12844
|
const request = new ManagedIdentityRequestParameters(HttpMethod.GET, this.msiEndpoint);
|
|
12389
12845
|
request.headers[ManagedIdentityHeaders.METADATA_HEADER_NAME] = "true";
|