@azure/msal-node 3.0.1 → 3.2.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 (96) hide show
  1. package/dist/cache/NodeStorage.mjs +1 -1
  2. package/dist/cache/TokenCache.d.ts +9 -1
  3. package/dist/cache/TokenCache.d.ts.map +1 -1
  4. package/dist/cache/TokenCache.mjs +25 -1
  5. package/dist/cache/TokenCache.mjs.map +1 -1
  6. package/dist/cache/distributed/DistributedCachePlugin.mjs +1 -1
  7. package/dist/cache/serializer/Deserializer.mjs +1 -1
  8. package/dist/cache/serializer/Serializer.mjs +1 -1
  9. package/dist/client/ClientApplication.d.ts +1 -0
  10. package/dist/client/ClientApplication.d.ts.map +1 -1
  11. package/dist/client/ClientApplication.mjs +44 -10
  12. package/dist/client/ClientApplication.mjs.map +1 -1
  13. package/dist/client/ClientAssertion.mjs +1 -1
  14. package/dist/client/ClientCredentialClient.mjs +1 -1
  15. package/dist/client/ConfidentialClientApplication.d.ts +0 -1
  16. package/dist/client/ConfidentialClientApplication.d.ts.map +1 -1
  17. package/dist/client/ConfidentialClientApplication.mjs +40 -43
  18. package/dist/client/ConfidentialClientApplication.mjs.map +1 -1
  19. package/dist/client/DeviceCodeClient.mjs +1 -1
  20. package/dist/client/ManagedIdentityApplication.mjs +1 -1
  21. package/dist/client/ManagedIdentityClient.d.ts.map +1 -1
  22. package/dist/client/ManagedIdentityClient.mjs +10 -6
  23. package/dist/client/ManagedIdentityClient.mjs.map +1 -1
  24. package/dist/client/ManagedIdentitySources/AppService.mjs +1 -1
  25. package/dist/client/ManagedIdentitySources/AzureArc.mjs +1 -1
  26. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +3 -2
  27. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
  28. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +7 -4
  29. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs.map +1 -1
  30. package/dist/client/ManagedIdentitySources/CloudShell.mjs +1 -1
  31. package/dist/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
  32. package/dist/client/ManagedIdentitySources/Imds.mjs +3 -2
  33. package/dist/client/ManagedIdentitySources/Imds.mjs.map +1 -1
  34. package/dist/client/ManagedIdentitySources/MachineLearning.d.ts +15 -0
  35. package/dist/client/ManagedIdentitySources/MachineLearning.d.ts.map +1 -0
  36. package/dist/client/ManagedIdentitySources/MachineLearning.mjs +51 -0
  37. package/dist/client/ManagedIdentitySources/MachineLearning.mjs.map +1 -0
  38. package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts.map +1 -1
  39. package/dist/client/ManagedIdentitySources/ServiceFabric.mjs +3 -4
  40. package/dist/client/ManagedIdentitySources/ServiceFabric.mjs.map +1 -1
  41. package/dist/client/OnBehalfOfClient.mjs +1 -1
  42. package/dist/client/PublicClientApplication.mjs +1 -1
  43. package/dist/client/UsernamePasswordClient.mjs +1 -1
  44. package/dist/config/Configuration.mjs +1 -1
  45. package/dist/config/ManagedIdentityId.mjs +1 -1
  46. package/dist/config/ManagedIdentityRequestParameters.mjs +1 -1
  47. package/dist/crypto/CryptoProvider.mjs +1 -1
  48. package/dist/crypto/GuidGenerator.mjs +1 -1
  49. package/dist/crypto/HashUtils.mjs +1 -1
  50. package/dist/crypto/PkceGenerator.mjs +1 -1
  51. package/dist/error/ManagedIdentityError.mjs +1 -1
  52. package/dist/error/ManagedIdentityErrorCodes.mjs +1 -1
  53. package/dist/error/NodeAuthError.mjs +1 -1
  54. package/dist/index.mjs +1 -1
  55. package/dist/internals.mjs +1 -1
  56. package/dist/network/HttpClient.mjs +1 -1
  57. package/dist/network/HttpClientWithRetries.mjs +1 -1
  58. package/dist/network/LoopbackClient.mjs +1 -1
  59. package/dist/packageMetadata.d.ts +1 -1
  60. package/dist/packageMetadata.mjs +2 -2
  61. package/dist/retry/LinearRetryPolicy.mjs +1 -1
  62. package/dist/utils/Constants.d.ts +3 -1
  63. package/dist/utils/Constants.d.ts.map +1 -1
  64. package/dist/utils/Constants.mjs +5 -3
  65. package/dist/utils/Constants.mjs.map +1 -1
  66. package/dist/utils/EncodingUtils.mjs +1 -1
  67. package/dist/utils/NetworkUtils.mjs +1 -1
  68. package/lib/msal-node.cjs +246 -177
  69. package/lib/msal-node.cjs.map +1 -1
  70. package/lib/types/cache/TokenCache.d.ts +9 -1
  71. package/lib/types/cache/TokenCache.d.ts.map +1 -1
  72. package/lib/types/client/ClientApplication.d.ts +1 -0
  73. package/lib/types/client/ClientApplication.d.ts.map +1 -1
  74. package/lib/types/client/ConfidentialClientApplication.d.ts +0 -1
  75. package/lib/types/client/ConfidentialClientApplication.d.ts.map +1 -1
  76. package/lib/types/client/ManagedIdentityClient.d.ts.map +1 -1
  77. package/lib/types/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +3 -2
  78. package/lib/types/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
  79. package/lib/types/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
  80. package/lib/types/client/ManagedIdentitySources/MachineLearning.d.ts +15 -0
  81. package/lib/types/client/ManagedIdentitySources/MachineLearning.d.ts.map +1 -0
  82. package/lib/types/client/ManagedIdentitySources/ServiceFabric.d.ts.map +1 -1
  83. package/lib/types/packageMetadata.d.ts +1 -1
  84. package/lib/types/utils/Constants.d.ts +3 -1
  85. package/lib/types/utils/Constants.d.ts.map +1 -1
  86. package/package.json +2 -2
  87. package/src/cache/TokenCache.ts +30 -1
  88. package/src/client/ClientApplication.ts +69 -11
  89. package/src/client/ConfidentialClientApplication.ts +57 -60
  90. package/src/client/ManagedIdentityClient.ts +11 -0
  91. package/src/client/ManagedIdentitySources/BaseManagedIdentitySource.ts +7 -3
  92. package/src/client/ManagedIdentitySources/Imds.ts +2 -1
  93. package/src/client/ManagedIdentitySources/MachineLearning.ts +123 -0
  94. package/src/client/ManagedIdentitySources/ServiceFabric.ts +2 -3
  95. package/src/packageMetadata.ts +1 -1
  96. package/src/utils/Constants.ts +3 -1
