@azure/msal-node 3.4.1 → 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 (119) 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.mjs +1 -1
  31. package/dist/config/ManagedIdentityId.mjs +1 -1
  32. package/dist/config/ManagedIdentityRequestParameters.d.ts.map +1 -1
  33. package/dist/config/ManagedIdentityRequestParameters.mjs +4 -5
  34. package/dist/config/ManagedIdentityRequestParameters.mjs.map +1 -1
  35. package/dist/crypto/CryptoProvider.mjs +1 -1
  36. package/dist/crypto/GuidGenerator.mjs +1 -1
  37. package/dist/crypto/HashUtils.mjs +1 -1
  38. package/dist/crypto/PkceGenerator.mjs +1 -1
  39. package/dist/error/ManagedIdentityError.mjs +1 -1
  40. package/dist/error/ManagedIdentityErrorCodes.mjs +1 -1
  41. package/dist/error/NodeAuthError.mjs +1 -1
  42. package/dist/index.mjs +1 -1
  43. package/dist/internals.mjs +1 -1
  44. package/dist/network/HttpClient.mjs +1 -1
  45. package/dist/network/HttpClientWithRetries.d.ts +3 -2
  46. package/dist/network/HttpClientWithRetries.d.ts.map +1 -1
  47. package/dist/network/HttpClientWithRetries.mjs +7 -3
  48. package/dist/network/HttpClientWithRetries.mjs.map +1 -1
  49. package/dist/network/LoopbackClient.mjs +1 -1
  50. package/dist/packageMetadata.d.ts +1 -1
  51. package/dist/packageMetadata.mjs +2 -2
  52. package/dist/protocol/Authorize.mjs +1 -1
  53. package/dist/retry/DefaultManagedIdentityRetryPolicy.d.ts +10 -0
  54. package/dist/retry/DefaultManagedIdentityRetryPolicy.d.ts.map +1 -0
  55. package/dist/retry/DefaultManagedIdentityRetryPolicy.mjs +49 -0
  56. package/dist/retry/DefaultManagedIdentityRetryPolicy.mjs.map +1 -0
  57. package/dist/retry/ExponentialRetryStrategy.d.ts +23 -0
  58. package/dist/retry/ExponentialRetryStrategy.d.ts.map +1 -0
  59. package/dist/retry/ExponentialRetryStrategy.mjs +40 -0
  60. package/dist/retry/ExponentialRetryStrategy.mjs.map +1 -0
  61. package/dist/retry/IHttpRetryPolicy.d.ts +12 -2
  62. package/dist/retry/IHttpRetryPolicy.d.ts.map +1 -1
  63. package/dist/retry/ImdsRetryPolicy.d.ts +22 -0
  64. package/dist/retry/ImdsRetryPolicy.d.ts.map +1 -0
  65. package/dist/retry/ImdsRetryPolicy.mjs +90 -0
  66. package/dist/retry/ImdsRetryPolicy.mjs.map +1 -0
  67. package/dist/retry/LinearRetryStrategy.d.ts +14 -0
  68. package/dist/retry/LinearRetryStrategy.d.ts.map +1 -0
  69. package/dist/retry/LinearRetryStrategy.mjs +36 -0
  70. package/dist/retry/LinearRetryStrategy.mjs.map +1 -0
  71. package/dist/utils/Constants.d.ts +4 -9
  72. package/dist/utils/Constants.d.ts.map +1 -1
  73. package/dist/utils/Constants.mjs +3 -13
  74. package/dist/utils/Constants.mjs.map +1 -1
  75. package/dist/utils/EncodingUtils.mjs +1 -1
  76. package/dist/utils/NetworkUtils.mjs +1 -1
  77. package/dist/utils/TimeUtils.mjs +1 -1
  78. package/lib/msal-node.cjs +254 -99
  79. package/lib/msal-node.cjs.map +1 -1
  80. package/lib/types/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +2 -1
  81. package/lib/types/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
  82. package/lib/types/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
  83. package/lib/types/client/ManagedIdentitySources/MachineLearning.d.ts.map +1 -1
  84. package/lib/types/config/ManagedIdentityRequestParameters.d.ts.map +1 -1
  85. package/lib/types/network/HttpClientWithRetries.d.ts +3 -2
  86. package/lib/types/network/HttpClientWithRetries.d.ts.map +1 -1
  87. package/lib/types/packageMetadata.d.ts +1 -1
  88. package/lib/types/retry/DefaultManagedIdentityRetryPolicy.d.ts +10 -0
  89. package/lib/types/retry/DefaultManagedIdentityRetryPolicy.d.ts.map +1 -0
  90. package/lib/types/retry/ExponentialRetryStrategy.d.ts +23 -0
  91. package/lib/types/retry/ExponentialRetryStrategy.d.ts.map +1 -0
  92. package/lib/types/retry/IHttpRetryPolicy.d.ts +12 -2
  93. package/lib/types/retry/IHttpRetryPolicy.d.ts.map +1 -1
  94. package/lib/types/retry/ImdsRetryPolicy.d.ts +22 -0
  95. package/lib/types/retry/ImdsRetryPolicy.d.ts.map +1 -0
  96. package/lib/types/retry/LinearRetryStrategy.d.ts +14 -0
  97. package/lib/types/retry/LinearRetryStrategy.d.ts.map +1 -0
  98. package/lib/types/utils/Constants.d.ts +4 -9
  99. package/lib/types/utils/Constants.d.ts.map +1 -1
  100. package/package.json +2 -2
  101. package/src/client/ManagedIdentitySources/BaseManagedIdentitySource.ts +14 -6
  102. package/src/client/ManagedIdentitySources/Imds.ts +3 -0
  103. package/src/client/ManagedIdentitySources/MachineLearning.ts +3 -1
  104. package/src/config/ManagedIdentityRequestParameters.ts +4 -14
  105. package/src/network/HttpClientWithRetries.ts +10 -1
  106. package/src/packageMetadata.ts +1 -1
  107. package/src/retry/DefaultManagedIdentityRetryPolicy.ts +70 -0
  108. package/src/retry/ExponentialRetryStrategy.ts +53 -0
  109. package/src/retry/IHttpRetryPolicy.ts +14 -5
  110. package/src/retry/ImdsRetryPolicy.ts +121 -0
  111. package/src/retry/LinearRetryStrategy.ts +40 -0
  112. package/src/utils/Constants.ts +4 -17
  113. package/dist/retry/LinearRetryPolicy.d.ts +0 -12
  114. package/dist/retry/LinearRetryPolicy.d.ts.map +0 -1
  115. package/dist/retry/LinearRetryPolicy.mjs +0 -45
  116. package/dist/retry/LinearRetryPolicy.mjs.map +0 -1
  117. package/lib/types/retry/LinearRetryPolicy.d.ts +0 -12
  118. package/lib/types/retry/LinearRetryPolicy.d.ts.map +0 -1
  119. 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.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.4.0 2025-03-25 */
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.
@@ -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.0 2025-04-08 */
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.0 2025-04-08 */
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.0 2025-04-08 */
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.0 2025-04-08 */
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.0 2025-04-08 */
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.0 2025-04-08 */
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.0 2025-04-08 */
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.0";
1095
1097
 
