@azure/msal-browser 2.22.1 → 2.24.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 (170) hide show
  1. package/README.md +1 -1
  2. package/dist/_virtual/_tslib.js +1 -1
  3. package/dist/app/ClientApplication.d.ts +82 -2
  4. package/dist/app/ClientApplication.d.ts.map +1 -1
  5. package/dist/app/ClientApplication.js +388 -72
  6. package/dist/app/ClientApplication.js.map +1 -1
  7. package/dist/app/IPublicClientApplication.d.ts +4 -1
  8. package/dist/app/IPublicClientApplication.d.ts.map +1 -1
  9. package/dist/app/IPublicClientApplication.js +10 -1
  10. package/dist/app/IPublicClientApplication.js.map +1 -1
  11. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  12. package/dist/app/PublicClientApplication.js +80 -38
  13. package/dist/app/PublicClientApplication.js.map +1 -1
  14. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +49 -0
  15. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -0
  16. package/dist/broker/nativeBroker/NativeMessageHandler.js +246 -0
  17. package/dist/broker/nativeBroker/NativeMessageHandler.js.map +1 -0
  18. package/dist/broker/nativeBroker/NativeRequest.d.ts +44 -0
  19. package/dist/broker/nativeBroker/NativeRequest.d.ts.map +1 -0
  20. package/dist/broker/nativeBroker/NativeResponse.d.ts +24 -0
  21. package/dist/broker/nativeBroker/NativeResponse.d.ts.map +1 -0
  22. package/dist/cache/AsyncMemoryStorage.d.ts +3 -2
  23. package/dist/cache/AsyncMemoryStorage.d.ts.map +1 -1
  24. package/dist/cache/AsyncMemoryStorage.js +17 -6
  25. package/dist/cache/AsyncMemoryStorage.js.map +1 -1
  26. package/dist/cache/BrowserCacheManager.d.ts +11 -0
  27. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  28. package/dist/cache/BrowserCacheManager.js +49 -7
  29. package/dist/cache/BrowserCacheManager.js.map +1 -1
  30. package/dist/cache/BrowserStorage.js +1 -1
  31. package/dist/cache/DatabaseStorage.d.ts +5 -0
  32. package/dist/cache/DatabaseStorage.d.ts.map +1 -1
  33. package/dist/cache/DatabaseStorage.js +65 -13
  34. package/dist/cache/DatabaseStorage.js.map +1 -1
  35. package/dist/cache/MemoryStorage.js +1 -1
  36. package/dist/cache/TokenCache.js +1 -1
  37. package/dist/config/Configuration.d.ts +109 -36
  38. package/dist/config/Configuration.d.ts.map +1 -1
  39. package/dist/config/Configuration.js +19 -11
  40. package/dist/config/Configuration.js.map +1 -1
  41. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  42. package/dist/crypto/BrowserCrypto.js +7 -6
  43. package/dist/crypto/BrowserCrypto.js.map +1 -1
  44. package/dist/crypto/CryptoOps.d.ts +12 -3
  45. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  46. package/dist/crypto/CryptoOps.js +71 -36
  47. package/dist/crypto/CryptoOps.js.map +1 -1
  48. package/dist/crypto/GuidGenerator.d.ts +3 -2
  49. package/dist/crypto/GuidGenerator.d.ts.map +1 -1
  50. package/dist/crypto/GuidGenerator.js +4 -3
  51. package/dist/crypto/GuidGenerator.js.map +1 -1
  52. package/dist/crypto/PkceGenerator.js +1 -1
  53. package/dist/crypto/SignedHttpRequest.js +1 -1
  54. package/dist/encode/Base64Decode.d.ts.map +1 -1
  55. package/dist/encode/Base64Decode.js +3 -2
  56. package/dist/encode/Base64Decode.js.map +1 -1
  57. package/dist/encode/Base64Encode.d.ts.map +1 -1
  58. package/dist/encode/Base64Encode.js +5 -4
  59. package/dist/encode/Base64Encode.js.map +1 -1
  60. package/dist/error/BrowserAuthError.d.ts +58 -0
  61. package/dist/error/BrowserAuthError.d.ts.map +1 -1
  62. package/dist/error/BrowserAuthError.js +73 -1
  63. package/dist/error/BrowserAuthError.js.map +1 -1
  64. package/dist/error/BrowserConfigurationAuthError.js +1 -1
  65. package/dist/error/NativeAuthError.d.ts +46 -0
  66. package/dist/error/NativeAuthError.d.ts.map +1 -0
  67. package/dist/error/NativeAuthError.js +82 -0
  68. package/dist/error/NativeAuthError.js.map +1 -0
  69. package/dist/event/EventHandler.js +1 -1
  70. package/dist/event/EventMessage.js +1 -1
  71. package/dist/event/EventType.d.ts +2 -0
  72. package/dist/event/EventType.d.ts.map +1 -1
  73. package/dist/event/EventType.js +3 -1
  74. package/dist/event/EventType.js.map +1 -1
  75. package/dist/index.cjs.js +5899 -3880
  76. package/dist/index.cjs.js.map +1 -1
  77. package/dist/index.d.ts +7 -13
  78. package/dist/index.d.ts.map +1 -1
  79. package/dist/index.js +5 -13
  80. package/dist/index.js.map +1 -1
  81. package/dist/interaction_client/BaseInteractionClient.d.ts +13 -2
  82. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  83. package/dist/interaction_client/BaseInteractionClient.js +37 -4
  84. package/dist/interaction_client/BaseInteractionClient.js.map +1 -1
  85. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +1 -1
  86. package/dist/interaction_client/NativeInteractionClient.d.ts +57 -0
  87. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -0
  88. package/dist/interaction_client/NativeInteractionClient.js +334 -0
  89. package/dist/interaction_client/NativeInteractionClient.js.map +1 -0
  90. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  91. package/dist/interaction_client/PopupClient.js +37 -8
  92. package/dist/interaction_client/PopupClient.js.map +1 -1
  93. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  94. package/dist/interaction_client/RedirectClient.js +40 -11
  95. package/dist/interaction_client/RedirectClient.js.map +1 -1
  96. package/dist/interaction_client/SilentAuthCodeClient.d.ts +3 -2
  97. package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  98. package/dist/interaction_client/SilentAuthCodeClient.js +5 -5
  99. package/dist/interaction_client/SilentAuthCodeClient.js.map +1 -1
  100. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  101. package/dist/interaction_client/SilentCacheClient.js +12 -6
  102. package/dist/interaction_client/SilentCacheClient.js.map +1 -1
  103. package/dist/interaction_client/SilentIframeClient.d.ts +5 -3
  104. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  105. package/dist/interaction_client/SilentIframeClient.js +51 -24
  106. package/dist/interaction_client/SilentIframeClient.js.map +1 -1
  107. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  108. package/dist/interaction_client/SilentRefreshClient.js +16 -4
  109. package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
  110. package/dist/interaction_client/StandardInteractionClient.d.ts +2 -8
  111. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  112. package/dist/interaction_client/StandardInteractionClient.js +32 -22
  113. package/dist/interaction_client/StandardInteractionClient.js.map +1 -1
  114. package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
  115. package/dist/interaction_handler/InteractionHandler.js +15 -4
  116. package/dist/interaction_handler/InteractionHandler.js.map +1 -1
  117. package/dist/interaction_handler/PopupHandler.js +1 -1
  118. package/dist/interaction_handler/RedirectHandler.d.ts +1 -1
  119. package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
  120. package/dist/interaction_handler/RedirectHandler.js +16 -9
  121. package/dist/interaction_handler/RedirectHandler.js.map +1 -1
  122. package/dist/interaction_handler/SilentHandler.js +1 -1
  123. package/dist/internals.d.ts +18 -0
  124. package/dist/internals.d.ts.map +1 -0
  125. package/dist/internals.js +20 -0
  126. package/dist/internals.js.map +1 -0
  127. package/dist/navigation/NavigationClient.js +1 -1
  128. package/dist/network/FetchClient.d.ts.map +1 -1
  129. package/dist/network/FetchClient.js +3 -2
  130. package/dist/network/FetchClient.js.map +1 -1
  131. package/dist/network/XhrClient.js +1 -1
  132. package/dist/packageMetadata.d.ts +1 -1
  133. package/dist/packageMetadata.js +2 -2
  134. package/dist/packageMetadata.js.map +1 -1
  135. package/dist/request/AuthorizationCodeRequest.d.ts +2 -1
  136. package/dist/request/AuthorizationCodeRequest.d.ts.map +1 -1
  137. package/dist/request/AuthorizationUrlRequest.d.ts +1 -1
  138. package/dist/request/AuthorizationUrlRequest.d.ts.map +1 -1
  139. package/dist/request/PopupRequest.d.ts +1 -1
  140. package/dist/request/PopupRequest.d.ts.map +1 -1
  141. package/dist/request/RedirectRequest.d.ts +1 -1
  142. package/dist/request/RedirectRequest.d.ts.map +1 -1
  143. package/dist/request/SsoSilentRequest.d.ts +1 -1
  144. package/dist/request/SsoSilentRequest.d.ts.map +1 -1
  145. package/dist/telemetry/BrowserPerformanceClient.d.ts +19 -0
  146. package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -0
  147. package/dist/telemetry/BrowserPerformanceClient.js +52 -0
  148. package/dist/telemetry/BrowserPerformanceClient.js.map +1 -0
  149. package/dist/telemetry/BrowserPerformanceMeasurement.d.ts +13 -0
  150. package/dist/telemetry/BrowserPerformanceMeasurement.d.ts.map +1 -0
  151. package/dist/telemetry/BrowserPerformanceMeasurement.js +66 -0
  152. package/dist/telemetry/BrowserPerformanceMeasurement.js.map +1 -0
  153. package/dist/utils/BrowserConstants.d.ts +12 -1
  154. package/dist/utils/BrowserConstants.d.ts.map +1 -1
  155. package/dist/utils/BrowserConstants.js +14 -2
  156. package/dist/utils/BrowserConstants.js.map +1 -1
  157. package/dist/utils/BrowserProtocolUtils.js +1 -1
  158. package/dist/utils/BrowserStringUtils.d.ts.map +1 -1
  159. package/dist/utils/BrowserStringUtils.js +4 -2
  160. package/dist/utils/BrowserStringUtils.js.map +1 -1
  161. package/dist/utils/BrowserUtils.d.ts +6 -0
  162. package/dist/utils/BrowserUtils.d.ts.map +1 -1
  163. package/dist/utils/BrowserUtils.js +12 -2
  164. package/dist/utils/BrowserUtils.js.map +1 -1
  165. package/dist/utils/MathUtils.js +1 -1
  166. package/dist/utils/PopupUtils.js +1 -1
  167. package/lib/msal-browser.js +5899 -3880
  168. package/lib/msal-browser.js.map +1 -1
  169. package/lib/msal-browser.min.js +41 -36
  170. package/package.json +2 -2
