@azure/msal-node 3.2.3 → 3.4.0
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/NodeStorage.mjs +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.d.ts +3 -3
- package/dist/client/ClientApplication.d.ts.map +1 -1
- package/dist/client/ClientApplication.mjs +14 -17
- package/dist/client/ClientApplication.mjs.map +1 -1
- package/dist/client/ClientAssertion.mjs +1 -1
- package/dist/client/ClientCredentialClient.d.ts.map +1 -1
- package/dist/client/ClientCredentialClient.mjs +16 -16
- package/dist/client/ClientCredentialClient.mjs.map +1 -1
- package/dist/client/ConfidentialClientApplication.d.ts.map +1 -1
- package/dist/client/ConfidentialClientApplication.mjs +5 -3
- package/dist/client/ConfidentialClientApplication.mjs.map +1 -1
- package/dist/client/DeviceCodeClient.d.ts.map +1 -1
- package/dist/client/DeviceCodeClient.mjs +24 -24
- package/dist/client/DeviceCodeClient.mjs.map +1 -1
- package/dist/client/ManagedIdentityApplication.d.ts.map +1 -1
- package/dist/client/ManagedIdentityApplication.mjs +2 -2
- package/dist/client/ManagedIdentityApplication.mjs.map +1 -1
- package/dist/client/ManagedIdentityClient.d.ts +2 -1
- package/dist/client/ManagedIdentityClient.d.ts.map +1 -1
- package/dist/client/ManagedIdentityClient.mjs +11 -10
- package/dist/client/ManagedIdentityClient.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/AppService.d.ts +2 -2
- package/dist/client/ManagedIdentitySources/AppService.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/AppService.mjs +5 -5
- package/dist/client/ManagedIdentitySources/AppService.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/AzureArc.d.ts +2 -2
- package/dist/client/ManagedIdentitySources/AzureArc.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/AzureArc.mjs +5 -5
- package/dist/client/ManagedIdentitySources/AzureArc.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +2 -1
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +15 -5
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/CloudShell.d.ts +2 -2
- package/dist/client/ManagedIdentitySources/CloudShell.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/CloudShell.mjs +5 -5
- package/dist/client/ManagedIdentitySources/CloudShell.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/Imds.d.ts +2 -2
- package/dist/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/Imds.mjs +5 -5
- package/dist/client/ManagedIdentitySources/Imds.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/MachineLearning.d.ts +2 -2
- package/dist/client/ManagedIdentitySources/MachineLearning.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/MachineLearning.mjs +5 -5
- package/dist/client/ManagedIdentitySources/MachineLearning.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts +2 -2
- package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/ServiceFabric.mjs +5 -5
- package/dist/client/ManagedIdentitySources/ServiceFabric.mjs.map +1 -1
- package/dist/client/OnBehalfOfClient.d.ts.map +1 -1
- package/dist/client/OnBehalfOfClient.mjs +19 -19
- package/dist/client/OnBehalfOfClient.mjs.map +1 -1
- package/dist/client/PublicClientApplication.d.ts.map +1 -1
- package/dist/client/PublicClientApplication.mjs +3 -2
- package/dist/client/PublicClientApplication.mjs.map +1 -1
- package/dist/client/UsernamePasswordClient.d.ts.map +1 -1
- package/dist/client/UsernamePasswordClient.mjs +21 -21
- package/dist/client/UsernamePasswordClient.mjs.map +1 -1
- package/dist/config/Configuration.d.ts +1 -0
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.mjs +2 -9
- package/dist/config/Configuration.mjs.map +1 -1
- package/dist/config/ManagedIdentityId.mjs +1 -1
- package/dist/config/ManagedIdentityRequestParameters.d.ts +3 -2
- package/dist/config/ManagedIdentityRequestParameters.d.ts.map +1 -1
- package/dist/config/ManagedIdentityRequestParameters.mjs +13 -9
- package/dist/config/ManagedIdentityRequestParameters.mjs.map +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.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/internals.mjs +1 -1
- package/dist/network/HttpClient.mjs +1 -1
- package/dist/network/HttpClientWithRetries.mjs +1 -1
- package/dist/network/ILoopbackClient.d.ts +2 -2
- package/dist/network/ILoopbackClient.d.ts.map +1 -1
- package/dist/network/LoopbackClient.d.ts +2 -2
- package/dist/network/LoopbackClient.d.ts.map +1 -1
- package/dist/network/LoopbackClient.mjs +3 -2
- package/dist/network/LoopbackClient.mjs.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/protocol/Authorize.d.ts +12 -0
- package/dist/protocol/Authorize.d.ts.map +1 -0
- package/dist/protocol/Authorize.mjs +42 -0
- package/dist/protocol/Authorize.mjs.map +1 -0
- package/dist/retry/LinearRetryPolicy.mjs +1 -1
- package/dist/utils/Constants.d.ts +5 -0
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.mjs +1 -1
- package/dist/utils/Constants.mjs.map +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 +1006 -1082
- package/lib/msal-node.cjs.map +1 -1
- package/lib/types/client/ClientApplication.d.ts +3 -3
- package/lib/types/client/ClientApplication.d.ts.map +1 -1
- package/lib/types/client/ClientCredentialClient.d.ts.map +1 -1
- package/lib/types/client/ConfidentialClientApplication.d.ts.map +1 -1
- package/lib/types/client/DeviceCodeClient.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentityApplication.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentityClient.d.ts +2 -1
- package/lib/types/client/ManagedIdentityClient.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/AppService.d.ts +2 -2
- package/lib/types/client/ManagedIdentitySources/AppService.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/AzureArc.d.ts +2 -2
- package/lib/types/client/ManagedIdentitySources/AzureArc.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +2 -1
- package/lib/types/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/CloudShell.d.ts +2 -2
- package/lib/types/client/ManagedIdentitySources/CloudShell.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/Imds.d.ts +2 -2
- package/lib/types/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/MachineLearning.d.ts +2 -2
- package/lib/types/client/ManagedIdentitySources/MachineLearning.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/ServiceFabric.d.ts +2 -2
- package/lib/types/client/ManagedIdentitySources/ServiceFabric.d.ts.map +1 -1
- package/lib/types/client/OnBehalfOfClient.d.ts.map +1 -1
- package/lib/types/client/PublicClientApplication.d.ts.map +1 -1
- package/lib/types/client/UsernamePasswordClient.d.ts.map +1 -1
- package/lib/types/config/Configuration.d.ts +1 -0
- package/lib/types/config/Configuration.d.ts.map +1 -1
- package/lib/types/config/ManagedIdentityRequestParameters.d.ts +3 -2
- package/lib/types/config/ManagedIdentityRequestParameters.d.ts.map +1 -1
- package/lib/types/index.d.ts +5 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/network/ILoopbackClient.d.ts +2 -2
- package/lib/types/network/ILoopbackClient.d.ts.map +1 -1
- package/lib/types/network/LoopbackClient.d.ts +2 -2
- package/lib/types/network/LoopbackClient.d.ts.map +1 -1
- package/lib/types/packageMetadata.d.ts +1 -1
- package/lib/types/protocol/Authorize.d.ts +12 -0
- package/lib/types/protocol/Authorize.d.ts.map +1 -0
- package/lib/types/utils/Constants.d.ts +5 -0
- package/lib/types/utils/Constants.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/client/ClientApplication.ts +42 -44
- package/src/client/ClientCredentialClient.ts +32 -14
- package/src/client/ConfidentialClientApplication.ts +15 -7
- package/src/client/DeviceCodeClient.ts +46 -24
- package/src/client/ManagedIdentityApplication.ts +2 -1
- package/src/client/ManagedIdentityClient.ts +20 -4
- package/src/client/ManagedIdentitySources/AppService.ts +11 -2
- package/src/client/ManagedIdentitySources/AzureArc.ts +10 -1
- package/src/client/ManagedIdentitySources/BaseManagedIdentitySource.ts +20 -4
- package/src/client/ManagedIdentitySources/CloudShell.ts +10 -1
- package/src/client/ManagedIdentitySources/Imds.ts +11 -2
- package/src/client/ManagedIdentitySources/MachineLearning.ts +11 -2
- package/src/client/ManagedIdentitySources/ServiceFabric.ts +10 -1
- package/src/client/OnBehalfOfClient.ts +38 -17
- package/src/client/PublicClientApplication.ts +9 -5
- package/src/client/UsernamePasswordClient.ts +37 -19
- package/src/config/Configuration.ts +2 -20
- package/src/config/ManagedIdentityRequestParameters.ts +38 -9
- package/src/index.ts +5 -2
- package/src/network/ILoopbackClient.ts +2 -2
- package/src/network/LoopbackClient.ts +43 -46
- package/src/packageMetadata.ts +1 -1
- package/src/protocol/Authorize.ts +63 -0
- package/src/utils/Constants.ts +6 -0
package/lib/msal-node.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-node v3.
|
|
1
|
+
/*! @azure/msal-node v3.4.0 2025-03-20 */
|
|
2
2
|
'use strict';
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
@@ -152,7 +152,7 @@ class Serializer {
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
/*! @azure/msal-common v15.
|
|
155
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
156
156
|
/*
|
|
157
157
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
158
158
|
* Licensed under the MIT License.
|
|
@@ -445,7 +445,7 @@ const CacheOutcome = {
|
|
|
445
445
|
// Token renewal offset default in seconds
|
|
446
446
|
const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
|
|
447
447
|
|
|
448
|
-
/*! @azure/msal-common v15.
|
|
448
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
449
449
|
/*
|
|
450
450
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
451
451
|
* Licensed under the MIT License.
|
|
@@ -462,7 +462,7 @@ var AuthErrorCodes = /*#__PURE__*/Object.freeze({
|
|
|
462
462
|
unexpectedError: unexpectedError
|
|
463
463
|
});
|
|
464
464
|
|
|
465
|
-
/*! @azure/msal-common v15.
|
|
465
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
466
466
|
|
|
467
467
|
/*
|
|
468
468
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -511,7 +511,7 @@ function createAuthError(code, additionalMessage) {
|
|
|
511
511
|
: AuthErrorMessages[code]);
|
|
512
512
|
}
|
|
513
513
|
|
|
514
|
-
/*! @azure/msal-common v15.
|
|
514
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
515
515
|
/*
|
|
516
516
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
517
517
|
* Licensed under the MIT License.
|
|
@@ -609,7 +609,7 @@ var ClientAuthErrorCodes = /*#__PURE__*/Object.freeze({
|
|
|
609
609
|
userTimeoutReached: userTimeoutReached
|
|
610
610
|
});
|
|
611
611
|
|
|
612
|
-
/*! @azure/msal-common v15.
|
|
612
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
613
613
|
|
|
614
614
|
/*
|
|
615
615
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -861,7 +861,7 @@ function createClientAuthError(errorCode, additionalMessage) {
|
|
|
861
861
|
return new ClientAuthError(errorCode, additionalMessage);
|
|
862
862
|
}
|
|
863
863
|
|
|
864
|
-
/*! @azure/msal-common v15.
|
|
864
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
865
865
|
|
|
866
866
|
/*
|
|
867
867
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -900,7 +900,7 @@ const DEFAULT_CRYPTO_IMPLEMENTATION = {
|
|
|
900
900
|
},
|
|
901
901
|
};
|
|
902
902
|
|
|
903
|
-
/*! @azure/msal-common v15.
|
|
903
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
904
904
|
|
|
905
905
|
/*
|
|
906
906
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1091,12 +1091,12 @@ class Logger {
|
|
|
1091
1091
|
}
|
|
1092
1092
|
}
|
|
1093
1093
|
|
|
1094
|
-
/*! @azure/msal-common v15.
|
|
1094
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
1095
1095
|
/* eslint-disable header/header */
|
|
1096
1096
|
const name$1 = "@azure/msal-common";
|
|
1097
|
-
const version$1 = "15.
|
|
1097
|
+
const version$1 = "15.3.0";
|
|
1098
1098
|
|
|
1099
|
-
/*! @azure/msal-common v15.
|
|
1099
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
1100
1100
|
/*
|
|
1101
1101
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1102
1102
|
* Licensed under the MIT License.
|
|
@@ -1116,7 +1116,7 @@ const AzureCloudInstance = {
|
|
|
1116
1116
|
AzureUsGovernment: "https://login.microsoftonline.us",
|
|
1117
1117
|
};
|
|
1118
1118
|
|
|
1119
|
-
/*! @azure/msal-common v15.
|
|
1119
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
1120
1120
|
|
|
1121
1121
|
/*
|
|
1122
1122
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1177,7 +1177,7 @@ function checkMaxAge(authTime, maxAge) {
|
|
|
1177
1177
|
}
|
|
1178
1178
|
}
|
|
1179
1179
|
|
|
1180
|
-
/*! @azure/msal-common v15.
|
|
1180
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
1181
1181
|
/*
|
|
1182
1182
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1183
1183
|
* Licensed under the MIT License.
|
|
@@ -1192,6 +1192,16 @@ function nowSeconds() {
|
|
|
1192
1192
|
// Date.getTime() returns in milliseconds.
|
|
1193
1193
|
return Math.round(new Date().getTime() / 1000.0);
|
|
1194
1194
|
}
|
|
1195
|
+
/**
|
|
1196
|
+
* Convert seconds to JS Date object. Seconds can be in a number or string format or undefined (will still return a date).
|
|
1197
|
+
* @param seconds
|
|
1198
|
+
*/
|
|
1199
|
+
function toDateFromSeconds(seconds) {
|
|
1200
|
+
if (seconds) {
|
|
1201
|
+
return new Date(Number(seconds) * 1000);
|
|
1202
|
+
}
|
|
1203
|
+
return new Date();
|
|
1204
|
+
}
|
|
1195
1205
|
/**
|
|
1196
1206
|
* check if a token is expired based on given UTC time in seconds.
|
|
1197
1207
|
* @param expiresOn
|
|
@@ -1222,7 +1232,7 @@ function delay(t, value) {
|
|
|
1222
1232
|
return new Promise((resolve) => setTimeout(() => resolve(value), t));
|
|
1223
1233
|
}
|
|
1224
1234
|
|
|
1225
|
-
/*! @azure/msal-common v15.
|
|
1235
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
1226
1236
|
|
|
1227
1237
|
/*
|
|
1228
1238
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1549,7 +1559,7 @@ function isAuthorityMetadataExpired(metadata) {
|
|
|
1549
1559
|
return metadata.expiresAt <= nowSeconds();
|
|
1550
1560
|
}
|
|
1551
1561
|
|
|
1552
|
-
/*! @azure/msal-common v15.
|
|
1562
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
1553
1563
|
/*
|
|
1554
1564
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1555
1565
|
* Licensed under the MIT License.
|
|
@@ -1603,7 +1613,7 @@ var ClientConfigurationErrorCodes = /*#__PURE__*/Object.freeze({
|
|
|
1603
1613
|
urlParseError: urlParseError
|
|
1604
1614
|
});
|
|
1605
1615
|
|
|
1606
|
-
/*! @azure/msal-common v15.
|
|
1616
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
1607
1617
|
|
|
1608
1618
|
/*
|
|
1609
1619
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -1741,7 +1751,7 @@ function createClientConfigurationError(errorCode) {
|
|
|
1741
1751
|
return new ClientConfigurationError(errorCode);
|
|
1742
1752
|
}
|
|
1743
1753
|
|
|
1744
|
-
/*! @azure/msal-common v15.
|
|
1754
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
1745
1755
|
/*
|
|
1746
1756
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
1747
1757
|
* Licensed under the MIT License.
|
|
@@ -1838,7 +1848,7 @@ class StringUtils {
|
|
|
1838
1848
|
}
|
|
1839
1849
|
}
|
|
1840
1850
|
|
|
1841
|
-
/*! @azure/msal-common v15.
|
|
1851
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
1842
1852
|
|
|
1843
1853
|
/*
|
|
1844
1854
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2029,7 +2039,7 @@ class ScopeSet {
|
|
|
2029
2039
|
}
|
|
2030
2040
|
}
|
|
2031
2041
|
|
|
2032
|
-
/*! @azure/msal-common v15.
|
|
2042
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
2033
2043
|
|
|
2034
2044
|
/*
|
|
2035
2045
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2069,7 +2079,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
|
|
|
2069
2079
|
};
|
|
2070
2080
|
}
|
|
2071
2081
|
|
|
2072
|
-
/*! @azure/msal-common v15.
|
|
2082
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
2073
2083
|
/*
|
|
2074
2084
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2075
2085
|
* Licensed under the MIT License.
|
|
@@ -2148,7 +2158,7 @@ function updateAccountTenantProfileData(baseAccountInfo, tenantProfile, idTokenC
|
|
|
2148
2158
|
return updatedAccountInfo;
|
|
2149
2159
|
}
|
|
2150
2160
|
|
|
2151
|
-
/*! @azure/msal-common v15.
|
|
2161
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
2152
2162
|
/*
|
|
2153
2163
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2154
2164
|
* Licensed under the MIT License.
|
|
@@ -2163,7 +2173,7 @@ const AuthorityType = {
|
|
|
2163
2173
|
Ciam: 3,
|
|
2164
2174
|
};
|
|
2165
2175
|
|
|
2166
|
-
/*! @azure/msal-common v15.
|
|
2176
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
2167
2177
|
/*
|
|
2168
2178
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2169
2179
|
* Licensed under the MIT License.
|
|
@@ -2185,7 +2195,7 @@ function getTenantIdFromIdTokenClaims(idTokenClaims) {
|
|
|
2185
2195
|
return null;
|
|
2186
2196
|
}
|
|
2187
2197
|
|
|
2188
|
-
/*! @azure/msal-common v15.
|
|
2198
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
2189
2199
|
/*
|
|
2190
2200
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2191
2201
|
* Licensed under the MIT License.
|
|
@@ -2198,7 +2208,7 @@ const ProtocolMode = {
|
|
|
2198
2208
|
OIDC: "OIDC",
|
|
2199
2209
|
};
|
|
2200
2210
|
|
|
2201
|
-
/*! @azure/msal-common v15.
|
|
2211
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
2202
2212
|
|
|
2203
2213
|
/*
|
|
2204
2214
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2441,7 +2451,7 @@ class AccountEntity {
|
|
|
2441
2451
|
}
|
|
2442
2452
|
}
|
|
2443
2453
|
|
|
2444
|
-
/*! @azure/msal-common v15.
|
|
2454
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
2445
2455
|
|
|
2446
2456
|
/*
|
|
2447
2457
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2486,9 +2496,19 @@ function getDeserializedResponse(responseString) {
|
|
|
2486
2496
|
throw createClientAuthError(hashNotDeserialized);
|
|
2487
2497
|
}
|
|
2488
2498
|
return null;
|
|
2499
|
+
}
|
|
2500
|
+
/**
|
|
2501
|
+
* Utility to create a URL from the params map
|
|
2502
|
+
*/
|
|
2503
|
+
function mapToQueryString(parameters) {
|
|
2504
|
+
const queryParameterArray = new Array();
|
|
2505
|
+
parameters.forEach((value, key) => {
|
|
2506
|
+
queryParameterArray.push(`${key}=${encodeURIComponent(value)}`);
|
|
2507
|
+
});
|
|
2508
|
+
return queryParameterArray.join("&");
|
|
2489
2509
|
}
|
|
2490
2510
|
|
|
2491
|
-
/*! @azure/msal-common v15.
|
|
2511
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
2492
2512
|
|
|
2493
2513
|
/*
|
|
2494
2514
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2652,7 +2672,7 @@ class UrlString {
|
|
|
2652
2672
|
}
|
|
2653
2673
|
}
|
|
2654
2674
|
|
|
2655
|
-
/*! @azure/msal-common v15.
|
|
2675
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
2656
2676
|
|
|
2657
2677
|
/*
|
|
2658
2678
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2792,7 +2812,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
|
|
|
2792
2812
|
return null;
|
|
2793
2813
|
}
|
|
2794
2814
|
|
|
2795
|
-
/*! @azure/msal-common v15.
|
|
2815
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
2796
2816
|
/*
|
|
2797
2817
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
2798
2818
|
* Licensed under the MIT License.
|
|
@@ -2800,7 +2820,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
|
|
|
2800
2820
|
const cacheQuotaExceededErrorCode = "cache_quota_exceeded";
|
|
2801
2821
|
const cacheUnknownErrorCode = "cache_error_unknown";
|
|
2802
2822
|
|
|
2803
|
-
/*! @azure/msal-common v15.
|
|
2823
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
2804
2824
|
|
|
2805
2825
|
/*
|
|
2806
2826
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -2827,7 +2847,7 @@ class CacheError extends Error {
|
|
|
2827
2847
|
}
|
|
2828
2848
|
}
|
|
2829
2849
|
|
|
2830
|
-
/*! @azure/msal-common v15.
|
|
2850
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
2831
2851
|
|
|
2832
2852
|
/*
|
|
2833
2853
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4011,7 +4031,7 @@ class DefaultStorageClass extends CacheManager {
|
|
|
4011
4031
|
}
|
|
4012
4032
|
}
|
|
4013
4033
|
|
|
4014
|
-
/*! @azure/msal-common v15.
|
|
4034
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
4015
4035
|
|
|
4016
4036
|
/*
|
|
4017
4037
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4110,7 +4130,7 @@ function isOidcProtocolMode(config) {
|
|
|
4110
4130
|
return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
|
|
4111
4131
|
}
|
|
4112
4132
|
|
|
4113
|
-
/*! @azure/msal-common v15.
|
|
4133
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
4114
4134
|
/*
|
|
4115
4135
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4116
4136
|
* Licensed under the MIT License.
|
|
@@ -4120,7 +4140,7 @@ const CcsCredentialType = {
|
|
|
4120
4140
|
UPN: "UPN",
|
|
4121
4141
|
};
|
|
4122
4142
|
|
|
4123
|
-
/*! @azure/msal-common v15.
|
|
4143
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
4124
4144
|
/*
|
|
4125
4145
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4126
4146
|
* Licensed under the MIT License.
|
|
@@ -4162,83 +4182,16 @@ const OBO_ASSERTION = "assertion";
|
|
|
4162
4182
|
const REQUESTED_TOKEN_USE = "requested_token_use";
|
|
4163
4183
|
const ON_BEHALF_OF = "on_behalf_of";
|
|
4164
4184
|
const RETURN_SPA_CODE = "return_spa_code";
|
|
4165
|
-
const NATIVE_BROKER = "nativebroker";
|
|
4166
4185
|
const LOGOUT_HINT = "logout_hint";
|
|
4167
4186
|
const SID = "sid";
|
|
4168
4187
|
const LOGIN_HINT = "login_hint";
|
|
4169
4188
|
const DOMAIN_HINT = "domain_hint";
|
|
4170
4189
|
const X_CLIENT_EXTRA_SKU = "x-client-xtra-sku";
|
|
4171
4190
|
const BROKER_CLIENT_ID = "brk_client_id";
|
|
4172
|
-
const BROKER_REDIRECT_URI = "brk_redirect_uri";
|
|
4173
|
-
|
|
4174
|
-
/*! @azure/msal-common v15.2.0 2025-02-18 */
|
|
4175
|
-
|
|
4176
|
-
/*
|
|
4177
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4178
|
-
* Licensed under the MIT License.
|
|
4179
|
-
*/
|
|
4180
|
-
/**
|
|
4181
|
-
* Validates server consumable params from the "request" objects
|
|
4182
|
-
*/
|
|
4183
|
-
class RequestValidator {
|
|
4184
|
-
/**
|
|
4185
|
-
* Utility to check if the `redirectUri` in the request is a non-null value
|
|
4186
|
-
* @param redirectUri
|
|
4187
|
-
*/
|
|
4188
|
-
static validateRedirectUri(redirectUri) {
|
|
4189
|
-
if (!redirectUri) {
|
|
4190
|
-
throw createClientConfigurationError(redirectUriEmpty);
|
|
4191
|
-
}
|
|
4192
|
-
}
|
|
4193
|
-
/**
|
|
4194
|
-
* Utility to validate prompt sent by the user in the request
|
|
4195
|
-
* @param prompt
|
|
4196
|
-
*/
|
|
4197
|
-
static validatePrompt(prompt) {
|
|
4198
|
-
const promptValues = [];
|
|
4199
|
-
for (const value in PromptValue) {
|
|
4200
|
-
promptValues.push(PromptValue[value]);
|
|
4201
|
-
}
|
|
4202
|
-
if (promptValues.indexOf(prompt) < 0) {
|
|
4203
|
-
throw createClientConfigurationError(invalidPromptValue);
|
|
4204
|
-
}
|
|
4205
|
-
}
|
|
4206
|
-
static validateClaims(claims) {
|
|
4207
|
-
try {
|
|
4208
|
-
JSON.parse(claims);
|
|
4209
|
-
}
|
|
4210
|
-
catch (e) {
|
|
4211
|
-
throw createClientConfigurationError(invalidClaims);
|
|
4212
|
-
}
|
|
4213
|
-
}
|
|
4214
|
-
/**
|
|
4215
|
-
* Utility to validate code_challenge and code_challenge_method
|
|
4216
|
-
* @param codeChallenge
|
|
4217
|
-
* @param codeChallengeMethod
|
|
4218
|
-
*/
|
|
4219
|
-
static validateCodeChallengeParams(codeChallenge, codeChallengeMethod) {
|
|
4220
|
-
if (!codeChallenge || !codeChallengeMethod) {
|
|
4221
|
-
throw createClientConfigurationError(pkceParamsMissing);
|
|
4222
|
-
}
|
|
4223
|
-
else {
|
|
4224
|
-
this.validateCodeChallengeMethod(codeChallengeMethod);
|
|
4225
|
-
}
|
|
4226
|
-
}
|
|
4227
|
-
/**
|
|
4228
|
-
* Utility to validate code_challenge_method
|
|
4229
|
-
* @param codeChallengeMethod
|
|
4230
|
-
*/
|
|
4231
|
-
static validateCodeChallengeMethod(codeChallengeMethod) {
|
|
4232
|
-
if ([
|
|
4233
|
-
CodeChallengeMethodValues.PLAIN,
|
|
4234
|
-
CodeChallengeMethodValues.S256,
|
|
4235
|
-
].indexOf(codeChallengeMethod) < 0) {
|
|
4236
|
-
throw createClientConfigurationError(invalidCodeChallengeMethod);
|
|
4237
|
-
}
|
|
4238
|
-
}
|
|
4239
|
-
}
|
|
4191
|
+
const BROKER_REDIRECT_URI = "brk_redirect_uri";
|
|
4192
|
+
const INSTANCE_AWARE = "instance_aware";
|
|
4240
4193
|
|
|
4241
|
-
/*! @azure/msal-common v15.
|
|
4194
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
4242
4195
|
|
|
4243
4196
|
/*
|
|
4244
4197
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -4256,397 +4209,379 @@ function instrumentBrokerParams(parameters, correlationId, performanceClient) {
|
|
|
4256
4209
|
}, correlationId);
|
|
4257
4210
|
}
|
|
4258
4211
|
}
|
|
4259
|
-
/**
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
|
|
4282
|
-
|
|
4283
|
-
|
|
4284
|
-
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4212
|
+
/**
|
|
4213
|
+
* add response_type = code
|
|
4214
|
+
*/
|
|
4215
|
+
function addResponseTypeCode(parameters) {
|
|
4216
|
+
parameters.set(RESPONSE_TYPE, Constants$1.CODE_RESPONSE_TYPE);
|
|
4217
|
+
}
|
|
4218
|
+
/**
|
|
4219
|
+
* add response_type = token id_token
|
|
4220
|
+
*/
|
|
4221
|
+
function addResponseTypeForTokenAndIdToken(parameters) {
|
|
4222
|
+
parameters.set(RESPONSE_TYPE, `${Constants$1.TOKEN_RESPONSE_TYPE} ${Constants$1.ID_TOKEN_RESPONSE_TYPE}`);
|
|
4223
|
+
}
|
|
4224
|
+
/**
|
|
4225
|
+
* add response_mode. defaults to query.
|
|
4226
|
+
* @param responseMode
|
|
4227
|
+
*/
|
|
4228
|
+
function addResponseMode(parameters, responseMode) {
|
|
4229
|
+
parameters.set(RESPONSE_MODE, responseMode ? responseMode : ResponseMode.QUERY);
|
|
4230
|
+
}
|
|
4231
|
+
/**
|
|
4232
|
+
* add scopes. set addOidcScopes to false to prevent default scopes in non-user scenarios
|
|
4233
|
+
* @param scopeSet
|
|
4234
|
+
* @param addOidcScopes
|
|
4235
|
+
*/
|
|
4236
|
+
function addScopes(parameters, scopes, addOidcScopes = true, defaultScopes = OIDC_DEFAULT_SCOPES) {
|
|
4237
|
+
// Always add openid to the scopes when adding OIDC scopes
|
|
4238
|
+
if (addOidcScopes &&
|
|
4239
|
+
!defaultScopes.includes("openid") &&
|
|
4240
|
+
!scopes.includes("openid")) {
|
|
4241
|
+
defaultScopes.push("openid");
|
|
4242
|
+
}
|
|
4243
|
+
const requestScopes = addOidcScopes
|
|
4244
|
+
? [...(scopes || []), ...defaultScopes]
|
|
4245
|
+
: scopes || [];
|
|
4246
|
+
const scopeSet = new ScopeSet(requestScopes);
|
|
4247
|
+
parameters.set(SCOPE, scopeSet.printScopes());
|
|
4248
|
+
}
|
|
4249
|
+
/**
|
|
4250
|
+
* add clientId
|
|
4251
|
+
* @param clientId
|
|
4252
|
+
*/
|
|
4253
|
+
function addClientId(parameters, clientId) {
|
|
4254
|
+
parameters.set(CLIENT_ID, clientId);
|
|
4255
|
+
}
|
|
4256
|
+
/**
|
|
4257
|
+
* add redirect_uri
|
|
4258
|
+
* @param redirectUri
|
|
4259
|
+
*/
|
|
4260
|
+
function addRedirectUri(parameters, redirectUri) {
|
|
4261
|
+
parameters.set(REDIRECT_URI, redirectUri);
|
|
4262
|
+
}
|
|
4263
|
+
/**
|
|
4264
|
+
* add post logout redirectUri
|
|
4265
|
+
* @param redirectUri
|
|
4266
|
+
*/
|
|
4267
|
+
function addPostLogoutRedirectUri(parameters, redirectUri) {
|
|
4268
|
+
parameters.set(POST_LOGOUT_URI, redirectUri);
|
|
4269
|
+
}
|
|
4270
|
+
/**
|
|
4271
|
+
* add id_token_hint to logout request
|
|
4272
|
+
* @param idTokenHint
|
|
4273
|
+
*/
|
|
4274
|
+
function addIdTokenHint(parameters, idTokenHint) {
|
|
4275
|
+
parameters.set(ID_TOKEN_HINT, idTokenHint);
|
|
4276
|
+
}
|
|
4277
|
+
/**
|
|
4278
|
+
* add domain_hint
|
|
4279
|
+
* @param domainHint
|
|
4280
|
+
*/
|
|
4281
|
+
function addDomainHint(parameters, domainHint) {
|
|
4282
|
+
parameters.set(DOMAIN_HINT, domainHint);
|
|
4283
|
+
}
|
|
4284
|
+
/**
|
|
4285
|
+
* add login_hint
|
|
4286
|
+
* @param loginHint
|
|
4287
|
+
*/
|
|
4288
|
+
function addLoginHint(parameters, loginHint) {
|
|
4289
|
+
parameters.set(LOGIN_HINT, loginHint);
|
|
4290
|
+
}
|
|
4291
|
+
/**
|
|
4292
|
+
* Adds the CCS (Cache Credential Service) query parameter for login_hint
|
|
4293
|
+
* @param loginHint
|
|
4294
|
+
*/
|
|
4295
|
+
function addCcsUpn(parameters, loginHint) {
|
|
4296
|
+
parameters.set(HeaderNames.CCS_HEADER, `UPN:${loginHint}`);
|
|
4297
|
+
}
|
|
4298
|
+
/**
|
|
4299
|
+
* Adds the CCS (Cache Credential Service) query parameter for account object
|
|
4300
|
+
* @param loginHint
|
|
4301
|
+
*/
|
|
4302
|
+
function addCcsOid(parameters, clientInfo) {
|
|
4303
|
+
parameters.set(HeaderNames.CCS_HEADER, `Oid:${clientInfo.uid}@${clientInfo.utid}`);
|
|
4304
|
+
}
|
|
4305
|
+
/**
|
|
4306
|
+
* add sid
|
|
4307
|
+
* @param sid
|
|
4308
|
+
*/
|
|
4309
|
+
function addSid(parameters, sid) {
|
|
4310
|
+
parameters.set(SID, sid);
|
|
4311
|
+
}
|
|
4312
|
+
/**
|
|
4313
|
+
* add claims
|
|
4314
|
+
* @param claims
|
|
4315
|
+
*/
|
|
4316
|
+
function addClaims(parameters, claims, clientCapabilities) {
|
|
4317
|
+
const mergedClaims = addClientCapabilitiesToClaims(claims, clientCapabilities);
|
|
4318
|
+
try {
|
|
4319
|
+
JSON.parse(mergedClaims);
|
|
4308
4320
|
}
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
* @param clientId
|
|
4312
|
-
*/
|
|
4313
|
-
addClientId(clientId) {
|
|
4314
|
-
this.parameters.set(CLIENT_ID, encodeURIComponent(clientId));
|
|
4321
|
+
catch (e) {
|
|
4322
|
+
throw createClientConfigurationError(invalidClaims);
|
|
4315
4323
|
}
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4324
|
+
parameters.set(CLAIMS, mergedClaims);
|
|
4325
|
+
}
|
|
4326
|
+
/**
|
|
4327
|
+
* add correlationId
|
|
4328
|
+
* @param correlationId
|
|
4329
|
+
*/
|
|
4330
|
+
function addCorrelationId(parameters, correlationId) {
|
|
4331
|
+
parameters.set(CLIENT_REQUEST_ID, correlationId);
|
|
4332
|
+
}
|
|
4333
|
+
/**
|
|
4334
|
+
* add library info query params
|
|
4335
|
+
* @param libraryInfo
|
|
4336
|
+
*/
|
|
4337
|
+
function addLibraryInfo(parameters, libraryInfo) {
|
|
4338
|
+
// Telemetry Info
|
|
4339
|
+
parameters.set(X_CLIENT_SKU, libraryInfo.sku);
|
|
4340
|
+
parameters.set(X_CLIENT_VER, libraryInfo.version);
|
|
4341
|
+
if (libraryInfo.os) {
|
|
4342
|
+
parameters.set(X_CLIENT_OS, libraryInfo.os);
|
|
4323
4343
|
}
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
* @param redirectUri
|
|
4327
|
-
*/
|
|
4328
|
-
addPostLogoutRedirectUri(redirectUri) {
|
|
4329
|
-
RequestValidator.validateRedirectUri(redirectUri);
|
|
4330
|
-
this.parameters.set(POST_LOGOUT_URI, encodeURIComponent(redirectUri));
|
|
4344
|
+
if (libraryInfo.cpu) {
|
|
4345
|
+
parameters.set(X_CLIENT_CPU, libraryInfo.cpu);
|
|
4331
4346
|
}
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
|
|
4347
|
+
}
|
|
4348
|
+
/**
|
|
4349
|
+
* Add client telemetry parameters
|
|
4350
|
+
* @param appTelemetry
|
|
4351
|
+
*/
|
|
4352
|
+
function addApplicationTelemetry(parameters, appTelemetry) {
|
|
4353
|
+
if (appTelemetry?.appName) {
|
|
4354
|
+
parameters.set(X_APP_NAME, appTelemetry.appName);
|
|
4338
4355
|
}
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
* @param domainHint
|
|
4342
|
-
*/
|
|
4343
|
-
addDomainHint(domainHint) {
|
|
4344
|
-
this.parameters.set(DOMAIN_HINT, encodeURIComponent(domainHint));
|
|
4356
|
+
if (appTelemetry?.appVersion) {
|
|
4357
|
+
parameters.set(X_APP_VER, appTelemetry.appVersion);
|
|
4345
4358
|
}
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4359
|
+
}
|
|
4360
|
+
/**
|
|
4361
|
+
* add prompt
|
|
4362
|
+
* @param prompt
|
|
4363
|
+
*/
|
|
4364
|
+
function addPrompt(parameters, prompt) {
|
|
4365
|
+
parameters.set(PROMPT, prompt);
|
|
4366
|
+
}
|
|
4367
|
+
/**
|
|
4368
|
+
* add state
|
|
4369
|
+
* @param state
|
|
4370
|
+
*/
|
|
4371
|
+
function addState(parameters, state) {
|
|
4372
|
+
if (state) {
|
|
4373
|
+
parameters.set(STATE, state);
|
|
4352
4374
|
}
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4375
|
+
}
|
|
4376
|
+
/**
|
|
4377
|
+
* add nonce
|
|
4378
|
+
* @param nonce
|
|
4379
|
+
*/
|
|
4380
|
+
function addNonce(parameters, nonce) {
|
|
4381
|
+
parameters.set(NONCE, nonce);
|
|
4382
|
+
}
|
|
4383
|
+
/**
|
|
4384
|
+
* add code_challenge and code_challenge_method
|
|
4385
|
+
* - throw if either of them are not passed
|
|
4386
|
+
* @param codeChallenge
|
|
4387
|
+
* @param codeChallengeMethod
|
|
4388
|
+
*/
|
|
4389
|
+
function addCodeChallengeParams(parameters, codeChallenge, codeChallengeMethod) {
|
|
4390
|
+
if (codeChallenge && codeChallengeMethod) {
|
|
4391
|
+
parameters.set(CODE_CHALLENGE, codeChallenge);
|
|
4392
|
+
parameters.set(CODE_CHALLENGE_METHOD, codeChallengeMethod);
|
|
4359
4393
|
}
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
* @param loginHint
|
|
4363
|
-
*/
|
|
4364
|
-
addCcsOid(clientInfo) {
|
|
4365
|
-
this.parameters.set(HeaderNames.CCS_HEADER, encodeURIComponent(`Oid:${clientInfo.uid}@${clientInfo.utid}`));
|
|
4394
|
+
else {
|
|
4395
|
+
throw createClientConfigurationError(pkceParamsMissing);
|
|
4366
4396
|
}
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4397
|
+
}
|
|
4398
|
+
/**
|
|
4399
|
+
* add the `authorization_code` passed by the user to exchange for a token
|
|
4400
|
+
* @param code
|
|
4401
|
+
*/
|
|
4402
|
+
function addAuthorizationCode(parameters, code) {
|
|
4403
|
+
parameters.set(CODE, code);
|
|
4404
|
+
}
|
|
4405
|
+
/**
|
|
4406
|
+
* add the `authorization_code` passed by the user to exchange for a token
|
|
4407
|
+
* @param code
|
|
4408
|
+
*/
|
|
4409
|
+
function addDeviceCode(parameters, code) {
|
|
4410
|
+
parameters.set(DEVICE_CODE, code);
|
|
4411
|
+
}
|
|
4412
|
+
/**
|
|
4413
|
+
* add the `refreshToken` passed by the user
|
|
4414
|
+
* @param refreshToken
|
|
4415
|
+
*/
|
|
4416
|
+
function addRefreshToken(parameters, refreshToken) {
|
|
4417
|
+
parameters.set(REFRESH_TOKEN, refreshToken);
|
|
4418
|
+
}
|
|
4419
|
+
/**
|
|
4420
|
+
* add the `code_verifier` passed by the user to exchange for a token
|
|
4421
|
+
* @param codeVerifier
|
|
4422
|
+
*/
|
|
4423
|
+
function addCodeVerifier(parameters, codeVerifier) {
|
|
4424
|
+
parameters.set(CODE_VERIFIER, codeVerifier);
|
|
4425
|
+
}
|
|
4426
|
+
/**
|
|
4427
|
+
* add client_secret
|
|
4428
|
+
* @param clientSecret
|
|
4429
|
+
*/
|
|
4430
|
+
function addClientSecret(parameters, clientSecret) {
|
|
4431
|
+
parameters.set(CLIENT_SECRET, clientSecret);
|
|
4432
|
+
}
|
|
4433
|
+
/**
|
|
4434
|
+
* add clientAssertion for confidential client flows
|
|
4435
|
+
* @param clientAssertion
|
|
4436
|
+
*/
|
|
4437
|
+
function addClientAssertion(parameters, clientAssertion) {
|
|
4438
|
+
if (clientAssertion) {
|
|
4439
|
+
parameters.set(CLIENT_ASSERTION, clientAssertion);
|
|
4373
4440
|
}
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4441
|
+
}
|
|
4442
|
+
/**
|
|
4443
|
+
* add clientAssertionType for confidential client flows
|
|
4444
|
+
* @param clientAssertionType
|
|
4445
|
+
*/
|
|
4446
|
+
function addClientAssertionType(parameters, clientAssertionType) {
|
|
4447
|
+
if (clientAssertionType) {
|
|
4448
|
+
parameters.set(CLIENT_ASSERTION_TYPE, clientAssertionType);
|
|
4382
4449
|
}
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4450
|
+
}
|
|
4451
|
+
/**
|
|
4452
|
+
* add OBO assertion for confidential client flows
|
|
4453
|
+
* @param clientAssertion
|
|
4454
|
+
*/
|
|
4455
|
+
function addOboAssertion(parameters, oboAssertion) {
|
|
4456
|
+
parameters.set(OBO_ASSERTION, oboAssertion);
|
|
4457
|
+
}
|
|
4458
|
+
/**
|
|
4459
|
+
* add grant type
|
|
4460
|
+
* @param grantType
|
|
4461
|
+
*/
|
|
4462
|
+
function addRequestTokenUse(parameters, tokenUse) {
|
|
4463
|
+
parameters.set(REQUESTED_TOKEN_USE, tokenUse);
|
|
4464
|
+
}
|
|
4465
|
+
/**
|
|
4466
|
+
* add grant type
|
|
4467
|
+
* @param grantType
|
|
4468
|
+
*/
|
|
4469
|
+
function addGrantType(parameters, grantType) {
|
|
4470
|
+
parameters.set(GRANT_TYPE, grantType);
|
|
4471
|
+
}
|
|
4472
|
+
/**
|
|
4473
|
+
* add client info
|
|
4474
|
+
*
|
|
4475
|
+
*/
|
|
4476
|
+
function addClientInfo(parameters) {
|
|
4477
|
+
parameters.set(CLIENT_INFO, "1");
|
|
4478
|
+
}
|
|
4479
|
+
function addInstanceAware(parameters) {
|
|
4480
|
+
if (!parameters.has(INSTANCE_AWARE)) {
|
|
4481
|
+
parameters.set(INSTANCE_AWARE, "true");
|
|
4389
4482
|
}
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
this.parameters.set(X_CLIENT_OS, libraryInfo.os);
|
|
4400
|
-
}
|
|
4401
|
-
if (libraryInfo.cpu) {
|
|
4402
|
-
this.parameters.set(X_CLIENT_CPU, libraryInfo.cpu);
|
|
4483
|
+
}
|
|
4484
|
+
/**
|
|
4485
|
+
* add extraQueryParams
|
|
4486
|
+
* @param eQParams
|
|
4487
|
+
*/
|
|
4488
|
+
function addExtraQueryParameters(parameters, eQParams) {
|
|
4489
|
+
Object.entries(eQParams).forEach(([key, value]) => {
|
|
4490
|
+
if (!parameters.has(key) && value) {
|
|
4491
|
+
parameters.set(key, value);
|
|
4403
4492
|
}
|
|
4493
|
+
});
|
|
4494
|
+
}
|
|
4495
|
+
function addClientCapabilitiesToClaims(claims, clientCapabilities) {
|
|
4496
|
+
let mergedClaims;
|
|
4497
|
+
// Parse provided claims into JSON object or initialize empty object
|
|
4498
|
+
if (!claims) {
|
|
4499
|
+
mergedClaims = {};
|
|
4404
4500
|
}
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
*/
|
|
4409
|
-
addApplicationTelemetry(appTelemetry) {
|
|
4410
|
-
if (appTelemetry?.appName) {
|
|
4411
|
-
this.parameters.set(X_APP_NAME, appTelemetry.appName);
|
|
4501
|
+
else {
|
|
4502
|
+
try {
|
|
4503
|
+
mergedClaims = JSON.parse(claims);
|
|
4412
4504
|
}
|
|
4413
|
-
|
|
4414
|
-
|
|
4505
|
+
catch (e) {
|
|
4506
|
+
throw createClientConfigurationError(invalidClaims);
|
|
4415
4507
|
}
|
|
4416
4508
|
}
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
addPrompt(prompt) {
|
|
4422
|
-
RequestValidator.validatePrompt(prompt);
|
|
4423
|
-
this.parameters.set(`${PROMPT}`, encodeURIComponent(prompt));
|
|
4424
|
-
}
|
|
4425
|
-
/**
|
|
4426
|
-
* add state
|
|
4427
|
-
* @param state
|
|
4428
|
-
*/
|
|
4429
|
-
addState(state) {
|
|
4430
|
-
if (state) {
|
|
4431
|
-
this.parameters.set(STATE, encodeURIComponent(state));
|
|
4509
|
+
if (clientCapabilities && clientCapabilities.length > 0) {
|
|
4510
|
+
if (!mergedClaims.hasOwnProperty(ClaimsRequestKeys.ACCESS_TOKEN)) {
|
|
4511
|
+
// Add access_token key to claims object
|
|
4512
|
+
mergedClaims[ClaimsRequestKeys.ACCESS_TOKEN] = {};
|
|
4432
4513
|
}
|
|
4514
|
+
// Add xms_cc claim with provided clientCapabilities to access_token key
|
|
4515
|
+
mergedClaims[ClaimsRequestKeys.ACCESS_TOKEN][ClaimsRequestKeys.XMS_CC] =
|
|
4516
|
+
{
|
|
4517
|
+
values: clientCapabilities,
|
|
4518
|
+
};
|
|
4433
4519
|
}
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
* add the `authorization_code` passed by the user to exchange for a token
|
|
4459
|
-
* @param code
|
|
4460
|
-
*/
|
|
4461
|
-
addAuthorizationCode(code) {
|
|
4462
|
-
this.parameters.set(CODE, encodeURIComponent(code));
|
|
4463
|
-
}
|
|
4464
|
-
/**
|
|
4465
|
-
* add the `authorization_code` passed by the user to exchange for a token
|
|
4466
|
-
* @param code
|
|
4467
|
-
*/
|
|
4468
|
-
addDeviceCode(code) {
|
|
4469
|
-
this.parameters.set(DEVICE_CODE, encodeURIComponent(code));
|
|
4470
|
-
}
|
|
4471
|
-
/**
|
|
4472
|
-
* add the `refreshToken` passed by the user
|
|
4473
|
-
* @param refreshToken
|
|
4474
|
-
*/
|
|
4475
|
-
addRefreshToken(refreshToken) {
|
|
4476
|
-
this.parameters.set(REFRESH_TOKEN, encodeURIComponent(refreshToken));
|
|
4477
|
-
}
|
|
4478
|
-
/**
|
|
4479
|
-
* add the `code_verifier` passed by the user to exchange for a token
|
|
4480
|
-
* @param codeVerifier
|
|
4481
|
-
*/
|
|
4482
|
-
addCodeVerifier(codeVerifier) {
|
|
4483
|
-
this.parameters.set(CODE_VERIFIER, encodeURIComponent(codeVerifier));
|
|
4484
|
-
}
|
|
4485
|
-
/**
|
|
4486
|
-
* add client_secret
|
|
4487
|
-
* @param clientSecret
|
|
4488
|
-
*/
|
|
4489
|
-
addClientSecret(clientSecret) {
|
|
4490
|
-
this.parameters.set(CLIENT_SECRET, encodeURIComponent(clientSecret));
|
|
4491
|
-
}
|
|
4492
|
-
/**
|
|
4493
|
-
* add clientAssertion for confidential client flows
|
|
4494
|
-
* @param clientAssertion
|
|
4495
|
-
*/
|
|
4496
|
-
addClientAssertion(clientAssertion) {
|
|
4497
|
-
if (clientAssertion) {
|
|
4498
|
-
this.parameters.set(CLIENT_ASSERTION, encodeURIComponent(clientAssertion));
|
|
4499
|
-
}
|
|
4500
|
-
}
|
|
4501
|
-
/**
|
|
4502
|
-
* add clientAssertionType for confidential client flows
|
|
4503
|
-
* @param clientAssertionType
|
|
4504
|
-
*/
|
|
4505
|
-
addClientAssertionType(clientAssertionType) {
|
|
4506
|
-
if (clientAssertionType) {
|
|
4507
|
-
this.parameters.set(CLIENT_ASSERTION_TYPE, encodeURIComponent(clientAssertionType));
|
|
4508
|
-
}
|
|
4509
|
-
}
|
|
4510
|
-
/**
|
|
4511
|
-
* add OBO assertion for confidential client flows
|
|
4512
|
-
* @param clientAssertion
|
|
4513
|
-
*/
|
|
4514
|
-
addOboAssertion(oboAssertion) {
|
|
4515
|
-
this.parameters.set(OBO_ASSERTION, encodeURIComponent(oboAssertion));
|
|
4516
|
-
}
|
|
4517
|
-
/**
|
|
4518
|
-
* add grant type
|
|
4519
|
-
* @param grantType
|
|
4520
|
-
*/
|
|
4521
|
-
addRequestTokenUse(tokenUse) {
|
|
4522
|
-
this.parameters.set(REQUESTED_TOKEN_USE, encodeURIComponent(tokenUse));
|
|
4523
|
-
}
|
|
4524
|
-
/**
|
|
4525
|
-
* add grant type
|
|
4526
|
-
* @param grantType
|
|
4527
|
-
*/
|
|
4528
|
-
addGrantType(grantType) {
|
|
4529
|
-
this.parameters.set(GRANT_TYPE, encodeURIComponent(grantType));
|
|
4530
|
-
}
|
|
4531
|
-
/**
|
|
4532
|
-
* add client info
|
|
4533
|
-
*
|
|
4534
|
-
*/
|
|
4535
|
-
addClientInfo() {
|
|
4536
|
-
this.parameters.set(CLIENT_INFO, "1");
|
|
4537
|
-
}
|
|
4538
|
-
/**
|
|
4539
|
-
* add extraQueryParams
|
|
4540
|
-
* @param eQParams
|
|
4541
|
-
*/
|
|
4542
|
-
addExtraQueryParameters(eQParams) {
|
|
4543
|
-
Object.entries(eQParams).forEach(([key, value]) => {
|
|
4544
|
-
if (!this.parameters.has(key) && value) {
|
|
4545
|
-
this.parameters.set(key, value);
|
|
4546
|
-
}
|
|
4547
|
-
});
|
|
4548
|
-
}
|
|
4549
|
-
addClientCapabilitiesToClaims(claims, clientCapabilities) {
|
|
4550
|
-
let mergedClaims;
|
|
4551
|
-
// Parse provided claims into JSON object or initialize empty object
|
|
4552
|
-
if (!claims) {
|
|
4553
|
-
mergedClaims = {};
|
|
4554
|
-
}
|
|
4555
|
-
else {
|
|
4556
|
-
try {
|
|
4557
|
-
mergedClaims = JSON.parse(claims);
|
|
4558
|
-
}
|
|
4559
|
-
catch (e) {
|
|
4560
|
-
throw createClientConfigurationError(invalidClaims);
|
|
4561
|
-
}
|
|
4562
|
-
}
|
|
4563
|
-
if (clientCapabilities && clientCapabilities.length > 0) {
|
|
4564
|
-
if (!mergedClaims.hasOwnProperty(ClaimsRequestKeys.ACCESS_TOKEN)) {
|
|
4565
|
-
// Add access_token key to claims object
|
|
4566
|
-
mergedClaims[ClaimsRequestKeys.ACCESS_TOKEN] = {};
|
|
4567
|
-
}
|
|
4568
|
-
// Add xms_cc claim with provided clientCapabilities to access_token key
|
|
4569
|
-
mergedClaims[ClaimsRequestKeys.ACCESS_TOKEN][ClaimsRequestKeys.XMS_CC] = {
|
|
4570
|
-
values: clientCapabilities,
|
|
4571
|
-
};
|
|
4572
|
-
}
|
|
4573
|
-
return JSON.stringify(mergedClaims);
|
|
4574
|
-
}
|
|
4575
|
-
/**
|
|
4576
|
-
* adds `username` for Password Grant flow
|
|
4577
|
-
* @param username
|
|
4578
|
-
*/
|
|
4579
|
-
addUsername(username) {
|
|
4580
|
-
this.parameters.set(PasswordGrantConstants.username, encodeURIComponent(username));
|
|
4581
|
-
}
|
|
4582
|
-
/**
|
|
4583
|
-
* adds `password` for Password Grant flow
|
|
4584
|
-
* @param password
|
|
4585
|
-
*/
|
|
4586
|
-
addPassword(password) {
|
|
4587
|
-
this.parameters.set(PasswordGrantConstants.password, encodeURIComponent(password));
|
|
4588
|
-
}
|
|
4589
|
-
/**
|
|
4590
|
-
* add pop_jwk to query params
|
|
4591
|
-
* @param cnfString
|
|
4592
|
-
*/
|
|
4593
|
-
addPopToken(cnfString) {
|
|
4594
|
-
if (cnfString) {
|
|
4595
|
-
this.parameters.set(TOKEN_TYPE, AuthenticationScheme.POP);
|
|
4596
|
-
this.parameters.set(REQ_CNF, encodeURIComponent(cnfString));
|
|
4597
|
-
}
|
|
4598
|
-
}
|
|
4599
|
-
/**
|
|
4600
|
-
* add SSH JWK and key ID to query params
|
|
4601
|
-
*/
|
|
4602
|
-
addSshJwk(sshJwkString) {
|
|
4603
|
-
if (sshJwkString) {
|
|
4604
|
-
this.parameters.set(TOKEN_TYPE, AuthenticationScheme.SSH);
|
|
4605
|
-
this.parameters.set(REQ_CNF, encodeURIComponent(sshJwkString));
|
|
4606
|
-
}
|
|
4607
|
-
}
|
|
4608
|
-
/**
|
|
4609
|
-
* add server telemetry fields
|
|
4610
|
-
* @param serverTelemetryManager
|
|
4611
|
-
*/
|
|
4612
|
-
addServerTelemetry(serverTelemetryManager) {
|
|
4613
|
-
this.parameters.set(X_CLIENT_CURR_TELEM, serverTelemetryManager.generateCurrentRequestHeaderValue());
|
|
4614
|
-
this.parameters.set(X_CLIENT_LAST_TELEM, serverTelemetryManager.generateLastRequestHeaderValue());
|
|
4615
|
-
}
|
|
4616
|
-
/**
|
|
4617
|
-
* Adds parameter that indicates to the server that throttling is supported
|
|
4618
|
-
*/
|
|
4619
|
-
addThrottling() {
|
|
4620
|
-
this.parameters.set(X_MS_LIB_CAPABILITY, ThrottlingConstants.X_MS_LIB_CAPABILITY_VALUE);
|
|
4520
|
+
return JSON.stringify(mergedClaims);
|
|
4521
|
+
}
|
|
4522
|
+
/**
|
|
4523
|
+
* adds `username` for Password Grant flow
|
|
4524
|
+
* @param username
|
|
4525
|
+
*/
|
|
4526
|
+
function addUsername(parameters, username) {
|
|
4527
|
+
parameters.set(PasswordGrantConstants.username, username);
|
|
4528
|
+
}
|
|
4529
|
+
/**
|
|
4530
|
+
* adds `password` for Password Grant flow
|
|
4531
|
+
* @param password
|
|
4532
|
+
*/
|
|
4533
|
+
function addPassword(parameters, password) {
|
|
4534
|
+
parameters.set(PasswordGrantConstants.password, password);
|
|
4535
|
+
}
|
|
4536
|
+
/**
|
|
4537
|
+
* add pop_jwk to query params
|
|
4538
|
+
* @param cnfString
|
|
4539
|
+
*/
|
|
4540
|
+
function addPopToken(parameters, cnfString) {
|
|
4541
|
+
if (cnfString) {
|
|
4542
|
+
parameters.set(TOKEN_TYPE, AuthenticationScheme.POP);
|
|
4543
|
+
parameters.set(REQ_CNF, cnfString);
|
|
4621
4544
|
}
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4545
|
+
}
|
|
4546
|
+
/**
|
|
4547
|
+
* add SSH JWK and key ID to query params
|
|
4548
|
+
*/
|
|
4549
|
+
function addSshJwk(parameters, sshJwkString) {
|
|
4550
|
+
if (sshJwkString) {
|
|
4551
|
+
parameters.set(TOKEN_TYPE, AuthenticationScheme.SSH);
|
|
4552
|
+
parameters.set(REQ_CNF, sshJwkString);
|
|
4627
4553
|
}
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4554
|
+
}
|
|
4555
|
+
/**
|
|
4556
|
+
* add server telemetry fields
|
|
4557
|
+
* @param serverTelemetryManager
|
|
4558
|
+
*/
|
|
4559
|
+
function addServerTelemetry(parameters, serverTelemetryManager) {
|
|
4560
|
+
parameters.set(X_CLIENT_CURR_TELEM, serverTelemetryManager.generateCurrentRequestHeaderValue());
|
|
4561
|
+
parameters.set(X_CLIENT_LAST_TELEM, serverTelemetryManager.generateLastRequestHeaderValue());
|
|
4562
|
+
}
|
|
4563
|
+
/**
|
|
4564
|
+
* Adds parameter that indicates to the server that throttling is supported
|
|
4565
|
+
*/
|
|
4566
|
+
function addThrottling(parameters) {
|
|
4567
|
+
parameters.set(X_MS_LIB_CAPABILITY, ThrottlingConstants.X_MS_LIB_CAPABILITY_VALUE);
|
|
4568
|
+
}
|
|
4569
|
+
/**
|
|
4570
|
+
* Adds logout_hint parameter for "silent" logout which prevent server account picker
|
|
4571
|
+
*/
|
|
4572
|
+
function addLogoutHint(parameters, logoutHint) {
|
|
4573
|
+
parameters.set(LOGOUT_HINT, logoutHint);
|
|
4574
|
+
}
|
|
4575
|
+
function addBrokerParameters(parameters, brokerClientId, brokerRedirectUri) {
|
|
4576
|
+
if (!parameters.has(BROKER_CLIENT_ID)) {
|
|
4577
|
+
parameters.set(BROKER_CLIENT_ID, brokerClientId);
|
|
4635
4578
|
}
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
*/
|
|
4639
|
-
createQueryString() {
|
|
4640
|
-
const queryParameterArray = new Array();
|
|
4641
|
-
this.parameters.forEach((value, key) => {
|
|
4642
|
-
queryParameterArray.push(`${key}=${value}`);
|
|
4643
|
-
});
|
|
4644
|
-
instrumentBrokerParams(this.parameters, this.correlationId, this.performanceClient);
|
|
4645
|
-
return queryParameterArray.join("&");
|
|
4579
|
+
if (!parameters.has(BROKER_REDIRECT_URI)) {
|
|
4580
|
+
parameters.set(BROKER_REDIRECT_URI, brokerRedirectUri);
|
|
4646
4581
|
}
|
|
4647
4582
|
}
|
|
4648
4583
|
|
|
4649
|
-
/*! @azure/msal-common v15.
|
|
4584
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
4650
4585
|
/*
|
|
4651
4586
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4652
4587
|
* Licensed under the MIT License.
|
|
@@ -4658,7 +4593,7 @@ function isOpenIdConfigResponse(response) {
|
|
|
4658
4593
|
response.hasOwnProperty("jwks_uri"));
|
|
4659
4594
|
}
|
|
4660
4595
|
|
|
4661
|
-
/*! @azure/msal-common v15.
|
|
4596
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
4662
4597
|
/*
|
|
4663
4598
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4664
4599
|
* Licensed under the MIT License.
|
|
@@ -4668,7 +4603,7 @@ function isCloudInstanceDiscoveryResponse(response) {
|
|
|
4668
4603
|
response.hasOwnProperty("metadata"));
|
|
4669
4604
|
}
|
|
4670
4605
|
|
|
4671
|
-
/*! @azure/msal-common v15.
|
|
4606
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
4672
4607
|
/*
|
|
4673
4608
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4674
4609
|
* Licensed under the MIT License.
|
|
@@ -4678,7 +4613,7 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
|
|
|
4678
4613
|
response.hasOwnProperty("error_description"));
|
|
4679
4614
|
}
|
|
4680
4615
|
|
|
4681
|
-
/*! @azure/msal-common v15.
|
|
4616
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
4682
4617
|
/*
|
|
4683
4618
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4684
4619
|
* Licensed under the MIT License.
|
|
@@ -4854,11 +4789,11 @@ const PerformanceEvents = {
|
|
|
4854
4789
|
StandardInteractionClientCreateAuthCodeClient: "standardInteractionClientCreateAuthCodeClient",
|
|
4855
4790
|
StandardInteractionClientGetClientConfiguration: "standardInteractionClientGetClientConfiguration",
|
|
4856
4791
|
StandardInteractionClientInitializeAuthorizationRequest: "standardInteractionClientInitializeAuthorizationRequest",
|
|
4857
|
-
StandardInteractionClientInitializeAuthorizationCodeRequest: "standardInteractionClientInitializeAuthorizationCodeRequest",
|
|
4858
4792
|
/**
|
|
4859
4793
|
* getAuthCodeUrl API (msal-browser and msal-node).
|
|
4860
4794
|
*/
|
|
4861
4795
|
GetAuthCodeUrl: "getAuthCodeUrl",
|
|
4796
|
+
GetStandardParams: "getStandardParams",
|
|
4862
4797
|
/**
|
|
4863
4798
|
* Functions from InteractionHandler (msal-browser)
|
|
4864
4799
|
*/
|
|
@@ -4871,7 +4806,6 @@ const PerformanceEvents = {
|
|
|
4871
4806
|
AuthClientAcquireToken: "authClientAcquireToken",
|
|
4872
4807
|
AuthClientExecuteTokenRequest: "authClientExecuteTokenRequest",
|
|
4873
4808
|
AuthClientCreateTokenRequestBody: "authClientCreateTokenRequestBody",
|
|
4874
|
-
AuthClientCreateQueryString: "authClientCreateQueryString",
|
|
4875
4809
|
/**
|
|
4876
4810
|
* Generate functions in PopTokenGenerator (msal-common)
|
|
4877
4811
|
*/
|
|
@@ -4933,7 +4867,7 @@ const PerformanceEvents = {
|
|
|
4933
4867
|
Decrypt: "decrypt",
|
|
4934
4868
|
};
|
|
4935
4869
|
|
|
4936
|
-
/*! @azure/msal-common v15.
|
|
4870
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
4937
4871
|
/*
|
|
4938
4872
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4939
4873
|
* Licensed under the MIT License.
|
|
@@ -5029,7 +4963,7 @@ const invokeAsync = (callback, eventName, logger, telemetryClient, correlationId
|
|
|
5029
4963
|
};
|
|
5030
4964
|
};
|
|
5031
4965
|
|
|
5032
|
-
/*! @azure/msal-common v15.
|
|
4966
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
5033
4967
|
|
|
5034
4968
|
/*
|
|
5035
4969
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5138,7 +5072,7 @@ RegionDiscovery.IMDS_OPTIONS = {
|
|
|
5138
5072
|
},
|
|
5139
5073
|
};
|
|
5140
5074
|
|
|
5141
|
-
/*! @azure/msal-common v15.
|
|
5075
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
5142
5076
|
|
|
5143
5077
|
/*
|
|
5144
5078
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -5977,7 +5911,7 @@ function buildStaticAuthorityOptions(authOptions) {
|
|
|
5977
5911
|
};
|
|
5978
5912
|
}
|
|
5979
5913
|
|
|
5980
|
-
/*! @azure/msal-common v15.
|
|
5914
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
5981
5915
|
|
|
5982
5916
|
/*
|
|
5983
5917
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6008,7 +5942,7 @@ async function createDiscoveredInstance(authorityUri, networkClient, cacheManage
|
|
|
6008
5942
|
}
|
|
6009
5943
|
}
|
|
6010
5944
|
|
|
6011
|
-
/*! @azure/msal-common v15.
|
|
5945
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
6012
5946
|
|
|
6013
5947
|
/*
|
|
6014
5948
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6027,7 +5961,28 @@ class ServerError extends AuthError {
|
|
|
6027
5961
|
}
|
|
6028
5962
|
}
|
|
6029
5963
|
|
|
6030
|
-
/*! @azure/msal-common v15.
|
|
5964
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
5965
|
+
/*
|
|
5966
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5967
|
+
* Licensed under the MIT License.
|
|
5968
|
+
*/
|
|
5969
|
+
function getRequestThumbprint(clientId, request, homeAccountId) {
|
|
5970
|
+
return {
|
|
5971
|
+
clientId: clientId,
|
|
5972
|
+
authority: request.authority,
|
|
5973
|
+
scopes: request.scopes,
|
|
5974
|
+
homeAccountIdentifier: homeAccountId,
|
|
5975
|
+
claims: request.claims,
|
|
5976
|
+
authenticationScheme: request.authenticationScheme,
|
|
5977
|
+
resourceRequestMethod: request.resourceRequestMethod,
|
|
5978
|
+
resourceRequestUri: request.resourceRequestUri,
|
|
5979
|
+
shrClaims: request.shrClaims,
|
|
5980
|
+
sshKid: request.sshKid,
|
|
5981
|
+
embeddedClientId: request.embeddedClientId || request.tokenBodyParameters?.clientId,
|
|
5982
|
+
};
|
|
5983
|
+
}
|
|
5984
|
+
|
|
5985
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
6031
5986
|
|
|
6032
5987
|
/*
|
|
6033
5988
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6108,24 +6063,13 @@ class ThrottlingUtils {
|
|
|
6108
6063
|
ThrottlingConstants.DEFAULT_MAX_THROTTLE_TIME_SECONDS) * 1000);
|
|
6109
6064
|
}
|
|
6110
6065
|
static removeThrottle(cacheManager, clientId, request, homeAccountIdentifier) {
|
|
6111
|
-
const thumbprint =
|
|
6112
|
-
clientId: clientId,
|
|
6113
|
-
authority: request.authority,
|
|
6114
|
-
scopes: request.scopes,
|
|
6115
|
-
homeAccountIdentifier: homeAccountIdentifier,
|
|
6116
|
-
claims: request.claims,
|
|
6117
|
-
authenticationScheme: request.authenticationScheme,
|
|
6118
|
-
resourceRequestMethod: request.resourceRequestMethod,
|
|
6119
|
-
resourceRequestUri: request.resourceRequestUri,
|
|
6120
|
-
shrClaims: request.shrClaims,
|
|
6121
|
-
sshKid: request.sshKid,
|
|
6122
|
-
};
|
|
6066
|
+
const thumbprint = getRequestThumbprint(clientId, request, homeAccountIdentifier);
|
|
6123
6067
|
const key = this.generateThrottlingStorageKey(thumbprint);
|
|
6124
6068
|
cacheManager.removeItem(key);
|
|
6125
6069
|
}
|
|
6126
6070
|
}
|
|
6127
6071
|
|
|
6128
|
-
/*! @azure/msal-common v15.
|
|
6072
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
6129
6073
|
|
|
6130
6074
|
/*
|
|
6131
6075
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6145,7 +6089,7 @@ class NetworkError extends AuthError {
|
|
|
6145
6089
|
}
|
|
6146
6090
|
}
|
|
6147
6091
|
|
|
6148
|
-
/*! @azure/msal-common v15.
|
|
6092
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
6149
6093
|
|
|
6150
6094
|
/*
|
|
6151
6095
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6280,22 +6224,20 @@ class BaseClient {
|
|
|
6280
6224
|
* @param request
|
|
6281
6225
|
*/
|
|
6282
6226
|
createTokenQueryParameters(request) {
|
|
6283
|
-
const
|
|
6227
|
+
const parameters = new Map();
|
|
6284
6228
|
if (request.embeddedClientId) {
|
|
6285
|
-
|
|
6286
|
-
brokerClientId: this.config.authOptions.clientId,
|
|
6287
|
-
brokerRedirectUri: this.config.authOptions.redirectUri,
|
|
6288
|
-
});
|
|
6229
|
+
addBrokerParameters(parameters, this.config.authOptions.clientId, this.config.authOptions.redirectUri);
|
|
6289
6230
|
}
|
|
6290
6231
|
if (request.tokenQueryParameters) {
|
|
6291
|
-
|
|
6232
|
+
addExtraQueryParameters(parameters, request.tokenQueryParameters);
|
|
6292
6233
|
}
|
|
6293
|
-
|
|
6294
|
-
|
|
6234
|
+
addCorrelationId(parameters, request.correlationId);
|
|
6235
|
+
instrumentBrokerParams(parameters, request.correlationId, this.performanceClient);
|
|
6236
|
+
return mapToQueryString(parameters);
|
|
6295
6237
|
}
|
|
6296
6238
|
}
|
|
6297
6239
|
|
|
6298
|
-
/*! @azure/msal-common v15.
|
|
6240
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
6299
6241
|
/*
|
|
6300
6242
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6301
6243
|
* Licensed under the MIT License.
|
|
@@ -6321,7 +6263,7 @@ var InteractionRequiredAuthErrorCodes = /*#__PURE__*/Object.freeze({
|
|
|
6321
6263
|
refreshTokenExpired: refreshTokenExpired
|
|
6322
6264
|
});
|
|
6323
6265
|
|
|
6324
|
-
/*! @azure/msal-common v15.
|
|
6266
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
6325
6267
|
|
|
6326
6268
|
/*
|
|
6327
6269
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6409,7 +6351,7 @@ function createInteractionRequiredAuthError(errorCode) {
|
|
|
6409
6351
|
return new InteractionRequiredAuthError(errorCode, InteractionRequiredAuthErrorMessages[errorCode]);
|
|
6410
6352
|
}
|
|
6411
6353
|
|
|
6412
|
-
/*! @azure/msal-common v15.
|
|
6354
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
6413
6355
|
|
|
6414
6356
|
/*
|
|
6415
6357
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6481,7 +6423,7 @@ class ProtocolUtils {
|
|
|
6481
6423
|
}
|
|
6482
6424
|
}
|
|
6483
6425
|
|
|
6484
|
-
/*! @azure/msal-common v15.
|
|
6426
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
6485
6427
|
|
|
6486
6428
|
/*
|
|
6487
6429
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -6565,7 +6507,7 @@ class PopTokenGenerator {
|
|
|
6565
6507
|
}
|
|
6566
6508
|
}
|
|
6567
6509
|
|
|
6568
|
-
/*! @azure/msal-common v15.
|
|
6510
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
6569
6511
|
/*
|
|
6570
6512
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6571
6513
|
* Licensed under the MIT License.
|
|
@@ -6592,19 +6534,12 @@ class PopTokenGenerator {
|
|
|
6592
6534
|
}
|
|
6593
6535
|
}
|
|
6594
6536
|
|
|
6595
|
-
/*! @azure/msal-common v15.
|
|
6537
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
6596
6538
|
|
|
6597
6539
|
/*
|
|
6598
6540
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6599
6541
|
* Licensed under the MIT License.
|
|
6600
6542
|
*/
|
|
6601
|
-
function parseServerErrorNo(serverResponse) {
|
|
6602
|
-
const errorCodePrefix = "code=";
|
|
6603
|
-
const errorCodePrefixIndex = serverResponse.error_uri?.lastIndexOf(errorCodePrefix);
|
|
6604
|
-
return errorCodePrefixIndex && errorCodePrefixIndex >= 0
|
|
6605
|
-
? serverResponse.error_uri?.substring(errorCodePrefixIndex + errorCodePrefix.length)
|
|
6606
|
-
: undefined;
|
|
6607
|
-
}
|
|
6608
6543
|
/**
|
|
6609
6544
|
* Class that handles response parsing.
|
|
6610
6545
|
* @internal
|
|
@@ -6619,46 +6554,6 @@ class ResponseHandler {
|
|
|
6619
6554
|
this.persistencePlugin = persistencePlugin;
|
|
6620
6555
|
this.performanceClient = performanceClient;
|
|
6621
6556
|
}
|
|
6622
|
-
/**
|
|
6623
|
-
* Function which validates server authorization code response.
|
|
6624
|
-
* @param serverResponseHash
|
|
6625
|
-
* @param requestState
|
|
6626
|
-
* @param cryptoObj
|
|
6627
|
-
*/
|
|
6628
|
-
validateServerAuthorizationCodeResponse(serverResponse, requestState) {
|
|
6629
|
-
if (!serverResponse.state || !requestState) {
|
|
6630
|
-
throw serverResponse.state
|
|
6631
|
-
? createClientAuthError(stateNotFound, "Cached State")
|
|
6632
|
-
: createClientAuthError(stateNotFound, "Server State");
|
|
6633
|
-
}
|
|
6634
|
-
let decodedServerResponseState;
|
|
6635
|
-
let decodedRequestState;
|
|
6636
|
-
try {
|
|
6637
|
-
decodedServerResponseState = decodeURIComponent(serverResponse.state);
|
|
6638
|
-
}
|
|
6639
|
-
catch (e) {
|
|
6640
|
-
throw createClientAuthError(invalidState, serverResponse.state);
|
|
6641
|
-
}
|
|
6642
|
-
try {
|
|
6643
|
-
decodedRequestState = decodeURIComponent(requestState);
|
|
6644
|
-
}
|
|
6645
|
-
catch (e) {
|
|
6646
|
-
throw createClientAuthError(invalidState, serverResponse.state);
|
|
6647
|
-
}
|
|
6648
|
-
if (decodedServerResponseState !== decodedRequestState) {
|
|
6649
|
-
throw createClientAuthError(stateMismatch);
|
|
6650
|
-
}
|
|
6651
|
-
// Check for error
|
|
6652
|
-
if (serverResponse.error ||
|
|
6653
|
-
serverResponse.error_description ||
|
|
6654
|
-
serverResponse.suberror) {
|
|
6655
|
-
const serverErrorNo = parseServerErrorNo(serverResponse);
|
|
6656
|
-
if (isInteractionRequiredError(serverResponse.error, serverResponse.error_description, serverResponse.suberror)) {
|
|
6657
|
-
throw new InteractionRequiredAuthError(serverResponse.error || "", serverResponse.error_description, serverResponse.suberror, serverResponse.timestamp || "", serverResponse.trace_id || "", serverResponse.correlation_id || "", serverResponse.claims || "", serverErrorNo);
|
|
6658
|
-
}
|
|
6659
|
-
throw new ServerError(serverResponse.error || "", serverResponse.error_description, serverResponse.suberror, serverErrorNo);
|
|
6660
|
-
}
|
|
6661
|
-
}
|
|
6662
6557
|
/**
|
|
6663
6558
|
* Function which validates server authorization token response.
|
|
6664
6559
|
* @param serverResponse
|
|
@@ -6884,10 +6779,11 @@ class ResponseHandler {
|
|
|
6884
6779
|
accessToken = cacheRecord.accessToken.secret;
|
|
6885
6780
|
}
|
|
6886
6781
|
responseScopes = ScopeSet.fromString(cacheRecord.accessToken.target).asArray();
|
|
6887
|
-
expiresOn
|
|
6888
|
-
|
|
6782
|
+
// Access token expiresOn cached in seconds, converting to Date for AuthenticationResult
|
|
6783
|
+
expiresOn = toDateFromSeconds(cacheRecord.accessToken.expiresOn);
|
|
6784
|
+
extExpiresOn = toDateFromSeconds(cacheRecord.accessToken.extendedExpiresOn);
|
|
6889
6785
|
if (cacheRecord.accessToken.refreshOn) {
|
|
6890
|
-
refreshOn =
|
|
6786
|
+
refreshOn = toDateFromSeconds(cacheRecord.accessToken.refreshOn);
|
|
6891
6787
|
}
|
|
6892
6788
|
}
|
|
6893
6789
|
if (cacheRecord.appMetadata) {
|
|
@@ -6969,7 +6865,74 @@ function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decod
|
|
|
6969
6865
|
return baseAccount;
|
|
6970
6866
|
}
|
|
6971
6867
|
|
|
6972
|
-
/*! @azure/msal-common v15.
|
|
6868
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
6869
|
+
|
|
6870
|
+
/*
|
|
6871
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6872
|
+
* Licensed under the MIT License.
|
|
6873
|
+
*/
|
|
6874
|
+
/**
|
|
6875
|
+
* Validates server consumable params from the "request" objects
|
|
6876
|
+
*/
|
|
6877
|
+
class RequestValidator {
|
|
6878
|
+
/**
|
|
6879
|
+
* Utility to check if the `redirectUri` in the request is a non-null value
|
|
6880
|
+
* @param redirectUri
|
|
6881
|
+
*/
|
|
6882
|
+
static validateRedirectUri(redirectUri) {
|
|
6883
|
+
if (!redirectUri) {
|
|
6884
|
+
throw createClientConfigurationError(redirectUriEmpty);
|
|
6885
|
+
}
|
|
6886
|
+
}
|
|
6887
|
+
/**
|
|
6888
|
+
* Utility to validate prompt sent by the user in the request
|
|
6889
|
+
* @param prompt
|
|
6890
|
+
*/
|
|
6891
|
+
static validatePrompt(prompt) {
|
|
6892
|
+
const promptValues = [];
|
|
6893
|
+
for (const value in PromptValue) {
|
|
6894
|
+
promptValues.push(PromptValue[value]);
|
|
6895
|
+
}
|
|
6896
|
+
if (promptValues.indexOf(prompt) < 0) {
|
|
6897
|
+
throw createClientConfigurationError(invalidPromptValue);
|
|
6898
|
+
}
|
|
6899
|
+
}
|
|
6900
|
+
static validateClaims(claims) {
|
|
6901
|
+
try {
|
|
6902
|
+
JSON.parse(claims);
|
|
6903
|
+
}
|
|
6904
|
+
catch (e) {
|
|
6905
|
+
throw createClientConfigurationError(invalidClaims);
|
|
6906
|
+
}
|
|
6907
|
+
}
|
|
6908
|
+
/**
|
|
6909
|
+
* Utility to validate code_challenge and code_challenge_method
|
|
6910
|
+
* @param codeChallenge
|
|
6911
|
+
* @param codeChallengeMethod
|
|
6912
|
+
*/
|
|
6913
|
+
static validateCodeChallengeParams(codeChallenge, codeChallengeMethod) {
|
|
6914
|
+
if (!codeChallenge || !codeChallengeMethod) {
|
|
6915
|
+
throw createClientConfigurationError(pkceParamsMissing);
|
|
6916
|
+
}
|
|
6917
|
+
else {
|
|
6918
|
+
this.validateCodeChallengeMethod(codeChallengeMethod);
|
|
6919
|
+
}
|
|
6920
|
+
}
|
|
6921
|
+
/**
|
|
6922
|
+
* Utility to validate code_challenge_method
|
|
6923
|
+
* @param codeChallengeMethod
|
|
6924
|
+
*/
|
|
6925
|
+
static validateCodeChallengeMethod(codeChallengeMethod) {
|
|
6926
|
+
if ([
|
|
6927
|
+
CodeChallengeMethodValues.PLAIN,
|
|
6928
|
+
CodeChallengeMethodValues.S256,
|
|
6929
|
+
].indexOf(codeChallengeMethod) < 0) {
|
|
6930
|
+
throw createClientConfigurationError(invalidCodeChallengeMethod);
|
|
6931
|
+
}
|
|
6932
|
+
}
|
|
6933
|
+
}
|
|
6934
|
+
|
|
6935
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
6973
6936
|
/*
|
|
6974
6937
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
6975
6938
|
* Licensed under the MIT License.
|
|
@@ -6987,7 +6950,7 @@ async function getClientAssertion(clientAssertion, clientId, tokenEndpoint) {
|
|
|
6987
6950
|
}
|
|
6988
6951
|
}
|
|
6989
6952
|
|
|
6990
|
-
/*! @azure/msal-common v15.
|
|
6953
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
6991
6954
|
|
|
6992
6955
|
/*
|
|
6993
6956
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7005,21 +6968,6 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
7005
6968
|
this.oidcDefaultScopes =
|
|
7006
6969
|
this.config.authOptions.authority.options.OIDCOptions?.defaultScopes;
|
|
7007
6970
|
}
|
|
7008
|
-
/**
|
|
7009
|
-
* Creates the URL of the authorization request letting the user input credentials and consent to the
|
|
7010
|
-
* application. The URL target the /authorize endpoint of the authority configured in the
|
|
7011
|
-
* application object.
|
|
7012
|
-
*
|
|
7013
|
-
* Once the user inputs their credentials and consents, the authority will send a response to the redirect URI
|
|
7014
|
-
* sent in the request and should contain an authorization code, which can then be used to acquire tokens via
|
|
7015
|
-
* acquireToken(AuthorizationCodeRequest)
|
|
7016
|
-
* @param request
|
|
7017
|
-
*/
|
|
7018
|
-
async getAuthCodeUrl(request) {
|
|
7019
|
-
this.performanceClient?.addQueueMeasurement(PerformanceEvents.GetAuthCodeUrl, request.correlationId);
|
|
7020
|
-
const queryString = await invokeAsync(this.createAuthCodeUrlQueryString.bind(this), PerformanceEvents.AuthClientCreateQueryString, this.logger, this.performanceClient, request.correlationId)(request);
|
|
7021
|
-
return UrlString.appendQueryString(this.authority.authorizationEndpoint, queryString);
|
|
7022
|
-
}
|
|
7023
6971
|
/**
|
|
7024
6972
|
* API to acquire a token in exchange of 'authorization_code` acquired by the user in the first leg of the
|
|
7025
6973
|
* authorization_code_grant
|
|
@@ -7039,22 +6987,6 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
7039
6987
|
responseHandler.validateTokenResponse(response.body);
|
|
7040
6988
|
return invokeAsync(responseHandler.handleServerTokenResponse.bind(responseHandler), PerformanceEvents.HandleServerTokenResponse, this.logger, this.performanceClient, request.correlationId)(response.body, this.authority, reqTimestamp, request, authCodePayload, undefined, undefined, undefined, requestId);
|
|
7041
6989
|
}
|
|
7042
|
-
/**
|
|
7043
|
-
* Handles the hash fragment response from public client code request. Returns a code response used by
|
|
7044
|
-
* the client to exchange for a token in acquireToken.
|
|
7045
|
-
* @param hashFragment
|
|
7046
|
-
*/
|
|
7047
|
-
handleFragmentResponse(serverParams, cachedState) {
|
|
7048
|
-
// Handle responses.
|
|
7049
|
-
const responseHandler = new ResponseHandler(this.config.authOptions.clientId, this.cacheManager, this.cryptoUtils, this.logger, null, null);
|
|
7050
|
-
// Get code response
|
|
7051
|
-
responseHandler.validateServerAuthorizationCodeResponse(serverParams, cachedState);
|
|
7052
|
-
// throw when there is no auth code in the response
|
|
7053
|
-
if (!serverParams.code) {
|
|
7054
|
-
throw createClientAuthError(authorizationCodeMissingFromServerResponse);
|
|
7055
|
-
}
|
|
7056
|
-
return serverParams;
|
|
7057
|
-
}
|
|
7058
6990
|
/**
|
|
7059
6991
|
* Used to log out the current user, and redirect the user to the postLogoutRedirectUri.
|
|
7060
6992
|
* Default behaviour is to redirect the user to `window.location.href`.
|
|
@@ -7093,18 +7025,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
7093
7025
|
}
|
|
7094
7026
|
}
|
|
7095
7027
|
const headers = this.createTokenRequestHeaders(ccsCredential || request.ccsCredential);
|
|
7096
|
-
const thumbprint =
|
|
7097
|
-
clientId: request.tokenBodyParameters?.clientId ||
|
|
7098
|
-
this.config.authOptions.clientId,
|
|
7099
|
-
authority: authority.canonicalAuthority,
|
|
7100
|
-
scopes: request.scopes,
|
|
7101
|
-
claims: request.claims,
|
|
7102
|
-
authenticationScheme: request.authenticationScheme,
|
|
7103
|
-
resourceRequestMethod: request.resourceRequestMethod,
|
|
7104
|
-
resourceRequestUri: request.resourceRequestUri,
|
|
7105
|
-
shrClaims: request.shrClaims,
|
|
7106
|
-
sshKid: request.sshKid,
|
|
7107
|
-
};
|
|
7028
|
+
const thumbprint = getRequestThumbprint(this.config.authOptions.clientId, request);
|
|
7108
7029
|
return invokeAsync(this.executePostToTokenEndpoint.bind(this), PerformanceEvents.AuthorizationCodeClientExecutePostToTokenEndpoint, this.logger, this.performanceClient, request.correlationId)(endpoint, requestBody, headers, thumbprint, request.correlationId, PerformanceEvents.AuthorizationCodeClientExecutePostToTokenEndpoint);
|
|
7109
7030
|
}
|
|
7110
7031
|
/**
|
|
@@ -7113,8 +7034,8 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
7113
7034
|
*/
|
|
7114
7035
|
async createTokenRequestBody(request) {
|
|
7115
7036
|
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthClientCreateTokenRequestBody, request.correlationId);
|
|
7116
|
-
const
|
|
7117
|
-
|
|
7037
|
+
const parameters = new Map();
|
|
7038
|
+
addClientId(parameters, request.embeddedClientId ||
|
|
7118
7039
|
request.tokenBodyParameters?.[CLIENT_ID] ||
|
|
7119
7040
|
this.config.authOptions.clientId);
|
|
7120
7041
|
/*
|
|
@@ -7127,33 +7048,33 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
7127
7048
|
}
|
|
7128
7049
|
else {
|
|
7129
7050
|
// Validate and include redirect uri
|
|
7130
|
-
|
|
7051
|
+
addRedirectUri(parameters, request.redirectUri);
|
|
7131
7052
|
}
|
|
7132
7053
|
// Add scope array, parameter builder will add default scopes and dedupe
|
|
7133
|
-
|
|
7054
|
+
addScopes(parameters, request.scopes, true, this.oidcDefaultScopes);
|
|
7134
7055
|
// add code: user set, not validated
|
|
7135
|
-
|
|
7056
|
+
addAuthorizationCode(parameters, request.code);
|
|
7136
7057
|
// Add library metadata
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7058
|
+
addLibraryInfo(parameters, this.config.libraryInfo);
|
|
7059
|
+
addApplicationTelemetry(parameters, this.config.telemetry.application);
|
|
7060
|
+
addThrottling(parameters);
|
|
7140
7061
|
if (this.serverTelemetryManager && !isOidcProtocolMode(this.config)) {
|
|
7141
|
-
|
|
7062
|
+
addServerTelemetry(parameters, this.serverTelemetryManager);
|
|
7142
7063
|
}
|
|
7143
7064
|
// add code_verifier if passed
|
|
7144
7065
|
if (request.codeVerifier) {
|
|
7145
|
-
|
|
7066
|
+
addCodeVerifier(parameters, request.codeVerifier);
|
|
7146
7067
|
}
|
|
7147
7068
|
if (this.config.clientCredentials.clientSecret) {
|
|
7148
|
-
|
|
7069
|
+
addClientSecret(parameters, this.config.clientCredentials.clientSecret);
|
|
7149
7070
|
}
|
|
7150
7071
|
if (this.config.clientCredentials.clientAssertion) {
|
|
7151
7072
|
const clientAssertion = this.config.clientCredentials.clientAssertion;
|
|
7152
|
-
|
|
7153
|
-
|
|
7073
|
+
addClientAssertion(parameters, await getClientAssertion(clientAssertion.assertion, this.config.authOptions.clientId, request.resourceRequestUri));
|
|
7074
|
+
addClientAssertionType(parameters, clientAssertion.assertionType);
|
|
7154
7075
|
}
|
|
7155
|
-
|
|
7156
|
-
|
|
7076
|
+
addGrantType(parameters, GrantType.AUTHORIZATION_CODE_GRANT);
|
|
7077
|
+
addClientInfo(parameters);
|
|
7157
7078
|
if (request.authenticationScheme === AuthenticationScheme.POP) {
|
|
7158
7079
|
const popTokenGenerator = new PopTokenGenerator(this.cryptoUtils, this.performanceClient);
|
|
7159
7080
|
let reqCnfData;
|
|
@@ -7165,11 +7086,11 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
7165
7086
|
reqCnfData = this.cryptoUtils.encodeKid(request.popKid);
|
|
7166
7087
|
}
|
|
7167
7088
|
// SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
|
|
7168
|
-
|
|
7089
|
+
addPopToken(parameters, reqCnfData);
|
|
7169
7090
|
}
|
|
7170
7091
|
else if (request.authenticationScheme === AuthenticationScheme.SSH) {
|
|
7171
7092
|
if (request.sshJwk) {
|
|
7172
|
-
|
|
7093
|
+
addSshJwk(parameters, request.sshJwk);
|
|
7173
7094
|
}
|
|
7174
7095
|
else {
|
|
7175
7096
|
throw createClientConfigurationError(missingSshJwk);
|
|
@@ -7178,7 +7099,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
7178
7099
|
if (!StringUtils.isEmptyObj(request.claims) ||
|
|
7179
7100
|
(this.config.authOptions.clientCapabilities &&
|
|
7180
7101
|
this.config.authOptions.clientCapabilities.length > 0)) {
|
|
7181
|
-
|
|
7102
|
+
addClaims(parameters, request.claims, this.config.authOptions.clientCapabilities);
|
|
7182
7103
|
}
|
|
7183
7104
|
let ccsCred = undefined;
|
|
7184
7105
|
if (request.clientInfo) {
|
|
@@ -7202,7 +7123,7 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
7202
7123
|
case CcsCredentialType.HOME_ACCOUNT_ID:
|
|
7203
7124
|
try {
|
|
7204
7125
|
const clientInfo = buildClientInfoFromHomeAccountId(ccsCred.credential);
|
|
7205
|
-
|
|
7126
|
+
addCcsOid(parameters, clientInfo);
|
|
7206
7127
|
}
|
|
7207
7128
|
catch (e) {
|
|
7208
7129
|
this.logger.verbose("Could not parse home account ID for CCS Header: " +
|
|
@@ -7210,234 +7131,59 @@ class AuthorizationCodeClient extends BaseClient {
|
|
|
7210
7131
|
}
|
|
7211
7132
|
break;
|
|
7212
7133
|
case CcsCredentialType.UPN:
|
|
7213
|
-
|
|
7134
|
+
addCcsUpn(parameters, ccsCred.credential);
|
|
7214
7135
|
break;
|
|
7215
7136
|
}
|
|
7216
7137
|
}
|
|
7217
|
-
if (request.embeddedClientId) {
|
|
7218
|
-
|
|
7219
|
-
brokerClientId: this.config.authOptions.clientId,
|
|
7220
|
-
brokerRedirectUri: this.config.authOptions.redirectUri,
|
|
7221
|
-
});
|
|
7222
|
-
}
|
|
7223
|
-
if (request.tokenBodyParameters) {
|
|
7224
|
-
parameterBuilder.addExtraQueryParameters(request.tokenBodyParameters);
|
|
7225
|
-
}
|
|
7226
|
-
// Add hybrid spa parameters if not already provided
|
|
7227
|
-
if (request.enableSpaAuthorizationCode &&
|
|
7228
|
-
(!request.tokenBodyParameters ||
|
|
7229
|
-
!request.tokenBodyParameters[RETURN_SPA_CODE])) {
|
|
7230
|
-
parameterBuilder.addExtraQueryParameters({
|
|
7231
|
-
[RETURN_SPA_CODE]: "1",
|
|
7232
|
-
});
|
|
7233
|
-
}
|
|
7234
|
-
return parameterBuilder.createQueryString();
|
|
7235
|
-
}
|
|
7236
|
-
/**
|
|
7237
|
-
* This API validates the `AuthorizationCodeUrlRequest` and creates a URL
|
|
7238
|
-
* @param request
|
|
7239
|
-
*/
|
|
7240
|
-
async createAuthCodeUrlQueryString(request) {
|
|
7241
|
-
// generate the correlationId if not set by the user and add
|
|
7242
|
-
const correlationId = request.correlationId ||
|
|
7243
|
-
this.config.cryptoInterface.createNewGuid();
|
|
7244
|
-
this.performanceClient?.addQueueMeasurement(PerformanceEvents.AuthClientCreateQueryString, correlationId);
|
|
7245
|
-
const parameterBuilder = new RequestParameterBuilder(correlationId, this.performanceClient);
|
|
7246
|
-
parameterBuilder.addClientId(request.embeddedClientId ||
|
|
7247
|
-
request.extraQueryParameters?.[CLIENT_ID] ||
|
|
7248
|
-
this.config.authOptions.clientId);
|
|
7249
|
-
const requestScopes = [
|
|
7250
|
-
...(request.scopes || []),
|
|
7251
|
-
...(request.extraScopesToConsent || []),
|
|
7252
|
-
];
|
|
7253
|
-
parameterBuilder.addScopes(requestScopes, true, this.oidcDefaultScopes);
|
|
7254
|
-
// validate the redirectUri (to be a non null value)
|
|
7255
|
-
parameterBuilder.addRedirectUri(request.redirectUri);
|
|
7256
|
-
parameterBuilder.addCorrelationId(correlationId);
|
|
7257
|
-
// add response_mode. If not passed in it defaults to query.
|
|
7258
|
-
parameterBuilder.addResponseMode(request.responseMode);
|
|
7259
|
-
// add response_type = code
|
|
7260
|
-
parameterBuilder.addResponseTypeCode();
|
|
7261
|
-
// add library info parameters
|
|
7262
|
-
parameterBuilder.addLibraryInfo(this.config.libraryInfo);
|
|
7263
|
-
if (!isOidcProtocolMode(this.config)) {
|
|
7264
|
-
parameterBuilder.addApplicationTelemetry(this.config.telemetry.application);
|
|
7265
|
-
}
|
|
7266
|
-
// add client_info=1
|
|
7267
|
-
parameterBuilder.addClientInfo();
|
|
7268
|
-
if (request.codeChallenge && request.codeChallengeMethod) {
|
|
7269
|
-
parameterBuilder.addCodeChallengeParams(request.codeChallenge, request.codeChallengeMethod);
|
|
7270
|
-
}
|
|
7271
|
-
if (request.prompt) {
|
|
7272
|
-
parameterBuilder.addPrompt(request.prompt);
|
|
7273
|
-
}
|
|
7274
|
-
if (request.domainHint) {
|
|
7275
|
-
parameterBuilder.addDomainHint(request.domainHint);
|
|
7276
|
-
this.performanceClient?.addFields({ domainHintFromRequest: true }, correlationId);
|
|
7277
|
-
}
|
|
7278
|
-
this.performanceClient?.addFields({ prompt: request.prompt }, correlationId);
|
|
7279
|
-
// Add sid or loginHint with preference for login_hint claim (in request) -> sid -> loginHint (upn/email) -> username of AccountInfo object
|
|
7280
|
-
if (request.prompt !== PromptValue.SELECT_ACCOUNT) {
|
|
7281
|
-
// AAD will throw if prompt=select_account is passed with an account hint
|
|
7282
|
-
if (request.sid && request.prompt === PromptValue.NONE) {
|
|
7283
|
-
// SessionID is only used in silent calls
|
|
7284
|
-
this.logger.verbose("createAuthCodeUrlQueryString: Prompt is none, adding sid from request");
|
|
7285
|
-
parameterBuilder.addSid(request.sid);
|
|
7286
|
-
this.performanceClient?.addFields({ sidFromRequest: true }, correlationId);
|
|
7287
|
-
}
|
|
7288
|
-
else if (request.account) {
|
|
7289
|
-
const accountSid = this.extractAccountSid(request.account);
|
|
7290
|
-
let accountLoginHintClaim = this.extractLoginHint(request.account);
|
|
7291
|
-
if (accountLoginHintClaim && request.domainHint) {
|
|
7292
|
-
this.logger.warning(`AuthorizationCodeClient.createAuthCodeUrlQueryString: "domainHint" param is set, skipping opaque "login_hint" claim. Please consider not passing domainHint`);
|
|
7293
|
-
accountLoginHintClaim = null;
|
|
7294
|
-
}
|
|
7295
|
-
// If login_hint claim is present, use it over sid/username
|
|
7296
|
-
if (accountLoginHintClaim) {
|
|
7297
|
-
this.logger.verbose("createAuthCodeUrlQueryString: login_hint claim present on account");
|
|
7298
|
-
parameterBuilder.addLoginHint(accountLoginHintClaim);
|
|
7299
|
-
this.performanceClient?.addFields({ loginHintFromClaim: true }, correlationId);
|
|
7300
|
-
try {
|
|
7301
|
-
const clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
|
|
7302
|
-
parameterBuilder.addCcsOid(clientInfo);
|
|
7303
|
-
}
|
|
7304
|
-
catch (e) {
|
|
7305
|
-
this.logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
|
|
7306
|
-
}
|
|
7307
|
-
}
|
|
7308
|
-
else if (accountSid && request.prompt === PromptValue.NONE) {
|
|
7309
|
-
/*
|
|
7310
|
-
* If account and loginHint are provided, we will check account first for sid before adding loginHint
|
|
7311
|
-
* SessionId is only used in silent calls
|
|
7312
|
-
*/
|
|
7313
|
-
this.logger.verbose("createAuthCodeUrlQueryString: Prompt is none, adding sid from account");
|
|
7314
|
-
parameterBuilder.addSid(accountSid);
|
|
7315
|
-
this.performanceClient?.addFields({ sidFromClaim: true }, correlationId);
|
|
7316
|
-
try {
|
|
7317
|
-
const clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
|
|
7318
|
-
parameterBuilder.addCcsOid(clientInfo);
|
|
7319
|
-
}
|
|
7320
|
-
catch (e) {
|
|
7321
|
-
this.logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
|
|
7322
|
-
}
|
|
7323
|
-
}
|
|
7324
|
-
else if (request.loginHint) {
|
|
7325
|
-
this.logger.verbose("createAuthCodeUrlQueryString: Adding login_hint from request");
|
|
7326
|
-
parameterBuilder.addLoginHint(request.loginHint);
|
|
7327
|
-
parameterBuilder.addCcsUpn(request.loginHint);
|
|
7328
|
-
this.performanceClient?.addFields({ loginHintFromRequest: true }, correlationId);
|
|
7329
|
-
}
|
|
7330
|
-
else if (request.account.username) {
|
|
7331
|
-
// Fallback to account username if provided
|
|
7332
|
-
this.logger.verbose("createAuthCodeUrlQueryString: Adding login_hint from account");
|
|
7333
|
-
parameterBuilder.addLoginHint(request.account.username);
|
|
7334
|
-
this.performanceClient?.addFields({ loginHintFromUpn: true }, correlationId);
|
|
7335
|
-
try {
|
|
7336
|
-
const clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
|
|
7337
|
-
parameterBuilder.addCcsOid(clientInfo);
|
|
7338
|
-
}
|
|
7339
|
-
catch (e) {
|
|
7340
|
-
this.logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
|
|
7341
|
-
}
|
|
7342
|
-
}
|
|
7343
|
-
}
|
|
7344
|
-
else if (request.loginHint) {
|
|
7345
|
-
this.logger.verbose("createAuthCodeUrlQueryString: No account, adding login_hint from request");
|
|
7346
|
-
parameterBuilder.addLoginHint(request.loginHint);
|
|
7347
|
-
parameterBuilder.addCcsUpn(request.loginHint);
|
|
7348
|
-
this.performanceClient?.addFields({ loginHintFromRequest: true }, correlationId);
|
|
7349
|
-
}
|
|
7350
|
-
}
|
|
7351
|
-
else {
|
|
7352
|
-
this.logger.verbose("createAuthCodeUrlQueryString: Prompt is select_account, ignoring account hints");
|
|
7353
|
-
}
|
|
7354
|
-
if (request.nonce) {
|
|
7355
|
-
parameterBuilder.addNonce(request.nonce);
|
|
7356
|
-
}
|
|
7357
|
-
if (request.state) {
|
|
7358
|
-
parameterBuilder.addState(request.state);
|
|
7138
|
+
if (request.embeddedClientId) {
|
|
7139
|
+
addBrokerParameters(parameters, this.config.authOptions.clientId, this.config.authOptions.redirectUri);
|
|
7359
7140
|
}
|
|
7360
|
-
if (request.
|
|
7361
|
-
(
|
|
7362
|
-
this.config.authOptions.clientCapabilities.length > 0)) {
|
|
7363
|
-
parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
|
|
7141
|
+
if (request.tokenBodyParameters) {
|
|
7142
|
+
addExtraQueryParameters(parameters, request.tokenBodyParameters);
|
|
7364
7143
|
}
|
|
7365
|
-
if
|
|
7366
|
-
|
|
7367
|
-
|
|
7368
|
-
|
|
7144
|
+
// Add hybrid spa parameters if not already provided
|
|
7145
|
+
if (request.enableSpaAuthorizationCode &&
|
|
7146
|
+
(!request.tokenBodyParameters ||
|
|
7147
|
+
!request.tokenBodyParameters[RETURN_SPA_CODE])) {
|
|
7148
|
+
addExtraQueryParameters(parameters, {
|
|
7149
|
+
[RETURN_SPA_CODE]: "1",
|
|
7369
7150
|
});
|
|
7370
7151
|
}
|
|
7371
|
-
|
|
7372
|
-
|
|
7373
|
-
// signal ests that this is a WAM call
|
|
7374
|
-
parameterBuilder.addNativeBroker();
|
|
7375
|
-
// pass the req_cnf for POP
|
|
7376
|
-
if (request.authenticationScheme === AuthenticationScheme.POP) {
|
|
7377
|
-
const popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
|
|
7378
|
-
// req_cnf is always sent as a string for SPAs
|
|
7379
|
-
let reqCnfData;
|
|
7380
|
-
if (!request.popKid) {
|
|
7381
|
-
const generatedReqCnfData = await invokeAsync(popTokenGenerator.generateCnf.bind(popTokenGenerator), PerformanceEvents.PopTokenGenerateCnf, this.logger, this.performanceClient, request.correlationId)(request, this.logger);
|
|
7382
|
-
reqCnfData = generatedReqCnfData.reqCnfString;
|
|
7383
|
-
}
|
|
7384
|
-
else {
|
|
7385
|
-
reqCnfData = this.cryptoUtils.encodeKid(request.popKid);
|
|
7386
|
-
}
|
|
7387
|
-
parameterBuilder.addPopToken(reqCnfData);
|
|
7388
|
-
}
|
|
7389
|
-
}
|
|
7390
|
-
return parameterBuilder.createQueryString();
|
|
7152
|
+
instrumentBrokerParams(parameters, request.correlationId, this.performanceClient);
|
|
7153
|
+
return mapToQueryString(parameters);
|
|
7391
7154
|
}
|
|
7392
7155
|
/**
|
|
7393
7156
|
* This API validates the `EndSessionRequest` and creates a URL
|
|
7394
7157
|
* @param request
|
|
7395
7158
|
*/
|
|
7396
7159
|
createLogoutUrlQueryString(request) {
|
|
7397
|
-
const
|
|
7160
|
+
const parameters = new Map();
|
|
7398
7161
|
if (request.postLogoutRedirectUri) {
|
|
7399
|
-
|
|
7162
|
+
addPostLogoutRedirectUri(parameters, request.postLogoutRedirectUri);
|
|
7400
7163
|
}
|
|
7401
7164
|
if (request.correlationId) {
|
|
7402
|
-
|
|
7165
|
+
addCorrelationId(parameters, request.correlationId);
|
|
7403
7166
|
}
|
|
7404
7167
|
if (request.idTokenHint) {
|
|
7405
|
-
|
|
7168
|
+
addIdTokenHint(parameters, request.idTokenHint);
|
|
7406
7169
|
}
|
|
7407
7170
|
if (request.state) {
|
|
7408
|
-
|
|
7171
|
+
addState(parameters, request.state);
|
|
7409
7172
|
}
|
|
7410
7173
|
if (request.logoutHint) {
|
|
7411
|
-
|
|
7412
|
-
}
|
|
7413
|
-
this.addExtraQueryParams(request, parameterBuilder);
|
|
7414
|
-
return parameterBuilder.createQueryString();
|
|
7415
|
-
}
|
|
7416
|
-
addExtraQueryParams(request, parameterBuilder) {
|
|
7417
|
-
const hasRequestInstanceAware = request.extraQueryParameters &&
|
|
7418
|
-
request.extraQueryParameters.hasOwnProperty("instance_aware");
|
|
7419
|
-
// Set instance_aware flag if config auth param is set
|
|
7420
|
-
if (!hasRequestInstanceAware && this.config.authOptions.instanceAware) {
|
|
7421
|
-
request.extraQueryParameters = request.extraQueryParameters || {};
|
|
7422
|
-
request.extraQueryParameters["instance_aware"] = "true";
|
|
7174
|
+
addLogoutHint(parameters, request.logoutHint);
|
|
7423
7175
|
}
|
|
7424
7176
|
if (request.extraQueryParameters) {
|
|
7425
|
-
|
|
7177
|
+
addExtraQueryParameters(parameters, request.extraQueryParameters);
|
|
7426
7178
|
}
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
*/
|
|
7432
|
-
extractAccountSid(account) {
|
|
7433
|
-
return account.idTokenClaims?.sid || null;
|
|
7434
|
-
}
|
|
7435
|
-
extractLoginHint(account) {
|
|
7436
|
-
return account.idTokenClaims?.login_hint || null;
|
|
7179
|
+
if (this.config.authOptions.instanceAware) {
|
|
7180
|
+
addInstanceAware(parameters);
|
|
7181
|
+
}
|
|
7182
|
+
return mapToQueryString(parameters);
|
|
7437
7183
|
}
|
|
7438
7184
|
}
|
|
7439
7185
|
|
|
7440
|
-
/*! @azure/msal-common v15.
|
|
7186
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
7441
7187
|
|
|
7442
7188
|
/*
|
|
7443
7189
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7557,18 +7303,7 @@ class RefreshTokenClient extends BaseClient {
|
|
|
7557
7303
|
const endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParametersString);
|
|
7558
7304
|
const requestBody = await invokeAsync(this.createTokenRequestBody.bind(this), PerformanceEvents.RefreshTokenClientCreateTokenRequestBody, this.logger, this.performanceClient, request.correlationId)(request);
|
|
7559
7305
|
const headers = this.createTokenRequestHeaders(request.ccsCredential);
|
|
7560
|
-
const thumbprint =
|
|
7561
|
-
clientId: request.tokenBodyParameters?.clientId ||
|
|
7562
|
-
this.config.authOptions.clientId,
|
|
7563
|
-
authority: authority.canonicalAuthority,
|
|
7564
|
-
scopes: request.scopes,
|
|
7565
|
-
claims: request.claims,
|
|
7566
|
-
authenticationScheme: request.authenticationScheme,
|
|
7567
|
-
resourceRequestMethod: request.resourceRequestMethod,
|
|
7568
|
-
resourceRequestUri: request.resourceRequestUri,
|
|
7569
|
-
shrClaims: request.shrClaims,
|
|
7570
|
-
sshKid: request.sshKid,
|
|
7571
|
-
};
|
|
7306
|
+
const thumbprint = getRequestThumbprint(this.config.authOptions.clientId, request);
|
|
7572
7307
|
return invokeAsync(this.executePostToTokenEndpoint.bind(this), PerformanceEvents.RefreshTokenClientExecutePostToTokenEndpoint, this.logger, this.performanceClient, request.correlationId)(endpoint, requestBody, headers, thumbprint, request.correlationId, PerformanceEvents.RefreshTokenClientExecutePostToTokenEndpoint);
|
|
7573
7308
|
}
|
|
7574
7309
|
/**
|
|
@@ -7577,31 +7312,30 @@ class RefreshTokenClient extends BaseClient {
|
|
|
7577
7312
|
*/
|
|
7578
7313
|
async createTokenRequestBody(request) {
|
|
7579
7314
|
this.performanceClient?.addQueueMeasurement(PerformanceEvents.RefreshTokenClientCreateTokenRequestBody, request.correlationId);
|
|
7580
|
-
const
|
|
7581
|
-
|
|
7582
|
-
parameterBuilder.addClientId(request.embeddedClientId ||
|
|
7315
|
+
const parameters = new Map();
|
|
7316
|
+
addClientId(parameters, request.embeddedClientId ||
|
|
7583
7317
|
request.tokenBodyParameters?.[CLIENT_ID] ||
|
|
7584
7318
|
this.config.authOptions.clientId);
|
|
7585
7319
|
if (request.redirectUri) {
|
|
7586
|
-
|
|
7587
|
-
}
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
|
|
7320
|
+
addRedirectUri(parameters, request.redirectUri);
|
|
7321
|
+
}
|
|
7322
|
+
addScopes(parameters, request.scopes, true, this.config.authOptions.authority.options.OIDCOptions?.defaultScopes);
|
|
7323
|
+
addGrantType(parameters, GrantType.REFRESH_TOKEN_GRANT);
|
|
7324
|
+
addClientInfo(parameters);
|
|
7325
|
+
addLibraryInfo(parameters, this.config.libraryInfo);
|
|
7326
|
+
addApplicationTelemetry(parameters, this.config.telemetry.application);
|
|
7327
|
+
addThrottling(parameters);
|
|
7594
7328
|
if (this.serverTelemetryManager && !isOidcProtocolMode(this.config)) {
|
|
7595
|
-
|
|
7329
|
+
addServerTelemetry(parameters, this.serverTelemetryManager);
|
|
7596
7330
|
}
|
|
7597
|
-
|
|
7331
|
+
addRefreshToken(parameters, request.refreshToken);
|
|
7598
7332
|
if (this.config.clientCredentials.clientSecret) {
|
|
7599
|
-
|
|
7333
|
+
addClientSecret(parameters, this.config.clientCredentials.clientSecret);
|
|
7600
7334
|
}
|
|
7601
7335
|
if (this.config.clientCredentials.clientAssertion) {
|
|
7602
7336
|
const clientAssertion = this.config.clientCredentials.clientAssertion;
|
|
7603
|
-
|
|
7604
|
-
|
|
7337
|
+
addClientAssertion(parameters, await getClientAssertion(clientAssertion.assertion, this.config.authOptions.clientId, request.resourceRequestUri));
|
|
7338
|
+
addClientAssertionType(parameters, clientAssertion.assertionType);
|
|
7605
7339
|
}
|
|
7606
7340
|
if (request.authenticationScheme === AuthenticationScheme.POP) {
|
|
7607
7341
|
const popTokenGenerator = new PopTokenGenerator(this.cryptoUtils, this.performanceClient);
|
|
@@ -7614,11 +7348,11 @@ class RefreshTokenClient extends BaseClient {
|
|
|
7614
7348
|
reqCnfData = this.cryptoUtils.encodeKid(request.popKid);
|
|
7615
7349
|
}
|
|
7616
7350
|
// SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
|
|
7617
|
-
|
|
7351
|
+
addPopToken(parameters, reqCnfData);
|
|
7618
7352
|
}
|
|
7619
7353
|
else if (request.authenticationScheme === AuthenticationScheme.SSH) {
|
|
7620
7354
|
if (request.sshJwk) {
|
|
7621
|
-
|
|
7355
|
+
addSshJwk(parameters, request.sshJwk);
|
|
7622
7356
|
}
|
|
7623
7357
|
else {
|
|
7624
7358
|
throw createClientConfigurationError(missingSshJwk);
|
|
@@ -7627,7 +7361,7 @@ class RefreshTokenClient extends BaseClient {
|
|
|
7627
7361
|
if (!StringUtils.isEmptyObj(request.claims) ||
|
|
7628
7362
|
(this.config.authOptions.clientCapabilities &&
|
|
7629
7363
|
this.config.authOptions.clientCapabilities.length > 0)) {
|
|
7630
|
-
|
|
7364
|
+
addClaims(parameters, request.claims, this.config.authOptions.clientCapabilities);
|
|
7631
7365
|
}
|
|
7632
7366
|
if (this.config.systemOptions.preventCorsPreflight &&
|
|
7633
7367
|
request.ccsCredential) {
|
|
@@ -7635,7 +7369,7 @@ class RefreshTokenClient extends BaseClient {
|
|
|
7635
7369
|
case CcsCredentialType.HOME_ACCOUNT_ID:
|
|
7636
7370
|
try {
|
|
7637
7371
|
const clientInfo = buildClientInfoFromHomeAccountId(request.ccsCredential.credential);
|
|
7638
|
-
|
|
7372
|
+
addCcsOid(parameters, clientInfo);
|
|
7639
7373
|
}
|
|
7640
7374
|
catch (e) {
|
|
7641
7375
|
this.logger.verbose("Could not parse home account ID for CCS Header: " +
|
|
@@ -7643,24 +7377,22 @@ class RefreshTokenClient extends BaseClient {
|
|
|
7643
7377
|
}
|
|
7644
7378
|
break;
|
|
7645
7379
|
case CcsCredentialType.UPN:
|
|
7646
|
-
|
|
7380
|
+
addCcsUpn(parameters, request.ccsCredential.credential);
|
|
7647
7381
|
break;
|
|
7648
7382
|
}
|
|
7649
7383
|
}
|
|
7650
7384
|
if (request.embeddedClientId) {
|
|
7651
|
-
|
|
7652
|
-
brokerClientId: this.config.authOptions.clientId,
|
|
7653
|
-
brokerRedirectUri: this.config.authOptions.redirectUri,
|
|
7654
|
-
});
|
|
7385
|
+
addBrokerParameters(parameters, this.config.authOptions.clientId, this.config.authOptions.redirectUri);
|
|
7655
7386
|
}
|
|
7656
7387
|
if (request.tokenBodyParameters) {
|
|
7657
|
-
|
|
7388
|
+
addExtraQueryParameters(parameters, request.tokenBodyParameters);
|
|
7658
7389
|
}
|
|
7659
|
-
|
|
7390
|
+
instrumentBrokerParams(parameters, request.correlationId, this.performanceClient);
|
|
7391
|
+
return mapToQueryString(parameters);
|
|
7660
7392
|
}
|
|
7661
7393
|
}
|
|
7662
7394
|
|
|
7663
|
-
/*! @azure/msal-common v15.
|
|
7395
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
7664
7396
|
|
|
7665
7397
|
/*
|
|
7666
7398
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -7758,7 +7490,157 @@ class SilentFlowClient extends BaseClient {
|
|
|
7758
7490
|
}
|
|
7759
7491
|
}
|
|
7760
7492
|
|
|
7761
|
-
/*! @azure/msal-common v15.
|
|
7493
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
7494
|
+
|
|
7495
|
+
/*
|
|
7496
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
7497
|
+
* Licensed under the MIT License.
|
|
7498
|
+
*/
|
|
7499
|
+
/**
|
|
7500
|
+
* Returns map of parameters that are applicable to all calls to /authorize whether using PKCE or EAR
|
|
7501
|
+
* @param config
|
|
7502
|
+
* @param request
|
|
7503
|
+
* @param logger
|
|
7504
|
+
* @param performanceClient
|
|
7505
|
+
* @returns
|
|
7506
|
+
*/
|
|
7507
|
+
function getStandardAuthorizeRequestParameters(authOptions, request, logger, performanceClient) {
|
|
7508
|
+
// generate the correlationId if not set by the user and add
|
|
7509
|
+
const correlationId = request.correlationId;
|
|
7510
|
+
const parameters = new Map();
|
|
7511
|
+
addClientId(parameters, request.embeddedClientId ||
|
|
7512
|
+
request.extraQueryParameters?.[CLIENT_ID] ||
|
|
7513
|
+
authOptions.clientId);
|
|
7514
|
+
const requestScopes = [
|
|
7515
|
+
...(request.scopes || []),
|
|
7516
|
+
...(request.extraScopesToConsent || []),
|
|
7517
|
+
];
|
|
7518
|
+
addScopes(parameters, requestScopes, true, authOptions.authority.options.OIDCOptions?.defaultScopes);
|
|
7519
|
+
addRedirectUri(parameters, request.redirectUri);
|
|
7520
|
+
addCorrelationId(parameters, correlationId);
|
|
7521
|
+
// add response_mode. If not passed in it defaults to query.
|
|
7522
|
+
addResponseMode(parameters, request.responseMode);
|
|
7523
|
+
// add client_info=1
|
|
7524
|
+
addClientInfo(parameters);
|
|
7525
|
+
if (request.prompt) {
|
|
7526
|
+
addPrompt(parameters, request.prompt);
|
|
7527
|
+
}
|
|
7528
|
+
if (request.domainHint) {
|
|
7529
|
+
addDomainHint(parameters, request.domainHint);
|
|
7530
|
+
}
|
|
7531
|
+
// Add sid or loginHint with preference for login_hint claim (in request) -> sid -> loginHint (upn/email) -> username of AccountInfo object
|
|
7532
|
+
if (request.prompt !== PromptValue.SELECT_ACCOUNT) {
|
|
7533
|
+
// AAD will throw if prompt=select_account is passed with an account hint
|
|
7534
|
+
if (request.sid && request.prompt === PromptValue.NONE) {
|
|
7535
|
+
// SessionID is only used in silent calls
|
|
7536
|
+
logger.verbose("createAuthCodeUrlQueryString: Prompt is none, adding sid from request");
|
|
7537
|
+
addSid(parameters, request.sid);
|
|
7538
|
+
}
|
|
7539
|
+
else if (request.account) {
|
|
7540
|
+
const accountSid = extractAccountSid(request.account);
|
|
7541
|
+
let accountLoginHintClaim = extractLoginHint(request.account);
|
|
7542
|
+
if (accountLoginHintClaim && request.domainHint) {
|
|
7543
|
+
logger.warning(`AuthorizationCodeClient.createAuthCodeUrlQueryString: "domainHint" param is set, skipping opaque "login_hint" claim. Please consider not passing domainHint`);
|
|
7544
|
+
accountLoginHintClaim = null;
|
|
7545
|
+
}
|
|
7546
|
+
// If login_hint claim is present, use it over sid/username
|
|
7547
|
+
if (accountLoginHintClaim) {
|
|
7548
|
+
logger.verbose("createAuthCodeUrlQueryString: login_hint claim present on account");
|
|
7549
|
+
addLoginHint(parameters, accountLoginHintClaim);
|
|
7550
|
+
try {
|
|
7551
|
+
const clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
|
|
7552
|
+
addCcsOid(parameters, clientInfo);
|
|
7553
|
+
}
|
|
7554
|
+
catch (e) {
|
|
7555
|
+
logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
|
|
7556
|
+
}
|
|
7557
|
+
}
|
|
7558
|
+
else if (accountSid && request.prompt === PromptValue.NONE) {
|
|
7559
|
+
/*
|
|
7560
|
+
* If account and loginHint are provided, we will check account first for sid before adding loginHint
|
|
7561
|
+
* SessionId is only used in silent calls
|
|
7562
|
+
*/
|
|
7563
|
+
logger.verbose("createAuthCodeUrlQueryString: Prompt is none, adding sid from account");
|
|
7564
|
+
addSid(parameters, accountSid);
|
|
7565
|
+
try {
|
|
7566
|
+
const clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
|
|
7567
|
+
addCcsOid(parameters, clientInfo);
|
|
7568
|
+
}
|
|
7569
|
+
catch (e) {
|
|
7570
|
+
logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
|
|
7571
|
+
}
|
|
7572
|
+
}
|
|
7573
|
+
else if (request.loginHint) {
|
|
7574
|
+
logger.verbose("createAuthCodeUrlQueryString: Adding login_hint from request");
|
|
7575
|
+
addLoginHint(parameters, request.loginHint);
|
|
7576
|
+
addCcsUpn(parameters, request.loginHint);
|
|
7577
|
+
}
|
|
7578
|
+
else if (request.account.username) {
|
|
7579
|
+
// Fallback to account username if provided
|
|
7580
|
+
logger.verbose("createAuthCodeUrlQueryString: Adding login_hint from account");
|
|
7581
|
+
addLoginHint(parameters, request.account.username);
|
|
7582
|
+
try {
|
|
7583
|
+
const clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
|
|
7584
|
+
addCcsOid(parameters, clientInfo);
|
|
7585
|
+
}
|
|
7586
|
+
catch (e) {
|
|
7587
|
+
logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
|
|
7588
|
+
}
|
|
7589
|
+
}
|
|
7590
|
+
}
|
|
7591
|
+
else if (request.loginHint) {
|
|
7592
|
+
logger.verbose("createAuthCodeUrlQueryString: No account, adding login_hint from request");
|
|
7593
|
+
addLoginHint(parameters, request.loginHint);
|
|
7594
|
+
addCcsUpn(parameters, request.loginHint);
|
|
7595
|
+
}
|
|
7596
|
+
}
|
|
7597
|
+
else {
|
|
7598
|
+
logger.verbose("createAuthCodeUrlQueryString: Prompt is select_account, ignoring account hints");
|
|
7599
|
+
}
|
|
7600
|
+
if (request.nonce) {
|
|
7601
|
+
addNonce(parameters, request.nonce);
|
|
7602
|
+
}
|
|
7603
|
+
if (request.state) {
|
|
7604
|
+
addState(parameters, request.state);
|
|
7605
|
+
}
|
|
7606
|
+
if (request.claims ||
|
|
7607
|
+
(authOptions.clientCapabilities &&
|
|
7608
|
+
authOptions.clientCapabilities.length > 0)) {
|
|
7609
|
+
addClaims(parameters, request.claims, authOptions.clientCapabilities);
|
|
7610
|
+
}
|
|
7611
|
+
if (request.embeddedClientId) {
|
|
7612
|
+
addBrokerParameters(parameters, authOptions.clientId, authOptions.redirectUri);
|
|
7613
|
+
}
|
|
7614
|
+
if (request.extraQueryParameters) {
|
|
7615
|
+
addExtraQueryParameters(parameters, request.extraQueryParameters);
|
|
7616
|
+
}
|
|
7617
|
+
if (authOptions.instanceAware) {
|
|
7618
|
+
addInstanceAware(parameters);
|
|
7619
|
+
}
|
|
7620
|
+
return parameters;
|
|
7621
|
+
}
|
|
7622
|
+
/**
|
|
7623
|
+
* Returns authorize endpoint with given request parameters in the query string
|
|
7624
|
+
* @param authority
|
|
7625
|
+
* @param requestParameters
|
|
7626
|
+
* @returns
|
|
7627
|
+
*/
|
|
7628
|
+
function getAuthorizeUrl(authority, requestParameters) {
|
|
7629
|
+
const queryString = mapToQueryString(requestParameters);
|
|
7630
|
+
return UrlString.appendQueryString(authority.authorizationEndpoint, queryString);
|
|
7631
|
+
}
|
|
7632
|
+
/**
|
|
7633
|
+
* Helper to get sid from account. Returns null if idTokenClaims are not present or sid is not present.
|
|
7634
|
+
* @param account
|
|
7635
|
+
*/
|
|
7636
|
+
function extractAccountSid(account) {
|
|
7637
|
+
return account.idTokenClaims?.sid || null;
|
|
7638
|
+
}
|
|
7639
|
+
function extractLoginHint(account) {
|
|
7640
|
+
return account.idTokenClaims?.login_hint || null;
|
|
7641
|
+
}
|
|
7642
|
+
|
|
7643
|
+
/*! @azure/msal-common v15.3.0 2025-03-20 */
|
|
7762
7644
|
|
|
7763
7645
|
/*
|
|
7764
7646
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -8782,82 +8664,6 @@ class ManagedIdentityId {
|
|
|
8782
8664
|
}
|
|
8783
8665
|
}
|
|
8784
8666
|
|
|
8785
|
-
/*
|
|
8786
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8787
|
-
* Licensed under the MIT License.
|
|
8788
|
-
*/
|
|
8789
|
-
class LinearRetryPolicy {
|
|
8790
|
-
constructor(maxRetries, retryDelay, httpStatusCodesToRetryOn) {
|
|
8791
|
-
this.maxRetries = maxRetries;
|
|
8792
|
-
this.retryDelay = retryDelay;
|
|
8793
|
-
this.httpStatusCodesToRetryOn = httpStatusCodesToRetryOn;
|
|
8794
|
-
}
|
|
8795
|
-
retryAfterMillisecondsToSleep(retryHeader) {
|
|
8796
|
-
if (!retryHeader) {
|
|
8797
|
-
return 0;
|
|
8798
|
-
}
|
|
8799
|
-
// retry-after header is in seconds
|
|
8800
|
-
let millisToSleep = Math.round(parseFloat(retryHeader) * 1000);
|
|
8801
|
-
/*
|
|
8802
|
-
* retry-after header is in HTTP Date format
|
|
8803
|
-
* <day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT
|
|
8804
|
-
*/
|
|
8805
|
-
if (isNaN(millisToSleep)) {
|
|
8806
|
-
millisToSleep = Math.max(0,
|
|
8807
|
-
// .valueOf() is needed to subtract dates in TypeScript
|
|
8808
|
-
new Date(retryHeader).valueOf() - new Date().valueOf());
|
|
8809
|
-
}
|
|
8810
|
-
return millisToSleep;
|
|
8811
|
-
}
|
|
8812
|
-
async pauseForRetry(httpStatusCode, currentRetry, retryAfterHeader) {
|
|
8813
|
-
if (this.httpStatusCodesToRetryOn.includes(httpStatusCode) &&
|
|
8814
|
-
currentRetry < this.maxRetries) {
|
|
8815
|
-
const retryAfterDelay = this.retryAfterMillisecondsToSleep(retryAfterHeader);
|
|
8816
|
-
await new Promise((resolve) => {
|
|
8817
|
-
// retryAfterHeader value of 0 evaluates to false, and this.retryDelay will be used
|
|
8818
|
-
return setTimeout(resolve, retryAfterDelay || this.retryDelay);
|
|
8819
|
-
});
|
|
8820
|
-
return true;
|
|
8821
|
-
}
|
|
8822
|
-
return false;
|
|
8823
|
-
}
|
|
8824
|
-
}
|
|
8825
|
-
|
|
8826
|
-
/*
|
|
8827
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8828
|
-
* Licensed under the MIT License.
|
|
8829
|
-
*/
|
|
8830
|
-
class HttpClientWithRetries {
|
|
8831
|
-
constructor(httpClientNoRetries, retryPolicy) {
|
|
8832
|
-
this.httpClientNoRetries = httpClientNoRetries;
|
|
8833
|
-
this.retryPolicy = retryPolicy;
|
|
8834
|
-
}
|
|
8835
|
-
async sendNetworkRequestAsyncHelper(httpMethod, url, options) {
|
|
8836
|
-
if (httpMethod === HttpMethod.GET) {
|
|
8837
|
-
return this.httpClientNoRetries.sendGetRequestAsync(url, options);
|
|
8838
|
-
}
|
|
8839
|
-
else {
|
|
8840
|
-
return this.httpClientNoRetries.sendPostRequestAsync(url, options);
|
|
8841
|
-
}
|
|
8842
|
-
}
|
|
8843
|
-
async sendNetworkRequestAsync(httpMethod, url, options) {
|
|
8844
|
-
// the underlying network module (custom or HttpClient) will make the call
|
|
8845
|
-
let response = await this.sendNetworkRequestAsyncHelper(httpMethod, url, options);
|
|
8846
|
-
let currentRetry = 0;
|
|
8847
|
-
while (await this.retryPolicy.pauseForRetry(response.status, currentRetry, response.headers[HeaderNames.RETRY_AFTER])) {
|
|
8848
|
-
response = await this.sendNetworkRequestAsyncHelper(httpMethod, url, options);
|
|
8849
|
-
currentRetry++;
|
|
8850
|
-
}
|
|
8851
|
-
return response;
|
|
8852
|
-
}
|
|
8853
|
-
async sendGetRequestAsync(url, options) {
|
|
8854
|
-
return this.sendNetworkRequestAsync(HttpMethod.GET, url, options);
|
|
8855
|
-
}
|
|
8856
|
-
async sendPostRequestAsync(url, options) {
|
|
8857
|
-
return this.sendNetworkRequestAsync(HttpMethod.POST, url, options);
|
|
8858
|
-
}
|
|
8859
|
-
}
|
|
8860
|
-
|
|
8861
8667
|
/*
|
|
8862
8668
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8863
8669
|
* Licensed under the MIT License.
|
|
@@ -9047,17 +8853,13 @@ function buildManagedIdentityConfiguration({ managedIdentityIdParams, system, })
|
|
|
9047
8853
|
else {
|
|
9048
8854
|
networkClient = new HttpClient(system?.proxyUrl, system?.customAgentOptions);
|
|
9049
8855
|
}
|
|
9050
|
-
// wrap the network client with a retry policy if the developer has not disabled the option to do so
|
|
9051
|
-
if (!system?.disableInternalRetries) {
|
|
9052
|
-
const linearRetryPolicy = new LinearRetryPolicy(MANAGED_IDENTITY_MAX_RETRIES, MANAGED_IDENTITY_RETRY_DELAY, MANAGED_IDENTITY_HTTP_STATUS_CODES_TO_RETRY_ON);
|
|
9053
|
-
networkClient = new HttpClientWithRetries(networkClient, linearRetryPolicy);
|
|
9054
|
-
}
|
|
9055
8856
|
return {
|
|
9056
8857
|
managedIdentityId: managedIdentityId,
|
|
9057
8858
|
system: {
|
|
9058
8859
|
loggerOptions,
|
|
9059
8860
|
networkClient,
|
|
9060
8861
|
},
|
|
8862
|
+
disableInternalRetries: system?.disableInternalRetries || false,
|
|
9061
8863
|
};
|
|
9062
8864
|
}
|
|
9063
8865
|
|
|
@@ -10131,7 +9933,7 @@ class ClientAssertion {
|
|
|
10131
9933
|
|
|
10132
9934
|
/* eslint-disable header/header */
|
|
10133
9935
|
const name = "@azure/msal-node";
|
|
10134
|
-
const version = "3.
|
|
9936
|
+
const version = "3.4.0";
|
|
10135
9937
|
|
|
10136
9938
|
/*
|
|
10137
9939
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
@@ -10193,42 +9995,76 @@ class UsernamePasswordClient extends BaseClient {
|
|
|
10193
9995
|
* @param request - CommonUsernamePasswordRequest provided by the developer
|
|
10194
9996
|
*/
|
|
10195
9997
|
async createTokenRequestBody(request) {
|
|
10196
|
-
const
|
|
10197
|
-
|
|
10198
|
-
|
|
10199
|
-
|
|
10200
|
-
|
|
10201
|
-
|
|
10202
|
-
|
|
10203
|
-
|
|
10204
|
-
|
|
10205
|
-
|
|
10206
|
-
|
|
9998
|
+
const parameters = new Map();
|
|
9999
|
+
addClientId(parameters, this.config.authOptions.clientId);
|
|
10000
|
+
addUsername(parameters, request.username);
|
|
10001
|
+
addPassword(parameters, request.password);
|
|
10002
|
+
addScopes(parameters, request.scopes);
|
|
10003
|
+
addResponseTypeForTokenAndIdToken(parameters);
|
|
10004
|
+
addGrantType(parameters, GrantType.RESOURCE_OWNER_PASSWORD_GRANT);
|
|
10005
|
+
addClientInfo(parameters);
|
|
10006
|
+
addLibraryInfo(parameters, this.config.libraryInfo);
|
|
10007
|
+
addApplicationTelemetry(parameters, this.config.telemetry.application);
|
|
10008
|
+
addThrottling(parameters);
|
|
10207
10009
|
if (this.serverTelemetryManager) {
|
|
10208
|
-
|
|
10010
|
+
addServerTelemetry(parameters, this.serverTelemetryManager);
|
|
10209
10011
|
}
|
|
10210
10012
|
const correlationId = request.correlationId ||
|
|
10211
10013
|
this.config.cryptoInterface.createNewGuid();
|
|
10212
|
-
|
|
10014
|
+
addCorrelationId(parameters, correlationId);
|
|
10213
10015
|
if (this.config.clientCredentials.clientSecret) {
|
|
10214
|
-
|
|
10016
|
+
addClientSecret(parameters, this.config.clientCredentials.clientSecret);
|
|
10215
10017
|
}
|
|
10216
10018
|
const clientAssertion = this.config.clientCredentials.clientAssertion;
|
|
10217
10019
|
if (clientAssertion) {
|
|
10218
|
-
|
|
10219
|
-
|
|
10020
|
+
addClientAssertion(parameters, await getClientAssertion(clientAssertion.assertion, this.config.authOptions.clientId, request.resourceRequestUri));
|
|
10021
|
+
addClientAssertionType(parameters, clientAssertion.assertionType);
|
|
10220
10022
|
}
|
|
10221
10023
|
if (!StringUtils.isEmptyObj(request.claims) ||
|
|
10222
10024
|
(this.config.authOptions.clientCapabilities &&
|
|
10223
10025
|
this.config.authOptions.clientCapabilities.length > 0)) {
|
|
10224
|
-
|
|
10026
|
+
addClaims(parameters, request.claims, this.config.authOptions.clientCapabilities);
|
|
10225
10027
|
}
|
|
10226
10028
|
if (this.config.systemOptions.preventCorsPreflight &&
|
|
10227
10029
|
request.username) {
|
|
10228
|
-
|
|
10030
|
+
addCcsUpn(parameters, request.username);
|
|
10229
10031
|
}
|
|
10230
|
-
return
|
|
10032
|
+
return mapToQueryString(parameters);
|
|
10033
|
+
}
|
|
10034
|
+
}
|
|
10035
|
+
|
|
10036
|
+
/*
|
|
10037
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
10038
|
+
* Licensed under the MIT License.
|
|
10039
|
+
*/
|
|
10040
|
+
/**
|
|
10041
|
+
* Constructs the full /authorize URL with request parameters
|
|
10042
|
+
* @param config
|
|
10043
|
+
* @param authority
|
|
10044
|
+
* @param request
|
|
10045
|
+
* @param logger
|
|
10046
|
+
* @returns
|
|
10047
|
+
*/
|
|
10048
|
+
function getAuthCodeRequestUrl(config, authority, request, logger) {
|
|
10049
|
+
const parameters = getStandardAuthorizeRequestParameters({
|
|
10050
|
+
...config.auth,
|
|
10051
|
+
authority: authority,
|
|
10052
|
+
redirectUri: request.redirectUri || "",
|
|
10053
|
+
}, request, logger);
|
|
10054
|
+
addLibraryInfo(parameters, {
|
|
10055
|
+
sku: Constants.MSAL_SKU,
|
|
10056
|
+
version: version,
|
|
10057
|
+
cpu: process.arch || "",
|
|
10058
|
+
os: process.platform || "",
|
|
10059
|
+
});
|
|
10060
|
+
if (config.auth.protocolMode !== ProtocolMode.OIDC) {
|
|
10061
|
+
addApplicationTelemetry(parameters, config.telemetry.application);
|
|
10062
|
+
}
|
|
10063
|
+
addResponseTypeCode(parameters);
|
|
10064
|
+
if (request.codeChallenge && request.codeChallengeMethod) {
|
|
10065
|
+
addCodeChallengeParams(parameters, request.codeChallenge, request.codeChallengeMethod);
|
|
10231
10066
|
}
|
|
10067
|
+
return getAuthorizeUrl(authority, parameters);
|
|
10232
10068
|
}
|
|
10233
10069
|
|
|
10234
10070
|
/*
|
|
@@ -10267,10 +10103,8 @@ class ClientApplication {
|
|
|
10267
10103
|
responseMode: request.responseMode || ResponseMode.QUERY,
|
|
10268
10104
|
authenticationScheme: AuthenticationScheme.BEARER,
|
|
10269
10105
|
};
|
|
10270
|
-
const
|
|
10271
|
-
|
|
10272
|
-
this.logger.verbose("Auth code client created", validRequest.correlationId);
|
|
10273
|
-
return authorizationCodeClient.getAuthCodeUrl(validRequest);
|
|
10106
|
+
const discoveredAuthority = await this.createAuthority(validRequest.authority, validRequest.correlationId, undefined, request.azureCloudOptions);
|
|
10107
|
+
return getAuthCodeRequestUrl(this.config, discoveredAuthority, validRequest, this.logger);
|
|
10274
10108
|
}
|
|
10275
10109
|
/**
|
|
10276
10110
|
* Acquires a token by exchanging the Authorization Code received from the first step of OAuth2.0
|
|
@@ -10295,7 +10129,8 @@ class ClientApplication {
|
|
|
10295
10129
|
};
|
|
10296
10130
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByCode, validRequest.correlationId);
|
|
10297
10131
|
try {
|
|
10298
|
-
const
|
|
10132
|
+
const discoveredAuthority = await this.createAuthority(validRequest.authority, validRequest.correlationId, undefined, request.azureCloudOptions);
|
|
10133
|
+
const authClientConfig = await this.buildOauthClientConfiguration(discoveredAuthority, validRequest.correlationId, validRequest.redirectUri, serverTelemetryManager);
|
|
10299
10134
|
const authorizationCodeClient = new AuthorizationCodeClient(authClientConfig);
|
|
10300
10135
|
this.logger.verbose("Auth code client created", validRequest.correlationId);
|
|
10301
10136
|
return await authorizationCodeClient.acquireToken(validRequest, authCodePayLoad);
|
|
@@ -10324,7 +10159,8 @@ class ClientApplication {
|
|
|
10324
10159
|
};
|
|
10325
10160
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByRefreshToken, validRequest.correlationId);
|
|
10326
10161
|
try {
|
|
10327
|
-
const
|
|
10162
|
+
const discoveredAuthority = await this.createAuthority(validRequest.authority, validRequest.correlationId, undefined, request.azureCloudOptions);
|
|
10163
|
+
const refreshTokenClientConfig = await this.buildOauthClientConfiguration(discoveredAuthority, validRequest.correlationId, validRequest.redirectUri || "", serverTelemetryManager);
|
|
10328
10164
|
const refreshTokenClient = new RefreshTokenClient(refreshTokenClientConfig);
|
|
10329
10165
|
this.logger.verbose("Refresh token client created", validRequest.correlationId);
|
|
10330
10166
|
return await refreshTokenClient.acquireToken(validRequest);
|
|
@@ -10353,7 +10189,8 @@ class ClientApplication {
|
|
|
10353
10189
|
};
|
|
10354
10190
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenSilent, validRequest.correlationId, validRequest.forceRefresh);
|
|
10355
10191
|
try {
|
|
10356
|
-
const
|
|
10192
|
+
const discoveredAuthority = await this.createAuthority(validRequest.authority, validRequest.correlationId, undefined, request.azureCloudOptions);
|
|
10193
|
+
const clientConfiguration = await this.buildOauthClientConfiguration(discoveredAuthority, validRequest.correlationId, validRequest.redirectUri || "", serverTelemetryManager);
|
|
10357
10194
|
const silentFlowClient = new SilentFlowClient(clientConfiguration);
|
|
10358
10195
|
this.logger.verbose("Silent flow client created", validRequest.correlationId);
|
|
10359
10196
|
try {
|
|
@@ -10419,7 +10256,8 @@ class ClientApplication {
|
|
|
10419
10256
|
};
|
|
10420
10257
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByUsernamePassword, validRequest.correlationId);
|
|
10421
10258
|
try {
|
|
10422
|
-
const
|
|
10259
|
+
const discoveredAuthority = await this.createAuthority(validRequest.authority, validRequest.correlationId, undefined, request.azureCloudOptions);
|
|
10260
|
+
const usernamePasswordClientConfig = await this.buildOauthClientConfiguration(discoveredAuthority, validRequest.correlationId, "", serverTelemetryManager);
|
|
10423
10261
|
const usernamePasswordClient = new UsernamePasswordClient(usernamePasswordClientConfig);
|
|
10424
10262
|
this.logger.verbose("Username password client created", validRequest.correlationId);
|
|
10425
10263
|
return await usernamePasswordClient.acquireToken(validRequest);
|
|
@@ -10474,14 +10312,8 @@ class ClientApplication {
|
|
|
10474
10312
|
* @param authority - user passed authority in configuration
|
|
10475
10313
|
* @param serverTelemetryManager - initializes servertelemetry if passed
|
|
10476
10314
|
*/
|
|
10477
|
-
async buildOauthClientConfiguration(
|
|
10315
|
+
async buildOauthClientConfiguration(discoveredAuthority, requestCorrelationId, redirectUri, serverTelemetryManager) {
|
|
10478
10316
|
this.logger.verbose("buildOauthClientConfiguration called", requestCorrelationId);
|
|
10479
|
-
// precedence - azureCloudInstance + tenant >> authority and request >> config
|
|
10480
|
-
const userAzureCloudOptions = azureCloudOptions
|
|
10481
|
-
? azureCloudOptions
|
|
10482
|
-
: this.config.auth.azureCloudOptions;
|
|
10483
|
-
// using null assertion operator as we ensure that all config values have default values in buildConfiguration()
|
|
10484
|
-
const discoveredAuthority = await this.createAuthority(authority, requestCorrelationId, azureRegionConfiguration, userAzureCloudOptions);
|
|
10485
10317
|
this.logger.info(`Building oauth client configuration with the following authority: ${discoveredAuthority.tokenEndpoint}.`, requestCorrelationId);
|
|
10486
10318
|
serverTelemetryManager?.updateRegionDiscoveryMetadata(discoveredAuthority.regionDiscoveryMetadata);
|
|
10487
10319
|
const clientConfiguration = {
|
|
@@ -10583,7 +10415,7 @@ class ClientApplication {
|
|
|
10583
10415
|
async createAuthority(authorityString, requestCorrelationId, azureRegionConfiguration, azureCloudOptions) {
|
|
10584
10416
|
this.logger.verbose("createAuthority called", requestCorrelationId);
|
|
10585
10417
|
// build authority string based on auth params - azureCloudInstance is prioritized if provided
|
|
10586
|
-
const authorityUrl = Authority.generateAuthority(authorityString, azureCloudOptions);
|
|
10418
|
+
const authorityUrl = Authority.generateAuthority(authorityString, azureCloudOptions || this.config.auth.azureCloudOptions);
|
|
10587
10419
|
const authorityOptions = {
|
|
10588
10420
|
protocolMode: this.config.auth.protocolMode,
|
|
10589
10421
|
knownAuthorities: this.config.auth.knownAuthorities,
|
|
@@ -10633,7 +10465,8 @@ class LoopbackClient {
|
|
|
10633
10465
|
}
|
|
10634
10466
|
const redirectUri = this.getRedirectUri();
|
|
10635
10467
|
const parsedUrl = new URL(url, redirectUri);
|
|
10636
|
-
const authCodeResponse = getDeserializedResponse(parsedUrl.search) ||
|
|
10468
|
+
const authCodeResponse = getDeserializedResponse(parsedUrl.search) ||
|
|
10469
|
+
{};
|
|
10637
10470
|
if (authCodeResponse.code) {
|
|
10638
10471
|
res.writeHead(HttpStatus.REDIRECT, {
|
|
10639
10472
|
location: redirectUri,
|
|
@@ -10738,11 +10571,11 @@ class DeviceCodeClient extends BaseClient {
|
|
|
10738
10571
|
* @param request - developer provided CommonDeviceCodeRequest
|
|
10739
10572
|
*/
|
|
10740
10573
|
createExtraQueryParameters(request) {
|
|
10741
|
-
const
|
|
10574
|
+
const parameters = new Map();
|
|
10742
10575
|
if (request.extraQueryParameters) {
|
|
10743
|
-
|
|
10576
|
+
addExtraQueryParameters(parameters, request.extraQueryParameters);
|
|
10744
10577
|
}
|
|
10745
|
-
return
|
|
10578
|
+
return mapToQueryString(parameters);
|
|
10746
10579
|
}
|
|
10747
10580
|
/**
|
|
10748
10581
|
* Executes POST request to device code endpoint
|
|
@@ -10771,18 +10604,18 @@ class DeviceCodeClient extends BaseClient {
|
|
|
10771
10604
|
* @param request - developer provided CommonDeviceCodeRequest
|
|
10772
10605
|
*/
|
|
10773
10606
|
createQueryString(request) {
|
|
10774
|
-
const
|
|
10775
|
-
|
|
10776
|
-
|
|
10607
|
+
const parameters = new Map();
|
|
10608
|
+
addScopes(parameters, request.scopes);
|
|
10609
|
+
addClientId(parameters, this.config.authOptions.clientId);
|
|
10777
10610
|
if (request.extraQueryParameters) {
|
|
10778
|
-
|
|
10611
|
+
addExtraQueryParameters(parameters, request.extraQueryParameters);
|
|
10779
10612
|
}
|
|
10780
10613
|
if (request.claims ||
|
|
10781
10614
|
(this.config.authOptions.clientCapabilities &&
|
|
10782
10615
|
this.config.authOptions.clientCapabilities.length > 0)) {
|
|
10783
|
-
|
|
10616
|
+
addClaims(parameters, request.claims, this.config.authOptions.clientCapabilities);
|
|
10784
10617
|
}
|
|
10785
|
-
return
|
|
10618
|
+
return mapToQueryString(parameters);
|
|
10786
10619
|
}
|
|
10787
10620
|
/**
|
|
10788
10621
|
* Breaks the polling with specific conditions
|
|
@@ -10872,27 +10705,27 @@ class DeviceCodeClient extends BaseClient {
|
|
|
10872
10705
|
* @param deviceCodeResponse - DeviceCodeResponse returned by the security token service device code endpoint
|
|
10873
10706
|
*/
|
|
10874
10707
|
createTokenRequestBody(request, deviceCodeResponse) {
|
|
10875
|
-
const
|
|
10876
|
-
|
|
10877
|
-
|
|
10878
|
-
|
|
10879
|
-
|
|
10708
|
+
const parameters = new Map();
|
|
10709
|
+
addScopes(parameters, request.scopes);
|
|
10710
|
+
addClientId(parameters, this.config.authOptions.clientId);
|
|
10711
|
+
addGrantType(parameters, GrantType.DEVICE_CODE_GRANT);
|
|
10712
|
+
addDeviceCode(parameters, deviceCodeResponse.deviceCode);
|
|
10880
10713
|
const correlationId = request.correlationId ||
|
|
10881
10714
|
this.config.cryptoInterface.createNewGuid();
|
|
10882
|
-
|
|
10883
|
-
|
|
10884
|
-
|
|
10885
|
-
|
|
10886
|
-
|
|
10715
|
+
addCorrelationId(parameters, correlationId);
|
|
10716
|
+
addClientInfo(parameters);
|
|
10717
|
+
addLibraryInfo(parameters, this.config.libraryInfo);
|
|
10718
|
+
addApplicationTelemetry(parameters, this.config.telemetry.application);
|
|
10719
|
+
addThrottling(parameters);
|
|
10887
10720
|
if (this.serverTelemetryManager) {
|
|
10888
|
-
|
|
10721
|
+
addServerTelemetry(parameters, this.serverTelemetryManager);
|
|
10889
10722
|
}
|
|
10890
10723
|
if (!StringUtils.isEmptyObj(request.claims) ||
|
|
10891
10724
|
(this.config.authOptions.clientCapabilities &&
|
|
10892
10725
|
this.config.authOptions.clientCapabilities.length > 0)) {
|
|
10893
|
-
|
|
10726
|
+
addClaims(parameters, request.claims, this.config.authOptions.clientCapabilities);
|
|
10894
10727
|
}
|
|
10895
|
-
return
|
|
10728
|
+
return mapToQueryString(parameters);
|
|
10896
10729
|
}
|
|
10897
10730
|
}
|
|
10898
10731
|
|
|
@@ -10953,7 +10786,8 @@ class PublicClientApplication extends ClientApplication {
|
|
|
10953
10786
|
const validRequest = Object.assign(request, await this.initializeBaseRequest(request));
|
|
10954
10787
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByDeviceCode, validRequest.correlationId);
|
|
10955
10788
|
try {
|
|
10956
|
-
const
|
|
10789
|
+
const discoveredAuthority = await this.createAuthority(validRequest.authority, validRequest.correlationId, undefined, request.azureCloudOptions);
|
|
10790
|
+
const deviceCodeConfig = await this.buildOauthClientConfiguration(discoveredAuthority, validRequest.correlationId, "", serverTelemetryManager);
|
|
10957
10791
|
const deviceCodeClient = new DeviceCodeClient(deviceCodeConfig);
|
|
10958
10792
|
this.logger.verbose("Device code client created", validRequest.correlationId);
|
|
10959
10793
|
return await deviceCodeClient.acquireToken(validRequest);
|
|
@@ -11298,35 +11132,35 @@ class ClientCredentialClient extends BaseClient {
|
|
|
11298
11132
|
* @param request - CommonClientCredentialRequest provided by the developer
|
|
11299
11133
|
*/
|
|
11300
11134
|
async createTokenRequestBody(request) {
|
|
11301
|
-
const
|
|
11302
|
-
|
|
11303
|
-
|
|
11304
|
-
|
|
11305
|
-
|
|
11306
|
-
|
|
11307
|
-
|
|
11135
|
+
const parameters = new Map();
|
|
11136
|
+
addClientId(parameters, this.config.authOptions.clientId);
|
|
11137
|
+
addScopes(parameters, request.scopes, false);
|
|
11138
|
+
addGrantType(parameters, GrantType.CLIENT_CREDENTIALS_GRANT);
|
|
11139
|
+
addLibraryInfo(parameters, this.config.libraryInfo);
|
|
11140
|
+
addApplicationTelemetry(parameters, this.config.telemetry.application);
|
|
11141
|
+
addThrottling(parameters);
|
|
11308
11142
|
if (this.serverTelemetryManager) {
|
|
11309
|
-
|
|
11143
|
+
addServerTelemetry(parameters, this.serverTelemetryManager);
|
|
11310
11144
|
}
|
|
11311
11145
|
const correlationId = request.correlationId ||
|
|
11312
11146
|
this.config.cryptoInterface.createNewGuid();
|
|
11313
|
-
|
|
11147
|
+
addCorrelationId(parameters, correlationId);
|
|
11314
11148
|
if (this.config.clientCredentials.clientSecret) {
|
|
11315
|
-
|
|
11149
|
+
addClientSecret(parameters, this.config.clientCredentials.clientSecret);
|
|
11316
11150
|
}
|
|
11317
11151
|
// Use clientAssertion from request, fallback to client assertion in base configuration
|
|
11318
11152
|
const clientAssertion = request.clientAssertion ||
|
|
11319
11153
|
this.config.clientCredentials.clientAssertion;
|
|
11320
11154
|
if (clientAssertion) {
|
|
11321
|
-
|
|
11322
|
-
|
|
11155
|
+
addClientAssertion(parameters, await getClientAssertion(clientAssertion.assertion, this.config.authOptions.clientId, request.resourceRequestUri));
|
|
11156
|
+
addClientAssertionType(parameters, clientAssertion.assertionType);
|
|
11323
11157
|
}
|
|
11324
11158
|
if (!StringUtils.isEmptyObj(request.claims) ||
|
|
11325
11159
|
(this.config.authOptions.clientCapabilities &&
|
|
11326
11160
|
this.config.authOptions.clientCapabilities.length > 0)) {
|
|
11327
|
-
|
|
11161
|
+
addClaims(parameters, request.claims, this.config.authOptions.clientCapabilities);
|
|
11328
11162
|
}
|
|
11329
|
-
return
|
|
11163
|
+
return mapToQueryString(parameters);
|
|
11330
11164
|
}
|
|
11331
11165
|
}
|
|
11332
11166
|
|
|
@@ -11499,36 +11333,36 @@ class OnBehalfOfClient extends BaseClient {
|
|
|
11499
11333
|
* @param request - developer provided CommonOnBehalfOfRequest
|
|
11500
11334
|
*/
|
|
11501
11335
|
async createTokenRequestBody(request) {
|
|
11502
|
-
const
|
|
11503
|
-
|
|
11504
|
-
|
|
11505
|
-
|
|
11506
|
-
|
|
11507
|
-
|
|
11508
|
-
|
|
11509
|
-
|
|
11336
|
+
const parameters = new Map();
|
|
11337
|
+
addClientId(parameters, this.config.authOptions.clientId);
|
|
11338
|
+
addScopes(parameters, request.scopes);
|
|
11339
|
+
addGrantType(parameters, GrantType.JWT_BEARER);
|
|
11340
|
+
addClientInfo(parameters);
|
|
11341
|
+
addLibraryInfo(parameters, this.config.libraryInfo);
|
|
11342
|
+
addApplicationTelemetry(parameters, this.config.telemetry.application);
|
|
11343
|
+
addThrottling(parameters);
|
|
11510
11344
|
if (this.serverTelemetryManager) {
|
|
11511
|
-
|
|
11345
|
+
addServerTelemetry(parameters, this.serverTelemetryManager);
|
|
11512
11346
|
}
|
|
11513
11347
|
const correlationId = request.correlationId ||
|
|
11514
11348
|
this.config.cryptoInterface.createNewGuid();
|
|
11515
|
-
|
|
11516
|
-
|
|
11517
|
-
|
|
11349
|
+
addCorrelationId(parameters, correlationId);
|
|
11350
|
+
addRequestTokenUse(parameters, ON_BEHALF_OF);
|
|
11351
|
+
addOboAssertion(parameters, request.oboAssertion);
|
|
11518
11352
|
if (this.config.clientCredentials.clientSecret) {
|
|
11519
|
-
|
|
11353
|
+
addClientSecret(parameters, this.config.clientCredentials.clientSecret);
|
|
11520
11354
|
}
|
|
11521
11355
|
const clientAssertion = this.config.clientCredentials.clientAssertion;
|
|
11522
11356
|
if (clientAssertion) {
|
|
11523
|
-
|
|
11524
|
-
|
|
11357
|
+
addClientAssertion(parameters, await getClientAssertion(clientAssertion.assertion, this.config.authOptions.clientId, request.resourceRequestUri));
|
|
11358
|
+
addClientAssertionType(parameters, clientAssertion.assertionType);
|
|
11525
11359
|
}
|
|
11526
11360
|
if (request.claims ||
|
|
11527
11361
|
(this.config.authOptions.clientCapabilities &&
|
|
11528
11362
|
this.config.authOptions.clientCapabilities.length > 0)) {
|
|
11529
|
-
|
|
11363
|
+
addClaims(parameters, request.claims, this.config.authOptions.clientCapabilities);
|
|
11530
11364
|
}
|
|
11531
|
-
return
|
|
11365
|
+
return mapToQueryString(parameters);
|
|
11532
11366
|
}
|
|
11533
11367
|
}
|
|
11534
11368
|
|
|
@@ -11668,7 +11502,8 @@ class ConfidentialClientApplication extends ClientApplication {
|
|
|
11668
11502
|
};
|
|
11669
11503
|
const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenByClientCredential, validRequest.correlationId, validRequest.skipCache);
|
|
11670
11504
|
try {
|
|
11671
|
-
const
|
|
11505
|
+
const discoveredAuthority = await this.createAuthority(validRequest.authority, validRequest.correlationId, azureRegionConfiguration, request.azureCloudOptions);
|
|
11506
|
+
const clientCredentialConfig = await this.buildOauthClientConfiguration(discoveredAuthority, validRequest.correlationId, "", serverTelemetryManager);
|
|
11672
11507
|
const clientCredentialClient = new ClientCredentialClient(clientCredentialConfig, this.appTokenProvider);
|
|
11673
11508
|
this.logger.verbose("Client credential client created", validRequest.correlationId);
|
|
11674
11509
|
return await clientCredentialClient.acquireToken(validRequest);
|
|
@@ -11699,7 +11534,8 @@ class ConfidentialClientApplication extends ClientApplication {
|
|
|
11699
11534
|
...(await this.initializeBaseRequest(request)),
|
|
11700
11535
|
};
|
|
11701
11536
|
try {
|
|
11702
|
-
const
|
|
11537
|
+
const discoveredAuthority = await this.createAuthority(validRequest.authority, validRequest.correlationId, undefined, request.azureCloudOptions);
|
|
11538
|
+
const onBehalfOfConfig = await this.buildOauthClientConfiguration(discoveredAuthority, validRequest.correlationId, "", undefined);
|
|
11703
11539
|
const oboClient = new OnBehalfOfClient(onBehalfOfConfig);
|
|
11704
11540
|
this.logger.verbose("On behalf of client created", validRequest.correlationId);
|
|
11705
11541
|
return await oboClient.acquireToken(validRequest);
|
|
@@ -11732,6 +11568,41 @@ function isIso8601(dateString) {
|
|
|
11732
11568
|
return !isNaN(date.getTime()) && date.toISOString() === dateString;
|
|
11733
11569
|
}
|
|
11734
11570
|
|
|
11571
|
+
/*
|
|
11572
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11573
|
+
* Licensed under the MIT License.
|
|
11574
|
+
*/
|
|
11575
|
+
class HttpClientWithRetries {
|
|
11576
|
+
constructor(httpClientNoRetries, retryPolicy) {
|
|
11577
|
+
this.httpClientNoRetries = httpClientNoRetries;
|
|
11578
|
+
this.retryPolicy = retryPolicy;
|
|
11579
|
+
}
|
|
11580
|
+
async sendNetworkRequestAsyncHelper(httpMethod, url, options) {
|
|
11581
|
+
if (httpMethod === HttpMethod.GET) {
|
|
11582
|
+
return this.httpClientNoRetries.sendGetRequestAsync(url, options);
|
|
11583
|
+
}
|
|
11584
|
+
else {
|
|
11585
|
+
return this.httpClientNoRetries.sendPostRequestAsync(url, options);
|
|
11586
|
+
}
|
|
11587
|
+
}
|
|
11588
|
+
async sendNetworkRequestAsync(httpMethod, url, options) {
|
|
11589
|
+
// the underlying network module (custom or HttpClient) will make the call
|
|
11590
|
+
let response = await this.sendNetworkRequestAsyncHelper(httpMethod, url, options);
|
|
11591
|
+
let currentRetry = 0;
|
|
11592
|
+
while (await this.retryPolicy.pauseForRetry(response.status, currentRetry, response.headers[HeaderNames.RETRY_AFTER])) {
|
|
11593
|
+
response = await this.sendNetworkRequestAsyncHelper(httpMethod, url, options);
|
|
11594
|
+
currentRetry++;
|
|
11595
|
+
}
|
|
11596
|
+
return response;
|
|
11597
|
+
}
|
|
11598
|
+
async sendGetRequestAsync(url, options) {
|
|
11599
|
+
return this.sendNetworkRequestAsync(HttpMethod.GET, url, options);
|
|
11600
|
+
}
|
|
11601
|
+
async sendPostRequestAsync(url, options) {
|
|
11602
|
+
return this.sendNetworkRequestAsync(HttpMethod.POST, url, options);
|
|
11603
|
+
}
|
|
11604
|
+
}
|
|
11605
|
+
|
|
11735
11606
|
/*
|
|
11736
11607
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11737
11608
|
* Licensed under the MIT License.
|
|
@@ -11746,11 +11617,12 @@ const ManagedIdentityUserAssignedIdQueryParameterNames = {
|
|
|
11746
11617
|
MANAGED_IDENTITY_RESOURCE_ID_NON_IMDS: "mi_res_id",
|
|
11747
11618
|
};
|
|
11748
11619
|
class BaseManagedIdentitySource {
|
|
11749
|
-
constructor(logger, nodeStorage, networkClient, cryptoProvider) {
|
|
11620
|
+
constructor(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries) {
|
|
11750
11621
|
this.logger = logger;
|
|
11751
11622
|
this.nodeStorage = nodeStorage;
|
|
11752
11623
|
this.networkClient = networkClient;
|
|
11753
11624
|
this.cryptoProvider = cryptoProvider;
|
|
11625
|
+
this.disableInternalRetries = disableInternalRetries;
|
|
11754
11626
|
}
|
|
11755
11627
|
async getServerTokenResponseAsync(response,
|
|
11756
11628
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -11807,18 +11679,26 @@ class BaseManagedIdentitySource {
|
|
|
11807
11679
|
networkRequestOptions.body =
|
|
11808
11680
|
networkRequest.computeParametersBodyString();
|
|
11809
11681
|
}
|
|
11682
|
+
/**
|
|
11683
|
+
* Initializes the network client helper based on the retry policy configuration.
|
|
11684
|
+
* If internal retries are disabled, it uses the provided network client directly.
|
|
11685
|
+
* Otherwise, it wraps the network client with an HTTP client that supports retries.
|
|
11686
|
+
*/
|
|
11687
|
+
const networkClientHelper = this.disableInternalRetries
|
|
11688
|
+
? this.networkClient
|
|
11689
|
+
: new HttpClientWithRetries(this.networkClient, networkRequest.retryPolicy);
|
|
11810
11690
|
const reqTimestamp = nowSeconds();
|
|
11811
11691
|
let response;
|
|
11812
11692
|
try {
|
|
11813
11693
|
// Sources that send POST requests: Cloud Shell
|
|
11814
11694
|
if (networkRequest.httpMethod === HttpMethod.POST) {
|
|
11815
11695
|
response =
|
|
11816
|
-
await
|
|
11696
|
+
await networkClientHelper.sendPostRequestAsync(networkRequest.computeUri(), networkRequestOptions);
|
|
11817
11697
|
// Sources that send GET requests: App Service, Azure Arc, IMDS, Service Fabric
|
|
11818
11698
|
}
|
|
11819
11699
|
else {
|
|
11820
11700
|
response =
|
|
11821
|
-
await
|
|
11701
|
+
await networkClientHelper.sendGetRequestAsync(networkRequest.computeUri(), networkRequestOptions);
|
|
11822
11702
|
}
|
|
11823
11703
|
}
|
|
11824
11704
|
catch (error) {
|
|
@@ -11830,7 +11710,7 @@ class BaseManagedIdentitySource {
|
|
|
11830
11710
|
}
|
|
11831
11711
|
}
|
|
11832
11712
|
const responseHandler = new ResponseHandler(managedIdentityId.id, this.nodeStorage, this.cryptoProvider, this.logger, null, null);
|
|
11833
|
-
const serverTokenResponse = await this.getServerTokenResponseAsync(response,
|
|
11713
|
+
const serverTokenResponse = await this.getServerTokenResponseAsync(response, networkClientHelper, networkRequest, networkRequestOptions);
|
|
11834
11714
|
responseHandler.validateTokenResponse(serverTokenResponse, refreshAccessToken);
|
|
11835
11715
|
// caches the token
|
|
11836
11716
|
return responseHandler.handleServerTokenResponse(serverTokenResponse, fakeAuthority, reqTimestamp, managedIdentityRequest);
|
|
@@ -11863,32 +11743,75 @@ BaseManagedIdentitySource.getValidatedEnvVariableUrlString = (envVariableStringN
|
|
|
11863
11743
|
}
|
|
11864
11744
|
};
|
|
11865
11745
|
|
|
11746
|
+
/*
|
|
11747
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11748
|
+
* Licensed under the MIT License.
|
|
11749
|
+
*/
|
|
11750
|
+
class LinearRetryPolicy {
|
|
11751
|
+
constructor(maxRetries, retryDelay, httpStatusCodesToRetryOn) {
|
|
11752
|
+
this.maxRetries = maxRetries;
|
|
11753
|
+
this.retryDelay = retryDelay;
|
|
11754
|
+
this.httpStatusCodesToRetryOn = httpStatusCodesToRetryOn;
|
|
11755
|
+
}
|
|
11756
|
+
retryAfterMillisecondsToSleep(retryHeader) {
|
|
11757
|
+
if (!retryHeader) {
|
|
11758
|
+
return 0;
|
|
11759
|
+
}
|
|
11760
|
+
// retry-after header is in seconds
|
|
11761
|
+
let millisToSleep = Math.round(parseFloat(retryHeader) * 1000);
|
|
11762
|
+
/*
|
|
11763
|
+
* retry-after header is in HTTP Date format
|
|
11764
|
+
* <day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT
|
|
11765
|
+
*/
|
|
11766
|
+
if (isNaN(millisToSleep)) {
|
|
11767
|
+
millisToSleep = Math.max(0,
|
|
11768
|
+
// .valueOf() is needed to subtract dates in TypeScript
|
|
11769
|
+
new Date(retryHeader).valueOf() - new Date().valueOf());
|
|
11770
|
+
}
|
|
11771
|
+
return millisToSleep;
|
|
11772
|
+
}
|
|
11773
|
+
async pauseForRetry(httpStatusCode, currentRetry, retryAfterHeader) {
|
|
11774
|
+
if (this.httpStatusCodesToRetryOn.includes(httpStatusCode) &&
|
|
11775
|
+
currentRetry < this.maxRetries) {
|
|
11776
|
+
const retryAfterDelay = this.retryAfterMillisecondsToSleep(retryAfterHeader);
|
|
11777
|
+
await new Promise((resolve) => {
|
|
11778
|
+
// retryAfterHeader value of 0 evaluates to false, and this.retryDelay will be used
|
|
11779
|
+
return setTimeout(resolve, retryAfterDelay || this.retryDelay);
|
|
11780
|
+
});
|
|
11781
|
+
return true;
|
|
11782
|
+
}
|
|
11783
|
+
return false;
|
|
11784
|
+
}
|
|
11785
|
+
}
|
|
11786
|
+
|
|
11866
11787
|
/*
|
|
11867
11788
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11868
11789
|
* Licensed under the MIT License.
|
|
11869
11790
|
*/
|
|
11870
11791
|
class ManagedIdentityRequestParameters {
|
|
11871
|
-
constructor(httpMethod, endpoint) {
|
|
11792
|
+
constructor(httpMethod, endpoint, retryPolicy) {
|
|
11872
11793
|
this.httpMethod = httpMethod;
|
|
11873
11794
|
this._baseEndpoint = endpoint;
|
|
11874
11795
|
this.headers = {};
|
|
11875
11796
|
this.bodyParameters = {};
|
|
11876
11797
|
this.queryParameters = {};
|
|
11798
|
+
const defaultRetryPolicy = new LinearRetryPolicy(MANAGED_IDENTITY_MAX_RETRIES, MANAGED_IDENTITY_RETRY_DELAY, MANAGED_IDENTITY_HTTP_STATUS_CODES_TO_RETRY_ON);
|
|
11799
|
+
this.retryPolicy = retryPolicy || defaultRetryPolicy;
|
|
11877
11800
|
}
|
|
11878
11801
|
computeUri() {
|
|
11879
|
-
const
|
|
11802
|
+
const parameters = new Map();
|
|
11880
11803
|
if (this.queryParameters) {
|
|
11881
|
-
|
|
11804
|
+
addExtraQueryParameters(parameters, this.queryParameters);
|
|
11882
11805
|
}
|
|
11883
|
-
const queryParametersString =
|
|
11806
|
+
const queryParametersString = mapToQueryString(parameters);
|
|
11884
11807
|
return UrlString.appendQueryString(this._baseEndpoint, queryParametersString);
|
|
11885
11808
|
}
|
|
11886
11809
|
computeParametersBodyString() {
|
|
11887
|
-
const
|
|
11810
|
+
const parameters = new Map();
|
|
11888
11811
|
if (this.bodyParameters) {
|
|
11889
|
-
|
|
11812
|
+
addExtraQueryParameters(parameters, this.bodyParameters);
|
|
11890
11813
|
}
|
|
11891
|
-
return
|
|
11814
|
+
return mapToQueryString(parameters);
|
|
11892
11815
|
}
|
|
11893
11816
|
}
|
|
11894
11817
|
|
|
@@ -11902,8 +11825,8 @@ const APP_SERVICE_MSI_API_VERSION = "2019-08-01";
|
|
|
11902
11825
|
* Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/AppServiceManagedIdentitySource.cs
|
|
11903
11826
|
*/
|
|
11904
11827
|
class AppService extends BaseManagedIdentitySource {
|
|
11905
|
-
constructor(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint, identityHeader) {
|
|
11906
|
-
super(logger, nodeStorage, networkClient, cryptoProvider);
|
|
11828
|
+
constructor(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, identityEndpoint, identityHeader) {
|
|
11829
|
+
super(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries);
|
|
11907
11830
|
this.identityEndpoint = identityEndpoint;
|
|
11908
11831
|
this.identityHeader = identityHeader;
|
|
11909
11832
|
}
|
|
@@ -11912,7 +11835,7 @@ class AppService extends BaseManagedIdentitySource {
|
|
|
11912
11835
|
const identityHeader = process.env[ManagedIdentityEnvironmentVariableNames.IDENTITY_HEADER];
|
|
11913
11836
|
return [identityEndpoint, identityHeader];
|
|
11914
11837
|
}
|
|
11915
|
-
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider) {
|
|
11838
|
+
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries) {
|
|
11916
11839
|
const [identityEndpoint, identityHeader] = AppService.getEnvironmentVariables();
|
|
11917
11840
|
// if either of the identity endpoint or identity header variables are undefined, this MSI provider is unavailable.
|
|
11918
11841
|
if (!identityEndpoint || !identityHeader) {
|
|
@@ -11921,7 +11844,7 @@ class AppService extends BaseManagedIdentitySource {
|
|
|
11921
11844
|
}
|
|
11922
11845
|
const validatedIdentityEndpoint = AppService.getValidatedEnvVariableUrlString(ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT, identityEndpoint, ManagedIdentitySourceNames.APP_SERVICE, logger);
|
|
11923
11846
|
logger.info(`[Managed Identity] Environment variables validation passed for ${ManagedIdentitySourceNames.APP_SERVICE} managed identity. Endpoint URI: ${validatedIdentityEndpoint}. Creating ${ManagedIdentitySourceNames.APP_SERVICE} managed identity.`);
|
|
11924
|
-
return new AppService(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint, identityHeader);
|
|
11847
|
+
return new AppService(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, identityEndpoint, identityHeader);
|
|
11925
11848
|
}
|
|
11926
11849
|
createRequest(resource, managedIdentityId) {
|
|
11927
11850
|
const request = new ManagedIdentityRequestParameters(HttpMethod.GET, this.identityEndpoint);
|
|
@@ -11957,8 +11880,8 @@ const AZURE_ARC_FILE_DETECTION = {
|
|
|
11957
11880
|
* Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/AzureArcManagedIdentitySource.cs
|
|
11958
11881
|
*/
|
|
11959
11882
|
class AzureArc extends BaseManagedIdentitySource {
|
|
11960
|
-
constructor(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint) {
|
|
11961
|
-
super(logger, nodeStorage, networkClient, cryptoProvider);
|
|
11883
|
+
constructor(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, identityEndpoint) {
|
|
11884
|
+
super(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries);
|
|
11962
11885
|
this.identityEndpoint = identityEndpoint;
|
|
11963
11886
|
}
|
|
11964
11887
|
static getEnvironmentVariables() {
|
|
@@ -11986,7 +11909,7 @@ class AzureArc extends BaseManagedIdentitySource {
|
|
|
11986
11909
|
}
|
|
11987
11910
|
return [identityEndpoint, imdsEndpoint];
|
|
11988
11911
|
}
|
|
11989
|
-
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) {
|
|
11912
|
+
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, managedIdentityId) {
|
|
11990
11913
|
const [identityEndpoint, imdsEndpoint] = AzureArc.getEnvironmentVariables();
|
|
11991
11914
|
// if either of the identity or imds endpoints are undefined (even after himds file detection)
|
|
11992
11915
|
if (!identityEndpoint || !imdsEndpoint) {
|
|
@@ -12010,7 +11933,7 @@ class AzureArc extends BaseManagedIdentitySource {
|
|
|
12010
11933
|
if (managedIdentityId.idType !== ManagedIdentityIdType.SYSTEM_ASSIGNED) {
|
|
12011
11934
|
throw createManagedIdentityError(unableToCreateAzureArc);
|
|
12012
11935
|
}
|
|
12013
|
-
return new AzureArc(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint);
|
|
11936
|
+
return new AzureArc(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, identityEndpoint);
|
|
12014
11937
|
}
|
|
12015
11938
|
createRequest(resource) {
|
|
12016
11939
|
const request = new ManagedIdentityRequestParameters(HttpMethod.GET, this.identityEndpoint.replace("localhost", "127.0.0.1"));
|
|
@@ -12100,15 +12023,15 @@ class AzureArc extends BaseManagedIdentitySource {
|
|
|
12100
12023
|
* Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/CloudShellManagedIdentitySource.cs
|
|
12101
12024
|
*/
|
|
12102
12025
|
class CloudShell extends BaseManagedIdentitySource {
|
|
12103
|
-
constructor(logger, nodeStorage, networkClient, cryptoProvider, msiEndpoint) {
|
|
12104
|
-
super(logger, nodeStorage, networkClient, cryptoProvider);
|
|
12026
|
+
constructor(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, msiEndpoint) {
|
|
12027
|
+
super(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries);
|
|
12105
12028
|
this.msiEndpoint = msiEndpoint;
|
|
12106
12029
|
}
|
|
12107
12030
|
static getEnvironmentVariables() {
|
|
12108
12031
|
const msiEndpoint = process.env[ManagedIdentityEnvironmentVariableNames.MSI_ENDPOINT];
|
|
12109
12032
|
return [msiEndpoint];
|
|
12110
12033
|
}
|
|
12111
|
-
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) {
|
|
12034
|
+
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, managedIdentityId) {
|
|
12112
12035
|
const [msiEndpoint] = CloudShell.getEnvironmentVariables();
|
|
12113
12036
|
// if the msi endpoint environment variable is undefined, this MSI provider is unavailable.
|
|
12114
12037
|
if (!msiEndpoint) {
|
|
@@ -12120,7 +12043,7 @@ class CloudShell extends BaseManagedIdentitySource {
|
|
|
12120
12043
|
if (managedIdentityId.idType !== ManagedIdentityIdType.SYSTEM_ASSIGNED) {
|
|
12121
12044
|
throw createManagedIdentityError(unableToCreateCloudShell);
|
|
12122
12045
|
}
|
|
12123
|
-
return new CloudShell(logger, nodeStorage, networkClient, cryptoProvider, msiEndpoint);
|
|
12046
|
+
return new CloudShell(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, msiEndpoint);
|
|
12124
12047
|
}
|
|
12125
12048
|
createRequest(resource) {
|
|
12126
12049
|
const request = new ManagedIdentityRequestParameters(HttpMethod.POST, this.msiEndpoint);
|
|
@@ -12141,11 +12064,11 @@ const DEFAULT_IMDS_ENDPOINT = `http://169.254.169.254${IMDS_TOKEN_PATH}`;
|
|
|
12141
12064
|
const IMDS_API_VERSION = "2018-02-01";
|
|
12142
12065
|
// Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/ImdsManagedIdentitySource.cs
|
|
12143
12066
|
class Imds extends BaseManagedIdentitySource {
|
|
12144
|
-
constructor(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint) {
|
|
12145
|
-
super(logger, nodeStorage, networkClient, cryptoProvider);
|
|
12067
|
+
constructor(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, identityEndpoint) {
|
|
12068
|
+
super(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries);
|
|
12146
12069
|
this.identityEndpoint = identityEndpoint;
|
|
12147
12070
|
}
|
|
12148
|
-
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider) {
|
|
12071
|
+
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries) {
|
|
12149
12072
|
let validatedIdentityEndpoint;
|
|
12150
12073
|
if (process.env[ManagedIdentityEnvironmentVariableNames
|
|
12151
12074
|
.AZURE_POD_IDENTITY_AUTHORITY_HOST]) {
|
|
@@ -12158,7 +12081,7 @@ class Imds extends BaseManagedIdentitySource {
|
|
|
12158
12081
|
logger.info(`[Managed Identity] Unable to find ${ManagedIdentityEnvironmentVariableNames.AZURE_POD_IDENTITY_AUTHORITY_HOST} environment variable for ${ManagedIdentitySourceNames.IMDS}, using the default endpoint.`);
|
|
12159
12082
|
validatedIdentityEndpoint = DEFAULT_IMDS_ENDPOINT;
|
|
12160
12083
|
}
|
|
12161
|
-
return new Imds(logger, nodeStorage, networkClient, cryptoProvider, validatedIdentityEndpoint);
|
|
12084
|
+
return new Imds(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, validatedIdentityEndpoint);
|
|
12162
12085
|
}
|
|
12163
12086
|
createRequest(resource, managedIdentityId) {
|
|
12164
12087
|
const request = new ManagedIdentityRequestParameters(HttpMethod.GET, this.identityEndpoint);
|
|
@@ -12186,8 +12109,8 @@ const SERVICE_FABRIC_MSI_API_VERSION = "2019-07-01-preview";
|
|
|
12186
12109
|
* Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/ServiceFabricManagedIdentitySource.cs
|
|
12187
12110
|
*/
|
|
12188
12111
|
class ServiceFabric extends BaseManagedIdentitySource {
|
|
12189
|
-
constructor(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint, identityHeader) {
|
|
12190
|
-
super(logger, nodeStorage, networkClient, cryptoProvider);
|
|
12112
|
+
constructor(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, identityEndpoint, identityHeader) {
|
|
12113
|
+
super(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries);
|
|
12191
12114
|
this.identityEndpoint = identityEndpoint;
|
|
12192
12115
|
this.identityHeader = identityHeader;
|
|
12193
12116
|
}
|
|
@@ -12198,7 +12121,7 @@ class ServiceFabric extends BaseManagedIdentitySource {
|
|
|
12198
12121
|
.IDENTITY_SERVER_THUMBPRINT];
|
|
12199
12122
|
return [identityEndpoint, identityHeader, identityServerThumbprint];
|
|
12200
12123
|
}
|
|
12201
|
-
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) {
|
|
12124
|
+
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, managedIdentityId) {
|
|
12202
12125
|
const [identityEndpoint, identityHeader, identityServerThumbprint] = ServiceFabric.getEnvironmentVariables();
|
|
12203
12126
|
/*
|
|
12204
12127
|
* if either of the identity endpoint, identity header, or identity server thumbprint
|
|
@@ -12213,7 +12136,7 @@ class ServiceFabric extends BaseManagedIdentitySource {
|
|
|
12213
12136
|
if (managedIdentityId.idType !== ManagedIdentityIdType.SYSTEM_ASSIGNED) {
|
|
12214
12137
|
logger.warning(`[Managed Identity] ${ManagedIdentitySourceNames.SERVICE_FABRIC} user assigned managed identity is configured in the cluster, not during runtime. See also: https://learn.microsoft.com/en-us/azure/service-fabric/configure-existing-cluster-enable-managed-identity-token-service.`);
|
|
12215
12138
|
}
|
|
12216
|
-
return new ServiceFabric(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint, identityHeader);
|
|
12139
|
+
return new ServiceFabric(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, identityEndpoint, identityHeader);
|
|
12217
12140
|
}
|
|
12218
12141
|
createRequest(resource, managedIdentityId) {
|
|
12219
12142
|
const request = new ManagedIdentityRequestParameters(HttpMethod.GET, this.identityEndpoint);
|
|
@@ -12236,8 +12159,8 @@ class ServiceFabric extends BaseManagedIdentitySource {
|
|
|
12236
12159
|
*/
|
|
12237
12160
|
const MACHINE_LEARNING_MSI_API_VERSION = "2017-09-01";
|
|
12238
12161
|
class MachineLearning extends BaseManagedIdentitySource {
|
|
12239
|
-
constructor(logger, nodeStorage, networkClient, cryptoProvider, msiEndpoint, secret) {
|
|
12240
|
-
super(logger, nodeStorage, networkClient, cryptoProvider);
|
|
12162
|
+
constructor(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, msiEndpoint, secret) {
|
|
12163
|
+
super(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries);
|
|
12241
12164
|
this.msiEndpoint = msiEndpoint;
|
|
12242
12165
|
this.secret = secret;
|
|
12243
12166
|
}
|
|
@@ -12246,7 +12169,7 @@ class MachineLearning extends BaseManagedIdentitySource {
|
|
|
12246
12169
|
const secret = process.env[ManagedIdentityEnvironmentVariableNames.MSI_SECRET];
|
|
12247
12170
|
return [msiEndpoint, secret];
|
|
12248
12171
|
}
|
|
12249
|
-
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider) {
|
|
12172
|
+
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries) {
|
|
12250
12173
|
const [msiEndpoint, secret] = MachineLearning.getEnvironmentVariables();
|
|
12251
12174
|
// if either of the MSI endpoint or MSI secret variables are undefined, this MSI provider is unavailable.
|
|
12252
12175
|
if (!msiEndpoint || !secret) {
|
|
@@ -12255,7 +12178,7 @@ class MachineLearning extends BaseManagedIdentitySource {
|
|
|
12255
12178
|
}
|
|
12256
12179
|
const validatedMsiEndpoint = MachineLearning.getValidatedEnvVariableUrlString(ManagedIdentityEnvironmentVariableNames.MSI_ENDPOINT, msiEndpoint, ManagedIdentitySourceNames.MACHINE_LEARNING, logger);
|
|
12257
12180
|
logger.info(`[Managed Identity] Environment variables validation passed for ${ManagedIdentitySourceNames.MACHINE_LEARNING} managed identity. Endpoint URI: ${validatedMsiEndpoint}. Creating ${ManagedIdentitySourceNames.MACHINE_LEARNING} managed identity.`);
|
|
12258
|
-
return new MachineLearning(logger, nodeStorage, networkClient, cryptoProvider, msiEndpoint, secret);
|
|
12181
|
+
return new MachineLearning(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, msiEndpoint, secret);
|
|
12259
12182
|
}
|
|
12260
12183
|
createRequest(resource, managedIdentityId) {
|
|
12261
12184
|
const request = new ManagedIdentityRequestParameters(HttpMethod.GET, this.msiEndpoint);
|
|
@@ -12282,16 +12205,17 @@ class MachineLearning extends BaseManagedIdentitySource {
|
|
|
12282
12205
|
* Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/ManagedIdentityClient.cs
|
|
12283
12206
|
*/
|
|
12284
12207
|
class ManagedIdentityClient {
|
|
12285
|
-
constructor(logger, nodeStorage, networkClient, cryptoProvider) {
|
|
12208
|
+
constructor(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries) {
|
|
12286
12209
|
this.logger = logger;
|
|
12287
12210
|
this.nodeStorage = nodeStorage;
|
|
12288
12211
|
this.networkClient = networkClient;
|
|
12289
12212
|
this.cryptoProvider = cryptoProvider;
|
|
12213
|
+
this.disableInternalRetries = disableInternalRetries;
|
|
12290
12214
|
}
|
|
12291
12215
|
async sendManagedIdentityTokenRequest(managedIdentityRequest, managedIdentityId, fakeAuthority, refreshAccessToken) {
|
|
12292
12216
|
if (!ManagedIdentityClient.identitySource) {
|
|
12293
12217
|
ManagedIdentityClient.identitySource =
|
|
12294
|
-
this.selectManagedIdentitySource(this.logger, this.nodeStorage, this.networkClient, this.cryptoProvider, managedIdentityId);
|
|
12218
|
+
this.selectManagedIdentitySource(this.logger, this.nodeStorage, this.networkClient, this.cryptoProvider, this.disableInternalRetries, managedIdentityId);
|
|
12295
12219
|
}
|
|
12296
12220
|
return ManagedIdentityClient.identitySource.acquireTokenWithManagedIdentity(managedIdentityRequest, managedIdentityId, fakeAuthority, refreshAccessToken);
|
|
12297
12221
|
}
|
|
@@ -12323,13 +12247,13 @@ class ManagedIdentityClient {
|
|
|
12323
12247
|
* Tries to create a managed identity source for all sources
|
|
12324
12248
|
* @returns the managed identity Source
|
|
12325
12249
|
*/
|
|
12326
|
-
selectManagedIdentitySource(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) {
|
|
12327
|
-
const source = ServiceFabric.tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) ||
|
|
12328
|
-
AppService.tryCreate(logger, nodeStorage, networkClient, cryptoProvider) ||
|
|
12329
|
-
MachineLearning.tryCreate(logger, nodeStorage, networkClient, cryptoProvider) ||
|
|
12330
|
-
CloudShell.tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) ||
|
|
12331
|
-
AzureArc.tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) ||
|
|
12332
|
-
Imds.tryCreate(logger, nodeStorage, networkClient, cryptoProvider);
|
|
12250
|
+
selectManagedIdentitySource(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, managedIdentityId) {
|
|
12251
|
+
const source = ServiceFabric.tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, managedIdentityId) ||
|
|
12252
|
+
AppService.tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries) ||
|
|
12253
|
+
MachineLearning.tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries) ||
|
|
12254
|
+
CloudShell.tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, managedIdentityId) ||
|
|
12255
|
+
AzureArc.tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, managedIdentityId) ||
|
|
12256
|
+
Imds.tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries);
|
|
12333
12257
|
if (!source) {
|
|
12334
12258
|
throw createManagedIdentityError(unableToCreateSource);
|
|
12335
12259
|
}
|
|
@@ -12372,7 +12296,7 @@ class ManagedIdentityApplication {
|
|
|
12372
12296
|
authority: this.fakeAuthority,
|
|
12373
12297
|
},
|
|
12374
12298
|
});
|
|
12375
|
-
this.managedIdentityClient = new ManagedIdentityClient(this.logger, ManagedIdentityApplication.nodeStorage, this.networkClient, this.cryptoProvider);
|
|
12299
|
+
this.managedIdentityClient = new ManagedIdentityClient(this.logger, ManagedIdentityApplication.nodeStorage, this.networkClient, this.cryptoProvider, this.config.disableInternalRetries);
|
|
12376
12300
|
}
|
|
12377
12301
|
/**
|
|
12378
12302
|
* Acquire an access token from the cache or the managed identity
|