1096
- /*! @azure/msal-common v15.4.0 2025-03-25 */
1098
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
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.0 2025-04-08 */
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.0 2025-04-08 */
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.0 2025-04-08 */
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.0 2025-04-08 */
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.0 2025-04-08 */
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.0 2025-04-08 */
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.0 2025-04-08 */
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.0 2025-04-08 */
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.0 2025-04-08 */
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.0 2025-04-08 */
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.0 2025-04-08 */
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.0 2025-04-08 */
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.0 2025-04-08 */
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.0 2025-04-08 */
2463
2465
 
2464
2466
  /*
2465
2467
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2517,7 +2519,7 @@ function mapToQueryString(parameters) {
2517
2519
  return queryParameterArray.join("&");
2518
2520
  }
2519
2521
 
2520
- /*! @azure/msal-common v15.4.0 2025-03-25 */
2522
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
2521
2523
 
2522
2524
  /*
2523
2525
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2681,7 +2683,7 @@ class UrlString {
2681
2683
  }
2682
2684
  }
2683
2685
 
2684
- /*! @azure/msal-common v15.4.0 2025-03-25 */
2686
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
2685
2687
 
2686
2688
  /*
2687
2689
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2821,7 +2823,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
2821
2823
  return null;
2822
2824
  }
2823
2825
 
2824
- /*! @azure/msal-common v15.4.0 2025-03-25 */
2826
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
2825
2827
  /*
2826
2828
  * Copyright (c) Microsoft Corporation. All rights reserved.
2827
2829
  * Licensed under the MIT License.
@@ -2829,7 +2831,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
2829
2831
  const cacheQuotaExceededErrorCode = "cache_quota_exceeded";
2830
2832
  const cacheUnknownErrorCode = "cache_error_unknown";
2831
2833
 
2832
- /*! @azure/msal-common v15.4.0 2025-03-25 */
2834
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
2833
2835
 
