@azure/msal-node 3.5.3 → 3.6.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/NodeStorage.d.ts.map +1 -1
- package/dist/cache/NodeStorage.mjs +3 -2
- package/dist/cache/NodeStorage.mjs.map +1 -1
- package/dist/cache/TokenCache.d.ts +1 -1
- package/dist/cache/TokenCache.d.ts.map +1 -1
- package/dist/cache/TokenCache.mjs +4 -3
- package/dist/cache/TokenCache.mjs.map +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.d.ts.map +1 -1
- package/dist/client/ClientAssertion.mjs +3 -3
- package/dist/client/ClientAssertion.mjs.map +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.d.ts +11 -0
- package/dist/client/ManagedIdentityApplication.d.ts.map +1 -1
- package/dist/client/ManagedIdentityApplication.mjs +46 -11
- package/dist/client/ManagedIdentityApplication.mjs.map +1 -1
- package/dist/client/ManagedIdentityClient.mjs +1 -1
- package/dist/client/ManagedIdentitySources/AppService.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/AppService.mjs +6 -5
- package/dist/client/ManagedIdentitySources/AppService.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/AzureArc.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/AzureArc.mjs +8 -8
- package/dist/client/ManagedIdentitySources/AzureArc.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs +11 -2
- package/dist/client/ManagedIdentitySources/BaseManagedIdentitySource.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/CloudShell.mjs +4 -4
- package/dist/client/ManagedIdentitySources/CloudShell.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/Imds.d.ts +32 -0
- package/dist/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/Imds.mjs +39 -8
- package/dist/client/ManagedIdentitySources/Imds.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/MachineLearning.d.ts +1 -0
- package/dist/client/ManagedIdentitySources/MachineLearning.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/MachineLearning.mjs +19 -9
- package/dist/client/ManagedIdentitySources/MachineLearning.mjs.map +1 -1
- package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts +30 -0
- package/dist/client/ManagedIdentitySources/ServiceFabric.d.ts.map +1 -1
- package/dist/client/ManagedIdentitySources/ServiceFabric.mjs +36 -10
- package/dist/client/ManagedIdentitySources/ServiceFabric.mjs.map +1 -1
- package/dist/client/OnBehalfOfClient.mjs +1 -1
- package/dist/client/PublicClientApplication.d.ts.map +1 -1
- package/dist/client/PublicClientApplication.mjs +2 -2
- package/dist/client/PublicClientApplication.mjs.map +1 -1
- package/dist/client/UsernamePasswordClient.mjs +1 -1
- package/dist/config/Configuration.d.ts +4 -2
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.mjs +3 -2
- package/dist/config/Configuration.mjs.map +1 -1
- package/dist/config/ManagedIdentityId.mjs +1 -1
- package/dist/config/ManagedIdentityRequestParameters.mjs +1 -1
- package/dist/crypto/CryptoProvider.d.ts +1 -1
- package/dist/crypto/CryptoProvider.d.ts.map +1 -1
- package/dist/crypto/CryptoProvider.mjs +3 -2
- package/dist/crypto/CryptoProvider.mjs.map +1 -1
- package/dist/crypto/GuidGenerator.mjs +1 -1
- package/dist/crypto/HashUtils.mjs +1 -1
- package/dist/crypto/PkceGenerator.d.ts.map +1 -1
- package/dist/crypto/PkceGenerator.mjs +3 -3
- package/dist/crypto/PkceGenerator.mjs.map +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/request/ManagedIdentityRequest.d.ts +6 -3
- package/dist/request/ManagedIdentityRequest.d.ts.map +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.d.ts +21 -6
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.mjs +21 -8
- package/dist/utils/Constants.mjs.map +1 -1
- package/dist/utils/EncodingUtils.mjs +4 -4
- package/dist/utils/EncodingUtils.mjs.map +1 -1
- package/dist/utils/NetworkUtils.mjs +1 -1
- package/dist/utils/TimeUtils.mjs +1 -1
- package/lib/msal-node.cjs +1120 -913
- package/lib/msal-node.cjs.map +1 -1
- package/lib/types/cache/NodeStorage.d.ts.map +1 -1
- package/lib/types/cache/TokenCache.d.ts +1 -1
- package/lib/types/cache/TokenCache.d.ts.map +1 -1
- package/lib/types/client/ClientAssertion.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentityApplication.d.ts +11 -0
- package/lib/types/client/ManagedIdentityApplication.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/AppService.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/AzureArc.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/BaseManagedIdentitySource.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/Imds.d.ts +32 -0
- package/lib/types/client/ManagedIdentitySources/Imds.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/MachineLearning.d.ts +1 -0
- package/lib/types/client/ManagedIdentitySources/MachineLearning.d.ts.map +1 -1
- package/lib/types/client/ManagedIdentitySources/ServiceFabric.d.ts +30 -0
- package/lib/types/client/ManagedIdentitySources/ServiceFabric.d.ts.map +1 -1
- package/lib/types/client/PublicClientApplication.d.ts.map +1 -1
- package/lib/types/config/Configuration.d.ts +4 -2
- package/lib/types/config/Configuration.d.ts.map +1 -1
- package/lib/types/crypto/CryptoProvider.d.ts +1 -1
- package/lib/types/crypto/CryptoProvider.d.ts.map +1 -1
- package/lib/types/crypto/PkceGenerator.d.ts.map +1 -1
- package/lib/types/packageMetadata.d.ts +1 -1
- package/lib/types/request/ManagedIdentityRequest.d.ts +6 -3
- package/lib/types/request/ManagedIdentityRequest.d.ts.map +1 -1
- package/lib/types/utils/Constants.d.ts +21 -6
- package/lib/types/utils/Constants.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/cache/NodeStorage.ts +8 -1
- package/src/cache/TokenCache.ts +8 -3
- package/src/client/ClientAssertion.ts +2 -1
- package/src/client/ManagedIdentityApplication.ts +71 -10
- package/src/client/ManagedIdentitySources/AppService.ts +6 -6
- package/src/client/ManagedIdentitySources/AzureArc.ts +10 -9
- package/src/client/ManagedIdentitySources/BaseManagedIdentitySource.ts +28 -1
- package/src/client/ManagedIdentitySources/CloudShell.ts +4 -4
- package/src/client/ManagedIdentitySources/Imds.ts +40 -10
- package/src/client/ManagedIdentitySources/MachineLearning.ts +28 -10
- package/src/client/ManagedIdentitySources/ServiceFabric.ts +36 -11
- package/src/client/PublicClientApplication.ts +4 -1
- package/src/config/Configuration.ts +5 -1
- package/src/crypto/CryptoProvider.ts +4 -4
- package/src/crypto/PkceGenerator.ts +3 -3
- package/src/packageMetadata.ts +1 -1
- package/src/request/ManagedIdentityRequest.ts +6 -3
- package/src/utils/Constants.ts +25 -6
- package/src/utils/EncodingUtils.ts +3 -3
|
@@ -7,12 +7,11 @@ import { INetworkModule, Logger } from "@azure/msal-common/node";
|
|
|
7
7
|
import { BaseManagedIdentitySource } from "./BaseManagedIdentitySource.js";
|
|
8
8
|
import {
|
|
9
9
|
HttpMethod,
|
|
10
|
-
APP_SERVICE_SECRET_HEADER_NAME,
|
|
11
|
-
API_VERSION_QUERY_PARAMETER_NAME,
|
|
12
|
-
RESOURCE_BODY_OR_QUERY_PARAMETER_NAME,
|
|
13
10
|
ManagedIdentityEnvironmentVariableNames,
|
|
14
11
|
ManagedIdentitySourceNames,
|
|
15
12
|
ManagedIdentityIdType,
|
|
13
|
+
ManagedIdentityQueryParameters,
|
|
14
|
+
ManagedIdentityHeaders,
|
|
16
15
|
} from "../../utils/Constants.js";
|
|
17
16
|
import { CryptoProvider } from "../../crypto/CryptoProvider.js";
|
|
18
17
|
import { ManagedIdentityRequestParameters } from "../../config/ManagedIdentityRequestParameters.js";
|
|
@@ -114,11 +113,12 @@ export class AppService extends BaseManagedIdentitySource {
|
|
|
114
113
|
this.identityEndpoint
|
|
115
114
|
);
|
|
116
115
|
|
|
117
|
-
request.headers[APP_SERVICE_SECRET_HEADER_NAME] =
|
|
116
|
+
request.headers[ManagedIdentityHeaders.APP_SERVICE_SECRET_HEADER_NAME] =
|
|
117
|
+
this.identityHeader;
|
|
118
118
|
|
|
119
|
-
request.queryParameters[
|
|
119
|
+
request.queryParameters[ManagedIdentityQueryParameters.API_VERSION] =
|
|
120
120
|
APP_SERVICE_MSI_API_VERSION;
|
|
121
|
-
request.queryParameters[
|
|
121
|
+
request.queryParameters[ManagedIdentityQueryParameters.RESOURCE] =
|
|
122
122
|
resource;
|
|
123
123
|
|
|
124
124
|
if (
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
NetworkRequestOptions,
|
|
14
14
|
Logger,
|
|
15
15
|
ServerAuthorizationTokenResponse,
|
|
16
|
+
EncodingTypes,
|
|
16
17
|
} from "@azure/msal-common/node";
|
|
17
18
|
import { ManagedIdentityRequestParameters } from "../../config/ManagedIdentityRequestParameters.js";
|
|
18
19
|
import { BaseManagedIdentitySource } from "./BaseManagedIdentitySource.js";
|
|
@@ -22,15 +23,13 @@ import {
|
|
|
22
23
|
createManagedIdentityError,
|
|
23
24
|
} from "../../error/ManagedIdentityError.js";
|
|
24
25
|
import {
|
|
25
|
-
API_VERSION_QUERY_PARAMETER_NAME,
|
|
26
|
-
AUTHORIZATION_HEADER_NAME,
|
|
27
26
|
AZURE_ARC_SECRET_FILE_MAX_SIZE_BYTES,
|
|
28
27
|
HttpMethod,
|
|
29
|
-
METADATA_HEADER_NAME,
|
|
30
28
|
ManagedIdentityEnvironmentVariableNames,
|
|
29
|
+
ManagedIdentityHeaders,
|
|
31
30
|
ManagedIdentityIdType,
|
|
31
|
+
ManagedIdentityQueryParameters,
|
|
32
32
|
ManagedIdentitySourceNames,
|
|
33
|
-
RESOURCE_BODY_OR_QUERY_PARAMETER_NAME,
|
|
34
33
|
} from "../../utils/Constants.js";
|
|
35
34
|
import { NodeStorage } from "../../cache/NodeStorage.js";
|
|
36
35
|
import {
|
|
@@ -201,11 +200,11 @@ export class AzureArc extends BaseManagedIdentitySource {
|
|
|
201
200
|
this.identityEndpoint.replace("localhost", "127.0.0.1")
|
|
202
201
|
);
|
|
203
202
|
|
|
204
|
-
request.headers[METADATA_HEADER_NAME] = "true";
|
|
203
|
+
request.headers[ManagedIdentityHeaders.METADATA_HEADER_NAME] = "true";
|
|
205
204
|
|
|
206
|
-
request.queryParameters[
|
|
205
|
+
request.queryParameters[ManagedIdentityQueryParameters.API_VERSION] =
|
|
207
206
|
ARC_API_VERSION;
|
|
208
|
-
request.queryParameters[
|
|
207
|
+
request.queryParameters[ManagedIdentityQueryParameters.RESOURCE] =
|
|
209
208
|
resource;
|
|
210
209
|
|
|
211
210
|
// bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
|
|
@@ -292,7 +291,7 @@ export class AzureArc extends BaseManagedIdentitySource {
|
|
|
292
291
|
// attempt to read the contents of the secret file
|
|
293
292
|
let secret;
|
|
294
293
|
try {
|
|
295
|
-
secret = readFileSync(secretFilePath,
|
|
294
|
+
secret = readFileSync(secretFilePath, EncodingTypes.UTF8);
|
|
296
295
|
} catch (e) {
|
|
297
296
|
throw createManagedIdentityError(
|
|
298
297
|
ManagedIdentityErrorCodes.unableToReadSecretFile
|
|
@@ -303,7 +302,9 @@ export class AzureArc extends BaseManagedIdentitySource {
|
|
|
303
302
|
this.logger.info(
|
|
304
303
|
`[Managed Identity] Adding authorization header to the request.`
|
|
305
304
|
);
|
|
306
|
-
networkRequest.headers[
|
|
305
|
+
networkRequest.headers[
|
|
306
|
+
ManagedIdentityHeaders.AUTHORIZATION_HEADER_NAME
|
|
307
|
+
] = authHeaderValue;
|
|
307
308
|
|
|
308
309
|
try {
|
|
309
310
|
retryResponse =
|
|
@@ -24,7 +24,11 @@ import { ManagedIdentityId } from "../../config/ManagedIdentityId.js";
|
|
|
24
24
|
import { ManagedIdentityRequestParameters } from "../../config/ManagedIdentityRequestParameters.js";
|
|
25
25
|
import { CryptoProvider } from "../../crypto/CryptoProvider.js";
|
|
26
26
|
import { ManagedIdentityRequest } from "../../request/ManagedIdentityRequest.js";
|
|
27
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
HttpMethod,
|
|
29
|
+
ManagedIdentityIdType,
|
|
30
|
+
ManagedIdentityQueryParameters,
|
|
31
|
+
} from "../../utils/Constants.js";
|
|
28
32
|
import { ManagedIdentityTokenResponse } from "../../response/ManagedIdentityTokenResponse.js";
|
|
29
33
|
import { NodeStorage } from "../../cache/NodeStorage.js";
|
|
30
34
|
import {
|
|
@@ -146,6 +150,29 @@ export abstract class BaseManagedIdentitySource {
|
|
|
146
150
|
managedIdentityId
|
|
147
151
|
);
|
|
148
152
|
|
|
153
|
+
if (managedIdentityRequest.revokedTokenSha256Hash) {
|
|
154
|
+
this.logger.info(
|
|
155
|
+
`[Managed Identity] The following claims are present in the request: ${managedIdentityRequest.claims}`
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
networkRequest.queryParameters[
|
|
159
|
+
ManagedIdentityQueryParameters.SHA256_TOKEN_TO_REFRESH
|
|
160
|
+
] = managedIdentityRequest.revokedTokenSha256Hash;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (managedIdentityRequest.clientCapabilities?.length) {
|
|
164
|
+
const clientCapabilities: string =
|
|
165
|
+
managedIdentityRequest.clientCapabilities.toString();
|
|
166
|
+
|
|
167
|
+
this.logger.info(
|
|
168
|
+
`[Managed Identity] The following client capabilities are present in the request: ${clientCapabilities}`
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
networkRequest.queryParameters[
|
|
172
|
+
ManagedIdentityQueryParameters.XMS_CC
|
|
173
|
+
] = clientCapabilities;
|
|
174
|
+
}
|
|
175
|
+
|
|
149
176
|
const headers: Record<string, string> = networkRequest.headers;
|
|
150
177
|
headers[HeaderNames.CONTENT_TYPE] = Constants.URL_FORM_CONTENT_TYPE;
|
|
151
178
|
|
|
@@ -10,11 +10,11 @@ import { NodeStorage } from "../../cache/NodeStorage.js";
|
|
|
10
10
|
import { CryptoProvider } from "../../crypto/CryptoProvider.js";
|
|
11
11
|
import {
|
|
12
12
|
HttpMethod,
|
|
13
|
-
METADATA_HEADER_NAME,
|
|
14
13
|
ManagedIdentityEnvironmentVariableNames,
|
|
14
|
+
ManagedIdentityHeaders,
|
|
15
15
|
ManagedIdentityIdType,
|
|
16
|
+
ManagedIdentityQueryParameters,
|
|
16
17
|
ManagedIdentitySourceNames,
|
|
17
|
-
RESOURCE_BODY_OR_QUERY_PARAMETER_NAME,
|
|
18
18
|
} from "../../utils/Constants.js";
|
|
19
19
|
import {
|
|
20
20
|
ManagedIdentityErrorCodes,
|
|
@@ -109,9 +109,9 @@ export class CloudShell extends BaseManagedIdentitySource {
|
|
|
109
109
|
this.msiEndpoint
|
|
110
110
|
);
|
|
111
111
|
|
|
112
|
-
request.headers[METADATA_HEADER_NAME] = "true";
|
|
112
|
+
request.headers[ManagedIdentityHeaders.METADATA_HEADER_NAME] = "true";
|
|
113
113
|
|
|
114
|
-
request.bodyParameters[
|
|
114
|
+
request.bodyParameters[ManagedIdentityQueryParameters.RESOURCE] =
|
|
115
115
|
resource;
|
|
116
116
|
|
|
117
117
|
return request;
|
|
@@ -9,27 +9,37 @@ import { ManagedIdentityRequestParameters } from "../../config/ManagedIdentityRe
|
|
|
9
9
|
import { BaseManagedIdentitySource } from "./BaseManagedIdentitySource.js";
|
|
10
10
|
import { CryptoProvider } from "../../crypto/CryptoProvider.js";
|
|
11
11
|
import {
|
|
12
|
-
API_VERSION_QUERY_PARAMETER_NAME,
|
|
13
12
|
HttpMethod,
|
|
14
|
-
METADATA_HEADER_NAME,
|
|
15
13
|
ManagedIdentityEnvironmentVariableNames,
|
|
14
|
+
ManagedIdentityHeaders,
|
|
16
15
|
ManagedIdentityIdType,
|
|
16
|
+
ManagedIdentityQueryParameters,
|
|
17
17
|
ManagedIdentitySourceNames,
|
|
18
|
-
RESOURCE_BODY_OR_QUERY_PARAMETER_NAME,
|
|
19
18
|
} from "../../utils/Constants.js";
|
|
20
19
|
import { NodeStorage } from "../../cache/NodeStorage.js";
|
|
21
20
|
import { ImdsRetryPolicy } from "../../retry/ImdsRetryPolicy.js";
|
|
22
21
|
|
|
23
|
-
//
|
|
22
|
+
// Documentation for IMDS is available at https://docs.microsoft.com/azure/active-directory/managed-identities-azure-resources/how-to-use-vm-token#get-a-token-using-http
|
|
23
|
+
|
|
24
24
|
const IMDS_TOKEN_PATH: string = "/metadata/identity/oauth2/token";
|
|
25
25
|
const DEFAULT_IMDS_ENDPOINT: string = `http://169.254.169.254${IMDS_TOKEN_PATH}`;
|
|
26
|
-
|
|
27
26
|
const IMDS_API_VERSION: string = "2018-02-01";
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Original source of code: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/identity/Azure.Identity/src/ImdsManagedIdentitySource.cs
|
|
30
|
+
*/
|
|
30
31
|
export class Imds extends BaseManagedIdentitySource {
|
|
31
32
|
private identityEndpoint: string;
|
|
32
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Constructs an Imds instance.
|
|
36
|
+
* @param logger - Logger instance for logging.
|
|
37
|
+
* @param nodeStorage - NodeStorage instance for caching.
|
|
38
|
+
* @param networkClient - Network client for HTTP requests.
|
|
39
|
+
* @param cryptoProvider - CryptoProvider for cryptographic operations.
|
|
40
|
+
* @param disableInternalRetries - Whether to disable internal retry logic.
|
|
41
|
+
* @param identityEndpoint - The IMDS endpoint to use.
|
|
42
|
+
*/
|
|
33
43
|
constructor(
|
|
34
44
|
logger: Logger,
|
|
35
45
|
nodeStorage: NodeStorage,
|
|
@@ -49,6 +59,18 @@ export class Imds extends BaseManagedIdentitySource {
|
|
|
49
59
|
this.identityEndpoint = identityEndpoint;
|
|
50
60
|
}
|
|
51
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Attempts to create an Imds instance by determining the correct endpoint.
|
|
64
|
+
* If the AZURE_POD_IDENTITY_AUTHORITY_HOST environment variable is set, it uses that as the endpoint.
|
|
65
|
+
* Otherwise, it falls back to the default IMDS endpoint.
|
|
66
|
+
*
|
|
67
|
+
* @param logger - Logger instance for logging.
|
|
68
|
+
* @param nodeStorage - NodeStorage instance for caching.
|
|
69
|
+
* @param networkClient - Network client for HTTP requests.
|
|
70
|
+
* @param cryptoProvider - CryptoProvider for cryptographic operations.
|
|
71
|
+
* @param disableInternalRetries - Whether to disable internal retry logic.
|
|
72
|
+
* @returns An instance of Imds configured with the appropriate endpoint.
|
|
73
|
+
*/
|
|
52
74
|
public static tryCreate(
|
|
53
75
|
logger: Logger,
|
|
54
76
|
nodeStorage: NodeStorage,
|
|
@@ -102,6 +124,14 @@ export class Imds extends BaseManagedIdentitySource {
|
|
|
102
124
|
);
|
|
103
125
|
}
|
|
104
126
|
|
|
127
|
+
/**
|
|
128
|
+
* Creates a ManagedIdentityRequestParameters object for acquiring a token from IMDS.
|
|
129
|
+
* Sets the required headers and query parameters for the IMDS token request.
|
|
130
|
+
*
|
|
131
|
+
* @param resource - The resource URI for which the token is requested.
|
|
132
|
+
* @param managedIdentityId - The managed identity ID (system-assigned or user-assigned).
|
|
133
|
+
* @returns A ManagedIdentityRequestParameters object configured for IMDS.
|
|
134
|
+
*/
|
|
105
135
|
public createRequest(
|
|
106
136
|
resource: string,
|
|
107
137
|
managedIdentityId: ManagedIdentityId
|
|
@@ -112,11 +142,11 @@ export class Imds extends BaseManagedIdentitySource {
|
|
|
112
142
|
this.identityEndpoint
|
|
113
143
|
);
|
|
114
144
|
|
|
115
|
-
request.headers[METADATA_HEADER_NAME] = "true";
|
|
145
|
+
request.headers[ManagedIdentityHeaders.METADATA_HEADER_NAME] = "true";
|
|
116
146
|
|
|
117
|
-
request.queryParameters[
|
|
147
|
+
request.queryParameters[ManagedIdentityQueryParameters.API_VERSION] =
|
|
118
148
|
IMDS_API_VERSION;
|
|
119
|
-
request.queryParameters[
|
|
149
|
+
request.queryParameters[ManagedIdentityQueryParameters.RESOURCE] =
|
|
120
150
|
resource;
|
|
121
151
|
|
|
122
152
|
if (
|
|
@@ -130,7 +160,7 @@ export class Imds extends BaseManagedIdentitySource {
|
|
|
130
160
|
] = managedIdentityId.id;
|
|
131
161
|
}
|
|
132
162
|
|
|
133
|
-
// bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
|
|
163
|
+
// The bodyParameters are calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity.
|
|
134
164
|
|
|
135
165
|
request.retryPolicy = new ImdsRetryPolicy();
|
|
136
166
|
|
|
@@ -4,16 +4,17 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { INetworkModule, Logger } from "@azure/msal-common/node";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
BaseManagedIdentitySource,
|
|
9
|
+
ManagedIdentityUserAssignedIdQueryParameterNames,
|
|
10
|
+
} from "./BaseManagedIdentitySource.js";
|
|
8
11
|
import {
|
|
9
12
|
HttpMethod,
|
|
10
|
-
API_VERSION_QUERY_PARAMETER_NAME,
|
|
11
|
-
RESOURCE_BODY_OR_QUERY_PARAMETER_NAME,
|
|
12
13
|
ManagedIdentityEnvironmentVariableNames,
|
|
13
14
|
ManagedIdentitySourceNames,
|
|
14
15
|
ManagedIdentityIdType,
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
ManagedIdentityQueryParameters,
|
|
17
|
+
ManagedIdentityHeaders,
|
|
17
18
|
} from "../../utils/Constants.js";
|
|
18
19
|
import { CryptoProvider } from "../../crypto/CryptoProvider.js";
|
|
19
20
|
import { ManagedIdentityRequestParameters } from "../../config/ManagedIdentityRequestParameters.js";
|
|
@@ -22,6 +23,8 @@ import { NodeStorage } from "../../cache/NodeStorage.js";
|
|
|
22
23
|
|
|
23
24
|
const MACHINE_LEARNING_MSI_API_VERSION: string = "2017-09-01";
|
|
24
25
|
|
|
26
|
+
export const MANAGED_IDENTITY_MACHINE_LEARNING_UNSUPPORTED_ID_TYPE_ERROR = `Only client id is supported for user-assigned managed identity in ${ManagedIdentitySourceNames.MACHINE_LEARNING}.`; // referenced in unit test
|
|
27
|
+
|
|
25
28
|
export class MachineLearning extends BaseManagedIdentitySource {
|
|
26
29
|
private msiEndpoint: string;
|
|
27
30
|
private secret: string;
|
|
@@ -107,16 +110,27 @@ export class MachineLearning extends BaseManagedIdentitySource {
|
|
|
107
110
|
this.msiEndpoint
|
|
108
111
|
);
|
|
109
112
|
|
|
110
|
-
request.headers[METADATA_HEADER_NAME] = "true";
|
|
111
|
-
request.headers[ML_AND_SF_SECRET_HEADER_NAME] =
|
|
113
|
+
request.headers[ManagedIdentityHeaders.METADATA_HEADER_NAME] = "true";
|
|
114
|
+
request.headers[ManagedIdentityHeaders.ML_AND_SF_SECRET_HEADER_NAME] =
|
|
115
|
+
this.secret;
|
|
112
116
|
|
|
113
|
-
request.queryParameters[
|
|
117
|
+
request.queryParameters[ManagedIdentityQueryParameters.API_VERSION] =
|
|
114
118
|
MACHINE_LEARNING_MSI_API_VERSION;
|
|
115
|
-
request.queryParameters[
|
|
119
|
+
request.queryParameters[ManagedIdentityQueryParameters.RESOURCE] =
|
|
116
120
|
resource;
|
|
117
121
|
|
|
118
122
|
if (
|
|
119
|
-
managedIdentityId.idType
|
|
123
|
+
managedIdentityId.idType === ManagedIdentityIdType.SYSTEM_ASSIGNED
|
|
124
|
+
) {
|
|
125
|
+
request.queryParameters[
|
|
126
|
+
ManagedIdentityUserAssignedIdQueryParameterNames.MANAGED_IDENTITY_CLIENT_ID_2017
|
|
127
|
+
] = process.env[
|
|
128
|
+
ManagedIdentityEnvironmentVariableNames
|
|
129
|
+
.DEFAULT_IDENTITY_CLIENT_ID
|
|
130
|
+
] as string; // this environment variable is always set in an Azure Machine Learning source
|
|
131
|
+
} else if (
|
|
132
|
+
managedIdentityId.idType ===
|
|
133
|
+
ManagedIdentityIdType.USER_ASSIGNED_CLIENT_ID
|
|
120
134
|
) {
|
|
121
135
|
request.queryParameters[
|
|
122
136
|
this.getManagedIdentityUserAssignedIdQueryParameterKey(
|
|
@@ -125,6 +139,10 @@ export class MachineLearning extends BaseManagedIdentitySource {
|
|
|
125
139
|
true // uses2017API
|
|
126
140
|
)
|
|
127
141
|
] = managedIdentityId.id;
|
|
142
|
+
} else {
|
|
143
|
+
throw new Error(
|
|
144
|
+
MANAGED_IDENTITY_MACHINE_LEARNING_UNSUPPORTED_ID_TYPE_ERROR
|
|
145
|
+
);
|
|
128
146
|
}
|
|
129
147
|
|
|
130
148
|
// bodyParameters calculated in BaseManagedIdentity.acquireTokenWithManagedIdentity
|
|
@@ -10,16 +10,14 @@ import { BaseManagedIdentitySource } from "./BaseManagedIdentitySource.js";
|
|
|
10
10
|
import { NodeStorage } from "../../cache/NodeStorage.js";
|
|
11
11
|
import { CryptoProvider } from "../../crypto/CryptoProvider.js";
|
|
12
12
|
import {
|
|
13
|
-
API_VERSION_QUERY_PARAMETER_NAME,
|
|
14
13
|
HttpMethod,
|
|
15
14
|
ManagedIdentityEnvironmentVariableNames,
|
|
16
15
|
ManagedIdentityIdType,
|
|
17
16
|
ManagedIdentitySourceNames,
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
ManagedIdentityQueryParameters,
|
|
18
|
+
ManagedIdentityHeaders,
|
|
20
19
|
} from "../../utils/Constants.js";
|
|
21
20
|
|
|
22
|
-
// MSI Constants. Docs for MSI are available here https://docs.microsoft.com/azure/app-service/overview-managed-identity
|
|
23
21
|
const SERVICE_FABRIC_MSI_API_VERSION: string = "2019-07-01-preview";
|
|
24
22
|
|
|
25
23
|
/**
|
|
@@ -29,6 +27,16 @@ export class ServiceFabric extends BaseManagedIdentitySource {
|
|
|
29
27
|
private identityEndpoint: string;
|
|
30
28
|
private identityHeader: string;
|
|
31
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Constructs a new ServiceFabric managed identity source.
|
|
32
|
+
* @param logger Logger instance for logging
|
|
33
|
+
* @param nodeStorage NodeStorage instance for caching
|
|
34
|
+
* @param networkClient Network client for HTTP requests
|
|
35
|
+
* @param cryptoProvider Crypto provider for cryptographic operations
|
|
36
|
+
* @param disableInternalRetries Whether to disable internal retry logic
|
|
37
|
+
* @param identityEndpoint The Service Fabric managed identity endpoint
|
|
38
|
+
* @param identityHeader The Service Fabric managed identity secret header
|
|
39
|
+
*/
|
|
32
40
|
constructor(
|
|
33
41
|
logger: Logger,
|
|
34
42
|
nodeStorage: NodeStorage,
|
|
@@ -50,6 +58,10 @@ export class ServiceFabric extends BaseManagedIdentitySource {
|
|
|
50
58
|
this.identityHeader = identityHeader;
|
|
51
59
|
}
|
|
52
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Retrieves the environment variables required for Service Fabric managed identity.
|
|
63
|
+
* @returns An array containing the identity endpoint, identity header, and identity server thumbprint.
|
|
64
|
+
*/
|
|
53
65
|
public static getEnvironmentVariables(): Array<string | undefined> {
|
|
54
66
|
const identityEndpoint: string | undefined =
|
|
55
67
|
process.env[
|
|
@@ -68,6 +80,16 @@ export class ServiceFabric extends BaseManagedIdentitySource {
|
|
|
68
80
|
return [identityEndpoint, identityHeader, identityServerThumbprint];
|
|
69
81
|
}
|
|
70
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Attempts to create a ServiceFabric managed identity source if all required environment variables are present.
|
|
85
|
+
* @param logger Logger instance for logging
|
|
86
|
+
* @param nodeStorage NodeStorage instance for caching
|
|
87
|
+
* @param networkClient Network client for HTTP requests
|
|
88
|
+
* @param cryptoProvider Crypto provider for cryptographic operations
|
|
89
|
+
* @param disableInternalRetries Whether to disable internal retry logic
|
|
90
|
+
* @param managedIdentityId Managed identity identifier
|
|
91
|
+
* @returns A ServiceFabric instance if environment variables are set, otherwise null
|
|
92
|
+
*/
|
|
71
93
|
public static tryCreate(
|
|
72
94
|
logger: Logger,
|
|
73
95
|
nodeStorage: NodeStorage,
|
|
@@ -79,10 +101,6 @@ export class ServiceFabric extends BaseManagedIdentitySource {
|
|
|
79
101
|
const [identityEndpoint, identityHeader, identityServerThumbprint] =
|
|
80
102
|
ServiceFabric.getEnvironmentVariables();
|
|
81
103
|
|
|
82
|
-
/*
|
|
83
|
-
* if either of the identity endpoint, identity header, or identity server thumbprint
|
|
84
|
-
* environment variables are undefined, this MSI provider is unavailable.
|
|
85
|
-
*/
|
|
86
104
|
if (!identityEndpoint || !identityHeader || !identityServerThumbprint) {
|
|
87
105
|
logger.info(
|
|
88
106
|
`[Managed Identity] ${ManagedIdentitySourceNames.SERVICE_FABRIC} managed identity is unavailable because one or all of the '${ManagedIdentityEnvironmentVariableNames.IDENTITY_HEADER}', '${ManagedIdentityEnvironmentVariableNames.IDENTITY_ENDPOINT}' or '${ManagedIdentityEnvironmentVariableNames.IDENTITY_SERVER_THUMBPRINT}' environment variables are not defined.`
|
|
@@ -121,6 +139,12 @@ export class ServiceFabric extends BaseManagedIdentitySource {
|
|
|
121
139
|
);
|
|
122
140
|
}
|
|
123
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Creates the request parameters for acquiring a token from the Service Fabric cluster.
|
|
144
|
+
* @param resource - The resource URI for which the token is requested.
|
|
145
|
+
* @param managedIdentityId - The managed identity ID (system-assigned or user-assigned).
|
|
146
|
+
* @returns A ManagedIdentityRequestParameters object configured for Service Fabric.
|
|
147
|
+
*/
|
|
124
148
|
public createRequest(
|
|
125
149
|
resource: string,
|
|
126
150
|
managedIdentityId: ManagedIdentityId
|
|
@@ -131,11 +155,12 @@ export class ServiceFabric extends BaseManagedIdentitySource {
|
|
|
131
155
|
this.identityEndpoint
|
|
132
156
|
);
|
|
133
157
|
|
|
134
|
-
request.headers[ML_AND_SF_SECRET_HEADER_NAME] =
|
|
158
|
+
request.headers[ManagedIdentityHeaders.ML_AND_SF_SECRET_HEADER_NAME] =
|
|
159
|
+
this.identityHeader;
|
|
135
160
|
|
|
136
|
-
request.queryParameters[
|
|
161
|
+
request.queryParameters[ManagedIdentityQueryParameters.API_VERSION] =
|
|
137
162
|
SERVICE_FABRIC_MSI_API_VERSION;
|
|
138
|
-
request.queryParameters[
|
|
163
|
+
request.queryParameters[ManagedIdentityQueryParameters.RESOURCE] =
|
|
139
164
|
resource;
|
|
140
165
|
|
|
141
166
|
if (
|
|
@@ -291,7 +291,10 @@ export class PublicClientApplication
|
|
|
291
291
|
await this.nativeBrokerPlugin.signOut(signoutRequest);
|
|
292
292
|
}
|
|
293
293
|
|
|
294
|
-
await this.getTokenCache().removeAccount(
|
|
294
|
+
await this.getTokenCache().removeAccount(
|
|
295
|
+
request.account,
|
|
296
|
+
request.correlationId
|
|
297
|
+
);
|
|
295
298
|
}
|
|
296
299
|
|
|
297
300
|
/**
|
|
@@ -134,6 +134,7 @@ export type ManagedIdentityIdParams = {
|
|
|
134
134
|
|
|
135
135
|
/** @public */
|
|
136
136
|
export type ManagedIdentityConfiguration = {
|
|
137
|
+
clientCapabilities?: Array<string>;
|
|
137
138
|
managedIdentityIdParams?: ManagedIdentityIdParams;
|
|
138
139
|
system?: NodeSystemOptions;
|
|
139
140
|
};
|
|
@@ -246,14 +247,16 @@ export function buildAppConfiguration({
|
|
|
246
247
|
|
|
247
248
|
/** @internal */
|
|
248
249
|
export type ManagedIdentityNodeConfiguration = {
|
|
250
|
+
clientCapabilities?: Array<string>;
|
|
251
|
+
disableInternalRetries: boolean;
|
|
249
252
|
managedIdentityId: ManagedIdentityId;
|
|
250
253
|
system: Required<
|
|
251
254
|
Pick<NodeSystemOptions, "loggerOptions" | "networkClient">
|
|
252
255
|
>;
|
|
253
|
-
disableInternalRetries: boolean;
|
|
254
256
|
};
|
|
255
257
|
|
|
256
258
|
export function buildManagedIdentityConfiguration({
|
|
259
|
+
clientCapabilities,
|
|
257
260
|
managedIdentityIdParams,
|
|
258
261
|
system,
|
|
259
262
|
}: ManagedIdentityConfiguration): ManagedIdentityNodeConfiguration {
|
|
@@ -277,6 +280,7 @@ export function buildManagedIdentityConfiguration({
|
|
|
277
280
|
}
|
|
278
281
|
|
|
279
282
|
return {
|
|
283
|
+
clientCapabilities: clientCapabilities || [],
|
|
280
284
|
managedIdentityId: managedIdentityId,
|
|
281
285
|
system: {
|
|
282
286
|
loggerOptions,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { ICrypto, PkceCodes } from "@azure/msal-common/node";
|
|
6
|
+
import { EncodingTypes, ICrypto, PkceCodes } from "@azure/msal-common/node";
|
|
7
7
|
import { GuidGenerator } from "./GuidGenerator.js";
|
|
8
8
|
import { EncodingUtils } from "../utils/EncodingUtils.js";
|
|
9
9
|
import { PkceGenerator } from "./PkceGenerator.js";
|
|
@@ -83,7 +83,7 @@ export class CryptoProvider implements ICrypto {
|
|
|
83
83
|
* Removes cryptographic keypair from key store matching the keyId passed in
|
|
84
84
|
* @param kid - public key id
|
|
85
85
|
*/
|
|
86
|
-
removeTokenBindingKey(): Promise<
|
|
86
|
+
removeTokenBindingKey(): Promise<void> {
|
|
87
87
|
throw new Error("Method not implemented.");
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -106,8 +106,8 @@ export class CryptoProvider implements ICrypto {
|
|
|
106
106
|
*/
|
|
107
107
|
async hashString(plainText: string): Promise<string> {
|
|
108
108
|
return EncodingUtils.base64EncodeUrl(
|
|
109
|
-
this.hashUtils.sha256(plainText).toString(
|
|
110
|
-
|
|
109
|
+
this.hashUtils.sha256(plainText).toString(EncodingTypes.BASE64),
|
|
110
|
+
EncodingTypes.BASE64
|
|
111
111
|
);
|
|
112
112
|
}
|
|
113
113
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Constants, PkceCodes } from "@azure/msal-common/node";
|
|
6
|
+
import { Constants, EncodingTypes, PkceCodes } from "@azure/msal-common/node";
|
|
7
7
|
import { CharSet, RANDOM_OCTET_SIZE } from "../utils/Constants.js";
|
|
8
8
|
import { EncodingUtils } from "../utils/EncodingUtils.js";
|
|
9
9
|
import { HashUtils } from "./HashUtils.js";
|
|
@@ -56,8 +56,8 @@ export class PkceGenerator {
|
|
|
56
56
|
*/
|
|
57
57
|
private generateCodeChallengeFromVerifier(codeVerifier: string): string {
|
|
58
58
|
return EncodingUtils.base64EncodeUrl(
|
|
59
|
-
this.hashUtils.sha256(codeVerifier).toString(
|
|
60
|
-
|
|
59
|
+
this.hashUtils.sha256(codeVerifier).toString(EncodingTypes.BASE64),
|
|
60
|
+
EncodingTypes.BASE64
|
|
61
61
|
);
|
|
62
62
|
}
|
|
63
63
|
}
|
package/src/packageMetadata.ts
CHANGED
|
@@ -8,8 +8,11 @@ import { ManagedIdentityRequestParams } from "./ManagedIdentityRequestParams.js"
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* ManagedIdentityRequest
|
|
11
|
-
* -
|
|
12
|
-
* -
|
|
11
|
+
* - clientCapabilities - an array of capabilities to be added to all network requests as part of the `xms_cc` claim
|
|
12
|
+
* - revokedTokenSha256Hash - a SHA256 hash of the token that was revoked. The managed identity will revoke the token based on the SHA256 hash of the token, not the token itself. This is to prevent the token from being leaked in transit.
|
|
13
13
|
*/
|
|
14
14
|
export type ManagedIdentityRequest = ManagedIdentityRequestParams &
|
|
15
|
-
CommonClientCredentialRequest
|
|
15
|
+
CommonClientCredentialRequest & {
|
|
16
|
+
clientCapabilities?: Array<string>;
|
|
17
|
+
revokedTokenSha256Hash?: string;
|
|
18
|
+
};
|
package/src/utils/Constants.ts
CHANGED
|
@@ -8,21 +8,40 @@ import { DefaultManagedIdentityRetryPolicy } from "../retry/DefaultManagedIdenti
|
|
|
8
8
|
import { ImdsRetryPolicy } from "../retry/ImdsRetryPolicy.js";
|
|
9
9
|
|
|
10
10
|
// MSI Constants. Docs for MSI are available here https://docs.microsoft.com/azure/app-service/overview-managed-identity
|
|
11
|
-
export const AUTHORIZATION_HEADER_NAME: string = "Authorization";
|
|
12
|
-
export const METADATA_HEADER_NAME: string = "Metadata";
|
|
13
|
-
export const APP_SERVICE_SECRET_HEADER_NAME: string = "X-IDENTITY-HEADER";
|
|
14
|
-
export const ML_AND_SF_SECRET_HEADER_NAME: string = "secret";
|
|
15
|
-
export const API_VERSION_QUERY_PARAMETER_NAME: string = "api-version";
|
|
16
|
-
export const RESOURCE_BODY_OR_QUERY_PARAMETER_NAME: string = "resource";
|
|
17
11
|
export const DEFAULT_MANAGED_IDENTITY_ID = "system_assigned_managed_identity";
|
|
18
12
|
export const MANAGED_IDENTITY_DEFAULT_TENANT = "managed_identity";
|
|
19
13
|
export const DEFAULT_AUTHORITY_FOR_MANAGED_IDENTITY = `https://login.microsoftonline.com/${MANAGED_IDENTITY_DEFAULT_TENANT}/`;
|
|
20
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Managed Identity Headers - used in network requests
|
|
17
|
+
*/
|
|
18
|
+
export const ManagedIdentityHeaders = {
|
|
19
|
+
AUTHORIZATION_HEADER_NAME: "Authorization",
|
|
20
|
+
METADATA_HEADER_NAME: "Metadata",
|
|
21
|
+
APP_SERVICE_SECRET_HEADER_NAME: "X-IDENTITY-HEADER",
|
|
22
|
+
ML_AND_SF_SECRET_HEADER_NAME: "secret",
|
|
23
|
+
} as const;
|
|
24
|
+
export type ManagedIdentityHeaders =
|
|
25
|
+
(typeof ManagedIdentityHeaders)[keyof typeof ManagedIdentityHeaders];
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Managed Identity Query Parameters - used in network requests
|
|
29
|
+
*/
|
|
30
|
+
export const ManagedIdentityQueryParameters = {
|
|
31
|
+
API_VERSION: "api-version",
|
|
32
|
+
RESOURCE: "resource",
|
|
33
|
+
SHA256_TOKEN_TO_REFRESH: "token_sha256_to_refresh",
|
|
34
|
+
XMS_CC: "xms_cc",
|
|
35
|
+
} as const;
|
|
36
|
+
export type ManagedIdentityQueryParameters =
|
|
37
|
+
(typeof ManagedIdentityQueryParameters)[keyof typeof ManagedIdentityQueryParameters];
|
|
38
|
+
|
|
21
39
|
/**
|
|
22
40
|
* Managed Identity Environment Variable Names
|
|
23
41
|
*/
|
|
24
42
|
export const ManagedIdentityEnvironmentVariableNames = {
|
|
25
43
|
AZURE_POD_IDENTITY_AUTHORITY_HOST: "AZURE_POD_IDENTITY_AUTHORITY_HOST",
|
|
44
|
+
DEFAULT_IDENTITY_CLIENT_ID: "DEFAULT_IDENTITY_CLIENT_ID",
|
|
26
45
|
IDENTITY_ENDPOINT: "IDENTITY_ENDPOINT",
|
|
27
46
|
IDENTITY_HEADER: "IDENTITY_HEADER",
|
|
28
47
|
IDENTITY_SERVER_THUMBPRINT: "IDENTITY_SERVER_THUMBPRINT",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { Constants } from "@azure/msal-common/node";
|
|
6
|
+
import { Constants, EncodingTypes } from "@azure/msal-common/node";
|
|
7
7
|
|
|
8
8
|
export class EncodingUtils {
|
|
9
9
|
/**
|
|
@@ -13,7 +13,7 @@ export class EncodingUtils {
|
|
|
13
13
|
* @param str text
|
|
14
14
|
*/
|
|
15
15
|
static base64Encode(str: string, encoding?: BufferEncoding): string {
|
|
16
|
-
return Buffer.from(str, encoding).toString(
|
|
16
|
+
return Buffer.from(str, encoding).toString(EncodingTypes.BASE64);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -34,7 +34,7 @@ export class EncodingUtils {
|
|
|
34
34
|
* @param base64Str Base64 encoded text
|
|
35
35
|
*/
|
|
36
36
|
static base64Decode(base64Str: string): string {
|
|
37
|
-
return Buffer.from(base64Str,
|
|
37
|
+
return Buffer.from(base64Str, EncodingTypes.BASE64).toString("utf8");
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/**
|