@azure/msal-node 1.10.0 → 1.12.1

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.
@@ -357,7 +357,8 @@ const DEFAULT_AUTH_OPTIONS = {
357
357
  azureCloudOptions: {
358
358
  azureCloudInstance: AzureCloudInstance.None,
359
359
  tenant: Constants$1.EMPTY_STRING
360
- }
360
+ },
361
+ skipAuthorityMetadataCache: false
361
362
  };
362
363
  const DEFAULT_CACHE_OPTIONS = {};
363
364
  const DEFAULT_LOGGER_OPTIONS = {
@@ -1752,7 +1753,7 @@ class TokenCache {
1752
1753
 
1753
1754
  /* eslint-disable header/header */
1754
1755
  const name = "@azure/msal-node";
1755
- const version = "1.10.0";
1756
+ const version = "1.12.1";
1756
1757
 
1757
1758
  /*
1758
1759
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1965,7 +1966,7 @@ class ClientApplication {
1965
1966
  this.logger.verbose(`building oauth client configuration with the authority: ${authority}`, requestCorrelationId);
1966
1967
  const discoveredAuthority = await this.createAuthority(authority, azureRegionConfiguration, requestCorrelationId, userAzureCloudOptions);
1967
1968
  serverTelemetryManager == null ? void 0 : serverTelemetryManager.updateRegionDiscoveryMetadata(discoveredAuthority.regionDiscoveryMetadata);
1968
- return {
1969
+ const clientConfiguration = {
1969
1970
  authOptions: {
1970
1971
  clientId: this.config.auth.clientId,
1971
1972
  authority: discoveredAuthority,
@@ -1998,6 +1999,7 @@ class ClientApplication {
1998
1999
  persistencePlugin: this.config.cache.cachePlugin,
1999
2000
  serializableCache: this.tokenCache
2000
2001
  };
2002
+ return clientConfiguration;
2001
2003
  }
2002
2004
 
2003
2005
  getClientAssertion(authority) {
@@ -2064,7 +2066,8 @@ class ClientApplication {
2064
2066
  knownAuthorities: this.config.auth.knownAuthorities,
2065
2067
  cloudDiscoveryMetadata: this.config.auth.cloudDiscoveryMetadata,
2066
2068
  authorityMetadata: this.config.auth.authorityMetadata,
2067
- azureRegionConfiguration
2069
+ azureRegionConfiguration,
2070
+ skipAuthorityMetadataCache: this.config.auth.skipAuthorityMetadataCache
2068
2071
  };
2069
2072
  return await AuthorityFactory.createDiscoveredInstance(authorityUrl, this.config.system.networkClient, this.storage, authorityOptions, this.config.system.proxyUrl);
2070
2073
  }
@@ -2313,6 +2316,18 @@ class ConfidentialClientApplication extends ClientApplication {
2313
2316
  constructor(configuration) {
2314
2317
  super(configuration);
2315
2318
  this.setClientCredential(this.config);
2319
+ this.appTokenProvider = undefined;
2320
+ }
2321
+ /**
2322
+ * This extensibility point only works for the client_credential flow, i.e. acquireTokenByClientCredential and
2323
+ * is meant for Azure SDK to enhance Managed Identity support.
2324
+ *
2325
+ * @param IAppTokenProvider - Extensibility interface, which allows the app developer to return a token from a custom source.
2326
+ */
2327
+
2328
+
2329
+ SetAppTokenProvider(provider) {
2330
+ this.appTokenProvider = provider;
2316
2331
  }
2317
2332
  /**
2318
2333
  * Acquires tokens from the authority for the application (not for an end user).
@@ -2343,7 +2358,7 @@ class ConfidentialClientApplication extends ClientApplication {
2343
2358
 
2344
2359
  try {
2345
2360
  const clientCredentialConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, azureRegionConfiguration, request.azureCloudOptions);
2346
- const clientCredentialClient = new ClientCredentialClient(clientCredentialConfig);
2361
+ const clientCredentialClient = new ClientCredentialClient(clientCredentialConfig, this.appTokenProvider);
2347
2362
  this.logger.verbose("Client credential client created", validRequest.correlationId);
2348
2363
  return clientCredentialClient.acquireToken(validRequest);
2349
2364
  } catch (e) {
@@ -2395,7 +2410,16 @@ class ConfidentialClientApplication extends ClientApplication {
2395
2410
  thumbprint: Constants$1.EMPTY_STRING,
2396
2411
  privateKey: Constants$1.EMPTY_STRING
2397
2412
  };
2398
- const certificateNotEmpty = !StringUtils.isEmpty(certificate.thumbprint) || !StringUtils.isEmpty(certificate.privateKey); // Check that at most one credential is set on the application
2413
+ const certificateNotEmpty = !StringUtils.isEmpty(certificate.thumbprint) || !StringUtils.isEmpty(certificate.privateKey);
2414
+ /*
2415
+ * If app developer configures this callback, they don't need a credential
2416
+ * i.e. AzureSDK can get token from Managed Identity without a cert / secret
2417
+ */
2418
+
2419
+ if (this.appTokenProvider) {
2420
+ return;
2421
+ } // Check that at most one credential is set on the application
2422
+
2399
2423
 
2400
2424
  if (clientSecretNotEmpty && clientAssertionNotEmpty || clientAssertionNotEmpty && certificateNotEmpty || clientSecretNotEmpty && certificateNotEmpty) {
2401
2425
  throw ClientAuthError.createInvalidCredentialError();