@azure/identity 2.0.2-alpha.20211115.3 → 2.0.2-alpha.20211123.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
@@ -4,6 +4,8 @@
4
4
 
5
5
  ### Features Added
6
6
 
7
+ - Improved the error message when `InteractiveBrowserCredential` is used with an unavailable port (such as when no `redirectUri` is provided, and the port `80` is busy) and when no browser is available.
8
+
7
9
  ### Breaking Changes
8
10
 
9
11
  ### Bugs Fixed
package/dist/index.js CHANGED
@@ -3049,6 +3049,20 @@ class MsalOpenBrowser extends MsalNode {
3049
3049
  }
3050
3050
  }
3051
3051
  app.on("connection", (socket) => socketToDestroy.push(socket));
3052
+ app.on("error", (err) => {
3053
+ cleanup();
3054
+ const code = err.code;
3055
+ if (code === "EACCES" || code === "EADDRINUSE") {
3056
+ reject(new CredentialUnavailableError([
3057
+ `InteractiveBrowserCredential: Access denied to port ${this.port}.`,
3058
+ `Try sending a redirect URI with a different port, as follows:`,
3059
+ '`new InteractiveBrowserCredential({ redirectUri: "http://localhost:1337" })`'
3060
+ ].join(" ")));
3061
+ }
3062
+ else {
3063
+ reject(new CredentialUnavailableError(`InteractiveBrowserCredential: Failed to start the necessary web server. Error: ${err.message}`));
3064
+ }
3065
+ });
3052
3066
  app.on("listening", () => {
3053
3067
  const openPromise = this.openAuthCodeUrl(scopes, options);
3054
3068
  const abortSignal = options === null || options === void 0 ? void 0 : options.abortSignal;
@@ -3085,7 +3099,7 @@ class MsalOpenBrowser extends MsalNode {
3085
3099
  await interactiveBrowserMockable.open(response, { wait: true });
3086
3100
  }
3087
3101
  catch (e) {
3088
- throw new CredentialUnavailableError(`Could not open a browser window. Error: ${e.message}`);
3102
+ throw new CredentialUnavailableError(`InteractiveBrowserCredential: Could not open a browser window. Error: ${e.message}`);
3089
3103
  }
3090
3104
  }
3091
3105
  }