@azure/msal-node 3.4.0 → 3.5.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.
Files changed (131) hide show
  1. package/dist/cache/NodeStorage.mjs +1 -1
  2. package/dist/cache/TokenCache.mjs +1 -1
  3. package/dist/cache/distributed/DistributedCachePlugin.mjs +1 -1
  4. package/dist/cache/serializer/Deserializer.mjs +1 -1
  5. package/dist/cache/serializer/Serializer.mjs +1 -1
  6. package/dist/client/ClientApplication.d.ts.map +1 -1
  7. package/dist/client/ClientApplication.mjs +3 -1
  8. package/dist/client/ClientApplication.mjs.map +1 -1
  9. package/dist/client/ClientAssertion.mjs +1 -1
  10. package/dist/client/ClientCredentialClient.mjs +1 -1
  11. package/dist/client/ConfidentialClientApplication.mjs +1 -1
  12. package/dist/client/DeviceCodeClient.mjs +1 -1
  13. package/dist/client/ManagedIdentityApplication.mjs +1 -1
  14. package/dist/client/ManagedIdentityClient.mjs +1 -1
  15. package/dist/client/ManagedIdentitySources/AppService.mjs +1 -1
  16. package/dist/client/ManagedIdentitySources/AzureArc.mjs +1 -1
  17. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +2 -1
  18. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
  19. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +10 -6
  20. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs.map +1 -1
  21. package/dist/client/ManagedIdentitySources/CloudShell.mjs +1 -1
  22. package/dist/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
  23. package/dist/client/ManagedIdentitySources/Imds.mjs +3 -1
  24. package/dist/client/ManagedIdentitySources/Imds.mjs.map +1 -1
  25. package/dist/client/ManagedIdentitySources/MachineLearning.d.ts.map +1 -1
  26. package/dist/client/ManagedIdentitySources/MachineLearning.mjs +4 -2
  27. package/dist/client/ManagedIdentitySources/MachineLearning.mjs.map +1 -1
  28. package/dist/client/ManagedIdentitySources/ServiceFabric.mjs +1 -1
  29. package/dist/client/OnBehalfOfClient.mjs +1 -1
  30. package/dist/client/PublicClientApplication.mjs +1 -1
  31. package/dist/client/UsernamePasswordClient.d.ts.map +1 -1
  32. package/dist/client/UsernamePasswordClient.mjs +3 -3
  33. package/dist/client/UsernamePasswordClient.mjs.map +1 -1
  34. package/dist/config/Configuration.mjs +1 -1
  35. package/dist/config/ManagedIdentityId.mjs +1 -1
  36. package/dist/config/ManagedIdentityRequestParameters.d.ts.map +1 -1
  37. package/dist/config/ManagedIdentityRequestParameters.mjs +4 -5
  38. package/dist/config/ManagedIdentityRequestParameters.mjs.map +1 -1
  39. package/dist/crypto/CryptoProvider.mjs +1 -1
  40. package/dist/crypto/GuidGenerator.mjs +1 -1
  41. package/dist/crypto/HashUtils.mjs +1 -1
  42. package/dist/crypto/PkceGenerator.mjs +1 -1
  43. package/dist/error/ManagedIdentityError.mjs +1 -1
  44. package/dist/error/ManagedIdentityErrorCodes.mjs +1 -1
  45. package/dist/error/NodeAuthError.mjs +1 -1
  46. package/dist/index.mjs +1 -1
  47. package/dist/internals.mjs +1 -1
  48. package/dist/network/HttpClient.mjs +1 -1
  49. package/dist/network/HttpClientWithRetries.d.ts +3 -2
  50. package/dist/network/HttpClientWithRetries.d.ts.map +1 -1
  51. package/dist/network/HttpClientWithRetries.mjs +7 -3
  52. package/dist/network/HttpClientWithRetries.mjs.map +1 -1
  53. package/dist/network/LoopbackClient.mjs +1 -1
  54. package/dist/packageMetadata.d.ts +1 -1
  55. package/dist/packageMetadata.mjs +2 -2
  56. package/dist/protocol/Authorize.d.ts.map +1 -1
  57. package/dist/protocol/Authorize.mjs +4 -3
  58. package/dist/protocol/Authorize.mjs.map +1 -1
  59. package/dist/retry/DefaultManagedIdentityRetryPolicy.d.ts +10 -0
  60. package/dist/retry/DefaultManagedIdentityRetryPolicy.d.ts.map +1 -0
  61. package/dist/retry/DefaultManagedIdentityRetryPolicy.mjs +49 -0
  62. package/dist/retry/DefaultManagedIdentityRetryPolicy.mjs.map +1 -0
  63. package/dist/retry/ExponentialRetryStrategy.d.ts +23 -0
  64. package/dist/retry/ExponentialRetryStrategy.d.ts.map +1 -0
  65. package/dist/retry/ExponentialRetryStrategy.mjs +40 -0
  66. package/dist/retry/ExponentialRetryStrategy.mjs.map +1 -0
  67. package/dist/retry/IHttpRetryPolicy.d.ts +12 -2
  68. package/dist/retry/IHttpRetryPolicy.d.ts.map +1 -1
  69. package/dist/retry/ImdsRetryPolicy.d.ts +22 -0
  70. package/dist/retry/ImdsRetryPolicy.d.ts.map +1 -0
  71. package/dist/retry/ImdsRetryPolicy.mjs +90 -0
  72. package/dist/retry/ImdsRetryPolicy.mjs.map +1 -0
  73. package/dist/retry/LinearRetryStrategy.d.ts +14 -0
  74. package/dist/retry/LinearRetryStrategy.d.ts.map +1 -0
  75. package/dist/retry/LinearRetryStrategy.mjs +36 -0
  76. package/dist/retry/LinearRetryStrategy.mjs.map +1 -0
  77. package/dist/utils/Constants.d.ts +4 -9
  78. package/dist/utils/Constants.d.ts.map +1 -1
  79. package/dist/utils/Constants.mjs +3 -13
  80. package/dist/utils/Constants.mjs.map +1 -1
  81. package/dist/utils/EncodingUtils.mjs +1 -1
  82. package/dist/utils/NetworkUtils.mjs +1 -1
  83. package/dist/utils/TimeUtils.mjs +1 -1
  84. package/lib/msal-node.cjs +297 -129
  85. package/lib/msal-node.cjs.map +1 -1
  86. package/lib/types/client/ClientApplication.d.ts.map +1 -1
  87. package/lib/types/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +2 -1
  88. package/lib/types/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
  89. package/lib/types/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
  90. package/lib/types/client/ManagedIdentitySources/MachineLearning.d.ts.map +1 -1
  91. package/lib/types/client/UsernamePasswordClient.d.ts.map +1 -1
  92. package/lib/types/config/ManagedIdentityRequestParameters.d.ts.map +1 -1
  93. package/lib/types/network/HttpClientWithRetries.d.ts +3 -2
  94. package/lib/types/network/HttpClientWithRetries.d.ts.map +1 -1
  95. package/lib/types/packageMetadata.d.ts +1 -1
  96. package/lib/types/protocol/Authorize.d.ts.map +1 -1
  97. package/lib/types/retry/DefaultManagedIdentityRetryPolicy.d.ts +10 -0
  98. package/lib/types/retry/DefaultManagedIdentityRetryPolicy.d.ts.map +1 -0
  99. package/lib/types/retry/ExponentialRetryStrategy.d.ts +23 -0
  100. package/lib/types/retry/ExponentialRetryStrategy.d.ts.map +1 -0
  101. package/lib/types/retry/IHttpRetryPolicy.d.ts +12 -2
  102. package/lib/types/retry/IHttpRetryPolicy.d.ts.map +1 -1
  103. package/lib/types/retry/ImdsRetryPolicy.d.ts +22 -0
  104. package/lib/types/retry/ImdsRetryPolicy.d.ts.map +1 -0
  105. package/lib/types/retry/LinearRetryStrategy.d.ts +14 -0
  106. package/lib/types/retry/LinearRetryStrategy.d.ts.map +1 -0
  107. package/lib/types/utils/Constants.d.ts +4 -9
  108. package/lib/types/utils/Constants.d.ts.map +1 -1
  109. package/package.json +2 -2
  110. package/src/client/ClientApplication.ts +2 -0
  111. package/src/client/ManagedIdentitySources/BaseManagedIdentitySource.ts +14 -6
  112. package/src/client/ManagedIdentitySources/Imds.ts +3 -0
  113. package/src/client/ManagedIdentitySources/MachineLearning.ts +3 -1
  114. package/src/client/UsernamePasswordClient.ts +5 -1
  115. package/src/config/ManagedIdentityRequestParameters.ts +4 -14
  116. package/src/network/HttpClientWithRetries.ts +10 -1
  117. package/src/packageMetadata.ts +1 -1
  118. package/src/protocol/Authorize.ts +7 -1
  119. package/src/retry/DefaultManagedIdentityRetryPolicy.ts +70 -0
  120. package/src/retry/ExponentialRetryStrategy.ts +53 -0
  121. package/src/retry/IHttpRetryPolicy.ts +14 -5
  122. package/src/retry/ImdsRetryPolicy.ts +121 -0
  123. package/src/retry/LinearRetryStrategy.ts +40 -0
  124. package/src/utils/Constants.ts +4 -17
  125. package/dist/retry/LinearRetryPolicy.d.ts +0 -12
  126. package/dist/retry/LinearRetryPolicy.d.ts.map +0 -1
  127. package/dist/retry/LinearRetryPolicy.mjs +0 -45
  128. package/dist/retry/LinearRetryPolicy.mjs.map +0 -1
  129. package/lib/types/retry/LinearRetryPolicy.d.ts +0 -12
  130. package/lib/types/retry/LinearRetryPolicy.d.ts.map +0 -1
  131. package/src/retry/LinearRetryPolicy.ts +0 -71