2834
2836
  /*
2835
2837
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2856,7 +2858,7 @@ class CacheError extends Error {
2856
2858
  }
2857
2859
  }
2858
2860
 
2859
- /*! @azure/msal-common v15.4.0 2025-03-25 */
2861
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
2860
2862
 
2861
2863
  /*
2862
2864
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4040,7 +4042,7 @@ class DefaultStorageClass extends CacheManager {
4040
4042
  }
4041
4043
  }
4042
4044
 
4043
- /*! @azure/msal-common v15.4.0 2025-03-25 */
4045
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
4044
4046
 
4045
4047
  /*
4046
4048
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4139,7 +4141,7 @@ function isOidcProtocolMode(config) {
4139
4141
  return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
4140
4142
  }
4141
4143
 
4142
- /*! @azure/msal-common v15.4.0 2025-03-25 */
4144
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
4143
4145
  /*
4144
4146
  * Copyright (c) Microsoft Corporation. All rights reserved.
4145
4147
  * Licensed under the MIT License.
@@ -4149,7 +4151,7 @@ const CcsCredentialType = {
4149
4151
  UPN: "UPN",
4150
4152
  };
4151
4153
 
4152
- /*! @azure/msal-common v15.4.0 2025-03-25 */
4154
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
4153
4155
  /*
4154
4156
  * Copyright (c) Microsoft Corporation. All rights reserved.
4155
4157
  * Licensed under the MIT License.
@@ -4200,7 +4202,7 @@ const BROKER_CLIENT_ID = "brk_client_id";
4200
4202
  const BROKER_REDIRECT_URI = "brk_redirect_uri";
4201
4203
  const INSTANCE_AWARE = "instance_aware";
4202
4204
 
4203
- /*! @azure/msal-common v15.4.0 2025-03-25 */
4205
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
4204
4206
 
4205
4207
  /*
4206
4208
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4586,7 +4588,7 @@ function addBrokerParameters(parameters, brokerClientId, brokerRedirectUri) {
4586
4588
  }
4587
4589
  }
4588
4590
 
4589
- /*! @azure/msal-common v15.4.0 2025-03-25 */
4591
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
4590
4592
  /*
4591
4593
  * Copyright (c) Microsoft Corporation. All rights reserved.
4592
4594
  * Licensed under the MIT License.
@@ -4598,7 +4600,7 @@ function isOpenIdConfigResponse(response) {
4598
4600
  response.hasOwnProperty("jwks_uri"));
4599
4601
  }
4600
4602
 
4601
- /*! @azure/msal-common v15.4.0 2025-03-25 */
4603
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
4602
4604
  /*
4603
4605
  * Copyright (c) Microsoft Corporation. All rights reserved.
4604
4606
  * Licensed under the MIT License.
@@ -4608,7 +4610,7 @@ function isCloudInstanceDiscoveryResponse(response) {
4608
4610
  response.hasOwnProperty("metadata"));
4609
4611
  }
4610
4612
 
4611
- /*! @azure/msal-common v15.4.0 2025-03-25 */
4613
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
4612
4614
  /*
4613
4615
  * Copyright (c) Microsoft Corporation. All rights reserved.
4614
4616
  * Licensed under the MIT License.
@@ -4618,7 +4620,7 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
4618
4620
  response.hasOwnProperty("error_description"));
4619
4621
  }
4620
4622
 
4621
- /*! @azure/msal-common v15.4.0 2025-03-25 */
4623
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
4622
4624
  /*
4623
4625
  * Copyright (c) Microsoft Corporation. All rights reserved.
4624
4626
  * Licensed under the MIT License.
@@ -4877,7 +4879,7 @@ const PerformanceEvents = {
4877
4879
  DecryptEarResponse: "decryptEarResponse",
4878
4880
  };
4879
4881
 
4880
- /*! @azure/msal-common v15.4.0 2025-03-25 */
4882
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
4881
4883
  /*
4882
4884
  * Copyright (c) Microsoft Corporation. All rights reserved.
4883
4885
  * Licensed under the MIT License.
@@ -4973,7 +4975,7 @@ const invokeAsync = (callback, eventName, logger, telemetryClient, correlationId
4973
4975
  };
4974
4976
  };
4975
4977
 
4976
- /*! @azure/msal-common v15.4.0 2025-03-25 */
4978
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
4977
4979
 
