@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
|
@@ -4,266 +4,210 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
|
-
UrlString,
|
|
8
|
-
CommonAuthorizationCodeRequest,
|
|
9
|
-
AuthorizationCodeClient,
|
|
10
|
-
Constants,
|
|
11
7
|
Logger,
|
|
12
8
|
IPerformanceClient,
|
|
13
9
|
PerformanceEvents,
|
|
14
10
|
invokeAsync,
|
|
11
|
+
invoke,
|
|
15
12
|
} from "@azure/msal-common";
|
|
16
|
-
import { InteractionHandler } from "./InteractionHandler";
|
|
17
13
|
import {
|
|
18
14
|
createBrowserAuthError,
|
|
19
15
|
BrowserAuthErrorCodes,
|
|
20
16
|
} from "../error/BrowserAuthError";
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
BrowserSystemOptions,
|
|
24
|
-
DEFAULT_IFRAME_TIMEOUT_MS,
|
|
25
|
-
} from "../config/Configuration";
|
|
26
|
-
|
|
27
|
-
export class SilentHandler extends InteractionHandler {
|
|
28
|
-
private navigateFrameWait: number;
|
|
29
|
-
private pollIntervalMilliseconds: number;
|
|
17
|
+
import { DEFAULT_IFRAME_TIMEOUT_MS } from "../config/Configuration";
|
|
30
18
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Creates a hidden iframe to given URL using user-requested scopes as an id.
|
|
21
|
+
* @param urlNavigate
|
|
22
|
+
* @param userRequestScopes
|
|
23
|
+
*/
|
|
24
|
+
export async function initiateAuthRequest(
|
|
25
|
+
requestUrl: string,
|
|
26
|
+
performanceClient: IPerformanceClient,
|
|
27
|
+
logger: Logger,
|
|
28
|
+
correlationId: string,
|
|
29
|
+
navigateFrameWait?: number
|
|
30
|
+
): Promise<HTMLIFrameElement> {
|
|
31
|
+
performanceClient.addQueueMeasurement(
|
|
32
|
+
PerformanceEvents.SilentHandlerInitiateAuthRequest,
|
|
33
|
+
correlationId
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
if (!requestUrl) {
|
|
37
|
+
// Throw error if request URL is empty.
|
|
38
|
+
logger.info("Navigate url is empty");
|
|
39
|
+
throw createBrowserAuthError(BrowserAuthErrorCodes.emptyNavigateUri);
|
|
40
|
+
}
|
|
41
|
+
if (navigateFrameWait) {
|
|
42
|
+
return await invokeAsync(
|
|
43
|
+
loadFrame,
|
|
44
|
+
PerformanceEvents.SilentHandlerLoadFrame,
|
|
48
45
|
logger,
|
|
49
|
-
performanceClient
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
this.pollIntervalMilliseconds = systemOptions.pollIntervalMilliseconds;
|
|
46
|
+
performanceClient,
|
|
47
|
+
correlationId
|
|
48
|
+
)(requestUrl, navigateFrameWait, performanceClient, correlationId);
|
|
53
49
|
}
|
|
50
|
+
return invoke(
|
|
51
|
+
loadFrameSync,
|
|
52
|
+
PerformanceEvents.SilentHandlerLoadFrameSync,
|
|
53
|
+
logger,
|
|
54
|
+
performanceClient,
|
|
55
|
+
correlationId
|
|
56
|
+
)(requestUrl);
|
|
57
|
+
}
|
|
54
58
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
59
|
+
/**
|
|
60
|
+
* Monitors an iframe content window until it loads a url with a known hash, or hits a specified timeout.
|
|
61
|
+
* @param iframe
|
|
62
|
+
* @param timeout
|
|
63
|
+
*/
|
|
64
|
+
export async function monitorIframeForHash(
|
|
65
|
+
iframe: HTMLIFrameElement,
|
|
66
|
+
timeout: number,
|
|
67
|
+
pollIntervalMilliseconds: number,
|
|
68
|
+
performanceClient: IPerformanceClient,
|
|
69
|
+
logger: Logger,
|
|
70
|
+
correlationId: string
|
|
71
|
+
): Promise<string> {
|
|
72
|
+
performanceClient.addQueueMeasurement(
|
|
73
|
+
PerformanceEvents.SilentHandlerMonitorIframeForHash,
|
|
74
|
+
correlationId
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
return new Promise<string>((resolve, reject) => {
|
|
78
|
+
if (timeout < DEFAULT_IFRAME_TIMEOUT_MS) {
|
|
79
|
+
logger.warning(
|
|
80
|
+
`system.loadFrameTimeout or system.iframeHashTimeout set to lower (${timeout}ms) than the default (${DEFAULT_IFRAME_TIMEOUT_MS}ms). This may result in timeouts.`
|
|
71
81
|
);
|
|
72
82
|
}
|
|
73
83
|
|
|
74
|
-
if (this.navigateFrameWait) {
|
|
75
|
-
return await invokeAsync(
|
|
76
|
-
this.loadFrame.bind(this),
|
|
77
|
-
PerformanceEvents.SilentHandlerLoadFrame,
|
|
78
|
-
this.logger,
|
|
79
|
-
this.performanceClient,
|
|
80
|
-
this.authCodeRequest.correlationId
|
|
81
|
-
)(requestUrl);
|
|
82
|
-
}
|
|
83
|
-
return this.loadFrameSync(requestUrl);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Monitors an iframe content window until it loads a url with a known hash, or hits a specified timeout.
|
|
88
|
-
* @param iframe
|
|
89
|
-
* @param timeout
|
|
90
|
-
*/
|
|
91
|
-
monitorIframeForHash(
|
|
92
|
-
iframe: HTMLIFrameElement,
|
|
93
|
-
timeout: number
|
|
94
|
-
): Promise<string> {
|
|
95
|
-
this.performanceClient.addQueueMeasurement(
|
|
96
|
-
PerformanceEvents.SilentHandlerMonitorIframeForHash,
|
|
97
|
-
this.authCodeRequest.correlationId
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
return new Promise((resolve, reject) => {
|
|
101
|
-
if (timeout < DEFAULT_IFRAME_TIMEOUT_MS) {
|
|
102
|
-
this.logger.warning(
|
|
103
|
-
`system.loadFrameTimeout or system.iframeHashTimeout set to lower (${timeout}ms) than the default (${DEFAULT_IFRAME_TIMEOUT_MS}ms). This may result in timeouts.`
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/*
|
|
108
|
-
* Polling for iframes can be purely timing based,
|
|
109
|
-
* since we don't need to account for interaction.
|
|
110
|
-
*/
|
|
111
|
-
const nowMark = window.performance.now();
|
|
112
|
-
const timeoutMark = nowMark + timeout;
|
|
113
|
-
|
|
114
|
-
const intervalId = setInterval(() => {
|
|
115
|
-
if (window.performance.now() > timeoutMark) {
|
|
116
|
-
this.removeHiddenIframe(iframe);
|
|
117
|
-
clearInterval(intervalId);
|
|
118
|
-
reject(
|
|
119
|
-
createBrowserAuthError(
|
|
120
|
-
BrowserAuthErrorCodes.monitorWindowTimeout
|
|
121
|
-
)
|
|
122
|
-
);
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
let href: string = Constants.EMPTY_STRING;
|
|
127
|
-
const contentWindow = iframe.contentWindow;
|
|
128
|
-
try {
|
|
129
|
-
/*
|
|
130
|
-
* Will throw if cross origin,
|
|
131
|
-
* which should be caught and ignored
|
|
132
|
-
* since we need the interval to keep running while on STS UI.
|
|
133
|
-
*/
|
|
134
|
-
href = contentWindow
|
|
135
|
-
? contentWindow.location.href
|
|
136
|
-
: Constants.EMPTY_STRING;
|
|
137
|
-
} catch (e) {}
|
|
138
|
-
|
|
139
|
-
if (!href || href === "about:blank") {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const contentHash = contentWindow
|
|
144
|
-
? contentWindow.location.hash
|
|
145
|
-
: Constants.EMPTY_STRING;
|
|
146
|
-
if (contentHash) {
|
|
147
|
-
if (UrlString.hashContainsKnownProperties(contentHash)) {
|
|
148
|
-
// Success case
|
|
149
|
-
this.removeHiddenIframe(iframe);
|
|
150
|
-
clearInterval(intervalId);
|
|
151
|
-
resolve(contentHash);
|
|
152
|
-
return;
|
|
153
|
-
} else {
|
|
154
|
-
// Hash is present but incorrect
|
|
155
|
-
this.logger.error(
|
|
156
|
-
"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."
|
|
157
|
-
);
|
|
158
|
-
this.logger.errorPii(
|
|
159
|
-
`SilentHandler:monitorIFrameForHash - the url detected in the iframe is: ${href}`
|
|
160
|
-
);
|
|
161
|
-
this.removeHiddenIframe(iframe);
|
|
162
|
-
clearInterval(intervalId);
|
|
163
|
-
reject(
|
|
164
|
-
createBrowserAuthError(
|
|
165
|
-
BrowserAuthErrorCodes.hashDoesNotContainKnownProperties
|
|
166
|
-
)
|
|
167
|
-
);
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
} else {
|
|
171
|
-
// No hash is present
|
|
172
|
-
this.logger.error(
|
|
173
|
-
"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."
|
|
174
|
-
);
|
|
175
|
-
this.logger.errorPii(
|
|
176
|
-
`SilentHandler:monitorIFrameForHash - the url detected in the iframe is: ${href}`
|
|
177
|
-
);
|
|
178
|
-
this.removeHiddenIframe(iframe);
|
|
179
|
-
clearInterval(intervalId);
|
|
180
|
-
reject(
|
|
181
|
-
createBrowserAuthError(
|
|
182
|
-
BrowserAuthErrorCodes.hashEmptyError
|
|
183
|
-
)
|
|
184
|
-
);
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
}, this.pollIntervalMilliseconds);
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* @hidden
|
|
193
|
-
* Loads iframe with authorization endpoint URL
|
|
194
|
-
* @ignore
|
|
195
|
-
*/
|
|
196
|
-
private loadFrame(urlNavigate: string): Promise<HTMLIFrameElement> {
|
|
197
|
-
this.performanceClient.addQueueMeasurement(
|
|
198
|
-
PerformanceEvents.SilentHandlerLoadFrame,
|
|
199
|
-
this.authCodeRequest.correlationId
|
|
200
|
-
);
|
|
201
|
-
|
|
202
84
|
/*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
85
|
+
* Polling for iframes can be purely timing based,
|
|
86
|
+
* since we don't need to account for interaction.
|
|
205
87
|
*/
|
|
88
|
+
const timeoutId = window.setTimeout(() => {
|
|
89
|
+
window.clearInterval(intervalId);
|
|
90
|
+
reject(
|
|
91
|
+
createBrowserAuthError(
|
|
92
|
+
BrowserAuthErrorCodes.monitorWindowTimeout
|
|
93
|
+
)
|
|
94
|
+
);
|
|
95
|
+
}, timeout);
|
|
96
|
+
|
|
97
|
+
const intervalId = window.setInterval(() => {
|
|
98
|
+
let href: string = "";
|
|
99
|
+
const contentWindow = iframe.contentWindow;
|
|
100
|
+
try {
|
|
101
|
+
/*
|
|
102
|
+
* Will throw if cross origin,
|
|
103
|
+
* which should be caught and ignored
|
|
104
|
+
* since we need the interval to keep running while on STS UI.
|
|
105
|
+
*/
|
|
106
|
+
href = contentWindow ? contentWindow.location.href : "";
|
|
107
|
+
} catch (e) {}
|
|
108
|
+
|
|
109
|
+
if (!href || href === "about:blank") {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
206
112
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
113
|
+
const contentHash = contentWindow
|
|
114
|
+
? contentWindow.location.hash
|
|
115
|
+
: "";
|
|
116
|
+
window.clearTimeout(timeoutId);
|
|
117
|
+
window.clearInterval(intervalId);
|
|
118
|
+
resolve(contentHash);
|
|
119
|
+
}, pollIntervalMilliseconds);
|
|
120
|
+
}).finally(() => {
|
|
121
|
+
invoke(
|
|
122
|
+
removeHiddenIframe,
|
|
123
|
+
PerformanceEvents.RemoveHiddenIframe,
|
|
124
|
+
logger,
|
|
125
|
+
performanceClient,
|
|
126
|
+
correlationId
|
|
127
|
+
)(iframe);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
215
130
|
|
|
216
|
-
|
|
131
|
+
/**
|
|
132
|
+
* @hidden
|
|
133
|
+
* Loads iframe with authorization endpoint URL
|
|
134
|
+
* @ignore
|
|
135
|
+
* @deprecated
|
|
136
|
+
*/
|
|
137
|
+
function loadFrame(
|
|
138
|
+
urlNavigate: string,
|
|
139
|
+
navigateFrameWait: number,
|
|
140
|
+
performanceClient: IPerformanceClient,
|
|
141
|
+
correlationId: string
|
|
142
|
+
): Promise<HTMLIFrameElement> {
|
|
143
|
+
performanceClient.addQueueMeasurement(
|
|
144
|
+
PerformanceEvents.SilentHandlerLoadFrame,
|
|
145
|
+
correlationId
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
/*
|
|
149
|
+
* This trick overcomes iframe navigation in IE
|
|
150
|
+
* IE does not load the page consistently in iframe
|
|
151
|
+
*/
|
|
217
152
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
});
|
|
221
|
-
}
|
|
153
|
+
return new Promise((resolve, reject) => {
|
|
154
|
+
const frameHandle = createHiddenIframe();
|
|
222
155
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
* @param logger
|
|
229
|
-
*/
|
|
230
|
-
private loadFrameSync(urlNavigate: string): HTMLIFrameElement {
|
|
231
|
-
const frameHandle = this.createHiddenIframe();
|
|
156
|
+
window.setTimeout(() => {
|
|
157
|
+
if (!frameHandle) {
|
|
158
|
+
reject("Unable to load iframe");
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
232
161
|
|
|
233
|
-
|
|
162
|
+
frameHandle.src = urlNavigate;
|
|
234
163
|
|
|
235
|
-
|
|
236
|
-
|
|
164
|
+
resolve(frameHandle);
|
|
165
|
+
}, navigateFrameWait);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* @hidden
|
|
170
|
+
* Loads the iframe synchronously when the navigateTimeFrame is set to `0`
|
|
171
|
+
* @param urlNavigate
|
|
172
|
+
* @param frameName
|
|
173
|
+
* @param logger
|
|
174
|
+
*/
|
|
175
|
+
function loadFrameSync(urlNavigate: string): HTMLIFrameElement {
|
|
176
|
+
const frameHandle = createHiddenIframe();
|
|
237
177
|
|
|
238
|
-
|
|
239
|
-
* @hidden
|
|
240
|
-
* Creates a new hidden iframe or gets an existing one for silent token renewal.
|
|
241
|
-
* @ignore
|
|
242
|
-
*/
|
|
243
|
-
private createHiddenIframe(): HTMLIFrameElement {
|
|
244
|
-
const authFrame = document.createElement("iframe");
|
|
178
|
+
frameHandle.src = urlNavigate;
|
|
245
179
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
authFrame.style.width = authFrame.style.height = "0";
|
|
249
|
-
authFrame.style.border = "0";
|
|
250
|
-
authFrame.setAttribute(
|
|
251
|
-
"sandbox",
|
|
252
|
-
"allow-scripts allow-same-origin allow-forms"
|
|
253
|
-
);
|
|
254
|
-
document.getElementsByTagName("body")[0].appendChild(authFrame);
|
|
180
|
+
return frameHandle;
|
|
181
|
+
}
|
|
255
182
|
|
|
256
|
-
|
|
257
|
-
|
|
183
|
+
/**
|
|
184
|
+
* @hidden
|
|
185
|
+
* Creates a new hidden iframe or gets an existing one for silent token renewal.
|
|
186
|
+
* @ignore
|
|
187
|
+
*/
|
|
188
|
+
function createHiddenIframe(): HTMLIFrameElement {
|
|
189
|
+
const authFrame = document.createElement("iframe");
|
|
190
|
+
|
|
191
|
+
authFrame.style.visibility = "hidden";
|
|
192
|
+
authFrame.style.position = "absolute";
|
|
193
|
+
authFrame.style.width = authFrame.style.height = "0";
|
|
194
|
+
authFrame.style.border = "0";
|
|
195
|
+
authFrame.setAttribute(
|
|
196
|
+
"sandbox",
|
|
197
|
+
"allow-scripts allow-same-origin allow-forms"
|
|
198
|
+
);
|
|
199
|
+
document.getElementsByTagName("body")[0].appendChild(authFrame);
|
|
200
|
+
|
|
201
|
+
return authFrame;
|
|
202
|
+
}
|
|
258
203
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
}
|
|
204
|
+
/**
|
|
205
|
+
* @hidden
|
|
206
|
+
* Removes a hidden iframe from the page.
|
|
207
|
+
* @ignore
|
|
208
|
+
*/
|
|
209
|
+
function removeHiddenIframe(iframe: HTMLIFrameElement): void {
|
|
210
|
+
if (document.body === iframe.parentNode) {
|
|
211
|
+
document.body.removeChild(iframe);
|
|
268
212
|
}
|
|
269
213
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type AccountInfo = {
|
|
7
|
+
homeAccountId: string;
|
|
8
|
+
environment: string;
|
|
9
|
+
tenantId: string;
|
|
10
|
+
username: string;
|
|
11
|
+
localAccountId: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
idToken?: string; // idTokenClaims can be parsed from idToken in MSAL.js
|
|
14
|
+
platformBrokerId?: string; // Used by WAM previous called nativeAccountId
|
|
15
|
+
idTokenClaims?: object;
|
|
16
|
+
client_info?: string;
|
|
17
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export type AccountByHomeIdRequest = {
|
|
7
|
+
homeAccountId: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type AccountByLocalIdRequest = {
|
|
11
|
+
localAccountId: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type AccountByUsernameRequest = {
|
|
15
|
+
username: string;
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export interface AuthBridge {
|
|
7
|
+
addEventListener: (
|
|
8
|
+
eventName: string,
|
|
9
|
+
callback: (response: string) => void
|
|
10
|
+
) => void;
|
|
11
|
+
postMessage: (message: string) => void;
|
|
12
|
+
removeEventListener: (
|
|
13
|
+
eventName: string,
|
|
14
|
+
callback: (response: string) => void
|
|
15
|
+
) => void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { BridgeStatusCode } from "./BridgeStatusCode";
|
|
7
|
+
|
|
8
|
+
export type BridgeError = {
|
|
9
|
+
status: BridgeStatusCode;
|
|
10
|
+
code: string; // auth_flow_last_error such as invalid_grant
|
|
11
|
+
subError: string; // server_suberror_code such as consent_required
|
|
12
|
+
description: string;
|
|
13
|
+
properties: object; // additional telemetry info
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export function isBridgeError(error: unknown): error is BridgeError {
|
|
17
|
+
return (error as BridgeError).status !== undefined;
|
|
18
|
+
}
|