package/lib/msal-node.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-node v3.4.0 2025-03-20 */
1
+ /*! @azure/msal-node v3.5.0 2025-04-08 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
@@ -7,6 +7,7 @@ var https = require('https');
7
7
  var uuid = require('uuid');
8
8
  var crypto = require('crypto');
9
9
  var jwt = require('jsonwebtoken');
10
+ var msalCommon = require('@azure/msal-common');
10
11
  var fs = require('fs');
11
12
  var path = require('path');
12
13
 
@@ -152,7 +153,7 @@ class Serializer {
152
153
  }
153
154
  }
154
155
 
155
- /*! @azure/msal-common v15.3.0 2025-03-20 */
156
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
156
157
  /*
157
158
  * Copyright (c) Microsoft Corporation. All rights reserved.
158
159
  * Licensed under the MIT License.
@@ -187,11 +188,8 @@ const Constants$1 = {
187
188
  PROFILE_SCOPE: "profile",
188
189
  OFFLINE_ACCESS_SCOPE: "offline_access",
189
190
  EMAIL_SCOPE: "email",
190
- // Default response type for authorization code flow
191
- CODE_RESPONSE_TYPE: "code",
192
191
  CODE_GRANT_TYPE: "authorization_code",
193
192
  RT_GRANT_TYPE: "refresh_token",
194
- FRAGMENT_RESPONSE_MODE: "fragment",
195
193
  S256_CODE_CHALLENGE_METHOD: "S256",
196
194
  URL_FORM_CONTENT_TYPE: "application/x-www-form-urlencoded;charset=utf-8",
197
195
  AUTHORIZATION_PENDING: "authorization_pending",
@@ -211,8 +209,6 @@ const Constants$1 = {
211
209
  "login.microsoft.com",
212
210
  "sts.windows.net",
213
211
  ],
214
- TOKEN_RESPONSE_TYPE: "token",
215
- ID_TOKEN_RESPONSE_TYPE: "id_token",
216
212
  SHR_NONCE_VALIDITY: 240,
217
213
  INVALID_INSTANCE: "invalid_instance",
218
214
  };
@@ -227,6 +223,7 @@ const HttpStatus = {
227
223
  UNAUTHORIZED: 401,
228
224
  NOT_FOUND: 404,
229
225
  REQUEST_TIMEOUT: 408,
226
+ GONE: 410,
230
227
  TOO_MANY_REQUESTS: 429,
231
228
  CLIENT_ERROR_RANGE_END: 499,
232
229
  SERVER_ERROR: 500,
@@ -291,17 +288,19 @@ const CodeChallengeMethodValues = {
291
288
  S256: "S256",
292
289
  };
293
290
  /**
294
- * allowed values for server response type
291
+ * Allowed values for response_type
295
292
  */
