@azure/identity 2.0.3-alpha.20220211.2 → 2.0.3

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
@@ -1,28 +1,16 @@
1
1
  # Release History
2
2
 
3
- ## 2.1.0-beta.1 (Unreleased)
3
+ ## 2.0.3 (2022-02-16)
4
4
 
5
5
  ### Features Added
6
6
 
7
- - Added log warning for non-support of user assigned identity in Managed Identity credentials in Cloud Shell environments
8
-
9
- ### Breaking Changes
7
+ - Added log warning for non-support of user assigned identity in Managed Identity credentials in Cloud Shell environments.
10
8
 
11
9
  ### Bugs Fixed
12
10
 
13
- ### Other Changes
14
-
15
- ## 2.0.3 (Unreleased)
16
-
17
- ### Features Added
18
-
19
- - Added log warning for non-support of user assigned identity in Managed Identity credentials in Cloud Shell environments
20
-
21
- ### Breaking Changes
22
-
23
- ### Bugs Fixed
24
-
25
- ### Other Changes
11
+ - Fixed bug that duplicated the tenant Id on the URI of outgoing requests when passing an `authorityHost` ending with a tenant Id.
12
+ - `ManagedIdentityCredential` now won't retry when it tries to ping the IMDS endpoint.
13
+ - Now we are specifying the maximum number of retries to 3 to ensure that maximum retries won't change without notice.
26
14
 
27
15
  ## 2.0.2 (2022-02-03)
28
16
 
package/dist/index.js CHANGED
@@ -123,7 +123,7 @@ class AuthenticationError extends Error {
123
123
  errorDescription: "An unknown error occurred and no additional details are available.",
124
124
  };
125
125
  }
126
- super(`${errorResponse.error}(status code ${statusCode}).\nMore details:\n${errorResponse.errorDescription}`);
126
+ super(`${errorResponse.error} Status code: ${statusCode}\nMore details:\n${errorResponse.errorDescription}`);
127
127
  this.statusCode = statusCode;
128
128
  this.errorResponse = errorResponse;
129
129
  // Ensure that this type reports the correct name
@@ -376,7 +376,9 @@ class IdentityClient extends coreClient.ServiceClient {
376
376
  if (!baseUri.startsWith("https:")) {
377
377
  throw new Error("The authorityHost address must use the 'https' protocol.");
378
378
  }
379
- super(Object.assign(Object.assign({ requestContentType: "application/json; charset=utf-8" }, options), { userAgentOptions: {
379
+ super(Object.assign(Object.assign({ requestContentType: "application/json; charset=utf-8", retryOptions: {
380
+ maxRetries: 3,
381
+ } }, options), { userAgentOptions: {
380
382
  userAgentPrefix,
381
383
  }, baseUri }));
382
384
  this.authorityHost = baseUri;
@@ -601,6 +603,9 @@ function getAuthority(tenantId, host) {
601
603
  if (!host) {
602
604
  host = DefaultAuthorityHost;
603
605
  }
606
+ if (new RegExp(`${tenantId}/?$`).test(host)) {
607
+ return host;
608
+ }
604
609
  if (host.endsWith("/")) {
605
610
  return host + tenantId;
606
611
  }
@@ -2769,15 +2774,20 @@ class ManagedIdentityCredential {
2769
2774
  */
2770
2775
  constructor(clientIdOrOptions, options) {
2771
2776
  this.isEndpointUnavailable = null;
2777
+ let _options;
2772
2778
  if (typeof clientIdOrOptions === "string") {
2773
2779
  // clientId, options constructor
2774
2780
  this.clientId = clientIdOrOptions;
2775
- this.identityClient = new IdentityClient(options);
2781
+ _options = options;
2776
2782
  }
2777
2783
  else {
2778
2784
  // options only constructor
2779
- this.identityClient = new IdentityClient(clientIdOrOptions);
2785
+ _options = options;
2780
2786
  }
2787
+ this.identityClient = new IdentityClient(_options);
2788
+ this.isAvailableIdentityClient = new IdentityClient(Object.assign(Object.assign({}, _options), { retryOptions: {
2789
+ maxRetries: 0,
2790
+ } }));
2781
2791
  }
2782
2792
  async cachedAvailableMSI(scopes, clientId, getTokenOptions) {
2783
2793
  if (this.cachedMSI) {
@@ -2785,7 +2795,7 @@ class ManagedIdentityCredential {
2785
2795
  }
2786
2796
  const MSIs = [fabricMsi, appServiceMsi2017, cloudShellMsi, arcMsi, tokenExchangeMsi(), imdsMsi];
2787
2797
  for (const msi of MSIs) {
2788
- if (await msi.isAvailable(scopes, this.identityClient, clientId, getTokenOptions)) {
2798
+ if (await msi.isAvailable(scopes, this.isAvailableIdentityClient, clientId, getTokenOptions)) {
2789
2799
  this.cachedMSI = msi;
2790
2800
  return msi;
2791
2801
  }