@azure/msal-node 2.12.0 → 2.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/dist/cache/ITokenCache.d.ts +15 -15
  2. package/dist/cache/NodeStorage.cjs +423 -423
  3. package/dist/cache/NodeStorage.d.ts +193 -193
  4. package/dist/cache/NodeStorage.mjs +423 -423
  5. package/dist/cache/TokenCache.cjs +265 -265
  6. package/dist/cache/TokenCache.d.ts +90 -90
  7. package/dist/cache/TokenCache.mjs +265 -265
  8. package/dist/cache/distributed/DistributedCachePlugin.cjs +26 -26
  9. package/dist/cache/distributed/DistributedCachePlugin.d.ts +10 -10
  10. package/dist/cache/distributed/DistributedCachePlugin.mjs +26 -26
  11. package/dist/cache/distributed/ICacheClient.d.ts +17 -17
  12. package/dist/cache/distributed/IPartitionManager.d.ts +28 -28
  13. package/dist/cache/serializer/Deserializer.cjs +167 -167
  14. package/dist/cache/serializer/Deserializer.d.ts +42 -42
  15. package/dist/cache/serializer/Deserializer.mjs +167 -167
  16. package/dist/cache/serializer/Serializer.cjs +137 -137
  17. package/dist/cache/serializer/Serializer.d.ts +39 -39
  18. package/dist/cache/serializer/Serializer.mjs +137 -137
  19. package/dist/cache/serializer/SerializerTypes.d.ts +102 -102
  20. package/dist/client/ClientApplication.cjs +334 -334
  21. package/dist/client/ClientApplication.d.ts +143 -143
  22. package/dist/client/ClientApplication.mjs +334 -334
  23. package/dist/client/ClientAssertion.cjs +143 -143
  24. package/dist/client/ClientAssertion.d.ts +55 -55
  25. package/dist/client/ClientAssertion.mjs +143 -143
  26. package/dist/client/ClientCredentialClient.cjs +194 -194
  27. package/dist/client/ClientCredentialClient.d.ts +33 -33
  28. package/dist/client/ClientCredentialClient.mjs +194 -194
  29. package/dist/client/ConfidentialClientApplication.cjs +169 -169
  30. package/dist/client/ConfidentialClientApplication.cjs.map +1 -1
  31. package/dist/client/ConfidentialClientApplication.d.ts +58 -58
  32. package/dist/client/ConfidentialClientApplication.mjs +169 -169
  33. package/dist/client/ConfidentialClientApplication.mjs.map +1 -1
  34. package/dist/client/DeviceCodeClient.cjs +207 -207
  35. package/dist/client/DeviceCodeClient.d.ts +53 -53
  36. package/dist/client/DeviceCodeClient.mjs +207 -207
  37. package/dist/client/IConfidentialClientApplication.d.ts +39 -39
  38. package/dist/client/IPublicClientApplication.d.ts +42 -42
  39. package/dist/client/ManagedIdentityApplication.cjs +84 -84
  40. package/dist/client/ManagedIdentityApplication.d.ts +30 -30
  41. package/dist/client/ManagedIdentityApplication.mjs +84 -84
  42. package/dist/client/ManagedIdentityClient.cjs +60 -60
  43. package/dist/client/ManagedIdentityClient.d.ts +27 -27
  44. package/dist/client/ManagedIdentityClient.mjs +60 -60
  45. package/dist/client/ManagedIdentitySources/AppService.cjs +45 -45
  46. package/dist/client/ManagedIdentitySources/AppService.d.ts +17 -17
  47. package/dist/client/ManagedIdentitySources/AppService.mjs +45 -45
  48. package/dist/client/ManagedIdentitySources/AzureArc.cjs +155 -120
  49. package/dist/client/ManagedIdentitySources/AzureArc.cjs.map +1 -1
  50. package/dist/client/ManagedIdentitySources/AzureArc.d.ts +27 -23
  51. package/dist/client/ManagedIdentitySources/AzureArc.d.ts.map +1 -1
  52. package/dist/client/ManagedIdentitySources/AzureArc.mjs +155 -122
  53. package/dist/client/ManagedIdentitySources/AzureArc.mjs.map +1 -1
  54. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.cjs +122 -122
  55. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.cjs.map +1 -1
  56. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +30 -30
  57. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +122 -122
  58. package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs.map +1 -1
  59. package/dist/client/ManagedIdentitySources/CloudShell.cjs +38 -38
  60. package/dist/client/ManagedIdentitySources/CloudShell.d.ts +16 -16
  61. package/dist/client/ManagedIdentitySources/CloudShell.mjs +38 -38
  62. package/dist/client/ManagedIdentitySources/Imds.cjs +43 -43
  63. package/dist/client/ManagedIdentitySources/Imds.d.ts +12 -12
  64. package/dist/client/ManagedIdentitySources/Imds.mjs +43 -43
  65. package/dist/client/ManagedIdentitySources/ServiceFabric.cjs +54 -54
  66. package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts +17 -17
  67. package/dist/client/ManagedIdentitySources/ServiceFabric.mjs +54 -54
  68. package/dist/client/OnBehalfOfClient.cjs +202 -202
  69. package/dist/client/OnBehalfOfClient.d.ts +47 -47
  70. package/dist/client/OnBehalfOfClient.mjs +202 -202
  71. package/dist/client/PublicClientApplication.cjs +237 -237
  72. package/dist/client/PublicClientApplication.d.ts +72 -72
  73. package/dist/client/PublicClientApplication.mjs +237 -237
  74. package/dist/client/UsernamePasswordClient.cjs +95 -95
  75. package/dist/client/UsernamePasswordClient.d.ts +25 -25
  76. package/dist/client/UsernamePasswordClient.mjs +95 -95
  77. package/dist/config/Configuration.cjs +106 -106
  78. package/dist/config/Configuration.d.ts +131 -131
  79. package/dist/config/Configuration.mjs +106 -106
  80. package/dist/config/ManagedIdentityId.cjs +48 -48
  81. package/dist/config/ManagedIdentityId.d.ts +11 -11
  82. package/dist/config/ManagedIdentityId.mjs +48 -48
  83. package/dist/config/ManagedIdentityRequestParameters.cjs +28 -28
  84. package/dist/config/ManagedIdentityRequestParameters.d.ts +11 -11
  85. package/dist/config/ManagedIdentityRequestParameters.mjs +28 -28
  86. package/dist/crypto/CryptoProvider.cjs +89 -89
  87. package/dist/crypto/CryptoProvider.d.ts +62 -62
  88. package/dist/crypto/CryptoProvider.mjs +89 -89
  89. package/dist/crypto/GuidGenerator.cjs +22 -22
  90. package/dist/crypto/GuidGenerator.d.ts +14 -14
  91. package/dist/crypto/GuidGenerator.mjs +22 -22
  92. package/dist/crypto/HashUtils.cjs +13 -13
  93. package/dist/crypto/HashUtils.d.ts +8 -8
  94. package/dist/crypto/HashUtils.mjs +13 -13
  95. package/dist/crypto/PkceGenerator.cjs +49 -49
  96. package/dist/crypto/PkceGenerator.d.ts +22 -22
  97. package/dist/crypto/PkceGenerator.mjs +49 -49
  98. package/dist/error/ManagedIdentityError.cjs +41 -41
  99. package/dist/error/ManagedIdentityError.d.ts +30 -30
  100. package/dist/error/ManagedIdentityError.mjs +41 -41
  101. package/dist/error/ManagedIdentityErrorCodes.cjs +24 -24
  102. package/dist/error/ManagedIdentityErrorCodes.d.ts +22 -22
  103. package/dist/error/ManagedIdentityErrorCodes.mjs +24 -24
  104. package/dist/error/NodeAuthError.cjs +95 -95
  105. package/dist/error/NodeAuthError.d.ts +73 -73
  106. package/dist/error/NodeAuthError.mjs +95 -95
  107. package/dist/index.cjs +1 -1
  108. package/dist/index.d.ts +45 -45
  109. package/dist/index.mjs +1 -1
  110. package/dist/internals.cjs +8 -8
  111. package/dist/internals.d.ts +6 -6
  112. package/dist/internals.mjs +8 -8
  113. package/dist/network/HttpClient.cjs +281 -281
  114. package/dist/network/HttpClient.d.ts +25 -25
  115. package/dist/network/HttpClient.mjs +281 -281
  116. package/dist/network/HttpClientWithRetries.cjs +34 -34
  117. package/dist/network/HttpClientWithRetries.d.ts +11 -11
  118. package/dist/network/HttpClientWithRetries.mjs +34 -34
  119. package/dist/network/ILoopbackClient.d.ts +10 -10
  120. package/dist/network/LoopbackClient.cjs +81 -77
  121. package/dist/network/LoopbackClient.cjs.map +1 -1
  122. package/dist/network/LoopbackClient.d.ts +21 -21
  123. package/dist/network/LoopbackClient.d.ts.map +1 -1
  124. package/dist/network/LoopbackClient.mjs +81 -77
  125. package/dist/network/LoopbackClient.mjs.map +1 -1
  126. package/dist/packageMetadata.cjs +4 -4
  127. package/dist/packageMetadata.d.ts +2 -2
  128. package/dist/packageMetadata.mjs +4 -4
  129. package/dist/request/AuthorizationCodeRequest.d.ts +21 -21
  130. package/dist/request/AuthorizationUrlRequest.d.ts +33 -33
  131. package/dist/request/ClientCredentialRequest.d.ts +14 -14
  132. package/dist/request/DeviceCodeRequest.d.ts +15 -15
  133. package/dist/request/InteractiveRequest.d.ts +22 -22
  134. package/dist/request/ManagedIdentityRequest.d.ts +8 -8
  135. package/dist/request/ManagedIdentityRequestParams.d.ts +9 -9
  136. package/dist/request/OnBehalfOfRequest.d.ts +14 -14
  137. package/dist/request/RefreshTokenRequest.d.ts +17 -17
  138. package/dist/request/SignOutRequest.d.ts +5 -5
  139. package/dist/request/SilentFlowRequest.d.ts +16 -16
  140. package/dist/request/UsernamePasswordRequest.d.ts +19 -19
  141. package/dist/response/ManagedIdentityTokenResponse.d.ts +34 -34
  142. package/dist/retry/IHttpRetryPolicy.d.ts +5 -5
  143. package/dist/retry/LinearRetryPolicy.cjs +40 -40
  144. package/dist/retry/LinearRetryPolicy.d.ts +11 -11
  145. package/dist/retry/LinearRetryPolicy.mjs +40 -40
  146. package/dist/utils/Constants.cjs +136 -136
  147. package/dist/utils/Constants.d.ts +141 -141
  148. package/dist/utils/Constants.mjs +136 -136
  149. package/dist/utils/EncodingUtils.cjs +44 -44
  150. package/dist/utils/EncodingUtils.d.ts +26 -26
  151. package/dist/utils/EncodingUtils.mjs +44 -44
  152. package/dist/utils/NetworkUtils.cjs +38 -38
  153. package/dist/utils/NetworkUtils.d.ts +5 -5
  154. package/dist/utils/NetworkUtils.mjs +38 -38
  155. package/package.json +2 -2
  156. package/src/client/ConfidentialClientApplication.ts +3 -3
  157. package/src/client/ManagedIdentitySources/AzureArc.ts +80 -25
  158. package/src/network/LoopbackClient.ts +7 -1
  159. package/src/packageMetadata.ts +1 -1
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-node v2.12.0 2024-07-23 */
1
+ /*! @azure/msal-node v2.13.1 2024-08-29 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
@@ -11,89 +11,89 @@ var ManagedIdentityClient = require('./ManagedIdentityClient.cjs');
11
11
  var NodeStorage = require('../cache/NodeStorage.cjs');
12
12
  var Constants = require('../utils/Constants.cjs');
13
13
 
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
- }
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
+ }
97
97
  }
98
98
 
99
99
  exports.ManagedIdentityApplication = ManagedIdentityApplication;
@@ -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.12.0 2024-07-23 */
1
+ /*! @azure/msal-node v2.13.1 2024-08-29 */
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,4 +1,4 @@
1
- /*! @azure/msal-node v2.12.0 2024-07-23 */
1
+ /*! @azure/msal-node v2.13.1 2024-08-29 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
@@ -11,65 +11,65 @@ var ManagedIdentityError = require('../error/ManagedIdentityError.cjs');
11
11
  var Constants = require('../utils/Constants.cjs');
12
12
  var ManagedIdentityErrorCodes = require('../error/ManagedIdentityErrorCodes.cjs');
13
13
 
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
- }
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
+ }
73
73
  }
74
74
 
75
75
  exports.ManagedIdentityClient = ManagedIdentityClient;
@@ -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