@azure/identity 4.3.1-alpha.20240628.2 → 4.3.1-alpha.20240702.3

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -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,