package/lib/msal-node.cjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-node v3.0.1 2025-01-15 */
1
+ /*! @azure/msal-node v3.2.0 2025-02-03 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
@@ -152,7 +152,7 @@ class Serializer {
152
152
  }
153
153
  }
154
154
 
155
- /*! @azure/msal-common v15.0.1 2025-01-15 */
155
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
156
156
  /*
157
157
  * Copyright (c) Microsoft Corporation. All rights reserved.
158
158
  * Licensed under the MIT License.
@@ -445,7 +445,7 @@ const CacheOutcome = {
445
445
  // Token renewal offset default in seconds
446
446
  const DEFAULT_TOKEN_RENEWAL_OFFSET_SEC = 300;
447
447
 
448
- /*! @azure/msal-common v15.0.1 2025-01-15 */
448
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
449
449
  /*
450
450
  * Copyright (c) Microsoft Corporation. All rights reserved.
451
451
  * Licensed under the MIT License.
@@ -462,7 +462,7 @@ var AuthErrorCodes = /*#__PURE__*/Object.freeze({
462
462
  unexpectedError: unexpectedError
463
463
  });
464
464
 
465
- /*! @azure/msal-common v15.0.1 2025-01-15 */
465
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
466
466
 
467
467
  /*
468
468
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -511,7 +511,7 @@ function createAuthError(code, additionalMessage) {
511
511
  : AuthErrorMessages[code]);
512
512
  }
513
513
 
514
- /*! @azure/msal-common v15.0.1 2025-01-15 */
514
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
515
515
  /*
516
516
  * Copyright (c) Microsoft Corporation. All rights reserved.
517
517
  * Licensed under the MIT License.
@@ -609,7 +609,7 @@ var ClientAuthErrorCodes = /*#__PURE__*/Object.freeze({
609
609
  userTimeoutReached: userTimeoutReached
610
610
  });
611
611
 
612
- /*! @azure/msal-common v15.0.1 2025-01-15 */
612
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
613
613
 
614
614
  /*
615
615
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -861,7 +861,7 @@ function createClientAuthError(errorCode, additionalMessage) {
861
861
  return new ClientAuthError(errorCode, additionalMessage);
862
862
  }
863
863
 
864
- /*! @azure/msal-common v15.0.1 2025-01-15 */
864
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
865
865
 
866
866
  /*
867
867
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -900,7 +900,7 @@ const DEFAULT_CRYPTO_IMPLEMENTATION = {
900
900
  },
901
901
  };
902
902
 
903
- /*! @azure/msal-common v15.0.1 2025-01-15 */
903
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
904
904
 
905
905
  /*
906
906
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1091,12 +1091,12 @@ class Logger {
1091
1091
  }
1092
1092
  }
1093
1093
 
1094
- /*! @azure/msal-common v15.0.1 2025-01-15 */
1094
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
1095
1095
  /* eslint-disable header/header */
1096
1096
  const name$1 = "@azure/msal-common";
1097
- const version$1 = "15.0.1";
1097
+ const version$1 = "15.1.0";
1098
1098
 
1099
- /*! @azure/msal-common v15.0.1 2025-01-15 */
1099
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
1100
1100
  /*
1101
1101
  * Copyright (c) Microsoft Corporation. All rights reserved.
1102
1102
  * Licensed under the MIT License.
@@ -1116,7 +1116,7 @@ const AzureCloudInstance = {
1116
1116
  AzureUsGovernment: "https://login.microsoftonline.us",
1117
1117
  };
1118
1118
 
1119
- /*! @azure/msal-common v15.0.1 2025-01-15 */
1119
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
1120
1120
 
1121
1121
  /*
1122
1122
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1177,7 +1177,7 @@ function checkMaxAge(authTime, maxAge) {
1177
1177
  }
1178
1178
  }
1179
1179
 
1180
- /*! @azure/msal-common v15.0.1 2025-01-15 */
1180
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
1181
1181
  /*
1182
1182
  * Copyright (c) Microsoft Corporation. All rights reserved.
1183
1183
  * Licensed under the MIT License.
@@ -1222,7 +1222,7 @@ function delay(t, value) {
1222
1222
  return new Promise((resolve) => setTimeout(() => resolve(value), t));
1223
1223
  }
1224
1224
 
1225
- /*! @azure/msal-common v15.0.1 2025-01-15 */
1225
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
1226
1226
 
1227
1227
  /*
1228
1228
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1549,7 +1549,7 @@ function isAuthorityMetadataExpired(metadata) {
1549
1549
  return metadata.expiresAt <= nowSeconds();
1550
1550
  }
1551
1551
 
1552
- /*! @azure/msal-common v15.0.1 2025-01-15 */
1552
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
1553
1553
  /*
1554
1554
  * Copyright (c) Microsoft Corporation. All rights reserved.
1555
1555
  * Licensed under the MIT License.
@@ -1603,7 +1603,7 @@ var ClientConfigurationErrorCodes = /*#__PURE__*/Object.freeze({
1603
1603
  urlParseError: urlParseError
1604
1604
  });
1605
1605
 
1606
- /*! @azure/msal-common v15.0.1 2025-01-15 */
1606
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
1607
1607
 
1608
1608
  /*
1609
1609
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1741,7 +1741,7 @@ function createClientConfigurationError(errorCode) {
1741
1741
  return new ClientConfigurationError(errorCode);
1742
1742
  }
1743
1743
 
1744
- /*! @azure/msal-common v15.0.1 2025-01-15 */
1744
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
1745
1745
  /*
1746
1746
  * Copyright (c) Microsoft Corporation. All rights reserved.
1747
1747
  * Licensed under the MIT License.
@@ -1838,7 +1838,7 @@ class StringUtils {
1838
1838
  }
1839
1839
  }
1840
1840
 
1841
- /*! @azure/msal-common v15.0.1 2025-01-15 */
1841
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
1842
1842
 
1843
1843
  /*
1844
1844
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1858,8 +1858,10 @@ class ScopeSet {
1858
1858
  const filteredInput = scopeArr
1859
1859
  ? StringUtils.removeEmptyStringsFromArray(scopeArr)
1860
1860
  : [];
1861
- // Validate and filter scopes (validate function throws if validation fails)
1862
- this.validateInputScopes(filteredInput);
1861
+ // Check if scopes array has at least one member
1862
+ if (!filteredInput || !filteredInput.length) {
1863
+ throw createClientConfigurationError(emptyInputScopesError);
1864
+ }
1863
1865
  this.scopes = new Set(); // Iterator in constructor not supported by IE11
1864
1866
  filteredInput.forEach((scope) => this.scopes.add(scope));
1865
1867
  }
@@ -1889,17 +1891,6 @@ class ScopeSet {
1889
1891
  }
1890
1892
  return scopeSet;
1891
1893
  }
1892
- /**
1893
- * Used to validate the scopes input parameter requested by the developer.
1894
- * @param {Array<string>} inputScopes - Developer requested permissions. Not all scopes are guaranteed to be included in the access token returned.
1895
- * @param {boolean} scopesRequired - Boolean indicating whether the scopes array is required or not
1896
- */
1897
- validateInputScopes(inputScopes) {
1898
- // Check if scopes are required but not given or is an empty array
1899
- if (!inputScopes || inputScopes.length < 1) {
1900
- throw createClientConfigurationError(emptyInputScopesError);
1901
- }
1902
- }
1903
1894
  /**
1904
1895
  * Check if a given scope is present in this set of scopes.
1905
1896
  * @param scope
@@ -2038,7 +2029,7 @@ class ScopeSet {
2038
2029
  }
2039
2030
  }
2040
2031
 
2041
- /*! @azure/msal-common v15.0.1 2025-01-15 */
2032
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
2042
2033
 
