@azure/msal-node 2.11.1 → 2.13.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 (200) hide show
  1. package/dist/cache/ITokenCache.d.ts +15 -15
  2. package/dist/cache/NodeStorage.cjs +425 -423
  3. package/dist/cache/NodeStorage.cjs.map +1 -1
  4. package/dist/cache/NodeStorage.d.ts +193 -193
  5. package/dist/cache/NodeStorage.mjs +423 -423
  6. package/dist/cache/TokenCache.cjs +267 -265
  7. package/dist/cache/TokenCache.cjs.map +1 -1
  8. package/dist/cache/TokenCache.d.ts +90 -90
  9. package/dist/cache/TokenCache.mjs +265 -265
  10. package/dist/cache/distributed/DistributedCachePlugin.cjs +28 -26
  11. package/dist/cache/distributed/DistributedCachePlugin.cjs.map +1 -1
  12. package/dist/cache/distributed/DistributedCachePlugin.d.ts +10 -10
  13. package/dist/cache/distributed/DistributedCachePlugin.mjs +26 -26
  14. package/dist/cache/distributed/ICacheClient.d.ts +17 -17
  15. package/dist/cache/distributed/IPartitionManager.d.ts +28 -28
  16. package/dist/cache/serializer/Deserializer.cjs +169 -167
  17. package/dist/cache/serializer/Deserializer.cjs.map +1 -1
  18. package/dist/cache/serializer/Deserializer.d.ts +42 -42
  19. package/dist/cache/serializer/Deserializer.mjs +167 -167
  20. package/dist/cache/serializer/Serializer.cjs +139 -137
  21. package/dist/cache/serializer/Serializer.cjs.map +1 -1
  22. package/dist/cache/serializer/Serializer.d.ts +39 -39
  23. package/dist/cache/serializer/Serializer.mjs +137 -137
  24. package/dist/cache/serializer/SerializerTypes.d.ts +102 -102
  25. package/dist/client/ClientApplication.cjs +336 -334
  26. package/dist/client/ClientApplication.cjs.map +1 -1
  27. package/dist/client/ClientApplication.d.ts +143 -143
  28. package/dist/client/ClientApplication.mjs +334 -334
  29. package/dist/client/ClientAssertion.cjs +149 -143
  30. package/dist/client/ClientAssertion.cjs.map +1 -1
  31. package/dist/client/ClientAssertion.d.ts +55 -55
  32. package/dist/client/ClientAssertion.mjs +143 -143
  33. package/dist/client/ClientCredentialClient.cjs +196 -194
  34. package/dist/client/ClientCredentialClient.cjs.map +1 -1
  35. package/dist/client/ClientCredentialClient.d.ts +33 -33
  36. package/dist/client/ClientCredentialClient.mjs +194 -194
  37. package/dist/client/ConfidentialClientApplication.cjs +170 -169
  38. package/dist/client/ConfidentialClientApplication.cjs.map +1 -1
  39. package/dist/client/ConfidentialClientApplication.d.ts +58 -58
  40. package/dist/client/ConfidentialClientApplication.mjs +168 -169
  41. package/dist/client/ConfidentialClientApplication.mjs.map +1 -1
  42. package/dist/client/DeviceCodeClient.cjs +209 -207
  43. package/dist/client/DeviceCodeClient.cjs.map +1 -1
  44. package/dist/client/DeviceCodeClient.d.ts +53 -53
  45. package/dist/client/DeviceCodeClient.mjs +207 -207
  46. package/dist/client/IConfidentialClientApplication.d.ts +39 -39
  47. package/dist/client/IPublicClientApplication.d.ts +42 -42
  48. package/dist/client/ManagedIdentityApplication.cjs +86 -84
  49. package/dist/client/ManagedIdentityApplication.cjs.map +1 -1
  50. package/dist/client/ManagedIdentityApplication.d.ts +30 -30
  51. package/dist/client/ManagedIdentityApplication.mjs +84 -84
  52. package/dist/client/ManagedIdentityClient.cjs +62 -60
  53. package/dist/client/ManagedIdentityClient.cjs.map +1 -1
  54. package/dist/client/ManagedIdentityClient.d.ts +27 -27
  55. package/dist/client/ManagedIdentityClient.mjs +60 -60
  56. package/dist/client/ManagedIdentitySources/AppService.cjs +47 -45
  57. package/dist/client/ManagedIdentitySources/AppService.cjs.map +1 -1
  58. package/dist/client/ManagedIdentitySources/AppService.d.ts +17 -17
  59. package/dist/client/ManagedIdentitySources/AppService.mjs +46 -46
  60. package/dist/client/ManagedIdentitySources/AzureArc.cjs +161 -120
  61. package/dist/client/ManagedIdentitySources/AzureArc.cjs.map +1 -1
  62. package/dist/client/ManagedIdentitySources/AzureArc.d.ts +27 -23
  63. package/dist/client/ManagedIdentitySources/AzureArc.d.ts.map +1 -1
  64. package/dist/client/ManagedIdentitySources/AzureArc.mjs +155 -122
  65. package/dist/client/ManagedIdentitySources/AzureArc.mjs.map +1 -1
  66. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.cjs +124 -122
  67. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.cjs.map +1 -1
  68. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +30 -30
  69. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +122 -122
  70. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs.map +1 -1
  71. package/dist/client/ManagedIdentitySources/CloudShell.cjs +40 -38
  72. package/dist/client/ManagedIdentitySources/CloudShell.cjs.map +1 -1
  73. package/dist/client/ManagedIdentitySources/CloudShell.d.ts +16 -16
  74. package/dist/client/ManagedIdentitySources/CloudShell.mjs +39 -39
  75. package/dist/client/ManagedIdentitySources/Imds.cjs +45 -43
  76. package/dist/client/ManagedIdentitySources/Imds.cjs.map +1 -1
  77. package/dist/client/ManagedIdentitySources/Imds.d.ts +12 -12
  78. package/dist/client/ManagedIdentitySources/Imds.mjs +44 -44
  79. package/dist/client/ManagedIdentitySources/ServiceFabric.cjs +56 -54
  80. package/dist/client/ManagedIdentitySources/ServiceFabric.cjs.map +1 -1
  81. package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts +17 -17
  82. package/dist/client/ManagedIdentitySources/ServiceFabric.mjs +55 -55
  83. package/dist/client/OnBehalfOfClient.cjs +204 -202
  84. package/dist/client/OnBehalfOfClient.cjs.map +1 -1
  85. package/dist/client/OnBehalfOfClient.d.ts +47 -47
  86. package/dist/client/OnBehalfOfClient.mjs +202 -202
  87. package/dist/client/PublicClientApplication.cjs +240 -229
  88. package/dist/client/PublicClientApplication.cjs.map +1 -1
  89. package/dist/client/PublicClientApplication.d.ts +72 -71
  90. package/dist/client/PublicClientApplication.d.ts.map +1 -1
  91. package/dist/client/PublicClientApplication.mjs +240 -231
  92. package/dist/client/PublicClientApplication.mjs.map +1 -1
  93. package/dist/client/UsernamePasswordClient.cjs +97 -95
  94. package/dist/client/UsernamePasswordClient.cjs.map +1 -1
  95. package/dist/client/UsernamePasswordClient.d.ts +25 -25
  96. package/dist/client/UsernamePasswordClient.mjs +95 -95
  97. package/dist/config/Configuration.cjs +108 -106
  98. package/dist/config/Configuration.cjs.map +1 -1
  99. package/dist/config/Configuration.d.ts +131 -131
  100. package/dist/config/Configuration.mjs +106 -106
  101. package/dist/config/ManagedIdentityId.cjs +50 -48
  102. package/dist/config/ManagedIdentityId.cjs.map +1 -1
  103. package/dist/config/ManagedIdentityId.d.ts +11 -11
  104. package/dist/config/ManagedIdentityId.mjs +48 -48
  105. package/dist/config/ManagedIdentityRequestParameters.cjs +30 -28
  106. package/dist/config/ManagedIdentityRequestParameters.cjs.map +1 -1
  107. package/dist/config/ManagedIdentityRequestParameters.d.ts +11 -11
  108. package/dist/config/ManagedIdentityRequestParameters.mjs +28 -28
  109. package/dist/crypto/CryptoProvider.cjs +91 -89
  110. package/dist/crypto/CryptoProvider.cjs.map +1 -1
  111. package/dist/crypto/CryptoProvider.d.ts +62 -62
  112. package/dist/crypto/CryptoProvider.mjs +89 -89
  113. package/dist/crypto/GuidGenerator.cjs +24 -22
  114. package/dist/crypto/GuidGenerator.cjs.map +1 -1
  115. package/dist/crypto/GuidGenerator.d.ts +14 -14
  116. package/dist/crypto/GuidGenerator.mjs +22 -22
  117. package/dist/crypto/HashUtils.cjs +19 -13
  118. package/dist/crypto/HashUtils.cjs.map +1 -1
  119. package/dist/crypto/HashUtils.d.ts +8 -8
  120. package/dist/crypto/HashUtils.mjs +13 -13
  121. package/dist/crypto/PkceGenerator.cjs +55 -49
  122. package/dist/crypto/PkceGenerator.cjs.map +1 -1
  123. package/dist/crypto/PkceGenerator.d.ts +22 -22
  124. package/dist/crypto/PkceGenerator.mjs +49 -49
  125. package/dist/error/ManagedIdentityError.cjs +43 -41
  126. package/dist/error/ManagedIdentityError.cjs.map +1 -1
  127. package/dist/error/ManagedIdentityError.d.ts +30 -30
  128. package/dist/error/ManagedIdentityError.mjs +41 -41
  129. package/dist/error/ManagedIdentityErrorCodes.cjs +26 -24
  130. package/dist/error/ManagedIdentityErrorCodes.cjs.map +1 -1
  131. package/dist/error/ManagedIdentityErrorCodes.d.ts +22 -22
  132. package/dist/error/ManagedIdentityErrorCodes.mjs +24 -24
  133. package/dist/error/NodeAuthError.cjs +97 -95
  134. package/dist/error/NodeAuthError.cjs.map +1 -1
  135. package/dist/error/NodeAuthError.d.ts +73 -73
  136. package/dist/error/NodeAuthError.mjs +95 -95
  137. package/dist/index.cjs +3 -1
  138. package/dist/index.cjs.map +1 -1
  139. package/dist/index.d.ts +45 -45
  140. package/dist/index.mjs +1 -1
  141. package/dist/internals.cjs +6 -8
  142. package/dist/internals.cjs.map +1 -1
  143. package/dist/internals.d.ts +6 -6
  144. package/dist/internals.mjs +4 -8
  145. package/dist/internals.mjs.map +1 -1
  146. package/dist/network/HttpClient.cjs +288 -281
  147. package/dist/network/HttpClient.cjs.map +1 -1
  148. package/dist/network/HttpClient.d.ts +25 -25
  149. package/dist/network/HttpClient.mjs +281 -281
  150. package/dist/network/HttpClientWithRetries.cjs +36 -34
  151. package/dist/network/HttpClientWithRetries.cjs.map +1 -1
  152. package/dist/network/HttpClientWithRetries.d.ts +11 -11
  153. package/dist/network/HttpClientWithRetries.mjs +34 -34
  154. package/dist/network/ILoopbackClient.d.ts +10 -10
  155. package/dist/network/LoopbackClient.cjs +87 -77
  156. package/dist/network/LoopbackClient.cjs.map +1 -1
  157. package/dist/network/LoopbackClient.d.ts +21 -21
  158. package/dist/network/LoopbackClient.d.ts.map +1 -1
  159. package/dist/network/LoopbackClient.mjs +81 -77
  160. package/dist/network/LoopbackClient.mjs.map +1 -1
  161. package/dist/packageMetadata.cjs +6 -4
  162. package/dist/packageMetadata.cjs.map +1 -1
  163. package/dist/packageMetadata.d.ts +2 -2
  164. package/dist/packageMetadata.mjs +4 -4
  165. package/dist/request/AuthorizationCodeRequest.d.ts +21 -21
  166. package/dist/request/AuthorizationUrlRequest.d.ts +33 -33
  167. package/dist/request/ClientCredentialRequest.d.ts +14 -14
  168. package/dist/request/DeviceCodeRequest.d.ts +15 -15
  169. package/dist/request/InteractiveRequest.d.ts +22 -22
  170. package/dist/request/ManagedIdentityRequest.d.ts +8 -8
  171. package/dist/request/ManagedIdentityRequestParams.d.ts +9 -9
  172. package/dist/request/OnBehalfOfRequest.d.ts +14 -14
  173. package/dist/request/RefreshTokenRequest.d.ts +17 -17
  174. package/dist/request/SignOutRequest.d.ts +5 -5
  175. package/dist/request/SilentFlowRequest.d.ts +16 -16
  176. package/dist/request/UsernamePasswordRequest.d.ts +19 -19
  177. package/dist/response/ManagedIdentityTokenResponse.d.ts +34 -34
  178. package/dist/retry/IHttpRetryPolicy.d.ts +5 -5
  179. package/dist/retry/LinearRetryPolicy.cjs +42 -40
  180. package/dist/retry/LinearRetryPolicy.cjs.map +1 -1
  181. package/dist/retry/LinearRetryPolicy.d.ts +11 -11
  182. package/dist/retry/LinearRetryPolicy.mjs +40 -40
  183. package/dist/utils/Constants.cjs +138 -136
  184. package/dist/utils/Constants.cjs.map +1 -1
  185. package/dist/utils/Constants.d.ts +141 -141
  186. package/dist/utils/Constants.mjs +136 -136
  187. package/dist/utils/EncodingUtils.cjs +46 -44
  188. package/dist/utils/EncodingUtils.cjs.map +1 -1
  189. package/dist/utils/EncodingUtils.d.ts +26 -26
  190. package/dist/utils/EncodingUtils.mjs +44 -44
  191. package/dist/utils/NetworkUtils.cjs +40 -38
  192. package/dist/utils/NetworkUtils.cjs.map +1 -1
  193. package/dist/utils/NetworkUtils.d.ts +5 -5
  194. package/dist/utils/NetworkUtils.mjs +38 -38
  195. package/package.json +2 -2
  196. package/src/client/ConfidentialClientApplication.ts +3 -3
  197. package/src/client/ManagedIdentitySources/AzureArc.ts +80 -25
  198. package/src/client/PublicClientApplication.ts +13 -1
  199. package/src/network/LoopbackClient.ts +6 -0
  200. package/src/packageMetadata.ts +1 -1