296
- const ServerResponseType = {
297
- QUERY: "query",
298
- FRAGMENT: "fragment",
293
+ const OAuthResponseType = {
294
+ CODE: "code",
295
+ IDTOKEN_TOKEN: "id_token token",
296
+ IDTOKEN_TOKEN_REFRESHTOKEN: "id_token token refresh_token",
299
297
  };
300
298
  /**
301
299
  * allowed values for response_mode
302
300
  */
303
301
  const ResponseMode = {
304
- ...ServerResponseType,
302
+ QUERY: "query",
303
+ FRAGMENT: "fragment",
305
304
  FORM_POST: "form_post",
306
305
  };
307
306
  /**
@@ -445,7 +444,7 @@ const CacheOutcome = {
445
444
  // Token renewal offset default in seconds
446
445
  const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
447
446
 
448
- /*! @azure/msal-common v15.3.0 2025-03-20 */
447
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
449
448
  /*
450
449
  * Copyright (c) Microsoft Corporation. All rights reserved.
451
450
  * Licensed under the MIT License.
@@ -462,7 +461,7 @@ var AuthErrorCodes = /*#__PURE__*/Object.freeze({
462
461
  unexpectedError: unexpectedError
463
462
  });
464
463
 
465
- /*! @azure/msal-common v15.3.0 2025-03-20 */
464
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
466
465
 
467
466
  /*
468
467
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -511,7 +510,7 @@ function createAuthError(code, additionalMessage) {
511
510
  : AuthErrorMessages[code]);
512
511
  }
513
512
 
514
- /*! @azure/msal-common v15.3.0 2025-03-20 */
513
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
515
514
  /*
516
515
  * Copyright (c) Microsoft Corporation. All rights reserved.
517
516
  * Licensed under the MIT License.
@@ -609,7 +608,7 @@ var ClientAuthErrorCodes = /*#__PURE__*/Object.freeze({
609
608
  userTimeoutReached: userTimeoutReached
610
609
  });
611
610
 
612
- /*! @azure/msal-common v15.3.0 2025-03-20 */
611
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
613
612
 
614
613
  /*
615
614
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -861,7 +860,7 @@ function createClientAuthError(errorCode, additionalMessage) {
861
860
  return new ClientAuthError(errorCode, additionalMessage);
862
861
  }
863
862
 
864
- /*! @azure/msal-common v15.3.0 2025-03-20 */
863
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
865
864
 
866
865
  /*
867
866
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -900,7 +899,7 @@ const DEFAULT_CRYPTO_IMPLEMENTATION = {
900
899
  },
901
900
  };
902
901
 
903
- /*! @azure/msal-common v15.3.0 2025-03-20 */
902
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
904
903
 
905
904
  /*
906
905
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1091,12 +1090,12 @@ class Logger {
1091
1090
  }
1092
1091
  }
1093
1092
 
1094
- /*! @azure/msal-common v15.3.0 2025-03-20 */
1093
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
1095
1094
  /* eslint-disable header/header */
1096
1095
  const name$1 = "@azure/msal-common";
1097
- const version$1 = "15.3.0";
1096
+ const version$1 = "15.5.0";
1098
1097
 
1099
- /*! @azure/msal-common v15.3.0 2025-03-20 */
1098
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
1100
1099
  /*
1101
1100
  * Copyright (c) Microsoft Corporation. All rights reserved.
1102
1101
  * Licensed under the MIT License.
@@ -1116,7 +1115,7 @@ const AzureCloudInstance = {
1116
1115
  AzureUsGovernment: "https://login.microsoftonline.us",
1117
1116
  };
1118
1117
 
1119
- /*! @azure/msal-common v15.3.0 2025-03-20 */
1118
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
1120
1119
 
1121
1120
  /*
1122
1121
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1177,7 +1176,7 @@ function checkMaxAge(authTime, maxAge) {
1177
1176
  }
1178
1177
  }
1179
1178
 
1180
- /*! @azure/msal-common v15.3.0 2025-03-20 */
1179
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
1181
1180
  /*
1182
1181
  * Copyright (c) Microsoft Corporation. All rights reserved.
1183
1182
  * Licensed under the MIT License.
@@ -1232,7 +1231,7 @@ function delay(t, value) {
1232
1231
  return new Promise((resolve) => setTimeout(() => resolve(value), t));
1233
1232
  }
1234
1233
 
1235
- /*! @azure/msal-common v15.3.0 2025-03-20 */
1234
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
1236
1235
 
1237
1236
  /*
1238
1237
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1559,7 +1558,7 @@ function isAuthorityMetadataExpired(metadata) {
1559
1558
  return metadata.expiresAt <= nowSeconds();
1560
1559
  }
1561
1560
 
1562
- /*! @azure/msal-common v15.3.0 2025-03-20 */
1561
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
1563
1562
  /*
1564
1563
  * Copyright (c) Microsoft Corporation. All rights reserved.
1565
1564
  * Licensed under the MIT License.
@@ -1613,7 +1612,7 @@ var ClientConfigurationErrorCodes = /*#__PURE__*/Object.freeze({
1613
1612
  urlParseError: urlParseError
1614
1613
  });
1615
1614
 
1616
- /*! @azure/msal-common v15.3.0 2025-03-20 */
1615
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
1617
1616
 
1618
1617
  /*
1619
1618
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1751,7 +1750,7 @@ function createClientConfigurationError(errorCode) {
1751
1750
  return new ClientConfigurationError(errorCode);
1752
1751
  }
1753
1752
 
1754
- /*! @azure/msal-common v15.3.0 2025-03-20 */
1753
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
1755
1754
  /*
1756
1755
  * Copyright (c) Microsoft Corporation. All rights reserved.
1757
1756
  * Licensed under the MIT License.
@@ -1848,7 +1847,7 @@ class StringUtils {
1848
1847
  }
1849
1848
  }
1850
1849
 
1851
- /*! @azure/msal-common v15.3.0 2025-03-20 */
1850
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
1852
1851
 
1853
1852
  /*
1854
1853
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2039,7 +2038,7 @@ class ScopeSet {
2039
2038
  }
2040
2039
  }
2041
2040
 
2042
- /*! @azure/msal-common v15.3.0 2025-03-20 */
2041
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
2043
2042
 
2044
2043
  /*
2045
2044
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2079,7 +2078,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
2079
2078
  };
2080
2079
  }
2081
2080
 
2082
- /*! @azure/msal-common v15.3.0 2025-03-20 */
2081
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
2083
2082
  /*
2084
2083
  * Copyright (c) Microsoft Corporation. All rights reserved.
2085
2084
  * Licensed under the MIT License.
@@ -2158,7 +2157,7 @@ function updateAccountTenantProfileData(baseAccountInfo, tenantProfile, idTokenC
2158
2157
  return updatedAccountInfo;
2159
2158
  }
2160
2159
 
2161
- /*! @azure/msal-common v15.3.0 2025-03-20 */
2160
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
2162
2161
  /*
2163
2162
  * Copyright (c) Microsoft Corporation. All rights reserved.
2164
2163
  * Licensed under the MIT License.
@@ -2173,7 +2172,7 @@ const AuthorityType = {
2173
2172
  Ciam: 3,
2174
2173
  };
2175
2174
 
2176
- /*! @azure/msal-common v15.3.0 2025-03-20 */
2175
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
2177
2176
  /*
2178
2177
  * Copyright (c) Microsoft Corporation. All rights reserved.
2179
2178
  * Licensed under the MIT License.
@@ -2195,7 +2194,7 @@ function getTenantIdFromIdTokenClaims(idTokenClaims) {
2195
2194
  return null;
2196
2195
  }
2197
2196
 
2198
- /*! @azure/msal-common v15.3.0 2025-03-20 */
2197
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
2199
2198
  /*
2200
2199
  * Copyright (c) Microsoft Corporation. All rights reserved.
2201
2200
  * Licensed under the MIT License.
@@ -2204,11 +2203,22 @@ function getTenantIdFromIdTokenClaims(idTokenClaims) {
2204
2203
  * Protocol modes supported by MSAL.
2205
2204
  */
2206
2205
  const ProtocolMode = {
2206
+ /**
2207
+ * Auth Code + PKCE with Entra ID (formerly AAD) specific optimizations and features
2208
+ */
2207
2209
  AAD: "AAD",
2210
+ /**
2211
+ * Auth Code + PKCE without Entra ID specific optimizations and features. For use only with non-Microsoft owned authorities.
2212
+ * Support is limited for this mode.
2213
+ */
2208
2214
  OIDC: "OIDC",
2215
+ /**
2216
+ * Encrypted Authorize Response (EAR) with Entra ID specific optimizations and features
2217
+ */
2218
+ EAR: "EAR",
2209
2219
  };
2210
2220
 
2211
- /*! @azure/msal-common v15.3.0 2025-03-20 */
2221
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
2212
2222
 
2213
2223
  /*
2214
2224
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2304,11 +2314,11 @@ class AccountEntity {
2304
2314
  if (authority.authorityType === AuthorityType.Adfs) {
2305
2315
  account.authorityType = CacheAccountType.ADFS_ACCOUNT_TYPE;
2306
2316
  }
2307
- else if (authority.protocolMode === ProtocolMode.AAD) {
2308
- account.authorityType = CacheAccountType.MSSTS_ACCOUNT_TYPE;
2317
+ else if (authority.protocolMode === ProtocolMode.OIDC) {
2318
+ account.authorityType = CacheAccountType.GENERIC_ACCOUNT_TYPE;
2309
2319
  }
2310
2320
  else {
2311
- account.authorityType = CacheAccountType.GENERIC_ACCOUNT_TYPE;
2321
+ account.authorityType = CacheAccountType.MSSTS_ACCOUNT_TYPE;
2312
2322
  }
2313
2323
  let clientInfo;
2314
2324
  if (accountDetails.clientInfo && base64Decode) {
@@ -2451,7 +2461,7 @@ class AccountEntity {
2451
2461
  }
2452
2462
  }
2453
2463
 
2454
- /*! @azure/msal-common v15.3.0 2025-03-20 */
2464
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
2455
2465
 
2456
2466
  /*
2457
2467
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2486,6 +2496,7 @@ function getDeserializedResponse(responseString) {
2486
2496
  const deserializedHash = Object.fromEntries(new URLSearchParams(normalizedResponse));
2487
2497
  // Check for known response properties
2488
2498
  if (deserializedHash.code ||
2499
+ deserializedHash.ear_jwe ||
2489
2500
  deserializedHash.error ||
2490
2501
  deserializedHash.error_description ||
2491
2502
  deserializedHash.state) {
@@ -2508,7 +2519,7 @@ function mapToQueryString(parameters) {
2508
2519
  return queryParameterArray.join("&");
2509
2520
  }
2510
2521
 
2511
- /*! @azure/msal-common v15.3.0 2025-03-20 */
2522
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
2512
2523
 
2513
2524
  /*
2514
2525
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2672,7 +2683,7 @@ class UrlString {
2672
2683
  }
2673
2684
  }
2674
2685
 
2675
- /*! @azure/msal-common v15.3.0 2025-03-20 */
2686
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
2676
2687
 
2677
2688
  /*
2678
2689
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2812,7 +2823,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
2812
2823
  return null;
2813
2824
  }
2814
2825
 
2815
- /*! @azure/msal-common v15.3.0 2025-03-20 */
2826
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
2816
2827
  /*
2817
2828
  * Copyright (c) Microsoft Corporation. All rights reserved.
2818
2829
  * Licensed under the MIT License.
@@ -2820,7 +2831,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
2820
2831
  const cacheQuotaExceededErrorCode = "cache_quota_exceeded";
2821
2832
  const cacheUnknownErrorCode = "cache_error_unknown";
2822
2833
 
2823
- /*! @azure/msal-common v15.3.0 2025-03-20 */
2834
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
2824
2835
 
2825
2836
  /*
2826
2837
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2847,7 +2858,7 @@ class CacheError extends Error {
2847
2858
  }
2848
2859
  }
2849
2860
 
2850
- /*! @azure/msal-common v15.3.0 2025-03-20 */
2861
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
2851
2862
 
2852
2863
  /*
2853
2864
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4031,7 +4042,7 @@ class DefaultStorageClass extends CacheManager {
4031
4042
  }
4032
4043
  }
4033
4044
 
4034
- /*! @azure/msal-common v15.3.0 2025-03-20 */
4045
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
4035
4046
 
4036
4047
  /*
4037
4048
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4130,7 +4141,7 @@ function isOidcProtocolMode(config) {
4130
4141
  return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
4131
4142
  }
4132
4143
 
4133
- /*! @azure/msal-common v15.3.0 2025-03-20 */
4144
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
4134
4145
  /*
4135
4146
  * Copyright (c) Microsoft Corporation. All rights reserved.
4136
4147
  * Licensed under the MIT License.
@@ -4140,7 +4151,7 @@ const CcsCredentialType = {
4140
4151
  UPN: "UPN",
4141
4152
  };
4142
4153
 
4143
- /*! @azure/msal-common v15.3.0 2025-03-20 */
4154
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
4144
4155
  /*
4145
4156
  * Copyright (c) Microsoft Corporation. All rights reserved.
4146
4157
  * Licensed under the MIT License.
@@ -4191,7 +4202,7 @@ const BROKER_CLIENT_ID = "brk_client_id";
4191
4202
  const BROKER_REDIRECT_URI = "brk_redirect_uri";
4192
4203
  const INSTANCE_AWARE = "instance_aware";
4193
4204
 
4194
- /*! @azure/msal-common v15.3.0 2025-03-20 */
4205
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
4195
4206
 
4196
4207
  /*
4197
4208
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4210,16 +4221,12 @@ function instrumentBrokerParams(parameters, correlationId, performanceClient) {
4210
4221
  }
4211
4222
  }
4212
4223
  /**
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
4224
+ * Add the given response_type
4225
+ * @param parameters
4226
+ * @param responseType
4220
4227
  */
4221
- function addResponseTypeForTokenAndIdToken(parameters) {
4222
- parameters.set(RESPONSE_TYPE, `${Constants$1.TOKEN_RESPONSE_TYPE} ${Constants$1.ID_TOKEN_RESPONSE_TYPE}`);
4228
+ function addResponseType(parameters, responseType) {
4229
+ parameters.set(RESPONSE_TYPE, responseType);
4223
4230
  }
4224
4231
  /**
4225
4232
  * add response_mode. defaults to query.
@@ -4581,7 +4588,7 @@ function addBrokerParameters(parameters, brokerClientId, brokerRedirectUri) {
4581
4588
  }
4582
4589
  }
4583
4590
 
4584
- /*! @azure/msal-common v15.3.0 2025-03-20 */
4591
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
4585
4592
  /*
4586
4593
  * Copyright (c) Microsoft Corporation. All rights reserved.
4587
4594
  * Licensed under the MIT License.
@@ -4593,7 +4600,7 @@ function isOpenIdConfigResponse(response) {
4593
4600
  response.hasOwnProperty("jwks_uri"));
4594
4601
  }
4595
4602
 
4596
- /*! @azure/msal-common v15.3.0 2025-03-20 */
4603
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
4597
4604
  /*
4598
4605
  * Copyright (c) Microsoft Corporation. All rights reserved.
4599
4606
  * Licensed under the MIT License.
@@ -4603,7 +4610,7 @@ function isCloudInstanceDiscoveryResponse(response) {
4603
4610
  response.hasOwnProperty("metadata"));
4604
4611
  }
4605
4612
 
4606
- /*! @azure/msal-common v15.3.0 2025-03-20 */
4613
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
4607
4614
  /*
4608
4615
  * Copyright (c) Microsoft Corporation. All rights reserved.
4609
4616
  * Licensed under the MIT License.
@@ -4613,7 +4620,7 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
4613
4620
  response.hasOwnProperty("error_description"));
4614
4621
  }
4615
4622
 
4616
- /*! @azure/msal-common v15.3.0 2025-03-20 */
4623
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
4617
4624
  /*
4618
4625
  * Copyright (c) Microsoft Corporation. All rights reserved.
4619
4626
  * Licensed under the MIT License.
@@ -4799,6 +4806,9 @@ const PerformanceEvents = {
4799
4806
  */
4800
4807
  HandleCodeResponseFromServer: "handleCodeResponseFromServer",
4801
4808
  HandleCodeResponse: "handleCodeResponse",
4809
+ HandleResponseEar: "handleResponseEar",
4810
+ HandleResponsePlatformBroker: "handleResponsePlatformBroker",
4811
+ HandleResponseCode: "handleResponseCode",
4802
4812
  UpdateTokenEndpointAuthority: "updateTokenEndpointAuthority",
4803
4813
  /**
4804
4814
  * APIs in Authorization Code Client (msal-common)
@@ -4865,9 +4875,11 @@ const PerformanceEvents = {
4865
4875
  UrlEncodeArr: "urlEncodeArr",
4866
4876
  Encrypt: "encrypt",
4867
4877
  Decrypt: "decrypt",
4878
+ GenerateEarKey: "generateEarKey",
4879
+ DecryptEarResponse: "decryptEarResponse",
4868
4880
  };
4869
4881
 
4870
- /*! @azure/msal-common v15.3.0 2025-03-20 */
4882
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
4871
4883
  /*
4872
4884
  * Copyright (c) Microsoft Corporation. All rights reserved.
4873
4885
  * Licensed under the MIT License.
@@ -4963,7 +4975,7 @@ const invokeAsync = (callback, eventName, logger, telemetryClient, correlationId
4963
4975
  };
4964
4976
  };
4965
4977
 
4966
- /*! @azure/msal-common v15.3.0 2025-03-20 */
4978
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
4967
4979
 
4968
4980
  /*
4969
4981
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5072,7 +5084,7 @@ RegionDiscovery.IMDS_OPTIONS = {
5072
5084
  },
5073
5085
  };
5074
5086
 
5075
- /*! @azure/msal-common v15.3.0 2025-03-20 */
5087
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
5076
5088
 
5077
5089
  /*
5078
5090
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5250,7 +5262,7 @@ class Authority {
5250
5262
  return (authorityUri.PathSegments.length === 1 &&
5251
5263
  !Authority.reservedTenantDomains.has(authorityUri.PathSegments[0]) &&
5252
5264
  this.getAuthorityType(authorityUri) === AuthorityType.Default &&
5253
- this.protocolMode === ProtocolMode.AAD);
5265
+ this.protocolMode !== ProtocolMode.OIDC);
5254
5266
  }
5255
5267
  /**
5256
5268
  * Replaces tenant in url path with current tenant. Defaults to common.
@@ -5297,7 +5309,7 @@ class Authority {
5297
5309
  const canonicalAuthorityHost = this.hostnameAndPort;
5298
5310
  if (this.canonicalAuthority.endsWith("v2.0/") ||
5299
5311
  this.authorityType === AuthorityType.Adfs ||
5300
- (this.protocolMode !== ProtocolMode.AAD &&
5312
+ (this.protocolMode === ProtocolMode.OIDC &&
5301
5313
  !this.isAliasOfKnownMicrosoftAuthority(canonicalAuthorityHost))) {
5302
5314
  return `${this.canonicalAuthority}.well-known/openid-configuration`;
5303
5315
  }
@@ -5911,7 +5923,7 @@ function buildStaticAuthorityOptions(authOptions) {
5911
5923
  };
5912
5924
  }
5913
5925
 
5914
- /*! @azure/msal-common v15.3.0 2025-03-20 */
5926
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
5915
5927
 
5916
5928
  /*
5917
5929
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5942,7 +5954,7 @@ async function createDiscoveredInstance(authorityUri, networkClient, cacheManage
5942
5954
  }
5943
5955
  }
5944
5956
 
5945
- /*! @azure/msal-common v15.3.0 2025-03-20 */
5957
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
5946
5958
 
5947
5959
  /*
5948
5960
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5961,7 +5973,7 @@ class ServerError extends AuthError {
5961
5973
  }
5962
5974
  }
5963
5975
 
5964
- /*! @azure/msal-common v15.3.0 2025-03-20 */
5976
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
5965
5977
  /*
5966
5978
  * Copyright (c) Microsoft Corporation. All rights reserved.
5967
5979
  * Licensed under the MIT License.
@@ -5982,7 +5994,7 @@ function getRequestThumbprint(clientId, request, homeAccountId) {
5982
5994
  };
5983
5995
  }
5984
5996
 
5985
- /*! @azure/msal-common v15.3.0 2025-03-20 */
5997
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
5986
5998
 
5987
5999
  /*
5988
6000
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6069,7 +6081,7 @@ class ThrottlingUtils {
6069
6081
  }
6070
6082
  }
6071
6083
 
6072
- /*! @azure/msal-common v15.3.0 2025-03-20 */
6084
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
6073
6085
 
6074
6086
  /*
6075
6087
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6089,7 +6101,7 @@ class NetworkError extends AuthError {
6089
6101
  }
6090
6102
  }
6091
6103
 
6092
- /*! @azure/msal-common v15.3.0 2025-03-20 */
6104
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
6093
6105
 
6094
6106
  /*
6095
6107
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6237,7 +6249,7 @@ class BaseClient {
6237
6249
  }
6238
6250
  }
6239
6251
 
6240
- /*! @azure/msal-common v15.3.0 2025-03-20 */
6252
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
6241
6253
  /*
6242
6254
  * Copyright (c) Microsoft Corporation. All rights reserved.
6243
6255
  * Licensed under the MIT License.
@@ -6263,7 +6275,7 @@ var InteractionRequiredAuthErrorCodes = /*#__PURE__*/Object.freeze({
6263
6275
  refreshTokenExpired: refreshTokenExpired
6264
6276
  });
6265
6277
 
6266
- /*! @azure/msal-common v15.3.0 2025-03-20 */
6278
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
6267
6279
 
6268
6280
  /*
6269
6281
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6351,7 +6363,7 @@ function createInteractionRequiredAuthError(errorCode) {
6351
6363
  return new InteractionRequiredAuthError(errorCode, InteractionRequiredAuthErrorMessages[errorCode]);
6352
6364
  }
6353
6365
 
6354
- /*! @azure/msal-common v15.3.0 2025-03-20 */
6366
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
6355
6367
 
6356
6368
  /*
6357
6369
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6423,7 +6435,7 @@ class ProtocolUtils {
6423
6435
  }
6424
6436
  }
6425
6437
 
6426
- /*! @azure/msal-common v15.3.0 2025-03-20 */
6438
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
6427
6439
 
6428
6440
  /*
6429
6441
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6507,7 +6519,7 @@ class PopTokenGenerator {
6507
6519
  }
6508
6520
  }
6509
6521
 
6510
- /*! @azure/msal-common v15.3.0 2025-03-20 */
6522
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
6511
6523
  /*
6512
6524
  * Copyright (c) Microsoft Corporation. All rights reserved.
6513
6525
  * Licensed under the MIT License.
@@ -6534,7 +6546,7 @@ class PopTokenGenerator {
6534
6546
  }
6535
6547
  }
6536
6548
 
6537
- /*! @azure/msal-common v15.3.0 2025-03-20 */
6549
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
6538
6550
 
6539
6551
  /*
6540
6552
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6865,7 +6877,7 @@ function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decod
6865
6877
  return baseAccount;
6866
6878
  }
6867
6879
 
6868
- /*! @azure/msal-common v15.3.0 2025-03-20 */
6880
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
6869
6881
 
6870
6882
  /*
6871
6883
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6932,7 +6944,7 @@ class RequestValidator {
6932
6944
  }
6933
6945
  }
6934
6946
 
6935
- /*! @azure/msal-common v15.3.0 2025-03-20 */
6947
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
6936
6948
  /*
6937
6949
  * Copyright (c) Microsoft Corporation. All rights reserved.
6938
6950
  * Licensed under the MIT License.
@@ -6950,7 +6962,7 @@ async function getClientAssertion(clientAssertion, clientId, tokenEndpoint) {
6950
6962
  }
6951
6963
  }
6952
6964
 
6953
- /*! @azure/msal-common v15.3.0 2025-03-20 */
6965
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
6954
6966
 
6955
6967
  /*
6956
6968
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7183,7 +7195,7 @@ class AuthorizationCodeClient extends BaseClient {
7183
7195
  }
7184
7196
  }
7185
7197
 
7186
- /*! @azure/msal-common v15.3.0 2025-03-20 */
7198
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
7187
7199
 
7188
7200
  /*
7189
7201
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7392,7 +7404,7 @@ class RefreshTokenClient extends BaseClient {
7392
7404
  }
7393
7405
  }
7394
7406
 
7395
- /*! @azure/msal-common v15.3.0 2025-03-20 */
7407
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
7396
7408
 
7397
7409
  /*
7398
7410
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7490,7 +7502,7 @@ class SilentFlowClient extends BaseClient {
7490
7502
  }
7491
7503
  }
7492
7504
 
7493
- /*! @azure/msal-common v15.3.0 2025-03-20 */
7505
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
7494
7506
 
7495
7507
  /*
7496
7508
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7611,10 +7623,10 @@ function getStandardAuthorizeRequestParameters(authOptions, request, logger, per
7611
7623
  if (request.embeddedClientId) {
7612
7624
  addBrokerParameters(parameters, authOptions.clientId, authOptions.redirectUri);
7613
7625
  }
7614
- if (request.extraQueryParameters) {
7615
- addExtraQueryParameters(parameters, request.extraQueryParameters);
7616
- }
7617
- if (authOptions.instanceAware) {
7626
+ // If extraQueryParameters includes instance_aware its value will be added when extraQueryParameters are added
7627
+ if (authOptions.instanceAware &&
7628
+ (!request.extraQueryParameters ||
7629
+ !Object.keys(request.extraQueryParameters).includes(INSTANCE_AWARE))) {
7618
7630
  addInstanceAware(parameters);
7619
7631
  }
7620
7632
  return parameters;
@@ -7640,7 +7652,7 @@ function extractLoginHint(account) {
7640
7652
  return account.idTokenClaims?.login_hint || null;
7641
7653
  }
7642
7654
 
7643
- /*! @azure/msal-common v15.3.0 2025-03-20 */
7655
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
7644
7656
 
7645
7657
  /*
7646
7658
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8215,17 +8227,7 @@ const LOOPBACK_SERVER_CONSTANTS = {
8215
8227
  INTERVAL_MS: 100,
8216
8228
  TIMEOUT_MS: 5000,
8217
8229
  };
8218
- const AZURE_ARC_SECRET_FILE_MAX_SIZE_BYTES = 4096; // 4 KB
8219
- const MANAGED_IDENTITY_MAX_RETRIES = 3;
8220
- const MANAGED_IDENTITY_RETRY_DELAY = 1000;
8221
- const MANAGED_IDENTITY_HTTP_STATUS_CODES_TO_RETRY_ON = [
8222
- HttpStatus.NOT_FOUND,
8223
- HttpStatus.REQUEST_TIMEOUT,
8224
- HttpStatus.TOO_MANY_REQUESTS,
8225
- HttpStatus.SERVER_ERROR,
8226
- HttpStatus.SERVICE_UNAVAILABLE,
8227
- HttpStatus.GATEWAY_TIMEOUT,
8228
- ];
8230
+ const AZURE_ARC_SECRET_FILE_MAX_SIZE_BYTES = 4096; // 4 KB
8229
8231
 
8230
8232
  /*
8231
8233
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -9933,7 +9935,7 @@ class ClientAssertion {
9933
9935
 
9934
9936
  /* eslint-disable header/header */
9935
9937
  const name = "@azure/msal-node";
9936
- const version = "3.4.0";
9938
+ const version = "3.5.0";
9937
9939
 
9938
9940
  /*
9939
9941
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10000,7 +10002,7 @@ class UsernamePasswordClient extends BaseClient {
10000
10002
  addUsername(parameters, request.username);
10001
10003
  addPassword(parameters, request.password);
10002
10004
  addScopes(parameters, request.scopes);
10003
- addResponseTypeForTokenAndIdToken(parameters);
10005
+ addResponseType(parameters, OAuthResponseType.IDTOKEN_TOKEN);
10004
10006
  addGrantType(parameters, GrantType.RESOURCE_OWNER_PASSWORD_GRANT);
10005
10007
  addClientInfo(parameters);
10006
10008
  addLibraryInfo(parameters, this.config.libraryInfo);
@@ -10060,10 +10062,11 @@ function getAuthCodeRequestUrl(config, authority, request, logger) {
10060
10062
  if (config.auth.protocolMode !== ProtocolMode.OIDC) {
10061
10063
  addApplicationTelemetry(parameters, config.telemetry.application);
10062
10064
  }
10063
- addResponseTypeCode(parameters);
10065
+ addResponseType(parameters, OAuthResponseType.CODE);
10064
10066
  if (request.codeChallenge && request.codeChallengeMethod) {
10065
10067
  addCodeChallengeParams(parameters, request.codeChallenge, request.codeChallengeMethod);
10066
10068
  }
10069
+ addExtraQueryParameters(parameters, request.extraQueryParameters || {});
10067
10070
  return getAuthorizeUrl(authority, parameters);
10068
10071
  }
10069
10072
 
@@ -10102,6 +10105,8 @@ class ClientApplication {
10102
10105
  ...(await this.initializeBaseRequest(request)),
10103
10106
  responseMode: request.responseMode || ResponseMode.QUERY,
10104
10107
  authenticationScheme: AuthenticationScheme.BEARER,
10108
+ state: request.state || "",
10109
+ nonce: request.nonce || "",
10105
10110
  };
10106
10111
  const discoveredAuthority = await this.createAuthority(validRequest.authority, validRequest.correlationId, undefined, request.azureCloudOptions);
10107
10112
  return getAuthCodeRequestUrl(this.config, discoveredAuthority, validRequest, this.logger);
@@ -11573,9 +11578,10 @@ function isIso8601(dateString) {
11573
11578
  * Licensed under the MIT License.
11574
11579
  */
11575
11580
  class HttpClientWithRetries {
11576
- constructor(httpClientNoRetries, retryPolicy) {
11581
+ constructor(httpClientNoRetries, retryPolicy, logger) {
11577
11582
  this.httpClientNoRetries = httpClientNoRetries;
11578
11583
  this.retryPolicy = retryPolicy;
11584
+ this.logger = logger;
11579
11585
  }
11580
11586
  async sendNetworkRequestAsyncHelper(httpMethod, url, options) {
11581
11587
  if (httpMethod === HttpMethod.GET) {
@@ -11588,8 +11594,11 @@ class HttpClientWithRetries {
11588
11594
  async sendNetworkRequestAsync(httpMethod, url, options) {
11589
11595
  // the underlying network module (custom or HttpClient) will make the call
11590
11596
  let response = await this.sendNetworkRequestAsyncHelper(httpMethod, url, options);
11597
+ if ("isNewRequest" in this.retryPolicy) {
11598
+ this.retryPolicy.isNewRequest = true;
11599
+ }
11591
11600
  let currentRetry = 0;
11592
- while (await this.retryPolicy.pauseForRetry(response.status, currentRetry, response.headers[HeaderNames.RETRY_AFTER])) {
11601
+ while (await this.retryPolicy.pauseForRetry(response.status, currentRetry, this.logger, response.headers[HeaderNames.RETRY_AFTER])) {
11593
11602
  response = await this.sendNetworkRequestAsyncHelper(httpMethod, url, options);
11594
11603
  currentRetry++;
11595
11604
  }
@@ -11611,6 +11620,7 @@ class HttpClientWithRetries {
11611
11620
  * Managed Identity User Assigned Id Query Parameter Names
11612
11621
  */
11613
11622
  const ManagedIdentityUserAssignedIdQueryParameterNames = {
11623
+ MANAGED_IDENTITY_CLIENT_ID_2017: "clientid",
11614
11624
  MANAGED_IDENTITY_CLIENT_ID: "client_id",
11615
11625
  MANAGED_IDENTITY_OBJECT_ID: "object_id",
11616
11626
  MANAGED_IDENTITY_RESOURCE_ID_IMDS: "msi_res_id",
@@ -11686,7 +11696,7 @@ class BaseManagedIdentitySource {
11686
11696
  */
11687
11697
  const networkClientHelper = this.disableInternalRetries
11688
11698
  ? this.networkClient
11689
- : new HttpClientWithRetries(this.networkClient, networkRequest.retryPolicy);
11699
+ : new HttpClientWithRetries(this.networkClient, networkRequest.retryPolicy, this.logger);
11690
11700
  const reqTimestamp = nowSeconds();
11691
11701
  let response;
11692
11702
  try {
@@ -11715,14 +11725,17 @@ class BaseManagedIdentitySource {
11715
11725
  // caches the token
11716
11726
  return responseHandler.handleServerTokenResponse(serverTokenResponse, fakeAuthority, reqTimestamp, managedIdentityRequest);
11717
11727
  }
11718
- getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityIdType, imds) {
11728
+ getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityIdType, isImds, usesApi2017) {
11719
11729
  switch (managedIdentityIdType) {
11720
11730
  case ManagedIdentityIdType.USER_ASSIGNED_CLIENT_ID:
11721
- this.logger.info("[Managed Identity] Adding user assigned client id to the request.");
11722
- return ManagedIdentityUserAssignedIdQueryParameterNames.MANAGED_IDENTITY_CLIENT_ID;
11731
+ this.logger.info(`[Managed Identity] [API version ${usesApi2017 ? "2017+" : "2019+"}] Adding user assigned client id to the request.`);
11732
+ // The Machine Learning source uses the 2017-09-01 API version, which uses "clientid" instead of "client_id"
11733
+ return usesApi2017
11734
+ ? ManagedIdentityUserAssignedIdQueryParameterNames.MANAGED_IDENTITY_CLIENT_ID_2017
11735
+ : ManagedIdentityUserAssignedIdQueryParameterNames.MANAGED_IDENTITY_CLIENT_ID;
11723
11736
  case ManagedIdentityIdType.USER_ASSIGNED_RESOURCE_ID:
11724
11737
  this.logger.info("[Managed Identity] Adding user assigned resource id to the request.");
11725
- return imds
11738
+ return isImds
11726
11739
  ? ManagedIdentityUserAssignedIdQueryParameterNames.MANAGED_IDENTITY_RESOURCE_ID_IMDS
11727
11740
  : ManagedIdentityUserAssignedIdQueryParameterNames.MANAGED_IDENTITY_RESOURCE_ID_NON_IMDS;
11728
11741
  case ManagedIdentityIdType.USER_ASSIGNED_OBJECT_ID:
@@ -11747,15 +11760,18 @@ BaseManagedIdentitySource.getValidatedEnvVariableUrlString = (envVariableStringN
11747
11760
  * Copyright (c) Microsoft Corporation. All rights reserved.
11748
11761
  * Licensed under the MIT License.
11749
11762
  */
11750
- class LinearRetryPolicy {
11751
- constructor(maxRetries, retryDelay, httpStatusCodesToRetryOn) {
11752
- this.maxRetries = maxRetries;
11753
- this.retryDelay = retryDelay;
11754
- this.httpStatusCodesToRetryOn = httpStatusCodesToRetryOn;
11755
- }
11756
- retryAfterMillisecondsToSleep(retryHeader) {
11763
+ class LinearRetryStrategy {
11764
+ /**
11765
+ * Calculates the number of milliseconds to sleep based on the `retry-after` HTTP header.
11766
+ *
11767
+ * @param retryHeader - The value of the `retry-after` HTTP header. This can be either a number of seconds
11768
+ * or an HTTP date string.
11769
+ * @returns The number of milliseconds to sleep before retrying the request. If the `retry-after` header is not
11770
+ * present or cannot be parsed, returns 0.
11771
+ */
11772
+ calculateDelay(retryHeader, minimumDelay) {
11757
11773
  if (!retryHeader) {
11758
- return 0;
11774
+ return minimumDelay;
11759
11775
  }
11760
11776
  // retry-after header is in seconds
11761
11777
  let millisToSleep = Math.round(parseFloat(retryHeader) * 1000);
@@ -11764,22 +11780,52 @@ class LinearRetryPolicy {
11764
11780
  * <day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT
11765
11781
  */
11766
11782
  if (isNaN(millisToSleep)) {
11767
- millisToSleep = Math.max(0,
11768
11783
  // .valueOf() is needed to subtract dates in TypeScript
11769
- new Date(retryHeader).valueOf() - new Date().valueOf());
11784
+ millisToSleep =
11785
+ new Date(retryHeader).valueOf() - new Date().valueOf();
11770
11786
  }
11771
- return millisToSleep;
11787
+ return Math.max(minimumDelay, millisToSleep);
11772
11788
  }
11773
- async pauseForRetry(httpStatusCode, currentRetry, retryAfterHeader) {
11774
- if (this.httpStatusCodesToRetryOn.includes(httpStatusCode) &&
11775
- currentRetry < this.maxRetries) {
11776
- const retryAfterDelay = this.retryAfterMillisecondsToSleep(retryAfterHeader);
11789
+ }
11790
+
11791
+ /*
11792
+ * Copyright (c) Microsoft Corporation. All rights reserved.
11793
+ * Licensed under the MIT License.
11794
+ */
11795
+ const DEFAULT_MANAGED_IDENTITY_MAX_RETRIES = 3;
11796
+ const DEFAULT_MANAGED_IDENTITY_RETRY_DELAY_MS = 1000;
11797
+ const DEFAULT_MANAGED_IDENTITY_HTTP_STATUS_CODES_TO_RETRY_ON = [
11798
+ msalCommon.HttpStatus.NOT_FOUND,
11799
+ msalCommon.HttpStatus.REQUEST_TIMEOUT,
11800
+ msalCommon.HttpStatus.TOO_MANY_REQUESTS,
11801
+ msalCommon.HttpStatus.SERVER_ERROR,
11802
+ msalCommon.HttpStatus.SERVICE_UNAVAILABLE,
11803
+ msalCommon.HttpStatus.GATEWAY_TIMEOUT,
11804
+ ];
11805
+ class DefaultManagedIdentityRetryPolicy {
11806
+ constructor() {
11807
+ this.linearRetryStrategy = new LinearRetryStrategy();
11808
+ }
11809
+ /*
11810
+ * this is defined here as a static variable despite being defined as a constant outside of the
11811
+ * class because it needs to be overridden in the unit tests so that the unit tests run faster
11812
+ */
11813
+ static get DEFAULT_MANAGED_IDENTITY_RETRY_DELAY_MS() {
11814
+ return DEFAULT_MANAGED_IDENTITY_RETRY_DELAY_MS;
11815
+ }
11816
+ async pauseForRetry(httpStatusCode, currentRetry, logger, retryAfterHeader) {
11817
+ if (DEFAULT_MANAGED_IDENTITY_HTTP_STATUS_CODES_TO_RETRY_ON.includes(httpStatusCode) &&
11818
+ currentRetry < DEFAULT_MANAGED_IDENTITY_MAX_RETRIES) {
11819
+ const retryAfterDelay = this.linearRetryStrategy.calculateDelay(retryAfterHeader, DefaultManagedIdentityRetryPolicy.DEFAULT_MANAGED_IDENTITY_RETRY_DELAY_MS);
11820
+ logger.verbose(`Retrying request in ${retryAfterDelay}ms (retry attempt: ${currentRetry + 1})`);
11821
+ // pause execution for the calculated delay
11777
11822
  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);
11823
+ // retryAfterHeader value of 0 evaluates to false, and DEFAULT_MANAGED_IDENTITY_RETRY_DELAY_MS will be used
11824
+ return setTimeout(resolve, retryAfterDelay);
11780
11825
  });
11781
11826
  return true;
11782
11827
  }
11828
+ // if the status code is not retriable or max retries have been reached, do not retry
11783
11829
  return false;
11784
11830
  }
11785
11831
  }
@@ -11795,8 +11841,8 @@ class ManagedIdentityRequestParameters {
11795
11841
  this.headers = {};
11796
11842
  this.bodyParameters = {};
11797
11843
  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;
11844
+ this.retryPolicy =
11845
+ retryPolicy || new DefaultManagedIdentityRetryPolicy();
11800
11846
  }
11801
11847
  computeUri() {
11802
11848
  const parameters = new Map();
@@ -12054,6 +12100,125 @@ class CloudShell extends BaseManagedIdentitySource {
12054
12100
  }
12055
12101
  }
12056
12102
 
12103
+ /*
12104
+ * Copyright (c) Microsoft Corporation. All rights reserved.
12105
+ * Licensed under the MIT License.
12106
+ */
12107
+ class ExponentialRetryStrategy {
12108
+ constructor(minExponentialBackoff, maxExponentialBackoff, exponentialDeltaBackoff) {
12109
+ this.minExponentialBackoff = minExponentialBackoff;
12110
+ this.maxExponentialBackoff = maxExponentialBackoff;
12111
+ this.exponentialDeltaBackoff = exponentialDeltaBackoff;
12112
+ }
12113
+ /**
12114
+ * Calculates the exponential delay based on the current retry attempt.
12115
+ *
12116
+ * @param {number} currentRetry - The current retry attempt number.
12117
+ * @returns {number} - The calculated exponential delay in milliseconds.
12118
+ *
12119
+ * The delay is calculated using the formula:
12120
+ * - If `currentRetry` is 0, it returns the minimum backoff time.
12121
+ * - Otherwise, it calculates the delay as the minimum of:
12122
+ * - `(2^(currentRetry - 1)) * deltaBackoff`
12123
+ * - `maxBackoff`
12124
+ *
12125
+ * This ensures that the delay increases exponentially with each retry attempt,
12126
+ * but does not exceed the maximum backoff time.
12127
+ */
12128
+ calculateDelay(currentRetry) {
12129
+ // Attempt 1
12130
+ if (currentRetry === 0) {
12131
+ return this.minExponentialBackoff;
12132
+ }
12133
+ // Attempt 2+
12134
+ const exponentialDelay = Math.min(Math.pow(2, currentRetry - 1) * this.exponentialDeltaBackoff, this.maxExponentialBackoff);
12135
+ return exponentialDelay;
12136
+ }
12137
+ }
12138
+
12139
+ /*
12140
+ * Copyright (c) Microsoft Corporation. All rights reserved.
12141
+ * Licensed under the MIT License.
12142
+ */
12143
+ const HTTP_STATUS_400_CODES_FOR_EXPONENTIAL_STRATEGY = [
12144
+ msalCommon.HttpStatus.NOT_FOUND,
12145
+ msalCommon.HttpStatus.REQUEST_TIMEOUT,
12146
+ msalCommon.HttpStatus.GONE,
12147
+ msalCommon.HttpStatus.TOO_MANY_REQUESTS,
12148
+ ];
12149
+ const EXPONENTIAL_STRATEGY_NUM_RETRIES = 3;
12150
+ const LINEAR_STRATEGY_NUM_RETRIES = 7;
12151
+ const MIN_EXPONENTIAL_BACKOFF_MS = 1000;
12152
+ const MAX_EXPONENTIAL_BACKOFF_MS = 4000;
12153
+ const EXPONENTIAL_DELTA_BACKOFF_MS = 2000;
12154
+ const HTTP_STATUS_GONE_RETRY_AFTER_MS = 10 * 1000; // 10 seconds
12155
+ class ImdsRetryPolicy {
12156
+ constructor() {
12157
+ this.exponentialRetryStrategy = new ExponentialRetryStrategy(ImdsRetryPolicy.MIN_EXPONENTIAL_BACKOFF_MS, ImdsRetryPolicy.MAX_EXPONENTIAL_BACKOFF_MS, ImdsRetryPolicy.EXPONENTIAL_DELTA_BACKOFF_MS);
12158
+ }
12159
+ /*
12160
+ * these are defined here as static variables despite being defined as constants outside of the
12161
+ * class because they need to be overridden in the unit tests so that the unit tests run faster
12162
+ */
12163
+ static get MIN_EXPONENTIAL_BACKOFF_MS() {
12164
+ return MIN_EXPONENTIAL_BACKOFF_MS;
12165
+ }
12166
+ static get MAX_EXPONENTIAL_BACKOFF_MS() {
12167
+ return MAX_EXPONENTIAL_BACKOFF_MS;
12168
+ }
12169
+ static get EXPONENTIAL_DELTA_BACKOFF_MS() {
12170
+ return EXPONENTIAL_DELTA_BACKOFF_MS;
12171
+ }
12172
+ static get HTTP_STATUS_GONE_RETRY_AFTER_MS() {
12173
+ return HTTP_STATUS_GONE_RETRY_AFTER_MS;
12174
+ }
12175
+ set isNewRequest(value) {
12176
+ this._isNewRequest = value;
12177
+ }
12178
+ /**
12179
+ * Pauses execution for a calculated delay before retrying a request.
12180
+ *
12181
+ * @param httpStatusCode - The HTTP status code of the response.
12182
+ * @param currentRetry - The current retry attempt number.
12183
+ * @param retryAfterHeader - The value of the "retry-after" header from the response.
12184
+ * @returns A promise that resolves to a boolean indicating whether a retry should be attempted.
12185
+ */
12186
+ async pauseForRetry(httpStatusCode, currentRetry, logger) {
12187
+ if (this._isNewRequest) {
12188
+ this._isNewRequest = false;
12189
+ // calculate the maxRetries based on the status code, once per request
12190
+ this.maxRetries =
12191
+ httpStatusCode === msalCommon.HttpStatus.GONE
12192
+ ? LINEAR_STRATEGY_NUM_RETRIES
12193
+ : EXPONENTIAL_STRATEGY_NUM_RETRIES;
12194
+ }
12195
+ /**
12196
+ * (status code is one of the retriable 400 status code
12197
+ * or
12198
+ * status code is >= 500 and <= 599)
12199
+ * and
12200
+ * current count of retries is less than the max number of retries
12201
+ */
12202
+ if ((HTTP_STATUS_400_CODES_FOR_EXPONENTIAL_STRATEGY.includes(httpStatusCode) ||
12203
+ (httpStatusCode >= msalCommon.HttpStatus.SERVER_ERROR_RANGE_START &&
12204
+ httpStatusCode <= msalCommon.HttpStatus.SERVER_ERROR_RANGE_END &&
12205
+ currentRetry < this.maxRetries)) &&
12206
+ currentRetry < this.maxRetries) {
12207
+ const retryAfterDelay = httpStatusCode === msalCommon.HttpStatus.GONE
12208
+ ? ImdsRetryPolicy.HTTP_STATUS_GONE_RETRY_AFTER_MS
12209
+ : this.exponentialRetryStrategy.calculateDelay(currentRetry);
12210
+ logger.verbose(`Retrying request in ${retryAfterDelay}ms (retry attempt: ${currentRetry + 1})`);
12211
+ // pause execution for the calculated delay
12212
+ await new Promise((resolve) => {
12213
+ return setTimeout(resolve, retryAfterDelay);
12214
+ });
12215
+ return true;
12216
+ }
12217
+ // if the status code is not retriable or max retries have been reached, do not retry
12218
+ return false;
12219
+ }
12220
+ }
12221
+
12057
12222
  /*
12058
12223
  * Copyright (c) Microsoft Corporation. All rights reserved.
12059
12224
  * Licensed under the MIT License.
@@ -12095,6 +12260,7 @@ class Imds extends BaseManagedIdentitySource {
12095
12260
  )] = managedIdentityId.id;
12096
12261
  }
12097
12262
  // bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
12263
+ request.retryPolicy = new ImdsRetryPolicy();
12098
12264
  return request;
12099
12265
  }
12100
12266
  }
@@ -12189,7 +12355,9 @@ class MachineLearning extends BaseManagedIdentitySource {
12189
12355
  request.queryParameters[RESOURCE_BODY_OR_QUERY_PARAMETER_NAME] =
12190
12356
  resource;
12191
12357
  if (managedIdentityId.idType !== ManagedIdentityIdType.SYSTEM_ASSIGNED) {
12192
- request.queryParameters[this.getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityId.idType)] = managedIdentityId.id;
12358
+ request.queryParameters[this.getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityId.idType, false, // isIMDS
12359
+ true // uses2017API
12360
+ )] = managedIdentityId.id;
12193
12361
  }
12194
12362
  // bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
12195
12363
  return request;