@azure/msal-node 3.4.1 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) 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.mjs +1 -1
  7. package/dist/client/ClientAssertion.mjs +1 -1
  8. package/dist/client/ClientCredentialClient.mjs +1 -1
  9. package/dist/client/ConfidentialClientApplication.mjs +1 -1
  10. package/dist/client/DeviceCodeClient.mjs +1 -1
  11. package/dist/client/ManagedIdentityApplication.mjs +1 -1
  12. package/dist/client/ManagedIdentityClient.mjs +1 -1
  13. package/dist/client/ManagedIdentitySources/AppService.mjs +1 -1
  14. package/dist/client/ManagedIdentitySources/AzureArc.mjs +1 -1
  15. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +2 -1
  16. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
  17. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +10 -6
  18. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs.map +1 -1
  19. package/dist/client/ManagedIdentitySources/CloudShell.mjs +1 -1
  20. package/dist/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
  21. package/dist/client/ManagedIdentitySources/Imds.mjs +3 -1
  22. package/dist/client/ManagedIdentitySources/Imds.mjs.map +1 -1
  23. package/dist/client/ManagedIdentitySources/MachineLearning.d.ts.map +1 -1
  24. package/dist/client/ManagedIdentitySources/MachineLearning.mjs +4 -2
  25. package/dist/client/ManagedIdentitySources/MachineLearning.mjs.map +1 -1
  26. package/dist/client/ManagedIdentitySources/ServiceFabric.mjs +1 -1
  27. package/dist/client/OnBehalfOfClient.mjs +1 -1
  28. package/dist/client/PublicClientApplication.mjs +1 -1
  29. package/dist/client/UsernamePasswordClient.mjs +1 -1
  30. package/dist/config/Configuration.d.ts +5 -0
  31. package/dist/config/Configuration.d.ts.map +1 -1
  32. package/dist/config/Configuration.mjs +2 -1
  33. package/dist/config/Configuration.mjs.map +1 -1
  34. package/dist/config/ManagedIdentityId.mjs +1 -1
  35. package/dist/config/ManagedIdentityRequestParameters.d.ts.map +1 -1
  36. package/dist/config/ManagedIdentityRequestParameters.mjs +4 -5
  37. package/dist/config/ManagedIdentityRequestParameters.mjs.map +1 -1
  38. package/dist/crypto/CryptoProvider.mjs +1 -1
  39. package/dist/crypto/GuidGenerator.mjs +1 -1
  40. package/dist/crypto/HashUtils.mjs +1 -1
  41. package/dist/crypto/PkceGenerator.mjs +1 -1
  42. package/dist/error/ManagedIdentityError.mjs +1 -1
  43. package/dist/error/ManagedIdentityErrorCodes.mjs +1 -1
  44. package/dist/error/NodeAuthError.mjs +1 -1
  45. package/dist/index.mjs +1 -1
  46. package/dist/internals.mjs +1 -1
  47. package/dist/network/HttpClient.mjs +1 -1
  48. package/dist/network/HttpClientWithRetries.d.ts +3 -2
  49. package/dist/network/HttpClientWithRetries.d.ts.map +1 -1
  50. package/dist/network/HttpClientWithRetries.mjs +7 -3
  51. package/dist/network/HttpClientWithRetries.mjs.map +1 -1
  52. package/dist/network/LoopbackClient.mjs +1 -1
  53. package/dist/packageMetadata.d.ts +1 -1
  54. package/dist/packageMetadata.mjs +2 -2
  55. package/dist/protocol/Authorize.d.ts.map +1 -1
  56. package/dist/protocol/Authorize.mjs +2 -2
  57. package/dist/protocol/Authorize.mjs.map +1 -1
  58. package/dist/retry/DefaultManagedIdentityRetryPolicy.d.ts +10 -0
  59. package/dist/retry/DefaultManagedIdentityRetryPolicy.d.ts.map +1 -0
  60. package/dist/retry/DefaultManagedIdentityRetryPolicy.mjs +49 -0
  61. package/dist/retry/DefaultManagedIdentityRetryPolicy.mjs.map +1 -0
  62. package/dist/retry/ExponentialRetryStrategy.d.ts +23 -0
  63. package/dist/retry/ExponentialRetryStrategy.d.ts.map +1 -0
  64. package/dist/retry/ExponentialRetryStrategy.mjs +40 -0
  65. package/dist/retry/ExponentialRetryStrategy.mjs.map +1 -0
  66. package/dist/retry/IHttpRetryPolicy.d.ts +12 -2
  67. package/dist/retry/IHttpRetryPolicy.d.ts.map +1 -1
  68. package/dist/retry/ImdsRetryPolicy.d.ts +22 -0
  69. package/dist/retry/ImdsRetryPolicy.d.ts.map +1 -0
  70. package/dist/retry/ImdsRetryPolicy.mjs +90 -0
  71. package/dist/retry/ImdsRetryPolicy.mjs.map +1 -0
  72. package/dist/retry/LinearRetryStrategy.d.ts +14 -0
  73. package/dist/retry/LinearRetryStrategy.d.ts.map +1 -0
  74. package/dist/retry/LinearRetryStrategy.mjs +36 -0
  75. package/dist/retry/LinearRetryStrategy.mjs.map +1 -0
  76. package/dist/utils/Constants.d.ts +4 -9
  77. package/dist/utils/Constants.d.ts.map +1 -1
  78. package/dist/utils/Constants.mjs +3 -13
  79. package/dist/utils/Constants.mjs.map +1 -1
  80. package/dist/utils/EncodingUtils.mjs +1 -1
  81. package/dist/utils/NetworkUtils.mjs +1 -1
  82. package/dist/utils/TimeUtils.mjs +1 -1
  83. package/lib/msal-node.cjs +269 -105
  84. package/lib/msal-node.cjs.map +1 -1
  85. package/lib/types/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +2 -1
  86. package/lib/types/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
  87. package/lib/types/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
  88. package/lib/types/client/ManagedIdentitySources/MachineLearning.d.ts.map +1 -1
  89. package/lib/types/config/Configuration.d.ts +5 -0
  90. package/lib/types/config/Configuration.d.ts.map +1 -1
  91. package/lib/types/config/ManagedIdentityRequestParameters.d.ts.map +1 -1
  92. package/lib/types/network/HttpClientWithRetries.d.ts +3 -2
  93. package/lib/types/network/HttpClientWithRetries.d.ts.map +1 -1
  94. package/lib/types/packageMetadata.d.ts +1 -1
  95. package/lib/types/protocol/Authorize.d.ts.map +1 -1
  96. package/lib/types/retry/DefaultManagedIdentityRetryPolicy.d.ts +10 -0
  97. package/lib/types/retry/DefaultManagedIdentityRetryPolicy.d.ts.map +1 -0
  98. package/lib/types/retry/ExponentialRetryStrategy.d.ts +23 -0
  99. package/lib/types/retry/ExponentialRetryStrategy.d.ts.map +1 -0
  100. package/lib/types/retry/IHttpRetryPolicy.d.ts +12 -2
  101. package/lib/types/retry/IHttpRetryPolicy.d.ts.map +1 -1
  102. package/lib/types/retry/ImdsRetryPolicy.d.ts +22 -0
  103. package/lib/types/retry/ImdsRetryPolicy.d.ts.map +1 -0
  104. package/lib/types/retry/LinearRetryStrategy.d.ts +14 -0
  105. package/lib/types/retry/LinearRetryStrategy.d.ts.map +1 -0
  106. package/lib/types/utils/Constants.d.ts +4 -9
  107. package/lib/types/utils/Constants.d.ts.map +1 -1
  108. package/package.json +2 -2
  109. package/src/client/ManagedIdentitySources/BaseManagedIdentitySource.ts +14 -6
  110. package/src/client/ManagedIdentitySources/Imds.ts +3 -0
  111. package/src/client/ManagedIdentitySources/MachineLearning.ts +3 -1
  112. package/src/config/Configuration.ts +6 -0
  113. package/src/config/ManagedIdentityRequestParameters.ts +4 -14
  114. package/src/network/HttpClientWithRetries.ts +10 -1
  115. package/src/packageMetadata.ts +1 -1
  116. package/src/protocol/Authorize.ts +6 -1
  117. package/src/retry/DefaultManagedIdentityRetryPolicy.ts +70 -0
  118. package/src/retry/ExponentialRetryStrategy.ts +53 -0
  119. package/src/retry/IHttpRetryPolicy.ts +14 -5
  120. package/src/retry/ImdsRetryPolicy.ts +121 -0
  121. package/src/retry/LinearRetryStrategy.ts +40 -0
  122. package/src/utils/Constants.ts +4 -17
  123. package/dist/retry/LinearRetryPolicy.d.ts +0 -12
  124. package/dist/retry/LinearRetryPolicy.d.ts.map +0 -1
  125. package/dist/retry/LinearRetryPolicy.mjs +0 -45
  126. package/dist/retry/LinearRetryPolicy.mjs.map +0 -1
  127. package/lib/types/retry/LinearRetryPolicy.d.ts +0 -12
  128. package/lib/types/retry/LinearRetryPolicy.d.ts.map +0 -1
  129. package/src/retry/LinearRetryPolicy.ts +0 -71
