@azure/identity 3.0.0-alpha.20220809.2 → 3.0.0-alpha.20220914.2
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.
Potentially problematic release.
This version of @azure/identity might be problematic. Click here for more details.
- package/dist/index.js +32 -33
- package/dist/index.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js +30 -35
- package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js.map +1 -1
- package/dist-esm/src/util/logging.js +4 -0
- package/dist-esm/src/util/logging.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -293,11 +293,15 @@ function credentialLoggerInstance(title, parent, log = logger$l) {
|
|
|
293
293
|
function warning(message) {
|
|
294
294
|
log.warning(`${fullTitle} =>`, message);
|
|
295
295
|
}
|
|
296
|
+
function verbose(message) {
|
|
297
|
+
log.verbose(`${fullTitle} =>`, message);
|
|
298
|
+
}
|
|
296
299
|
return {
|
|
297
300
|
title,
|
|
298
301
|
fullTitle,
|
|
299
302
|
info,
|
|
300
303
|
warning,
|
|
304
|
+
verbose,
|
|
301
305
|
};
|
|
302
306
|
}
|
|
303
307
|
/**
|
|
@@ -2471,48 +2475,43 @@ const imdsMsi = {
|
|
|
2471
2475
|
skipQuery: true,
|
|
2472
2476
|
});
|
|
2473
2477
|
return tracingClient.withSpan("ManagedIdentityCredential-pingImdsEndpoint", getTokenOptions, async (options) => {
|
|
2474
|
-
var _a
|
|
2478
|
+
var _a;
|
|
2475
2479
|
requestOptions.tracingOptions = options.tracingOptions;
|
|
2480
|
+
// Create a request with a timeout since we expect that
|
|
2481
|
+
// not having a "Metadata" header should cause an error to be
|
|
2482
|
+
// returned quickly from the endpoint, proving its availability.
|
|
2483
|
+
const request = coreRestPipeline.createPipelineRequest(requestOptions);
|
|
2484
|
+
// Default to 300 if the default of 0 is used.
|
|
2485
|
+
// Negative values can still be used to disable the timeout.
|
|
2486
|
+
request.timeout = ((_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.timeout) || 300;
|
|
2487
|
+
// This MSI uses the imdsEndpoint to get the token, which only uses http://
|
|
2488
|
+
request.allowInsecureConnection = true;
|
|
2476
2489
|
try {
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
// returned quickly from the endpoint, proving its availability.
|
|
2480
|
-
const request = coreRestPipeline.createPipelineRequest(requestOptions);
|
|
2481
|
-
request.timeout = (_b = (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.timeout) !== null && _b !== void 0 ? _b : 300;
|
|
2482
|
-
// This MSI uses the imdsEndpoint to get the token, which only uses http://
|
|
2483
|
-
request.allowInsecureConnection = true;
|
|
2484
|
-
try {
|
|
2485
|
-
logger$a.info(`${msiName$4}: Pinging the Azure IMDS endpoint`);
|
|
2486
|
-
await identityClient.sendRequest(request);
|
|
2487
|
-
}
|
|
2488
|
-
catch (err) {
|
|
2489
|
-
if ((err.name === "RestError" && err.code === coreRestPipeline.RestError.REQUEST_SEND_ERROR) ||
|
|
2490
|
-
err.name === "AbortError" ||
|
|
2491
|
-
err.code === "ENETUNREACH" || // Network unreachable
|
|
2492
|
-
err.code === "ECONNREFUSED" || // connection refused
|
|
2493
|
-
err.code === "EHOSTDOWN" // host is down
|
|
2494
|
-
) {
|
|
2495
|
-
// If the request failed, or Node.js was unable to establish a connection,
|
|
2496
|
-
// or the host was down, we'll assume the IMDS endpoint isn't available.
|
|
2497
|
-
logger$a.info(`${msiName$4}: The Azure IMDS endpoint is unavailable`);
|
|
2498
|
-
return false;
|
|
2499
|
-
}
|
|
2500
|
-
}
|
|
2501
|
-
// If we received any response, the endpoint is available
|
|
2502
|
-
logger$a.info(`${msiName$4}: The Azure IMDS endpoint is available`);
|
|
2503
|
-
return true;
|
|
2490
|
+
logger$a.info(`${msiName$4}: Pinging the Azure IMDS endpoint`);
|
|
2491
|
+
await identityClient.sendRequest(request);
|
|
2504
2492
|
}
|
|
2505
2493
|
catch (err) {
|
|
2506
|
-
//
|
|
2507
|
-
//
|
|
2508
|
-
|
|
2509
|
-
|
|
2494
|
+
// If the request failed, or Node.js was unable to establish a connection,
|
|
2495
|
+
// or the host was down, we'll assume the IMDS endpoint isn't available.
|
|
2496
|
+
if (coreUtil.isError(err)) {
|
|
2497
|
+
logger$a.verbose(`${msiName$4}: Caught error ${err.name}: ${err.message}`);
|
|
2498
|
+
}
|
|
2499
|
+
logger$a.info(`${msiName$4}: The Azure IMDS endpoint is unavailable`);
|
|
2500
|
+
return false;
|
|
2510
2501
|
}
|
|
2502
|
+
// If we received any response, the endpoint is available
|
|
2503
|
+
logger$a.info(`${msiName$4}: The Azure IMDS endpoint is available`);
|
|
2504
|
+
return true;
|
|
2511
2505
|
});
|
|
2512
2506
|
},
|
|
2513
2507
|
async getToken(configuration, getTokenOptions = {}) {
|
|
2514
2508
|
const { identityClient, scopes, clientId, resourceId } = configuration;
|
|
2515
|
-
|
|
2509
|
+
if (process.env.AZURE_POD_IDENTITY_AUTHORITY_HOST) {
|
|
2510
|
+
logger$a.info(`${msiName$4}: Using the Azure IMDS endpoint coming from the environment variable AZURE_POD_IDENTITY_AUTHORITY_HOST=${process.env.AZURE_POD_IDENTITY_AUTHORITY_HOST}.`);
|
|
2511
|
+
}
|
|
2512
|
+
else {
|
|
2513
|
+
logger$a.info(`${msiName$4}: Using the default Azure IMDS endpoint ${imdsHost}.`);
|
|
2514
|
+
}
|
|
2516
2515
|
let nextDelayInMs = imdsMsiRetryConfig.startDelayInMs;
|
|
2517
2516
|
for (let retries = 0; retries < imdsMsiRetryConfig.maxRetries; retries++) {
|
|
2518
2517
|
try {
|