4978
4980
  /*
4979
4981
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5082,7 +5084,7 @@ RegionDiscovery.IMDS_OPTIONS = {
5082
5084
  },
5083
5085
  };
5084
5086
 
5085
- /*! @azure/msal-common v15.4.0 2025-03-25 */
5087
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
5086
5088
 
5087
5089
  /*
5088
5090
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5921,7 +5923,7 @@ function buildStaticAuthorityOptions(authOptions) {
5921
5923
  };
5922
5924
  }
5923
5925
 
5924
- /*! @azure/msal-common v15.4.0 2025-03-25 */
5926
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
5925
5927
 
5926
5928
  /*
5927
5929
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5952,7 +5954,7 @@ async function createDiscoveredInstance(authorityUri, networkClient, cacheManage
5952
5954
  }
5953
5955
  }
5954
5956
 
5955
- /*! @azure/msal-common v15.4.0 2025-03-25 */
5957
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
5956
5958
 
5957
5959
  /*
5958
5960
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5971,7 +5973,7 @@ class ServerError extends AuthError {
5971
5973
  }
5972
5974
  }
5973
5975
 
5974
- /*! @azure/msal-common v15.4.0 2025-03-25 */
5976
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
5975
5977
  /*
5976
5978
  * Copyright (c) Microsoft Corporation. All rights reserved.
5977
5979
  * Licensed under the MIT License.
@@ -5992,7 +5994,7 @@ function getRequestThumbprint(clientId, request, homeAccountId) {
5992
5994
  };
5993
5995
  }
5994
5996
 
5995
- /*! @azure/msal-common v15.4.0 2025-03-25 */
5997
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
5996
5998
 
5997
5999
  /*
5998
6000
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6079,7 +6081,7 @@ class ThrottlingUtils {
6079
6081
  }
6080
6082
  }
6081
6083
 
6082
- /*! @azure/msal-common v15.4.0 2025-03-25 */
6084
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
6083
6085
 
6084
6086
  /*
6085
6087
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6099,7 +6101,7 @@ class NetworkError extends AuthError {
6099
6101
  }
6100
6102
  }
6101
6103
 
6102
- /*! @azure/msal-common v15.4.0 2025-03-25 */
6104
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
6103
6105
 
6104
6106
  /*
6105
6107
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6247,7 +6249,7 @@ class BaseClient {
6247
6249
  }
6248
6250
  }
6249
6251
 
6250
- /*! @azure/msal-common v15.4.0 2025-03-25 */
6252
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
6251
6253
  /*
6252
6254
  * Copyright (c) Microsoft Corporation. All rights reserved.
6253
6255
  * Licensed under the MIT License.
@@ -6273,7 +6275,7 @@ var InteractionRequiredAuthErrorCodes = /*#__PURE__*/Object.freeze({
6273
6275
  refreshTokenExpired: refreshTokenExpired
6274
6276
  });
6275
6277
 
6276
- /*! @azure/msal-common v15.4.0 2025-03-25 */
6278
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
6277
6279
 
