@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,28 +1,28 @@
1
- import { Authority, INetworkModule, Logger, AuthenticationResult } from "@azure/msal-common";
2
- import { CryptoProvider } from "../crypto/CryptoProvider";
3
- import { ManagedIdentityRequest } from "../request/ManagedIdentityRequest";
4
- import { ManagedIdentityId } from "../config/ManagedIdentityId";
5
- import { NodeStorage } from "../cache/NodeStorage";
6
- import { ManagedIdentitySourceNames } from "../utils/Constants";
7
- export declare class ManagedIdentityClient {
8
- private logger;
9
- private nodeStorage;
10
- private networkClient;
11
- private cryptoProvider;
12
- private static identitySource?;
13
- static sourceName?: ManagedIdentitySourceNames;
14
- constructor(logger: Logger, nodeStorage: NodeStorage, networkClient: INetworkModule, cryptoProvider: CryptoProvider);
15
- sendManagedIdentityTokenRequest(managedIdentityRequest: ManagedIdentityRequest, managedIdentityId: ManagedIdentityId, fakeAuthority: Authority, refreshAccessToken?: boolean): Promise<AuthenticationResult>;
16
- private allEnvironmentVariablesAreDefined;
17
- /**
18
- * Determine the Managed Identity Source based on available environment variables. This API is consumed by ManagedIdentityApplication's getManagedIdentitySource.
19
- * @returns ManagedIdentitySourceNames - The Managed Identity source's name
20
- */
21
- getManagedIdentitySource(): ManagedIdentitySourceNames;
22
- /**
23
- * Tries to create a managed identity source for all sources
24
- * @returns the managed identity Source
25
- */
26
- private selectManagedIdentitySource;
27
- }
1
+ import { Authority, INetworkModule, Logger, AuthenticationResult } from "@azure/msal-common";
2
+ import { CryptoProvider } from "../crypto/CryptoProvider";
3
+ import { ManagedIdentityRequest } from "../request/ManagedIdentityRequest";
4
+ import { ManagedIdentityId } from "../config/ManagedIdentityId";
5
+ import { NodeStorage } from "../cache/NodeStorage";
6
+ import { ManagedIdentitySourceNames } from "../utils/Constants";
7
+ export declare class ManagedIdentityClient {
8
+ private logger;
9
+ private nodeStorage;
10
+ private networkClient;
11
+ private cryptoProvider;
12
+ private static identitySource?;
13
+ static sourceName?: ManagedIdentitySourceNames;
14
+ constructor(logger: Logger, nodeStorage: NodeStorage, networkClient: INetworkModule, cryptoProvider: CryptoProvider);
15
+ sendManagedIdentityTokenRequest(managedIdentityRequest: ManagedIdentityRequest, managedIdentityId: ManagedIdentityId, fakeAuthority: Authority, refreshAccessToken?: boolean): Promise<AuthenticationResult>;
16
+ private allEnvironmentVariablesAreDefined;
17
+ /**
18
+ * Determine the Managed Identity Source based on available environment variables. This API is consumed by ManagedIdentityApplication's getManagedIdentitySource.
19
+ * @returns ManagedIdentitySourceNames - The Managed Identity source's name
20
+ */
21
+ getManagedIdentitySource(): ManagedIdentitySourceNames;
22
+ /**
23
+ * Tries to create a managed identity source for all sources
24
+ * @returns the managed identity Source
25
+ */
26
+ private selectManagedIdentitySource;
27
+ }
28
28
  //# sourceMappingURL=ManagedIdentityClient.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 { AppService } from './ManagedIdentitySources/AppService.mjs';
4
4
  import { AzureArc } from './ManagedIdentitySources/AzureArc.mjs';
@@ -9,65 +9,65 @@ import { createManagedIdentityError } from '../error/ManagedIdentityError.mjs';
9
9
  import { ManagedIdentitySourceNames } from '../utils/Constants.mjs';
10
10
  import { unableToCreateSource } from '../error/ManagedIdentityErrorCodes.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
- * Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/ManagedIdentityClient.cs
19
- */
20
- class ManagedIdentityClient {
21
- constructor(logger, nodeStorage, networkClient, cryptoProvider) {
22
- this.logger = logger;
23
- this.nodeStorage = nodeStorage;
24
- this.networkClient = networkClient;
25
- this.cryptoProvider = cryptoProvider;
26
- }
27
- async sendManagedIdentityTokenRequest(managedIdentityRequest, managedIdentityId, fakeAuthority, refreshAccessToken) {
28
- if (!ManagedIdentityClient.identitySource) {
29
- ManagedIdentityClient.identitySource =
30
- this.selectManagedIdentitySource(this.logger, this.nodeStorage, this.networkClient, this.cryptoProvider, managedIdentityId);
31
- }
32
- return ManagedIdentityClient.identitySource.acquireTokenWithManagedIdentity(managedIdentityRequest, managedIdentityId, fakeAuthority, refreshAccessToken);
33
- }
34
- allEnvironmentVariablesAreDefined(environmentVariables) {
35
- return Object.values(environmentVariables).every((environmentVariable) => {
36
- return environmentVariable !== undefined;
37
- });
38
- }
39
- /**
40
- * Determine the Managed Identity Source based on available environment variables. This API is consumed by ManagedIdentityApplication's getManagedIdentitySource.
41
- * @returns ManagedIdentitySourceNames - The Managed Identity source's name
42
- */
43
- getManagedIdentitySource() {
44
- ManagedIdentityClient.sourceName =
45
- this.allEnvironmentVariablesAreDefined(ServiceFabric.getEnvironmentVariables())
46
- ? ManagedIdentitySourceNames.SERVICE_FABRIC
47
- : this.allEnvironmentVariablesAreDefined(AppService.getEnvironmentVariables())
48
- ? ManagedIdentitySourceNames.APP_SERVICE
49
- : this.allEnvironmentVariablesAreDefined(CloudShell.getEnvironmentVariables())
50
- ? ManagedIdentitySourceNames.CLOUD_SHELL
51
- : this.allEnvironmentVariablesAreDefined(AzureArc.getEnvironmentVariables())
52
- ? ManagedIdentitySourceNames.AZURE_ARC
53
- : ManagedIdentitySourceNames.DEFAULT_TO_IMDS;
54
- return ManagedIdentityClient.sourceName;
55
- }
56
- /**
57
- * Tries to create a managed identity source for all sources
58
- * @returns the managed identity Source
59
- */
60
- selectManagedIdentitySource(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) {
61
- const source = ServiceFabric.tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) ||
62
- AppService.tryCreate(logger, nodeStorage, networkClient, cryptoProvider) ||
63
- CloudShell.tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) ||
64
- AzureArc.tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) ||
65
- Imds.tryCreate(logger, nodeStorage, networkClient, cryptoProvider);
66
- if (!source) {
67
- throw createManagedIdentityError(unableToCreateSource);
68
- }
69
- return source;
70
- }
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
+ * Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/ManagedIdentityClient.cs
19
+ */
20
+ class ManagedIdentityClient {
21
+ constructor(logger, nodeStorage, networkClient, cryptoProvider) {
22
+ this.logger = logger;
23
+ this.nodeStorage = nodeStorage;
24
+ this.networkClient = networkClient;
25
+ this.cryptoProvider = cryptoProvider;
26
+ }
27
+ async sendManagedIdentityTokenRequest(managedIdentityRequest, managedIdentityId, fakeAuthority, refreshAccessToken) {
28
+ if (!ManagedIdentityClient.identitySource) {
29
+ ManagedIdentityClient.identitySource =
30
+ this.selectManagedIdentitySource(this.logger, this.nodeStorage, this.networkClient, this.cryptoProvider, managedIdentityId);
31
+ }
32
+ return ManagedIdentityClient.identitySource.acquireTokenWithManagedIdentity(managedIdentityRequest, managedIdentityId, fakeAuthority, refreshAccessToken);
33
+ }
34
+ allEnvironmentVariablesAreDefined(environmentVariables) {
35
+ return Object.values(environmentVariables).every((environmentVariable) => {
36
+ return environmentVariable !== undefined;
37
+ });
38
+ }
39
+ /**
40
+ * Determine the Managed Identity Source based on available environment variables. This API is consumed by ManagedIdentityApplication's getManagedIdentitySource.
41
+ * @returns ManagedIdentitySourceNames - The Managed Identity source's name
42
+ */
43
+ getManagedIdentitySource() {
44
+ ManagedIdentityClient.sourceName =
45
+ this.allEnvironmentVariablesAreDefined(ServiceFabric.getEnvironmentVariables())
46
+ ? ManagedIdentitySourceNames.SERVICE_FABRIC
47
+ : this.allEnvironmentVariablesAreDefined(AppService.getEnvironmentVariables())
48
+ ? ManagedIdentitySourceNames.APP_SERVICE
49
+ : this.allEnvironmentVariablesAreDefined(CloudShell.getEnvironmentVariables())
50
+ ? ManagedIdentitySourceNames.CLOUD_SHELL
51
+ : this.allEnvironmentVariablesAreDefined(AzureArc.getEnvironmentVariables())
52
+ ? ManagedIdentitySourceNames.AZURE_ARC
53
+ : ManagedIdentitySourceNames.DEFAULT_TO_IMDS;
54
+ return ManagedIdentityClient.sourceName;
55
+ }
56
+ /**
57
+ * Tries to create a managed identity source for all sources
58
+ * @returns the managed identity Source
59
+ */
60
+ selectManagedIdentitySource(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) {
61
+ const source = ServiceFabric.tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) ||
62
+ AppService.tryCreate(logger, nodeStorage, networkClient, cryptoProvider) ||
63
+ CloudShell.tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) ||
64
+ AzureArc.tryCreate(logger, nodeStorage, networkClient, cryptoProvider, managedIdentityId) ||
65
+ Imds.tryCreate(logger, nodeStorage, networkClient, cryptoProvider);
66
+ if (!source) {
67
+ throw createManagedIdentityError(unableToCreateSource);
68
+ }
69
+ return source;
70
+ }
71
71
  }
