@azure/msal-common 7.2.0 → 7.3.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.
Files changed (88) hide show
  1. package/dist/_virtual/_tslib.js +1 -1
  2. package/dist/account/AuthToken.js +1 -1
  3. package/dist/account/CcsCredential.js +1 -1
  4. package/dist/account/ClientInfo.js +1 -1
  5. package/dist/authority/Authority.js +1 -1
  6. package/dist/authority/AuthorityFactory.js +1 -1
  7. package/dist/authority/AuthorityMetadata.js +1 -1
  8. package/dist/authority/AuthorityOptions.js +1 -1
  9. package/dist/authority/AuthorityType.js +1 -1
  10. package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
  11. package/dist/authority/OpenIdConfigResponse.js +1 -1
  12. package/dist/authority/ProtocolMode.js +1 -1
  13. package/dist/authority/RegionDiscovery.js +1 -1
  14. package/dist/cache/CacheManager.js +1 -1
  15. package/dist/cache/entities/AccessTokenEntity.js +1 -1
  16. package/dist/cache/entities/AccountEntity.js +1 -1
  17. package/dist/cache/entities/AppMetadataEntity.js +1 -1
  18. package/dist/cache/entities/AuthorityMetadataEntity.js +1 -1
  19. package/dist/cache/entities/CacheRecord.js +1 -1
  20. package/dist/cache/entities/CredentialEntity.js +1 -1
  21. package/dist/cache/entities/IdTokenEntity.js +1 -1
  22. package/dist/cache/entities/RefreshTokenEntity.js +1 -1
  23. package/dist/cache/entities/ServerTelemetryEntity.js +1 -1
  24. package/dist/cache/entities/ThrottlingEntity.js +1 -1
  25. package/dist/cache/persistence/TokenCacheContext.js +1 -1
  26. package/dist/client/AuthorizationCodeClient.d.ts +1 -0
  27. package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
  28. package/dist/client/AuthorizationCodeClient.js +29 -13
  29. package/dist/client/AuthorizationCodeClient.js.map +1 -1
  30. package/dist/client/BaseClient.d.ts +3 -1
  31. package/dist/client/BaseClient.d.ts.map +1 -1
  32. package/dist/client/BaseClient.js +4 -2
  33. package/dist/client/BaseClient.js.map +1 -1
  34. package/dist/client/ClientCredentialClient.js +1 -1
  35. package/dist/client/DeviceCodeClient.d.ts.map +1 -1
  36. package/dist/client/DeviceCodeClient.js +13 -7
  37. package/dist/client/DeviceCodeClient.js.map +1 -1
  38. package/dist/client/OnBehalfOfClient.js +1 -1
  39. package/dist/client/RefreshTokenClient.d.ts +2 -1
  40. package/dist/client/RefreshTokenClient.d.ts.map +1 -1
  41. package/dist/client/RefreshTokenClient.js +39 -15
  42. package/dist/client/RefreshTokenClient.js.map +1 -1
  43. package/dist/client/SilentFlowClient.d.ts +2 -1
  44. package/dist/client/SilentFlowClient.d.ts.map +1 -1
  45. package/dist/client/SilentFlowClient.js +4 -4
  46. package/dist/client/SilentFlowClient.js.map +1 -1
  47. package/dist/client/UsernamePasswordClient.js +1 -1
  48. package/dist/config/ClientConfiguration.js +1 -1
  49. package/dist/crypto/ICrypto.js +1 -1
  50. package/dist/crypto/JoseHeader.js +1 -1
  51. package/dist/crypto/PopTokenGenerator.js +1 -1
  52. package/dist/error/AuthError.d.ts +10 -0
  53. package/dist/error/AuthError.d.ts.map +1 -1
  54. package/dist/error/AuthError.js +13 -1
  55. package/dist/error/AuthError.js.map +1 -1
  56. package/dist/error/ClientAuthError.js +1 -1
  57. package/dist/error/ClientConfigurationError.js +1 -1
  58. package/dist/error/InteractionRequiredAuthError.js +1 -1
  59. package/dist/error/JoseHeaderError.js +1 -1
  60. package/dist/error/ServerError.js +1 -1
  61. package/dist/index.cjs.js +213 -147
  62. package/dist/index.cjs.js.map +1 -1
  63. package/dist/index.js +1 -1
  64. package/dist/logger/Logger.js +1 -1
  65. package/dist/network/INetworkModule.js +1 -1
  66. package/dist/network/NetworkManager.js +1 -1
  67. package/dist/network/ThrottlingUtils.js +1 -1
  68. package/dist/packageMetadata.d.ts +1 -1
  69. package/dist/packageMetadata.js +2 -2
  70. package/dist/packageMetadata.js.map +1 -1
  71. package/dist/request/AuthenticationHeaderParser.js +1 -1
  72. package/dist/request/RequestParameterBuilder.js +1 -1
  73. package/dist/request/RequestValidator.js +1 -1
  74. package/dist/request/ScopeSet.js +1 -1
  75. package/dist/response/ResponseHandler.js +1 -1
  76. package/dist/telemetry/performance/PerformanceClient.js +1 -1
  77. package/dist/telemetry/performance/PerformanceEvent.d.ts +8 -0
  78. package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
  79. package/dist/telemetry/performance/PerformanceEvent.js +9 -1
  80. package/dist/telemetry/performance/PerformanceEvent.js.map +1 -1
  81. package/dist/telemetry/performance/StubPerformanceClient.js +1 -1
  82. package/dist/telemetry/server/ServerTelemetryManager.js +1 -1
  83. package/dist/url/UrlString.js +1 -1
  84. package/dist/utils/Constants.js +1 -1
  85. package/dist/utils/ProtocolUtils.js +1 -1
  86. package/dist/utils/StringUtils.js +1 -1
  87. package/dist/utils/TimeUtils.js +1 -1
  88. package/package.json +2 -4
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-common v7.2.0 2022-07-18 */
1
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
2
2
  'use strict';