2043
2034
  /*
2044
2035
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2078,7 +2069,7 @@ function buildClientInfoFromHomeAccountId(homeAccountId) {
2078
2069
  };
2079
2070
  }
2080
2071
 
2081
- /*! @azure/msal-common v15.0.1 2025-01-15 */
2072
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
2082
2073
  /*
2083
2074
  * Copyright (c) Microsoft Corporation. All rights reserved.
2084
2075
  * Licensed under the MIT License.
@@ -2157,7 +2148,7 @@ function updateAccountTenantProfileData(baseAccountInfo, tenantProfile, idTokenC
2157
2148
  return updatedAccountInfo;
2158
2149
  }
2159
2150
 
2160
- /*! @azure/msal-common v15.0.1 2025-01-15 */
2151
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
2161
2152
  /*
2162
2153
  * Copyright (c) Microsoft Corporation. All rights reserved.
2163
2154
  * Licensed under the MIT License.
@@ -2172,7 +2163,7 @@ const AuthorityType = {
2172
2163
  Ciam: 3,
2173
2164
  };
2174
2165
 
2175
- /*! @azure/msal-common v15.0.1 2025-01-15 */
2166
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
2176
2167
  /*
2177
2168
  * Copyright (c) Microsoft Corporation. All rights reserved.
2178
2169
  * Licensed under the MIT License.
@@ -2194,7 +2185,7 @@ function getTenantIdFromIdTokenClaims(idTokenClaims) {
2194
2185
  return null;
2195
2186
  }
2196
2187
 
2197
- /*! @azure/msal-common v15.0.1 2025-01-15 */
2188
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
2198
2189
  /*
2199
2190
  * Copyright (c) Microsoft Corporation. All rights reserved.
2200
2191
  * Licensed under the MIT License.
@@ -2207,7 +2198,7 @@ const ProtocolMode = {
2207
2198
  OIDC: "OIDC",
2208
2199
  };
2209
2200
 
2210
- /*! @azure/msal-common v15.0.1 2025-01-15 */
2201
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
2211
2202
 
2212
2203
  /*
2213
2204
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2450,7 +2441,7 @@ class AccountEntity {
2450
2441
  }
2451
2442
  }
2452
2443
 
2453
- /*! @azure/msal-common v15.0.1 2025-01-15 */
2444
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
2454
2445
 
2455
2446
  /*
2456
2447
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2497,7 +2488,7 @@ function getDeserializedResponse(responseString) {
2497
2488
  return null;
2498
2489
  }
2499
2490
 
2500
- /*! @azure/msal-common v15.0.1 2025-01-15 */
2491
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
2501
2492
 
2502
2493
  /*
2503
2494
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2661,7 +2652,7 @@ class UrlString {
2661
2652
  }
2662
2653
  }
2663
2654
 
2664
- /*! @azure/msal-common v15.0.1 2025-01-15 */
2655
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
2665
2656
 
2666
2657
  /*
2667
2658
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2801,7 +2792,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
2801
2792
  return null;
2802
2793
  }
2803
2794
 
2804
- /*! @azure/msal-common v15.0.1 2025-01-15 */
2795
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
2805
2796
  /*
2806
2797
  * Copyright (c) Microsoft Corporation. All rights reserved.
2807
2798
  * Licensed under the MIT License.
@@ -2809,7 +2800,7 @@ function getCloudDiscoveryMetadataFromNetworkResponse(response, authorityHost) {
2809
2800
  const cacheQuotaExceededErrorCode = "cache_quota_exceeded";
2810
2801
  const cacheUnknownErrorCode = "cache_error_unknown";
2811
2802
 
2812
- /*! @azure/msal-common v15.0.1 2025-01-15 */
2803
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
2813
2804
 
2814
2805
  /*
2815
2806
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -2836,7 +2827,7 @@ class CacheError extends Error {
2836
2827
  }
2837
2828
  }
2838
2829
 
2839
- /*! @azure/msal-common v15.0.1 2025-01-15 */
2830
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
2840
2831
 
2841
2832
  /*
2842
2833
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4020,7 +4011,7 @@ class DefaultStorageClass extends CacheManager {
4020
4011
  }
4021
4012
  }
4022
4013
 
4023
- /*! @azure/msal-common v15.0.1 2025-01-15 */
4014
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
4024
4015
 
4025
4016
  /*
4026
4017
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4119,7 +4110,7 @@ function isOidcProtocolMode(config) {
4119
4110
  return (config.authOptions.authority.options.protocolMode === ProtocolMode.OIDC);
4120
4111
  }
4121
4112
 
4122
- /*! @azure/msal-common v15.0.1 2025-01-15 */
4113
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
4123
4114
  /*
4124
4115
  * Copyright (c) Microsoft Corporation. All rights reserved.
4125
4116
  * Licensed under the MIT License.
@@ -4129,7 +4120,7 @@ const CcsCredentialType = {
4129
4120
  UPN: "UPN",
4130
4121
  };
4131
4122
 
4132
- /*! @azure/msal-common v15.0.1 2025-01-15 */
4123
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
4133
4124
  /*
4134
4125
  * Copyright (c) Microsoft Corporation. All rights reserved.
4135
4126
  * Licensed under the MIT License.
@@ -4180,7 +4171,7 @@ const X_CLIENT_EXTRA_SKU = "x-client-xtra-sku";
4180
4171
  const BROKER_CLIENT_ID = "brk_client_id";
4181
4172
  const BROKER_REDIRECT_URI = "brk_redirect_uri";
4182
4173
 
4183
- /*! @azure/msal-common v15.0.1 2025-01-15 */
4174
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
4184
4175
 
4185
4176
  /*
4186
4177
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4247,7 +4238,7 @@ class RequestValidator {
4247
4238
  }
4248
4239
  }
4249
4240
 
4250
- /*! @azure/msal-common v15.0.1 2025-01-15 */
4241
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
4251
4242
 
4252
4243
  /*
4253
4244
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -4655,7 +4646,7 @@ class RequestParameterBuilder {
4655
4646
  }
4656
4647
  }
4657
4648
 
4658
- /*! @azure/msal-common v15.0.1 2025-01-15 */
4649
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
4659
4650
  /*
4660
4651
  * Copyright (c) Microsoft Corporation. All rights reserved.
4661
4652
  * Licensed under the MIT License.
@@ -4667,7 +4658,7 @@ function isOpenIdConfigResponse(response) {
4667
4658
  response.hasOwnProperty("jwks_uri"));
4668
4659
  }
4669
4660
 
4670
- /*! @azure/msal-common v15.0.1 2025-01-15 */
4661
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
4671
4662
  /*
4672
4663
  * Copyright (c) Microsoft Corporation. All rights reserved.
4673
4664
  * Licensed under the MIT License.
@@ -4677,7 +4668,7 @@ function isCloudInstanceDiscoveryResponse(response) {
4677
4668
  response.hasOwnProperty("metadata"));
4678
4669
  }
4679
4670
 
4680
- /*! @azure/msal-common v15.0.1 2025-01-15 */
4671
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
4681
4672
  /*
4682
4673
  * Copyright (c) Microsoft Corporation. All rights reserved.
4683
4674
  * Licensed under the MIT License.
@@ -4687,7 +4678,7 @@ function isCloudInstanceDiscoveryErrorResponse(response) {
4687
4678
  response.hasOwnProperty("error_description"));
4688
4679
  }
4689
4680
 
4690
- /*! @azure/msal-common v15.0.1 2025-01-15 */
4681
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
4691
4682
  /*
4692
4683
  * Copyright (c) Microsoft Corporation. All rights reserved.
4693
4684
  * Licensed under the MIT License.
@@ -4941,7 +4932,7 @@ const PerformanceEvents = {
4941
4932
  Decrypt: "decrypt",
4942
4933
  };
4943
4934
 
4944
- /*! @azure/msal-common v15.0.1 2025-01-15 */
4935
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
4945
4936
  /*
4946
4937
  * Copyright (c) Microsoft Corporation. All rights reserved.
4947
4938
  * Licensed under the MIT License.
@@ -5037,7 +5028,7 @@ const invokeAsync = (callback, eventName, logger, telemetryClient, correlationId
5037
5028
  };
5038
5029
  };
5039
5030
 
5040
- /*! @azure/msal-common v15.0.1 2025-01-15 */
5031
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
5041
5032
 