72
72
 
73
73
  export { ManagedIdentityClient };
@@ -1,55 +1,57 @@
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 BaseManagedIdentitySource = require('./BaseManagedIdentitySource.cjs');
6
8
  var Constants = require('../../utils/Constants.cjs');
7
9
  var ManagedIdentityRequestParameters = require('../../config/ManagedIdentityRequestParameters.cjs');
8
10
 
9
- /*
10
- * Copyright (c) Microsoft Corporation. All rights reserved.
11
- * Licensed under the MIT License.
12
- */
13
- // MSI Constants. Docs for MSI are available here https://docs.microsoft.com/azure/app-service/overview-managed-identity
14
- const APP_SERVICE_MSI_API_VERSION = "2019-08-01";
15
- /**
16
- * Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/AppServiceManagedIdentitySource.cs
17
- */
18
- class AppService extends BaseManagedIdentitySource.BaseManagedIdentitySource {
19
- constructor(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint, identityHeader) {
20
- super(logger, nodeStorage, networkClient, cryptoProvider);
21
- this.identityEndpoint = identityEndpoint;
22
- this.identityHeader = identityHeader;
23
- }
24
- static getEnvironmentVariables() {
25
- const identityEndpoint = process.env[Constants.ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT];
26
- const identityHeader = process.env[Constants.ManagedIdentityEnvironmentVariableNames.IDENTITY_HEADER];
27
- return [identityEndpoint, identityHeader];
28
- }
29
- static tryCreate(logger, nodeStorage, networkClient, cryptoProvider) {
30
- const [identityEndpoint, identityHeader] = AppService.getEnvironmentVariables();
31
- // if either of the identity endpoint or identity header variables are undefined, this MSI provider is unavailable.
32
- if (!identityEndpoint || !identityHeader) {
33
- logger.info(`[Managed Identity] ${Constants.ManagedIdentitySourceNames.APP_SERVICE} managed identity is unavailable because one or both of the '${Constants.ManagedIdentityEnvironmentVariableNames.IDENTITY_HEADER}' and '${Constants.ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT}' environment variables are not defined.`);
34
- return null;
35
- }
36
- const validatedIdentityEndpoint = AppService.getValidatedEnvVariableUrlString(Constants.ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT, identityEndpoint, Constants.ManagedIdentitySourceNames.APP_SERVICE, logger);
37
- logger.info(`[Managed Identity] Environment variables validation passed for ${Constants.ManagedIdentitySourceNames.APP_SERVICE} managed identity. Endpoint URI: ${validatedIdentityEndpoint}. Creating ${Constants.ManagedIdentitySourceNames.APP_SERVICE} managed identity.`);
38
- return new AppService(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint, identityHeader);
39
- }
40
- createRequest(resource, managedIdentityId) {
41
- const request = new ManagedIdentityRequestParameters.ManagedIdentityRequestParameters(Constants.HttpMethod.GET, this.identityEndpoint);
42
- request.headers[Constants.APP_SERVICE_SECRET_HEADER_NAME] = this.identityHeader;
43
- request.queryParameters[Constants.API_VERSION_QUERY_PARAMETER_NAME] =
44
- APP_SERVICE_MSI_API_VERSION;
45
- request.queryParameters[Constants.RESOURCE_BODY_OR_QUERY_PARAMETER_NAME] =
46
- resource;
47
- if (managedIdentityId.idType !== Constants.ManagedIdentityIdType.SYSTEM_ASSIGNED) {
48
- request.queryParameters[this.getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityId.idType)] = managedIdentityId.id;
49
- }
50
- // bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
51
- return request;
52
- }
11
+ /*
12
+ * Copyright (c) Microsoft Corporation. All rights reserved.
13
+ * Licensed under the MIT License.
14
+ */
15
+ // MSI Constants. Docs for MSI are available here https://docs.microsoft.com/azure/app-service/overview-managed-identity
16
+ const APP_SERVICE_MSI_API_VERSION = "2019-08-01";
17
+ /**
18
+ * Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/AppServiceManagedIdentitySource.cs
19
+ */
20
+ class AppService extends BaseManagedIdentitySource.BaseManagedIdentitySource {
21
+ constructor(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint, identityHeader) {
22
+ super(logger, nodeStorage, networkClient, cryptoProvider);
23
+ this.identityEndpoint = identityEndpoint;
24
+ this.identityHeader = identityHeader;
25
+ }
26
+ static getEnvironmentVariables() {
27
+ const identityEndpoint = process.env[Constants.ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT];
28
+ const identityHeader = process.env[Constants.ManagedIdentityEnvironmentVariableNames.IDENTITY_HEADER];
29
+ return [identityEndpoint, identityHeader];
30
+ }
31
+ static tryCreate(logger, nodeStorage, networkClient, cryptoProvider) {
32
+ const [identityEndpoint, identityHeader] = AppService.getEnvironmentVariables();
33
+ // if either of the identity endpoint or identity header variables are undefined, this MSI provider is unavailable.
34
+ if (!identityEndpoint || !identityHeader) {
35
+ logger.info(`[Managed Identity] ${Constants.ManagedIdentitySourceNames.APP_SERVICE} managed identity is unavailable because one or both of the '${Constants.ManagedIdentityEnvironmentVariableNames.IDENTITY_HEADER}' and '${Constants.ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT}' environment variables are not defined.`);
36
+ return null;
37
+ }
38
+ const validatedIdentityEndpoint = AppService.getValidatedEnvVariableUrlString(Constants.ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT, identityEndpoint, Constants.ManagedIdentitySourceNames.APP_SERVICE, logger);
39
+ logger.info(`[Managed Identity] Environment variables validation passed for ${Constants.ManagedIdentitySourceNames.APP_SERVICE} managed identity. Endpoint URI: ${validatedIdentityEndpoint}. Creating ${Constants.ManagedIdentitySourceNames.APP_SERVICE} managed identity.`);
40
+ return new AppService(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint, identityHeader);
41
+ }
42
+ createRequest(resource, managedIdentityId) {
43
+ const request = new ManagedIdentityRequestParameters.ManagedIdentityRequestParameters(Constants.HttpMethod.GET, this.identityEndpoint);
44
+ request.headers[Constants.APP_SERVICE_SECRET_HEADER_NAME] = this.identityHeader;
45
+ request.queryParameters[Constants.API_VERSION_QUERY_PARAMETER_NAME] =
46
+ APP_SERVICE_MSI_API_VERSION;
47
+ request.queryParameters[Constants.RESOURCE_BODY_OR_QUERY_PARAMETER_NAME] =
48
+ resource;
49
+ if (managedIdentityId.idType !== Constants.ManagedIdentityIdType.SYSTEM_ASSIGNED) {
50
+ request.queryParameters[this.getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityId.idType)] = managedIdentityId.id;
51
+ }
52
+ // bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
53
+ return request;
54
+ }
53
55
  }