@@ -1,7 +1,9 @@
1
- /*! @azure/msal-node v2.11.1 2024-07-16 */
1
+ /*! @azure/msal-node v2.13.0 2024-08-13 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
5
+ Object.defineProperty(exports, '__esModule', { value: true });
6
+
5
7
  var msalCommon = require('@azure/msal-common');
6
8
  var Configuration = require('../config/Configuration.cjs');
7
9
  var packageMetadata = require('../packageMetadata.cjs');
@@ -11,89 +13,89 @@ var ManagedIdentityClient = require('./ManagedIdentityClient.cjs');
11
13
  var NodeStorage = require('../cache/NodeStorage.cjs');
12
14
  var Constants = require('../utils/Constants.cjs');
13
15
 
14
- /*
15
- * Copyright (c) Microsoft Corporation. All rights reserved.
16
- * Licensed under the MIT License.
17
- */
18
- /**
19
- * Class to initialize a managed identity and identify the service
20
- * @public
21
- */
22
- class ManagedIdentityApplication {
23
- constructor(configuration) {
24
- // undefined config means the managed identity is system-assigned
25
- this.config = Configuration.buildManagedIdentityConfiguration(configuration || {});
26
- this.logger = new msalCommon.Logger(this.config.system.loggerOptions, packageMetadata.name, packageMetadata.version);
27
- const fakeStatusAuthorityOptions = {
28
- canonicalAuthority: msalCommon.Constants.DEFAULT_AUTHORITY,
29
- };
30
- if (!ManagedIdentityApplication.nodeStorage) {
31
- ManagedIdentityApplication.nodeStorage = new NodeStorage.NodeStorage(this.logger, this.config.managedIdentityId.id, msalCommon.DEFAULT_CRYPTO_IMPLEMENTATION, fakeStatusAuthorityOptions);
32
- }
33
- this.networkClient = this.config.system.networkClient;
34
- this.cryptoProvider = new CryptoProvider.CryptoProvider();
35
- const fakeAuthorityOptions = {
36
- protocolMode: msalCommon.ProtocolMode.AAD,
37
- knownAuthorities: [Constants.DEFAULT_AUTHORITY_FOR_MANAGED_IDENTITY],
38
- cloudDiscoveryMetadata: "",
39
- authorityMetadata: "",
40
- };
41
- this.fakeAuthority = new msalCommon.Authority(Constants.DEFAULT_AUTHORITY_FOR_MANAGED_IDENTITY, this.networkClient, ManagedIdentityApplication.nodeStorage, fakeAuthorityOptions, this.logger, this.cryptoProvider.createNewGuid(), // correlationID
42
- undefined, true);
43
- this.fakeClientCredentialClient = new ClientCredentialClient.ClientCredentialClient({
44
- authOptions: {
45
- clientId: this.config.managedIdentityId.id,
46
- authority: this.fakeAuthority,
47
- },
48
- });
49
- this.managedIdentityClient = new ManagedIdentityClient.ManagedIdentityClient(this.logger, ManagedIdentityApplication.nodeStorage, this.networkClient, this.cryptoProvider);
50
- }
51
- /**
52
- * Acquire an access token from the cache or the managed identity
53
- * @param managedIdentityRequest - the ManagedIdentityRequestParams object passed in by the developer
54
- * @returns the access token
55
- */
56
- async acquireToken(managedIdentityRequestParams) {
57
- if (!managedIdentityRequestParams.resource) {
58
- throw msalCommon.createClientConfigurationError(msalCommon.ClientConfigurationErrorCodes.urlEmptyError);
59
- }
60
- const managedIdentityRequest = {
61
- forceRefresh: managedIdentityRequestParams.forceRefresh,
62
- resource: managedIdentityRequestParams.resource.replace("/.default", ""),
63
- scopes: [
64
- managedIdentityRequestParams.resource.replace("/.default", ""),
65
- ],
66
- authority: this.fakeAuthority.canonicalAuthority,
67
- correlationId: this.cryptoProvider.createNewGuid(),
68
- };
69
- if (managedIdentityRequest.forceRefresh) {
70
- // make a network call to the managed identity source
71
- return this.managedIdentityClient.sendManagedIdentityTokenRequest(managedIdentityRequest, this.config.managedIdentityId, this.fakeAuthority);
72
- }
73
- const [cachedAuthenticationResult, lastCacheOutcome] = await this.fakeClientCredentialClient.getCachedAuthenticationResult(managedIdentityRequest, this.config, this.cryptoProvider, this.fakeAuthority, ManagedIdentityApplication.nodeStorage);
74
- if (cachedAuthenticationResult) {
75
- // if the token is not expired but must be refreshed; get a new one in the background
76
- if (lastCacheOutcome === msalCommon.CacheOutcome.PROACTIVELY_REFRESHED) {
77
- this.logger.info("ClientCredentialClient:getCachedAuthenticationResult - Cached access token's refreshOn property has been exceeded'. It's not expired, but must be refreshed.");
78
- // make a network call to the managed identity source; refresh the access token in the background
79
- const refreshAccessToken = true;
80
- await this.managedIdentityClient.sendManagedIdentityTokenRequest(managedIdentityRequest, this.config.managedIdentityId, this.fakeAuthority, refreshAccessToken);
81
- }
82
- return cachedAuthenticationResult;
83
- }
84
- else {
85
- // make a network call to the managed identity source
86
- return this.managedIdentityClient.sendManagedIdentityTokenRequest(managedIdentityRequest, this.config.managedIdentityId, this.fakeAuthority);
87
- }
88
- }
89
- /**
90
- * Determine the Managed Identity Source based on available environment variables. This API is consumed by Azure Identity SDK.
91
- * @returns ManagedIdentitySourceNames - The Managed Identity source's name
92
- */
93
- getManagedIdentitySource() {
94
- return (ManagedIdentityClient.ManagedIdentityClient.sourceName ||
95
- this.managedIdentityClient.getManagedIdentitySource());
96
- }
16
+ /*
17
+ * Copyright (c) Microsoft Corporation. All rights reserved.
18
+ * Licensed under the MIT License.
19
+ */
20
+ /**
21
+ * Class to initialize a managed identity and identify the service
22
+ * @public
23
+ */
24
+ class ManagedIdentityApplication {
25
+ constructor(configuration) {
26
+ // undefined config means the managed identity is system-assigned
27
+ this.config = Configuration.buildManagedIdentityConfiguration(configuration || {});
28
+ this.logger = new msalCommon.Logger(this.config.system.loggerOptions, packageMetadata.name, packageMetadata.version);
29
+ const fakeStatusAuthorityOptions = {
30
+ canonicalAuthority: msalCommon.Constants.DEFAULT_AUTHORITY,
31
+ };
32
+ if (!ManagedIdentityApplication.nodeStorage) {
33
+ ManagedIdentityApplication.nodeStorage = new NodeStorage.NodeStorage(this.logger, this.config.managedIdentityId.id, msalCommon.DEFAULT_CRYPTO_IMPLEMENTATION, fakeStatusAuthorityOptions);
34
+ }
35
+ this.networkClient = this.config.system.networkClient;
36
+ this.cryptoProvider = new CryptoProvider.CryptoProvider();
37
+ const fakeAuthorityOptions = {
38
+ protocolMode: msalCommon.ProtocolMode.AAD,
39
+ knownAuthorities: [Constants.DEFAULT_AUTHORITY_FOR_MANAGED_IDENTITY],
40
+ cloudDiscoveryMetadata: "",
41
+ authorityMetadata: "",
42
+ };
43
+ this.fakeAuthority = new msalCommon.Authority(Constants.DEFAULT_AUTHORITY_FOR_MANAGED_IDENTITY, this.networkClient, ManagedIdentityApplication.nodeStorage, fakeAuthorityOptions, this.logger, this.cryptoProvider.createNewGuid(), // correlationID
44
+ undefined, true);
45
+ this.fakeClientCredentialClient = new ClientCredentialClient.ClientCredentialClient({
46
+ authOptions: {
47
+ clientId: this.config.managedIdentityId.id,
48
+ authority: this.fakeAuthority,
49
+ },
50
+ });
51
+ this.managedIdentityClient = new ManagedIdentityClient.ManagedIdentityClient(this.logger, ManagedIdentityApplication.nodeStorage, this.networkClient, this.cryptoProvider);
52
+ }
53
+ /**
54
+ * Acquire an access token from the cache or the managed identity
55
+ * @param managedIdentityRequest - the ManagedIdentityRequestParams object passed in by the developer
56
+ * @returns the access token
57
+ */
58
+ async acquireToken(managedIdentityRequestParams) {
59
+ if (!managedIdentityRequestParams.resource) {
60
+ throw msalCommon.createClientConfigurationError(msalCommon.ClientConfigurationErrorCodes.urlEmptyError);
61
+ }
62
+ const managedIdentityRequest = {
63
+ forceRefresh: managedIdentityRequestParams.forceRefresh,
64
+ resource: managedIdentityRequestParams.resource.replace("/.default", ""),
65
+ scopes: [
66
+ managedIdentityRequestParams.resource.replace("/.default", ""),
67
+ ],
68
+ authority: this.fakeAuthority.canonicalAuthority,
69
+ correlationId: this.cryptoProvider.createNewGuid(),
70
+ };
71
+ if (managedIdentityRequest.forceRefresh) {
72
+ // make a network call to the managed identity source
73
+ return this.managedIdentityClient.sendManagedIdentityTokenRequest(managedIdentityRequest, this.config.managedIdentityId, this.fakeAuthority);
74
+ }
75
+ const [cachedAuthenticationResult, lastCacheOutcome] = await this.fakeClientCredentialClient.getCachedAuthenticationResult(managedIdentityRequest, this.config, this.cryptoProvider, this.fakeAuthority, ManagedIdentityApplication.nodeStorage);
76
+ if (cachedAuthenticationResult) {
77
+ // if the token is not expired but must be refreshed; get a new one in the background
78
+ if (lastCacheOutcome === msalCommon.CacheOutcome.PROACTIVELY_REFRESHED) {
79
+ this.logger.info("ClientCredentialClient:getCachedAuthenticationResult - Cached access token's refreshOn property has been exceeded'. It's not expired, but must be refreshed.");
80
+ // make a network call to the managed identity source; refresh the access token in the background
81
+ const refreshAccessToken = true;
82
+ await this.managedIdentityClient.sendManagedIdentityTokenRequest(managedIdentityRequest, this.config.managedIdentityId, this.fakeAuthority, refreshAccessToken);
83
+ }
84
+ return cachedAuthenticationResult;
85
+ }
86
+ else {
87
+ // make a network call to the managed identity source
88
+ return this.managedIdentityClient.sendManagedIdentityTokenRequest(managedIdentityRequest, this.config.managedIdentityId, this.fakeAuthority);
89
+ }
90
+ }
91
+ /**
92
+ * Determine the Managed Identity Source based on available environment variables. This API is consumed by Azure Identity SDK.
93
+ * @returns ManagedIdentitySourceNames - The Managed Identity source's name
94
+ */
95
+ getManagedIdentitySource() {
96
+ return (ManagedIdentityClient.ManagedIdentityClient.sourceName ||
97
+ this.managedIdentityClient.getManagedIdentitySource());
98
+ }
97
99
  }
98
100
 
99
101
  exports.ManagedIdentityApplication = ManagedIdentityApplication;
@@ -1 +1 @@
1
- {"version":3,"file":"ManagedIdentityApplication.cjs","sources":["../../src/client/ManagedIdentityApplication.ts"],"sourcesContent":[null],"names":["buildManagedIdentityConfiguration","Logger","name","version","Constants","NodeStorage","DEFAULT_CRYPTO_IMPLEMENTATION","CryptoProvider","ProtocolMode","DEFAULT_AUTHORITY_FOR_MANAGED_IDENTITY","Authority","ClientCredentialClient","ManagedIdentityClient","createClientConfigurationError","ClientConfigurationErrorCodes","CacheOutcome"],"mappings":";;;;;;;;;;;;;AAAA;;;AAGG;AAmCH;;;AAGG;MACU,0BAA0B,CAAA;AAgBnC,IAAA,WAAA,CAAY,aAA4C,EAAA;;QAEpD,IAAI,CAAC,MAAM,GAAGA,+CAAiC,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;AAErE,QAAA,IAAI,CAAC,MAAM,GAAG,IAAIC,iBAAM,CACpB,IAAI,CAAC,MAAM,CAAC,MAAM,CA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J,CACjK,CAAC;;gBAGF,MAAM,kBAAkB,GAAG,IAAI,CAAC;gBAChC,MAAM,IAAI,CAAC,qBAAqB,CAAC,+BAA+B,CAC5D,sBAAsB,EACtB,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAC7B,IAAI,CAAC,aAAa,EAClB,kBAAkB,CACrB,CAAC;AACL,aAAA;AAED,YAAA,OAAO,0BAA0B,CAAC;AACrC,SAAA;AAAM,aAAA;;AAEH,YAAA,OAAO,IAAI,CAAC,qBAAqB,CAAC,+BAA+B,CAC7D,sBAAsB,EACtB,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAC7B,IAAI,CAAC,aAAa,CACrB,CAAC;AACL,SAAA;KACJ;AAED;;;AAGG;IACI,wBAAwB,GAAA;QAC3B,QACIH,2CAAqB,CAAC,UAAU;AAChC,YAAA,IAAI,CAAC,qBAAqB,CAAC,wBAAwB,EAAE,EACvD;KACL;AACJ;;;;"}
1
+ {"version":3,"file":"ManagedIdentityApplication.cjs","sources":["../../src/client/ManagedIdentityApplication.ts"],"sourcesContent":[null],"names":["buildManagedIdentityConfiguration","Logger","name","version","Constants","NodeStorage","DEFAULT_CRYPTO_IMPLEMENTATION","CryptoProvider","ProtocolMode","DEFAULT_AUTHORITY_FOR_MANAGED_IDENTITY","Authority","ClientCredentialClient","ManagedIdentityClient","createClientConfigurationError","ClientConfigurationErrorCodes","CacheOutcome"],"mappings":";;;;;;;;;;;;;;;AAAA;;;AAGG;AAmCH;;;AAGG;MACU,0BAA0B,CAAA;AAgBnC,IAAA,WAAA,CAAY,aAA4C,EAAA;;QAEpD,IAAI,CAAC,MAAM,GAAGA,+CAAiC,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC;AAErE,QAAA,IAAI,CAAC,MAAM,GAAG,IAAIC,iBAAM,CACpB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,EAChCC,oBAAI,EACJC,uBAAO,CACV,CAAC;AAEF,QAAA,MAAM,0BAA0B,GAA2B;YACv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qB,CAAC,+BAA+B,CAC5D,sBAAsB,EACtB,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAC7B,IAAI,CAAC,aAAa,EAClB,kBAAkB,CACrB,CAAC;AACL,aAAA;AAED,YAAA,OAAO,0BAA0B,CAAC;AACrC,SAAA;AAAM,aAAA;;AAEH,YAAA,OAAO,IAAI,CAAC,qBAAqB,CAAC,+BAA+B,CAC7D,sBAAsB,EACtB,IAAI,CAAC,MAAM,CAAC,iBAAiB,EAC7B,IAAI,CAAC,aAAa,CACrB,CAAC;AACL,SAAA;KACJ;AAED;;;AAGG;IACI,wBAAwB,GAAA;QAC3B,QACIH,2CAAqB,CAAC,UAAU;AAChC,YAAA,IAAI,CAAC,qBAAqB,CAAC,wBAAwB,EAAE,EACvD;KACL;AACJ;;;;"}
@@ -1,31 +1,31 @@
1
- import { AuthenticationResult } from "@azure/msal-common";
2
- import { ManagedIdentityConfiguration } from "../config/Configuration";
3
- import { ManagedIdentityRequestParams } from "../request/ManagedIdentityRequestParams";
4
- import { ManagedIdentitySourceNames } from "../utils/Constants";
5
- /**
6
- * Class to initialize a managed identity and identify the service
7
- * @public
8
- */
9
- export declare class ManagedIdentityApplication {
10
- private config;
11
- private logger;
12
- private static nodeStorage?;
13
- private networkClient;
14
- private cryptoProvider;
15
- private fakeAuthority;
16
- private fakeClientCredentialClient;
17
- private managedIdentityClient;
18
- constructor(configuration?: ManagedIdentityConfiguration);
19
- /**
20
- * Acquire an access token from the cache or the managed identity
21
- * @param managedIdentityRequest - the ManagedIdentityRequestParams object passed in by the developer
22
- * @returns the access token
23
- */
24
- acquireToken(managedIdentityRequestParams: ManagedIdentityRequestParams): Promise<AuthenticationResult>;
25
- /**
26
- * Determine the Managed Identity Source based on available environment variables. This API is consumed by Azure Identity SDK.
27
- * @returns ManagedIdentitySourceNames - The Managed Identity source's name
28
- */
29
- getManagedIdentitySource(): ManagedIdentitySourceNames;
30
- }
1
+ import { AuthenticationResult } from "@azure/msal-common";
2
+ import { ManagedIdentityConfiguration } from "../config/Configuration";
3
+ import { ManagedIdentityRequestParams } from "../request/ManagedIdentityRequestParams";
4
+ import { ManagedIdentitySourceNames } from "../utils/Constants";
5
+ /**
6
+ * Class to initialize a managed identity and identify the service
7
+ * @public
8
+ */
9
+ export declare class ManagedIdentityApplication {
10
+ private config;
11
+ private logger;
12
+ private static nodeStorage?;
13
+ private networkClient;
14
+ private cryptoProvider;
15
+ private fakeAuthority;
16
+ private fakeClientCredentialClient;
17
+ private managedIdentityClient;
18
+ constructor(configuration?: ManagedIdentityConfiguration);
19
+ /**
20
+ * Acquire an access token from the cache or the managed identity
21
+ * @param managedIdentityRequest - the ManagedIdentityRequestParams object passed in by the developer
22
+ * @returns the access token
23
+ */
24
+ acquireToken(managedIdentityRequestParams: ManagedIdentityRequestParams): Promise<AuthenticationResult>;
25
+ /**
26
+ * Determine the Managed Identity Source based on available environment variables. This API is consumed by Azure Identity SDK.
27
+ * @returns ManagedIdentitySourceNames - The Managed Identity source's name
28
+ */
29
+ getManagedIdentitySource(): ManagedIdentitySourceNames;
30
+ }
31
31
  //# sourceMappingURL=ManagedIdentityApplication.d.ts.map
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-node v2.11.1 2024-07-16 */
1
+ /*! @azure/msal-node v2.13.0 2024-08-13 */
2
2
  'use strict';
3
3
  import { Logger, DEFAULT_CRYPTO_IMPLEMENTATION, Authority, createClientConfigurationError, ClientConfigurationErrorCodes, CacheOutcome, Constants, ProtocolMode } from '@azure/msal-common';
4
4
  import { buildManagedIdentityConfiguration } from '../config/Configuration.mjs';
@@ -9,89 +9,89 @@ import { ManagedIdentityClient } from './ManagedIdentityClient.mjs';
9
9
  import { NodeStorage } from '../cache/NodeStorage.mjs';
10
10
  import { DEFAULT_AUTHORITY_FOR_MANAGED_IDENTITY } from '../utils/Constants.mjs';
11
11
 
12
- /*
13
- * Copyright (c) Microsoft Corporation. All rights reserved.
14
- * Licensed under the MIT License.
15
- */
16
- /**
17
- * Class to initialize a managed identity and identify the service
18
- * @public
19
- */
20
- class ManagedIdentityApplication {
21
- constructor(configuration) {
22
- // undefined config means the managed identity is system-assigned
23
- this.config = buildManagedIdentityConfiguration(configuration || {});
24
- this.logger = new Logger(this.config.system.loggerOptions, name, version);
25
- const fakeStatusAuthorityOptions = {
26
- canonicalAuthority: Constants.DEFAULT_AUTHORITY,
27
- };
28
- if (!ManagedIdentityApplication.nodeStorage) {
29
- ManagedIdentityApplication.nodeStorage = new NodeStorage(this.logger, this.config.managedIdentityId.id, DEFAULT_CRYPTO_IMPLEMENTATION, fakeStatusAuthorityOptions);
30
- }
31
- this.networkClient = this.config.system.networkClient;
32
- this.cryptoProvider = new CryptoProvider();
33
- const fakeAuthorityOptions = {
34
- protocolMode: ProtocolMode.AAD,
35
- knownAuthorities: [DEFAULT_AUTHORITY_FOR_MANAGED_IDENTITY],
36
- cloudDiscoveryMetadata: "",
37
- authorityMetadata: "",
38
- };
39
- this.fakeAuthority = new Authority(DEFAULT_AUTHORITY_FOR_MANAGED_IDENTITY, this.networkClient, ManagedIdentityApplication.nodeStorage, fakeAuthorityOptions, this.logger, this.cryptoProvider.createNewGuid(), // correlationID
40
- undefined, true);
41
- this.fakeClientCredentialClient = new ClientCredentialClient({
42
- authOptions: {
43
- clientId: this.config.managedIdentityId.id,
44
- authority: this.fakeAuthority,
45
- },
46
- });
47
- this.managedIdentityClient = new ManagedIdentityClient(this.logger, ManagedIdentityApplication.nodeStorage, this.networkClient, this.cryptoProvider);
48
- }
49
- /**
50
- * Acquire an access token from the cache or the managed identity
51
- * @param managedIdentityRequest - the ManagedIdentityRequestParams object passed in by the developer
52
- * @returns the access token
53
- */
54
- async acquireToken(managedIdentityRequestParams) {
55
- if (!managedIdentityRequestParams.resource) {
56
- throw createClientConfigurationError(ClientConfigurationErrorCodes.urlEmptyError);
57
- }
58
- const managedIdentityRequest = {
59
- forceRefresh: managedIdentityRequestParams.forceRefresh,
60
- resource: managedIdentityRequestParams.resource.replace("/.default", ""),
61
- scopes: [
62
- managedIdentityRequestParams.resource.replace("/.default", ""),
63
- ],
64
- authority: this.fakeAuthority.canonicalAuthority,
65
- correlationId: this.cryptoProvider.createNewGuid(),
66
- };
67
- if (managedIdentityRequest.forceRefresh) {
68
- // make a network call to the managed identity source
69
- return this.managedIdentityClient.sendManagedIdentityTokenRequest(managedIdentityRequest, this.config.managedIdentityId, this.fakeAuthority);
70
- }
71
- const [cachedAuthenticationResult, lastCacheOutcome] = await this.fakeClientCredentialClient.getCachedAuthenticationResult(managedIdentityRequest, this.config, this.cryptoProvider, this.fakeAuthority, ManagedIdentityApplication.nodeStorage);
72
- if (cachedAuthenticationResult) {
73
- // if the token is not expired but must be refreshed; get a new one in the background
74
- if (lastCacheOutcome === CacheOutcome.PROACTIVELY_REFRESHED) {
75
- this.logger.info("ClientCredentialClient:getCachedAuthenticationResult - Cached access token's refreshOn property has been exceeded'. It's not expired, but must be refreshed.");
76
- // make a network call to the managed identity source; refresh the access token in the background
77
- const refreshAccessToken = true;
78
- await this.managedIdentityClient.sendManagedIdentityTokenRequest(managedIdentityRequest, this.config.managedIdentityId, this.fakeAuthority, refreshAccessToken);
79
- }
80
- return cachedAuthenticationResult;
81
- }
82
- else {
83
- // make a network call to the managed identity source
84
- return this.managedIdentityClient.sendManagedIdentityTokenRequest(managedIdentityRequest, this.config.managedIdentityId, this.fakeAuthority);
85
- }
86
- }
87
- /**
88
- * Determine the Managed Identity Source based on available environment variables. This API is consumed by Azure Identity SDK.
89
- * @returns ManagedIdentitySourceNames - The Managed Identity source's name
90
- */
91
- getManagedIdentitySource() {
92
- return (ManagedIdentityClient.sourceName ||
93
- this.managedIdentityClient.getManagedIdentitySource());
94
- }
12
+ /*
13
+ * Copyright (c) Microsoft Corporation. All rights reserved.
14
+ * Licensed under the MIT License.
15
+ */
16
+ /**
17
+ * Class to initialize a managed identity and identify the service
18
+ * @public
19
+ */
20
+ class ManagedIdentityApplication {
21
+ constructor(configuration) {
22
+ // undefined config means the managed identity is system-assigned
23
+ this.config = buildManagedIdentityConfiguration(configuration || {});
24
+ this.logger = new Logger(this.config.system.loggerOptions, name, version);
25
+ const fakeStatusAuthorityOptions = {
26
+ canonicalAuthority: Constants.DEFAULT_AUTHORITY,
27
+ };
28
+ if (!ManagedIdentityApplication.nodeStorage) {
29
+ ManagedIdentityApplication.nodeStorage = new NodeStorage(this.logger, this.config.managedIdentityId.id, DEFAULT_CRYPTO_IMPLEMENTATION, fakeStatusAuthorityOptions);
30
+ }
31
+ this.networkClient = this.config.system.networkClient;
32
+ this.cryptoProvider = new CryptoProvider();
33
+ const fakeAuthorityOptions = {
34
+ protocolMode: ProtocolMode.AAD,
35
+ knownAuthorities: [DEFAULT_AUTHORITY_FOR_MANAGED_IDENTITY],
36
+ cloudDiscoveryMetadata: "",
37
+ authorityMetadata: "",
38
+ };
39
+ this.fakeAuthority = new Authority(DEFAULT_AUTHORITY_FOR_MANAGED_IDENTITY, this.networkClient, ManagedIdentityApplication.nodeStorage, fakeAuthorityOptions, this.logger, this.cryptoProvider.createNewGuid(), // correlationID
40
+ undefined, true);
41
+ this.fakeClientCredentialClient = new ClientCredentialClient({
42
+ authOptions: {
43
+ clientId: this.config.managedIdentityId.id,
44
+ authority: this.fakeAuthority,
45
+ },
46
+ });
47
+ this.managedIdentityClient = new ManagedIdentityClient(this.logger, ManagedIdentityApplication.nodeStorage, this.networkClient, this.cryptoProvider);
48
+ }
49
+ /**
50
+ * Acquire an access token from the cache or the managed identity
51
+ * @param managedIdentityRequest - the ManagedIdentityRequestParams object passed in by the developer
52
+ * @returns the access token
53
+ */
54
+ async acquireToken(managedIdentityRequestParams) {
55
+ if (!managedIdentityRequestParams.resource) {
56
+ throw createClientConfigurationError(ClientConfigurationErrorCodes.urlEmptyError);
57
+ }
58
+ const managedIdentityRequest = {
59
+ forceRefresh: managedIdentityRequestParams.forceRefresh,
60
+ resource: managedIdentityRequestParams.resource.replace("/.default", ""),
61
+ scopes: [
62
+ managedIdentityRequestParams.resource.replace("/.default", ""),
63
+ ],
64
+ authority: this.fakeAuthority.canonicalAuthority,
65
+ correlationId: this.cryptoProvider.createNewGuid(),
66
+ };
67
+ if (managedIdentityRequest.forceRefresh) {
68
+ // make a network call to the managed identity source
69
+ return this.managedIdentityClient.sendManagedIdentityTokenRequest(managedIdentityRequest, this.config.managedIdentityId, this.fakeAuthority);
70
+ }
71
+ const [cachedAuthenticationResult, lastCacheOutcome] = await this.fakeClientCredentialClient.getCachedAuthenticationResult(managedIdentityRequest, this.config, this.cryptoProvider, this.fakeAuthority, ManagedIdentityApplication.nodeStorage);
72
+ if (cachedAuthenticationResult) {
73
+ // if the token is not expired but must be refreshed; get a new one in the background
74
+ if (lastCacheOutcome === CacheOutcome.PROACTIVELY_REFRESHED) {
75
+ this.logger.info("ClientCredentialClient:getCachedAuthenticationResult - Cached access token's refreshOn property has been exceeded'. It's not expired, but must be refreshed.");
76
+ // make a network call to the managed identity source; refresh the access token in the background
77
+ const refreshAccessToken = true;
78
+ await this.managedIdentityClient.sendManagedIdentityTokenRequest(managedIdentityRequest, this.config.managedIdentityId, this.fakeAuthority, refreshAccessToken);
79
+ }
80
+ return cachedAuthenticationResult;
81
+ }
82
+ else {
83
+ // make a network call to the managed identity source
84
+ return this.managedIdentityClient.sendManagedIdentityTokenRequest(managedIdentityRequest, this.config.managedIdentityId, this.fakeAuthority);
85
+ }
86
+ }
87
+ /**
88
+ * Determine the Managed Identity Source based on available environment variables. This API is consumed by Azure Identity SDK.
89
+ * @returns ManagedIdentitySourceNames - The Managed Identity source's name
90
+ */
91
+ getManagedIdentitySource() {
92
+ return (ManagedIdentityClient.sourceName ||
93
+ this.managedIdentityClient.getManagedIdentitySource());
94
+ }
95
95
  }
96
96
 
97
97
  export { ManagedIdentityApplication };
@@ -1,7 +1,9 @@
1
- /*! @azure/msal-node v2.11.1 2024-07-16 */
1
+ /*! @azure/msal-node v2.13.0 2024-08-13 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
5
+ Object.defineProperty(exports, '__esModule', { value: true });
6
+
5
7
  var AppService = require('./ManagedIdentitySources/AppService.cjs');
6
8
  var AzureArc = require('./ManagedIdentitySources/AzureArc.cjs');
7
9
  var CloudShell = require('./ManagedIdentitySources/CloudShell.cjs');
@@ -11,65 +13,65 @@ var ManagedIdentityError = require('../error/ManagedIdentityError.cjs');
11
13
  var Constants = require('../utils/Constants.cjs');
12
14
  var ManagedIdentityErrorCodes = require('../error/ManagedIdentityErrorCodes.cjs');
13
15
 
14
- /*
15
- * Copyright (c) Microsoft Corporation. All rights reserved.
16
- * Licensed under the MIT License.
17
- */
18
- /*
19
- * Class to initialize a managed identity and identify the service.
20
- * Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/ManagedIdentityClient.cs
21
- */
22
- class ManagedIdentityClient {
23
- constructor(logger, nodeStorage, networkClient, cryptoProvider) {
24
- this.logger = logger;
25
- this.nodeStorage = nodeStorage;
26
- this.networkClient = networkClient;
27
- this.cryptoProvider = cryptoProvider;
28
- }
29
- async sendManagedIdentityTokenRequest(managedIdentityRequest, managedIdentityId, fakeAuthority, refreshAccessToken) {
30
- if (!ManagedIdentityClient.identitySource) {
31
- ManagedIdentityClient.identitySource =
32
- this.selectManagedIdentitySource(this.logger, this.nodeStorage, this.networkClient, this.cryptoProvider, managedIdentityId);
33
- }
34
- return ManagedIdentityClient.identitySource.acquireTokenWithManagedIdentity(managedIdentityRequest, managedIdentityId, fakeAuthority, refreshAccessToken);
35
- }
36
- allEnvironmentVariablesAreDefined(environmentVariables) {
37
- return Object.values(environmentVariables).every((environmentVariable) => {
38
- return environmentVariable !== undefined;
39
- });
40
- }
41
- /**
42
- * Determine the Managed Identity Source based on available environment variables. This API is consumed by ManagedIdentityApplication's getManagedIdentitySource.
43
- * @returns ManagedIdentitySourceNames - The Managed Identity source's name
44
- */
45
- getManagedIdentitySource() {
46
- ManagedIdentityClient.sourceName =
47
- this.allEnvironmentVariablesAreDefined(ServiceFabric.ServiceFabric.getEnvironmentVariables())
48
- ? Constants.ManagedIdentitySourceNames.SERVICE_FABRIC
49
- : this.allEnvironmentVariablesAreDefined(AppService.AppService.getEnvironmentVariables())
50
- ? Constants.ManagedIdentitySourceNames.APP_SERVICE
51
- : this.allEnvironmentVariablesAreDefined(CloudShell.CloudShell.getEnvironmentVariables())
52
- ? Constants.ManagedIdentitySourceNames.CLOUD_SHELL
53
- : this.allEnvironmentVariablesAreDefined(AzureArc.AzureArc.getEnvironmentVariables())
54
- ? Constants.ManagedIdentitySourceNames.AZURE_ARC
55
- : Constants.ManagedIdentitySourceNames.DEFAULT_TO_IMDS;
56
- return ManagedIdentityClient.sourceName;
57
- }
58
- /**
59
- * Tries to create a managed identity source for all sources
60
- * @returns the managed identity Source
61
- */
62
- selectManagedIdentitySource(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) {
63
- const source = ServiceFabric.ServiceFabric.tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) ||
64
- AppService.AppService.tryCreate(logger, nodeStorage, networkClient, cryptoProvider) ||
65
- CloudShell.CloudShell.tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) ||
66
- AzureArc.AzureArc.tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) ||
67
- Imds.Imds.tryCreate(logger, nodeStorage, networkClient, cryptoProvider);
68
- if (!source) {
69
- throw ManagedIdentityError.createManagedIdentityError(ManagedIdentityErrorCodes.unableToCreateSource);
70
- }
71
- return source;
72
- }
16
+ /*
17
+ * Copyright (c) Microsoft Corporation. All rights reserved.
18
+ * Licensed under the MIT License.
19
+ */
20
+ /*
21
+ * Class to initialize a managed identity and identify the service.
22
+ * Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/ManagedIdentityClient.cs
23
+ */
24
+ class ManagedIdentityClient {
25
+ constructor(logger, nodeStorage, networkClient, cryptoProvider) {
26
+ this.logger = logger;
27
+ this.nodeStorage = nodeStorage;
28
+ this.networkClient = networkClient;
29
+ this.cryptoProvider = cryptoProvider;
30
+ }
31
+ async sendManagedIdentityTokenRequest(managedIdentityRequest, managedIdentityId, fakeAuthority, refreshAccessToken) {
32
+ if (!ManagedIdentityClient.identitySource) {
33
+ ManagedIdentityClient.identitySource =
34
+ this.selectManagedIdentitySource(this.logger, this.nodeStorage, this.networkClient, this.cryptoProvider, managedIdentityId);
35
+ }
36
+ return ManagedIdentityClient.identitySource.acquireTokenWithManagedIdentity(managedIdentityRequest, managedIdentityId, fakeAuthority, refreshAccessToken);
37
+ }
38
+ allEnvironmentVariablesAreDefined(environmentVariables) {
39
+ return Object.values(environmentVariables).every((environmentVariable) => {
40
+ return environmentVariable !== undefined;
41
+ });
42
+ }
43
+ /**
44
+ * Determine the Managed Identity Source based on available environment variables. This API is consumed by ManagedIdentityApplication's getManagedIdentitySource.
45
+ * @returns ManagedIdentitySourceNames - The Managed Identity source's name
46
+ */
47
+ getManagedIdentitySource() {
48
+ ManagedIdentityClient.sourceName =
49
+ this.allEnvironmentVariablesAreDefined(ServiceFabric.ServiceFabric.getEnvironmentVariables())
50
+ ? Constants.ManagedIdentitySourceNames.SERVICE_FABRIC
51
+ : this.allEnvironmentVariablesAreDefined(AppService.AppService.getEnvironmentVariables())
52
+ ? Constants.ManagedIdentitySourceNames.APP_SERVICE
53
+ : this.allEnvironmentVariablesAreDefined(CloudShell.CloudShell.getEnvironmentVariables())
54
+ ? Constants.ManagedIdentitySourceNames.CLOUD_SHELL
55
+ : this.allEnvironmentVariablesAreDefined(AzureArc.AzureArc.getEnvironmentVariables())
56
+ ? Constants.ManagedIdentitySourceNames.AZURE_ARC
57
+ : Constants.ManagedIdentitySourceNames.DEFAULT_TO_IMDS;
58
+ return ManagedIdentityClient.sourceName;
59
+ }
60
+ /**
61
+ * Tries to create a managed identity source for all sources
62
+ * @returns the managed identity Source
63
+ */
64
+ selectManagedIdentitySource(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) {
65
+ const source = ServiceFabric.ServiceFabric.tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) ||
66
+ AppService.AppService.tryCreate(logger, nodeStorage, networkClient, cryptoProvider) ||
67
+ CloudShell.CloudShell.tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) ||
68
+ AzureArc.AzureArc.tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) ||
69
+ Imds.Imds.tryCreate(logger, nodeStorage, networkClient, cryptoProvider);
70
+ if (!source) {
71
+ throw ManagedIdentityError.createManagedIdentityError(ManagedIdentityErrorCodes.unableToCreateSource);
72
+ }
73
+ return source;
74
+ }
73
75
  }
