@azure/msal-browser 2.37.0 → 3.0.0-alpha.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.
Files changed (231) hide show
  1. package/dist/app/IPublicClientApplication.d.ts.map +1 -1
  2. package/dist/app/IPublicClientApplication.js +33 -33
  3. package/dist/app/IPublicClientApplication.js.map +1 -1
  4. package/dist/app/PublicClientApplication.d.ts +198 -24
  5. package/dist/app/PublicClientApplication.d.ts.map +1 -1
  6. package/dist/app/PublicClientApplication.js +263 -220
  7. package/dist/app/PublicClientApplication.js.map +1 -1
  8. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +5 -4
  9. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
  10. package/dist/broker/nativeBroker/NativeMessageHandler.js +118 -124
  11. package/dist/broker/nativeBroker/NativeMessageHandler.js.map +1 -1
  12. package/dist/broker/nativeBroker/NativeRequest.d.ts +4 -4
  13. package/dist/broker/nativeBroker/NativeRequest.d.ts.map +1 -1
  14. package/dist/broker/nativeBroker/NativeResponse.d.ts +4 -4
  15. package/dist/broker/nativeBroker/NativeResponse.d.ts.map +1 -1
  16. package/dist/cache/AsyncMemoryStorage.d.ts.map +1 -1
  17. package/dist/cache/AsyncMemoryStorage.js +83 -152
  18. package/dist/cache/AsyncMemoryStorage.js.map +1 -1
  19. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  20. package/dist/cache/BrowserCacheManager.js +420 -412
  21. package/dist/cache/BrowserCacheManager.js.map +1 -1
  22. package/dist/cache/BrowserStorage.d.ts.map +1 -1
  23. package/dist/cache/BrowserStorage.js +19 -19
  24. package/dist/cache/BrowserStorage.js.map +1 -1
  25. package/dist/cache/CryptoKeyStore.d.ts.map +1 -1
  26. package/dist/cache/CryptoKeyStore.js +26 -36
  27. package/dist/cache/CryptoKeyStore.js.map +1 -1
  28. package/dist/cache/DatabaseStorage.d.ts.map +1 -1
  29. package/dist/cache/DatabaseStorage.js +127 -191
  30. package/dist/cache/DatabaseStorage.js.map +1 -1
  31. package/dist/cache/ITokenCache.d.ts.map +1 -1
  32. package/dist/cache/MemoryStorage.d.ts.map +1 -1
  33. package/dist/cache/MemoryStorage.js +18 -19
  34. package/dist/cache/MemoryStorage.js.map +1 -1
  35. package/dist/cache/TokenCache.d.ts +1 -1
  36. package/dist/cache/TokenCache.d.ts.map +1 -1
  37. package/dist/cache/TokenCache.js +55 -49
  38. package/dist/cache/TokenCache.js.map +1 -1
  39. package/dist/config/Configuration.d.ts +8 -8
  40. package/dist/config/Configuration.d.ts.map +1 -1
  41. package/dist/config/Configuration.js +53 -31
  42. package/dist/config/Configuration.js.map +1 -1
  43. package/dist/controllers/ControllerFactory.d.ts +10 -0
  44. package/dist/controllers/ControllerFactory.d.ts.map +1 -0
  45. package/dist/controllers/ControllerFactory.js +47 -0
  46. package/dist/controllers/ControllerFactory.js.map +1 -0
  47. package/dist/controllers/IController.d.ts +67 -0
  48. package/dist/controllers/IController.d.ts.map +1 -0
  49. package/dist/{app/ClientApplication.d.ts → controllers/StandardController.d.ts} +96 -15
  50. package/dist/controllers/StandardController.d.ts.map +1 -0
  51. package/dist/controllers/StandardController.js +1299 -0
  52. package/dist/controllers/StandardController.js.map +1 -0
  53. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  54. package/dist/crypto/BrowserCrypto.js +36 -60
  55. package/dist/crypto/BrowserCrypto.js.map +1 -1
  56. package/dist/crypto/CryptoOps.d.ts +1 -1
  57. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  58. package/dist/crypto/CryptoOps.js +93 -151
  59. package/dist/crypto/CryptoOps.js.map +1 -1
  60. package/dist/crypto/GuidGenerator.d.ts.map +1 -1
  61. package/dist/crypto/GuidGenerator.js +36 -25
  62. package/dist/crypto/GuidGenerator.js.map +1 -1
  63. package/dist/crypto/ISubtleCrypto.d.ts.map +1 -1
  64. package/dist/crypto/ModernBrowserCrypto.d.ts.map +1 -1
  65. package/dist/crypto/ModernBrowserCrypto.js +20 -44
  66. package/dist/crypto/ModernBrowserCrypto.js.map +1 -1
  67. package/dist/crypto/MsBrowserCrypto.d.ts.map +1 -1
  68. package/dist/crypto/MsBrowserCrypto.js +65 -89
  69. package/dist/crypto/MsBrowserCrypto.js.map +1 -1
  70. package/dist/crypto/MsrBrowserCrypto.d.ts.map +1 -1
  71. package/dist/crypto/MsrBrowserCrypto.js +23 -47
  72. package/dist/crypto/MsrBrowserCrypto.js.map +1 -1
  73. package/dist/crypto/PkceGenerator.d.ts.map +1 -1
  74. package/dist/crypto/PkceGenerator.js +28 -49
  75. package/dist/crypto/PkceGenerator.js.map +1 -1
  76. package/dist/crypto/SignedHttpRequest.d.ts +1 -1
  77. package/dist/crypto/SignedHttpRequest.d.ts.map +1 -1
  78. package/dist/crypto/SignedHttpRequest.js +15 -37
  79. package/dist/crypto/SignedHttpRequest.js.map +1 -1
  80. package/dist/encode/Base64Decode.d.ts.map +1 -1
  81. package/dist/encode/Base64Decode.js +32 -33
  82. package/dist/encode/Base64Decode.js.map +1 -1
  83. package/dist/encode/Base64Encode.d.ts.map +1 -1
  84. package/dist/encode/Base64Encode.js +34 -35
  85. package/dist/encode/Base64Encode.js.map +1 -1
  86. package/dist/error/BrowserAuthError.d.ts +1 -1
  87. package/dist/error/BrowserAuthError.d.ts.map +1 -1
  88. package/dist/error/BrowserAuthError.js +161 -163
  89. package/dist/error/BrowserAuthError.js.map +1 -1
  90. package/dist/error/BrowserConfigurationAuthError.d.ts.map +1 -1
  91. package/dist/error/BrowserConfigurationAuthError.js +32 -36
  92. package/dist/error/BrowserConfigurationAuthError.js.map +1 -1
  93. package/dist/error/NativeAuthError.d.ts +1 -1
  94. package/dist/error/NativeAuthError.d.ts.map +1 -1
  95. package/dist/error/NativeAuthError.js +26 -27
  96. package/dist/error/NativeAuthError.js.map +1 -1
  97. package/dist/event/EventHandler.d.ts.map +1 -1
  98. package/dist/event/EventHandler.js +33 -33
  99. package/dist/event/EventHandler.js.map +1 -1
  100. package/dist/event/EventMessage.d.ts +5 -5
  101. package/dist/event/EventMessage.d.ts.map +1 -1
  102. package/dist/event/EventMessage.js +18 -14
  103. package/dist/event/EventMessage.js.map +1 -1
  104. package/dist/event/EventType.js +1 -1
  105. package/dist/event/EventType.js.map +1 -1
  106. package/dist/index.d.ts +8 -8
  107. package/dist/index.d.ts.map +1 -1
  108. package/dist/index.js +1 -1
  109. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  110. package/dist/interaction_client/BaseInteractionClient.js +92 -123
  111. package/dist/interaction_client/BaseInteractionClient.js.map +1 -1
  112. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.d.ts.map +1 -1
  113. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +6 -10
  114. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js.map +1 -1
  115. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  116. package/dist/interaction_client/NativeInteractionClient.js +336 -393
  117. package/dist/interaction_client/NativeInteractionClient.js.map +1 -1
  118. package/dist/interaction_client/PopupClient.d.ts +1 -1
  119. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  120. package/dist/interaction_client/PopupClient.js +224 -246
  121. package/dist/interaction_client/PopupClient.js.map +1 -1
  122. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  123. package/dist/interaction_client/RedirectClient.js +244 -292
  124. package/dist/interaction_client/RedirectClient.js.map +1 -1
  125. package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  126. package/dist/interaction_client/SilentAuthCodeClient.js +50 -63
  127. package/dist/interaction_client/SilentAuthCodeClient.js.map +1 -1
  128. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  129. package/dist/interaction_client/SilentCacheClient.js +50 -81
  130. package/dist/interaction_client/SilentCacheClient.js.map +1 -1
  131. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  132. package/dist/interaction_client/SilentIframeClient.js +107 -125
  133. package/dist/interaction_client/SilentIframeClient.js.map +1 -1
  134. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  135. package/dist/interaction_client/SilentRefreshClient.js +44 -72
  136. package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
  137. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  138. package/dist/interaction_client/StandardInteractionClient.js +144 -180
  139. package/dist/interaction_client/StandardInteractionClient.js.map +1 -1
  140. package/dist/interaction_handler/InteractionHandler.d.ts +1 -1
  141. package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
  142. package/dist/interaction_handler/InteractionHandler.js +84 -110
  143. package/dist/interaction_handler/InteractionHandler.js.map +1 -1
  144. package/dist/interaction_handler/RedirectHandler.d.ts +1 -1
  145. package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
  146. package/dist/interaction_handler/RedirectHandler.js +105 -122
  147. package/dist/interaction_handler/RedirectHandler.js.map +1 -1
  148. package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
  149. package/dist/interaction_handler/SilentHandler.js +76 -65
  150. package/dist/interaction_handler/SilentHandler.js.map +1 -1
  151. package/dist/internals.js +1 -1
  152. package/dist/internals.js.map +1 -1
  153. package/dist/navigation/NavigationClient.d.ts.map +1 -1
  154. package/dist/navigation/NavigationClient.js +11 -14
  155. package/dist/navigation/NavigationClient.js.map +1 -1
  156. package/dist/navigation/NavigationOptions.d.ts +1 -1
  157. package/dist/navigation/NavigationOptions.d.ts.map +1 -1
  158. package/dist/network/FetchClient.d.ts.map +1 -1
  159. package/dist/network/FetchClient.js +66 -96
  160. package/dist/network/FetchClient.js.map +1 -1
  161. package/dist/network/XhrClient.d.ts.map +1 -1
  162. package/dist/network/XhrClient.js +38 -51
  163. package/dist/network/XhrClient.js.map +1 -1
  164. package/dist/operatingcontext/BaseOperatingContext.d.ts +41 -0
  165. package/dist/operatingcontext/BaseOperatingContext.d.ts.map +1 -0
  166. package/dist/operatingcontext/BaseOperatingContext.js +53 -0
  167. package/dist/operatingcontext/BaseOperatingContext.js.map +1 -0
  168. package/dist/operatingcontext/StandardOperatingContext.d.ts +26 -0
  169. package/dist/operatingcontext/StandardOperatingContext.d.ts.map +1 -0
  170. package/dist/operatingcontext/StandardOperatingContext.js +50 -0
  171. package/dist/operatingcontext/StandardOperatingContext.js.map +1 -0
  172. package/dist/operatingcontext/TeamsAppOperatingContext.d.ts +26 -0
  173. package/dist/operatingcontext/TeamsAppOperatingContext.d.ts.map +1 -0
  174. package/dist/operatingcontext/TeamsAppOperatingContext.js +49 -0
  175. package/dist/operatingcontext/TeamsAppOperatingContext.js.map +1 -0
  176. package/dist/packageMetadata.d.ts +1 -1
  177. package/dist/packageMetadata.d.ts.map +1 -1
  178. package/dist/packageMetadata.js +3 -3
  179. package/dist/packageMetadata.js.map +1 -1
  180. package/dist/request/AuthorizationCodeRequest.d.ts +1 -1
  181. package/dist/request/AuthorizationCodeRequest.d.ts.map +1 -1
  182. package/dist/request/AuthorizationUrlRequest.d.ts +1 -1
  183. package/dist/request/AuthorizationUrlRequest.d.ts.map +1 -1
  184. package/dist/request/EndSessionPopupRequest.d.ts +1 -1
  185. package/dist/request/EndSessionPopupRequest.d.ts.map +1 -1
  186. package/dist/request/EndSessionRequest.d.ts +1 -1
  187. package/dist/request/EndSessionRequest.d.ts.map +1 -1
  188. package/dist/request/PopupRequest.d.ts +1 -1
  189. package/dist/request/PopupRequest.d.ts.map +1 -1
  190. package/dist/request/PopupWindowAttributes.d.ts +3 -3
  191. package/dist/request/PopupWindowAttributes.d.ts.map +1 -1
  192. package/dist/request/RedirectRequest.d.ts +1 -1
  193. package/dist/request/RedirectRequest.d.ts.map +1 -1
  194. package/dist/request/SilentRequest.d.ts +1 -1
  195. package/dist/request/SilentRequest.d.ts.map +1 -1
  196. package/dist/request/SsoSilentRequest.d.ts +1 -1
  197. package/dist/request/SsoSilentRequest.d.ts.map +1 -1
  198. package/dist/telemetry/BrowserPerformanceClient.d.ts +1 -1
  199. package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
  200. package/dist/telemetry/BrowserPerformanceClient.js +62 -57
  201. package/dist/telemetry/BrowserPerformanceClient.js.map +1 -1
  202. package/dist/telemetry/BrowserPerformanceMeasurement.d.ts.map +1 -1
  203. package/dist/telemetry/BrowserPerformanceMeasurement.js +30 -31
  204. package/dist/telemetry/BrowserPerformanceMeasurement.js.map +1 -1
  205. package/dist/utils/BrowserConstants.d.ts.map +1 -1
  206. package/dist/utils/BrowserConstants.js +10 -10
  207. package/dist/utils/BrowserConstants.js.map +1 -1
  208. package/dist/utils/BrowserProtocolUtils.d.ts +1 -1
  209. package/dist/utils/BrowserProtocolUtils.d.ts.map +1 -1
  210. package/dist/utils/BrowserProtocolUtils.js +9 -12
  211. package/dist/utils/BrowserProtocolUtils.js.map +1 -1
  212. package/dist/utils/BrowserStringUtils.d.ts.map +1 -1
  213. package/dist/utils/BrowserStringUtils.js +83 -49
  214. package/dist/utils/BrowserStringUtils.js.map +1 -1
  215. package/dist/utils/BrowserUtils.d.ts.map +1 -1
  216. package/dist/utils/BrowserUtils.js +51 -49
  217. package/dist/utils/BrowserUtils.js.map +1 -1
  218. package/dist/utils/MathUtils.d.ts.map +1 -1
  219. package/dist/utils/MathUtils.js +6 -9
  220. package/dist/utils/MathUtils.js.map +1 -1
  221. package/package.json +17 -16
  222. package/dist/_virtual/_tslib.js +0 -117
  223. package/dist/_virtual/_tslib.js.map +0 -1
  224. package/dist/app/ClientApplication.d.ts.map +0 -1
  225. package/dist/app/ClientApplication.js +0 -1053
  226. package/dist/app/ClientApplication.js.map +0 -1
  227. package/dist/index.cjs.js +0 -18080
  228. package/dist/index.cjs.js.map +0 -1
  229. package/lib/msal-browser.js +0 -18086
  230. package/lib/msal-browser.js.map +0 -1
  231. package/lib/msal-browser.min.js +0 -70