54
56
 
55
57
  exports.AppService = AppService;
@@ -1 +1 @@
1
- {"version":3,"file":"AppService.cjs","sources":["../../../src/client/ManagedIdentitySources/AppService.ts"],"sourcesContent":[null],"names":["BaseManagedIdentitySource","ManagedIdentityEnvironmentVariableNames","ManagedIdentitySourceNames","ManagedIdentityRequestParameters","HttpMethod","APP_SERVICE_SECRET_HEADER_NAME","API_VERSION_QUERY_PARAMETER_NAME","RESOURCE_BODY_OR_QUERY_PARAMETER_NAME","ManagedIdentityIdType"],"mappings":";;;;;;;;AAAA;;;AAGG;AAkBH;AACA,MAAM,2BAA2B,GAAW,YAAY,CAAC;AAEzD;;AAEG;AACG,MAAO,UAAW,SAAQA,mDAAyB,CAAA;IAIrD,WACI,CAAA,MAAc,EACd,WAAwB,EACxB,aAA6B,EAC7B,cAA8B,EAC9B,gBAAwB,EACxB,cAAsB,EAAA;QAEtB,KAAK,CAAC,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;AAE1D,QAAA,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;AACzC,QAAA,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;KACxC;AAEM,IAAA,OAAO,uBAAuB,GAAA;QACjC,MAAM,gBAAgB,GAClB,OAAO,CAAC,GAAG,CACPC,iDAAuC,CAAC,iBAAiB,CAC5D,CAAC;QACN,MAAM,cAAc,GAChB,OAAO,CAAC,GAAG,CACPA,iDAAuC,CAAC,eAAe,CAC1D,CAAC;AAEN,QAAA,OAAO,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;KAC7C;IAEM,OAAO,SAAS,CACnB,MAAc,EACd,WAAwB,EACxB,aAA6B,EAC7B,cAA8B,EAAA;QAE9B,MAAM,CAAC,gBAAgB,EAAE,cAAc,CAAC,GACpC,UAAU,CAAC,uBAAuB,EAAE,CAAC;;AAGzC,QAAA,IAAI,CAAC,gBAAgB,IAAI,CAAC,cAAc,EAAE;AACtC,YAAA,MAAM,CAAC,IAAI,CACP,CAAsB,mBAAA,EAAAC,oCAA0B,CAAC,WAAW,CAAA,6DAAA,EAAgED,iDAAuC,CAAC,eAAe,CAAU,OAAA,EAAAA,iDAAuC,CAAC,iBAAiB,CAAA,wCAAA,CAA0C,CACnS,CAAC;AACF,YAAA,OAAO,IAAI,CAAC;AACf,SAAA;AAED,QAAA,MAAM,yBAAyB,GAC3B,UAAU,CAAC,gCAAgC,CACvCA,iDAAuC,CAAC,iBAAiB,EACzD,gBAAgB,EAChBC,oCAA0B,CAAC,WAAW,EACtC,MAAM,CACT,CAAC;AAEN,QAAA,MAAM,CAAC,IAAI,CACP,CAAA,+DAAA,EAAkEA,oCAA0B,CAAC,WAAW,CAAoC,iCAAA,EAAA,yBAAyB,cAAcA,oCAA0B,CAAC,WAAW,CAAA,kBAAA,CAAoB,CAChP,CAAC;AAEF,QAAA,OAAO,IAAI,UAAU,CACjB,MAAM,EACN,WAAW,EACX,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,cAAc,CACjB,CAAC;KACL;IAEM,aAAa,CAChB,QAAgB,EAChB,iBAAoC,EAAA;AAEpC,QAAA,MAAM,OAAO,GACT,IAAIC,iEAAgC,CAChCC,oBAAU,CAAC,GAAG,EACd,IAAI,CAAC,gBAAgB,CACxB,CAAC;QAEN,OAAO,CAAC,OAAO,CAACC,wCAA8B,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC;AAEtE,QAAA,OAAO,CAAC,eAAe,CAACC,0CAAgC,CAAC;AACrD,YAAA,2BAA2B,CAAC;AAChC,QAAA,OAAO,CAAC,eAAe,CAACC,+CAAqC,CAAC;AAC1D,YAAA,QAAQ,CAAC;AAEb,QAAA,IACI,iBAAiB,CAAC,MAAM,KAAKC,+BAAqB,CAAC,eAAe,EACpE;AACE,YAAA,OAAO,CAAC,eAAe,CACnB,IAAI,CAAC,iDAAiD,CAClD,iBAAiB,CAAC,MAAM,CAC3B,CACJ,GAAG,iBAAiB,CAAC,EAAE,CAAC;AAC5B,SAAA;;AAID,QAAA,OAAO,OAAO,CAAC;KAClB;AACJ;;;;"}
1
+ {"version":3,"file":"AppService.cjs","sources":["../../../src/client/ManagedIdentitySources/AppService.ts"],"sourcesContent":[null],"names":["BaseManagedIdentitySource","ManagedIdentityEnvironmentVariableNames","ManagedIdentitySourceNames","ManagedIdentityRequestParameters","HttpMethod","APP_SERVICE_SECRET_HEADER_NAME","API_VERSION_QUERY_PARAMETER_NAME","RESOURCE_BODY_OR_QUERY_PARAMETER_NAME","ManagedIdentityIdType"],"mappings":";;;;;;;;;;AAAA;;;AAGG;AAkBH;AACA,MAAM,2BAA2B,GAAW,YAAY,CAAC;AAEzD;;AAEG;AACG,MAAO,UAAW,SAAQA,mDAAyB,CAAA;IAIrD,WACI,CAAA,MAAc,EACd,WAAwB,EACxB,aAA6B,EAC7B,cAA8B,EAC9B,gBAAwB,EACxB,cAAsB,EAAA;QAEtB,KAAK,CAAC,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;AAE1D,QAAA,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;AACzC,QAAA,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;KACxC;AAEM,IAAA,OAAO,uBAAuB,GAAA;QACjC,MAAM,gBAAgB,GAClB,OAAO,CAAC,GAAG,CACPC,iDAAuC,CAAC,iBAAiB,CAC5D,CAAC;QACN,MAAM,cAAc,GAChB,OAAO,CAAC,GAAG,CACPA,iDAAuC,CAAC,eAAe,CAC1D,CAAC;AAEN,QAAA,OAAO,CAAC,gBAAgB,EAAE,cAAc,CAAC,CAAC;KAC7C;IAEM,OAAO,SAAS,CACnB,MAAc,EACd,WAAwB,EACxB,aAA6B,EAC7B,cAA8B,EAAA;QAE9B,MAAM,CAAC,gBAAgB,EAAE,cAAc,CAAC,GACpC,UAAU,CAAC,uBAAuB,EAAE,CAAC;;AAGzC,QAAA,IAAI,CAAC,gBAAgB,IAAI,CAAC,cAAc,EAAE;AACtC,YAAA,MAAM,CAAC,IAAI,CACP,CAAsB,mBAAA,EAAAC,oCAA0B,CAAC,WAAW,CAAA,6DAAA,EAAgED,iDAAuC,CAAC,eAAe,CAAU,OAAA,EAAAA,iDAAuC,CAAC,iBAAiB,CAAA,wCAAA,CAA0C,CACnS,CAAC;AACF,YAAA,OAAO,IAAI,CAAC;AACf,SAAA;AAED,QAAA,MAAM,yBAAyB,GAC3B,UAAU,CAAC,gCAAgC,CACvCA,iDAAuC,CAAC,iBAAiB,EACzD,gBAAgB,EAChBC,oCAA0B,CAAC,WAAW,EACtC,MAAM,CACT,CAAC;AAEN,QAAA,MAAM,CAAC,IAAI,CACP,CAAA,+DAAA,EAAkEA,oCAA0B,CAAC,WAAW,CAAoC,iCAAA,EAAA,yBAAyB,cAAcA,oCAA0B,CAAC,WAAW,CAAA,kBAAA,CAAoB,CAChP,CAAC;AAEF,QAAA,OAAO,IAAI,UAAU,CACjB,MAAM,EACN,WAAW,EACX,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,cAAc,CACjB,CAAC;KACL;IAEM,aAAa,CAChB,QAAgB,EAChB,iBAAoC,EAAA;AAEpC,QAAA,MAAM,OAAO,GACT,IAAIC,iEAAgC,CAChCC,oBAAU,CAAC,GAAG,EACd,IAAI,CAAC,gBAAgB,CACxB,CAAC;QAEN,OAAO,CAAC,OAAO,CAACC,wCAA8B,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC;AAEtE,QAAA,OAAO,CAAC,eAAe,CAACC,0CAAgC,CAAC;AACrD,YAAA,2BAA2B,CAAC;AAChC,QAAA,OAAO,CAAC,eAAe,CAACC,+CAAqC,CAAC;AAC1D,YAAA,QAAQ,CAAC;AAEb,QAAA,IACI,iBAAiB,CAAC,MAAM,KAAKC,+BAAqB,CAAC,eAAe,EACpE;AACE,YAAA,OAAO,CAAC,eAAe,CACnB,IAAI,CAAC,iDAAiD,CAClD,iBAAiB,CAAC,MAAM,CAC3B,CACJ,GAAG,iBAAiB,CAAC,EAAE,CAAC;AAC5B,SAAA;;AAID,QAAA,OAAO,OAAO,CAAC;KAClB;AACJ;;;;"}
@@ -1,18 +1,18 @@
1
- import { INetworkModule, Logger } from "@azure/msal-common";
2
- import { BaseManagedIdentitySource } from "./BaseManagedIdentitySource";
3
- import { CryptoProvider } from "../../crypto/CryptoProvider";
4
- import { ManagedIdentityRequestParameters } from "../../config/ManagedIdentityRequestParameters";
5
- import { ManagedIdentityId } from "../../config/ManagedIdentityId";
6
- import { NodeStorage } from "../../cache/NodeStorage";
7
- /**
8
- * Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/AppServiceManagedIdentitySource.cs
9
- */
10
- export declare class AppService extends BaseManagedIdentitySource {
11
- private identityEndpoint;
12
- private identityHeader;
13
- constructor(logger: Logger, nodeStorage: NodeStorage, networkClient: INetworkModule, cryptoProvider: CryptoProvider, identityEndpoint: string, identityHeader: string);
14
- static getEnvironmentVariables(): Array<string | undefined>;
15
- static tryCreate(logger: Logger, nodeStorage: NodeStorage, networkClient: INetworkModule, cryptoProvider: CryptoProvider): AppService | null;
16
- createRequest(resource: string, managedIdentityId: ManagedIdentityId): ManagedIdentityRequestParameters;
17
- }
1
+ import { INetworkModule, Logger } from "@azure/msal-common";
2
+ import { BaseManagedIdentitySource } from "./BaseManagedIdentitySource";
3
+ import { CryptoProvider } from "../../crypto/CryptoProvider";
4
+ import { ManagedIdentityRequestParameters } from "../../config/ManagedIdentityRequestParameters";
5
+ import { ManagedIdentityId } from "../../config/ManagedIdentityId";
6
+ import { NodeStorage } from "../../cache/NodeStorage";
7
+ /**
8
+ * Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/AppServiceManagedIdentitySource.cs
9
+ */
10
+ export declare class AppService extends BaseManagedIdentitySource {
11
+ private identityEndpoint;
12
+ private identityHeader;
13
+ constructor(logger: Logger, nodeStorage: NodeStorage, networkClient: INetworkModule, cryptoProvider: CryptoProvider, identityEndpoint: string, identityHeader: string);
14
+ static getEnvironmentVariables(): Array<string | undefined>;
15
+ static tryCreate(logger: Logger, nodeStorage: NodeStorage, networkClient: INetworkModule, cryptoProvider: CryptoProvider): AppService | null;
16
+ createRequest(resource: string, managedIdentityId: ManagedIdentityId): ManagedIdentityRequestParameters;
17
+ }
18
18
  //# sourceMappingURL=AppService.d.ts.map
