@azure/msal-node 1.11.0 → 1.12.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.
@@ -1753,7 +1753,7 @@ class TokenCache {
1753
1753
 
1754
1754
  /* eslint-disable header/header */
1755
1755
  const name = "@azure/msal-node";
1756
- const version = "1.11.0";
1756
+ const version = "1.12.0";
1757
1757
 
1758
1758
  /*
1759
1759
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -1966,7 +1966,7 @@ class ClientApplication {
1966
1966
  this.logger.verbose(`building oauth client configuration with the authority: ${authority}`, requestCorrelationId);
1967
1967
  const discoveredAuthority = await this.createAuthority(authority, azureRegionConfiguration, requestCorrelationId, userAzureCloudOptions);
1968
1968
  serverTelemetryManager == null ? void 0 : serverTelemetryManager.updateRegionDiscoveryMetadata(discoveredAuthority.regionDiscoveryMetadata);
1969
- return {
1969
+ const clientConfiguration = {
1970
1970
  authOptions: {
1971
1971
  clientId: this.config.auth.clientId,
1972
1972
  authority: discoveredAuthority,
@@ -1999,6 +1999,7 @@ class ClientApplication {
1999
1999
  persistencePlugin: this.config.cache.cachePlugin,
2000
2000
  serializableCache: this.tokenCache
2001
2001
  };
2002
+ return clientConfiguration;
2002
2003
  }
2003
2004
 
2004
2005
  getClientAssertion(authority) {
@@ -2315,6 +2316,18 @@ class ConfidentialClientApplication extends ClientApplication {
2315
2316
  constructor(configuration) {
2316
2317
  super(configuration);
2317
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;
2318
2331
  }
2319
2332
  /**
2320
2333
  * Acquires tokens from the authority for the application (not for an end user).
@@ -2345,7 +2358,7 @@ class ConfidentialClientApplication extends ClientApplication {
2345
2358
 
2346
2359
  try {
2347
2360
  const clientCredentialConfig = await this.buildOauthClientConfiguration(validRequest.authority, validRequest.correlationId, serverTelemetryManager, azureRegionConfiguration, request.azureCloudOptions);
2348
- const clientCredentialClient = new ClientCredentialClient(clientCredentialConfig);
2361
+ const clientCredentialClient = new ClientCredentialClient(clientCredentialConfig, this.appTokenProvider);
2349
2362
  this.logger.verbose("Client credential client created", validRequest.correlationId);
2350
2363
  return clientCredentialClient.acquireToken(validRequest);
2351
2364
  } catch (e) {
@@ -2397,7 +2410,16 @@ class ConfidentialClientApplication extends ClientApplication {
2397
2410
  thumbprint: Constants$1.EMPTY_STRING,
2398
2411
  privateKey: Constants$1.EMPTY_STRING
2399
2412
  };
2400
- 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
+
2401
2423
 
2402
2424
  if (clientSecretNotEmpty && clientAssertionNotEmpty || clientAssertionNotEmpty && certificateNotEmpty || clientSecretNotEmpty && certificateNotEmpty) {
2403
2425
  throw ClientAuthError.createInvalidCredentialError();