6278
6280
  /*
6279
6281
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6361,7 +6363,7 @@ function createInteractionRequiredAuthError(errorCode) {
6361
6363
  return new InteractionRequiredAuthError(errorCode, InteractionRequiredAuthErrorMessages[errorCode]);
6362
6364
  }
6363
6365
 
6364
- /*! @azure/msal-common v15.4.0 2025-03-25 */
6366
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
6365
6367
 
6366
6368
  /*
6367
6369
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6433,7 +6435,7 @@ class ProtocolUtils {
6433
6435
  }
6434
6436
  }
6435
6437
 
6436
- /*! @azure/msal-common v15.4.0 2025-03-25 */
6438
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
6437
6439
 
6438
6440
  /*
6439
6441
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6517,7 +6519,7 @@ class PopTokenGenerator {
6517
6519
  }
6518
6520
  }
6519
6521
 
6520
- /*! @azure/msal-common v15.4.0 2025-03-25 */
6522
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
6521
6523
  /*
6522
6524
  * Copyright (c) Microsoft Corporation. All rights reserved.
6523
6525
  * Licensed under the MIT License.
@@ -6544,7 +6546,7 @@ class PopTokenGenerator {
6544
6546
  }
6545
6547
  }
6546
6548
 
6547
- /*! @azure/msal-common v15.4.0 2025-03-25 */
6549
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
6548
6550
 
6549
6551
  /*
6550
6552
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6875,7 +6877,7 @@ function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decod
6875
6877
  return baseAccount;
6876
6878
  }
6877
6879
 
6878
- /*! @azure/msal-common v15.4.0 2025-03-25 */
6880
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
6879
6881
 
6880
6882
  /*
6881
6883
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6942,7 +6944,7 @@ class RequestValidator {
6942
6944
  }
6943
6945
  }
6944
6946
 
6945
- /*! @azure/msal-common v15.4.0 2025-03-25 */
6947
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
6946
6948
  /*
6947
6949
  * Copyright (c) Microsoft Corporation. All rights reserved.
6948
6950
  * Licensed under the MIT License.
@@ -6960,7 +6962,7 @@ async function getClientAssertion(clientAssertion, clientId, tokenEndpoint) {
6960
6962
  }
6961
6963
  }
6962
6964
 
6963
- /*! @azure/msal-common v15.4.0 2025-03-25 */
6965
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
6964
6966
 
6965
6967
  /*
6966
6968
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7193,7 +7195,7 @@ class AuthorizationCodeClient extends BaseClient {
7193
7195
  }
7194
7196
  }
7195
7197
 
7196
- /*! @azure/msal-common v15.4.0 2025-03-25 */
7198
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
7197
7199
 
7198
7200
  /*
7199
7201
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7402,7 +7404,7 @@ class RefreshTokenClient extends BaseClient {
7402
7404
  }
7403
7405
  }
7404
7406
 
7405
- /*! @azure/msal-common v15.4.0 2025-03-25 */
7407
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
7406
7408
 
7407
7409
  /*
7408
7410
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7500,7 +7502,7 @@ class SilentFlowClient extends BaseClient {
7500
7502
  }
7501
7503
  }
7502
7504
 
7503
- /*! @azure/msal-common v15.4.0 2025-03-25 */
7505
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
7504
7506
 
7505
7507
  /*
7506
7508
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7650,7 +7652,7 @@ function extractLoginHint(account) {
7650
7652
  return account.idTokenClaims?.login_hint || null;
7651
7653
  }
7652
7654
 
7653
- /*! @azure/msal-common v15.4.0 2025-03-25 */
7655
+ /*! @azure/msal-common v15.5.0 2025-04-08 */
7654
7656
 
7655
7657
  /*
7656
7658
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8225,17 +8227,7 @@ const LOOPBACK_SERVER_CONSTANTS = {
8225
8227
  INTERVAL_MS: 100,
8226
8228
  TIMEOUT_MS: 5000,
8227
8229
  };
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
- ];
8230
+ const AZURE_ARC_SECRET_FILE_MAX_SIZE_BYTES = 4096; // 4 KB
8239
8231
 
8240
8232
  /*
8241
8233
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -9943,7 +9935,7 @@ class ClientAssertion {
9943
9935
 
9944
9936
  /* eslint-disable header/header */