@@ -1,53 +1,53 @@
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 { BaseManagedIdentitySource } from './BaseManagedIdentitySource.mjs';
4
- import { ManagedIdentityEnvironmentVariableNames, ManagedIdentitySourceNames, APP_SERVICE_SECRET_HEADER_NAME, API_VERSION_QUERY_PARAMETER_NAME, RESOURCE_BODY_OR_QUERY_PARAMETER_NAME, ManagedIdentityIdType, HttpMethod } from '../../utils/Constants.mjs';
4
+ import { ManagedIdentityEnvironmentVariableNames, ManagedIdentitySourceNames, HttpMethod, APP_SERVICE_SECRET_HEADER_NAME, API_VERSION_QUERY_PARAMETER_NAME, RESOURCE_BODY_OR_QUERY_PARAMETER_NAME, ManagedIdentityIdType } from '../../utils/Constants.mjs';
5
5
  import { ManagedIdentityRequestParameters } from '../../config/ManagedIdentityRequestParameters.mjs';
6
6
 
7
- /*
8
- * Copyright (c) Microsoft Corporation. All rights reserved.
9
- * Licensed under the MIT License.
10
- */
11
- // MSI Constants. Docs for MSI are available here https://docs.microsoft.com/azure/app-service/overview-managed-identity
12
- const APP_SERVICE_MSI_API_VERSION = "2019-08-01";
13
- /**
14
- * Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/AppServiceManagedIdentitySource.cs
15
- */
16
- class AppService extends BaseManagedIdentitySource {
17
- constructor(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint, identityHeader) {
18
- super(logger, nodeStorage, networkClient, cryptoProvider);
19
- this.identityEndpoint = identityEndpoint;
20
- this.identityHeader = identityHeader;
21
- }
22
- static getEnvironmentVariables() {
23
- const identityEndpoint = process.env[ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT];
24
- const identityHeader = process.env[ManagedIdentityEnvironmentVariableNames.IDENTITY_HEADER];
25
- return [identityEndpoint, identityHeader];
26
- }
27
- static tryCreate(logger, nodeStorage, networkClient, cryptoProvider) {
28
- const [identityEndpoint, identityHeader] = AppService.getEnvironmentVariables();
29
- // if either of the identity endpoint or identity header variables are undefined, this MSI provider is unavailable.
30
- if (!identityEndpoint || !identityHeader) {
31
- logger.info(`[Managed Identity] ${ManagedIdentitySourceNames.APP_SERVICE} managed identity is unavailable because one or both of the '${ManagedIdentityEnvironmentVariableNames.IDENTITY_HEADER}' and '${ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT}' environment variables are not defined.`);
32
- return null;
33
- }
34
- const validatedIdentityEndpoint = AppService.getValidatedEnvVariableUrlString(ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT, identityEndpoint, ManagedIdentitySourceNames.APP_SERVICE, logger);
35
- logger.info(`[Managed Identity] Environment variables validation passed for ${ManagedIdentitySourceNames.APP_SERVICE} managed identity. Endpoint URI: ${validatedIdentityEndpoint}. Creating ${ManagedIdentitySourceNames.APP_SERVICE} managed identity.`);
36
- return new AppService(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint, identityHeader);
37
- }
38
- createRequest(resource, managedIdentityId) {
39
- const request = new ManagedIdentityRequestParameters(HttpMethod.GET, this.identityEndpoint);
40
- request.headers[APP_SERVICE_SECRET_HEADER_NAME] = this.identityHeader;
41
- request.queryParameters[API_VERSION_QUERY_PARAMETER_NAME] =
42
- APP_SERVICE_MSI_API_VERSION;
43
- request.queryParameters[RESOURCE_BODY_OR_QUERY_PARAMETER_NAME] =
44
- resource;
45
- if (managedIdentityId.idType !== ManagedIdentityIdType.SYSTEM_ASSIGNED) {
46
- request.queryParameters[this.getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityId.idType)] = managedIdentityId.id;
47
- }
48
- // bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
49
- return request;
50
- }
7
+ /*
8
+ * Copyright (c) Microsoft Corporation. All rights reserved.
9
+ * Licensed under the MIT License.
10
+ */
11
+ // MSI Constants. Docs for MSI are available here https://docs.microsoft.com/azure/app-service/overview-managed-identity
12
+ const APP_SERVICE_MSI_API_VERSION = "2019-08-01";
13
+ /**
14
+ * Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/AppServiceManagedIdentitySource.cs
15
+ */
16
+ class AppService extends BaseManagedIdentitySource {
17
+ constructor(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint, identityHeader) {
18
+ super(logger, nodeStorage, networkClient, cryptoProvider);
19
+ this.identityEndpoint = identityEndpoint;
20
+ this.identityHeader = identityHeader;
21
+ }
22
+ static getEnvironmentVariables() {
23
+ const identityEndpoint = process.env[ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT];
24
+ const identityHeader = process.env[ManagedIdentityEnvironmentVariableNames.IDENTITY_HEADER];
25
+ return [identityEndpoint, identityHeader];
26
+ }
27
+ static tryCreate(logger, nodeStorage, networkClient, cryptoProvider) {
28
+ const [identityEndpoint, identityHeader] = AppService.getEnvironmentVariables();
29
+ // if either of the identity endpoint or identity header variables are undefined, this MSI provider is unavailable.
30
+ if (!identityEndpoint || !identityHeader) {
31
+ logger.info(`[Managed Identity] ${ManagedIdentitySourceNames.APP_SERVICE} managed identity is unavailable because one or both of the '${ManagedIdentityEnvironmentVariableNames.IDENTITY_HEADER}' and '${ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT}' environment variables are not defined.`);
32
+ return null;
33
+ }
34
+ const validatedIdentityEndpoint = AppService.getValidatedEnvVariableUrlString(ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT, identityEndpoint, ManagedIdentitySourceNames.APP_SERVICE, logger);
35
+ logger.info(`[Managed Identity] Environment variables validation passed for ${ManagedIdentitySourceNames.APP_SERVICE} managed identity. Endpoint URI: ${validatedIdentityEndpoint}. Creating ${ManagedIdentitySourceNames.APP_SERVICE} managed identity.`);
36
+ return new AppService(logger, nodeStorage, networkClient, cryptoProvider, identityEndpoint, identityHeader);
37
+ }
38
+ createRequest(resource, managedIdentityId) {
39
+ const request = new ManagedIdentityRequestParameters(HttpMethod.GET, this.identityEndpoint);
40
+ request.headers[APP_SERVICE_SECRET_HEADER_NAME] = this.identityHeader;
41
+ request.queryParameters[API_VERSION_QUERY_PARAMETER_NAME] =
42
+ APP_SERVICE_MSI_API_VERSION;
43
+ request.queryParameters[RESOURCE_BODY_OR_QUERY_PARAMETER_NAME] =
44
+ resource;
45
+ if (managedIdentityId.idType !== ManagedIdentityIdType.SYSTEM_ASSIGNED) {
46
+ request.queryParameters[this.getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityId.idType)] = managedIdentityId.id;
47
+ }
48
+ // bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
49
+ return request;
50
+ }
51
51
  }
52
52
 
53
53
  export { AppService };