package/lib/msal-node.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-node v3.4.1 2025-03-25 */
1
+ /*! @azure/msal-node v3.5.1 2025-04-16 */
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.4.0 2025-03-25 */
156
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
156
157
  /*
157
158
  * Copyright (c) Microsoft Corporation. All rights reserved.
158
159
  * Licensed under the MIT License.
@@ -222,6 +223,7 @@ const HttpStatus = {
222
223
  UNAUTHORIZED: 401,
223
224
  NOT_FOUND: 404,
224
225
  REQUEST_TIMEOUT: 408,
226
+ GONE: 410,
225
227
  TOO_MANY_REQUESTS: 429,
226
228
  CLIENT_ERROR_RANGE_END: 499,
227
229
  SERVER_ERROR: 500,
@@ -442,7 +444,7 @@ const CacheOutcome = {
442
444
  // Token renewal offset default in seconds
443
445
  const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
444
446
 
445
- /*! @azure/msal-common v15.4.0 2025-03-25 */
447
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
446
448
  /*
447
449
  * Copyright (c) Microsoft Corporation. All rights reserved.
448
450
  * Licensed under the MIT License.
@@ -459,7 +461,7 @@ var AuthErrorCodes = /*#__PURE__*/Object.freeze({
459
461
  unexpectedError: unexpectedError
460
462
  });
461
463
 
462
- /*! @azure/msal-common v15.4.0 2025-03-25 */
464
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
463
465
 
464
466
  /*
465
467
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -508,7 +510,7 @@ function createAuthError(code, additionalMessage) {
508
510
  : AuthErrorMessages[code]);
509
511
  }
510
512
 
511
- /*! @azure/msal-common v15.4.0 2025-03-25 */
513
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
512
514
  /*
513
515
  * Copyright (c) Microsoft Corporation. All rights reserved.
514
516
  * Licensed under the MIT License.
@@ -606,7 +608,7 @@ var ClientAuthErrorCodes = /*#__PURE__*/Object.freeze({
606
608
  userTimeoutReached: userTimeoutReached
607
609
  });
608
610
 
609
- /*! @azure/msal-common v15.4.0 2025-03-25 */
611
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
610
612
 
611
613
  /*
612
614
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -858,7 +860,7 @@ function createClientAuthError(errorCode, additionalMessage) {
858
860
  return new ClientAuthError(errorCode, additionalMessage);
859
861
  }
860
862
 
861
- /*! @azure/msal-common v15.4.0 2025-03-25 */
863
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
862
864
 
863
865
  /*
864
866
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -897,7 +899,7 @@ const DEFAULT_CRYPTO_IMPLEMENTATION = {
897
899
  },
898
900
  };
899
901
 
900
- /*! @azure/msal-common v15.4.0 2025-03-25 */
902
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
901
903
 
902
904
  /*
903
905
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1088,12 +1090,12 @@ class Logger {
1088
1090
  }
1089
1091
  }
1090
1092
 
1091
- /*! @azure/msal-common v15.4.0 2025-03-25 */
1093
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
1092
1094
  /* eslint-disable header/header */
1093
1095
  const name$1 = "@azure/msal-common";
1094
- const version$1 = "15.4.0";
1096
+ const version$1 = "15.5.1";
1095
1097
 
1096
- /*! @azure/msal-common v15.4.0 2025-03-25 */
1098
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
1097
1099
  /*
1098
1100
  * Copyright (c) Microsoft Corporation. All rights reserved.
1099
1101
  * Licensed under the MIT License.
@@ -1113,7 +1115,7 @@ const AzureCloudInstance = {
1113
1115
  AzureUsGovernment: "https://login.microsoftonline.us",
1114
1116
  };
1115
1117
 
1116
- /*! @azure/msal-common v15.4.0 2025-03-25 */
1118
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
1117
1119
 
1118
1120
  /*
1119
1121
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1174,7 +1176,7 @@ function checkMaxAge(authTime, maxAge) {
1174
1176
  }
1175
1177
  }
1176
1178
 
1177
- /*! @azure/msal-common v15.4.0 2025-03-25 */
1179
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
1178
1180
  /*
1179
1181
  * Copyright (c) Microsoft Corporation. All rights reserved.
1180
1182
  * Licensed under the MIT License.
@@ -1229,7 +1231,7 @@ function delay(t, value) {
1229
1231
  return new Promise((resolve) => setTimeout(() => resolve(value), t));
1230
1232
  }
1231
1233
 
1232
- /*! @azure/msal-common v15.4.0 2025-03-25 */
1234
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
1233
1235
 