5042
5033
  /*
5043
5034
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5146,7 +5137,7 @@ RegionDiscovery.IMDS_OPTIONS = {
5146
5137
  },
5147
5138
  };
5148
5139
 
5149
- /*! @azure/msal-common v15.0.1 2025-01-15 */
5140
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
5150
5141
 
5151
5142
  /*
5152
5143
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -5985,7 +5976,7 @@ function buildStaticAuthorityOptions(authOptions) {
5985
5976
  };
5986
5977
  }
5987
5978
 
5988
- /*! @azure/msal-common v15.0.1 2025-01-15 */
5979
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
5989
5980
 
5990
5981
  /*
5991
5982
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6016,7 +6007,7 @@ async function createDiscoveredInstance(authorityUri, networkClient, cacheManage
6016
6007
  }
6017
6008
  }
6018
6009
 
6019
- /*! @azure/msal-common v15.0.1 2025-01-15 */
6010
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
6020
6011
 
6021
6012
  /*
6022
6013
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6035,7 +6026,7 @@ class ServerError extends AuthError {
6035
6026
  }
6036
6027
  }
6037
6028
 
6038
- /*! @azure/msal-common v15.0.1 2025-01-15 */
6029
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
6039
6030
 
6040
6031
  /*
6041
6032
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6133,7 +6124,7 @@ class ThrottlingUtils {
6133
6124
  }
6134
6125
  }
6135
6126
 
6136
- /*! @azure/msal-common v15.0.1 2025-01-15 */
6127
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
6137
6128
 
6138
6129
  /*
6139
6130
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6153,7 +6144,7 @@ class NetworkError extends AuthError {
6153
6144
  }
6154
6145
  }
6155
6146
 
6156
- /*! @azure/msal-common v15.0.1 2025-01-15 */
6147
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
6157
6148
 
6158
6149
  /*
6159
6150
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6303,7 +6294,7 @@ class BaseClient {
6303
6294
  }
6304
6295
  }
6305
6296
 
6306
- /*! @azure/msal-common v15.0.1 2025-01-15 */
6297
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
6307
6298
  /*
6308
6299
  * Copyright (c) Microsoft Corporation. All rights reserved.
6309
6300
  * Licensed under the MIT License.
@@ -6329,7 +6320,7 @@ var InteractionRequiredAuthErrorCodes = /*#__PURE__*/Object.freeze({
6329
6320
  refreshTokenExpired: refreshTokenExpired
6330
6321
  });
6331
6322
 
6332
- /*! @azure/msal-common v15.0.1 2025-01-15 */
6323
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
6333
6324
 
6334
6325
  /*
6335
6326
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6417,7 +6408,7 @@ function createInteractionRequiredAuthError(errorCode) {
6417
6408
  return new InteractionRequiredAuthError(errorCode, InteractionRequiredAuthErrorMessages[errorCode]);
6418
6409
  }
6419
6410
 
6420
- /*! @azure/msal-common v15.0.1 2025-01-15 */
6411
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
6421
6412
 
6422
6413
  /*
6423
6414
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6489,7 +6480,7 @@ class ProtocolUtils {
6489
6480
  }
6490
6481
  }
6491
6482
 
6492
- /*! @azure/msal-common v15.0.1 2025-01-15 */
6483
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
6493
6484
 
6494
6485
  /*
6495
6486
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6573,7 +6564,7 @@ class PopTokenGenerator {
6573
6564
  }
6574
6565
  }
6575
6566
 
6576
- /*! @azure/msal-common v15.0.1 2025-01-15 */
6567
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
6577
6568
  /*
6578
6569
  * Copyright (c) Microsoft Corporation. All rights reserved.
6579
6570
  * Licensed under the MIT License.
@@ -6600,7 +6591,7 @@ class PopTokenGenerator {
6600
6591
  }
6601
6592
  }
6602
6593
 
6603
- /*! @azure/msal-common v15.0.1 2025-01-15 */
6594
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
6604
6595
 
6605
6596
  /*
6606
6597
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -6977,7 +6968,7 @@ function buildAccountToCache(cacheStorage, authority, homeAccountId, base64Decod
6977
6968
  return baseAccount;
6978
6969
  }
6979
6970
 
6980
- /*! @azure/msal-common v15.0.1 2025-01-15 */
6971
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
6981
6972
  /*
6982
6973
  * Copyright (c) Microsoft Corporation. All rights reserved.
6983
6974
  * Licensed under the MIT License.
@@ -6995,7 +6986,7 @@ async function getClientAssertion(clientAssertion, clientId, tokenEndpoint) {
6995
6986
  }
6996
6987
  }
6997
6988
 
6998
- /*! @azure/msal-common v15.0.1 2025-01-15 */
6989
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
6999
6990
 
7000
6991
  /*
7001
6992
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7281,7 +7272,9 @@ class AuthorizationCodeClient extends BaseClient {
7281
7272
  }
7282
7273
  if (request.domainHint) {
7283
7274
  parameterBuilder.addDomainHint(request.domainHint);
7275
+ this.performanceClient?.addFields({ domainHintFromRequest: true }, correlationId);
7284
7276
  }
7277
+ this.performanceClient?.addFields({ prompt: request.prompt }, correlationId);
7285
7278
  // Add sid or loginHint with preference for login_hint claim (in request) -> sid -> loginHint (upn/email) -> username of AccountInfo object
7286
7279
  if (request.prompt !== PromptValue.SELECT_ACCOUNT) {
7287
7280
  // AAD will throw if prompt=select_account is passed with an account hint
@@ -7289,6 +7282,7 @@ class AuthorizationCodeClient extends BaseClient {
7289
7282
  // SessionID is only used in silent calls
7290
7283
  this.logger.verbose("createAuthCodeUrlQueryString: Prompt is none, adding sid from request");
7291
7284
  parameterBuilder.addSid(request.sid);
7285
+ this.performanceClient?.addFields({ sidFromRequest: true }, correlationId);
7292
7286
  }
7293
7287
  else if (request.account) {
7294
7288
  const accountSid = this.extractAccountSid(request.account);
@@ -7301,6 +7295,7 @@ class AuthorizationCodeClient extends BaseClient {
7301
7295
  if (accountLoginHintClaim) {
7302
7296
  this.logger.verbose("createAuthCodeUrlQueryString: login_hint claim present on account");
7303
7297
  parameterBuilder.addLoginHint(accountLoginHintClaim);
7298
+ this.performanceClient?.addFields({ loginHintFromClaim: true }, correlationId);
7304
7299
  try {
7305
7300
  const clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
7306
7301
  parameterBuilder.addCcsOid(clientInfo);
@@ -7316,6 +7311,7 @@ class AuthorizationCodeClient extends BaseClient {
7316
7311
  */