@@ -1,10 +1,9 @@
1
- /*! @azure/msal-browser v2.37.0 2023-05-01 */
1
+ /*! @azure/msal-browser v3.0.0-alpha.1 2023-05-08 */
2
2
  'use strict';
3
- import { __extends, __awaiter, __generator, __assign } from '../_virtual/_tslib.js';
4
- import { OIDC_DEFAULT_SCOPES, StringUtils, UrlString, Constants, AuthError, ThrottlingUtils, ProtocolUtils, PerformanceEvents } from '@azure/msal-common';
3
+ import { OIDC_DEFAULT_SCOPES, PerformanceEvents, Constants, UrlString, ThrottlingUtils, ProtocolUtils, AuthError, StringUtils } from '@azure/msal-common';
5
4
  import { StandardInteractionClient } from './StandardInteractionClient.js';
6
5
  import { EventType } from '../event/EventType.js';
7
- import { BrowserConstants, InteractionType, ApiId } from '../utils/BrowserConstants.js';
6
+ import { ApiId, InteractionType, BrowserConstants } from '../utils/BrowserConstants.js';
8
7
  import { BrowserUtils } from '../utils/BrowserUtils.js';
9
8
  import { NativeInteractionClient } from './NativeInteractionClient.js';
10
9
  import { NativeMessageHandler } from '../broker/nativeBroker/NativeMessageHandler.js';
