@azure/msal-browser 3.2.0 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/IPublicClientApplication.mjs +1 -1
- package/dist/app/PublicClientApplication.d.ts.map +1 -1
- package/dist/app/PublicClientApplication.mjs +3 -4
- package/dist/app/PublicClientApplication.mjs.map +1 -1
- package/dist/app/PublicClientNext.d.ts +274 -0
- package/dist/app/PublicClientNext.d.ts.map +1 -0
- package/dist/app/PublicClientNext.mjs +360 -0
- package/dist/app/PublicClientNext.mjs.map +1 -0
- package/dist/broker/nativeBroker/NativeMessageHandler.mjs +1 -1
- package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
- package/dist/cache/AsyncMemoryStorage.mjs +1 -1
- package/dist/cache/BrowserCacheManager.d.ts +2 -13
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.mjs +26 -83
- package/dist/cache/BrowserCacheManager.mjs.map +1 -1
- package/dist/cache/BrowserStorage.mjs +1 -1
- package/dist/cache/CryptoKeyStore.mjs +1 -1
- package/dist/cache/DatabaseStorage.mjs +1 -1
- package/dist/cache/MemoryStorage.mjs +1 -1
- package/dist/cache/TokenCache.d.ts.map +1 -1
- package/dist/cache/TokenCache.mjs +5 -5
- package/dist/cache/TokenCache.mjs.map +1 -1
- package/dist/config/Configuration.d.ts +4 -0
- package/dist/config/Configuration.d.ts.map +1 -1
- package/dist/config/Configuration.mjs +2 -1
- package/dist/config/Configuration.mjs.map +1 -1
- package/dist/controllers/ControllerFactory.d.ts +2 -7
- package/dist/controllers/ControllerFactory.d.ts.map +1 -1
- package/dist/controllers/ControllerFactory.mjs +24 -34
- package/dist/controllers/ControllerFactory.mjs.map +1 -1
- package/dist/controllers/IController.d.ts +1 -2
- package/dist/controllers/IController.d.ts.map +1 -1
- package/dist/controllers/NestedAppAuthController.d.ts +96 -0
- package/dist/controllers/NestedAppAuthController.d.ts.map +1 -0
- package/dist/controllers/NestedAppAuthController.mjs +345 -0
- package/dist/controllers/NestedAppAuthController.mjs.map +1 -0
- package/dist/controllers/StandardController.d.ts +4 -4
- package/dist/controllers/StandardController.d.ts.map +1 -1
- package/dist/controllers/StandardController.mjs +43 -42
- package/dist/controllers/StandardController.mjs.map +1 -1
- package/dist/controllers/UnknownOperatingContextController.d.ts +88 -0
- package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -0
- package/dist/controllers/UnknownOperatingContextController.mjs +275 -0
- package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -0
- package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
- package/dist/crypto/BrowserCrypto.mjs +3 -3
- package/dist/crypto/BrowserCrypto.mjs.map +1 -1
- package/dist/crypto/CryptoOps.d.ts.map +1 -1
- package/dist/crypto/CryptoOps.mjs +8 -5
- package/dist/crypto/CryptoOps.mjs.map +1 -1
- package/dist/crypto/PkceGenerator.mjs +1 -1
- package/dist/crypto/SignedHttpRequest.mjs +1 -1
- package/dist/encode/Base64Decode.mjs +1 -1
- package/dist/encode/Base64Encode.mjs +1 -1
- package/dist/error/BrowserAuthError.mjs +1 -1
- package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
- package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
- package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
- package/dist/error/NativeAuthError.mjs +1 -1
- package/dist/error/NativeAuthErrorCodes.mjs +1 -1
- package/dist/error/NestedAppAuthError.d.ts +15 -0
- package/dist/error/NestedAppAuthError.d.ts.map +1 -0
- package/dist/error/NestedAppAuthError.mjs +30 -0
- package/dist/error/NestedAppAuthError.mjs.map +1 -0
- package/dist/event/EventHandler.mjs +1 -1
- package/dist/event/EventMessage.mjs +1 -1
- package/dist/event/EventType.mjs +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +4 -2
- package/dist/index.mjs.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.mjs +4 -4
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.mjs +18 -7
- package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
- package/dist/interaction_client/PopupClient.d.ts +1 -2
- package/dist/interaction_client/PopupClient.d.ts.map +1 -1
- package/dist/interaction_client/PopupClient.mjs +13 -25
- package/dist/interaction_client/PopupClient.mjs.map +1 -1
- package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
- package/dist/interaction_client/RedirectClient.mjs +17 -25
- package/dist/interaction_client/RedirectClient.mjs.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.mjs +6 -8
- package/dist/interaction_client/SilentAuthCodeClient.mjs.map +1 -1
- package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentCacheClient.mjs +4 -3
- package/dist/interaction_client/SilentCacheClient.mjs.map +1 -1
- package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentIframeClient.mjs +28 -19
- package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.mjs +2 -12
- package/dist/interaction_client/SilentRefreshClient.mjs.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.mjs +5 -5
- package/dist/interaction_handler/InteractionHandler.d.ts +6 -13
- package/dist/interaction_handler/InteractionHandler.d.ts.map +1 -1
- package/dist/interaction_handler/InteractionHandler.mjs +29 -56
- package/dist/interaction_handler/InteractionHandler.mjs.map +1 -1
- package/dist/interaction_handler/RedirectHandler.d.ts +14 -7
- package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
- package/dist/interaction_handler/RedirectHandler.mjs +28 -9
- package/dist/interaction_handler/RedirectHandler.mjs.map +1 -1
- package/dist/interaction_handler/SilentHandler.d.ts +13 -47
- package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
- package/dist/interaction_handler/SilentHandler.mjs +120 -155
- package/dist/interaction_handler/SilentHandler.mjs.map +1 -1
- package/dist/naa/AccountInfo.d.ts +13 -0
- package/dist/naa/AccountInfo.d.ts.map +1 -0
- package/dist/naa/AccountRequests.d.ts +10 -0
- package/dist/naa/AccountRequests.d.ts.map +1 -0
- package/dist/naa/AuthBridge.d.ts +6 -0
- package/dist/naa/AuthBridge.d.ts.map +1 -0
- package/dist/naa/BridgeCapabilities.d.ts +4 -0
- package/dist/naa/BridgeCapabilities.d.ts.map +1 -0
- package/dist/naa/BridgeError.d.ts +10 -0
- package/dist/naa/BridgeError.d.ts.map +1 -0
- package/dist/naa/BridgeError.mjs +12 -0
- package/dist/naa/BridgeError.mjs.map +1 -0
- package/dist/naa/BridgeProxy.d.ts +72 -0
- package/dist/naa/BridgeProxy.d.ts.map +1 -0
- package/dist/naa/BridgeProxy.mjs +154 -0
- package/dist/naa/BridgeProxy.mjs.map +1 -0
- package/dist/naa/BridgeRequest.d.ts +7 -0
- package/dist/naa/BridgeRequest.d.ts.map +1 -0
- package/dist/naa/BridgeRequestEnvelope.d.ts +14 -0
- package/dist/naa/BridgeRequestEnvelope.d.ts.map +1 -0
- package/dist/naa/BridgeResponseEnvelope.d.ts +11 -0
- package/dist/naa/BridgeResponseEnvelope.d.ts.map +1 -0
- package/dist/naa/BridgeStatusCode.d.ts +11 -0
- package/dist/naa/BridgeStatusCode.d.ts.map +1 -0
- package/dist/naa/BridgeStatusCode.mjs +20 -0
- package/dist/naa/BridgeStatusCode.mjs.map +1 -0
- package/dist/naa/IBridgeProxy.d.ts +11 -0
- package/dist/naa/IBridgeProxy.d.ts.map +1 -0
- package/dist/naa/InitializeBridgeResponse.d.ts +7 -0
- package/dist/naa/InitializeBridgeResponse.d.ts.map +1 -0
- package/dist/naa/TokenRequest.d.ts +22 -0
- package/dist/naa/TokenRequest.d.ts.map +1 -0
- package/dist/naa/TokenResponse.d.ts +17 -0
- package/dist/naa/TokenResponse.d.ts.map +1 -0
- package/dist/naa/mapping/NestedAppAuthAdapter.d.ts +26 -0
- package/dist/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -0
- package/dist/naa/mapping/NestedAppAuthAdapter.mjs +178 -0
- package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +1 -0
- package/dist/navigation/NavigationClient.mjs +1 -1
- package/dist/network/FetchClient.mjs +1 -1
- package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
- package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
- package/dist/operatingcontext/TeamsAppOperatingContext.d.ts +7 -0
- package/dist/operatingcontext/TeamsAppOperatingContext.d.ts.map +1 -1
- package/dist/operatingcontext/TeamsAppOperatingContext.mjs +45 -4
- package/dist/operatingcontext/TeamsAppOperatingContext.mjs.map +1 -1
- package/dist/operatingcontext/UnknownOperatingContext.d.ts +26 -0
- package/dist/operatingcontext/UnknownOperatingContext.d.ts.map +1 -0
- package/dist/operatingcontext/UnknownOperatingContext.mjs +49 -0
- package/dist/operatingcontext/UnknownOperatingContext.mjs.map +1 -0
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
- package/dist/utils/BrowserConstants.mjs +1 -1
- package/dist/utils/BrowserProtocolUtils.mjs +1 -1
- package/dist/utils/BrowserUtils.d.ts +54 -53
- package/dist/utils/BrowserUtils.d.ts.map +1 -1
- package/dist/utils/BrowserUtils.mjs +114 -102
- package/dist/utils/BrowserUtils.mjs.map +1 -1
- package/lib/msal-browser.cjs +13221 -12385
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +13221 -12385
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +67 -68
- package/package.json +2 -2
- package/src/app/PublicClientApplication.ts +4 -3
- package/src/app/PublicClientNext.ts +444 -0
- package/src/cache/BrowserCacheManager.ts +33 -140
- package/src/cache/TokenCache.ts +5 -4
- package/src/config/Configuration.ts +5 -0
- package/src/controllers/ControllerFactory.ts +35 -43
- package/src/controllers/IController.ts +0 -6
- package/src/controllers/NestedAppAuthController.ts +525 -0
- package/src/controllers/StandardController.ts +50 -52
- package/src/controllers/UnknownOperatingContextController.ts +383 -0
- package/src/crypto/BrowserCrypto.ts +2 -2
- package/src/crypto/CryptoOps.ts +8 -5
- package/src/error/NestedAppAuthError.ts +32 -0
- package/src/index.ts +3 -10
- package/src/interaction_client/BaseInteractionClient.ts +1 -1
- package/src/interaction_client/NativeInteractionClient.ts +23 -6
- package/src/interaction_client/PopupClient.ts +41 -61
- package/src/interaction_client/RedirectClient.ts +42 -47
- package/src/interaction_client/SilentAuthCodeClient.ts +6 -16
- package/src/interaction_client/SilentCacheClient.ts +11 -3
- package/src/interaction_client/SilentIframeClient.ts +54 -34
- package/src/interaction_client/SilentRefreshClient.ts +5 -19
- package/src/interaction_client/StandardInteractionClient.ts +1 -1
- package/src/interaction_handler/InteractionHandler.ts +34 -104
- package/src/interaction_handler/RedirectHandler.ts +48 -22
- package/src/interaction_handler/SilentHandler.ts +177 -233
- package/src/naa/AccountInfo.ts +17 -0
- package/src/naa/AccountRequests.ts +16 -0
- package/src/naa/AuthBridge.ts +16 -0
- package/src/naa/BridgeCapabilities.ts +8 -0
- package/src/naa/BridgeError.ts +18 -0
- package/src/naa/BridgeProxy.ts +230 -0
- package/src/naa/BridgeRequest.ts +12 -0
- package/src/naa/BridgeRequestEnvelope.ts +46 -0
- package/src/naa/BridgeResponseEnvelope.ts +21 -0
- package/src/naa/BridgeStatusCode.ts +15 -0
- package/src/naa/IBridgeProxy.ts +25 -0
- package/src/naa/InitializeBridgeResponse.ts +12 -0
- package/src/naa/TokenRequest.ts +26 -0
- package/src/naa/TokenResponse.ts +61 -0
- package/src/naa/mapping/NestedAppAuthAdapter.ts +252 -0
- package/src/operatingcontext/TeamsAppOperatingContext.ts +43 -3
- package/src/operatingcontext/UnknownOperatingContext.ts +48 -0
- package/src/packageMetadata.ts +1 -1
- package/src/utils/BrowserUtils.ts +133 -125
- package/dist/utils/BrowserStringUtils.d.ts +0 -22
- package/dist/utils/BrowserStringUtils.d.ts.map +0 -1
- package/dist/utils/BrowserStringUtils.mjs +0 -144
- package/dist/utils/BrowserStringUtils.mjs.map +0 -1
- package/src/utils/BrowserStringUtils.ts +0 -143
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
/*! @azure/msal-browser v3.
|
|
1
|
+
/*! @azure/msal-browser v3.4.0 2023-10-30 */
|
|
2
2
|
'use strict';
|
|
3
|
-
import { PerformanceEvents,
|
|
3
|
+
import { PerformanceEvents, ServerError, invokeAsync, CcsCredentialType } from '@azure/msal-common';
|
|
4
4
|
import { createBrowserAuthError } from '../error/BrowserAuthError.mjs';
|
|
5
|
-
import { TemporaryCacheKeys } from '../utils/BrowserConstants.mjs';
|
|
6
5
|
import { hashEmptyError, userCancelled } from '../error/BrowserAuthErrorCodes.mjs';
|
|
7
6
|
|
|
8
7
|
/*
|
|
@@ -24,21 +23,15 @@ class InteractionHandler {
|
|
|
24
23
|
* Function to handle response parameters from hash.
|
|
25
24
|
* @param locationHash
|
|
26
25
|
*/
|
|
27
|
-
async handleCodeResponseFromHash(locationHash,
|
|
28
|
-
this.performanceClient.addQueueMeasurement(PerformanceEvents.HandleCodeResponseFromHash,
|
|
26
|
+
async handleCodeResponseFromHash(locationHash, request) {
|
|
27
|
+
this.performanceClient.addQueueMeasurement(PerformanceEvents.HandleCodeResponseFromHash, request.correlationId);
|
|
29
28
|
// Check that location hash isn't empty.
|
|
30
29
|
if (!locationHash) {
|
|
31
30
|
throw createBrowserAuthError(hashEmptyError);
|
|
32
31
|
}
|
|
33
|
-
// Handle code response.
|
|
34
|
-
const stateKey = this.browserStorage.generateStateKey(state);
|
|
35
|
-
const requestState = this.browserStorage.getTemporaryCache(stateKey);
|
|
36
|
-
if (!requestState) {
|
|
37
|
-
throw createClientAuthError(ClientAuthErrorCodes.stateNotFound, "Cached State");
|
|
38
|
-
}
|
|
39
32
|
let authCodeResponse;
|
|
40
33
|
try {
|
|
41
|
-
authCodeResponse = this.authModule.handleFragmentResponse(locationHash,
|
|
34
|
+
authCodeResponse = this.authModule.handleFragmentResponse(locationHash, request.state);
|
|
42
35
|
}
|
|
43
36
|
catch (e) {
|
|
44
37
|
if (e instanceof ServerError &&
|
|
@@ -50,7 +43,7 @@ class InteractionHandler {
|
|
|
50
43
|
throw e;
|
|
51
44
|
}
|
|
52
45
|
}
|
|
53
|
-
return invokeAsync(this.handleCodeResponseFromServer.bind(this), PerformanceEvents.HandleCodeResponseFromServer, this.logger, this.performanceClient,
|
|
46
|
+
return invokeAsync(this.handleCodeResponseFromServer.bind(this), PerformanceEvents.HandleCodeResponseFromServer, this.logger, this.performanceClient, request.correlationId)(authCodeResponse, request);
|
|
54
47
|
}
|
|
55
48
|
/**
|
|
56
49
|
* Process auth code response from AAD
|
|
@@ -60,70 +53,50 @@ class InteractionHandler {
|
|
|
60
53
|
* @param networkModule
|
|
61
54
|
* @returns
|
|
62
55
|
*/
|
|
63
|
-
async handleCodeResponseFromServer(authCodeResponse,
|
|
64
|
-
this.performanceClient.addQueueMeasurement(PerformanceEvents.HandleCodeResponseFromServer,
|
|
56
|
+
async handleCodeResponseFromServer(authCodeResponse, request, validateNonce = true) {
|
|
57
|
+
this.performanceClient.addQueueMeasurement(PerformanceEvents.HandleCodeResponseFromServer, request.correlationId);
|
|
65
58
|
this.logger.trace("InteractionHandler.handleCodeResponseFromServer called");
|
|
66
|
-
// Handle code response.
|
|
67
|
-
const stateKey = this.browserStorage.generateStateKey(state);
|
|
68
|
-
const requestState = this.browserStorage.getTemporaryCache(stateKey);
|
|
69
|
-
if (!requestState) {
|
|
70
|
-
throw createClientAuthError(ClientAuthErrorCodes.stateNotFound, "Cached State");
|
|
71
|
-
}
|
|
72
|
-
// Get cached items
|
|
73
|
-
const nonceKey = this.browserStorage.generateNonceKey(requestState);
|
|
74
|
-
const cachedNonce = this.browserStorage.getTemporaryCache(nonceKey);
|
|
75
59
|
// Assign code to request
|
|
76
60
|
this.authCodeRequest.code = authCodeResponse.code;
|
|
77
61
|
// Check for new cloud instance
|
|
78
62
|
if (authCodeResponse.cloud_instance_host_name) {
|
|
79
|
-
await invokeAsync(this.
|
|
63
|
+
await invokeAsync(this.authModule.updateAuthority.bind(this.authModule), PerformanceEvents.UpdateTokenEndpointAuthority, this.logger, this.performanceClient, request.correlationId)(authCodeResponse.cloud_instance_host_name, request.correlationId);
|
|
80
64
|
}
|
|
81
65
|
// Nonce validation not needed when redirect not involved (e.g. hybrid spa, renewing token via rt)
|
|
82
66
|
if (validateNonce) {
|
|
83
|
-
|
|
67
|
+
// TODO: Assigning "response nonce" to "request nonce" is confusing. Refactor the function doing validation to accept request nonce directly
|
|
68
|
+
authCodeResponse.nonce = request.nonce || undefined;
|
|
84
69
|
}
|
|
85
|
-
authCodeResponse.state =
|
|
70
|
+
authCodeResponse.state = request.state;
|
|
86
71
|
// Add CCS parameters if available
|
|
87
72
|
if (authCodeResponse.client_info) {
|
|
88
73
|
this.authCodeRequest.clientInfo = authCodeResponse.client_info;
|
|
89
74
|
}
|
|
90
75
|
else {
|
|
91
|
-
const
|
|
92
|
-
if (
|
|
93
|
-
this.authCodeRequest.ccsCredential =
|
|
76
|
+
const ccsCred = this.createCcsCredentials(request);
|
|
77
|
+
if (ccsCred) {
|
|
78
|
+
this.authCodeRequest.ccsCredential = ccsCred;
|
|
94
79
|
}
|
|
95
80
|
}
|
|
96
81
|
// Acquire token with retrieved code.
|
|
97
|
-
const tokenResponse = (await invokeAsync(this.authModule.acquireToken.bind(this.authModule), PerformanceEvents.AuthClientAcquireToken, this.logger, this.performanceClient,
|
|
98
|
-
this.browserStorage.cleanRequestByState(state);
|
|
82
|
+
const tokenResponse = (await invokeAsync(this.authModule.acquireToken.bind(this.authModule), PerformanceEvents.AuthClientAcquireToken, this.logger, this.performanceClient, request.correlationId)(this.authCodeRequest, authCodeResponse));
|
|
99
83
|
return tokenResponse;
|
|
100
84
|
}
|
|
101
85
|
/**
|
|
102
|
-
*
|
|
103
|
-
* @param cloudInstanceHostname
|
|
104
|
-
* @param authority
|
|
105
|
-
* @param networkModule
|
|
106
|
-
*/
|
|
107
|
-
async updateTokenEndpointAuthority(cloudInstanceHostname, authority, networkModule) {
|
|
108
|
-
this.performanceClient.addQueueMeasurement(PerformanceEvents.UpdateTokenEndpointAuthority, this.authCodeRequest.correlationId);
|
|
109
|
-
const cloudInstanceAuthorityUri = `https://${cloudInstanceHostname}/${authority.tenant}/`;
|
|
110
|
-
const cloudInstanceAuthority = await AuthorityFactory.createDiscoveredInstance(cloudInstanceAuthorityUri, networkModule, this.browserStorage, authority.options, this.logger, this.performanceClient, this.authCodeRequest.correlationId);
|
|
111
|
-
this.authModule.updateAuthority(cloudInstanceAuthority);
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Looks up ccs creds in the cache
|
|
86
|
+
* Build ccs creds if available
|
|
115
87
|
*/
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
88
|
+
createCcsCredentials(request) {
|
|
89
|
+
if (request.account) {
|
|
90
|
+
return {
|
|
91
|
+
credential: request.account.homeAccountId,
|
|
92
|
+
type: CcsCredentialType.HOME_ACCOUNT_ID,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
else if (request.loginHint) {
|
|
96
|
+
return {
|
|
97
|
+
credential: request.loginHint,
|
|
98
|
+
type: CcsCredentialType.UPN,
|
|
99
|
+
};
|
|
127
100
|
}
|
|
128
101
|
return null;
|
|
129
102
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InteractionHandler.mjs","sources":["../../src/interaction_handler/InteractionHandler.ts"],"sourcesContent":[null],"names":[
|
|
1
|
+
{"version":3,"file":"InteractionHandler.mjs","sources":["../../src/interaction_handler/InteractionHandler.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;AAKA;AAaA;AAKA;AACA;AAIG;AACH;AACI;AACA,MAAS,kBAAiB,CAAA;AAC1B,IAAA,WAAU,CAAA,cAAiB,EAAA,WAAA,EAAA,eAAA,EAA+B,MAAA,EAAA,iBAAA,EAAA;AAC1D,QAAA,IAAA,CAAS,UAAS,GAAA,cAAO,CAAA;AACzB,QAAA,IAAA,CAAS,cAAC,GAAA,WAAmB,CAAA;AAGzB,QAAA,IAAA,CAAA,eAAA,kBAAuC,CAAA;AAa3C,QAAA,IAAA,CAAA,MAAA,GAAA,MAAA,CAAA;;;AAGG;AACG;AA0CN;;;;;;;AAOG,SAAA;AACG,QAAA,IAAA,gBAAA,CAAA;AAwDN,QAAA,IAAA;;AAEG,SAAA;QACM;AAiBZ,YAAA,IAAA,CAAA,YAAA,WAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import { AuthorizationCodeClient, CommonAuthorizationCodeRequest,
|
|
1
|
+
import { AuthorizationCodeClient, CommonAuthorizationCodeRequest, Logger, IPerformanceClient, CcsCredential } from "@azure/msal-common";
|
|
2
2
|
import { BrowserCacheManager } from "../cache/BrowserCacheManager";
|
|
3
|
-
import { InteractionHandler, InteractionParams } from "./InteractionHandler";
|
|
4
3
|
import { INavigationClient } from "../navigation/INavigationClient";
|
|
5
4
|
import { AuthenticationResult } from "../response/AuthenticationResult";
|
|
6
|
-
export type RedirectParams =
|
|
5
|
+
export type RedirectParams = {
|
|
7
6
|
navigationClient: INavigationClient;
|
|
8
7
|
redirectTimeout: number;
|
|
9
8
|
redirectStartPage: string;
|
|
10
9
|
onRedirectNavigate?: (url: string) => void | boolean;
|
|
11
10
|
};
|
|
12
|
-
export declare class RedirectHandler
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
export declare class RedirectHandler {
|
|
12
|
+
authModule: AuthorizationCodeClient;
|
|
13
|
+
browserStorage: BrowserCacheManager;
|
|
14
|
+
authCodeRequest: CommonAuthorizationCodeRequest;
|
|
15
|
+
logger: Logger;
|
|
16
|
+
performanceClient: IPerformanceClient;
|
|
17
|
+
constructor(authCodeModule: AuthorizationCodeClient, storageImpl: BrowserCacheManager, authCodeRequest: CommonAuthorizationCodeRequest, logger: Logger, performanceClient: IPerformanceClient);
|
|
15
18
|
/**
|
|
16
19
|
* Redirects window to given URL.
|
|
17
20
|
* @param urlNavigate
|
|
@@ -21,6 +24,10 @@ export declare class RedirectHandler extends InteractionHandler {
|
|
|
21
24
|
* Handle authorization code response in the window.
|
|
22
25
|
* @param hash
|
|
23
26
|
*/
|
|
24
|
-
handleCodeResponseFromHash(locationHash: string, state: string
|
|
27
|
+
handleCodeResponseFromHash(locationHash: string, state: string): Promise<AuthenticationResult>;
|
|
28
|
+
/**
|
|
29
|
+
* Looks up ccs creds in the cache
|
|
30
|
+
*/
|
|
31
|
+
protected checkCcsCredentials(): CcsCredential | null;
|
|
25
32
|
}
|
|
26
33
|
//# sourceMappingURL=RedirectHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RedirectHandler.d.ts","sourceRoot":"","sources":["../../src/interaction_handler/RedirectHandler.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,uBAAuB,EACvB,8BAA8B,EAC9B,
|
|
1
|
+
{"version":3,"file":"RedirectHandler.d.ts","sourceRoot":"","sources":["../../src/interaction_handler/RedirectHandler.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,uBAAuB,EACvB,8BAA8B,EAC9B,MAAM,EAEN,kBAAkB,EAGlB,aAAa,EAGhB,MAAM,oBAAoB,CAAC;AAM5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AAEpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAExE,MAAM,MAAM,cAAc,GAAG;IACzB,gBAAgB,EAAE,iBAAiB,CAAC;IACpC,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC;CACxD,CAAC;AAEF,qBAAa,eAAe;IACxB,UAAU,EAAE,uBAAuB,CAAC;IACpC,cAAc,EAAE,mBAAmB,CAAC;IACpC,eAAe,EAAE,8BAA8B,CAAC;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,kBAAkB,CAAC;gBAGlC,cAAc,EAAE,uBAAuB,EACvC,WAAW,EAAE,mBAAmB,EAChC,eAAe,EAAE,8BAA8B,EAC/C,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,kBAAkB;IASzC;;;OAGG;IACG,mBAAmB,CACrB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,cAAc,GACvB,OAAO,CAAC,IAAI,CAAC;IA6EhB;;;OAGG;IACG,0BAA0B,CAC5B,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,MAAM,GACd,OAAO,CAAC,oBAAoB,CAAC;IAqFhC;;OAEG;IACH,SAAS,CAAC,mBAAmB,IAAI,aAAa,GAAG,IAAI;CAoBxD"}
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
/*! @azure/msal-browser v3.
|
|
1
|
+
/*! @azure/msal-browser v3.4.0 2023-10-30 */
|
|
2
2
|
'use strict';
|
|
3
|
-
import { createClientAuthError, ClientAuthErrorCodes, ServerError } from '@azure/msal-common';
|
|
3
|
+
import { createClientAuthError, ClientAuthErrorCodes, ServerError, invokeAsync, PerformanceEvents } from '@azure/msal-common';
|
|
4
4
|
import { createBrowserAuthError } from '../error/BrowserAuthError.mjs';
|
|
5
5
|
import { TemporaryCacheKeys, ApiId } from '../utils/BrowserConstants.mjs';
|
|
6
|
-
import { InteractionHandler } from './InteractionHandler.mjs';
|
|
7
6
|
import { emptyNavigateUri, hashEmptyError, userCancelled } from '../error/BrowserAuthErrorCodes.mjs';
|
|
8
7
|
|
|
9
8
|
/*
|
|
10
9
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11
10
|
* Licensed under the MIT License.
|
|
12
11
|
*/
|
|
13
|
-
class RedirectHandler
|
|
14
|
-
constructor(authCodeModule, storageImpl, authCodeRequest, logger,
|
|
15
|
-
|
|
16
|
-
this.
|
|
12
|
+
class RedirectHandler {
|
|
13
|
+
constructor(authCodeModule, storageImpl, authCodeRequest, logger, performanceClient) {
|
|
14
|
+
this.authModule = authCodeModule;
|
|
15
|
+
this.browserStorage = storageImpl;
|
|
16
|
+
this.authCodeRequest = authCodeRequest;
|
|
17
|
+
this.logger = logger;
|
|
18
|
+
this.performanceClient = performanceClient;
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
19
21
|
* Redirects window to given URL.
|
|
@@ -69,7 +71,7 @@ class RedirectHandler extends InteractionHandler {
|
|
|
69
71
|
* Handle authorization code response in the window.
|
|
70
72
|
* @param hash
|
|
71
73
|
*/
|
|
72
|
-
async handleCodeResponseFromHash(locationHash, state
|
|
74
|
+
async handleCodeResponseFromHash(locationHash, state) {
|
|
73
75
|
this.logger.verbose("RedirectHandler.handleCodeResponse called");
|
|
74
76
|
// Check that location hash isn't empty.
|
|
75
77
|
if (!locationHash) {
|
|
@@ -104,7 +106,7 @@ class RedirectHandler extends InteractionHandler {
|
|
|
104
106
|
this.authCodeRequest.code = authCodeResponse.code;
|
|
105
107
|
// Check for new cloud instance
|
|
106
108
|
if (authCodeResponse.cloud_instance_host_name) {
|
|
107
|
-
await this.
|
|
109
|
+
await invokeAsync(this.authModule.updateAuthority.bind(this.authModule), PerformanceEvents.UpdateTokenEndpointAuthority, this.logger, this.performanceClient, this.authCodeRequest.correlationId)(authCodeResponse.cloud_instance_host_name, this.authCodeRequest.correlationId);
|
|
108
110
|
}
|
|
109
111
|
authCodeResponse.nonce = cachedNonce || undefined;
|
|
110
112
|
authCodeResponse.state = requestState;
|
|
@@ -123,6 +125,23 @@ class RedirectHandler extends InteractionHandler {
|
|
|
123
125
|
this.browserStorage.cleanRequestByState(state);
|
|
124
126
|
return tokenResponse;
|
|
125
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Looks up ccs creds in the cache
|
|
130
|
+
*/
|
|
131
|
+
checkCcsCredentials() {
|
|
132
|
+
// Look up ccs credential in temp cache
|
|
133
|
+
const cachedCcsCred = this.browserStorage.getTemporaryCache(TemporaryCacheKeys.CCS_CREDENTIAL, true);
|
|
134
|
+
if (cachedCcsCred) {
|
|
135
|
+
try {
|
|
136
|
+
return JSON.parse(cachedCcsCred);
|
|
137
|
+
}
|
|
138
|
+
catch (e) {
|
|
139
|
+
this.authModule.logger.error("Cache credential could not be parsed");
|
|
140
|
+
this.authModule.logger.errorPii(`Cache credential could not be parsed: ${cachedCcsCred}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
126
145
|
}
|
|
127
146
|
|
|
128
147
|
export { RedirectHandler };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RedirectHandler.mjs","sources":["../../src/interaction_handler/RedirectHandler.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RedirectHandler.mjs","sources":["../../src/interaction_handler/RedirectHandler.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAKA;AAiBA;AACA;AAEA;AAKqB,MAAA,gBAAQ;IACzB,WAAkB,CAAA,cAAO,aAAa,EAAA,eAAe,EAAA,MAAA,EAAA,iBAAA,EAAA;QACvD,IAAA,CAAA,UAAA,GAAA,cAAA,CAAA;AAEF,QAAA,IAAA,CAAA,cAA4B,GAAA,WAAA,CAAA;QACd,IAAA,CAAA,iCAA0B,CAAA;QACtB,IAAA,CAAA,MAAA;QACC,IAAA,CAAA,sCAAgC;KACzC;;AAIF;AAaJ;;;AAGG,QAAA,IAAA,CAAA,MAAA,CAAA,OAAA,CAAA,4CAAA,CAAA,CAAA;AACG;AAgFN,QAAA,IAAA,UAAA,EAAA;;;AAGG,gBAAA,IAAA,CAAA,MAAA,CAAA,OAAA,CAAA,gFAAA,CAAA,CAAA;AACG,gBAAA,IAAA,CAAA,cACF,CAAA,iBACA,CAAA,kBACD,CAAA,UAAQ,EAAA,MAAA,CAAA,iBAAqB,EAAA,IAAA,CAAA,CAAA;AAqFhC,aAAA;;AAEG,YAAA,IAAA,CAAA,cAAA,CAAA,iBAAA,CAAA,kBAAA,CAAA,cAAA,EAAA,IAAA,CAAA,eAAA,CAAA,aAAA,EAAA,IAAA,CAAA,CAAA;AACH,YAAA,IAAU,CAAA,cAAA,CAAA,gBAAuB,CAAA,IAAgB,CAAI,eAAA,CAAA,CAAA;AAoBxD,YAAA,IAAA,CAAA,MAAA,CAAA,OAAA,CAAA,CAAA,kDAAA,EAAA,UAAA,CAAA,CAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,48 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
initiateAuthRequest(requestUrl: string): Promise<HTMLIFrameElement>;
|
|
15
|
-
/**
|
|
16
|
-
* Monitors an iframe content window until it loads a url with a known hash, or hits a specified timeout.
|
|
17
|
-
* @param iframe
|
|
18
|
-
* @param timeout
|
|
19
|
-
*/
|
|
20
|
-
monitorIframeForHash(iframe: HTMLIFrameElement, timeout: number): Promise<string>;
|
|
21
|
-
/**
|
|
22
|
-
* @hidden
|
|
23
|
-
* Loads iframe with authorization endpoint URL
|
|
24
|
-
* @ignore
|
|
25
|
-
*/
|
|
26
|
-
private loadFrame;
|
|
27
|
-
/**
|
|
28
|
-
* @hidden
|
|
29
|
-
* Loads the iframe synchronously when the navigateTimeFrame is set to `0`
|
|
30
|
-
* @param urlNavigate
|
|
31
|
-
* @param frameName
|
|
32
|
-
* @param logger
|
|
33
|
-
*/
|
|
34
|
-
private loadFrameSync;
|
|
35
|
-
/**
|
|
36
|
-
* @hidden
|
|
37
|
-
* Creates a new hidden iframe or gets an existing one for silent token renewal.
|
|
38
|
-
* @ignore
|
|
39
|
-
*/
|
|
40
|
-
private createHiddenIframe;
|
|
41
|
-
/**
|
|
42
|
-
* @hidden
|
|
43
|
-
* Removes a hidden iframe from the page.
|
|
44
|
-
* @ignore
|
|
45
|
-
*/
|
|
46
|
-
private removeHiddenIframe;
|
|
47
|
-
}
|
|
1
|
+
import { Logger, IPerformanceClient } from "@azure/msal-common";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a hidden iframe to given URL using user-requested scopes as an id.
|
|
4
|
+
* @param urlNavigate
|
|
5
|
+
* @param userRequestScopes
|
|
6
|
+
*/
|
|
7
|
+
export declare function initiateAuthRequest(requestUrl: string, performanceClient: IPerformanceClient, logger: Logger, correlationId: string, navigateFrameWait?: number): Promise<HTMLIFrameElement>;
|
|
8
|
+
/**
|
|
9
|
+
* Monitors an iframe content window until it loads a url with a known hash, or hits a specified timeout.
|
|
10
|
+
* @param iframe
|
|
11
|
+
* @param timeout
|
|
12
|
+
*/
|
|
13
|
+
export declare function monitorIframeForHash(iframe: HTMLIFrameElement, timeout: number, pollIntervalMilliseconds: number, performanceClient: IPerformanceClient, logger: Logger, correlationId: string): Promise<string>;
|
|
48
14
|
//# sourceMappingURL=SilentHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SilentHandler.d.ts","sourceRoot":"","sources":["../../src/interaction_handler/SilentHandler.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"SilentHandler.d.ts","sourceRoot":"","sources":["../../src/interaction_handler/SilentHandler.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,MAAM,EACN,kBAAkB,EAIrB,MAAM,oBAAoB,CAAC;AAO5B;;;;GAIG;AACH,wBAAsB,mBAAmB,CACrC,UAAU,EAAE,MAAM,EAClB,iBAAiB,EAAE,kBAAkB,EACrC,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,iBAAiB,CAAC,EAAE,MAAM,GAC3B,OAAO,CAAC,iBAAiB,CAAC,CA2B5B;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACtC,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,MAAM,EACf,wBAAwB,EAAE,MAAM,EAChC,iBAAiB,EAAE,kBAAkB,EACrC,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,GACtB,OAAO,CAAC,MAAM,CAAC,CA0DjB"}
|
|
@@ -1,172 +1,137 @@
|
|
|
1
|
-
/*! @azure/msal-browser v3.
|
|
1
|
+
/*! @azure/msal-browser v3.4.0 2023-10-30 */
|
|
2
2
|
'use strict';
|
|
3
|
-
import { PerformanceEvents, invokeAsync,
|
|
4
|
-
import { InteractionHandler } from './InteractionHandler.mjs';
|
|
3
|
+
import { PerformanceEvents, invokeAsync, invoke } from '@azure/msal-common';
|
|
5
4
|
import { createBrowserAuthError } from '../error/BrowserAuthError.mjs';
|
|
6
5
|
import { DEFAULT_IFRAME_TIMEOUT_MS } from '../config/Configuration.mjs';
|
|
7
|
-
import { emptyNavigateUri, monitorWindowTimeout
|
|
6
|
+
import { emptyNavigateUri, monitorWindowTimeout } from '../error/BrowserAuthErrorCodes.mjs';
|
|
8
7
|
|
|
9
8
|
/*
|
|
10
9
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
11
10
|
* Licensed under the MIT License.
|
|
12
11
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
async initiateAuthRequest(requestUrl) {
|
|
25
|
-
this.performanceClient.addQueueMeasurement(PerformanceEvents.SilentHandlerInitiateAuthRequest, this.authCodeRequest.correlationId);
|
|
26
|
-
if (!requestUrl) {
|
|
27
|
-
// Throw error if request URL is empty.
|
|
28
|
-
this.logger.info("Navigate url is empty");
|
|
29
|
-
throw createBrowserAuthError(emptyNavigateUri);
|
|
30
|
-
}
|
|
31
|
-
if (this.navigateFrameWait) {
|
|
32
|
-
return await invokeAsync(this.loadFrame.bind(this), PerformanceEvents.SilentHandlerLoadFrame, this.logger, this.performanceClient, this.authCodeRequest.correlationId)(requestUrl);
|
|
33
|
-
}
|
|
34
|
-
return this.loadFrameSync(requestUrl);
|
|
12
|
+
/**
|
|
13
|
+
* Creates a hidden iframe to given URL using user-requested scopes as an id.
|
|
14
|
+
* @param urlNavigate
|
|
15
|
+
* @param userRequestScopes
|
|
16
|
+
*/
|
|
17
|
+
async function initiateAuthRequest(requestUrl, performanceClient, logger, correlationId, navigateFrameWait) {
|
|
18
|
+
performanceClient.addQueueMeasurement(PerformanceEvents.SilentHandlerInitiateAuthRequest, correlationId);
|
|
19
|
+
if (!requestUrl) {
|
|
20
|
+
// Throw error if request URL is empty.
|
|
21
|
+
logger.info("Navigate url is empty");
|
|
22
|
+
throw createBrowserAuthError(emptyNavigateUri);
|
|
35
23
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
* @param iframe
|
|
39
|
-
* @param timeout
|
|
40
|
-
*/
|
|
41
|
-
monitorIframeForHash(iframe, timeout) {
|
|
42
|
-
this.performanceClient.addQueueMeasurement(PerformanceEvents.SilentHandlerMonitorIframeForHash, this.authCodeRequest.correlationId);
|
|
43
|
-
return new Promise((resolve, reject) => {
|
|
44
|
-
if (timeout < DEFAULT_IFRAME_TIMEOUT_MS) {
|
|
45
|
-
this.logger.warning(`system.loadFrameTimeout or system.iframeHashTimeout set to lower (${timeout}ms) than the default (${DEFAULT_IFRAME_TIMEOUT_MS}ms). This may result in timeouts.`);
|
|
46
|
-
}
|
|
47
|
-
/*
|
|
48
|
-
* Polling for iframes can be purely timing based,
|
|
49
|
-
* since we don't need to account for interaction.
|
|
50
|
-
*/
|
|
51
|
-
const nowMark = window.performance.now();
|
|
52
|
-
const timeoutMark = nowMark + timeout;
|
|
53
|
-
const intervalId = setInterval(() => {
|
|
54
|
-
if (window.performance.now() > timeoutMark) {
|
|
55
|
-
this.removeHiddenIframe(iframe);
|
|
56
|
-
clearInterval(intervalId);
|
|
57
|
-
reject(createBrowserAuthError(monitorWindowTimeout));
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
let href = Constants.EMPTY_STRING;
|
|
61
|
-
const contentWindow = iframe.contentWindow;
|
|
62
|
-
try {
|
|
63
|
-
/*
|
|
64
|
-
* Will throw if cross origin,
|
|
65
|
-
* which should be caught and ignored
|
|
66
|
-
* since we need the interval to keep running while on STS UI.
|
|
67
|
-
*/
|
|
68
|
-
href = contentWindow
|
|
69
|
-
? contentWindow.location.href
|
|
70
|
-
: Constants.EMPTY_STRING;
|
|
71
|
-
}
|
|
72
|
-
catch (e) { }
|
|
73
|
-
if (!href || href === "about:blank") {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
const contentHash = contentWindow
|
|
77
|
-
? contentWindow.location.hash
|
|
78
|
-
: Constants.EMPTY_STRING;
|
|
79
|
-
if (contentHash) {
|
|
80
|
-
if (UrlString.hashContainsKnownProperties(contentHash)) {
|
|
81
|
-
// Success case
|
|
82
|
-
this.removeHiddenIframe(iframe);
|
|
83
|
-
clearInterval(intervalId);
|
|
84
|
-
resolve(contentHash);
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
// Hash is present but incorrect
|
|
89
|
-
this.logger.error("SilentHandler:monitorIFrameForHash - a hash is present in the iframe but it does not contain known properties. It's likely that the hash has been replaced by code running on the redirectUri page.");
|
|
90
|
-
this.logger.errorPii(`SilentHandler:monitorIFrameForHash - the url detected in the iframe is: ${href}`);
|
|
91
|
-
this.removeHiddenIframe(iframe);
|
|
92
|
-
clearInterval(intervalId);
|
|
93
|
-
reject(createBrowserAuthError(hashDoesNotContainKnownProperties));
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
// No hash is present
|
|
99
|
-
this.logger.error("SilentHandler:monitorIFrameForHash - the request has returned to the redirectUri but a hash is not present in the iframe. It's likely that the hash has been removed or the page has been redirected by code running on the redirectUri page.");
|
|
100
|
-
this.logger.errorPii(`SilentHandler:monitorIFrameForHash - the url detected in the iframe is: ${href}`);
|
|
101
|
-
this.removeHiddenIframe(iframe);
|
|
102
|
-
clearInterval(intervalId);
|
|
103
|
-
reject(createBrowserAuthError(hashEmptyError));
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
}, this.pollIntervalMilliseconds);
|
|
107
|
-
});
|
|
24
|
+
if (navigateFrameWait) {
|
|
25
|
+
return await invokeAsync(loadFrame, PerformanceEvents.SilentHandlerLoadFrame, logger, performanceClient, correlationId)(requestUrl, navigateFrameWait, performanceClient, correlationId);
|
|
108
26
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
27
|
+
return invoke(loadFrameSync, PerformanceEvents.SilentHandlerLoadFrameSync, logger, performanceClient, correlationId)(requestUrl);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Monitors an iframe content window until it loads a url with a known hash, or hits a specified timeout.
|
|
31
|
+
* @param iframe
|
|
32
|
+
* @param timeout
|
|
33
|
+
*/
|
|
34
|
+
async function monitorIframeForHash(iframe, timeout, pollIntervalMilliseconds, performanceClient, logger, correlationId) {
|
|
35
|
+
performanceClient.addQueueMeasurement(PerformanceEvents.SilentHandlerMonitorIframeForHash, correlationId);
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
if (timeout < DEFAULT_IFRAME_TIMEOUT_MS) {
|
|
38
|
+
logger.warning(`system.loadFrameTimeout or system.iframeHashTimeout set to lower (${timeout}ms) than the default (${DEFAULT_IFRAME_TIMEOUT_MS}ms). This may result in timeouts.`);
|
|
39
|
+
}
|
|
116
40
|
/*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
41
|
+
* Polling for iframes can be purely timing based,
|
|
42
|
+
* since we don't need to account for interaction.
|
|
119
43
|
*/
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
*
|
|
161
|
-
* Removes a hidden iframe from the page.
|
|
162
|
-
* @ignore
|
|
44
|
+
const timeoutId = window.setTimeout(() => {
|
|
45
|
+
window.clearInterval(intervalId);
|
|
46
|
+
reject(createBrowserAuthError(monitorWindowTimeout));
|
|
47
|
+
}, timeout);
|
|
48
|
+
const intervalId = window.setInterval(() => {
|
|
49
|
+
let href = "";
|
|
50
|
+
const contentWindow = iframe.contentWindow;
|
|
51
|
+
try {
|
|
52
|
+
/*
|
|
53
|
+
* Will throw if cross origin,
|
|
54
|
+
* which should be caught and ignored
|
|
55
|
+
* since we need the interval to keep running while on STS UI.
|
|
56
|
+
*/
|
|
57
|
+
href = contentWindow ? contentWindow.location.href : "";
|
|
58
|
+
}
|
|
59
|
+
catch (e) { }
|
|
60
|
+
if (!href || href === "about:blank") {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const contentHash = contentWindow
|
|
64
|
+
? contentWindow.location.hash
|
|
65
|
+
: "";
|
|
66
|
+
window.clearTimeout(timeoutId);
|
|
67
|
+
window.clearInterval(intervalId);
|
|
68
|
+
resolve(contentHash);
|
|
69
|
+
}, pollIntervalMilliseconds);
|
|
70
|
+
}).finally(() => {
|
|
71
|
+
invoke(removeHiddenIframe, PerformanceEvents.RemoveHiddenIframe, logger, performanceClient, correlationId)(iframe);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* @hidden
|
|
76
|
+
* Loads iframe with authorization endpoint URL
|
|
77
|
+
* @ignore
|
|
78
|
+
* @deprecated
|
|
79
|
+
*/
|
|
80
|
+
function loadFrame(urlNavigate, navigateFrameWait, performanceClient, correlationId) {
|
|
81
|
+
performanceClient.addQueueMeasurement(PerformanceEvents.SilentHandlerLoadFrame, correlationId);
|
|
82
|
+
/*
|
|
83
|
+
* This trick overcomes iframe navigation in IE
|
|
84
|
+
* IE does not load the page consistently in iframe
|
|
163
85
|
*/
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
86
|
+
return new Promise((resolve, reject) => {
|
|
87
|
+
const frameHandle = createHiddenIframe();
|
|
88
|
+
window.setTimeout(() => {
|
|
89
|
+
if (!frameHandle) {
|
|
90
|
+
reject("Unable to load iframe");
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
frameHandle.src = urlNavigate;
|
|
94
|
+
resolve(frameHandle);
|
|
95
|
+
}, navigateFrameWait);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* @hidden
|
|
100
|
+
* Loads the iframe synchronously when the navigateTimeFrame is set to `0`
|
|
101
|
+
* @param urlNavigate
|
|
102
|
+
* @param frameName
|
|
103
|
+
* @param logger
|
|
104
|
+
*/
|
|
105
|
+
function loadFrameSync(urlNavigate) {
|
|
106
|
+
const frameHandle = createHiddenIframe();
|
|
107
|
+
frameHandle.src = urlNavigate;
|
|
108
|
+
return frameHandle;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* @hidden
|
|
112
|
+
* Creates a new hidden iframe or gets an existing one for silent token renewal.
|
|
113
|
+
* @ignore
|
|
114
|
+
*/
|
|
115
|
+
function createHiddenIframe() {
|
|
116
|
+
const authFrame = document.createElement("iframe");
|
|
117
|
+
authFrame.style.visibility = "hidden";
|
|
118
|
+
authFrame.style.position = "absolute";
|
|
119
|
+
authFrame.style.width = authFrame.style.height = "0";
|
|
120
|
+
authFrame.style.border = "0";
|
|
121
|
+
authFrame.setAttribute("sandbox", "allow-scripts allow-same-origin allow-forms");
|
|
122
|
+
document.getElementsByTagName("body")[0].appendChild(authFrame);
|
|
123
|
+
return authFrame;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* @hidden
|
|
127
|
+
* Removes a hidden iframe from the page.
|
|
128
|
+
* @ignore
|
|
129
|
+
*/
|
|
130
|
+
function removeHiddenIframe(iframe) {
|
|
131
|
+
if (document.body === iframe.parentNode) {
|
|
132
|
+
document.body.removeChild(iframe);
|
|
168
133
|
}
|
|
169
134
|
}
|
|
170
135
|
|
|
171
|
-
export {
|
|
136
|
+
export { initiateAuthRequest, monitorIframeForHash };
|
|
172
137
|
//# sourceMappingURL=SilentHandler.mjs.map
|