@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.
- package/dist/app/IPublicClientApplication.d.ts.map +1 -1
- package/dist/app/IPublicClientApplication.js +33 -33
- package/dist/app/IPublicClientApplication.js.map +1 -1
- package/dist/app/PublicClientApplication.d.ts +198 -24
- package/dist/app/PublicClientApplication.d.ts.map +1 -1
- package/dist/app/PublicClientApplication.js +263 -220
- package/dist/app/PublicClientApplication.js.map +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts +5 -4
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.js +118 -124
- package/dist/broker/nativeBroker/NativeMessageHandler.js.map +1 -1
- package/dist/broker/nativeBroker/NativeRequest.d.ts +4 -4
- package/dist/broker/nativeBroker/NativeRequest.d.ts.map +1 -1
- package/dist/broker/nativeBroker/NativeResponse.d.ts +4 -4
- package/dist/broker/nativeBroker/NativeResponse.d.ts.map +1 -1
- package/dist/cache/AsyncMemoryStorage.d.ts.map +1 -1
- package/dist/cache/AsyncMemoryStorage.js +83 -152
- package/dist/cache/AsyncMemoryStorage.js.map +1 -1
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.js +420 -412
- package/dist/cache/BrowserCacheManager.js.map +1 -1
- package/dist/cache/BrowserStorage.d.ts.map +1 -1
- package/dist/cache/BrowserStorage.js +19 -19
- package/dist/cache/BrowserStorage.js.map +1 -1
- package/dist/cache/CryptoKeyStore.d.ts.map +1 -1
- package/dist/cache/CryptoKeyStore.js +26 -36
- package/dist/cache/CryptoKeyStore.js.map +1 -1
- package/dist/cache/DatabaseStorage.d.ts.map +1 -1
- package/dist/cache/DatabaseStorage.js +127 -191
- package/dist/cache/DatabaseStorage.js.map +1 -1
- package/dist/cache/ITokenCache.d.ts.map +1 -1
- package/dist/cache/MemoryStorage.d.ts.map +1 -1
- package/dist/cache/MemoryStorage.js +18 -19
- package/dist/cache/MemoryStorage.js.map +1 -1
- package/dist/cache/TokenCache.d.ts +1 -1
- package/dist/cache/TokenCache.d.ts.map +1 -1
- package/dist/cache/TokenCache.js +55 -49
- package/dist/cache/TokenCache.js.map +1 -1
- package/dist/config/Configuration.d.ts +8 -8
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.js +53 -31
- package/dist/config/Configuration.js.map +1 -1
- package/dist/controllers/ControllerFactory.d.ts +10 -0
- package/dist/controllers/ControllerFactory.d.ts.map +1 -0
- package/dist/controllers/ControllerFactory.js +47 -0
- package/dist/controllers/ControllerFactory.js.map +1 -0
- package/dist/controllers/IController.d.ts +67 -0
- package/dist/controllers/IController.d.ts.map +1 -0
- package/dist/{app/ClientApplication.d.ts → controllers/StandardController.d.ts} +96 -15
- package/dist/controllers/StandardController.d.ts.map +1 -0
- package/dist/controllers/StandardController.js +1299 -0
- package/dist/controllers/StandardController.js.map +1 -0
- package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
- package/dist/crypto/BrowserCrypto.js +36 -60
- package/dist/crypto/BrowserCrypto.js.map +1 -1
- package/dist/crypto/CryptoOps.d.ts +1 -1
- package/dist/crypto/CryptoOps.d.ts.map +1 -1
- package/dist/crypto/CryptoOps.js +93 -151
- package/dist/crypto/CryptoOps.js.map +1 -1
- package/dist/crypto/GuidGenerator.d.ts.map +1 -1
- package/dist/crypto/GuidGenerator.js +36 -25
- package/dist/crypto/GuidGenerator.js.map +1 -1
- package/dist/crypto/ISubtleCrypto.d.ts.map +1 -1
- package/dist/crypto/ModernBrowserCrypto.d.ts.map +1 -1
- package/dist/crypto/ModernBrowserCrypto.js +20 -44
- package/dist/crypto/ModernBrowserCrypto.js.map +1 -1
- package/dist/crypto/MsBrowserCrypto.d.ts.map +1 -1
- package/dist/crypto/MsBrowserCrypto.js +65 -89
- package/dist/crypto/MsBrowserCrypto.js.map +1 -1
- package/dist/crypto/MsrBrowserCrypto.d.ts.map +1 -1
- package/dist/crypto/MsrBrowserCrypto.js +23 -47
- package/dist/crypto/MsrBrowserCrypto.js.map +1 -1
- package/dist/crypto/PkceGenerator.d.ts.map +1 -1
- package/dist/crypto/PkceGenerator.js +28 -49
- package/dist/crypto/PkceGenerator.js.map +1 -1
- package/dist/crypto/SignedHttpRequest.d.ts +1 -1
- package/dist/crypto/SignedHttpRequest.d.ts.map +1 -1
- package/dist/crypto/SignedHttpRequest.js +15 -37
- package/dist/crypto/SignedHttpRequest.js.map +1 -1
- package/dist/encode/Base64Decode.d.ts.map +1 -1
- package/dist/encode/Base64Decode.js +32 -33
- package/dist/encode/Base64Decode.js.map +1 -1
- package/dist/encode/Base64Encode.d.ts.map +1 -1
- package/dist/encode/Base64Encode.js +34 -35
- package/dist/encode/Base64Encode.js.map +1 -1
- package/dist/error/BrowserAuthError.d.ts +1 -1
- package/dist/error/BrowserAuthError.d.ts.map +1 -1
- package/dist/error/BrowserAuthError.js +161 -163
- package/dist/error/BrowserAuthError.js.map +1 -1
- package/dist/error/BrowserConfigurationAuthError.d.ts.map +1 -1
- package/dist/error/BrowserConfigurationAuthError.js +32 -36
- package/dist/error/BrowserConfigurationAuthError.js.map +1 -1
- package/dist/error/NativeAuthError.d.ts +1 -1
- package/dist/error/NativeAuthError.d.ts.map +1 -1
- package/dist/error/NativeAuthError.js +26 -27
- package/dist/error/NativeAuthError.js.map +1 -1
- package/dist/event/EventHandler.d.ts.map +1 -1
- package/dist/event/EventHandler.js +33 -33
- package/dist/event/EventHandler.js.map +1 -1
- package/dist/event/EventMessage.d.ts +5 -5
- package/dist/event/EventMessage.d.ts.map +1 -1
- package/dist/event/EventMessage.js +18 -14
- package/dist/event/EventMessage.js.map +1 -1
- package/dist/event/EventType.js +1 -1
- package/dist/event/EventType.js.map +1 -1
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.js +92 -123
- package/dist/interaction_client/BaseInteractionClient.js.map +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.d.ts.map +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js +6 -10
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.js.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.js +336 -393
- package/dist/interaction_client/NativeInteractionClient.js.map +1 -1
- package/dist/interaction_client/PopupClient.d.ts +1 -1
- package/dist/interaction_client/PopupClient.d.ts.map +1 -1
- package/dist/interaction_client/PopupClient.js +224 -246
- package/dist/interaction_client/PopupClient.js.map +1 -1
- package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
- package/dist/interaction_client/RedirectClient.js +244 -292
- package/dist/interaction_client/RedirectClient.js.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.js +50 -63
- package/dist/interaction_client/SilentAuthCodeClient.js.map +1 -1
- package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentCacheClient.js +50 -81
- package/dist/interaction_client/SilentCacheClient.js.map +1 -1
- package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentIframeClient.js +107 -125
- package/dist/interaction_client/SilentIframeClient.js.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.js +44 -72
- package/dist/interaction_client/SilentRefreshClient.js.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.js +144 -180
- package/dist/interaction_client/StandardInteractionClient.js.map +1 -1
- package/dist/interaction_handler/InteractionHandler.d.ts +1 -1
- package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
- package/dist/interaction_handler/InteractionHandler.js +84 -110
- package/dist/interaction_handler/InteractionHandler.js.map +1 -1
- package/dist/interaction_handler/RedirectHandler.d.ts +1 -1
- package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
- package/dist/interaction_handler/RedirectHandler.js +105 -122
- package/dist/interaction_handler/RedirectHandler.js.map +1 -1
- package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
- package/dist/interaction_handler/SilentHandler.js +76 -65
- package/dist/interaction_handler/SilentHandler.js.map +1 -1
- package/dist/internals.js +1 -1
- package/dist/internals.js.map +1 -1
- package/dist/navigation/NavigationClient.d.ts.map +1 -1
- package/dist/navigation/NavigationClient.js +11 -14
- package/dist/navigation/NavigationClient.js.map +1 -1
- package/dist/navigation/NavigationOptions.d.ts +1 -1
- package/dist/navigation/NavigationOptions.d.ts.map +1 -1
- package/dist/network/FetchClient.d.ts.map +1 -1
- package/dist/network/FetchClient.js +66 -96
- package/dist/network/FetchClient.js.map +1 -1
- package/dist/network/XhrClient.d.ts.map +1 -1
- package/dist/network/XhrClient.js +38 -51
- package/dist/network/XhrClient.js.map +1 -1
- package/dist/operatingcontext/BaseOperatingContext.d.ts +41 -0
- package/dist/operatingcontext/BaseOperatingContext.d.ts.map +1 -0
- package/dist/operatingcontext/BaseOperatingContext.js +53 -0
- package/dist/operatingcontext/BaseOperatingContext.js.map +1 -0
- package/dist/operatingcontext/StandardOperatingContext.d.ts +26 -0
- package/dist/operatingcontext/StandardOperatingContext.d.ts.map +1 -0
- package/dist/operatingcontext/StandardOperatingContext.js +50 -0
- package/dist/operatingcontext/StandardOperatingContext.js.map +1 -0
- package/dist/operatingcontext/TeamsAppOperatingContext.d.ts +26 -0
- package/dist/operatingcontext/TeamsAppOperatingContext.d.ts.map +1 -0
- package/dist/operatingcontext/TeamsAppOperatingContext.js +49 -0
- package/dist/operatingcontext/TeamsAppOperatingContext.js.map +1 -0
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.d.ts.map +1 -1
- package/dist/packageMetadata.js +3 -3
- package/dist/packageMetadata.js.map +1 -1
- package/dist/request/AuthorizationCodeRequest.d.ts +1 -1
- package/dist/request/AuthorizationCodeRequest.d.ts.map +1 -1
- package/dist/request/AuthorizationUrlRequest.d.ts +1 -1
- package/dist/request/AuthorizationUrlRequest.d.ts.map +1 -1
- package/dist/request/EndSessionPopupRequest.d.ts +1 -1
- package/dist/request/EndSessionPopupRequest.d.ts.map +1 -1
- package/dist/request/EndSessionRequest.d.ts +1 -1
- package/dist/request/EndSessionRequest.d.ts.map +1 -1
- package/dist/request/PopupRequest.d.ts +1 -1
- package/dist/request/PopupRequest.d.ts.map +1 -1
- package/dist/request/PopupWindowAttributes.d.ts +3 -3
- package/dist/request/PopupWindowAttributes.d.ts.map +1 -1
- package/dist/request/RedirectRequest.d.ts +1 -1
- package/dist/request/RedirectRequest.d.ts.map +1 -1
- package/dist/request/SilentRequest.d.ts +1 -1
- package/dist/request/SilentRequest.d.ts.map +1 -1
- package/dist/request/SsoSilentRequest.d.ts +1 -1
- package/dist/request/SsoSilentRequest.d.ts.map +1 -1
- package/dist/telemetry/BrowserPerformanceClient.d.ts +1 -1
- package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/BrowserPerformanceClient.js +62 -57
- package/dist/telemetry/BrowserPerformanceClient.js.map +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.d.ts.map +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.js +30 -31
- package/dist/telemetry/BrowserPerformanceMeasurement.js.map +1 -1
- package/dist/utils/BrowserConstants.d.ts.map +1 -1
- package/dist/utils/BrowserConstants.js +10 -10
- package/dist/utils/BrowserConstants.js.map +1 -1
- package/dist/utils/BrowserProtocolUtils.d.ts +1 -1
- package/dist/utils/BrowserProtocolUtils.d.ts.map +1 -1
- package/dist/utils/BrowserProtocolUtils.js +9 -12
- package/dist/utils/BrowserProtocolUtils.js.map +1 -1
- package/dist/utils/BrowserStringUtils.d.ts.map +1 -1
- package/dist/utils/BrowserStringUtils.js +83 -49
- package/dist/utils/BrowserStringUtils.js.map +1 -1
- package/dist/utils/BrowserUtils.d.ts.map +1 -1
- package/dist/utils/BrowserUtils.js +51 -49
- package/dist/utils/BrowserUtils.js.map +1 -1
- package/dist/utils/MathUtils.d.ts.map +1 -1
- package/dist/utils/MathUtils.js +6 -9
- package/dist/utils/MathUtils.js.map +1 -1
- package/package.json +17 -16
- package/dist/_virtual/_tslib.js +0 -117
- package/dist/_virtual/_tslib.js.map +0 -1
- package/dist/app/ClientApplication.d.ts.map +0 -1
- package/dist/app/ClientApplication.js +0 -1053
- package/dist/app/ClientApplication.js.map +0 -1
- package/dist/index.cjs.js +0 -18080
- package/dist/index.cjs.js.map +0 -1
- package/lib/msal-browser.js +0 -18086
- package/lib/msal-browser.js.map +0 -1
- package/lib/msal-browser.min.js +0 -70
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
/*! @azure/msal-browser
|
|
1
|
+
/*! @azure/msal-browser v3.0.0-alpha.1 2023-05-08 */
|
|
2
2
|
'use strict';
|
|
3
|
-
import {
|
|
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 {
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
24
|
-
|
|
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
|
-
|
|
28
|
+
acquireToken(request) {
|
|
32
29
|
try {
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
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
|
-
|
|
53
|
+
logout(logoutRequest) {
|
|
57
54
|
try {
|
|
58
55
|
this.logger.verbose("logoutPopup called");
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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
|
-
|
|
238
|
+
initiateAuthRequest(requestUrl, params) {
|
|
262
239
|
// Check that request url is not empty.
|
|
263
240
|
if (!StringUtils.isEmpty(requestUrl)) {
|
|
264
|
-
this.logger.infoPii(
|
|
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
|
-
|
|
280
|
-
|
|
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
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
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
|
-
|
|
293
|
-
|
|
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
|
-
|
|
299
|
-
|
|
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
|
-
|
|
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
|
-
|
|
298
|
+
this.logger.verbose("PopupHandler.monitorPopupForHash - found hash in url");
|
|
322
299
|
clearInterval(intervalId);
|
|
323
|
-
|
|
300
|
+
this.cleanPopup(popupWindow);
|
|
324
301
|
if (UrlString.hashContainsKnownProperties(hash)) {
|
|
325
|
-
|
|
302
|
+
this.logger.verbose("PopupHandler.monitorPopupForHash - hash contains known properties, returning.");
|
|
326
303
|
resolve(hash);
|
|
327
304
|
}
|
|
328
305
|
else {
|
|
329
|
-
|
|
330
|
-
|
|
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
|
-
|
|
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
|
-
},
|
|
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
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
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
|
-
|
|
355
|
-
|
|
330
|
+
this.logger.error("PopupHandler.waitForLogoutPopup - window closed");
|
|
331
|
+
this.cleanPopup();
|
|
356
332
|
clearInterval(intervalId);
|
|
357
333
|
resolve();
|
|
358
334
|
}
|
|
359
|
-
|
|
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
|
-
|
|
349
|
+
this.logger.verbose("PopupHandler.waitForLogoutPopup - popup window is on same origin as caller, closing.");
|
|
374
350
|
clearInterval(intervalId);
|
|
375
|
-
|
|
351
|
+
this.cleanPopup(popupWindow);
|
|
376
352
|
resolve();
|
|
377
|
-
},
|
|
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
|
-
|
|
369
|
+
openPopup(urlNavigate, popupParams) {
|
|
394
370
|
try {
|
|
395
|
-
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
438
|
-
|
|
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
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
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,
|
|
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,
|
|
442
|
+
left = Math.max(0, winWidth / 2 - BrowserConstants.POPUP_WIDTH / 2 + winLeft);
|
|
464
443
|
}
|
|
465
|
-
return window.open(urlNavigate, popupName,
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
498
|
-
return BrowserConstants.POPUP_NAME_PREFIX
|
|
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
|
-
|
|
506
|
-
|
|
507
|
-
return BrowserConstants.POPUP_NAME_PREFIX
|
|
508
|
-
}
|
|
509
|
-
|
|
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
|