@@ -15,23 +14,21 @@ import { InteractionHandler } from '../interaction_handler/InteractionHandler.js
15
14
  * Copyright (c) Microsoft Corporation. All rights reserved.
16
15
  * Licensed under the MIT License.
17
16
  */
18
- var PopupClient = /** @class */ (function (_super) {
19
- __extends(PopupClient, _super);
20
- function PopupClient(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeStorageImpl, nativeMessageHandler, correlationId) {
21
- var _this = _super.call(this, config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId) || this;
17
+ class PopupClient extends StandardInteractionClient {
18
+ constructor(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeStorageImpl, nativeMessageHandler, correlationId) {
19
+ super(config, storageImpl, browserCrypto, logger, eventHandler, navigationClient, performanceClient, nativeMessageHandler, correlationId);
22
20
  // Properly sets this reference for the unload event.
23
- _this.unloadWindow = _this.unloadWindow.bind(_this);
24
- _this.nativeStorage = nativeStorageImpl;
25
- return _this;
21
+ this.unloadWindow = this.unloadWindow.bind(this);
22
+ this.nativeStorage = nativeStorageImpl;
26
23
  }
27
24
  /**
28
25
  * Acquires tokens by opening a popup window to the /authorize endpoint of the authority
29
26
  * @param request
30
27
  */
31
- PopupClient.prototype.acquireToken = function (request) {
28
+ acquireToken(request) {
32
29
  try {
33
- var popupName = this.generatePopupName(request.scopes || OIDC_DEFAULT_SCOPES, request.authority || this.config.auth.authority);
34
- var popupWindowAttributes = request.popupWindowAttributes || {};
30
+ const popupName = this.generatePopupName(request.scopes || OIDC_DEFAULT_SCOPES, request.authority || this.config.auth.authority);
31
+ const popupWindowAttributes = request.popupWindowAttributes || {};
35
32
  // asyncPopups flag is true. Acquires token without first opening popup. Popup will be opened later asynchronously.
36
33
  if (this.config.system.asyncPopups) {
37
34
  this.logger.verbose("asyncPopups set to true, acquiring token");
@@ -41,26 +38,26 @@ var PopupClient = /** @class */ (function (_super) {
41
38
  else {
42
39
  // asyncPopups flag is set to false. Opens popup before acquiring token.
43
40
  this.logger.verbose("asyncPopup set to false, opening popup before acquiring token");
44
- var popup = this.openSizedPopup("about:blank", popupName, popupWindowAttributes);
41
+ const popup = this.openSizedPopup("about:blank", popupName, popupWindowAttributes);
45
42
  return this.acquireTokenPopupAsync(request, popupName, popupWindowAttributes, popup);
46
43
  }
47
44
  }
48
45
  catch (e) {
49
46
  return Promise.reject(e);
50
47
  }
51
- };
48
+ }
52
49
  /**
53
50
  * Clears local cache for the current user then opens a popup window prompting the user to sign-out of the server
54
51
  * @param logoutRequest
55
52
  */
56
- PopupClient.prototype.logout = function (logoutRequest) {
53
+ logout(logoutRequest) {
57
54
  try {
58
55
  this.logger.verbose("logoutPopup called");
59
- var validLogoutRequest = this.initializeLogoutRequest(logoutRequest);
60
- var popupName = this.generateLogoutPopupName(validLogoutRequest);
61
- var authority = logoutRequest && logoutRequest.authority;
62
- var mainWindowRedirectUri = logoutRequest && logoutRequest.mainWindowRedirectUri;
63
- var popupWindowAttributes = (logoutRequest === null || logoutRequest === void 0 ? void 0 : logoutRequest.popupWindowAttributes) || {};
56
+ const validLogoutRequest = this.initializeLogoutRequest(logoutRequest);
57
+ const popupName = this.generateLogoutPopupName(validLogoutRequest);
58
+ const authority = logoutRequest && logoutRequest.authority;
59
+ const mainWindowRedirectUri = logoutRequest && logoutRequest.mainWindowRedirectUri;
60
+ const popupWindowAttributes = logoutRequest?.popupWindowAttributes || {};
64
61
  // asyncPopups flag is true. Acquires token without first opening popup. Popup will be opened later asynchronously.
65
62
  if (this.config.system.asyncPopups) {
66
63
  this.logger.verbose("asyncPopups set to true");
@@ -70,7 +67,7 @@ var PopupClient = /** @class */ (function (_super) {
70
67
  else {
71
68
  // asyncPopups flag is set to false. Opens popup before logging out.
72
69
  this.logger.verbose("asyncPopup set to false, opening popup");
73
- var popup = this.openSizedPopup("about:blank", popupName, popupWindowAttributes);
70
+ const popup = this.openSizedPopup("about:blank", popupName, popupWindowAttributes);
74
71
  return this.logoutPopupAsync(validLogoutRequest, popupName, popupWindowAttributes, authority, popup, mainWindowRedirectUri);
75
72
  }
76
73
  }
@@ -78,7 +75,7 @@ var PopupClient = /** @class */ (function (_super) {
78
75
  // Since this function is synchronous we need to reject
79
76
  return Promise.reject(e);
80
77
  }
81
- };
78
+ }
82
79
  /**
83
80
  * Helper which obtains an access_token for your API via opening a popup window in the user's browser
84
81
  * @param validRequest
@@ -88,97 +85,90 @@ var PopupClient = /** @class */ (function (_super) {
88
85
  *
89
86
  * @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.
90
87
  */
91
- PopupClient.prototype.acquireTokenPopupAsync = function (request, popupName, popupWindowAttributes, popup) {
92
- return __awaiter(this, void 0, void 0, function () {
93
- var serverTelemetryManager, validRequest, authCodeRequest, authClient, isNativeBroker, fetchNativeAccountIdMeasurement, navigateUrl, interactionHandler, popupParameters, popupWindow, hash, serverParams, state_1, nativeInteractionClient, userRequestState, result, e_1;
94
- var _this = this;
95
- return __generator(this, function (_a) {
96
- switch (_a.label) {
97
- case 0:
98
- this.logger.verbose("acquireTokenPopupAsync called");
99
- serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenPopup);
100
- this.performanceClient.setPreQueueTime(PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest, request.correlationId);
101
- return [4 /*yield*/, this.initializeAuthorizationRequest(request, InteractionType.Popup)];
102
- case 1:
103
- validRequest = _a.sent();
104
- this.browserStorage.updateCacheEntries(validRequest.state, validRequest.nonce, validRequest.authority, validRequest.loginHint || Constants.EMPTY_STRING, validRequest.account || null);
105
- _a.label = 2;
106
- case 2:
107
- _a.trys.push([2, 8, , 9]);
108
- // Create auth code request and generate PKCE params
109
- this.performanceClient.setPreQueueTime(PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest, request.correlationId);
110
- return [4 /*yield*/, this.initializeAuthorizationCodeRequest(validRequest)];
111
- case 3:
112
- authCodeRequest = _a.sent();
113
- // Initialize the client
114
- this.performanceClient.setPreQueueTime(PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, request.correlationId);
115
- return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, validRequest.authority, validRequest.azureCloudOptions)];
116
- case 4:
117
- authClient = _a.sent();
118
- this.logger.verbose("Auth code client created");
119
- isNativeBroker = NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeMessageHandler, request.authenticationScheme);
120
- fetchNativeAccountIdMeasurement = void 0;
121
- if (isNativeBroker) {
122
- fetchNativeAccountIdMeasurement = this.performanceClient.startMeasurement(PerformanceEvents.FetchAccountIdWithNativeBroker, request.correlationId);
123
- }
124
- return [4 /*yield*/, authClient.getAuthCodeUrl(__assign(__assign({}, validRequest), { nativeBroker: isNativeBroker }))];
125
- case 5:
126
- navigateUrl = _a.sent();
127
- interactionHandler = new InteractionHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.performanceClient);
128
- popupParameters = {
129
- popup: popup,
130
- popupName: popupName,
131
- popupWindowAttributes: popupWindowAttributes
132
- };
133
- popupWindow = this.initiateAuthRequest(navigateUrl, popupParameters);
134
- this.eventHandler.emitEvent(EventType.POPUP_OPENED, InteractionType.Popup, { popupWindow: popupWindow }, null);
135
- return [4 /*yield*/, this.monitorPopupForHash(popupWindow)];
136
- case 6:
137
- hash = _a.sent();
138
- serverParams = UrlString.getDeserializedHash(hash);
139
- state_1 = this.validateAndExtractStateFromHash(serverParams, InteractionType.Popup, validRequest.correlationId);
140
- // Remove throttle if it exists
141
- ThrottlingUtils.removeThrottle(this.browserStorage, this.config.auth.clientId, authCodeRequest);
142
- if (serverParams.accountId) {
143
- this.logger.verbose("Account id found in hash, calling WAM for token");
144
- // end measurement for server call with native brokering enabled
145
- if (fetchNativeAccountIdMeasurement) {
146
- fetchNativeAccountIdMeasurement.endMeasurement({
147
- success: true,
148
- isNativeBroker: true
149
- });
150
- }
151
- if (!this.nativeMessageHandler) {
152
- throw BrowserAuthError.createNativeConnectionNotEstablishedError();
153
- }
154
- nativeInteractionClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, ApiId.acquireTokenPopup, this.performanceClient, this.nativeMessageHandler, serverParams.accountId, this.nativeStorage, validRequest.correlationId);
155
- userRequestState = ProtocolUtils.parseRequestState(this.browserCrypto, state_1).userRequestState;
156
- return [2 /*return*/, nativeInteractionClient.acquireToken(__assign(__assign({}, validRequest), { state: userRequestState, prompt: undefined // Server should handle the prompt, ideally native broker can do this part silently
157
- })).finally(function () {
158
- _this.browserStorage.cleanRequestByState(state_1);
159
- })];
160
- }
161
- return [4 /*yield*/, interactionHandler.handleCodeResponseFromHash(hash, state_1, authClient.authority, this.networkClient)];
162
- case 7:
163
- result = _a.sent();
164
- return [2 /*return*/, result];
165
- case 8:
166
- e_1 = _a.sent();
167
- if (popup) {
168
- // Close the synchronous popup if an error is thrown before the window unload event is registered
169
- popup.close();
170
- }
171
- if (e_1 instanceof AuthError) {
172
- e_1.setCorrelationId(this.correlationId);
173
- }
174
- serverTelemetryManager.cacheFailedRequest(e_1);
175
- this.browserStorage.cleanRequestByState(validRequest.state);
176
- throw e_1;
177
- case 9: return [2 /*return*/];
178
- }
88
+ async acquireTokenPopupAsync(request, popupName, popupWindowAttributes, popup) {
89
+ this.logger.verbose("acquireTokenPopupAsync called");
90
+ const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.acquireTokenPopup);
91
+ this.performanceClient.setPreQueueTime(PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest, request.correlationId);
92
+ const validRequest = await this.initializeAuthorizationRequest(request, InteractionType.Popup);
93
+ this.browserStorage.updateCacheEntries(validRequest.state, validRequest.nonce, validRequest.authority, validRequest.loginHint || Constants.EMPTY_STRING, validRequest.account || null);
94
+ try {
95
+ // Create auth code request and generate PKCE params
96
+ this.performanceClient.setPreQueueTime(PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest, request.correlationId);
97
+ const authCodeRequest = await this.initializeAuthorizationCodeRequest(validRequest);
98
+ // Initialize the client
99
+ this.performanceClient.setPreQueueTime(PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, request.correlationId);
100
+ const authClient = await this.createAuthCodeClient(serverTelemetryManager, validRequest.authority, validRequest.azureCloudOptions);
101
+ this.logger.verbose("Auth code client created");
102
+ const isNativeBroker = NativeMessageHandler.isNativeAvailable(this.config, this.logger, this.nativeMessageHandler, request.authenticationScheme);
103
+ // Start measurement for server calls with native brokering enabled
104
+ let fetchNativeAccountIdMeasurement;
105
+ if (isNativeBroker) {
106
+ fetchNativeAccountIdMeasurement =
107
+ this.performanceClient.startMeasurement(PerformanceEvents.FetchAccountIdWithNativeBroker, request.correlationId);
108
+ }
109
+ // Create acquire token url.
110
+ const navigateUrl = await authClient.getAuthCodeUrl({
111
+ ...validRequest,
112
+ nativeBroker: isNativeBroker,
179
113
  });
180
- });
181
- };
114
+ // Create popup interaction handler.
115
+ const interactionHandler = new InteractionHandler(authClient, this.browserStorage, authCodeRequest, this.logger, this.performanceClient);
116
+ // Show the UI once the url has been created. Get the window handle for the popup.
117
+ const popupParameters = {
118
+ popup,
119
+ popupName,
120
+ popupWindowAttributes,
121
+ };
122
+ const popupWindow = this.initiateAuthRequest(navigateUrl, popupParameters);
123
+ this.eventHandler.emitEvent(EventType.POPUP_OPENED, InteractionType.Popup, { popupWindow }, null);
124
+ // Monitor the window for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.
125
+ const hash = await this.monitorPopupForHash(popupWindow);
126
+ // Deserialize hash fragment response parameters.
127
+ const serverParams = UrlString.getDeserializedHash(hash);
128
+ const state = this.validateAndExtractStateFromHash(serverParams, InteractionType.Popup, validRequest.correlationId);
129
+ // Remove throttle if it exists
130
+ ThrottlingUtils.removeThrottle(this.browserStorage, this.config.auth.clientId, authCodeRequest);
131
+ if (serverParams.accountId) {
132
+ this.logger.verbose("Account id found in hash, calling WAM for token");
133
+ // end measurement for server call with native brokering enabled
134
+ if (fetchNativeAccountIdMeasurement) {
135
+ fetchNativeAccountIdMeasurement.endMeasurement({
136
+ success: true,
137
+ isNativeBroker: true,
138
+ });
139
+ }
140
+ if (!this.nativeMessageHandler) {
141
+ throw BrowserAuthError.createNativeConnectionNotEstablishedError();
142
+ }
143
+ const nativeInteractionClient = new NativeInteractionClient(this.config, this.browserStorage, this.browserCrypto, this.logger, this.eventHandler, this.navigationClient, ApiId.acquireTokenPopup, this.performanceClient, this.nativeMessageHandler, serverParams.accountId, this.nativeStorage, validRequest.correlationId);
144
+ const { userRequestState } = ProtocolUtils.parseRequestState(this.browserCrypto, state);
145
+ return nativeInteractionClient
146
+ .acquireToken({
147
+ ...validRequest,
148
+ state: userRequestState,
149
+ prompt: undefined, // Server should handle the prompt, ideally native broker can do this part silently
150
+ })
151
+ .finally(() => {
152
+ this.browserStorage.cleanRequestByState(state);
153
+ });
154
+ }
155
+ // Handle response from hash string.
156
+ const result = await interactionHandler.handleCodeResponseFromHash(hash, state, authClient.authority, this.networkClient);
157
+ return result;
158
+ }
159
+ catch (e) {
160
+ if (popup) {
161
+ // Close the synchronous popup if an error is thrown before the window unload event is registered
162
+ popup.close();
163
+ }
164
+ if (e instanceof AuthError) {
165
+ e.setCorrelationId(this.correlationId);
166
+ serverTelemetryManager.cacheFailedRequest(e);
167
+ }
168
+ this.browserStorage.cleanRequestByState(validRequest.state);
169
+ throw e;
170
+ }
171
+ }
182
172
  /**
183
173
  *
184
174
  * @param validRequest
@@ -188,80 +178,67 @@ var PopupClient = /** @class */ (function (_super) {
188
178
  * @param mainWindowRedirectUri
189
179
  * @param popupWindowAttributes
190
180
  */
191
- PopupClient.prototype.logoutPopupAsync = function (validRequest, popupName, popupWindowAttributes, requestAuthority, popup, mainWindowRedirectUri) {
192
- return __awaiter(this, void 0, void 0, function () {
193
- var serverTelemetryManager, authClient, logoutUri, popupWindow, navigationOptions, absoluteUrl, e_2;
194
- return __generator(this, function (_a) {
195
- switch (_a.label) {
196
- case 0:
197
- this.logger.verbose("logoutPopupAsync called");
198
- this.eventHandler.emitEvent(EventType.LOGOUT_START, InteractionType.Popup, validRequest);
199
- serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.logoutPopup);
200
- _a.label = 1;
201
- case 1:
202
- _a.trys.push([1, 5, , 6]);
203
- // Clear cache on logout
204
- return [4 /*yield*/, this.clearCacheOnLogout(validRequest.account)];
205
- case 2:
206
- // Clear cache on logout
207
- _a.sent();
208
- // Initialize the client
209
- this.performanceClient.setPreQueueTime(PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, validRequest.correlationId);
210
- return [4 /*yield*/, this.createAuthCodeClient(serverTelemetryManager, requestAuthority)];
211
- case 3:
212
- authClient = _a.sent();
213
- this.logger.verbose("Auth code client created");
214
- logoutUri = authClient.getLogoutUri(validRequest);
215
- this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, InteractionType.Popup, validRequest);
216
- popupWindow = this.openPopup(logoutUri, { popupName: popupName, popupWindowAttributes: popupWindowAttributes, popup: popup });
217
- this.eventHandler.emitEvent(EventType.POPUP_OPENED, InteractionType.Popup, { popupWindow: popupWindow }, null);
218
- return [4 /*yield*/, this.waitForLogoutPopup(popupWindow)];
219
- case 4:
220
- _a.sent();
221
- if (mainWindowRedirectUri) {
222
- navigationOptions = {
223
- apiId: ApiId.logoutPopup,
224
- timeout: this.config.system.redirectNavigationTimeout,
225
- noHistory: false
226
- };
227
- absoluteUrl = UrlString.getAbsoluteUrl(mainWindowRedirectUri, BrowserUtils.getCurrentUri());
228
- this.logger.verbose("Redirecting main window to url specified in the request");
229
- this.logger.verbosePii("Redirecting main window to: " + absoluteUrl);
230
- this.navigationClient.navigateInternal(absoluteUrl, navigationOptions);
231
- }
232
- else {
233
- this.logger.verbose("No main window navigation requested");
234
- }
235
- return [3 /*break*/, 6];
236
- case 5:
237
- e_2 = _a.sent();
238
- if (popup) {
239
- // Close the synchronous popup if an error is thrown before the window unload event is registered
240
- popup.close();
241
- }
242
- if (e_2 instanceof AuthError) {
243
- e_2.setCorrelationId(this.correlationId);
244
- }
245
- this.browserStorage.setInteractionInProgress(false);
246
- this.eventHandler.emitEvent(EventType.LOGOUT_FAILURE, InteractionType.Popup, null, e_2);
247
- this.eventHandler.emitEvent(EventType.LOGOUT_END, InteractionType.Popup);
248
- serverTelemetryManager.cacheFailedRequest(e_2);
249
- throw e_2;
250
- case 6:
251
- this.eventHandler.emitEvent(EventType.LOGOUT_END, InteractionType.Popup);
252
- return [2 /*return*/];
253
- }
181
+ async logoutPopupAsync(validRequest, popupName, popupWindowAttributes, requestAuthority, popup, mainWindowRedirectUri) {
182
+ this.logger.verbose("logoutPopupAsync called");
183
+ this.eventHandler.emitEvent(EventType.LOGOUT_START, InteractionType.Popup, validRequest);
184
+ const serverTelemetryManager = this.initializeServerTelemetryManager(ApiId.logoutPopup);
185
+ try {
186
+ // Clear cache on logout
187
+ await this.clearCacheOnLogout(validRequest.account);
188
+ // Initialize the client
189
+ this.performanceClient.setPreQueueTime(PerformanceEvents.StandardInteractionClientCreateAuthCodeClient, validRequest.correlationId);
190
+ const authClient = await this.createAuthCodeClient(serverTelemetryManager, requestAuthority);
191
+ this.logger.verbose("Auth code client created");
192
+ // Create logout string and navigate user window to logout.
193
+ const logoutUri = authClient.getLogoutUri(validRequest);
194
+ this.eventHandler.emitEvent(EventType.LOGOUT_SUCCESS, InteractionType.Popup, validRequest);
195
+ // Open the popup window to requestUrl.
196
+ const popupWindow = this.openPopup(logoutUri, {
197
+ popupName,
198
+ popupWindowAttributes,
199
+ popup,
254
200
  });
255
- });
256
- };
201
+ this.eventHandler.emitEvent(EventType.POPUP_OPENED, InteractionType.Popup, { popupWindow }, null);
202
+ await this.waitForLogoutPopup(popupWindow);
203
+ if (mainWindowRedirectUri) {
204
+ const navigationOptions = {
205
+ apiId: ApiId.logoutPopup,
206
+ timeout: this.config.system.redirectNavigationTimeout,
207
+ noHistory: false,
208
+ };
209
+ const absoluteUrl = UrlString.getAbsoluteUrl(mainWindowRedirectUri, BrowserUtils.getCurrentUri());
210
+ this.logger.verbose("Redirecting main window to url specified in the request");
211
+ this.logger.verbosePii(`Redirecting main window to: ${absoluteUrl}`);
212
+ this.navigationClient.navigateInternal(absoluteUrl, navigationOptions);
213
+ }
214
+ else {
215
+ this.logger.verbose("No main window navigation requested");
216
+ }
217
+ }
218
+ catch (e) {
219
+ if (popup) {
220
+ // Close the synchronous popup if an error is thrown before the window unload event is registered
221
+ popup.close();
222
+ }
223
+ if (e instanceof AuthError) {
224
+ e.setCorrelationId(this.correlationId);
225
+ serverTelemetryManager.cacheFailedRequest(e);
226
+ }
227
+ this.browserStorage.setInteractionInProgress(false);
228
+ this.eventHandler.emitEvent(EventType.LOGOUT_FAILURE, InteractionType.Popup, null, e);
229
+ this.eventHandler.emitEvent(EventType.LOGOUT_END, InteractionType.Popup);
230
+ throw e;
231
+ }
232
+ this.eventHandler.emitEvent(EventType.LOGOUT_END, InteractionType.Popup);
233
+ }
257
234
  /**
258
235
  * Opens a popup window with given request Url.
259
236
  * @param requestUrl
260
237
  */
261
- PopupClient.prototype.initiateAuthRequest = function (requestUrl, params) {
238
+ initiateAuthRequest(requestUrl, params) {
262
239
  // Check that request url is not empty.
263
240
  if (!StringUtils.isEmpty(requestUrl)) {
264
- this.logger.infoPii("Navigate to: " + requestUrl);
241
+ this.logger.infoPii(`Navigate to: ${requestUrl}`);
265
242
  // Open the popup window to requestUrl.
266
243
  return this.openPopup(requestUrl, params);
267
244
  }
@@ -270,33 +247,33 @@ var PopupClient = /** @class */ (function (_super) {
270
247
  this.logger.error("Navigate url is empty");
271
248
  throw BrowserAuthError.createEmptyNavigationUriError();
272
249
  }
273
- };
250
+ }
274
251
  /**
275
252
  * Monitors a window until it loads a url with the same origin.
276
253
  * @param popupWindow - window that is being monitored
277
254
  * @param timeout - timeout for processing hash once popup is redirected back to application
278
255
  */
279
- PopupClient.prototype.monitorPopupForHash = function (popupWindow) {
280
- var _this = this;
281
- return new Promise(function (resolve, reject) {
256
+ monitorPopupForHash(popupWindow) {
257
+ return new Promise((resolve, reject) => {
282
258
  /*
283
259
  * Polling for popups needs to be tick-based,
284
260
  * since a non-trivial amount of time can be spent on interaction (which should not count against the timeout).
285
261
  */
286
- var maxTicks = _this.config.system.windowHashTimeout / _this.config.system.pollIntervalMilliseconds;
287
- var ticks = 0;
288
- _this.logger.verbose("PopupHandler.monitorPopupForHash - polling started");
289
- var intervalId = setInterval(function () {
262
+ const maxTicks = this.config.system.windowHashTimeout /
263
+ this.config.system.pollIntervalMilliseconds;
264
+ let ticks = 0;
265
+ this.logger.verbose("PopupHandler.monitorPopupForHash - polling started");
266
+ const intervalId = setInterval(() => {
290
267
  // Window is closed
291
268
  if (popupWindow.closed) {
292
- _this.logger.error("PopupHandler.monitorPopupForHash - window closed");
293
- _this.cleanPopup();
269
+ this.logger.error("PopupHandler.monitorPopupForHash - window closed");
270
+ this.cleanPopup();
294
271
  clearInterval(intervalId);
295
272
  reject(BrowserAuthError.createUserCancelledError());
296
273
  return;
297
274
  }
298
- var href = Constants.EMPTY_STRING;
299
- var hash = Constants.EMPTY_STRING;
275
+ let href = Constants.EMPTY_STRING;
276
+ let hash = Constants.EMPTY_STRING;
300
277
  try {
301
278
  /*
302
279
  * Will throw if cross origin,
@@ -311,52 +288,51 @@ var PopupClient = /** @class */ (function (_super) {
311
288
  if (StringUtils.isEmpty(href) || href === "about:blank") {
312
289
  return;
313
290
  }
314
- _this.logger.verbose("PopupHandler.monitorPopupForHash - popup window is on same origin as caller");
291
+ this.logger.verbose("PopupHandler.monitorPopupForHash - popup window is on same origin as caller");
315
292
  /*
316
293
  * Only run clock when we are on same domain for popups
317
294
  * as popup operations can take a long time.
318
295
  */
319
296
  ticks++;
320
297
  if (hash) {
321
- _this.logger.verbose("PopupHandler.monitorPopupForHash - found hash in url");
298
+ this.logger.verbose("PopupHandler.monitorPopupForHash - found hash in url");
322
299
  clearInterval(intervalId);
323
- _this.cleanPopup(popupWindow);
300
+ this.cleanPopup(popupWindow);
324
301
  if (UrlString.hashContainsKnownProperties(hash)) {
325
- _this.logger.verbose("PopupHandler.monitorPopupForHash - hash contains known properties, returning.");
302
+ this.logger.verbose("PopupHandler.monitorPopupForHash - hash contains known properties, returning.");
326
303
  resolve(hash);
327
304
  }
328
305
  else {
329
- _this.logger.error("PopupHandler.monitorPopupForHash - found hash in url but it does not contain known properties. Check that your router is not changing the hash prematurely.");
330
- _this.logger.errorPii("PopupHandler.monitorPopupForHash - hash found: " + hash);
306
+ this.logger.error("PopupHandler.monitorPopupForHash - found hash in url but it does not contain known properties. Check that your router is not changing the hash prematurely.");
307
+ this.logger.errorPii(`PopupHandler.monitorPopupForHash - hash found: ${hash}`);
331
308
  reject(BrowserAuthError.createHashDoesNotContainKnownPropertiesError());
332
309
  }
333
310
  }
334
311
  else if (ticks > maxTicks) {
335
- _this.logger.error("PopupHandler.monitorPopupForHash - unable to find hash in url, timing out");
312
+ this.logger.error("PopupHandler.monitorPopupForHash - unable to find hash in url, timing out");
336
313
  clearInterval(intervalId);
337
314
  reject(BrowserAuthError.createMonitorPopupTimeoutError());
338
315
  }
339
- }, _this.config.system.pollIntervalMilliseconds);
316
+ }, this.config.system.pollIntervalMilliseconds);
340
317
  });
341
- };
318
+ }
342
319
  /**
343
320
  * Waits for user interaction in logout popup window
344
321
  * @param popupWindow
345
322
  * @returns
346
323
  */
347
- PopupClient.prototype.waitForLogoutPopup = function (popupWindow) {
348
- var _this = this;
349
- return new Promise(function (resolve) {
350
- _this.logger.verbose("PopupHandler.waitForLogoutPopup - polling started");
351
- var intervalId = setInterval(function () {
324
+ waitForLogoutPopup(popupWindow) {
325
+ return new Promise((resolve) => {
326
+ this.logger.verbose("PopupHandler.waitForLogoutPopup - polling started");
327
+ const intervalId = setInterval(() => {
352
328
  // Window is closed
353
329
  if (popupWindow.closed) {
354
- _this.logger.error("PopupHandler.waitForLogoutPopup - window closed");
355
- _this.cleanPopup();
330
+ this.logger.error("PopupHandler.waitForLogoutPopup - window closed");
331
+ this.cleanPopup();
356
332
  clearInterval(intervalId);
357
333
  resolve();
358
334
  }
359
- var href = Constants.EMPTY_STRING;
335
+ let href = Constants.EMPTY_STRING;
360
336
  try {
361
337
  /*
362
338
  * Will throw if cross origin,
@@ -370,13 +346,13 @@ var PopupClient = /** @class */ (function (_super) {
370
346
  if (StringUtils.isEmpty(href) || href === "about:blank") {
371
347
  return;
372
348
  }
373
- _this.logger.verbose("PopupHandler.waitForLogoutPopup - popup window is on same origin as caller, closing.");
349
+ this.logger.verbose("PopupHandler.waitForLogoutPopup - popup window is on same origin as caller, closing.");
374
350
  clearInterval(intervalId);
375
- _this.cleanPopup(popupWindow);
351
+ this.cleanPopup(popupWindow);
376
352
  resolve();
377
- }, _this.config.system.pollIntervalMilliseconds);
353
+ }, this.config.system.pollIntervalMilliseconds);
378
354
  });
379
- };
355
+ }
380
356
  /**
381
357
  * @hidden
382
358
  *
@@ -390,18 +366,18 @@ var PopupClient = /** @class */ (function (_super) {
390
366
  * @ignore
391
367
  * @hidden
392
368
  */
393
- PopupClient.prototype.openPopup = function (urlNavigate, popupParams) {
369
+ openPopup(urlNavigate, popupParams) {
394
370
  try {
395
- var popupWindow = void 0;
371
+ let popupWindow;
396
372
  // Popup window passed in, setting url to navigate to
397
373
  if (popupParams.popup) {
398
374
  popupWindow = popupParams.popup;
399
- this.logger.verbosePii("Navigating popup window to: " + urlNavigate);
375
+ this.logger.verbosePii(`Navigating popup window to: ${urlNavigate}`);
400
376
  popupWindow.location.assign(urlNavigate);
401
377
  }
402
378
  else if (typeof popupParams.popup === "undefined") {
403
379
  // Popup will be undefined if it was not passed in
404
- this.logger.verbosePii("Opening popup window to: " + urlNavigate);
380
+ this.logger.verbosePii(`Opening popup window to: ${urlNavigate}`);
405
381
  popupWindow = this.openSizedPopup(urlNavigate, popupParams.popupName, popupParams.popupWindowAttributes);
406
382
  }
407
383
  // Popup will be null if popups are blocked
@@ -420,7 +396,7 @@ var PopupClient = /** @class */ (function (_super) {
420
396
  this.browserStorage.setInteractionInProgress(false);
421
397
  throw BrowserAuthError.createPopupWindowError(e.toString());
422
398
  }
423
- };
399
+ }
424
400
  /**
425
401
  * Helper function to set popup window dimensions and position
426
402
  * @param urlNavigate
@@ -428,24 +404,27 @@ var PopupClient = /** @class */ (function (_super) {
428
404
  * @param popupWindowAttributes
429
405
  * @returns
430
406
  */
431
- PopupClient.prototype.openSizedPopup = function (urlNavigate, popupName, popupWindowAttributes) {
432
- var _a, _b, _c, _d;
407
+ openSizedPopup(urlNavigate, popupName, popupWindowAttributes) {
433
408
  /**
434
409
  * adding winLeft and winTop to account for dual monitor
435
410
  * using screenLeft and screenTop for IE8 and earlier
436
411
  */
437
- var winLeft = window.screenLeft ? window.screenLeft : window.screenX;
438
- var winTop = window.screenTop ? window.screenTop : window.screenY;
412
+ const winLeft = window.screenLeft ? window.screenLeft : window.screenX;
413
+ const winTop = window.screenTop ? window.screenTop : window.screenY;
439
414
  /**
440
415
  * window.innerWidth displays browser window"s height and width excluding toolbars
441
416
  * using document.documentElement.clientWidth for IE8 and earlier
442
417
  */
443
- var winWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
444
- var winHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
445
- var width = (_a = popupWindowAttributes.popupSize) === null || _a === void 0 ? void 0 : _a.width;
446
- var height = (_b = popupWindowAttributes.popupSize) === null || _b === void 0 ? void 0 : _b.height;
447
- var top = (_c = popupWindowAttributes.popupPosition) === null || _c === void 0 ? void 0 : _c.top;
448
- var left = (_d = popupWindowAttributes.popupPosition) === null || _d === void 0 ? void 0 : _d.left;
418
+ const winWidth = window.innerWidth ||
419
+ document.documentElement.clientWidth ||
420
+ document.body.clientWidth;
421
+ const winHeight = window.innerHeight ||
422
+ document.documentElement.clientHeight ||
423
+ document.body.clientHeight;
424
+ let width = popupWindowAttributes.popupSize?.width;
425
+ let height = popupWindowAttributes.popupSize?.height;
426
+ let top = popupWindowAttributes.popupPosition?.top;
427
+ let left = popupWindowAttributes.popupPosition?.left;
449
428
  if (!width || width < 0 || width > winWidth) {
450
429
  this.logger.verbose("Default popup window width used. Window width not configured or invalid.");
451
430
  width = BrowserConstants.POPUP_WIDTH;
@@ -456,30 +435,30 @@ var PopupClient = /** @class */ (function (_super) {
456
435
  }
457
436
  if (!top || top < 0 || top > winHeight) {
458
437
  this.logger.verbose("Default popup window top position used. Window top not configured or invalid.");
459
- top = Math.max(0, ((winHeight / 2) - (BrowserConstants.POPUP_HEIGHT / 2)) + winTop);
438
+ top = Math.max(0, winHeight / 2 - BrowserConstants.POPUP_HEIGHT / 2 + winTop);
460
439
  }
461
440
  if (!left || left < 0 || left > winWidth) {
462
441
  this.logger.verbose("Default popup window left position used. Window left not configured or invalid.");
463
- left = Math.max(0, ((winWidth / 2) - (BrowserConstants.POPUP_WIDTH / 2)) + winLeft);
442
+ left = Math.max(0, winWidth / 2 - BrowserConstants.POPUP_WIDTH / 2 + winLeft);
464
443
  }
465
- return window.open(urlNavigate, popupName, "width=" + width + ", height=" + height + ", top=" + top + ", left=" + left + ", scrollbars=yes");
466
- };
444
+ return window.open(urlNavigate, popupName, `width=${width}, height=${height}, top=${top}, left=${left}, scrollbars=yes`);
445
+ }
467
446
  /**
468
447
  * Event callback to unload main window.
469
448
  */
470
- PopupClient.prototype.unloadWindow = function (e) {
449
+ unloadWindow(e) {
471
450
  this.browserStorage.cleanRequestByInteractionType(InteractionType.Popup);
472
451
  if (this.currentWindow) {
473
452
  this.currentWindow.close();
474
453
  }
475
454
  // Guarantees browser unload will happen, so no other errors will be thrown.
476
455
  e.preventDefault();
477
- };
456
+ }
478
457
  /**
479
458
  * Closes popup, removes any state vars created during popup calls.
480
459
  * @param popupWindow
481
460
  */
482
- PopupClient.prototype.cleanPopup = function (popupWindow) {
461
+ cleanPopup(popupWindow) {
483
462
  if (popupWindow) {
484
463
  // Close window.
485
464
  popupWindow.close();
@@ -488,26 +467,25 @@ var PopupClient = /** @class */ (function (_super) {
488
467
  window.removeEventListener("beforeunload", this.unloadWindow);
489
468
  // Interaction is completed - remove interaction status.
490
469
  this.browserStorage.setInteractionInProgress(false);
491
- };
470
+ }
492
471
  /**
493
472
  * Generates the name for the popup based on the client id and request
494
473
  * @param clientId
495
474
  * @param request
496
475
  */
497
- PopupClient.prototype.generatePopupName = function (scopes, authority) {
498
- return BrowserConstants.POPUP_NAME_PREFIX + "." + this.config.auth.clientId + "." + scopes.join("-") + "." + authority + "." + this.correlationId;
499
- };
476
+ generatePopupName(scopes, authority) {
477
+ return `${BrowserConstants.POPUP_NAME_PREFIX}.${this.config.auth.clientId}.${scopes.join("-")}.${authority}.${this.correlationId}`;
478
+ }
500
479
  /**
501
480
  * Generates the name for the popup based on the client id and request for logouts
502
481
  * @param clientId
503
482
  * @param request
504
483
  */
505
- PopupClient.prototype.generateLogoutPopupName = function (request) {
506
- var homeAccountId = request.account && request.account.homeAccountId;
507
- return BrowserConstants.POPUP_NAME_PREFIX + "." + this.config.auth.clientId + "." + homeAccountId + "." + this.correlationId;
508
- };
509
- return PopupClient;
510
- }(StandardInteractionClient));
484
+ generateLogoutPopupName(request) {
485
+ const homeAccountId = request.account && request.account.homeAccountId;
486
+ return `${BrowserConstants.POPUP_NAME_PREFIX}.${this.config.auth.clientId}.${homeAccountId}.${this.correlationId}`;
487
+ }
488
+ }
511
489
 
512
490
  export { PopupClient };
513
491
  //# sourceMappingURL=PopupClient.js.map