@azure/identity 4.3.1-alpha.20240628.2 → 4.4.0

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.
package/README.md CHANGED
@@ -10,7 +10,7 @@ Key links:
10
10
  - [Package (npm)](https://www.npmjs.com/package/@azure/identity)
11
11
  - [API Reference Documentation](https://learn.microsoft.com/javascript/api/@azure/identity)
12
12
  - [Microsoft Entra ID documentation](https://learn.microsoft.com/entra/identity)
13
- - [Samples](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples/v2)
13
+ - [Samples](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/samples)
14
14
 
15
15
  ## Getting started
16
16
 
package/dist/index.js CHANGED
@@ -46,7 +46,7 @@ var child_process__namespace = /*#__PURE__*/_interopNamespaceDefault(child_proce
46
46
  /**
47
47
  * Current version of the `@azure/identity` package.
48
48
  */
49
- const SDK_VERSION = `4.3.1`;
49
+ const SDK_VERSION = `4.4.0`;
50
50
  /**
51
51
  * The default client ID for authentication
52
52
  * @internal
@@ -2056,6 +2056,16 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
2056
2056
  state.logger.getToken.info("Attempting to acquire token silently");
2057
2057
  return app.acquireTokenSilent(silentRequest);
2058
2058
  }
2059
+ /**
2060
+ * Builds an authority URL for the given request. The authority may be different than the one used when creating the MSAL client
2061
+ * if the user is creating cross-tenant requests
2062
+ */
2063
+ function calculateRequestAuthority(options) {
2064
+ if (options === null || options === void 0 ? void 0 : options.tenantId) {
2065
+ return getAuthority(options.tenantId, createMsalClientOptions.authorityHost);
2066
+ }
2067
+ return state.msalConfig.auth.authority;
2068
+ }
2059
2069
  /**
2060
2070
  * Performs silent authentication using MSAL to acquire an access token.
2061
2071
  * If silent authentication fails, falls back to interactive authentication.
@@ -2109,7 +2119,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
2109
2119
  try {
2110
2120
  const response = await msalApp.acquireTokenByClientCredential({
2111
2121
  scopes,
2112
- authority: state.msalConfig.auth.authority,
2122
+ authority: calculateRequestAuthority(options),
2113
2123
  azureRegion: calculateRegionalAuthority(),
2114
2124
  claims: options === null || options === void 0 ? void 0 : options.claims,
2115
2125
  });
@@ -2131,7 +2141,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
2131
2141
  try {
2132
2142
  const response = await msalApp.acquireTokenByClientCredential({
2133
2143
  scopes,
2134
- authority: state.msalConfig.auth.authority,
2144
+ authority: calculateRequestAuthority(options),
2135
2145
  azureRegion: calculateRegionalAuthority(),
2136
2146
  claims: options === null || options === void 0 ? void 0 : options.claims,
2137
2147
  clientAssertion,
@@ -2154,7 +2164,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
2154
2164
  try {
2155
2165
  const response = await msalApp.acquireTokenByClientCredential({
2156
2166
  scopes,
2157
- authority: state.msalConfig.auth.authority,
2167
+ authority: calculateRequestAuthority(options),
2158
2168
  azureRegion: calculateRegionalAuthority(),
2159
2169
  claims: options === null || options === void 0 ? void 0 : options.claims,
2160
2170
  });
@@ -2178,7 +2188,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
2178
2188
  scopes,
2179
2189
  cancel: (_b = (_a = options === null || options === void 0 ? void 0 : options.abortSignal) === null || _a === void 0 ? void 0 : _a.aborted) !== null && _b !== void 0 ? _b : false,
2180
2190
  deviceCodeCallback,
2181
- authority: state.msalConfig.auth.authority,
2191
+ authority: calculateRequestAuthority(options),
2182
2192
  claims: options === null || options === void 0 ? void 0 : options.claims,
2183
2193
  };
2184
2194
  const deviceCodeRequest = msalApp.acquireTokenByDeviceCode(requestOptions);
@@ -2198,7 +2208,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
2198
2208
  scopes,
2199
2209
  username,
2200
2210
  password,
2201
- authority: state.msalConfig.auth.authority,
2211
+ authority: calculateRequestAuthority(options),
2202
2212
  claims: options === null || options === void 0 ? void 0 : options.claims,
2203
2213
  };
2204
2214
  return msalApp.acquireTokenByUsernamePassword(requestOptions);
@@ -2227,7 +2237,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
2227
2237
  scopes,
2228
2238
  redirectUri,
2229
2239
  code: authorizationCode,
2230
- authority: state.msalConfig.auth.authority,
2240
+ authority: calculateRequestAuthority(options),
2231
2241
  claims: options === null || options === void 0 ? void 0 : options.claims,
2232
2242
  });
2233
2243
  });
@@ -2253,7 +2263,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
2253
2263
  try {
2254
2264
  const response = await msalApp.acquireTokenOnBehalfOf({
2255
2265
  scopes,
2256
- authority: state.msalConfig.auth.authority,
2266
+ authority: calculateRequestAuthority(options),
2257
2267
  claims: options.claims,
2258
2268
  oboAssertion: userAssertionToken,
2259
2269
  });
@@ -2320,7 +2330,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
2320
2330
  await interactiveBrowserMockable.open(url, { wait: true, newInstance: true });
2321
2331
  },
2322
2332
  scopes,
2323
- authority: state.msalConfig.auth.authority,
2333
+ authority: calculateRequestAuthority(options),
2324
2334
  claims: options === null || options === void 0 ? void 0 : options.claims,
2325
2335
  loginHint: options === null || options === void 0 ? void 0 : options.loginHint,
2326
2336
  errorTemplate: (_a = options === null || options === void 0 ? void 0 : options.browserCustomizationOptions) === null || _a === void 0 ? void 0 : _a.errorMessage,