3
3
  import { __extends } from '../_virtual/_tslib.js';
4
4
  import { ClientAuthError } from './ClientAuthError.js';
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-common v7.2.0 2022-07-18 */
1
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
2
2
  'use strict';
3
3
  import { __extends } from '../_virtual/_tslib.js';
4
4
  import { AuthError } from './AuthError.js';
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-common v7.2.0 2022-07-18 */
1
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
2
2
  'use strict';
3
3
  import { __extends } from '../_virtual/_tslib.js';
4
4
  import { AuthError } from './AuthError.js';
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-common v7.2.0 2022-07-18 */
1
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
2
2
  'use strict';
3
3
  import { __extends } from '../_virtual/_tslib.js';
4
4
  import { AuthError } from './AuthError.js';
package/dist/index.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @azure/msal-common v7.2.0 2022-07-18 */
1
+ /*! @azure/msal-common v7.3.0 2022-08-01 */
2
2
  'use strict';
3
3
  'use strict';
4
4
 
@@ -483,6 +483,10 @@ var AuthErrorMessage = {
483
483
  unexpectedError: {
484
484
  code: "unexpected_error",
485
485
  desc: "Unexpected error in authentication."
486
+ },
487
+ postRequestFailed: {
488
+ code: "post_request_failed",
489
+ desc: "Post request failed from the network, could be a 4xx/5xx or a network unavailability. Please check the exact error code for details."
486
490
  }
487
491
  };
488
492
  /**
@@ -511,6 +515,14 @@ var AuthError = /** @class */ (function (_super) {
511
515
  AuthError.createUnexpectedError = function (errDesc) {
512
516
  return new AuthError(AuthErrorMessage.unexpectedError.code, AuthErrorMessage.unexpectedError.desc + ": " + errDesc);
513
517
  };
518
+ /**
519
+ * Creates an error for post request failures.
520
+ * @param errDesc
521
+ * @returns
522
+ */
523
+ AuthError.createPostRequestFailed = function (errDesc) {
524
+ return new AuthError(AuthErrorMessage.postRequestFailed.code, AuthErrorMessage.postRequestFailed.desc + ": " + errDesc);
525
+ };
514
526
  return AuthError;
515
527
  }(Error));
516
528
 