1234
1236
  /*
1235
1237
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1556,7 +1558,7 @@ function isAuthorityMetadataExpired(metadata) {
1556
1558
  return metadata.expiresAt <= nowSeconds();
1557
1559
  }
1558
1560
 
1559
- /*! @azure/msal-common v15.4.0 2025-03-25 */
1561
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
1560
1562
  /*
1561
1563
  * Copyright (c) Microsoft Corporation. All rights reserved.
1562
1564
  * Licensed under the MIT License.
@@ -1610,7 +1612,7 @@ var ClientConfigurationErrorCodes = /*#__PURE__*/Object.freeze({
1610
1612
  urlParseError: urlParseError
1611
1613
  });
1612
1614
 
1613
- /*! @azure/msal-common v15.4.0 2025-03-25 */
1615
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
1614
1616
 
1615
1617
  /*
1616
1618
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1748,7 +1750,7 @@ function createClientConfigurationError(errorCode) {
1748
1750
  return new ClientConfigurationError(errorCode);
1749
1751
  }
1750
1752
 
1751
- /*! @azure/msal-common v15.4.0 2025-03-25 */
1753
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
1752
1754
  /*
1753
1755
  * Copyright (c) Microsoft Corporation. All rights reserved.
1754
1756
  * Licensed under the MIT License.
@@ -1845,7 +1847,7 @@ class StringUtils {
1845
1847
  }
1846
1848
  }
1847
1849
 
1848
- /*! @azure/msal-common v15.4.0 2025-03-25 */
1850
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
1849
1851
 
1850
1852
  /*
1851
1853
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2036,7 +2038,7 @@ class ScopeSet {
2036
2038
  }
2037
2039
  }
2038
2040
 
2039
- /*! @azure/msal-common v15.4.0 2025-03-25 */
2041
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
2040
2042
 
2041
2043
  /*
2042
2044
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2076,7 +2078,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
2076
2078
  };
2077
2079
  }
2078
2080
 
2079
- /*! @azure/msal-common v15.4.0 2025-03-25 */
2081
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
2080
2082
  /*
2081
2083
  * Copyright (c) Microsoft Corporation. All rights reserved.
2082
2084
  * Licensed under the MIT License.
@@ -2155,7 +2157,7 @@ function updateAccountTenantProfileData(baseAccountInfo, tenantProfile, idTokenC
2155
2157
  return updatedAccountInfo;
2156
2158
  }
2157
2159
 
2158
- /*! @azure/msal-common v15.4.0 2025-03-25 */
2160
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
2159
2161
  /*
2160
2162
  * Copyright (c) Microsoft Corporation. All rights reserved.
2161
2163
  * Licensed under the MIT License.
@@ -2170,7 +2172,7 @@ const AuthorityType = {
2170
2172
  Ciam: 3,
2171
2173
  };
2172
2174
 
2173
- /*! @azure/msal-common v15.4.0 2025-03-25 */
2175
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
2174
2176
  /*
2175
2177
  * Copyright (c) Microsoft Corporation. All rights reserved.
2176
2178
  * Licensed under the MIT License.
@@ -2192,7 +2194,7 @@ function getTenantIdFromIdTokenClaims(idTokenClaims) {
2192
2194
  return null;
2193
2195
  }
2194
2196
 
2195
- /*! @azure/msal-common v15.4.0 2025-03-25 */
2197
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
2196
2198
  /*
2197
2199
  * Copyright (c) Microsoft Corporation. All rights reserved.
2198
2200
  * Licensed under the MIT License.
@@ -2216,7 +2218,7 @@ const ProtocolMode = {
2216
2218
  EAR: "EAR",
2217
2219
  };
2218
2220
 
2219
- /*! @azure/msal-common v15.4.0 2025-03-25 */
2221
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
2220
2222
 
2221
2223
  /*
2222
2224
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2459,7 +2461,7 @@ class AccountEntity {
2459
2461
  }
2460
2462
  }
2461
2463
 
2462
- /*! @azure/msal-common v15.4.0 2025-03-25 */
2464
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
2463
2465
 
2464
2466
  /*
2465
2467
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2509,15 +2511,22 @@ function getDeserializedResponse(responseString) {
2509
2511
  /**
2510
2512
  * Utility to create a URL from the params map
2511
2513
  */
