@azure/msal-node 3.8.0 → 3.8.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.
- package/dist/cache/CacheHelpers.mjs +1 -1
- package/dist/cache/NodeStorage.d.ts.map +1 -1
- package/dist/cache/NodeStorage.mjs +2 -2
- package/dist/cache/NodeStorage.mjs.map +1 -1
- package/dist/cache/TokenCache.mjs +1 -1
- package/dist/cache/distributed/DistributedCachePlugin.mjs +1 -1
- package/dist/cache/serializer/Deserializer.mjs +1 -1
- package/dist/cache/serializer/Serializer.mjs +1 -1
- package/dist/client/ClientApplication.mjs +1 -1
- package/dist/client/ClientAssertion.mjs +1 -1
- package/dist/client/ClientCredentialClient.mjs +1 -1
- package/dist/client/ConfidentialClientApplication.mjs +1 -1
- package/dist/client/DeviceCodeClient.mjs +1 -1
- package/dist/client/ManagedIdentityApplication.mjs +1 -1
- package/dist/client/ManagedIdentityClient.mjs +1 -1
- package/dist/client/ManagedIdentitySources/AppService.d.ts +54 -0
- package/dist/client/ManagedIdentitySources/AppService.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/AppService.mjs +55 -1
- package/dist/client/ManagedIdentitySources/AppService.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/AzureArc.d.ts +81 -0
- package/dist/client/ManagedIdentitySources/AzureArc.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/AzureArc.mjs +82 -1
- package/dist/client/ManagedIdentitySources/AzureArc.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +93 -2
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +81 -1
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/CloudShell.d.ts +54 -0
- package/dist/client/ManagedIdentitySources/CloudShell.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/CloudShell.mjs +55 -1
- package/dist/client/ManagedIdentitySources/CloudShell.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/Imds.d.ts +44 -22
- package/dist/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/Imds.mjs +44 -22
- package/dist/client/ManagedIdentitySources/Imds.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/MachineLearning.d.ts +65 -0
- package/dist/client/ManagedIdentitySources/MachineLearning.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/MachineLearning.mjs +66 -1
- package/dist/client/ManagedIdentitySources/MachineLearning.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts +56 -22
- package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/ServiceFabric.mjs +57 -23
- package/dist/client/ManagedIdentitySources/ServiceFabric.mjs.map +1 -1
- package/dist/client/OnBehalfOfClient.mjs +1 -1
- package/dist/client/PublicClientApplication.mjs +1 -1
- package/dist/client/UsernamePasswordClient.mjs +1 -1
- package/dist/config/Configuration.mjs +1 -1
- package/dist/config/ManagedIdentityId.mjs +1 -1
- package/dist/config/ManagedIdentityRequestParameters.mjs +1 -1
- package/dist/crypto/CryptoProvider.mjs +1 -1
- package/dist/crypto/GuidGenerator.mjs +1 -1
- package/dist/crypto/HashUtils.mjs +1 -1
- package/dist/crypto/PkceGenerator.mjs +1 -1
- package/dist/error/ManagedIdentityError.mjs +1 -1
- package/dist/error/ManagedIdentityErrorCodes.mjs +1 -1
- package/dist/error/NodeAuthError.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/internals.mjs +1 -1
- package/dist/network/HttpClient.mjs +1 -1
- package/dist/network/HttpClientWithRetries.mjs +1 -1
- package/dist/network/LoopbackClient.mjs +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/protocol/Authorize.mjs +1 -1
- package/dist/retry/DefaultManagedIdentityRetryPolicy.mjs +1 -1
- package/dist/retry/ExponentialRetryStrategy.mjs +1 -1
- package/dist/retry/ImdsRetryPolicy.mjs +1 -1
- package/dist/retry/LinearRetryStrategy.mjs +1 -1
- package/dist/utils/Constants.mjs +1 -1
- package/dist/utils/EncodingUtils.mjs +1 -1
- package/dist/utils/NetworkUtils.mjs +1 -1
- package/dist/utils/TimeUtils.mjs +1 -1
- package/lib/msal-node.cjs +914 -503
- package/lib/msal-node.cjs.map +1 -1
- package/lib/types/cache/NodeStorage.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/AppService.d.ts +54 -0
- package/lib/types/client/ManagedIdentitySources/AppService.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/AzureArc.d.ts +81 -0
- package/lib/types/client/ManagedIdentitySources/AzureArc.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts +93 -2
- package/lib/types/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/CloudShell.d.ts +54 -0
- package/lib/types/client/ManagedIdentitySources/CloudShell.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/Imds.d.ts +44 -22
- package/lib/types/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/MachineLearning.d.ts +65 -0
- package/lib/types/client/ManagedIdentitySources/MachineLearning.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/ServiceFabric.d.ts +56 -22
- package/lib/types/client/ManagedIdentitySources/ServiceFabric.d.ts.map +1 -1
- package/lib/types/packageMetadata.d.ts +1 -1
- package/package.json +2 -2
- package/src/cache/NodeStorage.ts +3 -1
- package/src/client/ManagedIdentitySources/AppService.ts +54 -0
- package/src/client/ManagedIdentitySources/AzureArc.ts +81 -0
- package/src/client/ManagedIdentitySources/BaseManagedIdentitySource.ts +92 -2
- package/src/client/ManagedIdentitySources/CloudShell.ts +54 -0
- package/src/client/ManagedIdentitySources/Imds.ts +43 -21
- package/src/client/ManagedIdentitySources/MachineLearning.ts +65 -0
- package/src/client/ManagedIdentitySources/ServiceFabric.ts +56 -22
- package/src/packageMetadata.ts +1 -1
|
@@ -6,6 +6,7 @@ import { ManagedIdentityRequest } from "../../request/ManagedIdentityRequest.js"
|
|
|
6
6
|
import { ManagedIdentityIdType } from "../../utils/Constants.js";
|
|
7
7
|
import { ManagedIdentityTokenResponse } from "../../response/ManagedIdentityTokenResponse.js";
|
|
8
8
|
import { NodeStorage } from "../../cache/NodeStorage.js";
|
|
9
|
+
import { ManagedIdentityErrorCodes } from "../../error/ManagedIdentityError.js";
|
|
9
10
|
/**
|
|
10
11
|
* Managed Identity User Assigned Id Query Parameter Names
|
|
11
12
|
*/
|
|
@@ -17,18 +18,108 @@ export declare const ManagedIdentityUserAssignedIdQueryParameterNames: {
|
|
|
17
18
|
readonly MANAGED_IDENTITY_RESOURCE_ID_NON_IMDS: "mi_res_id";
|
|
18
19
|
};
|
|
19
20
|
export type ManagedIdentityUserAssignedIdQueryParameterNames = (typeof ManagedIdentityUserAssignedIdQueryParameterNames)[keyof typeof ManagedIdentityUserAssignedIdQueryParameterNames];
|
|
21
|
+
/**
|
|
22
|
+
* Base class for all Managed Identity sources. Provides common functionality for
|
|
23
|
+
* authenticating with Azure Managed Identity endpoints across different Azure services
|
|
24
|
+
* including IMDS, App Service, Azure Arc, Service Fabric, Cloud Shell, and Machine Learning.
|
|
25
|
+
*
|
|
26
|
+
* This abstract class handles token acquisition, response processing, and network communication
|
|
27
|
+
* while allowing concrete implementations to define source-specific request creation logic.
|
|
28
|
+
*/
|
|
20
29
|
export declare abstract class BaseManagedIdentitySource {
|
|
21
30
|
protected logger: Logger;
|
|
22
31
|
private nodeStorage;
|
|
23
32
|
private networkClient;
|
|
24
33
|
private cryptoProvider;
|
|
25
34
|
private disableInternalRetries;
|
|
35
|
+
/**
|
|
36
|
+
* Creates an instance of BaseManagedIdentitySource.
|
|
37
|
+
*
|
|
38
|
+
* @param logger - Logger instance for diagnostic information
|
|
39
|
+
* @param nodeStorage - Storage interface for caching tokens
|
|
40
|
+
* @param networkClient - Network client for making HTTP requests
|
|
41
|
+
* @param cryptoProvider - Cryptographic provider for token operations
|
|
42
|
+
* @param disableInternalRetries - Whether to disable automatic retry logic
|
|
43
|
+
*/
|
|
26
44
|
constructor(logger: Logger, nodeStorage: NodeStorage, networkClient: INetworkModule, cryptoProvider: CryptoProvider, disableInternalRetries: boolean);
|
|
27
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Creates a managed identity request with source-specific parameters.
|
|
47
|
+
* This method must be implemented by concrete managed identity sources to define
|
|
48
|
+
* how requests are constructed for their specific endpoint requirements.
|
|
49
|
+
*
|
|
50
|
+
* @param resource - The Azure resource URI for which the access token is requested (e.g., "https://vault.azure.net/")
|
|
51
|
+
* @param managedIdentityId - The managed identity configuration specifying system-assigned or user-assigned identity details
|
|
52
|
+
*
|
|
53
|
+
* @returns Request parameters configured for the specific managed identity source
|
|
54
|
+
*/
|
|
55
|
+
abstract createRequest(resource: string, managedIdentityId: ManagedIdentityId): ManagedIdentityRequestParameters;
|
|
56
|
+
/**
|
|
57
|
+
* Processes the network response and converts it to a standardized server token response.
|
|
58
|
+
* This async version allows for source-specific response processing logic while maintaining
|
|
59
|
+
* backward compatibility with the synchronous version.
|
|
60
|
+
*
|
|
61
|
+
* @param response - The network response containing the managed identity token
|
|
62
|
+
* @param _networkClient - Network client used for the request (unused in base implementation)
|
|
63
|
+
* @param _networkRequest - The original network request parameters (unused in base implementation)
|
|
64
|
+
* @param _networkRequestOptions - The network request options (unused in base implementation)
|
|
65
|
+
*
|
|
66
|
+
* @returns Promise resolving to a standardized server authorization token response
|
|
67
|
+
*/
|
|
28
68
|
getServerTokenResponseAsync(response: NetworkResponse<ManagedIdentityTokenResponse>, _networkClient: INetworkModule, _networkRequest: ManagedIdentityRequestParameters, _networkRequestOptions: NetworkRequestOptions): Promise<ServerAuthorizationTokenResponse>;
|
|
69
|
+
/**
|
|
70
|
+
* Converts a managed identity token response to a standardized server authorization token response.
|
|
71
|
+
* Handles time format conversion, expiration calculation, and error mapping to ensure
|
|
72
|
+
* compatibility with the MSAL response handling pipeline.
|
|
73
|
+
*
|
|
74
|
+
* @param response - The network response containing the managed identity token
|
|
75
|
+
*
|
|
76
|
+
* @returns Standardized server authorization token response with normalized fields
|
|
77
|
+
*/
|
|
29
78
|
getServerTokenResponse(response: NetworkResponse<ManagedIdentityTokenResponse>): ServerAuthorizationTokenResponse;
|
|
79
|
+
/**
|
|
80
|
+
* Acquires an access token using the managed identity endpoint for the specified resource.
|
|
81
|
+
* This is the primary method for token acquisition, handling the complete flow from
|
|
82
|
+
* request creation through response processing and token caching.
|
|
83
|
+
*
|
|
84
|
+
* @param managedIdentityRequest - The managed identity request containing resource and optional parameters
|
|
85
|
+
* @param managedIdentityId - The managed identity configuration (system or user-assigned)
|
|
86
|
+
* @param fakeAuthority - Authority instance used for token caching (managed identity uses a placeholder authority)
|
|
87
|
+
* @param refreshAccessToken - Whether this is a token refresh operation
|
|
88
|
+
*
|
|
89
|
+
* @returns Promise resolving to an authentication result containing the access token and metadata
|
|
90
|
+
*
|
|
91
|
+
* @throws {AuthError} When network requests fail or token validation fails
|
|
92
|
+
* @throws {ClientAuthError} When network errors occur during the request
|
|
93
|
+
*/
|
|
30
94
|
acquireTokenWithManagedIdentity(managedIdentityRequest: ManagedIdentityRequest, managedIdentityId: ManagedIdentityId, fakeAuthority: Authority, refreshAccessToken?: boolean): Promise<AuthenticationResult>;
|
|
95
|
+
/**
|
|
96
|
+
* Determines the appropriate query parameter name for user-assigned managed identity
|
|
97
|
+
* based on the identity type, API version, and endpoint characteristics.
|
|
98
|
+
* Different Azure services and API versions use different parameter names for the same identity types.
|
|
99
|
+
*
|
|
100
|
+
* @param managedIdentityIdType - The type of user-assigned managed identity (client ID, object ID, or resource ID)
|
|
101
|
+
* @param isImds - Whether the request is being made to the IMDS (Instance Metadata Service) endpoint
|
|
102
|
+
* @param usesApi2017 - Whether the endpoint uses the 2017-09-01 API version (affects client ID parameter name)
|
|
103
|
+
*
|
|
104
|
+
* @returns The correct query parameter name for the specified identity type and endpoint
|
|
105
|
+
*
|
|
106
|
+
* @throws {ManagedIdentityError} When an invalid managed identity ID type is provided
|
|
107
|
+
*/
|
|
31
108
|
getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityIdType: ManagedIdentityIdType, isImds?: boolean, usesApi2017?: boolean): string;
|
|
32
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Validates and normalizes an environment variable containing a URL string.
|
|
111
|
+
* This static utility method ensures that environment variables used for managed identity
|
|
112
|
+
* endpoints contain properly formatted URLs and provides informative error messages when validation fails.
|
|
113
|
+
*
|
|
114
|
+
* @param envVariableStringName - The name of the environment variable being validated (for error reporting)
|
|
115
|
+
* @param envVariable - The environment variable value containing the URL string
|
|
116
|
+
* @param sourceName - The name of the managed identity source (for error reporting)
|
|
117
|
+
* @param logger - Logger instance for diagnostic information
|
|
118
|
+
*
|
|
119
|
+
* @returns The validated and normalized URL string
|
|
120
|
+
*
|
|
121
|
+
* @throws {ManagedIdentityError} When the environment variable contains a malformed URL
|
|
122
|
+
*/
|
|
123
|
+
static getValidatedEnvVariableUrlString: (envVariableStringName: keyof typeof ManagedIdentityErrorCodes.MsiEnvironmentVariableUrlMalformedErrorCodes, envVariable: string, sourceName: string, logger: Logger) => string;
|
|
33
124
|
}
|
|
34
125
|
//# sourceMappingURL=BaseManagedIdentitySource.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseManagedIdentitySource.d.ts","sourceRoot":"","sources":["../../../src/client/ManagedIdentitySources/BaseManagedIdentitySource.ts"],"names":[],"mappings":"AAKA,OAAO,EAEH,SAAS,EAIT,cAAc,EACd,MAAM,EACN,qBAAqB,EACrB,eAAe,EAEf,gCAAgC,EAGhC,oBAAoB,EAEvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,gCAAgC,EAAE,MAAM,kDAAkD,CAAC;AACpG,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAEH,qBAAqB,EAExB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,4BAA4B,EAAE,MAAM,gDAAgD,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"BaseManagedIdentitySource.d.ts","sourceRoot":"","sources":["../../../src/client/ManagedIdentitySources/BaseManagedIdentitySource.ts"],"names":[],"mappings":"AAKA,OAAO,EAEH,SAAS,EAIT,cAAc,EACd,MAAM,EACN,qBAAqB,EACrB,eAAe,EAEf,gCAAgC,EAGhC,oBAAoB,EAEvB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,gCAAgC,EAAE,MAAM,kDAAkD,CAAC;AACpG,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AACjF,OAAO,EAEH,qBAAqB,EAExB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,4BAA4B,EAAE,MAAM,gDAAgD,CAAC;AAC9F,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EACH,yBAAyB,EAE5B,MAAM,qCAAqC,CAAC;AAI7C;;GAEG;AACH,eAAO,MAAM,gDAAgD;;;;;;CAMnD,CAAC;AACX,MAAM,MAAM,gDAAgD,GACxD,CAAC,OAAO,gDAAgD,CAAC,CAAC,MAAM,OAAO,gDAAgD,CAAC,CAAC;AAE7H;;;;;;;GAOG;AACH,8BAAsB,yBAAyB;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1
|
-
/*! @azure/msal-node v3.8.
|
|
1
|
+
/*! @azure/msal-node v3.8.1 2025-10-29 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { TimeUtils, Constants, HeaderNames, AuthError, createClientAuthError, ClientAuthErrorCodes, ResponseHandler, UrlString } from '@azure/msal-common/node';
|
|
4
4
|
import { ManagedIdentityQueryParameters, HttpMethod, ManagedIdentityIdType } from '../../utils/Constants.mjs';
|
|
@@ -21,7 +21,24 @@ const ManagedIdentityUserAssignedIdQueryParameterNames = {
|
|
|
21
21
|
MANAGED_IDENTITY_RESOURCE_ID_IMDS: "msi_res_id",
|
|
22
22
|
MANAGED_IDENTITY_RESOURCE_ID_NON_IMDS: "mi_res_id",
|
|
23
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Base class for all Managed Identity sources. Provides common functionality for
|
|
26
|
+
* authenticating with Azure Managed Identity endpoints across different Azure services
|
|
27
|
+
* including IMDS, App Service, Azure Arc, Service Fabric, Cloud Shell, and Machine Learning.
|
|
28
|
+
*
|
|
29
|
+
* This abstract class handles token acquisition, response processing, and network communication
|
|
30
|
+
* while allowing concrete implementations to define source-specific request creation logic.
|
|
31
|
+
*/
|
|
24
32
|
class BaseManagedIdentitySource {
|
|
33
|
+
/**
|
|
34
|
+
* Creates an instance of BaseManagedIdentitySource.
|
|
35
|
+
*
|
|
36
|
+
* @param logger - Logger instance for diagnostic information
|
|
37
|
+
* @param nodeStorage - Storage interface for caching tokens
|
|
38
|
+
* @param networkClient - Network client for making HTTP requests
|
|
39
|
+
* @param cryptoProvider - Cryptographic provider for token operations
|
|
40
|
+
* @param disableInternalRetries - Whether to disable automatic retry logic
|
|
41
|
+
*/
|
|
25
42
|
constructor(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries) {
|
|
26
43
|
this.logger = logger;
|
|
27
44
|
this.nodeStorage = nodeStorage;
|
|
@@ -29,6 +46,18 @@ class BaseManagedIdentitySource {
|
|
|
29
46
|
this.cryptoProvider = cryptoProvider;
|
|
30
47
|
this.disableInternalRetries = disableInternalRetries;
|
|
31
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Processes the network response and converts it to a standardized server token response.
|
|
51
|
+
* This async version allows for source-specific response processing logic while maintaining
|
|
52
|
+
* backward compatibility with the synchronous version.
|
|
53
|
+
*
|
|
54
|
+
* @param response - The network response containing the managed identity token
|
|
55
|
+
* @param _networkClient - Network client used for the request (unused in base implementation)
|
|
56
|
+
* @param _networkRequest - The original network request parameters (unused in base implementation)
|
|
57
|
+
* @param _networkRequestOptions - The network request options (unused in base implementation)
|
|
58
|
+
*
|
|
59
|
+
* @returns Promise resolving to a standardized server authorization token response
|
|
60
|
+
*/
|
|
32
61
|
async getServerTokenResponseAsync(response,
|
|
33
62
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
34
63
|
_networkClient,
|
|
@@ -38,6 +67,15 @@ class BaseManagedIdentitySource {
|
|
|
38
67
|
_networkRequestOptions) {
|
|
39
68
|
return this.getServerTokenResponse(response);
|
|
40
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Converts a managed identity token response to a standardized server authorization token response.
|
|
72
|
+
* Handles time format conversion, expiration calculation, and error mapping to ensure
|
|
73
|
+
* compatibility with the MSAL response handling pipeline.
|
|
74
|
+
*
|
|
75
|
+
* @param response - The network response containing the managed identity token
|
|
76
|
+
*
|
|
77
|
+
* @returns Standardized server authorization token response with normalized fields
|
|
78
|
+
*/
|
|
41
79
|
getServerTokenResponse(response) {
|
|
42
80
|
let refreshIn, expiresIn;
|
|
43
81
|
if (response.body.expires_on) {
|
|
@@ -75,6 +113,21 @@ class BaseManagedIdentitySource {
|
|
|
75
113
|
};
|
|
76
114
|
return serverTokenResponse;
|
|
77
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Acquires an access token using the managed identity endpoint for the specified resource.
|
|
118
|
+
* This is the primary method for token acquisition, handling the complete flow from
|
|
119
|
+
* request creation through response processing and token caching.
|
|
120
|
+
*
|
|
121
|
+
* @param managedIdentityRequest - The managed identity request containing resource and optional parameters
|
|
122
|
+
* @param managedIdentityId - The managed identity configuration (system or user-assigned)
|
|
123
|
+
* @param fakeAuthority - Authority instance used for token caching (managed identity uses a placeholder authority)
|
|
124
|
+
* @param refreshAccessToken - Whether this is a token refresh operation
|
|
125
|
+
*
|
|
126
|
+
* @returns Promise resolving to an authentication result containing the access token and metadata
|
|
127
|
+
*
|
|
128
|
+
* @throws {AuthError} When network requests fail or token validation fails
|
|
129
|
+
* @throws {ClientAuthError} When network errors occur during the request
|
|
130
|
+
*/
|
|
78
131
|
async acquireTokenWithManagedIdentity(managedIdentityRequest, managedIdentityId, fakeAuthority, refreshAccessToken) {
|
|
79
132
|
const networkRequest = this.createRequest(managedIdentityRequest.resource, managedIdentityId);
|
|
80
133
|
if (managedIdentityRequest.revokedTokenSha256Hash) {
|
|
@@ -129,6 +182,19 @@ class BaseManagedIdentitySource {
|
|
|
129
182
|
// caches the token
|
|
130
183
|
return responseHandler.handleServerTokenResponse(serverTokenResponse, fakeAuthority, reqTimestamp, managedIdentityRequest);
|
|
131
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Determines the appropriate query parameter name for user-assigned managed identity
|
|
187
|
+
* based on the identity type, API version, and endpoint characteristics.
|
|
188
|
+
* Different Azure services and API versions use different parameter names for the same identity types.
|
|
189
|
+
*
|
|
190
|
+
* @param managedIdentityIdType - The type of user-assigned managed identity (client ID, object ID, or resource ID)
|
|
191
|
+
* @param isImds - Whether the request is being made to the IMDS (Instance Metadata Service) endpoint
|
|
192
|
+
* @param usesApi2017 - Whether the endpoint uses the 2017-09-01 API version (affects client ID parameter name)
|
|
193
|
+
*
|
|
194
|
+
* @returns The correct query parameter name for the specified identity type and endpoint
|
|
195
|
+
*
|
|
196
|
+
* @throws {ManagedIdentityError} When an invalid managed identity ID type is provided
|
|
197
|
+
*/
|
|
132
198
|
getManagedIdentityUserAssignedIdQueryParameterKey(managedIdentityIdType, isImds, usesApi2017) {
|
|
133
199
|
switch (managedIdentityIdType) {
|
|
134
200
|
case ManagedIdentityIdType.USER_ASSIGNED_CLIENT_ID:
|
|
@@ -150,6 +216,20 @@ class BaseManagedIdentitySource {
|
|
|
150
216
|
}
|
|
151
217
|
}
|
|
152
218
|
}
|
|
219
|
+
/**
|
|
220
|
+
* Validates and normalizes an environment variable containing a URL string.
|
|
221
|
+
* This static utility method ensures that environment variables used for managed identity
|
|
222
|
+
* endpoints contain properly formatted URLs and provides informative error messages when validation fails.
|
|
223
|
+
*
|
|
224
|
+
* @param envVariableStringName - The name of the environment variable being validated (for error reporting)
|
|
225
|
+
* @param envVariable - The environment variable value containing the URL string
|
|
226
|
+
* @param sourceName - The name of the managed identity source (for error reporting)
|
|
227
|
+
* @param logger - Logger instance for diagnostic information
|
|
228
|
+
*
|
|
229
|
+
* @returns The validated and normalized URL string
|
|
230
|
+
*
|
|
231
|
+
* @throws {ManagedIdentityError} When the environment variable contains a malformed URL
|
|
232
|
+
*/
|
|
153
233
|
BaseManagedIdentitySource.getValidatedEnvVariableUrlString = (envVariableStringName, envVariable, sourceName, logger) => {
|
|
154
234
|
try {
|
|
155
235
|
return new UrlString(envVariable).urlString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseManagedIdentitySource.mjs","sources":["../../../src/client/ManagedIdentitySources/BaseManagedIdentitySource.ts"],"sourcesContent":[null],"names":["ManagedIdentityErrorCodes.invalidManagedIdentityIdType","ManagedIdentityErrorCodes\r\n .MsiEnvironmentVariableUrlMalformedErrorCodes"],"mappings":";;;;;;;;;AAAA;;;AAGG;AAqCH;;AAEG;AACU,MAAA,gDAAgD,GAAG;AAC5D,IAAA,+BAA+B,EAAE,UAAU;AAC3C,IAAA,0BAA0B,EAAE,WAAW;AACvC,IAAA,0BAA0B,EAAE,WAAW;AACvC,IAAA,iCAAiC,EAAE,YAAY;AAC/C,IAAA,qCAAqC,EAAE,WAAW;EAC3C;
|
|
1
|
+
{"version":3,"file":"BaseManagedIdentitySource.mjs","sources":["../../../src/client/ManagedIdentitySources/BaseManagedIdentitySource.ts"],"sourcesContent":[null],"names":["ManagedIdentityErrorCodes.invalidManagedIdentityIdType","ManagedIdentityErrorCodes\r\n .MsiEnvironmentVariableUrlMalformedErrorCodes"],"mappings":";;;;;;;;;AAAA;;;AAGG;AAqCH;;AAEG;AACU,MAAA,gDAAgD,GAAG;AAC5D,IAAA,+BAA+B,EAAE,UAAU;AAC3C,IAAA,0BAA0B,EAAE,WAAW;AACvC,IAAA,0BAA0B,EAAE,WAAW;AACvC,IAAA,iCAAiC,EAAE,YAAY;AAC/C,IAAA,qCAAqC,EAAE,WAAW;EAC3C;AAIX;;;;;;;AAOG;MACmB,yBAAyB,CAAA;AAO3C;;;;;;;;AAQG;IACH,WACI,CAAA,MAAc,EACd,WAAwB,EACxB,aAA6B,EAC7B,cAA8B,EAC9B,sBAA+B,EAAA;AAE/B,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;AACrC,QAAA,IAAI,CAAC,sBAAsB,GAAG,sBAAsB,CAAC;KACxD;AAiBD;;;;;;;;;;;AAWG;IACI,MAAM,2BAA2B,CACpC,QAAuD;;IAEvD,cAA8B;;IAE9B,eAAiD;;IAEjD,sBAA6C,EAAA;AAE7C,QAAA,OAAO,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC;KAChD;AAED;;;;;;;;AAQG;AACI,IAAA,sBAAsB,CACzB,QAAuD,EAAA;QAEvD,IAAI,SAAS,EAAE,SAA6B,CAAC;AAC7C,QAAA,IAAI,QAAQ,CAAC,IAAI,CAAC,UAAU,EAAE;;YAE1B,IAAI,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE;gBACrC,QAAQ,CAAC,IAAI,CAA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EAAA,qBAAqB,CAAsC,oCAAA,CAAA,CAC/I,CAAC;QAEF,MAAM,0BAA0B,CAC5BC,4CACiD,CAC7C,qBAAqB,CACxB,CACJ,CAAC;AACL,KAAA;AACL,CAAC;;;;"}
|
|
@@ -5,13 +5,67 @@ import { NodeStorage } from "../../cache/NodeStorage.js";
|
|
|
5
5
|
import { CryptoProvider } from "../../crypto/CryptoProvider.js";
|
|
6
6
|
import { ManagedIdentityId } from "../../config/ManagedIdentityId.js";
|
|
7
7
|
/**
|
|
8
|
+
* Azure Cloud Shell managed identity source implementation.
|
|
9
|
+
*
|
|
10
|
+
* This class handles authentication for applications running in Azure Cloud Shell environment.
|
|
11
|
+
* Cloud Shell provides a browser-accessible shell for managing Azure resources and includes
|
|
12
|
+
* a pre-configured managed identity for authentication.
|
|
13
|
+
*
|
|
8
14
|
* Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/CloudShellManagedIdentitySource.cs
|
|
9
15
|
*/
|
|
10
16
|
export declare class CloudShell extends BaseManagedIdentitySource {
|
|
11
17
|
private msiEndpoint;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new CloudShell managed identity source instance.
|
|
20
|
+
*
|
|
21
|
+
* @param logger - Logger instance for diagnostic logging
|
|
22
|
+
* @param nodeStorage - Node.js storage implementation for caching
|
|
23
|
+
* @param networkClient - HTTP client for making requests to the managed identity endpoint
|
|
24
|
+
* @param cryptoProvider - Cryptographic operations provider
|
|
25
|
+
* @param disableInternalRetries - Whether to disable automatic retry logic for failed requests
|
|
26
|
+
* @param msiEndpoint - The MSI endpoint URL obtained from environment variables
|
|
27
|
+
*/
|
|
12
28
|
constructor(logger: Logger, nodeStorage: NodeStorage, networkClient: INetworkModule, cryptoProvider: CryptoProvider, disableInternalRetries: boolean, msiEndpoint: string);
|
|
29
|
+
/**
|
|
30
|
+
* Retrieves the required environment variables for Cloud Shell managed identity.
|
|
31
|
+
*
|
|
32
|
+
* Cloud Shell requires the MSI_ENDPOINT environment variable to be set, which
|
|
33
|
+
* contains the URL of the managed identity service endpoint.
|
|
34
|
+
*
|
|
35
|
+
* @returns An array containing the MSI_ENDPOINT environment variable value (or undefined if not set)
|
|
36
|
+
*/
|
|
13
37
|
static getEnvironmentVariables(): Array<string | undefined>;
|
|
38
|
+
/**
|
|
39
|
+
* Attempts to create a CloudShell managed identity source instance.
|
|
40
|
+
*
|
|
41
|
+
* This method validates that the required environment variables are present and
|
|
42
|
+
* creates a CloudShell instance if the environment is properly configured.
|
|
43
|
+
* Cloud Shell only supports system-assigned managed identities.
|
|
44
|
+
*
|
|
45
|
+
* @param logger - Logger instance for diagnostic logging
|
|
46
|
+
* @param nodeStorage - Node.js storage implementation for caching
|
|
47
|
+
* @param networkClient - HTTP client for making requests
|
|
48
|
+
* @param cryptoProvider - Cryptographic operations provider
|
|
49
|
+
* @param disableInternalRetries - Whether to disable automatic retry logic
|
|
50
|
+
* @param managedIdentityId - The managed identity configuration (must be system-assigned)
|
|
51
|
+
*
|
|
52
|
+
* @returns A CloudShell instance if the environment is valid, null otherwise
|
|
53
|
+
*
|
|
54
|
+
* @throws {ManagedIdentityError} When a user-assigned managed identity is requested,
|
|
55
|
+
* as Cloud Shell only supports system-assigned identities
|
|
56
|
+
*/
|
|
14
57
|
static tryCreate(logger: Logger, nodeStorage: NodeStorage, networkClient: INetworkModule, cryptoProvider: CryptoProvider, disableInternalRetries: boolean, managedIdentityId: ManagedIdentityId): CloudShell | null;
|
|
58
|
+
/**
|
|
59
|
+
* Creates an HTTP request to acquire an access token from the Cloud Shell managed identity endpoint.
|
|
60
|
+
*
|
|
61
|
+
* This method constructs a POST request to the MSI endpoint with the required headers and
|
|
62
|
+
* body parameters for Cloud Shell authentication. The request includes the target resource
|
|
63
|
+
* for which the access token is being requested.
|
|
64
|
+
*
|
|
65
|
+
* @param resource - The target resource/scope for which to request an access token (e.g., "https://graph.microsoft.com/.default")
|
|
66
|
+
*
|
|
67
|
+
* @returns A configured ManagedIdentityRequestParameters object ready for network execution
|
|
68
|
+
*/
|
|
15
69
|
createRequest(resource: string): ManagedIdentityRequestParameters;
|
|
16
70
|
}
|
|
17
71
|
//# sourceMappingURL=CloudShell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudShell.d.ts","sourceRoot":"","sources":["../../../src/client/ManagedIdentitySources/CloudShell.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,gCAAgC,EAAE,MAAM,kDAAkD,CAAC;AACpG,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAahE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE
|
|
1
|
+
{"version":3,"file":"CloudShell.d.ts","sourceRoot":"","sources":["../../../src/client/ManagedIdentitySources/CloudShell.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,gCAAgC,EAAE,MAAM,kDAAkD,CAAC;AACpG,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAahE,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAEtE;;;;;;;;GAQG;AACH,qBAAa,UAAW,SAAQ,yBAAyB;IACrD,OAAO,CAAC,WAAW,CAAS;IAE5B;;;;;;;;;OASG;gBAEC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,cAAc,EAC7B,cAAc,EAAE,cAAc,EAC9B,sBAAsB,EAAE,OAAO,EAC/B,WAAW,EAAE,MAAM;IAavB;;;;;;;OAOG;WACW,uBAAuB,IAAI,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC;IAOlE;;;;;;;;;;;;;;;;;;OAkBG;WACW,SAAS,CACnB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,cAAc,EAC7B,cAAc,EAAE,cAAc,EAC9B,sBAAsB,EAAE,OAAO,EAC/B,iBAAiB,EAAE,iBAAiB,GACrC,UAAU,GAAG,IAAI;IAyCpB;;;;;;;;;;OAUG;IACI,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,gCAAgC;CAc3E"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-node v3.8.
|
|
1
|
+
/*! @azure/msal-node v3.8.1 2025-10-29 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { ManagedIdentityRequestParameters } from '../../config/ManagedIdentityRequestParameters.mjs';
|
|
4
4
|
import { BaseManagedIdentitySource } from './BaseManagedIdentitySource.mjs';
|
|
@@ -11,17 +11,60 @@ import { unableToCreateCloudShell } from '../../error/ManagedIdentityErrorCodes.
|
|
|
11
11
|
* Licensed under the MIT License.
|
|
12
12
|
*/
|
|
13
13
|
/**
|
|
14
|
+
* Azure Cloud Shell managed identity source implementation.
|
|
15
|
+
*
|
|
16
|
+
* This class handles authentication for applications running in Azure Cloud Shell environment.
|
|
17
|
+
* Cloud Shell provides a browser-accessible shell for managing Azure resources and includes
|
|
18
|
+
* a pre-configured managed identity for authentication.
|
|
19
|
+
*
|
|
14
20
|
* Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/CloudShellManagedIdentitySource.cs
|
|
15
21
|
*/
|
|
16
22
|
class CloudShell extends BaseManagedIdentitySource {
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new CloudShell managed identity source instance.
|
|
25
|
+
*
|
|
26
|
+
* @param logger - Logger instance for diagnostic logging
|
|
27
|
+
* @param nodeStorage - Node.js storage implementation for caching
|
|
28
|
+
* @param networkClient - HTTP client for making requests to the managed identity endpoint
|
|
29
|
+
* @param cryptoProvider - Cryptographic operations provider
|
|
30
|
+
* @param disableInternalRetries - Whether to disable automatic retry logic for failed requests
|
|
31
|
+
* @param msiEndpoint - The MSI endpoint URL obtained from environment variables
|
|
32
|
+
*/
|
|
17
33
|
constructor(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, msiEndpoint) {
|
|
18
34
|
super(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries);
|
|
19
35
|
this.msiEndpoint = msiEndpoint;
|
|
20
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Retrieves the required environment variables for Cloud Shell managed identity.
|
|
39
|
+
*
|
|
40
|
+
* Cloud Shell requires the MSI_ENDPOINT environment variable to be set, which
|
|
41
|
+
* contains the URL of the managed identity service endpoint.
|
|
42
|
+
*
|
|
43
|
+
* @returns An array containing the MSI_ENDPOINT environment variable value (or undefined if not set)
|
|
44
|
+
*/
|
|
21
45
|
static getEnvironmentVariables() {
|
|
22
46
|
const msiEndpoint = process.env[ManagedIdentityEnvironmentVariableNames.MSI_ENDPOINT];
|
|
23
47
|
return [msiEndpoint];
|
|
24
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Attempts to create a CloudShell managed identity source instance.
|
|
51
|
+
*
|
|
52
|
+
* This method validates that the required environment variables are present and
|
|
53
|
+
* creates a CloudShell instance if the environment is properly configured.
|
|
54
|
+
* Cloud Shell only supports system-assigned managed identities.
|
|
55
|
+
*
|
|
56
|
+
* @param logger - Logger instance for diagnostic logging
|
|
57
|
+
* @param nodeStorage - Node.js storage implementation for caching
|
|
58
|
+
* @param networkClient - HTTP client for making requests
|
|
59
|
+
* @param cryptoProvider - Cryptographic operations provider
|
|
60
|
+
* @param disableInternalRetries - Whether to disable automatic retry logic
|
|
61
|
+
* @param managedIdentityId - The managed identity configuration (must be system-assigned)
|
|
62
|
+
*
|
|
63
|
+
* @returns A CloudShell instance if the environment is valid, null otherwise
|
|
64
|
+
*
|
|
65
|
+
* @throws {ManagedIdentityError} When a user-assigned managed identity is requested,
|
|
66
|
+
* as Cloud Shell only supports system-assigned identities
|
|
67
|
+
*/
|
|
25
68
|
static tryCreate(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, managedIdentityId) {
|
|
26
69
|
const [msiEndpoint] = CloudShell.getEnvironmentVariables();
|
|
27
70
|
// if the msi endpoint environment variable is undefined, this MSI provider is unavailable.
|
|
@@ -36,6 +79,17 @@ class CloudShell extends BaseManagedIdentitySource {
|
|
|
36
79
|
}
|
|
37
80
|
return new CloudShell(logger, nodeStorage, networkClient, cryptoProvider, disableInternalRetries, msiEndpoint);
|
|
38
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Creates an HTTP request to acquire an access token from the Cloud Shell managed identity endpoint.
|
|
84
|
+
*
|
|
85
|
+
* This method constructs a POST request to the MSI endpoint with the required headers and
|
|
86
|
+
* body parameters for Cloud Shell authentication. The request includes the target resource
|
|
87
|
+
* for which the access token is being requested.
|
|
88
|
+
*
|
|
89
|
+
* @param resource - The target resource/scope for which to request an access token (e.g., "https://graph.microsoft.com/.default")
|
|
90
|
+
*
|
|
91
|
+
* @returns A configured ManagedIdentityRequestParameters object ready for network execution
|
|
92
|
+
*/
|
|
39
93
|
createRequest(resource) {
|
|
40
94
|
const request = new ManagedIdentityRequestParameters(HttpMethod.POST, this.msiEndpoint);
|
|
41
95
|
request.headers[ManagedIdentityHeaders.METADATA_HEADER_NAME] = "true";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudShell.mjs","sources":["../../../src/client/ManagedIdentitySources/CloudShell.ts"],"sourcesContent":[null],"names":["ManagedIdentityErrorCodes.unableToCreateCloudShell"],"mappings":";;;;;;;;AAAA;;;AAGG;AAqBH
|
|
1
|
+
{"version":3,"file":"CloudShell.mjs","sources":["../../../src/client/ManagedIdentitySources/CloudShell.ts"],"sources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,oBAAoB,cAAc,0BAA0B,CAAC,WAAW,CAAA,kBAAA,CAAoB,CAC1O,CAAC;AAEF,QAAA,IACI,iBAAiB,CAAC,MAAM,KAAK,qBAAqB,CAAC,eAAe,EACpE;AACE,YAAA,MAAM,0BAA0B,CAC5BA,wBAAkD,CACrD,CAAC;AACL,SAAA;AAED,QAAA,OAAO,IAAI,UAAU,CACjB,MAAM,EACN,WAAW,EACX,aAAa,EACb,cAAc,EACd,sBAAsB,EACtB,WAAW,CACd,CAAC;KACL;AAED;;;;;;;;;;AAUG;AACI,IAAA,aAAa,CAAC,QAAgB,EAAA;AACjC,QAAA,MAAM,OAAO,GACT,IAAI,gCAAgC,CAChC,UAAU,CAAC,IAAI,EACf,IAAI,CAAC,WAAW,CACnB,CAAC;QAEN,OAAO,CAAC,OAAO,CAAC,sBAAsB,CAAC,oBAAoB,CAAC,GAAG,MAAM,CAAC;AAEtE,QAAA,OAAO,CAAC,cAAc,CAAC,8BAA8B,CAAC,QAAQ,CAAC;AAC3D,YAAA,QAAQ,CAAC;AAEb,QAAA,OAAO,OAAO,CAAC;KAClB;AACJ;;;;"}
|
|
@@ -5,40 +5,62 @@ import { BaseManagedIdentitySource } from "./BaseManagedIdentitySource.js";
|
|
|
5
5
|
import { CryptoProvider } from "../../crypto/CryptoProvider.js";
|
|
6
6
|
import { NodeStorage } from "../../cache/NodeStorage.js";
|
|
7
7
|
/**
|
|
8
|
+
* Managed Identity source implementation for Azure Instance Metadata Service (IMDS).
|
|
9
|
+
*
|
|
10
|
+
* IMDS is available on Azure Virtual Machines and Virtual Machine Scale Sets and provides
|
|
11
|
+
* a REST endpoint to obtain OAuth tokens for managed identities. This implementation
|
|
12
|
+
* handles both system-assigned and user-assigned managed identities.
|
|
13
|
+
*
|
|
8
14
|
* Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/ImdsManagedIdentitySource.cs
|
|
9
15
|
*/
|
|
10
16
|
export declare class Imds extends BaseManagedIdentitySource {
|
|
11
17
|
private identityEndpoint;
|
|
12
18
|
/**
|
|
13
|
-
* Constructs an Imds instance.
|
|
14
|
-
*
|
|
15
|
-
* @param
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
18
|
-
* @param
|
|
19
|
-
* @param
|
|
19
|
+
* Constructs an Imds instance with the specified configuration.
|
|
20
|
+
*
|
|
21
|
+
* @param logger - Logger instance for recording debug information and errors
|
|
22
|
+
* @param nodeStorage - NodeStorage instance used for token caching operations
|
|
23
|
+
* @param networkClient - Network client implementation for making HTTP requests to IMDS
|
|
24
|
+
* @param cryptoProvider - CryptoProvider for generating correlation IDs and other cryptographic operations
|
|
25
|
+
* @param disableInternalRetries - When true, disables the built-in retry logic for IMDS requests
|
|
26
|
+
* @param identityEndpoint - The complete IMDS endpoint URL including the token path
|
|
20
27
|
*/
|
|
21
28
|
constructor(logger: Logger, nodeStorage: NodeStorage, networkClient: INetworkModule, cryptoProvider: CryptoProvider, disableInternalRetries: boolean, identityEndpoint: string);
|
|
22
29
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* @param
|
|
31
|
-
* @param
|
|
32
|
-
* @
|
|
30
|
+
* Creates an Imds instance with the appropriate endpoint configuration.
|
|
31
|
+
*
|
|
32
|
+
* This method checks for the presence of the AZURE_POD_IDENTITY_AUTHORITY_HOST environment
|
|
33
|
+
* variable, which is used in Azure Kubernetes Service (AKS) environments with Azure AD
|
|
34
|
+
* Pod Identity. If found, it uses that endpoint; otherwise, it falls back to the standard
|
|
35
|
+
* IMDS endpoint (169.254.169.254).
|
|
36
|
+
*
|
|
37
|
+
* @param logger - Logger instance for recording endpoint discovery and validation
|
|
38
|
+
* @param nodeStorage - NodeStorage instance for token caching
|
|
39
|
+
* @param networkClient - Network client for HTTP requests
|
|
40
|
+
* @param cryptoProvider - CryptoProvider for cryptographic operations
|
|
41
|
+
* @param disableInternalRetries - Whether to disable built-in retry logic
|
|
42
|
+
*
|
|
43
|
+
* @returns A configured Imds instance ready to make token requests
|
|
33
44
|
*/
|
|
34
45
|
static tryCreate(logger: Logger, nodeStorage: NodeStorage, networkClient: INetworkModule, cryptoProvider: CryptoProvider, disableInternalRetries: boolean): Imds;
|
|
35
46
|
/**
|
|
36
|
-
* Creates a
|
|
37
|
-
*
|
|
47
|
+
* Creates a properly configured HTTP request for acquiring an access token from IMDS.
|
|
48
|
+
*
|
|
49
|
+
* This method builds a complete request object with all necessary headers, query parameters,
|
|
50
|
+
* and retry policies required by the Azure Instance Metadata Service.
|
|
51
|
+
*
|
|
52
|
+
* Key request components:
|
|
53
|
+
* - HTTP GET method to the IMDS token endpoint
|
|
54
|
+
* - Metadata header set to "true" (required by IMDS)
|
|
55
|
+
* - API version parameter (currently "2018-02-01")
|
|
56
|
+
* - Resource parameter specifying the target audience
|
|
57
|
+
* - Identity-specific parameters for user-assigned managed identities
|
|
58
|
+
* - IMDS-specific retry policy
|
|
59
|
+
*
|
|
60
|
+
* @param resource - The target resource/scope for which to request an access token (e.g., "https://graph.microsoft.com/.default")
|
|
61
|
+
* @param managedIdentityId - The managed identity configuration specifying whether to use system-assigned or user-assigned identity
|
|
38
62
|
*
|
|
39
|
-
* @
|
|
40
|
-
* @param managedIdentityId - The managed identity ID (system-assigned or user-assigned).
|
|
41
|
-
* @returns A ManagedIdentityRequestParameters object configured for IMDS.
|
|
63
|
+
* @returns A configured ManagedIdentityRequestParameters object ready for network execution
|
|
42
64
|
*/
|
|
43
65
|
createRequest(resource: string, managedIdentityId: ManagedIdentityId): ManagedIdentityRequestParameters;
|
|
44
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Imds.d.ts","sourceRoot":"","sources":["../../../src/client/ManagedIdentitySources/Imds.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,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