@azure/identity 3.2.0-alpha.20230330.2 → 3.2.0-alpha.20230411.7

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 CHANGED
@@ -473,7 +473,7 @@ class MsalBaseUtilities {
473
473
  }
474
474
  // transformations.ts
475
475
  function publicToMsal(account) {
476
- const [environment] = account.authority.match(/([a-z]*\.[a-z]*\.[a-z]*)/) || [];
476
+ const [environment] = account.authority.match(/([a-z]*\.[a-z]*\.[a-z]*)/) || [""];
477
477
  return Object.assign(Object.assign({}, account), { localAccountId: account.homeAccountId, environment });
478
478
  }
479
479
  function msalToPublic(clientId, account) {
@@ -1993,37 +1993,28 @@ const logger$g = credentialLogger(credentialName$3);
1993
1993
  */
1994
1994
  class WorkloadIdentityCredential {
1995
1995
  /**
1996
- * @internal
1997
- * @hidden
1996
+ * WorkloadIdentityCredential supports Azure workload identity on Kubernetes.
1997
+ *
1998
+ * @param options - The identity client options to use for authentication.
1998
1999
  */
1999
2000
  constructor(options) {
2000
2001
  this.azureFederatedTokenFileContent = undefined;
2001
2002
  this.cacheDate = undefined;
2003
+ // Logging environment variables for error details
2004
+ const assignedEnv = processEnvVars(SupportedWorkloadEnvironmentVariables).assigned.join(", ");
2005
+ logger$g.info(`Found the following environment variables: ${assignedEnv}`);
2002
2006
  const workloadIdentityCredentialOptions = options;
2003
- if ((workloadIdentityCredentialOptions === null || workloadIdentityCredentialOptions === void 0 ? void 0 : workloadIdentityCredentialOptions.clientId) &&
2004
- (workloadIdentityCredentialOptions === null || workloadIdentityCredentialOptions === void 0 ? void 0 : workloadIdentityCredentialOptions.tenantId) &&
2005
- (workloadIdentityCredentialOptions === null || workloadIdentityCredentialOptions === void 0 ? void 0 : workloadIdentityCredentialOptions.federatedTokenFilePath)) {
2006
- const tenantId = workloadIdentityCredentialOptions.tenantId;
2007
- if (tenantId) {
2008
- checkTenantId(logger$g, tenantId);
2009
- }
2010
- this.federatedTokenFilePath = workloadIdentityCredentialOptions.federatedTokenFilePath;
2011
- logger$g.info(`Invoking ClientAssertionCredential with tenant ID: ${tenantId}, clientId: ${workloadIdentityCredentialOptions.clientId} and federated token path: [REDACTED]`);
2012
- this.client = new ClientAssertionCredential(tenantId, workloadIdentityCredentialOptions.clientId, this.readFileContents.bind(this), options);
2007
+ const tenantId = workloadIdentityCredentialOptions.tenantId || process.env.AZURE_TENANT_ID;
2008
+ const clientId = workloadIdentityCredentialOptions.clientId || process.env.AZURE_CLIENT_ID;
2009
+ this.federatedTokenFilePath =
2010
+ workloadIdentityCredentialOptions.federatedTokenFilePath ||
2011
+ process.env.AZURE_FEDERATED_TOKEN_FILE;
2012
+ if (tenantId) {
2013
+ checkTenantId(logger$g, tenantId);
2013
2014
  }
2014
- else {
2015
- // Keep track of any missing environment variables for error details
2016
- const assigned = processEnvVars(SupportedWorkloadEnvironmentVariables).assigned.join(", ");
2017
- logger$g.info(`Found the following environment variables: ${assigned}`);
2018
- const tenantId = process.env.AZURE_TENANT_ID, clientId = process.env.AZURE_CLIENT_ID, federatedTokenFilePath = process.env.AZURE_FEDERATED_TOKEN_FILE;
2019
- this.federatedTokenFilePath = federatedTokenFilePath;
2020
- if (tenantId) {
2021
- checkTenantId(logger$g, tenantId);
2022
- }
2023
- if (tenantId && clientId && federatedTokenFilePath) {
2024
- logger$g.info(`Invoking ClientAssertionCredential with the following environment variables tenant ID: ${tenantId}, clientId: ${clientId} and federatedTokenFilePath: [REDACTED]`);
2025
- this.client = new ClientAssertionCredential(tenantId, clientId, this.readFileContents.bind(this), options);
2026
- }
2015
+ if (clientId && tenantId && this.federatedTokenFilePath) {
2016
+ logger$g.info(`Invoking ClientAssertionCredential with tenant ID: ${tenantId}, clientId: ${workloadIdentityCredentialOptions.clientId} and federated token path: [REDACTED]`);
2017
+ this.client = new ClientAssertionCredential(tenantId, clientId, this.readFileContents.bind(this), options);
2027
2018
  }
2028
2019
  }
2029
2020
  /**
@@ -3563,6 +3554,34 @@ class DefaultManagedIdentityCredential extends ManagedIdentityCredential {
3563
3554
  }
3564
3555
  }
3565
3556
  }
3557
+ /**
3558
+ * A shim around WorkloadIdentityCredential that adapts it to accept
3559
+ * `DefaultAzureCredentialOptions`.
3560
+ *
3561
+ * @internal
3562
+ */
3563
+ class DefaultWorkloadIdentityCredential extends WorkloadIdentityCredential {
3564
+ // Constructor overload with just the other default options
3565
+ // Last constructor overload with Union of all options not required since the above two constructor overloads have optional properties
3566
+ constructor(options) {
3567
+ var _a, _b, _c;
3568
+ const managedIdentityClientId = (_a = options === null || options === void 0 ? void 0 : options.managedIdentityClientId) !== null && _a !== void 0 ? _a : process.env.AZURE_CLIENT_ID;
3569
+ const workloadIdentityClientId = (_b = options === null || options === void 0 ? void 0 : options.workloadIdentityClientId) !== null && _b !== void 0 ? _b : managedIdentityClientId;
3570
+ const workloadFile = process.env.AZURE_FEDERATED_TOKEN_FILE;
3571
+ const tenantId = (_c = options === null || options === void 0 ? void 0 : options.tenantId) !== null && _c !== void 0 ? _c : process.env.AZURE_TENANT_ID;
3572
+ if (workloadFile && workloadIdentityClientId) {
3573
+ const workloadIdentityCredentialOptions = Object.assign(Object.assign({}, options), { tenantId, clientId: workloadIdentityClientId, federatedTokenFilePath: workloadFile });
3574
+ super(workloadIdentityCredentialOptions);
3575
+ }
3576
+ else if (tenantId) {
3577
+ const workloadIdentityClientTenantOptions = Object.assign(Object.assign({}, options), { tenantId });
3578
+ super(workloadIdentityClientTenantOptions);
3579
+ }
3580
+ else {
3581
+ super(options);
3582
+ }
3583
+ }
3584
+ }
3566
3585
  class DefaultAzureDeveloperCliCredential extends AzureDeveloperCliCredential {
3567
3586
  constructor(options) {
3568
3587
  super(Object.assign({ processTimeoutInMs: options === null || options === void 0 ? void 0 : options.developerCredentialTimeOutInMs }, options));
@@ -3580,7 +3599,7 @@ class DefaultAzurePowershellCredential extends AzurePowerShellCredential {
3580
3599
  }
3581
3600
  const defaultCredentials = [
3582
3601
  EnvironmentCredential,
3583
- WorkloadIdentityCredential,
3602
+ DefaultWorkloadIdentityCredential,
3584
3603
  DefaultManagedIdentityCredential,
3585
3604
  DefaultAzureDeveloperCliCredential,
3586
3605
  DefaultAzureCliCredential,
@@ -4135,6 +4154,7 @@ exports.AuthenticationErrorName = AuthenticationErrorName;
4135
4154
  exports.AuthenticationRequiredError = AuthenticationRequiredError;
4136
4155
  exports.AuthorizationCodeCredential = AuthorizationCodeCredential;
4137
4156
  exports.AzureCliCredential = AzureCliCredential;
4157
+ exports.AzureDeveloperCliCredential = AzureDeveloperCliCredential;
4138
4158
  exports.AzurePowerShellCredential = AzurePowerShellCredential;
4139
4159
  exports.ChainedTokenCredential = ChainedTokenCredential;
4140
4160
  exports.ClientAssertionCredential = ClientAssertionCredential;