@@ -1,11 +1,11 @@
1
- /*! @azure/msal-browser v2.22.1 2022-03-07 */
1
+ /*! @azure/msal-browser v2.24.0 2022-05-02 */
2
2
  'use strict';
3
- import { __awaiter, __generator } from '../_virtual/_tslib.js';
3
+ import { __awaiter, __generator, __assign } from '../_virtual/_tslib.js';
4
4
  import { CryptoOps } from '../crypto/CryptoOps.js';
5
- import { StringUtils, Logger, DEFAULT_CRYPTO_IMPLEMENTATION, Constants, ServerError, InteractionRequiredAuthError } from '@azure/msal-common';
5
+ import { Constants, PerformanceEvents, PromptValue, StringUtils, Logger, StubPerformanceClient, DEFAULT_CRYPTO_IMPLEMENTATION, ServerError, InteractionRequiredAuthError } from '@azure/msal-common';
6
6
  import { BrowserCacheManager, DEFAULT_BROWSER_CACHE_MANAGER } from '../cache/BrowserCacheManager.js';
7
7
  import { buildConfiguration } from '../config/Configuration.js';
8
- import { InteractionType, TemporaryCacheKeys, ApiId, BrowserCacheLocation, BrowserConstants } from '../utils/BrowserConstants.js';
8
+ import { InteractionType, ApiId, TemporaryCacheKeys, BrowserCacheLocation, BrowserConstants } from '../utils/BrowserConstants.js';
9
9
  import { BrowserUtils } from '../utils/BrowserUtils.js';