@@ -1360,7 +1372,7 @@ var Logger = /** @class */ (function () {
1360
1372
 
1361
1373
  /* eslint-disable header/header */
1362
1374
  var name = "@azure/msal-common";
1363
- var version = "7.2.0";
1375
+ var version = "7.3.0";
1364
1376
 
1365
1377
  /*
1366
1378
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -3433,7 +3445,7 @@ exports.CcsCredentialType = void 0;
3433
3445
  * Base application class which will construct requests to send to and handle responses from the Microsoft STS using the authorization code flow.
3434
3446
  */
3435
3447
  var BaseClient = /** @class */ (function () {
3436
- function BaseClient(configuration) {
3448
+ function BaseClient(configuration, performanceClient) {
3437
3449
  // Set the configuration
3438
3450
  this.config = buildClientConfiguration(configuration);
3439
3451
  // Initialize the logger
@@ -3450,6 +3462,8 @@ var BaseClient = /** @class */ (function () {
3450
3462
  this.serverTelemetryManager = this.config.serverTelemetryManager;
3451
3463
  // set Authority
3452
3464
  this.authority = this.config.authOptions.authority;
3465
+ // set performance telemetry client
3466
+ this.performanceClient = performanceClient;
3453
3467
  }
3454
3468
  /**
3455
3469
  * Creates default headers for requests to token endpoint
@@ -5373,7 +5387,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5373
5387
  */
5374
5388
  AuthorizationCodeClient.prototype.createAuthCodeUrlQueryString = function (request) {
5375
5389
  return __awaiter(this, void 0, void 0, function () {
5376
- var parameterBuilder, requestScopes, correlationId, accountSid, clientInfo, clientInfo, popTokenGenerator, reqCnfData;
5390
+ var parameterBuilder, requestScopes, correlationId, accountSid, accountLoginHintClaim, clientInfo, clientInfo, clientInfo, popTokenGenerator, reqCnfData;
5377
5391
  return __generator(this, function (_a) {
5378
5392
  switch (_a.label) {
5379
5393
  case 0:
@@ -5403,7 +5417,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5403
5417
  if (request.domainHint) {
5404
5418
  parameterBuilder.addDomainHint(request.domainHint);
5405
5419
  }
5406
- // Add sid or loginHint with preference for sid -> loginHint -> username of AccountInfo object
5420
+ // Add sid or loginHint with preference for login_hint claim (in request) -> sid -> loginHint (upn/email) -> username of AccountInfo object
5407
5421
  if (request.prompt !== PromptValue.SELECT_ACCOUNT) {
5408
5422
  // AAD will throw if prompt=select_account is passed with an account hint
5409
5423
  if (request.sid && request.prompt === PromptValue.NONE) {
@@ -5413,9 +5427,24 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5413
5427
  }
5414
5428
  else if (request.account) {
5415
5429
  accountSid = this.extractAccountSid(request.account);
5416
- // If account and loginHint are provided, we will check account first for sid before adding loginHint
5417
- if (accountSid && request.prompt === PromptValue.NONE) {
5418
- // SessionId is only used in silent calls
5430
+ accountLoginHintClaim = this.extractLoginHint(request.account);
5431
+ // If login_hint claim is present, use it over sid/username
5432
+ if (accountLoginHintClaim) {
5433
+ this.logger.verbose("createAuthCodeUrlQueryString: login_hint claim present on account");
5434
+ parameterBuilder.addLoginHint(accountLoginHintClaim);
5435
+ try {
5436
+ clientInfo = buildClientInfoFromHomeAccountId(request.account.homeAccountId);
5437
+ parameterBuilder.addCcsOid(clientInfo);
5438
+ }
5439
+ catch (e) {
5440
+ this.logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
5441
+ }
5442
+ }
5443
+ else if (accountSid && request.prompt === PromptValue.NONE) {
5444
+ /*
5445
+ * If account and loginHint are provided, we will check account first for sid before adding loginHint
5446
+ * SessionId is only used in silent calls
5447
+ */
5419
5448
  this.logger.verbose("createAuthCodeUrlQueryString: Prompt is none, adding sid from account");
5420
5449
  parameterBuilder.addSid(accountSid);
5421
5450
  try {
@@ -5423,7 +5452,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5423
5452
  parameterBuilder.addCcsOid(clientInfo);
5424
5453
  }
5425
5454
  catch (e) {
5426
- this.logger.verbose("Could not parse home account ID for CCS Header: " + e);
5455
+ this.logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
5427
5456
  }
5428
5457
  }
5429
5458
  else if (request.loginHint) {
@@ -5440,7 +5469,7 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5440
5469
  parameterBuilder.addCcsOid(clientInfo);
5441
5470
  }
5442
5471
  catch (e) {
5443
- this.logger.verbose("Could not parse home account ID for CCS Header: " + e);
5472
+ this.logger.verbose("createAuthCodeUrlQueryString: Could not parse home account ID for CCS Header");
5444
5473
  }
5445
5474
  }
5446
5475
  }
@@ -5511,11 +5540,12 @@ var AuthorizationCodeClient = /** @class */ (function (_super) {
5511
5540
  * @param account
5512
5541
  */
5513
5542
  AuthorizationCodeClient.prototype.extractAccountSid = function (account) {
5514
- if (account.idTokenClaims) {
5515
- var tokenClaims = account.idTokenClaims;
5516
- return tokenClaims.sid || null;
5517
- }
5518
- return null;
5543
+ var _a;
5544
+ return ((_a = account.idTokenClaims) === null || _a === void 0 ? void 0 : _a.sid) || null;
5545
+ };
5546
+ AuthorizationCodeClient.prototype.extractLoginHint = function (account) {
5547
+ var _a;
5548
+ return ((_a = account.idTokenClaims) === null || _a === void 0 ? void 0 : _a.login_hint) || null;
5519
5549
  };
5520
5550
  return AuthorizationCodeClient;
5521
5551
  }(BaseClient));
@@ -5668,7 +5698,7 @@ var DeviceCodeClient = /** @class */ (function (_super) {
5668
5698
  pollingIntervalMilli = deviceCodeResponse.interval * 1000;
5669
5699
  _a.label = 1;
5670
5700
  case 1:
5671
- if (!this.continuePolling(deviceCodeExpirationTime, userSpecifiedTimeout, request.cancel)) return [3 /*break*/, 6];
5701
+ if (!this.continuePolling(deviceCodeExpirationTime, userSpecifiedTimeout, request.cancel)) return [3 /*break*/, 8];
5672
5702
  thumbprint = {
5673
5703
  clientId: this.config.authOptions.clientId,
5674
5704
  authority: request.authority,
@@ -5683,18 +5713,23 @@ var DeviceCodeClient = /** @class */ (function (_super) {
5683
5713
  return [4 /*yield*/, this.executePostToTokenEndpoint(this.authority.tokenEndpoint, requestBody, headers, thumbprint)];
5684
5714
  case 2:
5685
5715
  response = _a.sent();
5686
- if (!(response.body && response.body.error === Constants.AUTHORIZATION_PENDING)) return [3 /*break*/, 4];
5687
- // user authorization is pending. Sleep for polling interval and try again
5688
- this.logger.info(response.body.error_description || "Authorization pending. Continue polling.");
5716
+ if (!(response.body && response.body.error)) return [3 /*break*/, 6];
5717
+ if (!(response.body.error === Constants.AUTHORIZATION_PENDING)) return [3 /*break*/, 4];
5718
+ this.logger.info("Authorization pending. Continue polling.");
5689
5719
  return [4 /*yield*/, TimeUtils.delay(pollingIntervalMilli)];
5690
5720
  case 3:
5691
5721
  _a.sent();
5692
5722
  return [3 /*break*/, 5];
5693
5723
  case 4:
5724
+ // for any other error, throw
5725
+ this.logger.info("Unexpected error in polling from the server");
5726
+ throw ServerError.createPostRequestFailed(response.body.error);
5727
+ case 5: return [3 /*break*/, 7];
5728
+ case 6:
5694
5729
  this.logger.verbose("Authorization completed successfully. Polling stopped.");
5695
5730
  return [2 /*return*/, response.body];
5696
- case 5: return [3 /*break*/, 1];
5697
- case 6:
5731
+ case 7: return [3 /*break*/, 1];
5732
+ case 8:
5698
5733
  /*
5699
5734
  * The above code should've thrown by this point, but to satisfy TypeScript,
5700
5735
  * and in the rare case the conditionals in continuePolling() may not catch everything...
@@ -5733,6 +5768,123 @@ var DeviceCodeClient = /** @class */ (function (_super) {
5733
5768
  return DeviceCodeClient;
5734
5769
  }(BaseClient));
5735
5770
 
5771
+ /*
5772
+ * Copyright (c) Microsoft Corporation. All rights reserved.
5773
+ * Licensed under the MIT License.
5774
+ */
5775
+ /**
5776
+ * Enumeration of operations that are instrumented by have their performance measured by the PerformanceClient.
5777
+ *
5778
+ * @export
5779
+ * @enum {number}
5780
+ */
5781
+ exports.PerformanceEvents = void 0;
5782
+ (function (PerformanceEvents) {
5783
+ /**
5784
+ * acquireTokenByCode API (msal-browser and msal-node).
5785
+ * Used to acquire tokens by trading an authorization code against the token endpoint.
5786
+ */
5787
+ PerformanceEvents["AcquireTokenByCode"] = "acquireTokenByCode";
5788
+ /**
5789
+ * acquireTokenByRefreshToken API (msal-browser and msal-node).
5790
+ * Used to renew an access token using a refresh token against the token endpoint.
5791
+ */
5792
+ PerformanceEvents["AcquireTokenByRefreshToken"] = "acquireTokenByRefreshToken";
5793
+ /**
5794
+ * acquireTokenSilent API (msal-browser and msal-node).
5795
+ * Used to silently acquire a new access token (from the cache or the network).
5796
+ */
5797
+ PerformanceEvents["AcquireTokenSilent"] = "acquireTokenSilent";
5798
+ /**
5799
+ * acquireTokenSilentAsync (msal-browser).
5800
+ * Internal API for acquireTokenSilent.
5801
+ */
5802
+ PerformanceEvents["AcquireTokenSilentAsync"] = "acquireTokenSilentAsync";
5803
+ /**
5804
+ * acquireTokenPopup (msal-browser).
5805
+ * Used to acquire a new access token interactively through pop ups
5806
+ */
5807
+ PerformanceEvents["AcquireTokenPopup"] = "acquireTokenPopup";
5808
+ /**
5809
+ * getPublicKeyThumbprint API in CryptoOpts class (msal-browser).
5810
+ * Used to generate a public/private keypair and generate a public key thumbprint for pop requests.
5811
+ */
5812
+ PerformanceEvents["CryptoOptsGetPublicKeyThumbprint"] = "cryptoOptsGetPublicKeyThumbprint";
5813
+ /**
5814
+ * signJwt API in CryptoOpts class (msal-browser).
5815
+ * Used to signed a pop token.
5816
+ */
5817
+ PerformanceEvents["CryptoOptsSignJwt"] = "cryptoOptsSignJwt";
5818
+ /**
5819
+ * acquireToken API in the SilentCacheClient class (msal-browser).
5820
+ * Used to read access tokens from the cache.
5821
+ */
5822
+ PerformanceEvents["SilentCacheClientAcquireToken"] = "silentCacheClientAcquireToken";
5823
+ /**
5824
+ * acquireToken API in the SilentIframeClient class (msal-browser).
5825
+ * Used to acquire a new set of tokens from the authorize endpoint in a hidden iframe.
5826
+ */
5827
+ PerformanceEvents["SilentIframeClientAcquireToken"] = "silentIframeClientAcquireToken";
5828
+ /**
5829
+ * acquireToken API in SilentRereshClient (msal-browser).
5830
+ * Used to acquire a new set of tokens from the token endpoint using a refresh token.
5831
+ */
5832
+ PerformanceEvents["SilentRefreshClientAcquireToken"] = "silentRefreshClientAcquireToken";
5833
+ /**
5834
+ * ssoSilent API (msal-browser).
5835
+ * Used to silently acquire an authorization code and set of tokens using a hidden iframe.
5836
+ */
5837
+ PerformanceEvents["SsoSilent"] = "ssoSilent";
5838
+ /**
5839
+ * getDiscoveredAuthority API in StandardInteractionClient class (msal-browser).
5840
+ * Used to load authority metadata for a request.
5841
+ */
5842
+ PerformanceEvents["StandardInteractionClientGetDiscoveredAuthority"] = "standardInteractionClientGetDiscoveredAuthority";
5843
+ /**
5844
+ * acquireToken APIs in msal-browser.
5845
+ * Used to make an /authorize endpoint call with native brokering enabled.
5846
+ */
5847
+ PerformanceEvents["FetchAccountIdWithNativeBroker"] = "fetchAccountIdWithNativeBroker";
5848
+ /**
5849
+ * acquireToken API in NativeInteractionClient class (msal-browser).
5850
+ * Used to acquire a token from Native component when native brokering is enabled.
5851
+ */
5852
+ PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
5853
+ /**
5854
+ * Time spent on the network for refresh token acquisition
5855
+ */
5856
+ PerformanceEvents["RefreshTokenClientExecuteTokenRequest"] = "refreshTokenClientExecuteTokenRequest";
5857
+ /**
5858
+ * Time spent creating default headers for requests to token endpoint
5859
+ */
5860
+ PerformanceEvents["BaseClientCreateTokenRequestHeaders"] = "baseClientCreateTokenRequestHeaders";
5861
+ /**
5862
+ * Used to measure the time taken for completing embedded-broker handshake (PW-Broker).
5863
+ */
5864
+ PerformanceEvents["BrokerHandhshake"] = "brokerHandshake";
5865
+ /**
5866
+ * acquireTokenByRefreshToken API in BrokerClientApplication (PW-Broker) .
5867
+ */
5868
+ PerformanceEvents["AcquireTokenByRefreshTokenInBroker"] = "acquireTokenByRefreshTokenInBroker";
5869
+ /**
5870
+ * acquireToken API in BrokerClientApplication.
5871
+ * Used to acquire a token on behalf of the embedded application (PW-Broker).
5872
+ */
5873
+ PerformanceEvents["AcquireTokenByBroker"] = "acquireTokenByBroker";
5874
+ })(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
5875
+ /**
5876
+ * State of the performance event.
5877
+ *
5878
+ * @export
5879
+ * @enum {number}
5880
+ */
5881
+ exports.PerformanceEventStatus = void 0;
5882
+ (function (PerformanceEventStatus) {
5883
+ PerformanceEventStatus[PerformanceEventStatus["NotStarted"] = 0] = "NotStarted";
5884
+ PerformanceEventStatus[PerformanceEventStatus["InProgress"] = 1] = "InProgress";
5885
+ PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
5886
+ })(exports.PerformanceEventStatus || (exports.PerformanceEventStatus = {}));
5887
+
5736
5888
  /*
5737
5889
  * Copyright (c) Microsoft Corporation. All rights reserved.
5738
5890
  * Licensed under the MIT License.
@@ -5742,8 +5894,8 @@ var DeviceCodeClient = /** @class */ (function (_super) {
5742
5894
  */
5743
5895
  var RefreshTokenClient = /** @class */ (function (_super) {
5744
5896
  __extends(RefreshTokenClient, _super);
5745
- function RefreshTokenClient(configuration) {
5746
- return _super.call(this, configuration) || this;
5897
+ function RefreshTokenClient(configuration, performanceClient) {
5898
+ return _super.call(this, configuration, performanceClient) || this;
5747
5899
  }
5748
5900
  RefreshTokenClient.prototype.acquireToken = function (request) {
5749
5901
  return __awaiter(this, void 0, void 0, function () {
@@ -5829,13 +5981,16 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5829
5981
  * @param authority
5830
5982
  */
5831
5983
  RefreshTokenClient.prototype.executeTokenRequest = function (request, authority) {
5984
+ var _a;
5832
5985
  return __awaiter(this, void 0, void 0, function () {
5833
- var requestBody, queryParameters, headers, thumbprint, endpoint;
5834
- return __generator(this, function (_a) {
5835
- switch (_a.label) {
5836
- case 0: return [4 /*yield*/, this.createTokenRequestBody(request)];
5986
+ var acquireTokenMeasurement, requestBody, queryParameters, headers, thumbprint, endpoint;
5987
+ return __generator(this, function (_b) {
5988
+ switch (_b.label) {
5989
+ case 0:
5990
+ acquireTokenMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.RefreshTokenClientExecuteTokenRequest, request.correlationId);
5991
+ return [4 /*yield*/, this.createTokenRequestBody(request)];
5837
5992
  case 1:
5838
- requestBody = _a.sent();
5993
+ requestBody = _b.sent();
5839
5994
  queryParameters = this.createTokenQueryParameters(request);
5840
5995
  headers = this.createTokenRequestHeaders(request.ccsCredential);
5841
5996
  thumbprint = {
@@ -5850,7 +6005,19 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5850
6005
  sshKid: request.sshKid
5851
6006
  };
5852
6007
  endpoint = UrlString.appendQueryString(authority.tokenEndpoint, queryParameters);
5853
- return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)];
6008
+ return [2 /*return*/, this.executePostToTokenEndpoint(endpoint, requestBody, headers, thumbprint)
6009
+ .then(function (result) {
6010
+ acquireTokenMeasurement === null || acquireTokenMeasurement === void 0 ? void 0 : acquireTokenMeasurement.endMeasurement({
6011
+ success: true
6012
+ });
6013
+ return result;
6014
+ })
6015
+ .catch(function (error) {
6016
+ acquireTokenMeasurement === null || acquireTokenMeasurement === void 0 ? void 0 : acquireTokenMeasurement.endMeasurement({
6017
+ success: false
6018
+ });
6019
+ throw error;
6020
+ })];
5854
6021
  }
5855
6022
  });
5856
6023
  });
@@ -5871,11 +6038,14 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5871
6038
  * @param request
5872
6039
  */
5873
6040
  RefreshTokenClient.prototype.createTokenRequestBody = function (request) {
6041
+ var _a;
5874
6042
  return __awaiter(this, void 0, void 0, function () {
5875
- var parameterBuilder, correlationId, clientAssertion, popTokenGenerator, reqCnfData, clientInfo;
5876
- return __generator(this, function (_a) {
5877
- switch (_a.label) {
6043
+ var correlationId, acquireTokenMeasurement, parameterBuilder, clientAssertion, popTokenGenerator, reqCnfData, clientInfo;
6044
+ return __generator(this, function (_b) {
6045
+ switch (_b.label) {
5878
6046
  case 0:
6047
+ correlationId = request.correlationId;
6048
+ acquireTokenMeasurement = (_a = this.performanceClient) === null || _a === void 0 ? void 0 : _a.startMeasurement(exports.PerformanceEvents.BaseClientCreateTokenRequestHeaders, correlationId);
5879
6049
  parameterBuilder = new RequestParameterBuilder();
5880
6050
  parameterBuilder.addClientId(this.config.authOptions.clientId);
5881
6051
  parameterBuilder.addScopes(request.scopes);
@@ -5887,7 +6057,6 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5887
6057
  if (this.serverTelemetryManager) {
5888
6058
  parameterBuilder.addServerTelemetry(this.serverTelemetryManager);
5889
6059
  }
5890
- correlationId = request.correlationId || this.config.cryptoInterface.createNewGuid();
5891
6060
  parameterBuilder.addCorrelationId(correlationId);
5892
6061
  parameterBuilder.addRefreshToken(request.refreshToken);
5893
6062
  if (this.config.clientCredentials.clientSecret) {
@@ -5902,7 +6071,7 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5902
6071
  popTokenGenerator = new PopTokenGenerator(this.cryptoUtils);
5903
6072
  return [4 /*yield*/, popTokenGenerator.generateCnf(request)];
5904
6073
  case 1:
5905
- reqCnfData = _a.sent();
6074
+ reqCnfData = _b.sent();
5906
6075
  // SPA PoP requires full Base64Url encoded req_cnf string (unhashed)
5907
6076
  parameterBuilder.addPopToken(reqCnfData.reqCnfString);
5908
6077
  return [3 /*break*/, 3];
@@ -5912,10 +6081,13 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5912
6081
  parameterBuilder.addSshJwk(request.sshJwk);
5913
6082
  }
5914
6083
  else {
6084
+ acquireTokenMeasurement === null || acquireTokenMeasurement === void 0 ? void 0 : acquireTokenMeasurement.endMeasurement({
6085
+ success: false
6086
+ });
5915
6087
  throw ClientConfigurationError.createMissingSshJwkError();
5916
6088
  }
5917
6089
  }
5918
- _a.label = 3;
6090
+ _b.label = 3;
5919
6091
  case 3:
5920
6092
  if (!StringUtils.isEmptyObj(request.claims) || this.config.authOptions.clientCapabilities && this.config.authOptions.clientCapabilities.length > 0) {
5921
6093
  parameterBuilder.addClaims(request.claims, this.config.authOptions.clientCapabilities);
@@ -5936,6 +6108,9 @@ var RefreshTokenClient = /** @class */ (function (_super) {
5936
6108
  break;
5937
6109
  }
5938
6110
  }
6111
+ acquireTokenMeasurement === null || acquireTokenMeasurement === void 0 ? void 0 : acquireTokenMeasurement.endMeasurement({
6112
+ success: true
6113
+ });
5939
6114
  return [2 /*return*/, parameterBuilder.createQueryString()];
5940
6115
  }
5941
6116
  });
@@ -6368,8 +6543,8 @@ var OnBehalfOfClient = /** @class */ (function (_super) {
6368
6543
  */
6369
6544
  var SilentFlowClient = /** @class */ (function (_super) {
6370
6545
  __extends(SilentFlowClient, _super);
6371
- function SilentFlowClient(configuration) {
6372
- return _super.call(this, configuration) || this;
6546
+ function SilentFlowClient(configuration, performanceClient) {
6547
+ return _super.call(this, configuration, performanceClient) || this;
6373
6548
  }
6374
6549
  /**
6375
6550
  * Retrieves a token from cache if it is still valid, or uses the cached refresh token to renew
@@ -6388,7 +6563,7 @@ var SilentFlowClient = /** @class */ (function (_super) {
6388
6563
  case 2:
6389
6564
  e_1 = _a.sent();
6390
6565
  if (e_1 instanceof ClientAuthError && e_1.errorCode === ClientAuthErrorMessage.tokenRefreshRequired.code) {
6391
- refreshTokenClient = new RefreshTokenClient(this.config);
6566
+ refreshTokenClient = new RefreshTokenClient(this.config, this.performanceClient);
6392
6567
  return [2 /*return*/, refreshTokenClient.acquireTokenByRefreshToken(request)];
6393
6568
  }
6394
6569
  else {
@@ -7906,115 +8081,6 @@ var ServerTelemetryManager = /** @class */ (function () {
7906
8081
  return ServerTelemetryManager;
7907
8082
  }());
7908
8083
 
7909
- /*
7910
- * Copyright (c) Microsoft Corporation. All rights reserved.
7911
- * Licensed under the MIT License.
7912
- */
7913
- /**
7914
- * Enumeration of operations that are instrumented by have their performance measured by the PerformanceClient.
7915
- *
7916
- * @export
7917
- * @enum {number}
7918
- */
7919
- exports.PerformanceEvents = void 0;
7920
- (function (PerformanceEvents) {
7921
- /**
7922
- * acquireTokenByCode API (msal-browser and msal-node).
7923
- * Used to acquire tokens by trading an authorization code against the token endpoint.
7924
- */
7925
- PerformanceEvents["AcquireTokenByCode"] = "acquireTokenByCode";
7926
- /**
7927
- * acquireTokenByRefreshToken API (msal-browser and msal-node).
7928
- * Used to renew an access token using a refresh token against the token endpoint.
7929
- */
7930
- PerformanceEvents["AcquireTokenByRefreshToken"] = "acquireTokenByRefreshToken";
7931
- /**
7932
- * acquireTokenSilent API (msal-browser and msal-node).
7933
- * Used to silently acquire a new access token (from the cache or the network).
7934
- */
7935
- PerformanceEvents["AcquireTokenSilent"] = "acquireTokenSilent";
7936
- /**
7937
- * acquireTokenSilentAsync (msal-browser).
7938
- * Internal API for acquireTokenSilent.
7939
- */
7940
- PerformanceEvents["AcquireTokenSilentAsync"] = "acquireTokenSilentAsync";
7941
- /**
7942
- * acquireTokenPopup (msal-browser).
7943
- * Used to acquire a new access token interactively through pop ups
7944
- */
7945
- PerformanceEvents["AcquireTokenPopup"] = "acquireTokenPopup";
7946
- /**
7947
- * getPublicKeyThumbprint API in CryptoOpts class (msal-browser).
7948
- * Used to generate a public/private keypair and generate a public key thumbprint for pop requests.
7949
- */
7950
- PerformanceEvents["CryptoOptsGetPublicKeyThumbprint"] = "cryptoOptsGetPublicKeyThumbprint";
7951
- /**
7952
- * signJwt API in CryptoOpts class (msal-browser).
7953
- * Used to signed a pop token.
7954
- */
7955
- PerformanceEvents["CryptoOptsSignJwt"] = "cryptoOptsSignJwt";
7956
- /**
7957
- * acquireToken API in the SilentCacheClient class (msal-browser).
7958
- * Used to read access tokens from the cache.
7959
- */
7960
- PerformanceEvents["SilentCacheClientAcquireToken"] = "silentCacheClientAcquireToken";
7961
- /**
7962
- * acquireToken API in the SilentIframeClient class (msal-browser).
7963
- * Used to acquire a new set of tokens from the authorize endpoint in a hidden iframe.
7964
- */
7965
- PerformanceEvents["SilentIframeClientAcquireToken"] = "silentIframeClientAcquireToken";
7966
- /**
7967
- * acquireToken API in SilentRereshClient (msal-browser).
7968
- * Used to acquire a new set of tokens from the token endpoint using a refresh token.
7969
- */
7970
- PerformanceEvents["SilentRefreshClientAcquireToken"] = "silentRefreshClientAcquireToken";
7971
- /**
7972
- * ssoSilent API (msal-browser).
7973
- * Used to silently acquire an authorization code and set of tokens using a hidden iframe.
7974
- */
7975
- PerformanceEvents["SsoSilent"] = "ssoSilent";
7976
- /**
7977
- * getDiscoveredAuthority API in StandardInteractionClient class (msal-browser).
7978
- * Used to load authority metadata for a request.
7979
- */
7980
- PerformanceEvents["StandardInteractionClientGetDiscoveredAuthority"] = "standardInteractionClientGetDiscoveredAuthority";
7981
- /**
7982
- * acquireToken APIs in msal-browser.
7983
- * Used to make an /authorize endpoint call with native brokering enabled.
7984
- */
7985
- PerformanceEvents["FetchAccountIdWithNativeBroker"] = "fetchAccountIdWithNativeBroker";
7986
- /**
7987
- * acquireToken API in NativeInteractionClient class (msal-browser).
7988
- * Used to acquire a token from Native component when native brokering is enabled.
7989
- */
7990
- PerformanceEvents["NativeInteractionClientAcquireToken"] = "nativeInteractionClientAcquireToken";
7991
- /**
7992
- * Used to measure the time taken for completing embedded-broker handshake (PW-Broker).
7993
- */
7994
- PerformanceEvents["BrokerHandhshake"] = "brokerHandshake";
7995
- /**
7996
- * acquireTokenByRefreshToken API in BrokerClientApplication (PW-Broker) .
7997
- */
7998
- PerformanceEvents["AcquireTokenByRefreshTokenInBroker"] = "acquireTokenByRefreshTokenInBroker";
7999
- /**
8000
- * acquireToken API in BrokerClientApplication.
8001
- * Used to acquire a token on behalf of the embedded application (PW-Broker).
8002
- */
8003
- PerformanceEvents["AcquireTokenByBroker"] = "acquireTokenByBroker";
8004
- })(exports.PerformanceEvents || (exports.PerformanceEvents = {}));
8005
- /**
8006
- * State of the performance event.
8007
- *
8008
- * @export
8009
- * @enum {number}
8010
- */
8011
- exports.PerformanceEventStatus = void 0;
8012
- (function (PerformanceEventStatus) {
8013
- PerformanceEventStatus[PerformanceEventStatus["NotStarted"] = 0] = "NotStarted";
8014
- PerformanceEventStatus[PerformanceEventStatus["InProgress"] = 1] = "InProgress";
8015
- PerformanceEventStatus[PerformanceEventStatus["Completed"] = 2] = "Completed";
8016
- })(exports.PerformanceEventStatus || (exports.PerformanceEventStatus = {}));
8017
-
8018
8084
  /*
8019
8085
  * Copyright (c) Microsoft Corporation. All rights reserved.
8020
8086
  * Licensed under the MIT License.