@azure/identity 3.3.2-alpha.20231016.2 → 3.3.2-alpha.20231017.9
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 +43 -24
- package/dist/index.js.map +1 -1
- package/dist-esm/src/credentials/authorizationCodeCredential.js +2 -2
- package/dist-esm/src/credentials/authorizationCodeCredential.js.map +1 -1
- package/dist-esm/src/credentials/azureCliCredential.js +2 -2
- package/dist-esm/src/credentials/azureCliCredential.js.map +1 -1
- package/dist-esm/src/credentials/azureDeveloperCliCredential.js +2 -2
- package/dist-esm/src/credentials/azureDeveloperCliCredential.js.map +1 -1
- package/dist-esm/src/credentials/azurePowerShellCredential.js +2 -2
- package/dist-esm/src/credentials/azurePowerShellCredential.js.map +1 -1
- package/dist-esm/src/credentials/clientAssertionCredential.js +2 -2
- package/dist-esm/src/credentials/clientAssertionCredential.js.map +1 -1
- package/dist-esm/src/credentials/clientCertificateCredential.js +3 -3
- package/dist-esm/src/credentials/clientCertificateCredential.js.map +1 -1
- package/dist-esm/src/credentials/clientSecretCredential.browser.js +3 -3
- package/dist-esm/src/credentials/clientSecretCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/clientSecretCredential.js +2 -2
- package/dist-esm/src/credentials/clientSecretCredential.js.map +1 -1
- package/dist-esm/src/credentials/deviceCodeCredential.js +2 -2
- package/dist-esm/src/credentials/deviceCodeCredential.js.map +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js +4 -4
- package/dist-esm/src/credentials/interactiveBrowserCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/interactiveBrowserCredential.js +2 -2
- package/dist-esm/src/credentials/interactiveBrowserCredential.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js +14 -4
- package/dist-esm/src/credentials/managedIdentityCredential/imdsMsi.js.map +1 -1
- package/dist-esm/src/credentials/managedIdentityCredential/index.js +10 -1
- package/dist-esm/src/credentials/managedIdentityCredential/index.js.map +1 -1
- package/dist-esm/src/credentials/onBehalfOfCredential.js +3 -3
- package/dist-esm/src/credentials/onBehalfOfCredential.js.map +1 -1
- package/dist-esm/src/credentials/usernamePasswordCredential.browser.js +2 -2
- package/dist-esm/src/credentials/usernamePasswordCredential.browser.js.map +1 -1
- package/dist-esm/src/credentials/usernamePasswordCredential.js +2 -2
- package/dist-esm/src/credentials/usernamePasswordCredential.js.map +1 -1
- package/dist-esm/src/credentials/visualStudioCodeCredential.js +2 -2
- package/dist-esm/src/credentials/visualStudioCodeCredential.js.map +1 -1
- package/dist-esm/src/errors.js.map +1 -1
- package/dist-esm/src/msal/browserFlows/msalAuthCode.js +1 -1
- package/dist-esm/src/msal/browserFlows/msalAuthCode.js.map +1 -1
- package/dist-esm/src/msal/browserFlows/msalBrowserCommon.js +2 -2
- package/dist-esm/src/msal/browserFlows/msalBrowserCommon.js.map +1 -1
- package/dist-esm/src/msal/nodeFlows/msalNodeCommon.js +2 -2
- package/dist-esm/src/msal/nodeFlows/msalNodeCommon.js.map +1 -1
- package/dist-esm/src/util/scopeUtils.js +1 -1
- package/dist-esm/src/util/scopeUtils.js.map +1 -1
- package/dist-esm/src/util/tenantIdUtils.js +3 -3
- package/dist-esm/src/util/tenantIdUtils.js.map +1 -1
- package/package.json +1 -1
- package/types/identity.d.ts +4 -4
package/dist/index.js
CHANGED
|
@@ -557,8 +557,8 @@ function processMultiTenantRequest(tenantId, getTokenOptions, additionallyAllowe
|
|
|
557
557
|
* @internal
|
|
558
558
|
*/
|
|
559
559
|
function checkTenantId(logger, tenantId) {
|
|
560
|
-
if (!tenantId.match(/^[0-9a-zA-Z
|
|
561
|
-
const error = new Error("Invalid tenant id provided. You can locate your tenant id by following the instructions listed here: https://
|
|
560
|
+
if (!tenantId.match(/^[0-9a-zA-Z-.]+$/)) {
|
|
561
|
+
const error = new Error("Invalid tenant id provided. You can locate your tenant id by following the instructions listed here: https://learn.microsoft.com/partner-center/find-ids-and-domain-names.");
|
|
562
562
|
logger.info(formatError("", error));
|
|
563
563
|
throw error;
|
|
564
564
|
}
|
|
@@ -582,7 +582,7 @@ function resolveTenantId(logger, tenantId, clientId) {
|
|
|
582
582
|
/**
|
|
583
583
|
* @internal
|
|
584
584
|
*/
|
|
585
|
-
function
|
|
585
|
+
function resolveAdditionallyAllowedTenantIds(additionallyAllowedTenants) {
|
|
586
586
|
if (!additionallyAllowedTenants || additionallyAllowedTenants.length === 0) {
|
|
587
587
|
return [];
|
|
588
588
|
}
|
|
@@ -1058,7 +1058,7 @@ class MsalNode extends MsalBaseUtilities {
|
|
|
1058
1058
|
this.requiresConfidential = false;
|
|
1059
1059
|
this.msalConfig = this.defaultNodeMsalConfig(options);
|
|
1060
1060
|
this.tenantId = resolveTenantId(options.logger, options.tenantId, options.clientId);
|
|
1061
|
-
this.additionallyAllowedTenantIds =
|
|
1061
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds((_a = options === null || options === void 0 ? void 0 : options.tokenCredentialOptions) === null || _a === void 0 ? void 0 : _a.additionallyAllowedTenants);
|
|
1062
1062
|
this.clientId = this.msalConfig.auth.clientId;
|
|
1063
1063
|
if (options === null || options === void 0 ? void 0 : options.getAssertion) {
|
|
1064
1064
|
this.getAssertion = options.getAssertion;
|
|
@@ -1398,7 +1398,7 @@ class VisualStudioCodeCredential {
|
|
|
1398
1398
|
else {
|
|
1399
1399
|
this.tenantId = CommonTenantId;
|
|
1400
1400
|
}
|
|
1401
|
-
this.additionallyAllowedTenantIds =
|
|
1401
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
1402
1402
|
checkUnsupportedTenant(this.tenantId);
|
|
1403
1403
|
}
|
|
1404
1404
|
/**
|
|
@@ -1741,20 +1741,21 @@ const imdsMsi = {
|
|
|
1741
1741
|
skipQuery: true,
|
|
1742
1742
|
});
|
|
1743
1743
|
return tracingClient.withSpan("ManagedIdentityCredential-pingImdsEndpoint", getTokenOptions, async (options) => {
|
|
1744
|
-
var _a;
|
|
1744
|
+
var _a, _b;
|
|
1745
1745
|
requestOptions.tracingOptions = options.tracingOptions;
|
|
1746
1746
|
// Create a request with a timeout since we expect that
|
|
1747
1747
|
// not having a "Metadata" header should cause an error to be
|
|
1748
1748
|
// returned quickly from the endpoint, proving its availability.
|
|
1749
1749
|
const request = coreRestPipeline.createPipelineRequest(requestOptions);
|
|
1750
|
-
// Default to
|
|
1750
|
+
// Default to 1000 if the default of 0 is used.
|
|
1751
1751
|
// Negative values can still be used to disable the timeout.
|
|
1752
|
-
request.timeout = ((_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.timeout) ||
|
|
1752
|
+
request.timeout = ((_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.timeout) || 1000;
|
|
1753
1753
|
// This MSI uses the imdsEndpoint to get the token, which only uses http://
|
|
1754
1754
|
request.allowInsecureConnection = true;
|
|
1755
|
+
let response;
|
|
1755
1756
|
try {
|
|
1756
1757
|
logger$j.info(`${msiName$4}: Pinging the Azure IMDS endpoint`);
|
|
1757
|
-
await identityClient.sendRequest(request);
|
|
1758
|
+
response = await identityClient.sendRequest(request);
|
|
1758
1759
|
}
|
|
1759
1760
|
catch (err) {
|
|
1760
1761
|
// If the request failed, or Node.js was unable to establish a connection,
|
|
@@ -1762,9 +1763,18 @@ const imdsMsi = {
|
|
|
1762
1763
|
if (coreUtil.isError(err)) {
|
|
1763
1764
|
logger$j.verbose(`${msiName$4}: Caught error ${err.name}: ${err.message}`);
|
|
1764
1765
|
}
|
|
1766
|
+
// This is a special case for Docker Desktop which responds with a 403 with a message that contains "A socket operation was attempted to an unreachable network"
|
|
1767
|
+
// rather than just timing out, as expected.
|
|
1765
1768
|
logger$j.info(`${msiName$4}: The Azure IMDS endpoint is unavailable`);
|
|
1766
1769
|
return false;
|
|
1767
1770
|
}
|
|
1771
|
+
if (response.status === 403) {
|
|
1772
|
+
if ((_b = response.bodyAsText) === null || _b === void 0 ? void 0 : _b.includes("A socket operation was attempted to an unreachable network")) {
|
|
1773
|
+
logger$j.info(`${msiName$4}: The Azure IMDS endpoint is unavailable`);
|
|
1774
|
+
logger$j.info(`${msiName$4}: ${response.bodyAsText}`);
|
|
1775
|
+
return false;
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1768
1778
|
// If we received any response, the endpoint is available
|
|
1769
1779
|
logger$j.info(`${msiName$4}: The Azure IMDS endpoint is available`);
|
|
1770
1780
|
return true;
|
|
@@ -1971,7 +1981,7 @@ class ClientAssertionCredential {
|
|
|
1971
1981
|
throw new Error("ClientAssertionCredential: tenantId, clientId, and clientAssertion are required parameters.");
|
|
1972
1982
|
}
|
|
1973
1983
|
this.tenantId = tenantId;
|
|
1974
|
-
this.additionallyAllowedTenantIds =
|
|
1984
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
1975
1985
|
this.clientId = clientId;
|
|
1976
1986
|
this.options = options;
|
|
1977
1987
|
this.msalFlow = new MsalClientAssertion(Object.assign(Object.assign({}, options), { logger: logger$h, clientId: this.clientId, tenantId: this.tenantId, tokenCredentialOptions: this.options, getAssertion }));
|
|
@@ -2289,7 +2299,7 @@ const logger$c = credentialLogger("ManagedIdentityCredential");
|
|
|
2289
2299
|
* Azure Kubernetes Services, Azure Service Fabric instances and inside of the Azure Cloud Shell.
|
|
2290
2300
|
*
|
|
2291
2301
|
* More information about configuring managed identities can be found here:
|
|
2292
|
-
* https://
|
|
2302
|
+
* https://learn.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview
|
|
2293
2303
|
*/
|
|
2294
2304
|
class ManagedIdentityCredential {
|
|
2295
2305
|
/**
|
|
@@ -2480,6 +2490,15 @@ class ManagedIdentityCredential {
|
|
|
2480
2490
|
if (err.statusCode === 400) {
|
|
2481
2491
|
throw new CredentialUnavailableError(`${ManagedIdentityCredential.name}: The managed identity endpoint is indicating there's no available identity. Message: ${err.message}`);
|
|
2482
2492
|
}
|
|
2493
|
+
// This is a special case for Docker Desktop which responds with a 403 with a message that contains "A socket operation was attempted to an unreachable network"
|
|
2494
|
+
// rather than just timing out, as expected.
|
|
2495
|
+
if (err.statusCode === 403 || err.code === 403) {
|
|
2496
|
+
if (err.message.includes("A socket operation was attempted to an unreachable network")) {
|
|
2497
|
+
const error = new CredentialUnavailableError(`${ManagedIdentityCredential.name}: Unavailable. Network unreachable. Message: ${err.message}`);
|
|
2498
|
+
logger$c.getToken.info(formatError(scopes, error));
|
|
2499
|
+
throw error;
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2483
2502
|
// If the error has no status code, we can assume there was no available identity.
|
|
2484
2503
|
// This will throw silently during any ChainedTokenCredential.
|
|
2485
2504
|
if (err.statusCode === undefined) {
|
|
@@ -2576,7 +2595,7 @@ function ensureScopes(scopes) {
|
|
|
2576
2595
|
* @internal
|
|
2577
2596
|
*/
|
|
2578
2597
|
function ensureValidScopeForDevTimeCreds(scope, logger) {
|
|
2579
|
-
if (!scope.match(/^[0-9a-zA-Z
|
|
2598
|
+
if (!scope.match(/^[0-9a-zA-Z-_.:/]+$/)) {
|
|
2580
2599
|
const error = new Error("Invalid scope was specified by the user or calling client");
|
|
2581
2600
|
logger.getToken.info(formatError(scope, error));
|
|
2582
2601
|
throw error;
|
|
@@ -2662,7 +2681,7 @@ class AzureCliCredential {
|
|
|
2662
2681
|
checkTenantId(logger$b, options === null || options === void 0 ? void 0 : options.tenantId);
|
|
2663
2682
|
this.tenantId = options === null || options === void 0 ? void 0 : options.tenantId;
|
|
2664
2683
|
}
|
|
2665
|
-
this.additionallyAllowedTenantIds =
|
|
2684
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
2666
2685
|
this.timeout = options === null || options === void 0 ? void 0 : options.processTimeoutInMs;
|
|
2667
2686
|
}
|
|
2668
2687
|
/**
|
|
@@ -2844,7 +2863,7 @@ class AzurePowerShellCredential {
|
|
|
2844
2863
|
checkTenantId(logger$a, options === null || options === void 0 ? void 0 : options.tenantId);
|
|
2845
2864
|
this.tenantId = options === null || options === void 0 ? void 0 : options.tenantId;
|
|
2846
2865
|
}
|
|
2847
|
-
this.additionallyAllowedTenantIds =
|
|
2866
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
2848
2867
|
this.timeout = options === null || options === void 0 ? void 0 : options.processTimeoutInMs;
|
|
2849
2868
|
}
|
|
2850
2869
|
/**
|
|
@@ -3130,7 +3149,7 @@ const logger$8 = credentialLogger(credentialName$2);
|
|
|
3130
3149
|
* certificate that is assigned to an App Registration. More information
|
|
3131
3150
|
* on how to configure certificate authentication can be found here:
|
|
3132
3151
|
*
|
|
3133
|
-
* https://
|
|
3152
|
+
* https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-certificate-credentials#register-your-certificate-with-azure-ad
|
|
3134
3153
|
*
|
|
3135
3154
|
*/
|
|
3136
3155
|
class ClientCertificateCredential {
|
|
@@ -3139,7 +3158,7 @@ class ClientCertificateCredential {
|
|
|
3139
3158
|
throw new Error(`${credentialName$2}: tenantId and clientId are required parameters.`);
|
|
3140
3159
|
}
|
|
3141
3160
|
this.tenantId = tenantId;
|
|
3142
|
-
this.additionallyAllowedTenantIds =
|
|
3161
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
3143
3162
|
const configuration = Object.assign({}, (typeof certificatePathOrConfiguration === "string"
|
|
3144
3163
|
? {
|
|
3145
3164
|
certificatePath: certificatePathOrConfiguration,
|
|
@@ -3234,7 +3253,7 @@ class ClientSecretCredential {
|
|
|
3234
3253
|
throw new Error("ClientSecretCredential: tenantId, clientId, and clientSecret are required parameters. To troubleshoot, visit https://aka.ms/azsdk/js/identity/serviceprincipalauthentication/troubleshoot.");
|
|
3235
3254
|
}
|
|
3236
3255
|
this.tenantId = tenantId;
|
|
3237
|
-
this.additionallyAllowedTenantIds =
|
|
3256
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
3238
3257
|
this.msalFlow = new MsalClientSecret(Object.assign(Object.assign({}, options), { logger: logger$7,
|
|
3239
3258
|
clientId,
|
|
3240
3259
|
tenantId,
|
|
@@ -3314,7 +3333,7 @@ class UsernamePasswordCredential {
|
|
|
3314
3333
|
throw new Error("UsernamePasswordCredential: tenantId, clientId, username and password are required parameters. To troubleshoot, visit https://aka.ms/azsdk/js/identity/usernamepasswordcredential/troubleshoot.");
|
|
3315
3334
|
}
|
|
3316
3335
|
this.tenantId = tenantId;
|
|
3317
|
-
this.additionallyAllowedTenantIds =
|
|
3336
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
3318
3337
|
this.msalFlow = new MsalUsernamePassword(Object.assign(Object.assign({}, options), { logger: logger$6,
|
|
3319
3338
|
clientId,
|
|
3320
3339
|
tenantId,
|
|
@@ -3548,7 +3567,7 @@ class AzureDeveloperCliCredential {
|
|
|
3548
3567
|
checkTenantId(logger$4, options === null || options === void 0 ? void 0 : options.tenantId);
|
|
3549
3568
|
this.tenantId = options === null || options === void 0 ? void 0 : options.tenantId;
|
|
3550
3569
|
}
|
|
3551
|
-
this.additionallyAllowedTenantIds =
|
|
3570
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
3552
3571
|
this.timeout = options === null || options === void 0 ? void 0 : options.processTimeoutInMs;
|
|
3553
3572
|
}
|
|
3554
3573
|
/**
|
|
@@ -3781,7 +3800,7 @@ class InteractiveBrowserCredential {
|
|
|
3781
3800
|
? options.redirectUri()
|
|
3782
3801
|
: options.redirectUri || "http://localhost";
|
|
3783
3802
|
this.tenantId = options === null || options === void 0 ? void 0 : options.tenantId;
|
|
3784
|
-
this.additionallyAllowedTenantIds =
|
|
3803
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
3785
3804
|
this.msalFlow = new MsalOpenBrowser(Object.assign(Object.assign({}, options), { tokenCredentialOptions: options, logger: logger$3,
|
|
3786
3805
|
redirectUri }));
|
|
3787
3806
|
this.disableAutomaticAuthentication = options === null || options === void 0 ? void 0 : options.disableAutomaticAuthentication;
|
|
@@ -3897,7 +3916,7 @@ class DeviceCodeCredential {
|
|
|
3897
3916
|
*/
|
|
3898
3917
|
constructor(options) {
|
|
3899
3918
|
this.tenantId = options === null || options === void 0 ? void 0 : options.tenantId;
|
|
3900
|
-
this.additionallyAllowedTenantIds =
|
|
3919
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
3901
3920
|
this.msalFlow = new MsalDeviceCode(Object.assign(Object.assign({}, options), { logger: logger$2, userPromptCallback: (options === null || options === void 0 ? void 0 : options.userPromptCallback) || defaultDeviceCodePromptCallback, tokenCredentialOptions: options || {} }));
|
|
3902
3921
|
this.disableAutomaticAuthentication = options === null || options === void 0 ? void 0 : options.disableAutomaticAuthentication;
|
|
3903
3922
|
}
|
|
@@ -4016,7 +4035,7 @@ class AuthorizationCodeCredential {
|
|
|
4016
4035
|
}
|
|
4017
4036
|
// TODO: Validate tenant if provided
|
|
4018
4037
|
this.tenantId = tenantId;
|
|
4019
|
-
this.additionallyAllowedTenantIds =
|
|
4038
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(options === null || options === void 0 ? void 0 : options.additionallyAllowedTenants);
|
|
4020
4039
|
this.msalFlow = new MsalAuthorizationCode(Object.assign(Object.assign({}, options), { clientSecret,
|
|
4021
4040
|
clientId,
|
|
4022
4041
|
tenantId, tokenCredentialOptions: options || {}, logger: logger$1, redirectUri: this.redirectUri, authorizationCode: this.authorizationCode }));
|
|
@@ -4098,7 +4117,7 @@ class MsalOnBehalfOf extends MsalNode {
|
|
|
4098
4117
|
const credentialName = "OnBehalfOfCredential";
|
|
4099
4118
|
const logger = credentialLogger(credentialName);
|
|
4100
4119
|
/**
|
|
4101
|
-
* Enables authentication to Microsoft Entra ID using the [On Behalf Of flow](https://
|
|
4120
|
+
* Enables authentication to Microsoft Entra ID using the [On Behalf Of flow](https://learn.microsoft.com/azure/active-directory/develop/v2-oauth2-on-behalf-of-flow).
|
|
4102
4121
|
*/
|
|
4103
4122
|
class OnBehalfOfCredential {
|
|
4104
4123
|
constructor(options) {
|
|
@@ -4110,7 +4129,7 @@ class OnBehalfOfCredential {
|
|
|
4110
4129
|
throw new Error(`${credentialName}: tenantId, clientId, clientSecret (or certificatePath) and userAssertionToken are required parameters.`);
|
|
4111
4130
|
}
|
|
4112
4131
|
this.tenantId = tenantId;
|
|
4113
|
-
this.additionallyAllowedTenantIds =
|
|
4132
|
+
this.additionallyAllowedTenantIds = resolveAdditionallyAllowedTenantIds(additionallyAllowedTenantIds);
|
|
4114
4133
|
this.msalFlow = new MsalOnBehalfOf(Object.assign(Object.assign({}, this.options), { logger, tokenCredentialOptions: this.options }));
|
|
4115
4134
|
}
|
|
4116
4135
|
/**
|