2512
- function mapToQueryString(parameters) {
2514
+ function mapToQueryString(parameters, encodeExtraParams = true, extraQueryParameters) {
2513
2515
  const queryParameterArray = new Array();
2514
2516
  parameters.forEach((value, key) => {
2515
- queryParameterArray.push(`${key}=${encodeURIComponent(value)}`);
2517
+ if (!encodeExtraParams &&
2518
+ extraQueryParameters &&
2519
+ key in extraQueryParameters) {
2520
+ queryParameterArray.push(`${key}=${value}`);
2521
+ }
2522
+ else {
2523
+ queryParameterArray.push(`${key}=${encodeURIComponent(value)}`);
2524
+ }
2516
2525
  });
2517
2526
  return queryParameterArray.join("&");
2518
2527
  }
2519
2528
 
2520
- /*! @azure/msal-common v15.4.0 2025-03-25 */
2529
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
2521
2530
 
2522
2531
  /*
2523
2532
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2681,7 +2690,7 @@ class UrlString {
2681
2690
  }
2682
2691
  }
2683
2692
 
2684
- /*! @azure/msal-common v15.4.0 2025-03-25 */
2693
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
2685
2694
 
2686
2695
  /*
2687
2696
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2821,7 +2830,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
2821
2830
  return null;
2822
2831
  }
2823
2832
 
2824
- /*! @azure/msal-common v15.4.0 2025-03-25 */
2833
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
2825
2834
  /*
2826
2835
  * Copyright (c) Microsoft Corporation. All rights reserved.
2827
2836
  * Licensed under the MIT License.
@@ -2829,7 +2838,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
2829
2838
  const cacheQuotaExceededErrorCode = "cache_quota_exceeded";
2830
2839
  const cacheUnknownErrorCode = "cache_error_unknown";
2831
2840
 
2832
- /*! @azure/msal-common v15.4.0 2025-03-25 */
2841
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
2833
2842
 
2834
2843
  /*
2835
2844
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2856,7 +2865,7 @@ class CacheError extends Error {
2856
2865
  }
2857
2866
  }
2858
2867
 
2859
- /*! @azure/msal-common v15.4.0 2025-03-25 */
2868
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
2860
2869
 
2861
2870
  /*
2862
2871
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4040,7 +4049,7 @@ class DefaultStorageClass extends CacheManager {
4040
4049
  }
4041
4050
  }
4042
4051
 
4043
- /*! @azure/msal-common v15.4.0 2025-03-25 */
4052
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
4044
4053
 
4045
4054
  /*
4046
4055
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4128,6 +4137,7 @@ function buildAuthOptions(authOptions) {
4128
4137
  azureCloudOptions: DEFAULT_AZURE_CLOUD_OPTIONS,
4129
4138
  skipAuthorityMetadataCache: false,
4130
4139
  instanceAware: false,
4140
+ encodeExtraQueryParams: false,
4131
4141
  ...authOptions,
4132
4142
  };
4133
4143
  }
@@ -4139,7 +4149,7 @@ function isOidcProtocolMode(config) {
4139
4149
  return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
4140
4150
  }
4141
4151
 
4142
- /*! @azure/msal-common v15.4.0 2025-03-25 */
4152
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
4143
4153
  /*
4144
4154
  * Copyright (c) Microsoft Corporation. All rights reserved.
4145
4155
  * Licensed under the MIT License.
@@ -4149,7 +4159,7 @@ const CcsCredentialType = {
4149
4159
  UPN: "UPN",
4150
4160
  };
4151
4161
 
4152
- /*! @azure/msal-common v15.4.0 2025-03-25 */
4162
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
4153
4163
  /*
4154
4164
  * Copyright (c) Microsoft Corporation. All rights reserved.
4155
4165
  * Licensed under the MIT License.
@@ -4200,7 +4210,7 @@ const BROKER_CLIENT_ID = "brk_client_id";
4200
4210
  const BROKER_REDIRECT_URI = "brk_redirect_uri";
4201
4211
  const INSTANCE_AWARE = "instance_aware";
4202
4212
 
4203
- /*! @azure/msal-common v15.4.0 2025-03-25 */
4213
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
4204
4214
 
4205
4215
  /*
4206
4216
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4586,7 +4596,7 @@ function addBrokerParameters(parameters, brokerClientId, brokerRedirectUri) {
4586
4596
  }
4587
4597
  }
4588
4598
 
4589
- /*! @azure/msal-common v15.4.0 2025-03-25 */
4599
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
4590
4600
  /*
4591
4601
  * Copyright (c) Microsoft Corporation. All rights reserved.
4592
4602
  * Licensed under the MIT License.
@@ -4598,7 +4608,7 @@ function isOpenIdConfigResponse(response) {
4598
4608
  response.hasOwnProperty("jwks_uri"));
4599
4609
  }
4600
4610
 
4601
- /*! @azure/msal-common v15.4.0 2025-03-25 */
4611
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
4602
4612
  /*
4603
4613
  * Copyright (c) Microsoft Corporation. All rights reserved.
4604
4614
  * Licensed under the MIT License.
@@ -4608,7 +4618,7 @@ function isCloudInstanceDiscoveryResponse(response) {
4608
4618
  response.hasOwnProperty("metadata"));
4609
4619
  }
4610
4620
 
4611
- /*! @azure/msal-common v15.4.0 2025-03-25 */
4621
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
4612
4622
  /*
4613
4623
  * Copyright (c) Microsoft Corporation. All rights reserved.
4614
4624
  * Licensed under the MIT License.
@@ -4618,7 +4628,7 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
4618
4628
  response.hasOwnProperty("error_description"));
4619
4629
  }
4620
4630
 
4621
- /*! @azure/msal-common v15.4.0 2025-03-25 */
4631
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
4622
4632
  /*
4623
4633
  * Copyright (c) Microsoft Corporation. All rights reserved.
4624
4634
  * Licensed under the MIT License.
@@ -4877,7 +4887,7 @@ const PerformanceEvents = {
4877
4887
  DecryptEarResponse: "decryptEarResponse",
4878
4888
  };
4879
4889
 
4880
- /*! @azure/msal-common v15.4.0 2025-03-25 */
4890
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
4881
4891
  /*
4882
4892
  * Copyright (c) Microsoft Corporation. All rights reserved.
4883
4893
  * Licensed under the MIT License.
@@ -4973,7 +4983,7 @@ const invokeAsync = (callback, eventName, logger, telemetryClient, correlationId
4973
4983
  };
4974
4984
  };
4975
4985
 
4976
- /*! @azure/msal-common v15.4.0 2025-03-25 */
4986
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
4977
4987
 
4978
4988
  /*
4979
4989
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5082,7 +5092,7 @@ RegionDiscovery.IMDS_OPTIONS = {
5082
5092
  },
5083
5093
  };
5084
5094
 
5085
- /*! @azure/msal-common v15.4.0 2025-03-25 */
5095
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
5086
5096
 
5087
5097
  /*
5088
5098
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5921,7 +5931,7 @@ function buildStaticAuthorityOptions(authOptions) {
5921
5931
  };
5922
5932
  }
5923
5933
 
5924
- /*! @azure/msal-common v15.4.0 2025-03-25 */
5934
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
5925
5935
 
5926
5936
  /*
5927
5937
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5952,7 +5962,7 @@ async function createDiscoveredInstance(authorityUri, networkClient, cacheManage
5952
5962
  }
5953
5963
  }
5954
5964
 
5955
- /*! @azure/msal-common v15.4.0 2025-03-25 */
5965
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
5956
5966
 
5957
5967
  /*
5958
5968
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5971,7 +5981,7 @@ class ServerError extends AuthError {
5971
5981
  }
5972
5982
  }
5973
5983
 
5974
- /*! @azure/msal-common v15.4.0 2025-03-25 */
5984
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
5975
5985
  /*
5976
5986
  * Copyright (c) Microsoft Corporation. All rights reserved.
5977
5987
  * Licensed under the MIT License.
@@ -5992,7 +6002,7 @@ function getRequestThumbprint(clientId, request, homeAccountId) {
5992
6002
  };
5993
6003
  }
5994
6004
 
5995
- /*! @azure/msal-common v15.4.0 2025-03-25 */
6005
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
5996
6006
 
5997
6007
  /*
5998
6008
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6079,7 +6089,7 @@ class ThrottlingUtils {
6079
6089
  }
6080
6090
  }
6081
6091
 
6082
- /*! @azure/msal-common v15.4.0 2025-03-25 */
6092
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
6083
6093
 
6084
6094
  /*
6085
6095
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6099,7 +6109,7 @@ class NetworkError extends AuthError {
6099
6109
  }
6100
6110
  }
6101
6111
 
6102
- /*! @azure/msal-common v15.4.0 2025-03-25 */
6112
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
6103
6113
 
6104
6114
  /*
6105
6115
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6247,7 +6257,7 @@ class BaseClient {
6247
6257
  }
6248
6258
  }
6249
6259
 
6250
- /*! @azure/msal-common v15.4.0 2025-03-25 */
6260
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
6251
6261
  /*
6252
6262
  * Copyright (c) Microsoft Corporation. All rights reserved.
6253
6263
  * Licensed under the MIT License.
@@ -6273,7 +6283,7 @@ var InteractionRequiredAuthErrorCodes = /*#__PURE__*/Object.freeze({
6273
6283
  refreshTokenExpired: refreshTokenExpired
6274
6284
  });
6275
6285
 
6276
- /*! @azure/msal-common v15.4.0 2025-03-25 */
6286
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
6277
6287
 
6278
6288
  /*
6279
6289
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6361,7 +6371,7 @@ function createInteractionRequiredAuthError(errorCode) {
6361
6371
  return new InteractionRequiredAuthError(errorCode, InteractionRequiredAuthErrorMessages[errorCode]);
6362
6372
  }
6363
6373
 
6364
- /*! @azure/msal-common v15.4.0 2025-03-25 */
6374
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
6365
6375
 
6366
6376
  /*
6367
6377
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6433,7 +6443,7 @@ class ProtocolUtils {
6433
6443
  }
6434
6444
  }
6435
6445
 
6436
- /*! @azure/msal-common v15.4.0 2025-03-25 */
6446
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
6437
6447
 
6438
6448
  /*
6439
6449
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6517,7 +6527,7 @@ class PopTokenGenerator {
6517
6527
  }
6518
6528
  }
6519
6529
 
6520
- /*! @azure/msal-common v15.4.0 2025-03-25 */
6530
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
6521
6531
  /*
6522
6532
  * Copyright (c) Microsoft Corporation. All rights reserved.
6523
6533
  * Licensed under the MIT License.
@@ -6544,7 +6554,7 @@ class PopTokenGenerator {
6544
6554
  }
6545
6555
  }
6546
6556
 
6547
- /*! @azure/msal-common v15.4.0 2025-03-25 */
6557
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
6548
6558
 
6549
6559
  /*
6550
6560
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6875,7 +6885,7 @@ function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decod
6875
6885
  return baseAccount;
6876
6886
  }
6877
6887
 
6878
- /*! @azure/msal-common v15.4.0 2025-03-25 */
6888
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
6879
6889
 
6880
6890
  /*
6881
6891
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6942,7 +6952,7 @@ class RequestValidator {
6942
6952
  }
6943
6953
  }
6944
6954
 
6945
- /*! @azure/msal-common v15.4.0 2025-03-25 */
6955
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
6946
6956
  /*
6947
6957
  * Copyright (c) Microsoft Corporation. All rights reserved.
6948
6958
  * Licensed under the MIT License.
@@ -6960,7 +6970,7 @@ async function getClientAssertion(clientAssertion, clientId, tokenEndpoint) {
6960
6970
  }
6961
6971
  }
6962
6972
 
6963
- /*! @azure/msal-common v15.4.0 2025-03-25 */
6973
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
6964
6974
 
6965
6975
  /*
6966
6976
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7189,11 +7199,11 @@ class AuthorizationCodeClient extends BaseClient {
7189
7199
  if (this.config.authOptions.instanceAware) {
7190
7200
  addInstanceAware(parameters);
7191
7201
  }
7192
- return mapToQueryString(parameters);
7202
+ return mapToQueryString(parameters, this.config.authOptions.encodeExtraQueryParams, request.extraQueryParameters);
7193
7203
  }
7194
7204
  }
7195
7205
 
7196
- /*! @azure/msal-common v15.4.0 2025-03-25 */
7206
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
7197
7207
 
7198
7208
  /*
7199
7209
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7402,7 +7412,7 @@ class RefreshTokenClient extends BaseClient {
7402
7412
  }
7403
7413
  }
7404
7414
 
7405
- /*! @azure/msal-common v15.4.0 2025-03-25 */
7415
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
7406
7416
 
7407
7417
  /*
7408
7418
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7500,7 +7510,7 @@ class SilentFlowClient extends BaseClient {
7500
7510
  }
7501
7511
  }
7502
7512
 
7503
- /*! @azure/msal-common v15.4.0 2025-03-25 */
7513
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
7504
7514
 
7505
7515
  /*
7506
7516
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7635,8 +7645,8 @@ function getStandardAuthorizeRequestParameters(authOptions, request, logger, per
7635
7645
  * @param requestParameters
7636
7646
  * @returns
7637
7647
  */
7638
- function getAuthorizeUrl(authority, requestParameters) {
7639
- const queryString = mapToQueryString(requestParameters);
7648
+ function getAuthorizeUrl(authority, requestParameters, encodeParams, extraQueryParameters) {
7649
+ const queryString = mapToQueryString(requestParameters, encodeParams, extraQueryParameters);
7640
7650
  return UrlString.appendQueryString(authority.authorizationEndpoint, queryString);
7641
7651
  }
7642
7652
  /**
@@ -7650,7 +7660,7 @@ function extractLoginHint(account) {
7650
7660
  return account.idTokenClaims?.login_hint || null;
7651
7661
  }
7652
7662
 
7653
- /*! @azure/msal-common v15.4.0 2025-03-25 */
7663
+ /*! @azure/msal-common v15.5.1 2025-04-16 */
7654
7664
 
7655
7665
  /*
7656
7666
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8225,17 +8235,7 @@ const LOOPBACK_SERVER_CONSTANTS = {
8225
8235
  INTERVAL_MS: 100,
8226
8236
  TIMEOUT_MS: 5000,
8227
8237
  };
8228
- const AZURE_ARC_SECRET_FILE_MAX_SIZE_BYTES = 4096; // 4 KB
8229
- const MANAGED_IDENTITY_MAX_RETRIES = 3;
8230
- const MANAGED_IDENTITY_RETRY_DELAY = 1000;
8231
- const MANAGED_IDENTITY_HTTP_STATUS_CODES_TO_RETRY_ON = [
8232
- HttpStatus.NOT_FOUND,
8233
- HttpStatus.REQUEST_TIMEOUT,
8234
- HttpStatus.TOO_MANY_REQUESTS,
8235
- HttpStatus.SERVER_ERROR,
8236
- HttpStatus.SERVICE_UNAVAILABLE,
8237
- HttpStatus.GATEWAY_TIMEOUT,
8238
- ];
8238
+ const AZURE_ARC_SECRET_FILE_MAX_SIZE_BYTES = 4096; // 4 KB
8239
8239
 
8240
8240
  /*
8241
8241
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8795,6 +8795,7 @@ const DEFAULT_AUTH_OPTIONS = {
8795
8795
  tenant: Constants$1.EMPTY_STRING,
8796
8796
  },
8797
8797
  skipAuthorityMetadataCache: false,
8798
+ encodeExtraQueryParams: false,
8798
8799
  };
8799
8800
  const DEFAULT_CACHE_OPTIONS = {
8800
8801
  claimsBasedCachingEnabled: false,
@@ -9943,7 +9944,7 @@ class ClientAssertion {
9943
9944
 
9944
9945
  /* eslint-disable header/header */
9945
9946
  const name = "@azure/msal-node";
9946
- const version = "3.4.1";
9947
+ const version = "3.5.1";
9947
9948
 
9948
9949
  /*
9949
9950
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10075,7 +10076,7 @@ function getAuthCodeRequestUrl(config, authority, request, logger) {
10075
10076
  addCodeChallengeParams(parameters, request.codeChallenge, request.codeChallengeMethod);
10076
10077
  }
10077
10078
  addExtraQueryParameters(parameters, request.extraQueryParameters || {});
10078
- return getAuthorizeUrl(authority, parameters);
10079
+ return getAuthorizeUrl(authority, parameters, config.auth.encodeExtraQueryParams, request.extraQueryParameters);
10079
10080
  }
10080
10081
 
10081
10082
  /*
@@ -11586,9 +11587,10 @@ function isIso8601(dateString) {
11586
11587
  * Licensed under the MIT License.
11587
11588
  */
11588
11589
  class HttpClientWithRetries {
11589
- constructor(httpClientNoRetries, retryPolicy) {
11590
+ constructor(httpClientNoRetries, retryPolicy, logger) {
11590
11591
  this.httpClientNoRetries = httpClientNoRetries;
11591
11592
  this.retryPolicy = retryPolicy;
11593
+ this.logger = logger;
11592
11594
  }
11593
11595
  async sendNetworkRequestAsyncHelper(httpMethod, url, options) {
11594
11596
  if (httpMethod === HttpMethod.GET) {
@@ -11601,8 +11603,11 @@ class HttpClientWithRetries {
11601
11603
  async sendNetworkRequestAsync(httpMethod, url, options) {
11602
11604
  // the underlying network module (custom or HttpClient) will make the call
11603
11605
  let response = await this.sendNetworkRequestAsyncHelper(httpMethod, url, options);
11606
+ if ("isNewRequest" in this.retryPolicy) {
11607
+ this.retryPolicy.isNewRequest = true;
11608
+ }
11604
11609
  let currentRetry = 0;
11605
- while (await this.retryPolicy.pauseForRetry(response.status, currentRetry, response.headers[HeaderNames.RETRY_AFTER])) {
11610
+ while (await this.retryPolicy.pauseForRetry(response.status, currentRetry, this.logger, response.headers[HeaderNames.RETRY_AFTER])) {
11606
11611
  response = await this.sendNetworkRequestAsyncHelper(httpMethod, url, options);
11607
11612
  currentRetry++;
11608
11613
  }
@@ -11624,6 +11629,7 @@ class HttpClientWithRetries {
11624
11629
  * Managed Identity User Assigned Id Query Parameter Names
11625
11630
  */
11626
11631
  const ManagedIdentityUserAssignedIdQueryParameterNames = {
11632
+ MANAGED_IDENTITY_CLIENT_ID_2017: "clientid",
11627
11633
  MANAGED_IDENTITY_CLIENT_ID: "client_id",
11628
11634
  MANAGED_IDENTITY_OBJECT_ID: "object_id",
11629
11635
  MANAGED_IDENTITY_RESOURCE_ID_IMDS: "msi_res_id",
@@ -11699,7 +11705,7 @@ class BaseManagedIdentitySource {
11699
11705
  */
11700
11706
  const networkClientHelper = this.disableInternalRetries
11701
11707
  ? this.networkClient
11702
- : new HttpClientWithRetries(this.networkClient, networkRequest.retryPolicy);
11708
+ : new HttpClientWithRetries(this.networkClient, networkRequest.retryPolicy, this.logger);
11703
11709
  const reqTimestamp = nowSeconds();
11704
11710
  let response;
11705
11711
  try {
@@ -11728,14 +11734,17 @@ class BaseManagedIdentitySource {
11728
11734
  // caches the token
11729
11735
  return responseHandler.handleServerTokenResponse(serverTokenResponse, fakeAuthority, reqTimestamp, managedIdentityRequest);
11730
11736
  }
11731
- getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityIdType, imds) {
11737
+ getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityIdType, isImds, usesApi2017) {
11732
11738
  switch (managedIdentityIdType) {
11733
11739
  case ManagedIdentityIdType.USER_ASSIGNED_CLIENT_ID:
11734
- this.logger.info("[Managed Identity] Adding user assigned client id to the request.");
11735
- return ManagedIdentityUserAssignedIdQueryParameterNames.MANAGED_IDENTITY_CLIENT_ID;
11740
+ this.logger.info(`[Managed Identity] [API version ${usesApi2017 ? "2017+" : "2019+"}] Adding user assigned client id to the request.`);
11741
+ // The Machine Learning source uses the 2017-09-01 API version, which uses "clientid" instead of "client_id"
11742
+ return usesApi2017
11743
+ ? ManagedIdentityUserAssignedIdQueryParameterNames.MANAGED_IDENTITY_CLIENT_ID_2017
11744
+ : ManagedIdentityUserAssignedIdQueryParameterNames.MANAGED_IDENTITY_CLIENT_ID;
11736
11745
  case ManagedIdentityIdType.USER_ASSIGNED_RESOURCE_ID:
11737
11746
  this.logger.info("[Managed Identity] Adding user assigned resource id to the request.");
11738
- return imds
11747
+ return isImds
11739
11748
  ? ManagedIdentityUserAssignedIdQueryParameterNames.MANAGED_IDENTITY_RESOURCE_ID_IMDS
11740
11749
  : ManagedIdentityUserAssignedIdQueryParameterNames.MANAGED_IDENTITY_RESOURCE_ID_NON_IMDS;
11741
11750
  case ManagedIdentityIdType.USER_ASSIGNED_OBJECT_ID:
@@ -11760,15 +11769,18 @@ BaseManagedIdentitySource.getValidatedEnvVariableUrlString = (envVariableStringN
11760
11769
  * Copyright (c) Microsoft Corporation. All rights reserved.
11761
11770
  * Licensed under the MIT License.
11762
11771
  */
11763
- class LinearRetryPolicy {
11764
- constructor(maxRetries, retryDelay, httpStatusCodesToRetryOn) {
11765
- this.maxRetries = maxRetries;
11766
- this.retryDelay = retryDelay;
11767
- this.httpStatusCodesToRetryOn = httpStatusCodesToRetryOn;
11768
- }
11769
- retryAfterMillisecondsToSleep(retryHeader) {
11772
+ class LinearRetryStrategy {
11773
+ /**
11774
+ * Calculates the number of milliseconds to sleep based on the `retry-after` HTTP header.
11775
+ *
11776
+ * @param retryHeader - The value of the `retry-after` HTTP header. This can be either a number of seconds
11777
+ * or an HTTP date string.
11778
+ * @returns The number of milliseconds to sleep before retrying the request. If the `retry-after` header is not
11779
+ * present or cannot be parsed, returns 0.
11780
+ */
11781
+ calculateDelay(retryHeader, minimumDelay) {
11770
11782
  if (!retryHeader) {
11771
- return 0;
11783
+ return minimumDelay;
11772
11784
  }
11773
11785
  // retry-after header is in seconds
11774
11786
  let millisToSleep = Math.round(parseFloat(retryHeader) * 1000);
@@ -11777,22 +11789,52 @@ class LinearRetryPolicy {
11777
11789
  * <day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT
11778
11790
  */
11779
11791
  if (isNaN(millisToSleep)) {
11780
- millisToSleep = Math.max(0,
11781
11792
  // .valueOf() is needed to subtract dates in TypeScript
11782
- new Date(retryHeader).valueOf() - new Date().valueOf());
11793
+ millisToSleep =
11794
+ new Date(retryHeader).valueOf() - new Date().valueOf();
11783
11795
  }
11784
- return millisToSleep;
11796
+ return Math.max(minimumDelay, millisToSleep);
11785
11797
  }
11786
- async pauseForRetry(httpStatusCode, currentRetry, retryAfterHeader) {
11787
- if (this.httpStatusCodesToRetryOn.includes(httpStatusCode) &&
11788
- currentRetry < this.maxRetries) {
11789
- const retryAfterDelay = this.retryAfterMillisecondsToSleep(retryAfterHeader);
11798
+ }
11799
+
11800
+ /*
11801
+ * Copyright (c) Microsoft Corporation. All rights reserved.
11802
+ * Licensed under the MIT License.
11803
+ */
11804
+ const DEFAULT_MANAGED_IDENTITY_MAX_RETRIES = 3;
11805
+ const DEFAULT_MANAGED_IDENTITY_RETRY_DELAY_MS = 1000;
11806
+ const DEFAULT_MANAGED_IDENTITY_HTTP_STATUS_CODES_TO_RETRY_ON = [
11807
+ msalCommon.HttpStatus.NOT_FOUND,
11808
+ msalCommon.HttpStatus.REQUEST_TIMEOUT,
11809
+ msalCommon.HttpStatus.TOO_MANY_REQUESTS,
11810
+ msalCommon.HttpStatus.SERVER_ERROR,
11811
+ msalCommon.HttpStatus.SERVICE_UNAVAILABLE,
11812
+ msalCommon.HttpStatus.GATEWAY_TIMEOUT,
11813
+ ];
11814
+ class DefaultManagedIdentityRetryPolicy {
11815
+ constructor() {
11816
+ this.linearRetryStrategy = new LinearRetryStrategy();
11817
+ }
11818
+ /*
11819
+ * this is defined here as a static variable despite being defined as a constant outside of the
11820
+ * class because it needs to be overridden in the unit tests so that the unit tests run faster
11821
+ */
11822
+ static get DEFAULT_MANAGED_IDENTITY_RETRY_DELAY_MS() {
11823
+ return DEFAULT_MANAGED_IDENTITY_RETRY_DELAY_MS;
11824
+ }
11825
+ async pauseForRetry(httpStatusCode, currentRetry, logger, retryAfterHeader) {
11826
+ if (DEFAULT_MANAGED_IDENTITY_HTTP_STATUS_CODES_TO_RETRY_ON.includes(httpStatusCode) &&
11827
+ currentRetry < DEFAULT_MANAGED_IDENTITY_MAX_RETRIES) {
11828
+ const retryAfterDelay = this.linearRetryStrategy.calculateDelay(retryAfterHeader, DefaultManagedIdentityRetryPolicy.DEFAULT_MANAGED_IDENTITY_RETRY_DELAY_MS);
11829
+ logger.verbose(`Retrying request in ${retryAfterDelay}ms (retry attempt: ${currentRetry + 1})`);
11830
+ // pause execution for the calculated delay
11790
11831
  await new Promise((resolve) => {
11791
- // retryAfterHeader value of 0 evaluates to false, and this.retryDelay will be used
11792
- return setTimeout(resolve, retryAfterDelay || this.retryDelay);
11832
+ // retryAfterHeader value of 0 evaluates to false, and DEFAULT_MANAGED_IDENTITY_RETRY_DELAY_MS will be used
11833
+ return setTimeout(resolve, retryAfterDelay);
11793
11834
  });
11794
11835
  return true;
11795
11836
  }
11837
+ // if the status code is not retriable or max retries have been reached, do not retry
11796
11838
  return false;
11797
11839
  }
11798
11840
  }
@@ -11808,8 +11850,8 @@ class ManagedIdentityRequestParameters {
11808
11850
  this.headers = {};
11809
11851
  this.bodyParameters = {};
11810
11852
  this.queryParameters = {};
11811
- const defaultRetryPolicy = new LinearRetryPolicy(MANAGED_IDENTITY_MAX_RETRIES, MANAGED_IDENTITY_RETRY_DELAY, MANAGED_IDENTITY_HTTP_STATUS_CODES_TO_RETRY_ON);
11812
- this.retryPolicy = retryPolicy || defaultRetryPolicy;
11853
+ this.retryPolicy =
11854
+ retryPolicy || new DefaultManagedIdentityRetryPolicy();
11813
11855
  }
11814
11856
  computeUri() {
11815
11857
  const parameters = new Map();
@@ -12067,6 +12109,125 @@ class CloudShell extends BaseManagedIdentitySource {
12067
12109
  }
12068
12110
  }
12069
12111
 
12112
+ /*
12113
+ * Copyright (c) Microsoft Corporation. All rights reserved.
12114
+ * Licensed under the MIT License.
12115
+ */
12116
+ class ExponentialRetryStrategy {
12117
+ constructor(minExponentialBackoff, maxExponentialBackoff, exponentialDeltaBackoff) {
12118
+ this.minExponentialBackoff = minExponentialBackoff;
12119
+ this.maxExponentialBackoff = maxExponentialBackoff;
12120
+ this.exponentialDeltaBackoff = exponentialDeltaBackoff;
12121
+ }
12122
+ /**
12123
+ * Calculates the exponential delay based on the current retry attempt.
12124
+ *
12125
+ * @param {number} currentRetry - The current retry attempt number.
12126
+ * @returns {number} - The calculated exponential delay in milliseconds.
12127
+ *
12128
+ * The delay is calculated using the formula:
12129
+ * - If `currentRetry` is 0, it returns the minimum backoff time.
12130
+ * - Otherwise, it calculates the delay as the minimum of:
12131
+ * - `(2^(currentRetry - 1)) * deltaBackoff`
12132
+ * - `maxBackoff`
12133
+ *
12134
+ * This ensures that the delay increases exponentially with each retry attempt,
12135
+ * but does not exceed the maximum backoff time.
12136
+ */
12137
+ calculateDelay(currentRetry) {
12138
+ // Attempt 1
12139
+ if (currentRetry === 0) {
12140
+ return this.minExponentialBackoff;
12141
+ }
12142
+ // Attempt 2+
12143
+ const exponentialDelay = Math.min(Math.pow(2, currentRetry - 1) * this.exponentialDeltaBackoff, this.maxExponentialBackoff);
12144
+ return exponentialDelay;
12145
+ }
12146
+ }
12147
+
12148
+ /*
12149
+ * Copyright (c) Microsoft Corporation. All rights reserved.
12150
+ * Licensed under the MIT License.
12151
+ */
12152
+ const HTTP_STATUS_400_CODES_FOR_EXPONENTIAL_STRATEGY = [
12153
+ msalCommon.HttpStatus.NOT_FOUND,
12154
+ msalCommon.HttpStatus.REQUEST_TIMEOUT,
12155
+ msalCommon.HttpStatus.GONE,
12156
+ msalCommon.HttpStatus.TOO_MANY_REQUESTS,
12157
+ ];
12158
+ const EXPONENTIAL_STRATEGY_NUM_RETRIES = 3;
12159
+ const LINEAR_STRATEGY_NUM_RETRIES = 7;
12160
+ const MIN_EXPONENTIAL_BACKOFF_MS = 1000;
12161
+ const MAX_EXPONENTIAL_BACKOFF_MS = 4000;
12162
+ const EXPONENTIAL_DELTA_BACKOFF_MS = 2000;
12163
+ const HTTP_STATUS_GONE_RETRY_AFTER_MS = 10 * 1000; // 10 seconds
12164
+ class ImdsRetryPolicy {
12165
+ constructor() {
12166
+ this.exponentialRetryStrategy = new ExponentialRetryStrategy(ImdsRetryPolicy.MIN_EXPONENTIAL_BACKOFF_MS, ImdsRetryPolicy.MAX_EXPONENTIAL_BACKOFF_MS, ImdsRetryPolicy.EXPONENTIAL_DELTA_BACKOFF_MS);
12167
+ }
12168
+ /*
12169
+ * these are defined here as static variables despite being defined as constants outside of the
12170
+ * class because they need to be overridden in the unit tests so that the unit tests run faster
12171
+ */
12172
+ static get MIN_EXPONENTIAL_BACKOFF_MS() {
12173
+ return MIN_EXPONENTIAL_BACKOFF_MS;
12174
+ }
12175
+ static get MAX_EXPONENTIAL_BACKOFF_MS() {
12176
+ return MAX_EXPONENTIAL_BACKOFF_MS;
12177
+ }
12178
+ static get EXPONENTIAL_DELTA_BACKOFF_MS() {
12179
+ return EXPONENTIAL_DELTA_BACKOFF_MS;
12180
+ }
12181
+ static get HTTP_STATUS_GONE_RETRY_AFTER_MS() {
12182
+ return HTTP_STATUS_GONE_RETRY_AFTER_MS;
12183
+ }
12184
+ set isNewRequest(value) {
12185
+ this._isNewRequest = value;
12186
+ }
12187
+ /**
12188
+ * Pauses execution for a calculated delay before retrying a request.
12189
+ *
12190
+ * @param httpStatusCode - The HTTP status code of the response.
12191
+ * @param currentRetry - The current retry attempt number.
12192
+ * @param retryAfterHeader - The value of the "retry-after" header from the response.
12193
+ * @returns A promise that resolves to a boolean indicating whether a retry should be attempted.
12194
+ */
12195
+ async pauseForRetry(httpStatusCode, currentRetry, logger) {
12196
+ if (this._isNewRequest) {
12197
+ this._isNewRequest = false;
12198
+ // calculate the maxRetries based on the status code, once per request
12199
+ this.maxRetries =
12200
+ httpStatusCode === msalCommon.HttpStatus.GONE
12201
+ ? LINEAR_STRATEGY_NUM_RETRIES
12202
+ : EXPONENTIAL_STRATEGY_NUM_RETRIES;
12203
+ }
12204
+ /**
12205
+ * (status code is one of the retriable 400 status code
12206
+ * or
12207
+ * status code is >= 500 and <= 599)
12208
+ * and
12209
+ * current count of retries is less than the max number of retries
12210
+ */
12211
+ if ((HTTP_STATUS_400_CODES_FOR_EXPONENTIAL_STRATEGY.includes(httpStatusCode) ||
12212
+ (httpStatusCode >= msalCommon.HttpStatus.SERVER_ERROR_RANGE_START &&
12213
+ httpStatusCode <= msalCommon.HttpStatus.SERVER_ERROR_RANGE_END &&
12214
+ currentRetry < this.maxRetries)) &&
12215
+ currentRetry < this.maxRetries) {
12216
+ const retryAfterDelay = httpStatusCode === msalCommon.HttpStatus.GONE
12217
+ ? ImdsRetryPolicy.HTTP_STATUS_GONE_RETRY_AFTER_MS
12218
+ : this.exponentialRetryStrategy.calculateDelay(currentRetry);
12219
+ logger.verbose(`Retrying request in ${retryAfterDelay}ms (retry attempt: ${currentRetry + 1})`);
12220
+ // pause execution for the calculated delay
12221
+ await new Promise((resolve) => {
12222
+ return setTimeout(resolve, retryAfterDelay);
12223
+ });
12224
+ return true;
12225
+ }
12226
+ // if the status code is not retriable or max retries have been reached, do not retry
12227
+ return false;
12228
+ }
12229
+ }
12230
+
12070
12231
  /*
12071
12232
  * Copyright (c) Microsoft Corporation. All rights reserved.
12072
12233
  * Licensed under the MIT License.
@@ -12108,6 +12269,7 @@ class Imds extends BaseManagedIdentitySource {
12108
12269
  )] = managedIdentityId.id;
12109
12270
  }
12110
12271
  // bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
12272
+ request.retryPolicy = new ImdsRetryPolicy();
12111
12273
  return request;
12112
12274
  }
12113
12275
  }
@@ -12202,7 +12364,9 @@ class MachineLearning extends BaseManagedIdentitySource {
12202
12364
  request.queryParameters[RESOURCE_BODY_OR_QUERY_PARAMETER_NAME] =
12203
12365
  resource;
12204
12366
  if (managedIdentityId.idType !== ManagedIdentityIdType.SYSTEM_ASSIGNED) {
12205
- request.queryParameters[this.getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityId.idType)] = managedIdentityId.id;
12367
+ request.queryParameters[this.getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityId.idType, false, // isIMDS
12368
+ true // uses2017API
12369
+ )] = managedIdentityId.id;
12206
12370
  }
12207
12371
  // bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
12208
12372
  return request;