9945
9937
  const name = "@azure/msal-node";
9946
- const version = "3.4.1";
9938
+ const version = "3.5.0";
9947
9939
 
9948
9940
  /*
9949
9941
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -11586,9 +11578,10 @@ function isIso8601(dateString) {
11586
11578
  * Licensed under the MIT License.
11587
11579
  */
11588
11580
  class HttpClientWithRetries {
11589
- constructor(httpClientNoRetries, retryPolicy) {
11581
+ constructor(httpClientNoRetries, retryPolicy, logger) {
11590
11582
  this.httpClientNoRetries = httpClientNoRetries;
11591
11583
  this.retryPolicy = retryPolicy;
11584
+ this.logger = logger;
11592
11585
  }
11593
11586
  async sendNetworkRequestAsyncHelper(httpMethod, url, options) {
11594
11587
  if (httpMethod === HttpMethod.GET) {
@@ -11601,8 +11594,11 @@ class HttpClientWithRetries {
11601
11594
  async sendNetworkRequestAsync(httpMethod, url, options) {
11602
11595
  // the underlying network module (custom or HttpClient) will make the call
11603
11596
  let response = await this.sendNetworkRequestAsyncHelper(httpMethod, url, options);
11597
+ if ("isNewRequest" in this.retryPolicy) {
11598
+ this.retryPolicy.isNewRequest = true;
11599
+ }
11604
11600
  let currentRetry = 0;
11605
- 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])) {
11606
11602
  response = await this.sendNetworkRequestAsyncHelper(httpMethod, url, options);
11607
11603
  currentRetry++;
11608
11604
  }
@@ -11624,6 +11620,7 @@ class HttpClientWithRetries {
11624
11620
  * Managed Identity User Assigned Id Query Parameter Names
11625
11621
  */
11626
11622
  const ManagedIdentityUserAssignedIdQueryParameterNames = {
11623
+ MANAGED_IDENTITY_CLIENT_ID_2017: "clientid",
11627
11624
  MANAGED_IDENTITY_CLIENT_ID: "client_id",
11628
11625
  MANAGED_IDENTITY_OBJECT_ID: "object_id",
11629
11626
  MANAGED_IDENTITY_RESOURCE_ID_IMDS: "msi_res_id",
@@ -11699,7 +11696,7 @@ class BaseManagedIdentitySource {
11699
11696
  */
11700
11697
  const networkClientHelper = this.disableInternalRetries
11701
11698
  ? this.networkClient
11702
- : new HttpClientWithRetries(this.networkClient, networkRequest.retryPolicy);
11699
+ : new HttpClientWithRetries(this.networkClient, networkRequest.retryPolicy, this.logger);
11703
11700
  const reqTimestamp = nowSeconds();
11704
11701
  let response;
11705
11702
  try {
@@ -11728,14 +11725,17 @@ class BaseManagedIdentitySource {
11728
11725
  // caches the token
11729
11726
  return responseHandler.handleServerTokenResponse(serverTokenResponse, fakeAuthority, reqTimestamp, managedIdentityRequest);
11730
11727
  }
11731
- getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityIdType, imds) {
11728
+ getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityIdType, isImds, usesApi2017) {
11732
11729
  switch (managedIdentityIdType) {
11733
11730
  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;
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;
11736
11736
  case ManagedIdentityIdType.USER_ASSIGNED_RESOURCE_ID:
11737
11737
  this.logger.info("[Managed Identity] Adding user assigned resource id to the request.");
11738
- return imds
11738
+ return isImds
11739
11739
  ? ManagedIdentityUserAssignedIdQueryParameterNames.MANAGED_IDENTITY_RESOURCE_ID_IMDS
11740
11740
  : ManagedIdentityUserAssignedIdQueryParameterNames.MANAGED_IDENTITY_RESOURCE_ID_NON_IMDS;
11741
11741
  case ManagedIdentityIdType.USER_ASSIGNED_OBJECT_ID:
@@ -11760,15 +11760,18 @@ BaseManagedIdentitySource.getValidatedEnvVariableUrlString = (envVariableStringN
11760
11760
  * Copyright (c) Microsoft Corporation. All rights reserved.
11761
11761
  * Licensed under the MIT License.
11762
11762
  */
11763
- class LinearRetryPolicy {
11764
- constructor(maxRetries, retryDelay, httpStatusCodesToRetryOn) {
11765
- this.maxRetries = maxRetries;
11766
- this.retryDelay = retryDelay;
11767
- this.httpStatusCodesToRetryOn = httpStatusCodesToRetryOn;
11768
- }
11769
- 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) {
11770
11773
  if (!retryHeader) {
11771
- return 0;
11774
+ return minimumDelay;
11772
11775
  }
11773
11776
  // retry-after header is in seconds
11774
11777
  let millisToSleep = Math.round(parseFloat(retryHeader) * 1000);
@@ -11777,22 +11780,52 @@ class LinearRetryPolicy {
11777
11780
  * <day-name>, <day> <month> <year> <hour>:<minute>:<second> GMT
11778
11781
  */
11779
11782
  if (isNaN(millisToSleep)) {
11780
- millisToSleep = Math.max(0,
11781
11783
  // .valueOf() is needed to subtract dates in TypeScript
11782
- new Date(retryHeader).valueOf() - new Date().valueOf());
11784
+ millisToSleep =
11785
+ new Date(retryHeader).valueOf() - new Date().valueOf();
11783
11786
  }
11784
- return millisToSleep;
11787
+ return Math.max(minimumDelay, millisToSleep);
11785
11788
  }
11786
- async pauseForRetry(httpStatusCode, currentRetry, retryAfterHeader) {
11787
- if (this.httpStatusCodesToRetryOn.includes(httpStatusCode) &&
11788
- currentRetry < this.maxRetries) {
11789
- 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
11790
11822
  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);
11823
+ // retryAfterHeader value of 0 evaluates to false, and DEFAULT_MANAGED_IDENTITY_RETRY_DELAY_MS will be used
11824
+ return setTimeout(resolve, retryAfterDelay);
11793
11825
  });
11794
11826
  return true;
11795
11827
  }
11828
+ // if the status code is not retriable or max retries have been reached, do not retry
11796
11829
  return false;
11797
11830
  }
11798
11831
  }
@@ -11808,8 +11841,8 @@ class ManagedIdentityRequestParameters {
11808
11841
  this.headers = {};
11809
11842
  this.bodyParameters = {};
11810
11843
  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;
11844
+ this.retryPolicy =
11845
+ retryPolicy || new DefaultManagedIdentityRetryPolicy();
11813
11846
  }
11814
11847
  computeUri() {
11815
11848
  const parameters = new Map();
@@ -12067,6 +12100,125 @@ class CloudShell extends BaseManagedIdentitySource {
12067
12100
  }
12068
12101
  }
12069
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
+
12070
12222
  /*
12071
12223
  * Copyright (c) Microsoft Corporation. All rights reserved.
12072
12224
  * Licensed under the MIT License.
@@ -12108,6 +12260,7 @@ class Imds extends BaseManagedIdentitySource {
12108
12260
  )] = managedIdentityId.id;
12109
12261
  }
12110
12262
  // bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
12263
+ request.retryPolicy = new ImdsRetryPolicy();
12111
12264
  return request;
12112
12265
  }
12113
12266
  }
@@ -12202,7 +12355,9 @@ class MachineLearning extends BaseManagedIdentitySource {
12202
12355
  request.queryParameters[RESOURCE_BODY_OR_QUERY_PARAMETER_NAME] =
12203
12356
  resource;
12204
12357
  if (managedIdentityId.idType !== ManagedIdentityIdType.SYSTEM_ASSIGNED) {
12205
- request.queryParameters[this.getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityId.idType)] = managedIdentityId.id;
12358
+ request.queryParameters[this.getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityId.idType, false, // isIMDS
12359
+ true // uses2017API
12360
+ )] = managedIdentityId.id;
12206
12361
  }
12207
12362
  // bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
12208
12363
  return request;