74
76
 
75
77
  exports.ManagedIdentityClient = ManagedIdentityClient;
@@ -1 +1 @@
1
- {"version":3,"file":"ManagedIdentityClient.cjs","sources":["../../src/client/ManagedIdentityClient.ts"],"sourcesContent":[null],"names":["ServiceFabric","ManagedIdentitySourceNames","AppService","CloudShell","AzureArc","Imds","createManagedIdentityError","ManagedIdentityErrorCodes.unableToCreateSource"],"mappings":";;;;;;;;;;;;;AAAA;;;AAGG;AAwBH;;;AAGG;MACU,qBAAqB,CAAA;AAS9B,IAAA,WAAA,CACI,MAAc,EACd,WAAwB,EACxB,aAA6B,EAC7B,cAA8B,EAAA;AAE9B,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AACrB,QAAA,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;AAC/B,QAAA,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;AACnC,QAAA,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;KACxC;IAEM,MAAM,+BAA+B,CACxC,sBAA8C,EAC9C,iBAAoC,EACpC,aAAwB,EACxB,kBAA4B,EAAA;AAE5B,QAAA,IAAI,CAAC,qBAAqB,CAAC,cAAc,EAAE;AACvC,YAAA,qBAAqB,CAAC,cAAc;gBAChC,IAAI,CAAC,2BAA2B,CAC5B,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,WAAW,EAChB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ACb,cAAc,CACjB;AACD,YAAAC,qBAAU,CAAC,SAAS,CAChB,MAAM,EACN,WAAW,EACX,aAAa,EACb,cAAc,EACd,iBAAiB,CACpB;AACD,YAAAC,iBAAQ,CAAC,SAAS,CACd,MAAM,EACN,WAAW,EACX,aAAa,EACb,cAAc,EACd,iBAAiB,CACpB;YACDC,SAAI,CAAC,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;QACvE,IAAI,CAAC,MAAM,EAAE;AACT,YAAA,MAAMC,+CAA0B,CAC5BC,8CAA8C,CACjD,CAAC;AACL,SAAA;AACD,QAAA,OAAO,MAAM,CAAC;KACjB;AACJ;;;;"}
1
+ {"version":3,"file":"ManagedIdentityClient.cjs","sources":["../../src/client/ManagedIdentityClient.ts"],"sourcesContent":[null],"names":["ServiceFabric","ManagedIdentitySourceNames","AppService","CloudShell","AzureArc","Imds","createManagedIdentityError","ManagedIdentityErrorCodes.unableToCreateSource"],"mappings":";;;;;;;;;;;;;;;AAAA;;;AAGG;AAwBH;;;AAGG;MACU,qBAAqB,CAAA;AAS9B,IAAA,WAAA,CACI,MAAc,EACd,WAAwB,EACxB,aAA6B,EAC7B,cAA8B,EAAA;AAE9B,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AACrB,QAAA,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;AAC/B,QAAA,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;AACnC,QAAA,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;KACxC;IAEM,MAAM,+BAA+B,CACxC,sBAA8C,EAC9C,iBAAoC,EACpC,aAAwB,EACxB,kBAA4B,EAAA;AAE5B,QAAA,IAAI,CAAC,qBAAqB,CAAC,cAAc,EAAE;AACvC,YAAA,qBAAqB,CAAC,cAAc;gBAChC,IAAI,CAAC,2BAA2B,CAC5B,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,aAAa,EACl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