@azure/identity 2.1.0-alpha.20220419.3 → 2.1.0-alpha.20220426.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.

Potentially problematic release.


This version of @azure/identity might be problematic. Click here for more details.

package/CHANGELOG.md CHANGED
@@ -15,6 +15,7 @@
15
15
  ### Other Changes
16
16
 
17
17
  - Upgraded to `@azure/core-tracing` version `^1.0.0`.
18
+ - Improved the errors displayed on the `AzureCliCredential`.
18
19
 
19
20
  ## 2.1.0-beta.2 (2022-03-22)
20
21
 
package/README.md CHANGED
@@ -120,12 +120,12 @@ If used from Node.js, the `DefaultAzureCredential` will attempt to authenticate
120
120
 
121
121
  ![DefaultAzureCredential authentication flow][defaultauthflow_image]
122
122
 
123
- - Environment - The `DefaultAzureCredential` will read account information specified via [environment variables](#environment-variables) and use it to authenticate.
124
- - Managed Identity - If the application is deployed to an Azure host with Managed Identity enabled, the `DefaultAzureCredential` will authenticate with that account.
125
- - Visual Studio Code - If the developer has authenticated with the [Visual Studio Code Azure Account extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.azure-account), the `DefaultAzureCredential` will authenticate using that account.
126
- - In `@azure/identity` version 2.0 or later, the [`@azure/identity-vscode`](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity-vscode) package must be installed for the Visual Studio Code authentication to work.
127
- - Azure CLI - If the developer has authenticated an account via the Azure CLI `az login` command, the `DefaultAzureCredential` will authenticate with that account.
128
- - Azure PowerShell - If the developer has authenticated using the Azure PowerShell module `Connect-AzAccount` command, the `DefaultAzureCredential` will authenticate with that account.
123
+ 1. **Environment** - The `DefaultAzureCredential` will read account information specified via [environment variables](#environment-variables) and use it to authenticate.
124
+ 1. **Managed Identity** - If the application is deployed to an Azure host with Managed Identity enabled, the `DefaultAzureCredential` will authenticate with that account.
125
+ 1. **Visual Studio Code** - If the developer has authenticated with the [Visual Studio Code Azure Account extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.azure-account), the `DefaultAzureCredential` will authenticate using that account.
126
+ - In `@azure/identity` version 2.0 or later, the [`@azure/identity-vscode`](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity-vscode) package must be installed for the Visual Studio Code authentication to work.
127
+ 1. **Azure CLI** - If the developer has authenticated an account via the Azure CLI `az login` command, the `DefaultAzureCredential` will authenticate with that account.
128
+ 1. **Azure PowerShell** - If the developer has authenticated using the Azure PowerShell module `Connect-AzAccount` command, the `DefaultAzureCredential` will authenticate with that account.
129
129
 
130
130
  ## Plugins
131
131
 
@@ -366,6 +366,6 @@ If you'd like to contribute to this library, please read the [contributing guide
366
366
  [azureclilogin_image]: https://raw.githubusercontent.com/Azure/azure-sdk-for-js/main/sdk/identity/identity/images/AzureCliLogin.png
367
367
  [azureclilogindevicecode_image]: https://raw.githubusercontent.com/Azure/azure-sdk-for-js/main/sdk/identity/identity/images/AzureCliLoginDeviceCode.png
368
368
  [azurepowershelllogin_image]: https://raw.githubusercontent.com/Azure/azure-sdk-for-js/main/sdk/identity/identity/images/AzurePowerShellLogin.png
369
- [defaultauthflow_image]: https://raw.githubusercontent.com/Azure/azure-sdk-for-js/main/sdk/identity/identity/images/DefaultAzureCredentialAuthenticationFlow.png
369
+ [defaultauthflow_image]: https://raw.githubusercontent.com/Azure/azure-sdk-for-js/main/sdk/identity/identity/images/mermaidjs/DefaultAzureCredentialAuthFlow.svg
370
370
 
371
371
  ![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fidentity%2Fidentity%2FREADME.png)
package/dist/index.js CHANGED
@@ -1542,13 +1542,14 @@ class AzureCliCredential {
1542
1542
  ensureValidScope(scope, logger$h);
1543
1543
  const resource = getScopeResource(scope);
1544
1544
  return tracingClient.withSpan(`${this.constructor.name}.getToken`, options, async () => {
1545
- var _a, _b, _c;
1545
+ var _a, _b, _c, _d;
1546
1546
  try {
1547
1547
  const obj = await cliCredentialInternals.getAzureCliAccessToken(resource, tenantId);
1548
- const isLoginError = (_a = obj.stderr) === null || _a === void 0 ? void 0 : _a.match("(.*)az login(.*)");
1549
- const isNotInstallError = ((_b = obj.stderr) === null || _b === void 0 ? void 0 : _b.match("az:(.*)not found")) || ((_c = obj.stderr) === null || _c === void 0 ? void 0 : _c.startsWith("'az' is not recognized"));
1548
+ const specificScope = (_a = obj.stderr) === null || _a === void 0 ? void 0 : _a.match("(.*)az login --scope(.*)");
1549
+ const isLoginError = ((_b = obj.stderr) === null || _b === void 0 ? void 0 : _b.match("(.*)az login(.*)")) && !specificScope;
1550
+ const isNotInstallError = ((_c = obj.stderr) === null || _c === void 0 ? void 0 : _c.match("az:(.*)not found")) || ((_d = obj.stderr) === null || _d === void 0 ? void 0 : _d.startsWith("'az' is not recognized"));
1550
1551
  if (isNotInstallError) {
1551
- const error = new CredentialUnavailableError("Azure CLI could not be found. Please visit https://aka.ms/azure-cli for installation instructions and then, once installed, authenticate to your Azure account using 'az login'.");
1552
+ const error = new CredentialUnavailableError("Azure CLI could not be found. Please visit https://aka.ms/azure-cli for installation instructions and then, once installed, authenticate to your Azure account using 'az login'.");
1552
1553
  logger$h.getToken.info(formatError(scopes, error));
1553
1554
  throw error;
1554
1555
  }
@@ -2878,7 +2879,6 @@ class ManagedIdentityCredential {
2878
2879
  * @hidden
2879
2880
  */
2880
2881
  constructor(clientIdOrOptions, options) {
2881
- var _a, _b;
2882
2882
  this.isEndpointUnavailable = null;
2883
2883
  let _options;
2884
2884
  if (typeof clientIdOrOptions === "string") {
@@ -2886,10 +2886,10 @@ class ManagedIdentityCredential {
2886
2886
  _options = options;
2887
2887
  }
2888
2888
  else {
2889
- this.clientId = (_a = clientIdOrOptions) === null || _a === void 0 ? void 0 : _a.clientId;
2889
+ this.clientId = clientIdOrOptions === null || clientIdOrOptions === void 0 ? void 0 : clientIdOrOptions.clientId;
2890
2890
  _options = clientIdOrOptions;
2891
2891
  }
2892
- this.resourceId = (_b = _options) === null || _b === void 0 ? void 0 : _b.resourceId;
2892
+ this.resourceId = _options === null || _options === void 0 ? void 0 : _options.resourceId;
2893
2893
  // For JavaScript users.
2894
2894
  if (this.clientId && this.resourceId) {
2895
2895
  throw new Error(`${ManagedIdentityCredential.name} - Client Id and Resource Id can't be provided at the same time.`);
@@ -2904,11 +2904,11 @@ class ManagedIdentityCredential {
2904
2904
  return this.cachedMSI;
2905
2905
  }
2906
2906
  const MSIs = [
2907
+ arcMsi,
2907
2908
  fabricMsi,
2908
2909
  appServiceMsi2019,
2909
2910
  appServiceMsi2017,
2910
2911
  cloudShellMsi,
2911
- arcMsi,
2912
2912
  tokenExchangeMsi(),
2913
2913
  imdsMsi,
2914
2914
  ];
@@ -3056,9 +3056,9 @@ class DefaultManagedIdentityCredential extends ManagedIdentityCredential {
3056
3056
  // Constructor overload with just the other default options
3057
3057
  // Last constructor overload with Union of all options not required since the above two constructor overloads have optional properties
3058
3058
  constructor(options) {
3059
- var _a, _b, _c;
3060
- const managedIdentityClientId = (_b = (_a = options) === null || _a === void 0 ? void 0 : _a.managedIdentityClientId) !== null && _b !== void 0 ? _b : process.env.AZURE_CLIENT_ID;
3061
- const managedResourceId = (_c = options) === null || _c === void 0 ? void 0 : _c.managedIdentityResourceId;
3059
+ var _a;
3060
+ const managedIdentityClientId = (_a = options === null || options === void 0 ? void 0 : options.managedIdentityClientId) !== null && _a !== void 0 ? _a : process.env.AZURE_CLIENT_ID;
3061
+ const managedResourceId = options === null || options === void 0 ? void 0 : options.managedIdentityResourceId;
3062
3062
  // ManagedIdentityCredential throws if both the resourceId and the clientId are provided.
3063
3063
  if (managedResourceId) {
3064
3064
  const managedIdentityResourceIdOptions = Object.assign(Object.assign({}, options), { resourceId: managedResourceId });