7317
7312
  this.logger.verbose("createAuthCodeUrlQueryString: Prompt is none, adding sid from account");
7318
7313
  parameterBuilder.addSid(accountSid);
7314
+ this.performanceClient?.addFields({ sidFromClaim: true }, correlationId);
7319
7315
  try {
7320
7316
  const clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
7321
7317
  parameterBuilder.addCcsOid(clientInfo);
@@ -7328,11 +7324,13 @@ class AuthorizationCodeClient extends BaseClient {
7328
7324
  this.logger.verbose("createAuthCodeUrlQueryString: Adding login_hint from request");
7329
7325
  parameterBuilder.addLoginHint(request.loginHint);
7330
7326
  parameterBuilder.addCcsUpn(request.loginHint);
7327
+ this.performanceClient?.addFields({ loginHintFromRequest: true }, correlationId);
7331
7328
  }
7332
7329
  else if (request.account.username) {
7333
7330
  // Fallback to account username if provided
7334
7331
  this.logger.verbose("createAuthCodeUrlQueryString: Adding login_hint from account");
7335
7332
  parameterBuilder.addLoginHint(request.account.username);
7333
+ this.performanceClient?.addFields({ loginHintFromUpn: true }, correlationId);
7336
7334
  try {
7337
7335
  const clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
7338
7336
  parameterBuilder.addCcsOid(clientInfo);
@@ -7346,6 +7344,7 @@ class AuthorizationCodeClient extends BaseClient {
7346
7344
  this.logger.verbose("createAuthCodeUrlQueryString: No account, adding login_hint from request");
7347
7345
  parameterBuilder.addLoginHint(request.loginHint);
7348
7346
  parameterBuilder.addCcsUpn(request.loginHint);
7347
+ this.performanceClient?.addFields({ loginHintFromRequest: true }, correlationId);
7349
7348
  }
7350
7349
  }
7351
7350
  else {
@@ -7437,7 +7436,7 @@ class AuthorizationCodeClient extends BaseClient {
7437
7436
  }
7438
7437
  }
7439
7438
 
7440
- /*! @azure/msal-common v15.0.1 2025-01-15 */
7439
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
7441
7440
 
7442
7441
  /*
7443
7442
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7517,6 +7516,7 @@ class RefreshTokenClient extends BaseClient {
7517
7516
  if (refreshToken.expiresOn &&
7518
7517
  isTokenExpired(refreshToken.expiresOn, request.refreshTokenExpirationOffsetSeconds ||
7519
7518
  DEFAULT_REFRESH_TOKEN_EXPIRATION_OFFSET_SECONDS)) {
7519
+ this.performanceClient?.addFields({ rtExpiresOnMs: Number(refreshToken.expiresOn) }, request.correlationId);
7520
7520
  throw createInteractionRequiredAuthError(refreshTokenExpired);
7521
7521
  }
7522
7522
  // attach cached RT size to the current measurement
@@ -7533,12 +7533,14 @@ class RefreshTokenClient extends BaseClient {
7533
7533
  return await invokeAsync(this.acquireToken.bind(this), PerformanceEvents.RefreshTokenClientAcquireToken, this.logger, this.performanceClient, request.correlationId)(refreshTokenRequest);
7534
7534
  }
7535
7535
  catch (e) {
7536
- if (e instanceof InteractionRequiredAuthError &&
7537
- e.subError === badToken) {
7538
- // Remove bad refresh token from cache
7539
- this.logger.verbose("acquireTokenWithRefreshToken: bad refresh token, removing from cache");
7540
- const badRefreshTokenKey = generateCredentialKey(refreshToken);
7541
- this.cacheManager.removeRefreshToken(badRefreshTokenKey);
7536
+ if (e instanceof InteractionRequiredAuthError) {
7537
+ this.performanceClient?.addFields({ rtExpiresOnMs: Number(refreshToken.expiresOn) }, request.correlationId);
7538
+ if (e.subError === badToken) {
7539
+ // Remove bad refresh token from cache
7540
+ this.logger.verbose("acquireTokenWithRefreshToken: bad refresh token, removing from cache");
7541
+ const badRefreshTokenKey = generateCredentialKey(refreshToken);
7542
+ this.cacheManager.removeRefreshToken(badRefreshTokenKey);
7543
+ }
7542
7544
  }
7543
7545
  throw e;
7544
7546
  }
@@ -7657,7 +7659,7 @@ class RefreshTokenClient extends BaseClient {
7657
7659
  }
7658
7660
  }
7659
7661
 
7660
- /*! @azure/msal-common v15.0.1 2025-01-15 */
7662
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
7661
7663
 
7662
7664
  /*
7663
7665
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -7668,44 +7670,6 @@ class SilentFlowClient extends BaseClient {
7668
7670
  constructor(configuration, performanceClient) {
7669
7671
  super(configuration, performanceClient);
7670
7672
  }
7671
- /**
7672
- * Retrieves a token from cache if it is still valid, or uses the cached refresh token to renew
7673
- * the given token and returns the renewed token
7674
- * @param request
7675
- */
7676
- async acquireToken(request) {
7677
- try {
7678
- const [authResponse, cacheOutcome] = await this.acquireCachedToken({
7679
- ...request,
7680
- scopes: request.scopes?.length
7681
- ? request.scopes
7682
- : [...OIDC_DEFAULT_SCOPES],
7683
- });
7684
- // if the token is not expired but must be refreshed; get a new one in the background
7685
- if (cacheOutcome === CacheOutcome.PROACTIVELY_REFRESHED) {
7686
- this.logger.info("SilentFlowClient:acquireCachedToken - Cached access token's refreshOn property has been exceeded'. It's not expired, but must be refreshed.");
7687
- // refresh the access token in the background
7688
- const refreshTokenClient = new RefreshTokenClient(this.config, this.performanceClient);
7689
- refreshTokenClient
7690
- .acquireTokenByRefreshToken(request)
7691
- .catch(() => {
7692
- // do nothing, this is running in the background and no action is to be taken upon success or failure
7693
- });
7694
- }
7695
- // return the cached token
7696
- return authResponse;
7697
- }
7698
- catch (e) {
7699
- if (e instanceof ClientAuthError &&
7700
- e.errorCode === tokenRefreshRequired) {
7701
- const refreshTokenClient = new RefreshTokenClient(this.config, this.performanceClient);
7702
- return refreshTokenClient.acquireTokenByRefreshToken(request);
7703
- }
7704
- else {
7705
- throw e;
7706
- }
7707
- }
7708
- }
7709
7673
  /**
7710
7674
  * Retrieves token from cache or throws an error if it must be refreshed.
7711
7675
  * @param request
@@ -7793,7 +7757,7 @@ class SilentFlowClient extends BaseClient {
7793
7757
  }
7794
7758
  }
7795
7759
 
7796
- /*! @azure/msal-common v15.0.1 2025-01-15 */
7760
+ /*! @azure/msal-common v15.1.0 2025-02-03 */
7797
7761
 
7798
7762
  /*
7799
7763
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -8248,7 +8212,7 @@ var internals = /*#__PURE__*/Object.freeze({
8248
8212
  const AUTHORIZATION_HEADER_NAME = "Authorization";
8249
8213
  const METADATA_HEADER_NAME = "Metadata";
8250
8214
  const APP_SERVICE_SECRET_HEADER_NAME = "X-IDENTITY-HEADER";
8251
- const SERVICE_FABRIC_SECRET_HEADER_NAME = "secret";
8215
+ const ML_AND_SF_SECRET_HEADER_NAME = "secret";
8252
8216
  const API_VERSION_QUERY_PARAMETER_NAME = "api-version";
8253
8217
  const RESOURCE_BODY_OR_QUERY_PARAMETER_NAME = "resource";
8254
8218
  const DEFAULT_MANAGED_IDENTITY_ID = "system_assigned_managed_identity";
@@ -8264,6 +8228,7 @@ const ManagedIdentityEnvironmentVariableNames = {
8264
8228
  IDENTITY_SERVER_THUMBPRINT: "IDENTITY_SERVER_THUMBPRINT",
8265
8229
  IMDS_ENDPOINT: "IMDS_ENDPOINT",
8266
8230
  MSI_ENDPOINT: "MSI_ENDPOINT",
8231
+ MSI_SECRET: "MSI_SECRET",
8267
8232
  };
8268
8233
  /**
8269
8234
  * Managed Identity Source Names
@@ -8275,6 +8240,7 @@ const ManagedIdentitySourceNames = {
8275
8240
  CLOUD_SHELL: "CloudShell",
8276
8241
  DEFAULT_TO_IMDS: "DefaultToImds",
8277
8242
  IMDS: "Imds",
8243
+ MACHINE_LEARNING: "MachineLearning",
8278
8244
  SERVICE_FABRIC: "ServiceFabric",
8279
8245
  };
8280
8246
  /**
@@ -9799,6 +9765,13 @@ class TokenCache {
9799
9765
  getKVStore() {
9800
9766
  return this.storage.getCache();
9801
9767
  }
9768
+ /**
9769
+ * Gets cache snapshot in CacheKVStore format
9770
+ */
9771
+ getCacheSnapshot() {
9772
+ const deserializedPersistentStorage = NodeStorage.generateInMemoryCache(this.cacheSnapshot);
9773
+ return this.storage.inMemoryCacheToCache(deserializedPersistentStorage);
9774
+ }
9802
9775
  /**
9803
9776
  * API that retrieves all accounts currently in cache to the user
9804
9777
  */
@@ -9868,6 +9841,22 @@ class TokenCache {
9868
9841
  }
9869
9842
  }
9870
9843
  }
9844
+ /**
9845
+ * Overwrites in-memory cache with persistent cache
9846
+ */
9847
+ async overwriteCache() {
9848
+ if (!this.persistence) {
9849
+ this.logger.info("No persistence layer specified, cache cannot be overwritten");
9850
+ return;
9851
+ }
9852
+ this.logger.info("Overwriting in-memory cache with persistent cache");
9853
+ this.storage.clear();
9854
+ const cacheContext = new TokenCacheContext(this, false);
9855
+ await this.persistence.beforeCacheAccess(cacheContext);
9856
+ const cacheSnapshot = this.getCacheSnapshot();
9857
+ this.storage.setCache(cacheSnapshot);
9858
+ await this.persistence.afterCacheAccess(cacheContext);
9859
+ }
9871
9860
  /**
9872
9861
  * Called when the cache has changed state.
9873
9862
  */
@@ -10141,7 +10130,7 @@ class ClientAssertion {
10141
10130
 
10142
10131
  /* eslint-disable header/header */
10143
10132
  const name = "@azure/msal-node";
10144
- const version = "3.0.1";
10133
+ const version = "3.2.0";
10145
10134
 
10146
10135
  /*
10147
10136
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -10362,18 +10351,52 @@ class ClientApplication {
10362
10351
  };
10363
10352
  const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenSilent, validRequest.correlationId, validRequest.forceRefresh);
10364
10353
  try {
10365
- const silentFlowClientConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, validRequest.redirectUri || "", serverTelemetryManager, undefined, request.azureCloudOptions);
10366
- const silentFlowClient = new SilentFlowClient(silentFlowClientConfig);
10354
+ const clientConfiguration = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, validRequest.redirectUri || "", serverTelemetryManager, undefined, validRequest.azureCloudOptions);
10355
+ const silentFlowClient = new SilentFlowClient(clientConfiguration);
10367
10356
  this.logger.verbose("Silent flow client created", validRequest.correlationId);
10368
- return await silentFlowClient.acquireToken(validRequest);
10357
+ try {
10358
+ // always overwrite the in-memory cache with the persistence cache (if it exists) before a cache lookup
10359
+ await this.tokenCache.overwriteCache();
10360
+ return await this.acquireCachedTokenSilent(validRequest, silentFlowClient, clientConfiguration);
10361
+ }
10362
+ catch (error) {
10363
+ if (error instanceof ClientAuthError &&
10364
+ error.errorCode ===
10365
+ tokenRefreshRequired) {
10366
+ const refreshTokenClient = new RefreshTokenClient(clientConfiguration);
10367
+ return refreshTokenClient.acquireTokenByRefreshToken(validRequest);
10368
+ }
10369
+ throw error;
10370
+ }
10369
10371
  }
10370
- catch (e) {
10371
- if (e instanceof AuthError) {
10372
- e.setCorrelationId(validRequest.correlationId);
10372
+ catch (error) {
10373
+ if (error instanceof AuthError) {
10374
+ error.setCorrelationId(validRequest.correlationId);
10375
+ }
10376
+ serverTelemetryManager.cacheFailedRequest(error);
10377
+ throw error;
10378
+ }
10379
+ }
10380
+ async acquireCachedTokenSilent(validRequest, silentFlowClient, clientConfiguration) {
10381
+ const [authResponse, cacheOutcome] = await silentFlowClient.acquireCachedToken({
10382
+ ...validRequest,
10383
+ scopes: validRequest.scopes?.length
10384
+ ? validRequest.scopes
10385
+ : [...OIDC_DEFAULT_SCOPES],
10386
+ });
10387
+ if (cacheOutcome === CacheOutcome.PROACTIVELY_REFRESHED) {
10388
+ this.logger.info("ClientApplication:acquireCachedTokenSilent - Cached access token's refreshOn property has been exceeded'. It's not expired, but must be refreshed.");
10389
+ // refresh the access token in the background
10390
+ const refreshTokenClient = new RefreshTokenClient(clientConfiguration);
10391
+ try {
10392
+ await refreshTokenClient.acquireTokenByRefreshToken(validRequest);
10393
+ }
10394
+ catch {
10395
+ // do nothing, this is running in the background and no action is to be taken upon success or failure
10373
10396
  }
10374
- serverTelemetryManager.cacheFailedRequest(e);
10375
- throw e;
10376
10397
  }
10398
+ // return the cached token
10399
+ return authResponse;
10377
10400
  }
10378
10401
  /**
10379
10402
  * Acquires tokens with password grant by exchanging client applications username and password for credentials
@@ -11538,7 +11561,44 @@ class ConfidentialClientApplication extends ClientApplication {
11538
11561
  */
11539
11562
  constructor(configuration) {
11540
11563
  super(configuration);
11541
- this.setClientCredential();
11564
+ const clientSecretNotEmpty = !!this.config.auth.clientSecret;
11565
+ const clientAssertionNotEmpty = !!this.config.auth.clientAssertion;
11566
+ const certificateNotEmpty = (!!this.config.auth.clientCertificate?.thumbprint ||
11567
+ !!this.config.auth.clientCertificate?.thumbprintSha256) &&
11568
+ !!this.config.auth.clientCertificate?.privateKey;
11569
+ /*
11570
+ * If app developer configures this callback, they don't need a credential
11571
+ * i.e. AzureSDK can get token from Managed Identity without a cert / secret
11572
+ */
11573
+ if (this.appTokenProvider) {
11574
+ return;
11575
+ }
11576
+ // Check that at most one credential is set on the application
11577
+ if ((clientSecretNotEmpty && clientAssertionNotEmpty) ||
11578
+ (clientAssertionNotEmpty && certificateNotEmpty) ||
11579
+ (clientSecretNotEmpty && certificateNotEmpty)) {
11580
+ throw createClientAuthError(invalidClientCredential);
11581
+ }
11582
+ if (this.config.auth.clientSecret) {
11583
+ this.clientSecret = this.config.auth.clientSecret;
11584
+ return;
11585
+ }
11586
+ if (this.config.auth.clientAssertion) {
11587
+ this.developerProvidedClientAssertion =
11588
+ this.config.auth.clientAssertion;
11589
+ return;
11590
+ }
11591
+ if (!certificateNotEmpty) {
11592
+ throw createClientAuthError(invalidClientCredential);
11593
+ }
11594
+ else {
11595
+ this.clientAssertion = !!this.config.auth.clientCertificate
11596
+ .thumbprintSha256
11597
+ ? ClientAssertion.fromCertificateWithSha256Thumbprint(this.config.auth.clientCertificate.thumbprintSha256, this.config.auth.clientCertificate.privateKey, this.config.auth.clientCertificate.x5c)
11598
+ : ClientAssertion.fromCertificate(
11599
+ // guaranteed to be a string, due to prior error checking in this function
11600
+ this.config.auth.clientCertificate.thumbprint, this.config.auth.clientCertificate.privateKey, this.config.auth.clientCertificate.x5c);
11601
+ }
11542
11602
  this.appTokenProvider = undefined;
11543
11603
  }
11544
11604
  /**
@@ -11648,46 +11708,6 @@ class ConfidentialClientApplication extends ClientApplication {
11648
11708
  throw e;
11649
11709
  }
11650
11710
  }
11651
- setClientCredential() {
11652
- const clientSecretNotEmpty = !!this.config.auth.clientSecret;
11653
- const clientAssertionNotEmpty = !!this.config.auth.clientAssertion;
11654
- const certificateNotEmpty = (!!this.config.auth.clientCertificate?.thumbprint ||
11655
- !!this.config.auth.clientCertificate?.thumbprintSha256) &&
11656
- !!this.config.auth.clientCertificate?.privateKey;
11657
- /*
11658
- * If app developer configures this callback, they don't need a credential
11659
- * i.e. AzureSDK can get token from Managed Identity without a cert / secret
11660
- */
11661
- if (this.appTokenProvider) {
11662
- return;
11663
- }
11664
- // Check that at most one credential is set on the application
11665
- if ((clientSecretNotEmpty && clientAssertionNotEmpty) ||
11666
- (clientAssertionNotEmpty && certificateNotEmpty) ||
11667
- (clientSecretNotEmpty && certificateNotEmpty)) {
11668
- throw createClientAuthError(invalidClientCredential);
11669
- }
11670
- if (this.config.auth.clientSecret) {
11671
- this.clientSecret = this.config.auth.clientSecret;
11672
- return;
11673
- }
11674
- if (this.config.auth.clientAssertion) {
11675
- this.developerProvidedClientAssertion =
11676
- this.config.auth.clientAssertion;
11677
- return;
11678
- }
11679
- if (!certificateNotEmpty) {
11680
- throw createClientAuthError(invalidClientCredential);
11681
- }
11682
- else {
11683
- this.clientAssertion = !!this.config.auth.clientCertificate
11684
- .thumbprintSha256
11685
- ? ClientAssertion.fromCertificateWithSha256Thumbprint(this.config.auth.clientCertificate.thumbprintSha256, this.config.auth.clientCertificate.privateKey, this.config.auth.clientCertificate.x5c)
11686
- : ClientAssertion.fromCertificate(
11687
- // guaranteed to be a string, due to prior error checking in this function
11688
- this.config.auth.clientCertificate.thumbprint, this.config.auth.clientCertificate.privateKey, this.config.auth.clientCertificate.x5c);
11689
- }
11690
- }
11691
11711
  }
11692
11712
 
11693
11713
  /*
@@ -11700,7 +11720,8 @@ class ConfidentialClientApplication extends ClientApplication {
11700
11720
  const ManagedIdentityUserAssignedIdQueryParameterNames = {
11701
11721
  MANAGED_IDENTITY_CLIENT_ID: "client_id",
11702
11722
  MANAGED_IDENTITY_OBJECT_ID: "object_id",
11703
- MANAGED_IDENTITY_RESOURCE_ID: "mi_res_id",
11723
+ MANAGED_IDENTITY_RESOURCE_ID_IMDS: "msi_res_id",
11724
+ MANAGED_IDENTITY_RESOURCE_ID_NON_IMDS: "mi_res_id",
11704
11725
  };
11705
11726
  class BaseManagedIdentitySource {
11706
11727
  constructor(logger, nodeStorage, networkClient, cryptoProvider) {
@@ -11787,14 +11808,16 @@ class BaseManagedIdentitySource {
11787
11808
  // caches the token
11788
11809
  return responseHandler.handleServerTokenResponse(serverTokenResponse, fakeAuthority, reqTimestamp, managedIdentityRequest);
11789
11810
  }
11790
- getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityIdType) {
11811
+ getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityIdType, imds) {
11791
11812
  switch (managedIdentityIdType) {
11792
11813
  case ManagedIdentityIdType.USER_ASSIGNED_CLIENT_ID:
11793
11814
  this.logger.info("[Managed Identity] Adding user assigned client id to the request.");
11794
11815
  return ManagedIdentityUserAssignedIdQueryParameterNames.MANAGED_IDENTITY_CLIENT_ID;
11795
11816
  case ManagedIdentityIdType.USER_ASSIGNED_RESOURCE_ID:
11796
11817
  this.logger.info("[Managed Identity] Adding user assigned resource id to the request.");
11797
- return ManagedIdentityUserAssignedIdQueryParameterNames.MANAGED_IDENTITY_RESOURCE_ID;
11818
+ return imds
11819
+ ? ManagedIdentityUserAssignedIdQueryParameterNames.MANAGED_IDENTITY_RESOURCE_ID_IMDS
11820
+ : ManagedIdentityUserAssignedIdQueryParameterNames.MANAGED_IDENTITY_RESOURCE_ID_NON_IMDS;
11798
11821
  case ManagedIdentityIdType.USER_ASSIGNED_OBJECT_ID:
11799
11822
  this.logger.info("[Managed Identity] Adding user assigned object id to the request.");
11800
11823
  return ManagedIdentityUserAssignedIdQueryParameterNames.MANAGED_IDENTITY_OBJECT_ID;
@@ -12118,7 +12141,8 @@ class Imds extends BaseManagedIdentitySource {
12118
12141
  request.queryParameters[RESOURCE_BODY_OR_QUERY_PARAMETER_NAME] =
12119
12142
  resource;
12120
12143
  if (managedIdentityId.idType !== ManagedIdentityIdType.SYSTEM_ASSIGNED) {
12121
- request.queryParameters[this.getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityId.idType)] = managedIdentityId.id;
12144
+ request.queryParameters[this.getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityId.idType, true // indicates source is IMDS
12145
+ )] = managedIdentityId.id;
12122
12146
  }
12123
12147
  // bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
12124
12148
  return request;
@@ -12166,8 +12190,7 @@ class ServiceFabric extends BaseManagedIdentitySource {
12166
12190
  }
12167
12191
  createRequest(resource, managedIdentityId) {
12168
12192
  const request = new ManagedIdentityRequestParameters(HttpMethod.GET, this.identityEndpoint);
12169
- request.headers[SERVICE_FABRIC_SECRET_HEADER_NAME] =
12170
- this.identityHeader;
12193
+ request.headers[ML_AND_SF_SECRET_HEADER_NAME] = this.identityHeader;
12171
12194
  request.queryParameters[API_VERSION_QUERY_PARAMETER_NAME] =
12172
12195
  SERVICE_FABRIC_MSI_API_VERSION;
12173
12196
  request.queryParameters[RESOURCE_BODY_OR_QUERY_PARAMETER_NAME] =
@@ -12180,6 +12203,49 @@ class ServiceFabric extends BaseManagedIdentitySource {
12180
12203
  }
12181
12204
  }
12182
12205
 
12206
+ /*
12207
+ * Copyright (c) Microsoft Corporation. All rights reserved.
12208
+ * Licensed under the MIT License.
12209
+ */
12210
+ const MACHINE_LEARNING_MSI_API_VERSION = "2017-09-01";
12211
+ class MachineLearning extends BaseManagedIdentitySource {
12212
+ constructor(logger, nodeStorage, networkClient, cryptoProvider, msiEndpoint, secret) {
12213
+ super(logger, nodeStorage, networkClient, cryptoProvider);
12214
+ this.msiEndpoint = msiEndpoint;
12215
+ this.secret = secret;
12216
+ }
12217
+ static getEnvironmentVariables() {
12218
+ const msiEndpoint = process.env[ManagedIdentityEnvironmentVariableNames.MSI_ENDPOINT];
12219
+ const secret = process.env[ManagedIdentityEnvironmentVariableNames.MSI_SECRET];
12220
+ return [msiEndpoint, secret];
12221
+ }
12222
+ static tryCreate(logger, nodeStorage, networkClient, cryptoProvider) {
12223
+ const [msiEndpoint, secret] = MachineLearning.getEnvironmentVariables();
12224
+ // if either of the MSI endpoint or MSI secret variables are undefined, this MSI provider is unavailable.
12225
+ if (!msiEndpoint || !secret) {
12226
+ logger.info(`[Managed Identity] ${ManagedIdentitySourceNames.MACHINE_LEARNING} managed identity is unavailable because one or both of the '${ManagedIdentityEnvironmentVariableNames.MSI_ENDPOINT}' and '${ManagedIdentityEnvironmentVariableNames.MSI_SECRET}' environment variables are not defined.`);
12227
+ return null;
12228
+ }
12229
+ const validatedMsiEndpoint = MachineLearning.getValidatedEnvVariableUrlString(ManagedIdentityEnvironmentVariableNames.MSI_ENDPOINT, msiEndpoint, ManagedIdentitySourceNames.MACHINE_LEARNING, logger);
12230
+ logger.info(`[Managed Identity] Environment variables validation passed for ${ManagedIdentitySourceNames.MACHINE_LEARNING} managed identity. Endpoint URI: ${validatedMsiEndpoint}. Creating ${ManagedIdentitySourceNames.MACHINE_LEARNING} managed identity.`);
12231
+ return new MachineLearning(logger, nodeStorage, networkClient, cryptoProvider, msiEndpoint, secret);
12232
+ }
12233
+ createRequest(resource, managedIdentityId) {
12234
+ const request = new ManagedIdentityRequestParameters(HttpMethod.GET, this.msiEndpoint);
12235
+ request.headers[METADATA_HEADER_NAME] = "true";
12236
+ request.headers[ML_AND_SF_SECRET_HEADER_NAME] = this.secret;
12237
+ request.queryParameters[API_VERSION_QUERY_PARAMETER_NAME] =
12238
+ MACHINE_LEARNING_MSI_API_VERSION;
12239
+ request.queryParameters[RESOURCE_BODY_OR_QUERY_PARAMETER_NAME] =
12240
+ resource;
12241
+ if (managedIdentityId.idType !== ManagedIdentityIdType.SYSTEM_ASSIGNED) {
12242
+ request.queryParameters[this.getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityId.idType)] = managedIdentityId.id;
12243
+ }
12244
+ // bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
12245
+ return request;
12246
+ }
12247
+ }
12248
+
12183
12249
  /*
12184
12250
  * Copyright (c) Microsoft Corporation. All rights reserved.
12185
12251
  * Licensed under the MIT License.
@@ -12217,11 +12283,13 @@ class ManagedIdentityClient {
12217
12283
  ? ManagedIdentitySourceNames.SERVICE_FABRIC
12218
12284
  : this.allEnvironmentVariablesAreDefined(AppService.getEnvironmentVariables())
12219
12285
  ? ManagedIdentitySourceNames.APP_SERVICE
12220
- : this.allEnvironmentVariablesAreDefined(CloudShell.getEnvironmentVariables())
12221
- ? ManagedIdentitySourceNames.CLOUD_SHELL
12222
- : this.allEnvironmentVariablesAreDefined(AzureArc.getEnvironmentVariables())
12223
- ? ManagedIdentitySourceNames.AZURE_ARC
12224
- : ManagedIdentitySourceNames.DEFAULT_TO_IMDS;
12286
+ : this.allEnvironmentVariablesAreDefined(MachineLearning.getEnvironmentVariables())
12287
+ ? ManagedIdentitySourceNames.MACHINE_LEARNING
12288
+ : this.allEnvironmentVariablesAreDefined(CloudShell.getEnvironmentVariables())
12289
+ ? ManagedIdentitySourceNames.CLOUD_SHELL
12290
+ : this.allEnvironmentVariablesAreDefined(AzureArc.getEnvironmentVariables())
12291
+ ? ManagedIdentitySourceNames.AZURE_ARC
12292
+ : ManagedIdentitySourceNames.DEFAULT_TO_IMDS;
12225
12293
  return ManagedIdentityClient.sourceName;
12226
12294
  }
12227
12295
  /**
@@ -12231,6 +12299,7 @@ class ManagedIdentityClient {
12231
12299
  selectManagedIdentitySource(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) {
12232
12300
  const source = ServiceFabric.tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) ||
12233
12301
  AppService.tryCreate(logger, nodeStorage, networkClient, cryptoProvider) ||
12302
+ MachineLearning.tryCreate(logger, nodeStorage, networkClient, cryptoProvider) ||
12234
12303
  CloudShell.tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) ||
12235
12304
  AzureArc.tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) ||
12236
12305
  Imds.tryCreate(logger, nodeStorage, networkClient, cryptoProvider);