@azure/msal-browser 3.2.0 → 3.3.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.mjs +2 -2
- 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 +362 -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 +7 -64
- 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.mjs +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 -1
- package/dist/controllers/ControllerFactory.d.ts.map +1 -1
- package/dist/controllers/ControllerFactory.mjs +26 -19
- package/dist/controllers/ControllerFactory.mjs.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.map +1 -1
- package/dist/controllers/StandardController.mjs +16 -13
- 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 +15 -4
- package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
- package/dist/interaction_client/PopupClient.d.ts.map +1 -1
- package/dist/interaction_client/PopupClient.mjs +5 -4
- package/dist/interaction_client/PopupClient.mjs.map +1 -1
- package/dist/interaction_client/RedirectClient.mjs +7 -7
- package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.mjs +4 -4
- 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 +27 -13
- package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
- package/dist/interaction_client/StandardInteractionClient.mjs +5 -5
- package/dist/interaction_handler/InteractionHandler.mjs +1 -1
- package/dist/interaction_handler/RedirectHandler.mjs +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 +61 -17728
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +14625 -13223
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +66 -68
- package/package.json +2 -2
- package/src/app/PublicClientApplication.ts +1 -1
- package/src/app/PublicClientNext.ts +442 -0
- package/src/cache/BrowserCacheManager.ts +11 -100
- package/src/config/Configuration.ts +5 -0
- package/src/controllers/ControllerFactory.ts +36 -25
- package/src/controllers/NestedAppAuthController.ts +525 -0
- package/src/controllers/StandardController.ts +8 -6
- 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 +19 -3
- package/src/interaction_client/PopupClient.ts +2 -1
- package/src/interaction_client/RedirectClient.ts +1 -1
- package/src/interaction_client/SilentAuthCodeClient.ts +5 -4
- package/src/interaction_client/SilentCacheClient.ts +11 -3
- package/src/interaction_client/SilentIframeClient.ts +53 -17
- package/src/interaction_client/StandardInteractionClient.ts +1 -1
- 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,172 +1,137 @@
|
|
|
1
|
-
/*! @azure/msal-browser v3.
|
|
1
|
+
/*! @azure/msal-browser v3.3.0 2023-10-20 */
|
|
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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SilentHandler.mjs","sources":["../../src/interaction_handler/SilentHandler.ts"],"sourcesContent":[null],"names":[
|
|
1
|
+
{"version":3,"file":"SilentHandler.mjs","sources":["../../src/interaction_handler/SilentHandler.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;AAKA;AAaA;;;AAwCA;;;;AAIG;AACH,eAAA,mBAA0C,CAAA,UAChC,EAAmB,iBAAA,EAClB,MAAA,EAAE,aACe,EAAA,iBAAA,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type AccountInfo = {
|
|
2
|
+
homeAccountId: string;
|
|
3
|
+
environment: string;
|
|
4
|
+
tenantId: string;
|
|
5
|
+
username: string;
|
|
6
|
+
localAccountId: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
idToken?: string;
|
|
9
|
+
platformBrokerId?: string;
|
|
10
|
+
idTokenClaims?: object;
|
|
11
|
+
client_info?: string;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=AccountInfo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountInfo.d.ts","sourceRoot":"","sources":["../../src/naa/AccountInfo.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,WAAW,GAAG;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountRequests.d.ts","sourceRoot":"","sources":["../../src/naa/AccountRequests.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,sBAAsB,GAAG;IACjC,aAAa,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IAClC,cAAc,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACnC,QAAQ,EAAE,MAAM,CAAC;CACpB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export interface AuthBridge {
|
|
2
|
+
addEventListener: (eventName: string, callback: (response: string) => void) => void;
|
|
3
|
+
postMessage: (message: string) => void;
|
|
4
|
+
removeEventListener: (eventName: string, callback: (response: string) => void) => void;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=AuthBridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthBridge.d.ts","sourceRoot":"","sources":["../../src/naa/AuthBridge.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,UAAU;IACvB,gBAAgB,EAAE,CACd,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,KACnC,IAAI,CAAC;IACV,WAAW,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,mBAAmB,EAAE,CACjB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,KACnC,IAAI,CAAC;CACb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BridgeCapabilities.d.ts","sourceRoot":"","sources":["../../src/naa/BridgeCapabilities.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,kBAAkB;IAC/B,YAAY,EAAE,OAAO,CAAC;CACzB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BridgeStatusCode } from "./BridgeStatusCode";
|
|
2
|
+
export type BridgeError = {
|
|
3
|
+
status: BridgeStatusCode;
|
|
4
|
+
code: string;
|
|
5
|
+
subError: string;
|
|
6
|
+
description: string;
|
|
7
|
+
properties: object;
|
|
8
|
+
};
|
|
9
|
+
export declare function isBridgeError(error: unknown): error is BridgeError;
|
|
10
|
+
//# sourceMappingURL=BridgeError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BridgeError.d.ts","sourceRoot":"","sources":["../../src/naa/BridgeError.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,MAAM,MAAM,WAAW,GAAG;IACtB,MAAM,EAAE,gBAAgB,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*! @azure/msal-browser v3.3.0 2023-10-20 */
|
|
2
|
+
'use strict';
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5
|
+
* Licensed under the MIT License.
|
|
6
|
+
*/
|
|
7
|
+
function isBridgeError(error) {
|
|
8
|
+
return error.status !== undefined;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { isBridgeError };
|
|
12
|
+
//# sourceMappingURL=BridgeError.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BridgeError.mjs","sources":["../../src/naa/BridgeError.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAKA;AAEA;;;AAGY,sBAAS,CAAA,KAAA,EAAA;IACjB,OAAW,KAAA,CAAE,MAAM,KAAC,SAAA,CAAA;;;;;"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { AccountInfo } from "./AccountInfo";
|
|
2
|
+
import { AccountByHomeIdRequest, AccountByLocalIdRequest, AccountByUsernameRequest } from "./AccountRequests";
|
|
3
|
+
import { AuthBridge } from "./AuthBridge";
|
|
4
|
+
import { BridgeCapabilities } from "./BridgeCapabilities";
|
|
5
|
+
import { IBridgeProxy } from "./IBridgeProxy";
|
|
6
|
+
import { InitializeBridgeResponse } from "./InitializeBridgeResponse";
|
|
7
|
+
import { TokenRequest } from "./TokenRequest";
|
|
8
|
+
import { TokenResponse } from "./TokenResponse";
|
|
9
|
+
declare global {
|
|
10
|
+
interface Window {
|
|
11
|
+
nestedAppAuthBridge: AuthBridge;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* BridgeProxy
|
|
16
|
+
* Provides a proxy for accessing a bridge to a host app and/or
|
|
17
|
+
* platform broker
|
|
18
|
+
*/
|
|
19
|
+
export declare class BridgeProxy implements IBridgeProxy {
|
|
20
|
+
static bridgeRequests: any[];
|
|
21
|
+
static crypto: Crypto;
|
|
22
|
+
sdkName: string;
|
|
23
|
+
sdkVersion: string;
|
|
24
|
+
capabilities: BridgeCapabilities;
|
|
25
|
+
/**
|
|
26
|
+
* initializeNestedAppAuthBridge - Initializes the bridge to the host app
|
|
27
|
+
* @returns a promise that resolves to an InitializeBridgeResponse or rejects with an Error
|
|
28
|
+
* @remarks This method will be called by the create factory method
|
|
29
|
+
* @remarks If the bridge is not available, this method will throw an error
|
|
30
|
+
*/
|
|
31
|
+
protected static initializeNestedAppAuthBridge(): Promise<InitializeBridgeResponse>;
|
|
32
|
+
static getRandomId(): string;
|
|
33
|
+
/**
|
|
34
|
+
* getTokenInteractive - Attempts to get a token interactively from the bridge
|
|
35
|
+
* @param request A token request
|
|
36
|
+
* @returns a promise that resolves to a token response or rejects with a BridgeError
|
|
37
|
+
*/
|
|
38
|
+
getTokenInteractive(request: TokenRequest): Promise<TokenResponse>;
|
|
39
|
+
/**
|
|
40
|
+
* getTokenSilent Attempts to get a token silently from the bridge
|
|
41
|
+
* @param request A token request
|
|
42
|
+
* @returns a promise that resolves to a token response or rejects with a BridgeError
|
|
43
|
+
*/
|
|
44
|
+
getTokenSilent(request: TokenRequest): Promise<TokenResponse>;
|
|
45
|
+
/**
|
|
46
|
+
* getAccountInfo - Gets account information from the bridge
|
|
47
|
+
*
|
|
48
|
+
* @param request A request for account information
|
|
49
|
+
*/
|
|
50
|
+
getAccountInfo(request: AccountByHomeIdRequest | AccountByLocalIdRequest | AccountByUsernameRequest): Promise<AccountInfo>;
|
|
51
|
+
getActiveAccount(): Promise<AccountInfo>;
|
|
52
|
+
/**
|
|
53
|
+
* A method used to send a request to the bridge
|
|
54
|
+
* @param request A token request
|
|
55
|
+
* @returns a promise that resolves to a response of provided type or rejects with a BridgeError
|
|
56
|
+
*/
|
|
57
|
+
private sendRequest;
|
|
58
|
+
/**
|
|
59
|
+
* Private constructor for BridgeProxy
|
|
60
|
+
* @param sdkName The name of the SDK being used to make requests on behalf of the app
|
|
61
|
+
* @param sdkVersion The version of the SDK being used to make requests on behalf of the app
|
|
62
|
+
* @param capabilities The capabilities of the bridge / SDK / platform broker
|
|
63
|
+
*/
|
|
64
|
+
private constructor();
|
|
65
|
+
/**
|
|
66
|
+
* Factory method for creating an implementation of IBridgeProxy
|
|
67
|
+
* @returns A promise that resolves to a BridgeProxy implementation
|
|
68
|
+
*/
|
|
69
|
+
static create(): Promise<IBridgeProxy>;
|
|
70
|
+
}
|
|
71
|
+
export default BridgeProxy;
|
|
72
|
+
//# sourceMappingURL=BridgeProxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BridgeProxy.d.ts","sourceRoot":"","sources":["../../src/naa/BridgeProxy.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACH,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAI1D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,mBAAmB,EAAE,UAAU,CAAC;KACnC;CACJ;AAED;;;;GAIG;AACH,qBAAa,WAAY,YAAW,YAAY;IAE5C,MAAM,CAAC,cAAc,EAAE,GAAG,EAAE,CAAM;IAClC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,kBAAkB,CAAC;IAEjC;;;;;OAKG;qBACoB,6BAA6B,IAAI,OAAO,CAAC,wBAAwB,CAAC;WAgE3E,WAAW,IAAI,MAAM;IAInC;;;;OAIG;IACI,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;IAIzE;;;;OAIG;IACI,cAAc,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,aAAa,CAAC;IAIpE;;;;OAIG;IACI,cAAc,CACjB,OAAO,EACD,sBAAsB,GACtB,uBAAuB,GACvB,wBAAwB,GAC/B,OAAO,CAAC,WAAW,CAAC;IAkBhB,gBAAgB,IAAI,OAAO,CAAC,WAAW,CAAC;IAI/C;;;;OAIG;IACH,OAAO,CAAC,WAAW;IA8BnB;;;;;OAKG;IACH,OAAO;IAUP;;;OAGG;WACiB,MAAM,IAAI,OAAO,CAAC,YAAY,CAAC;CAQtD;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/*! @azure/msal-browser v3.3.0 2023-10-20 */
|
|
2
|
+
'use strict';
|
|
3
|
+
/*
|
|
4
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
5
|
+
* Licensed under the MIT License.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* BridgeProxy
|
|
9
|
+
* Provides a proxy for accessing a bridge to a host app and/or
|
|
10
|
+
* platform broker
|
|
11
|
+
*/
|
|
12
|
+
class BridgeProxy {
|
|
13
|
+
/**
|
|
14
|
+
* initializeNestedAppAuthBridge - Initializes the bridge to the host app
|
|
15
|
+
* @returns a promise that resolves to an InitializeBridgeResponse or rejects with an Error
|
|
16
|
+
* @remarks This method will be called by the create factory method
|
|
17
|
+
* @remarks If the bridge is not available, this method will throw an error
|
|
18
|
+
*/
|
|
19
|
+
static async initializeNestedAppAuthBridge() {
|
|
20
|
+
if (window === undefined) {
|
|
21
|
+
throw new Error("window is undefined");
|
|
22
|
+
}
|
|
23
|
+
if (window.nestedAppAuthBridge === undefined) {
|
|
24
|
+
throw new Error("window.nestedAppAuthBridge is undefined");
|
|
25
|
+
}
|
|
26
|
+
if (window.crypto === undefined) {
|
|
27
|
+
throw new Error("window.crypto is undefined");
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
BridgeProxy.crypto = window.crypto;
|
|
31
|
+
window.nestedAppAuthBridge.addEventListener("message", (response) => {
|
|
32
|
+
const responseEnvelope = JSON.parse(response);
|
|
33
|
+
const request = BridgeProxy.bridgeRequests.find((element) => element.requestId === responseEnvelope.requestId);
|
|
34
|
+
if (request !== undefined) {
|
|
35
|
+
BridgeProxy.bridgeRequests.splice(BridgeProxy.bridgeRequests.indexOf(request), 1);
|
|
36
|
+
if (responseEnvelope.success) {
|
|
37
|
+
request.resolve(responseEnvelope.body);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
request.reject(responseEnvelope.body);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
const promise = new Promise((resolve, reject) => {
|
|
45
|
+
const message = {
|
|
46
|
+
messageType: "NestedAppAuthRequest",
|
|
47
|
+
method: "GetInitContext",
|
|
48
|
+
requestId: BridgeProxy.getRandomId(),
|
|
49
|
+
};
|
|
50
|
+
const request = {
|
|
51
|
+
requestId: message.requestId,
|
|
52
|
+
method: message.method,
|
|
53
|
+
resolve: resolve,
|
|
54
|
+
reject: reject,
|
|
55
|
+
};
|
|
56
|
+
BridgeProxy.bridgeRequests.push(request);
|
|
57
|
+
window.nestedAppAuthBridge.postMessage(JSON.stringify(message));
|
|
58
|
+
});
|
|
59
|
+
return promise;
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
window.console.log(error);
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
static getRandomId() {
|
|
67
|
+
return BridgeProxy.crypto.randomUUID();
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* getTokenInteractive - Attempts to get a token interactively from the bridge
|
|
71
|
+
* @param request A token request
|
|
72
|
+
* @returns a promise that resolves to a token response or rejects with a BridgeError
|
|
73
|
+
*/
|
|
74
|
+
getTokenInteractive(request) {
|
|
75
|
+
return this.sendRequest("GetTokenPopup", request);
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* getTokenSilent Attempts to get a token silently from the bridge
|
|
79
|
+
* @param request A token request
|
|
80
|
+
* @returns a promise that resolves to a token response or rejects with a BridgeError
|
|
81
|
+
*/
|
|
82
|
+
getTokenSilent(request) {
|
|
83
|
+
return this.sendRequest("GetToken", request);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* getAccountInfo - Gets account information from the bridge
|
|
87
|
+
*
|
|
88
|
+
* @param request A request for account information
|
|
89
|
+
*/
|
|
90
|
+
getAccountInfo(request) {
|
|
91
|
+
let method = "GetAccountByHomeId";
|
|
92
|
+
if (request.homeAccountId !== undefined) {
|
|
93
|
+
method = "GetAccountByHomeId";
|
|
94
|
+
}
|
|
95
|
+
if (request.localAccountId !== undefined) {
|
|
96
|
+
method = "GetAccountByLocalId";
|
|
97
|
+
}
|
|
98
|
+
if (request.username !== undefined) {
|
|
99
|
+
method = "GetAccountByUsername";
|
|
100
|
+
}
|
|
101
|
+
return this.sendRequest(method, request);
|
|
102
|
+
}
|
|
103
|
+
getActiveAccount() {
|
|
104
|
+
return this.sendRequest("GetActiveAccount", undefined);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* A method used to send a request to the bridge
|
|
108
|
+
* @param request A token request
|
|
109
|
+
* @returns a promise that resolves to a response of provided type or rejects with a BridgeError
|
|
110
|
+
*/
|
|
111
|
+
sendRequest(method, request) {
|
|
112
|
+
const message = {
|
|
113
|
+
messageType: "NestedAppAuthRequest",
|
|
114
|
+
method: method,
|
|
115
|
+
requestId: BridgeProxy.getRandomId(),
|
|
116
|
+
body: request,
|
|
117
|
+
};
|
|
118
|
+
const promise = new Promise((resolve, reject) => {
|
|
119
|
+
const request = {
|
|
120
|
+
requestId: message.requestId,
|
|
121
|
+
method: message.method,
|
|
122
|
+
resolve: resolve,
|
|
123
|
+
reject: reject,
|
|
124
|
+
};
|
|
125
|
+
BridgeProxy.bridgeRequests.push(request);
|
|
126
|
+
window.nestedAppAuthBridge.postMessage(JSON.stringify(message));
|
|
127
|
+
});
|
|
128
|
+
return promise;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Private constructor for BridgeProxy
|
|
132
|
+
* @param sdkName The name of the SDK being used to make requests on behalf of the app
|
|
133
|
+
* @param sdkVersion The version of the SDK being used to make requests on behalf of the app
|
|
134
|
+
* @param capabilities The capabilities of the bridge / SDK / platform broker
|
|
135
|
+
*/
|
|
136
|
+
constructor(sdkName, sdkVersion, capabilities) {
|
|
137
|
+
this.sdkName = sdkName;
|
|
138
|
+
this.sdkVersion = sdkVersion;
|
|
139
|
+
this.capabilities = capabilities;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Factory method for creating an implementation of IBridgeProxy
|
|
143
|
+
* @returns A promise that resolves to a BridgeProxy implementation
|
|
144
|
+
*/
|
|
145
|
+
static async create() {
|
|
146
|
+
const response = await BridgeProxy.initializeNestedAppAuthBridge();
|
|
147
|
+
return new BridgeProxy(response.sdkName, response.sdkVersion, response.capabilities);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
151
|
+
BridgeProxy.bridgeRequests = [];
|
|
152
|
+
|
|
153
|
+
export { BridgeProxy, BridgeProxy as default };
|
|
154
|
+
//# sourceMappingURL=BridgeProxy.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BridgeProxy.mjs","sources":["../../src/naa/BridgeProxy.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAKA;AACA;AAKA;AACA;AAIA;AACA;AACA;AACA;AAEA;AACI,MAAA,WAAgB,CAAA;;AAEf;AACJ;AAED;;;;AAIG,QAAA,IAAA,MAAA,KAAA,SAAA,EAAA;AACH,YAAa,MAAA,IAAA,KAAA,CAAA,qBAAmC,CAAA,CAAA;AAE5C,SAAA;AACA,QAAA,IAAO,MAAQ,CAAA,mBAAO,KAAA,SAAA,EAAA;YACf,UAAS,KAAA,CAAA,yCAAA,CAAA,CAAA;SACN;QACE,IAAA,MAAE,qBAAmB,EAAA;AAEjC,YAAA,MAAA,IAAA,KAAA,CAAA,4BAAA,CAAA,CAAA;;;;;AAKG,gBAAA,MAAA,gBAAA,GAAA,IAAA,CAAA,KAAA,CAAA,QAAA,CAAA,CAAA;AACoB,gBAAA,MAAA,OAAA,GAAA,WAAA,CAAA,cAAiC,CAAA,IAAQ,CAAA,CAAA,OAAA,KAAA,OAAA,CAAA,SAAyB,KAAA,gBAAA,CAAA,SAAA,CAAA,CAAA;AAgE3E,gBAAA,IAAA,OAAqB,KAAA,SAAA,EAAA;AAInC,oBAAA,WAAA,CAAA,cAAA,CAAA,MAAA,CAAA,WAAA,CAAA,cAAA,CAAA,OAAA,CAAA,OAAA,CAAA,EAAA,CAAA,CAAA,CAAA;;;;AAIG,yBAAA;wBACwB,OAAO,CAAE,MAAA,CAAA,gBAAsB,CAAC;AAI3D,qBAAA;;;;AAIG,gBAAA,MAAA,OAAA,GAAA;+BAC4B,EAAA;AAI/B,oBAAA,MAAA,EAAA,gBAAA;;;;AAIG,oBAAA,SAAA,EAAA,OAAA,CAAA,SAAA;AACI,oBACH,MAAO,EACD,OAAA,CAAA,MAAA;AAqBH,oBAAgB,OAAI,EAAA,OAAQ;AAInC,oBAAA,MAAA,EAAA,MAAA;;;;AAIG,aAAA,CAAA,CAAA;AACH,YAAQ,OAAW,OAAA,CAAA;AA8BnB,SAAA;;;;;AAKG,KAAA;IACH,OAAO,WAAA,GAAA;AAUP,QAAA,OAAA,WAAA,CAAA,MAAA,CAAA,UAAA,EAAA,CAAA;;;AAGG;AACiB;AAQvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BridgeRequest.d.ts","sourceRoot":"","sources":["../../src/naa/BridgeRequest.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,aAAa,CAAC,SAAS,IAAI;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC;IAE7D,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;CAClC,CAAC"}
|