10
10
  import { name, version } from '../packageMetadata.js';
11
11
  import { EventType } from '../event/EventType.js';
@@ -16,8 +16,13 @@ import { RedirectClient } from '../interaction_client/RedirectClient.js';
16
16
  import { SilentIframeClient } from '../interaction_client/SilentIframeClient.js';
17
17
  import { SilentRefreshClient } from '../interaction_client/SilentRefreshClient.js';
18
18
  import { TokenCache } from '../cache/TokenCache.js';
19
+ import { NativeInteractionClient } from '../interaction_client/NativeInteractionClient.js';
20
+ import { NativeMessageHandler } from '../broker/nativeBroker/NativeMessageHandler.js';
21
+ import { NativeAuthError } from '../error/NativeAuthError.js';
22
+ import { SilentCacheClient } from '../interaction_client/SilentCacheClient.js';
19
23
  import { SilentAuthCodeClient } from '../interaction_client/SilentAuthCodeClient.js';
20
24
  import { BrowserAuthError } from '../error/BrowserAuthError.js';
25
+ import { BrowserPerformanceClient } from '../telemetry/BrowserPerformanceClient.js';
21
26
 
22
27
  /*
23
28
  * Copyright (c) Microsoft Corporation. All rights reserved.
@@ -54,6 +59,7 @@ var ClientApplication = /** @class */ (function () {
54
59
  this.isBrowserEnvironment = typeof window !== "undefined";
55
60
  // Set the configuration.
56
61
  this.config = buildConfiguration(configuration, this.isBrowserEnvironment);
62
+ this.initialized = false;
57
63
  // Initialize logger
58
64
  this.logger = new Logger(this.config.system.loggerOptions, name, version);
59
65
  // Initialize the network module class.
@@ -64,8 +70,12 @@ var ClientApplication = /** @class */ (function () {
64
70
  this.redirectResponse = new Map();
65
71
  // Initial hybrid spa map
66
72
  this.hybridAuthCodeResponses = new Map();
73
+ // Initialize performance client
74
+ this.performanceClient = this.isBrowserEnvironment ?
75
+ new BrowserPerformanceClient(this.config.auth.clientId, this.config.auth.authority, this.logger, name, version, this.config.telemetry.application) :
76
+ new StubPerformanceClient(this.config.auth.clientId, this.config.auth.authority, this.logger, name, version, this.config.telemetry.application);
67
77
  // Initialize the crypto class.
68
- this.browserCrypto = this.isBrowserEnvironment ? new CryptoOps(this.logger) : DEFAULT_CRYPTO_IMPLEMENTATION;
78
+ this.browserCrypto = this.isBrowserEnvironment ? new CryptoOps(this.logger, this.performanceClient) : DEFAULT_CRYPTO_IMPLEMENTATION;
69
79
  this.eventHandler = new EventHandler(this.logger, this.browserCrypto);
70
80
  // Initialize the browser storage class.
71
81
  this.browserStorage = this.isBrowserEnvironment ?
@@ -74,6 +84,42 @@ var ClientApplication = /** @class */ (function () {
74
84
  // Initialize the token cache
75
85
  this.tokenCache = new TokenCache(this.config, this.browserStorage, this.logger, this.browserCrypto);
76
86
  }
87
+ /**
88
+ * Initializer function to perform async startup tasks such as connecting to WAM extension
89
+ */
90
+ ClientApplication.prototype.initialize = function () {
91
+ return __awaiter(this, void 0, void 0, function () {
92
+ var _a, e_1;
93
+ return __generator(this, function (_b) {
94
+ switch (_b.label) {
95
+ case 0:
96
+ this.logger.trace("initialize called");
97
+ if (this.initialized) {
98
+ this.logger.warning("initialize has already been called. This function only needs to be run once.");
99
+ return [2 /*return*/];
100
+ }
101
+ this.eventHandler.emitEvent(EventType.INITIALIZE_START);
102
+ if (!this.config.system.allowNativeBroker) return [3 /*break*/, 4];
103
+ _b.label = 1;
104
+ case 1:
105
+ _b.trys.push([1, 3, , 4]);
106
+ _a = this;
107
+ return [4 /*yield*/, NativeMessageHandler.createProvider(this.logger, this.config.system.nativeBrokerHandshakeTimeout)];
108
+ case 2:
109
+ _a.nativeExtensionProvider = _b.sent();
110
+ return [3 /*break*/, 4];
111
+ case 3:
112
+ e_1 = _b.sent();
113
+ this.logger.verbose(e_1);
114
+ return [3 /*break*/, 4];
115
+ case 4:
116
+ this.initialized = true;
117
+ this.eventHandler.emitEvent(EventType.INITIALIZE_END);
118
+ return [2 /*return*/];
119
+ }
120
+ });
121
+ });
122
+ };
77
123
  // #region Redirect Flow
78
124
  /**
79
125
  * Event handler function which allows users to fire events after the PublicClientApplication object
@@ -84,10 +130,12 @@ var ClientApplication = /** @class */ (function () {
84
130
  */
85
131
  ClientApplication.prototype.handleRedirectPromise = function (hash) {
86
132
  return __awaiter(this, void 0, void 0, function () {
87
- var loggedInAccounts, redirectResponseKey, response, correlationId, redirectClient;
133
+ var loggedInAccounts, redirectResponseKey, response, request, redirectResponse, nativeClient, correlationId, redirectClient;
88
134
  var _this = this;
89
135
  return __generator(this, function (_a) {
90
136
  this.logger.verbose("handleRedirectPromise called");
137
+ // Block token acquisition before initialize has been called if native brokering is enabled
138
+ BrowserUtils.blockNativeBrokerCalledBeforeInitialized(this.config.system.allowNativeBroker, this.initialized);
91
139
  loggedInAccounts = this.getAllAccounts();
92
140
  if (this.isBrowserEnvironment) {
93
141
  redirectResponseKey = hash || Constants.EMPTY_STRING;
@@ -95,10 +143,20 @@ var ClientApplication = /** @class */ (function () {
95
143
  if (typeof response === "undefined") {
96
144
  this.eventHandler.emitEvent(EventType.HANDLE_REDIRECT_START, InteractionType.Redirect);
97
145
  this.logger.verbose("handleRedirectPromise has been called for the first time, storing the promise");
98
- correlationId = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.CORRELATION_ID, true) || "";
99
- redirectClient = new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, correlationId);
100
- response = redirectClient.handleRedirectPromise(hash)
101
- .then(function (result) {
146
+ request = this.browserStorage.getCachedNativeRequest();
147
+ redirectResponse = void 0;
148
+ if (request && NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider) && this.nativeExtensionProvider && !hash) {
149
+ this.logger.trace("handleRedirectPromise - acquiring token from native platform");
150
+ nativeClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, ApiId.handleRedirectPromise, this.performanceClient, this.nativeExtensionProvider, request.accountId, request.correlationId);
151
+ redirectResponse = nativeClient.handleRedirectPromise();
152
+ }
153
+ else {
154
+ this.logger.trace("handleRedirectPromise - acquiring token from web flow");
155
+ correlationId = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.CORRELATION_ID, true) || Constants.EMPTY_STRING;
156
+ redirectClient = this.createRedirectClient(correlationId);
157
+ redirectResponse = redirectClient.handleRedirectPromise(hash);
158
+ }
159
+ response = redirectResponse.then(function (result) {
102
160
  if (result) {
103
161
  // Emit login event if number of accounts change
104
162
  var isLoggingIn = loggedInAccounts.length < _this.getAllAccounts().length;
@@ -113,8 +171,7 @@ var ClientApplication = /** @class */ (function () {
113
171
  }
114
172
  _this.eventHandler.emitEvent(EventType.HANDLE_REDIRECT_END, InteractionType.Redirect);
115
173
  return result;
116
- })
117
- .catch(function (e) {
174
+ }).catch(function (e) {
118
175
  // Emit login event if there is an account
119
176
  if (loggedInAccounts.length > 0) {
120
177
  _this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_FAILURE, InteractionType.Redirect, null, e);
@@ -148,11 +205,11 @@ var ClientApplication = /** @class */ (function () {
148
205
  */
149
206
  ClientApplication.prototype.acquireTokenRedirect = function (request) {
150
207
  return __awaiter(this, void 0, void 0, function () {
151
- var isLoggedIn, redirectClient;
208
+ var correlationId, isLoggedIn, result, nativeClient, redirectClient;
152
209
  var _this = this;
153
210
  return __generator(this, function (_a) {
154
- // Preflight request
155
- this.logger.verbose("acquireTokenRedirect called");
211
+ correlationId = this.getRequestCorrelationId(request);
212
+ this.logger.verbose("acquireTokenRedirect called", correlationId);
156
213
  this.preflightBrowserEnvironmentCheck(InteractionType.Redirect);
157
214
  isLoggedIn = this.getAllAccounts().length > 0;
158
215
  if (isLoggedIn) {
@@ -161,8 +218,22 @@ var ClientApplication = /** @class */ (function () {
161
218
  else {
162
219
  this.eventHandler.emitEvent(EventType.LOGIN_START, InteractionType.Redirect, request);
163
220
  }
164
- redirectClient = new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, request.correlationId);
165
- return [2 /*return*/, redirectClient.acquireToken(request).catch(function (e) {
221
+ if (this.nativeExtensionProvider && this.canUseNative(request)) {
222
+ nativeClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, ApiId.acquireTokenRedirect, this.performanceClient, this.nativeExtensionProvider, this.getNativeAccountId(request), request.correlationId);
223
+ result = nativeClient.acquireTokenRedirect(request).catch(function (e) {
224
+ if (e instanceof NativeAuthError && e.isFatal()) {
225
+ _this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
226
+ var redirectClient = _this.createRedirectClient(request.correlationId);
227
+ return redirectClient.acquireToken(request);
228
+ }
229
+ throw e;
230
+ });
231
+ }
232
+ else {
233
+ redirectClient = this.createRedirectClient(request.correlationId);
234
+ result = redirectClient.acquireToken(request);
235
+ }
236
+ return [2 /*return*/, result.catch(function (e) {
166
237
  // If logged in, emit acquire token events
167
238
  if (isLoggedIn) {
168
239
  _this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_FAILURE, InteractionType.Redirect, null, e);
@@ -186,8 +257,10 @@ var ClientApplication = /** @class */ (function () {
186
257
  */
187
258
  ClientApplication.prototype.acquireTokenPopup = function (request) {
188
259
  var _this = this;
260
+ var correlationId = this.getRequestCorrelationId(request);
261
+ var atPopupMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.AcquireTokenPopup, correlationId);
189
262
  try {
190
- this.logger.verbose("acquireTokenPopup called", request.correlationId);
263
+ this.logger.verbose("acquireTokenPopup called", correlationId);
191
264
  this.preflightBrowserEnvironmentCheck(InteractionType.Popup);
192
265
  }
193
266
  catch (e) {
@@ -202,8 +275,30 @@ var ClientApplication = /** @class */ (function () {
202
275
  else {
203
276
  this.eventHandler.emitEvent(EventType.LOGIN_START, InteractionType.Popup, request);
204
277
  }
205
- var popupClient = new PopupClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, request.correlationId);
206
- return popupClient.acquireToken(request).then(function (result) {
278
+ var result;
279
+ if (this.canUseNative(request)) {
280
+ result = this.acquireTokenNative(request, ApiId.acquireTokenPopup).then(function (response) {
281
+ _this.browserStorage.setInteractionInProgress(false);
282
+ atPopupMeasurement.endMeasurement({
283
+ success: true,
284
+ isNativeBroker: true
285
+ });
286
+ atPopupMeasurement.flushMeasurement();
287
+ return response;
288
+ }).catch(function (e) {
289
+ if (e instanceof NativeAuthError && e.isFatal()) {
290
+ _this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
291
+ var popupClient = _this.createPopupClient(request.correlationId);
292
+ return popupClient.acquireToken(request);
293
+ }
294
+ throw e;
295
+ });
296
+ }
297
+ else {
298
+ var popupClient = this.createPopupClient(request.correlationId);
299
+ result = popupClient.acquireToken(request);
300
+ }
301
+ return result.then(function (result) {
207
302
  // If logged in, emit acquire token events
208
303
  var isLoggingIn = loggedInAccounts.length < _this.getAllAccounts().length;
209
304
  if (isLoggingIn) {
@@ -212,6 +307,10 @@ var ClientApplication = /** @class */ (function () {
212
307
  else {
213
308
  _this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_SUCCESS, InteractionType.Popup, result);
214
309
  }
310
+ atPopupMeasurement.endMeasurement({
311
+ success: true
312
+ });
313
+ atPopupMeasurement.flushMeasurement();
215
314
  return result;
216
315
  }).catch(function (e) {
217
316
  if (loggedInAccounts.length > 0) {
@@ -220,6 +319,10 @@ var ClientApplication = /** @class */ (function () {
220
319
  else {
221
320
  _this.eventHandler.emitEvent(EventType.LOGIN_FAILURE, InteractionType.Popup, null, e);
222
321
  }
322
+ atPopupMeasurement.endMeasurement({
323
+ success: false
324
+ });
325
+ atPopupMeasurement.flushMeasurement();
223
326
  // Since this function is syncronous we need to reject
224
327
  return Promise.reject(e);
225
328
  });
@@ -243,28 +346,45 @@ var ClientApplication = /** @class */ (function () {
243
346
  */
244
347
  ClientApplication.prototype.ssoSilent = function (request) {
245
348
  return __awaiter(this, void 0, void 0, function () {
246
- var silentIframeClient, silentTokenResult, e_1;
349
+ var correlationId, validRequest, ssoSilentMeasurement, result, silentIframeClient;
350
+ var _this = this;
247
351
  return __generator(this, function (_a) {
248
- switch (_a.label) {
249
- case 0:
250
- this.preflightBrowserEnvironmentCheck(InteractionType.Silent);
251
- this.logger.verbose("ssoSilent called", request.correlationId);
252
- this.eventHandler.emitEvent(EventType.SSO_SILENT_START, InteractionType.Silent, request);
253
- _a.label = 1;
254
- case 1:
255
- _a.trys.push([1, 3, , 4]);
256
- silentIframeClient = new SilentIframeClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, ApiId.ssoSilent, request.correlationId);
257
- return [4 /*yield*/, silentIframeClient.acquireToken(request)];
258
- case 2:
259
- silentTokenResult = _a.sent();
260
- this.eventHandler.emitEvent(EventType.SSO_SILENT_SUCCESS, InteractionType.Silent, silentTokenResult);
261
- return [2 /*return*/, silentTokenResult];
262
- case 3:
263
- e_1 = _a.sent();
264
- this.eventHandler.emitEvent(EventType.SSO_SILENT_FAILURE, InteractionType.Silent, null, e_1);
265
- throw e_1;
266
- case 4: return [2 /*return*/];
352
+ correlationId = this.getRequestCorrelationId(request);
353
+ validRequest = __assign(__assign({}, request), { prompt: PromptValue.NONE, correlationId: correlationId });
354
+ this.preflightBrowserEnvironmentCheck(InteractionType.Silent);
355
+ ssoSilentMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.SsoSilent, correlationId);
356
+ this.logger.verbose("ssoSilent called", correlationId);
357
+ this.eventHandler.emitEvent(EventType.SSO_SILENT_START, InteractionType.Silent, validRequest);
358
+ if (this.canUseNative(validRequest)) {
359
+ result = this.acquireTokenNative(validRequest, ApiId.ssoSilent).catch(function (e) {
360
+ // If native token acquisition fails for availability reasons fallback to standard flow
361
+ if (e instanceof NativeAuthError && e.isFatal()) {
362
+ _this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
363
+ var silentIframeClient = _this.createSilentIframeClient(validRequest.correlationId);
364
+ return silentIframeClient.acquireToken(validRequest);
365
+ }
366
+ throw e;
367
+ });
267
368
  }
369
+ else {
370
+ silentIframeClient = this.createSilentIframeClient(validRequest.correlationId);
371
+ result = silentIframeClient.acquireToken(validRequest);
372
+ }
373
+ return [2 /*return*/, result.then(function (response) {
374
+ _this.eventHandler.emitEvent(EventType.SSO_SILENT_SUCCESS, InteractionType.Silent, response);
375
+ ssoSilentMeasurement.endMeasurement({
376
+ success: true
377
+ });
378
+ ssoSilentMeasurement.flushMeasurement();
379
+ return response;
380
+ }).catch(function (e) {
381
+ _this.eventHandler.emitEvent(EventType.SSO_SILENT_FAILURE, InteractionType.Silent, null, e);
382
+ ssoSilentMeasurement.endMeasurement({
383
+ success: false
384
+ });
385
+ ssoSilentMeasurement.flushMeasurement();
386
+ throw e;
387
+ })];
268
388
  });
269
389
  });
270
390
  };
@@ -280,38 +400,73 @@ var ClientApplication = /** @class */ (function () {
280
400
  */
281
401
  ClientApplication.prototype.acquireTokenByCode = function (request) {
282
402
  return __awaiter(this, void 0, void 0, function () {
283
- var response;
403
+ var correlationId, atbcMeasurement, hybridAuthCode_1, response;
284
404
  var _this = this;
285
405
  return __generator(this, function (_a) {
406
+ correlationId = this.getRequestCorrelationId(request);
286
407
  this.preflightBrowserEnvironmentCheck(InteractionType.Silent);
287
- this.logger.trace("acquireTokenByCode called", request.correlationId);
408
+ this.logger.trace("acquireTokenByCode called", correlationId);
288
409
  this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_BY_CODE_START, InteractionType.Silent, request);
410
+ atbcMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.AcquireTokenByCode, request.correlationId);
289
411
  try {
290
- if (!request.code) {
291
- throw BrowserAuthError.createAuthCodeRequiredError();
412
+ if (request.code) {
413
+ hybridAuthCode_1 = request.code;
414
+ response = this.hybridAuthCodeResponses.get(hybridAuthCode_1);
415
+ if (!response) {
416
+ this.logger.verbose("Initiating new acquireTokenByCode request", correlationId);
417
+ response = this.acquireTokenByCodeAsync(__assign(__assign({}, request), { correlationId: correlationId }))
418
+ .then(function (result) {
419
+ _this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_BY_CODE_SUCCESS, InteractionType.Silent, result);
420
+ _this.hybridAuthCodeResponses.delete(hybridAuthCode_1);
421
+ atbcMeasurement.endMeasurement({
422
+ success: true
423
+ });
424
+ atbcMeasurement.flushMeasurement();
425
+ return result;
426
+ })
427
+ .catch(function (error) {
428
+ _this.hybridAuthCodeResponses.delete(hybridAuthCode_1);
429
+ _this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, InteractionType.Silent, null, error);
430
+ atbcMeasurement.endMeasurement({
431
+ success: false
432
+ });
433
+ atbcMeasurement.flushMeasurement();
434
+ throw error;
435
+ });
436
+ this.hybridAuthCodeResponses.set(hybridAuthCode_1, response);
437
+ }
438
+ else {
439
+ this.logger.verbose("Existing acquireTokenByCode request found", request.correlationId);
440
+ atbcMeasurement.endMeasurement({
441
+ success: true
442
+ });
443
+ atbcMeasurement.discardMeasurement();
444
+ }
445
+ return [2 /*return*/, response];
292
446
  }
293
- response = this.hybridAuthCodeResponses.get(request.code);
294
- if (!response) {
295
- this.logger.verbose("Initiating new acquireTokenByCode request", request.correlationId);
296
- response = this.acquireTokenByCodeAsync(request)
297
- .then(function (result) {
298
- _this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_BY_CODE_SUCCESS, InteractionType.Silent, result);
299
- _this.hybridAuthCodeResponses.delete(request.code);
300
- return result;
301
- })
302
- .catch(function (error) {
303
- _this.hybridAuthCodeResponses.delete(request.code);
304
- throw error;
305
- });
306
- this.hybridAuthCodeResponses.set(request.code, response);
447
+ else if (request.nativeAccountId) {
448
+ if (this.canUseNative(request, request.nativeAccountId)) {
449
+ return [2 /*return*/, this.acquireTokenNative(request, ApiId.acquireTokenByCode, request.nativeAccountId).catch(function (e) {
450
+ // If native token acquisition fails for availability reasons fallback to standard flow
451
+ if (e instanceof NativeAuthError && e.isFatal()) {
452
+ _this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
453
+ }
454
+ throw e;
455
+ })];
456
+ }
457
+ else {
458
+ throw BrowserAuthError.createUnableToAcquireTokenFromNativePlatformError();
459
+ }
307
460
  }
308
461
  else {
309
- this.logger.verbose("Existing acquireTokenByCode request found", request.correlationId);
462
+ throw BrowserAuthError.createAuthCodeOrNativeAccountIdRequiredError();
310
463
  }
311
- return [2 /*return*/, response];
312
464
  }
313
465
  catch (e) {
314
466
  this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_BY_CODE_FAILURE, InteractionType.Silent, null, e);
467
+ atbcMeasurement.endMeasurement({
468
+ success: false
469
+ });
315
470
  throw e;
316
471
  }
317
472
  return [2 /*return*/];
@@ -330,7 +485,7 @@ var ClientApplication = /** @class */ (function () {
330
485
  switch (_a.label) {
331
486
  case 0:
332
487
  this.logger.trace("acquireTokenByCodeAsync called", request.correlationId);
333
- silentAuthCodeClient = new SilentAuthCodeClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, ApiId.acquireTokenByCode, request.correlationId);
488
+ silentAuthCodeClient = this.createSilentAuthCodeClient(request.correlationId);
334
489
  return [4 /*yield*/, silentAuthCodeClient.acquireToken(request)];
335
490
  case 1:
336
491
  silentTokenResult = _a.sent();
@@ -352,22 +507,47 @@ var ClientApplication = /** @class */ (function () {
352
507
  */
353
508
  ClientApplication.prototype.acquireTokenByRefreshToken = function (request) {
354
509
  return __awaiter(this, void 0, void 0, function () {
355
- var silentRefreshClient;
510
+ var atbrtMeasurement, silentRefreshClient;
356
511
  var _this = this;
357
512
  return __generator(this, function (_a) {
358
- this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_NETWORK_START, InteractionType.Silent, request);
359
513
  // block the reload if it occurred inside a hidden iframe
360
514
  BrowserUtils.blockReloadInHiddenIframes();
361
- silentRefreshClient = new SilentRefreshClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, request.correlationId);
362
- return [2 /*return*/, silentRefreshClient.acquireToken(request).catch(function (e) {
515
+ atbrtMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.AcquireTokenByRefreshToken, request.correlationId);
516
+ this.eventHandler.emitEvent(EventType.ACQUIRE_TOKEN_NETWORK_START, InteractionType.Silent, request);
517
+ silentRefreshClient = this.createSilentRefreshClient(request.correlationId);
518
+ return [2 /*return*/, silentRefreshClient.acquireToken(request)
519
+ .then(function (result) {
520
+ atbrtMeasurement.endMeasurement({
521
+ success: true,
522
+ fromCache: result.fromCache
523
+ });
524
+ return result;
525
+ })
526
+ .catch(function (e) {
363
527
  var isServerError = e instanceof ServerError;
364
528
  var isInteractionRequiredError = e instanceof InteractionRequiredAuthError;
365
529
  var isInvalidGrantError = (e.errorCode === BrowserConstants.INVALID_GRANT_ERROR);
366
530
  if (isServerError && isInvalidGrantError && !isInteractionRequiredError) {
367
531
  _this.logger.verbose("Refresh token expired or invalid, attempting acquire token by iframe", request.correlationId);
368
- var silentIframeClient = new SilentIframeClient(_this.config, _this.browserStorage, _this.browserCrypto, _this.logger, _this.eventHandler, _this.navigationClient, ApiId.acquireTokenSilent_authCode, request.correlationId);
369
- return silentIframeClient.acquireToken(request);
532
+ var silentIframeClient = _this.createSilentIframeClient(request.correlationId);
533
+ return silentIframeClient.acquireToken(request)
534
+ .then(function (result) {
535
+ atbrtMeasurement.endMeasurement({
536
+ success: true,
537
+ fromCache: result.fromCache
538
+ });
539
+ return result;
540
+ })
541
+ .catch(function (error) {
542
+ atbrtMeasurement.endMeasurement({
543
+ success: false
544
+ });
545
+ throw error;
546
+ });
370
547
  }
548
+ atbrtMeasurement.endMeasurement({
549
+ success: false
550
+ });
371
551
  throw e;
372
552
  })];
373
553
  });
@@ -382,9 +562,11 @@ var ClientApplication = /** @class */ (function () {
382
562
  */
383
563
  ClientApplication.prototype.logout = function (logoutRequest) {
384
564
  return __awaiter(this, void 0, void 0, function () {
565
+ var correlationId;
385
566
  return __generator(this, function (_a) {
386
- this.logger.warning("logout API is deprecated and will be removed in msal-browser v3.0.0. Use logoutRedirect instead.");
387
- return [2 /*return*/, this.logoutRedirect(logoutRequest)];
567
+ correlationId = this.getRequestCorrelationId(logoutRequest);
568
+ this.logger.warning("logout API is deprecated and will be removed in msal-browser v3.0.0. Use logoutRedirect instead.", correlationId);
569
+ return [2 /*return*/, this.logoutRedirect(__assign({ correlationId: correlationId }, logoutRequest))];
388
570
  });
389
571
  });
390
572
  };
@@ -395,10 +577,11 @@ var ClientApplication = /** @class */ (function () {
395
577
  */
396
578
  ClientApplication.prototype.logoutRedirect = function (logoutRequest) {
397
579
  return __awaiter(this, void 0, void 0, function () {
398
- var redirectClient;
580
+ var correlationId, redirectClient;
399
581
  return __generator(this, function (_a) {
582
+ correlationId = this.getRequestCorrelationId(logoutRequest);
400
583
  this.preflightBrowserEnvironmentCheck(InteractionType.Redirect);
401
- redirectClient = new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, logoutRequest === null || logoutRequest === void 0 ? void 0 : logoutRequest.correlationId);
584
+ redirectClient = this.createRedirectClient(correlationId);
402
585
  return [2 /*return*/, redirectClient.logout(logoutRequest)];
403
586
  });
404
587
  });
@@ -409,8 +592,9 @@ var ClientApplication = /** @class */ (function () {
409
592
  */
410
593
  ClientApplication.prototype.logoutPopup = function (logoutRequest) {
411
594
  try {
595
+ var correlationId = this.getRequestCorrelationId(logoutRequest);
412
596
  this.preflightBrowserEnvironmentCheck(InteractionType.Popup);
413
- var popupClient = new PopupClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, logoutRequest === null || logoutRequest === void 0 ? void 0 : logoutRequest.correlationId);
597
+ var popupClient = this.createPopupClient(correlationId);
414
598
  return popupClient.logout(logoutRequest);
415
599
  }
416
600
  catch (e) {
@@ -517,6 +701,8 @@ var ClientApplication = /** @class */ (function () {
517
701
  BrowserUtils.blockReloadInHiddenIframes();
518
702
  // Block redirectUri opened in a popup from calling MSAL APIs
519
703
  BrowserUtils.blockAcquireTokenInPopups();
704
+ // Block token acquisition before initialize has been called if native brokering is enabled
705
+ BrowserUtils.blockNativeBrokerCalledBeforeInitialized(this.config.system.allowNativeBroker, this.initialized);
520
706
  // Block redirects if memory storage is enabled but storeAuthStateInCookie is not
521
707
  if (interactionType === InteractionType.Redirect &&
522
708
  this.config.cache.cacheLocation === BrowserCacheLocation.MemoryStorage &&
@@ -539,6 +725,98 @@ var ClientApplication = /** @class */ (function () {
539
725
  // Set interaction in progress temporary cache or throw if alread set.
540
726
  this.browserStorage.setInteractionInProgress(true);
541
727
  };
728
+ /**
729
+ * Acquire a token from native device (e.g. WAM)
730
+ * @param request
731
+ */
732
+ ClientApplication.prototype.acquireTokenNative = function (request, apiId, accountId) {
733
+ return __awaiter(this, void 0, void 0, function () {
734
+ var nativeClient;
735
+ return __generator(this, function (_a) {
736
+ this.logger.trace("acquireTokenNative called");
737
+ if (!this.nativeExtensionProvider) {
738
+ throw BrowserAuthError.createNativeConnectionNotEstablishedError();
739
+ }
740
+ nativeClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, apiId, this.performanceClient, this.nativeExtensionProvider, accountId || this.getNativeAccountId(request), request.correlationId);
741
+ return [2 /*return*/, nativeClient.acquireToken(request)];
742
+ });
743
+ });
744
+ };
745
+ /**
746
+ * Returns boolean indicating if this request can use the native broker
747
+ * @param request
748
+ */
749
+ ClientApplication.prototype.canUseNative = function (request, accountId) {
750
+ this.logger.trace("canUseNative called");
751
+ if (!NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeExtensionProvider, request.authenticationScheme)) {
752
+ this.logger.trace("canUseNative: isNativeAvailable returned false, returning false");
753
+ return false;
754
+ }
755
+ if (request.prompt) {
756
+ switch (request.prompt) {
757
+ case PromptValue.NONE:
758
+ case PromptValue.CONSENT:
759
+ this.logger.trace("canUseNative: prompt is compatible with native flow");
760
+ break;
761
+ default:
762
+ this.logger.trace("canUseNative: prompt = " + request.prompt + " is not compatible with native flow, returning false");
763
+ return false;
764
+ }
765
+ }
766
+ if (!accountId && !this.getNativeAccountId(request)) {
767
+ this.logger.trace("canUseNative: nativeAccountId is not available, returning false");
768
+ return false;
769
+ }
770
+ return true;
771
+ };
772
+ /**
773
+ * Get the native accountId from the account
774
+ * @param request
775
+ * @returns
776
+ */
777
+ ClientApplication.prototype.getNativeAccountId = function (request) {
778
+ var account = request.account || this.browserStorage.getAccountInfoByHints(request.loginHint, request.sid) || this.getActiveAccount();
779
+ return account && account.nativeAccountId || "";
780
+ };
781
+ /**
782
+ * Returns new instance of the Popup Interaction Client
783
+ * @param correlationId
784
+ */
785
+ ClientApplication.prototype.createPopupClient = function (correlationId) {
786
+ return new PopupClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeExtensionProvider, correlationId);
787
+ };
788
+ /**
789
+ * Returns new instance of the Popup Interaction Client
790
+ * @param correlationId
791
+ */
792
+ ClientApplication.prototype.createRedirectClient = function (correlationId) {
793
+ return new RedirectClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeExtensionProvider, correlationId);
794
+ };
795
+ /**
796
+ * Returns new instance of the Silent Iframe Interaction Client
797
+ * @param correlationId
798
+ */
799
+ ClientApplication.prototype.createSilentIframeClient = function (correlationId) {
800
+ return new SilentIframeClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, ApiId.ssoSilent, this.performanceClient, this.nativeExtensionProvider, correlationId);
801
+ };
802
+ /**
803
+ * Returns new instance of the Silent Cache Interaction Client
804
+ */
805
+ ClientApplication.prototype.createSilentCacheClient = function (correlationId) {
806
+ return new SilentCacheClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeExtensionProvider, correlationId);
807
+ };
808
+ /**
809
+ * Returns new instance of the Silent Refresh Interaction Client
810
+ */
811
+ ClientApplication.prototype.createSilentRefreshClient = function (correlationId) {
812
+ return new SilentRefreshClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, this.performanceClient, this.nativeExtensionProvider, correlationId);
813
+ };
814
+ /**
815
+ * Returns new instance of the Silent AuthCode Interaction Client
816
+ */
817
+ ClientApplication.prototype.createSilentAuthCodeClient = function (correlationId) {
818
+ return new SilentAuthCodeClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, ApiId.acquireTokenByCode, this.performanceClient, this.nativeExtensionProvider, correlationId);
819
+ };
542
820
  /**
543
821
  * Adds event callbacks to array
544
822
  * @param callback
@@ -553,6 +831,24 @@ var ClientApplication = /** @class */ (function () {
553
831
  ClientApplication.prototype.removeEventCallback = function (callbackId) {
554
832
  this.eventHandler.removeEventCallback(callbackId);
555
833
  };
834
+ /**
835
+ * Registers a callback to receive performance events.
836
+ *
837
+ * @param {PerformanceCallbackFunction} callback
838
+ * @returns {string}
839
+ */
840
+ ClientApplication.prototype.addPerformanceCallback = function (callback) {
841
+ return this.performanceClient.addPerformanceCallback(callback);
842
+ };
843
+ /**
844
+ * Removes a callback registered with addPerformanceCallback.
845
+ *
846
+ * @param {string} callbackId
847
+ * @returns {boolean}
848
+ */
849
+ ClientApplication.prototype.removePerformanceCallback = function (callbackId) {
850
+ return this.performanceClient.removePerformanceCallback(callbackId);
851
+ };
556
852
  /**
557
853
  * Adds event listener that emits an event when a user account is added or removed from localstorage in a different browser tab or window
558
854
  */
@@ -606,6 +902,26 @@ var ClientApplication = /** @class */ (function () {
606
902
  ClientApplication.prototype.getConfiguration = function () {
607
903
  return this.config;
608
904
  };
905
+ /**
906
+ * Generates a correlation id for a request if none is provided.
907
+ *
908
+ * @protected
909
+ * @param {?Partial<BaseAuthRequest>} [request]
910
+ * @returns {string}
911
+ */
912
+ ClientApplication.prototype.getRequestCorrelationId = function (request) {
913
+ if (request === null || request === void 0 ? void 0 : request.correlationId) {
914
+ return request.correlationId;
915
+ }
916
+ if (this.isBrowserEnvironment) {
917
+ return this.browserCrypto.createNewGuid();
918
+ }
919
+ /*
920
+ * Included for fallback for non-browser environments,
921
+ * and to ensure this method always returns a string.
922
+ */
923
+ return Constants.EMPTY_STRING;
924
+ };
609
925
  return ClientApplication;
610
926
  }());
611
927