@azure/identity 4.5.0-alpha.20240916.2 → 4.5.0-alpha.20240917.2

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -1072,6 +1072,19 @@ function ensureValidMsalToken(scopes, msalToken, getTokenOptions) {
1072
1072
  throw error(`Response had no "accessToken" property.`);
1073
1073
  }
1074
1074
  }
1075
+ /**
1076
+ * Returns the authority host from either the options bag or the AZURE_AUTHORITY_HOST environment variable.
1077
+ *
1078
+ * Defaults to {@link DefaultAuthorityHost}.
1079
+ * @internal
1080
+ */
1081
+ function getAuthorityHost(options) {
1082
+ let authorityHost = options === null || options === void 0 ? void 0 : options.authorityHost;
1083
+ if (!authorityHost && coreUtil.isNodeLike) {
1084
+ authorityHost = process.env.AZURE_AUTHORITY_HOST;
1085
+ }
1086
+ return authorityHost !== null && authorityHost !== void 0 ? authorityHost : DefaultAuthorityHost;
1087
+ }
1075
1088
  /**
1076
1089
  * Generates a valid authority by combining a host with a tenantId.
1077
1090
  * @internal
@@ -1570,10 +1583,10 @@ const interactiveBrowserMockable = {
1570
1583
  * @returns The MSAL configuration object.
1571
1584
  */
1572
1585
  function generateMsalConfiguration(clientId, tenantId, msalClientOptions = {}) {
1573
- var _a, _b, _c, _d;
1586
+ var _a, _b, _c;
1574
1587
  const resolvedTenant = resolveTenantId((_a = msalClientOptions.logger) !== null && _a !== void 0 ? _a : msalLogger, tenantId, clientId);
1575
1588
  // TODO: move and reuse getIdentityClientAuthorityHost
1576
- const authority = getAuthority(resolvedTenant, (_b = msalClientOptions.authorityHost) !== null && _b !== void 0 ? _b : process.env.AZURE_AUTHORITY_HOST);
1589
+ const authority = getAuthority(resolvedTenant, getAuthorityHost(msalClientOptions));
1577
1590
  const httpClient = new IdentityClient(Object.assign(Object.assign({}, msalClientOptions.tokenCredentialOptions), { authorityHost: authority, loggingOptions: msalClientOptions.loggingOptions }));
1578
1591
  const msalConfig = {
1579
1592
  auth: {
@@ -1584,9 +1597,9 @@ function generateMsalConfiguration(clientId, tenantId, msalClientOptions = {}) {
1584
1597
  system: {
1585
1598
  networkClient: httpClient,
1586
1599
  loggerOptions: {
1587
- loggerCallback: defaultLoggerCallback((_c = msalClientOptions.logger) !== null && _c !== void 0 ? _c : msalLogger),
1600
+ loggerCallback: defaultLoggerCallback((_b = msalClientOptions.logger) !== null && _b !== void 0 ? _b : msalLogger),
1588
1601
  logLevel: getMSALLogLevel(logger$m.getLogLevel()),
1589
- piiLoggingEnabled: (_d = msalClientOptions.loggingOptions) === null || _d === void 0 ? void 0 : _d.enableUnsafeSupportLogging,
1602
+ piiLoggingEnabled: (_c = msalClientOptions.loggingOptions) === null || _c === void 0 ? void 0 : _c.enableUnsafeSupportLogging,
1590
1603
  },
1591
1604
  },
1592
1605
  };
@@ -1691,7 +1704,7 @@ To work with multiple accounts for the same Client ID and Tenant ID, please prov
1691
1704
  */
1692
1705
  function calculateRequestAuthority(options) {
1693
1706
  if (options === null || options === void 0 ? void 0 : options.tenantId) {
1694
- return getAuthority(options.tenantId, createMsalClientOptions.authorityHost);
1707
+ return getAuthority(options.tenantId, getAuthorityHost(createMsalClientOptions));
1695
1708
  }
1696
1709
  return state.msalConfig.auth.authority;
1697
1710
  }