@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
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
CommonAuthorizationUrlRequest,
|
|
8
|
+
CommonSilentFlowRequest,
|
|
9
|
+
PerformanceCallbackFunction,
|
|
10
|
+
AccountInfo,
|
|
11
|
+
Logger,
|
|
12
|
+
ICrypto,
|
|
13
|
+
IPerformanceClient,
|
|
14
|
+
DEFAULT_CRYPTO_IMPLEMENTATION,
|
|
15
|
+
PerformanceEvents,
|
|
16
|
+
AccountFilter,
|
|
17
|
+
} from "@azure/msal-common";
|
|
18
|
+
import { ITokenCache } from "../cache/ITokenCache";
|
|
19
|
+
import { BrowserConfiguration } from "../config/Configuration";
|
|
20
|
+
import { INavigationClient } from "../navigation/INavigationClient";
|
|
21
|
+
import { AuthorizationCodeRequest } from "../request/AuthorizationCodeRequest";
|
|
22
|
+
import { EndSessionPopupRequest } from "../request/EndSessionPopupRequest";
|
|
23
|
+
import { EndSessionRequest } from "../request/EndSessionRequest";
|
|
24
|
+
import { PopupRequest } from "../request/PopupRequest";
|
|
25
|
+
import { RedirectRequest } from "../request/RedirectRequest";
|
|
26
|
+
import { SilentRequest } from "../request/SilentRequest";
|
|
27
|
+
import { SsoSilentRequest } from "../request/SsoSilentRequest";
|
|
28
|
+
import { ApiId, WrapperSKU, InteractionType } from "../utils/BrowserConstants";
|
|
29
|
+
import { IController } from "./IController";
|
|
30
|
+
import { TeamsAppOperatingContext } from "../operatingcontext/TeamsAppOperatingContext";
|
|
31
|
+
import { IBridgeProxy } from "../naa/IBridgeProxy";
|
|
32
|
+
import { CryptoOps } from "../crypto/CryptoOps";
|
|
33
|
+
import { NestedAppAuthAdapter } from "../naa/mapping/NestedAppAuthAdapter";
|
|
34
|
+
import { NestedAppAuthError } from "../error/NestedAppAuthError";
|
|
35
|
+
import { EventHandler } from "../event/EventHandler";
|
|
36
|
+
import { EventType } from "../event/EventType";
|
|
37
|
+
import { EventCallbackFunction, EventError } from "../event/EventMessage";
|
|
38
|
+
import { AuthenticationResult } from "../response/AuthenticationResult";
|
|
39
|
+
import { BrowserCacheManager } from "../cache/BrowserCacheManager";
|
|
40
|
+
import { ClearCacheRequest } from "../request/ClearCacheRequest";
|
|
41
|
+
|
|
42
|
+
export class NestedAppAuthController implements IController {
|
|
43
|
+
// OperatingContext
|
|
44
|
+
protected readonly operatingContext: TeamsAppOperatingContext;
|
|
45
|
+
|
|
46
|
+
// BridgeProxy
|
|
47
|
+
protected readonly bridgeProxy: IBridgeProxy;
|
|
48
|
+
|
|
49
|
+
// Crypto interface implementation
|
|
50
|
+
protected readonly browserCrypto: ICrypto;
|
|
51
|
+
|
|
52
|
+
// Input configuration by developer/user
|
|
53
|
+
protected readonly config: BrowserConfiguration;
|
|
54
|
+
|
|
55
|
+
// Logger
|
|
56
|
+
protected logger: Logger;
|
|
57
|
+
|
|
58
|
+
// Performance telemetry client
|
|
59
|
+
protected readonly performanceClient: IPerformanceClient;
|
|
60
|
+
|
|
61
|
+
// EventHandler
|
|
62
|
+
protected readonly eventHandler: EventHandler;
|
|
63
|
+
|
|
64
|
+
// NestedAppAuthAdapter
|
|
65
|
+
protected readonly nestedAppAuthAdapter: NestedAppAuthAdapter;
|
|
66
|
+
|
|
67
|
+
constructor(operatingContext: TeamsAppOperatingContext) {
|
|
68
|
+
this.operatingContext = operatingContext;
|
|
69
|
+
const proxy = this.operatingContext.getBridgeProxy();
|
|
70
|
+
if (proxy !== undefined) {
|
|
71
|
+
this.bridgeProxy = proxy;
|
|
72
|
+
} else {
|
|
73
|
+
throw new Error("unexpected: bridgeProxy is undefined");
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Set the configuration.
|
|
77
|
+
this.config = operatingContext.getConfig();
|
|
78
|
+
|
|
79
|
+
// Initialize logger
|
|
80
|
+
this.logger = this.operatingContext.getLogger();
|
|
81
|
+
// Initialize performance client
|
|
82
|
+
this.performanceClient = this.config.telemetry.client;
|
|
83
|
+
|
|
84
|
+
// Initialize the crypto class.
|
|
85
|
+
this.browserCrypto = operatingContext.isBrowserEnvironment()
|
|
86
|
+
? new CryptoOps(this.logger, this.performanceClient)
|
|
87
|
+
: DEFAULT_CRYPTO_IMPLEMENTATION;
|
|
88
|
+
|
|
89
|
+
this.eventHandler = new EventHandler(this.logger, this.browserCrypto);
|
|
90
|
+
|
|
91
|
+
this.nestedAppAuthAdapter = new NestedAppAuthAdapter(
|
|
92
|
+
this.config.auth.clientId,
|
|
93
|
+
this.config.auth.clientCapabilities,
|
|
94
|
+
this.browserCrypto,
|
|
95
|
+
this.logger
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
getBrowserStorage(): BrowserCacheManager {
|
|
99
|
+
throw NestedAppAuthError.createUnsupportedError();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
getEventHandler(): EventHandler {
|
|
103
|
+
return this.eventHandler;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
static async createController(
|
|
107
|
+
operatingContext: TeamsAppOperatingContext
|
|
108
|
+
): Promise<IController> {
|
|
109
|
+
const controller = new NestedAppAuthController(operatingContext);
|
|
110
|
+
return Promise.resolve(controller);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
initialize(): Promise<void> {
|
|
114
|
+
// do nothing not required by this controller
|
|
115
|
+
return Promise.resolve();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private async acquireTokenInteractive(
|
|
119
|
+
request: PopupRequest | RedirectRequest
|
|
120
|
+
): Promise<AuthenticationResult> {
|
|
121
|
+
this.eventHandler.emitEvent(
|
|
122
|
+
EventType.ACQUIRE_TOKEN_START,
|
|
123
|
+
InteractionType.Popup,
|
|
124
|
+
request
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
const atPopupMeasurement = this.performanceClient.startMeasurement(
|
|
128
|
+
PerformanceEvents.AcquireTokenPopup,
|
|
129
|
+
request.correlationId
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
atPopupMeasurement?.add({ nestedAppAuthRequest: true });
|
|
133
|
+
|
|
134
|
+
try {
|
|
135
|
+
const naaRequest =
|
|
136
|
+
this.nestedAppAuthAdapter.toNaaTokenRequest(request);
|
|
137
|
+
const response = await this.bridgeProxy.getTokenInteractive(
|
|
138
|
+
naaRequest
|
|
139
|
+
);
|
|
140
|
+
const result: AuthenticationResult =
|
|
141
|
+
this.nestedAppAuthAdapter.fromNaaTokenResponse(
|
|
142
|
+
naaRequest,
|
|
143
|
+
response
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
this.operatingContext.setActiveAccount(result.account);
|
|
147
|
+
this.eventHandler.emitEvent(
|
|
148
|
+
EventType.ACQUIRE_TOKEN_SUCCESS,
|
|
149
|
+
InteractionType.Popup,
|
|
150
|
+
result
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
atPopupMeasurement.add({
|
|
154
|
+
accessTokenSize: result.accessToken.length,
|
|
155
|
+
idTokenSize: result.idToken.length,
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
atPopupMeasurement.end({
|
|
159
|
+
success: true,
|
|
160
|
+
requestId: result.requestId,
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
return result;
|
|
164
|
+
} catch (e) {
|
|
165
|
+
const error = this.nestedAppAuthAdapter.fromBridgeError(e);
|
|
166
|
+
this.eventHandler.emitEvent(
|
|
167
|
+
EventType.ACQUIRE_TOKEN_FAILURE,
|
|
168
|
+
InteractionType.Popup,
|
|
169
|
+
null,
|
|
170
|
+
e as EventError
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
atPopupMeasurement.end({
|
|
174
|
+
errorCode: error.errorCode,
|
|
175
|
+
subErrorCode: error.subError,
|
|
176
|
+
success: false,
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
private async acquireTokenSilentInternal(
|
|
184
|
+
request: SilentRequest
|
|
185
|
+
): Promise<AuthenticationResult> {
|
|
186
|
+
this.eventHandler.emitEvent(
|
|
187
|
+
EventType.ACQUIRE_TOKEN_START,
|
|
188
|
+
InteractionType.Silent,
|
|
189
|
+
request
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
const ssoSilentMeasurement = this.performanceClient.startMeasurement(
|
|
193
|
+
PerformanceEvents.SsoSilent,
|
|
194
|
+
request.correlationId
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
ssoSilentMeasurement?.increment({
|
|
198
|
+
visibilityChangeCount: 0,
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
ssoSilentMeasurement?.add({
|
|
202
|
+
nestedAppAuthRequest: true,
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
try {
|
|
206
|
+
const naaRequest =
|
|
207
|
+
this.nestedAppAuthAdapter.toNaaSilentTokenRequest(request);
|
|
208
|
+
const response = await this.bridgeProxy.getTokenSilent(naaRequest);
|
|
209
|
+
|
|
210
|
+
const result: AuthenticationResult =
|
|
211
|
+
this.nestedAppAuthAdapter.fromNaaTokenResponse(
|
|
212
|
+
naaRequest,
|
|
213
|
+
response
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
this.operatingContext.setActiveAccount(result.account);
|
|
217
|
+
this.eventHandler.emitEvent(
|
|
218
|
+
EventType.ACQUIRE_TOKEN_SUCCESS,
|
|
219
|
+
InteractionType.Silent,
|
|
220
|
+
result
|
|
221
|
+
);
|
|
222
|
+
ssoSilentMeasurement?.add({
|
|
223
|
+
accessTokenSize: result.accessToken.length,
|
|
224
|
+
idTokenSize: result.idToken.length,
|
|
225
|
+
});
|
|
226
|
+
ssoSilentMeasurement?.end({
|
|
227
|
+
success: true,
|
|
228
|
+
requestId: result.requestId,
|
|
229
|
+
});
|
|
230
|
+
return result;
|
|
231
|
+
} catch (e) {
|
|
232
|
+
const error = this.nestedAppAuthAdapter.fromBridgeError(e);
|
|
233
|
+
this.eventHandler.emitEvent(
|
|
234
|
+
EventType.ACQUIRE_TOKEN_FAILURE,
|
|
235
|
+
InteractionType.Silent,
|
|
236
|
+
null,
|
|
237
|
+
e as EventError
|
|
238
|
+
);
|
|
239
|
+
ssoSilentMeasurement?.end({
|
|
240
|
+
errorCode: error.errorCode,
|
|
241
|
+
subErrorCode: error.subError,
|
|
242
|
+
success: false,
|
|
243
|
+
});
|
|
244
|
+
throw error;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
async acquireTokenPopup(
|
|
249
|
+
request: PopupRequest
|
|
250
|
+
): Promise<AuthenticationResult> {
|
|
251
|
+
return this.acquireTokenInteractive(request);
|
|
252
|
+
}
|
|
253
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
254
|
+
acquireTokenRedirect(request: RedirectRequest): Promise<void> {
|
|
255
|
+
throw NestedAppAuthError.createUnsupportedError();
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
async acquireTokenSilent(
|
|
259
|
+
silentRequest: SilentRequest
|
|
260
|
+
): Promise<AuthenticationResult> {
|
|
261
|
+
return this.acquireTokenSilentInternal(silentRequest);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
265
|
+
acquireTokenByCode(
|
|
266
|
+
request: AuthorizationCodeRequest // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
267
|
+
): Promise<AuthenticationResult> {
|
|
268
|
+
throw NestedAppAuthError.createUnsupportedError();
|
|
269
|
+
}
|
|
270
|
+
acquireTokenNative(
|
|
271
|
+
request: // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
272
|
+
| SilentRequest
|
|
273
|
+
| Partial<
|
|
274
|
+
Omit<
|
|
275
|
+
CommonAuthorizationUrlRequest,
|
|
276
|
+
| "requestedClaimsHash"
|
|
277
|
+
| "responseMode"
|
|
278
|
+
| "codeChallenge"
|
|
279
|
+
| "codeChallengeMethod"
|
|
280
|
+
| "nativeBroker"
|
|
281
|
+
>
|
|
282
|
+
>
|
|
283
|
+
| PopupRequest,
|
|
284
|
+
apiId: ApiId, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
285
|
+
accountId?: string | undefined // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
286
|
+
): Promise<AuthenticationResult> {
|
|
287
|
+
throw NestedAppAuthError.createUnsupportedError();
|
|
288
|
+
}
|
|
289
|
+
acquireTokenByRefreshToken(
|
|
290
|
+
commonRequest: CommonSilentFlowRequest, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
291
|
+
silentRequest: SilentRequest // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
292
|
+
): Promise<AuthenticationResult> {
|
|
293
|
+
throw NestedAppAuthError.createUnsupportedError();
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Adds event callbacks to array
|
|
298
|
+
* @param callback
|
|
299
|
+
*/
|
|
300
|
+
addEventCallback(callback: EventCallbackFunction): string | null {
|
|
301
|
+
return this.eventHandler.addEventCallback(callback);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Removes callback with provided id from callback array
|
|
306
|
+
* @param callbackId
|
|
307
|
+
*/
|
|
308
|
+
removeEventCallback(callbackId: string): void {
|
|
309
|
+
this.eventHandler.removeEventCallback(callbackId);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
313
|
+
addPerformanceCallback(callback: PerformanceCallbackFunction): string {
|
|
314
|
+
throw NestedAppAuthError.createUnsupportedError();
|
|
315
|
+
}
|
|
316
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
317
|
+
removePerformanceCallback(callbackId: string): boolean {
|
|
318
|
+
throw NestedAppAuthError.createUnsupportedError();
|
|
319
|
+
}
|
|
320
|
+
enableAccountStorageEvents(): void {
|
|
321
|
+
throw NestedAppAuthError.createUnsupportedError();
|
|
322
|
+
}
|
|
323
|
+
disableAccountStorageEvents(): void {
|
|
324
|
+
throw NestedAppAuthError.createUnsupportedError();
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
328
|
+
getAccount(accountFilter: AccountFilter): AccountInfo | null {
|
|
329
|
+
throw NestedAppAuthError.createUnsupportedError();
|
|
330
|
+
// TODO: Look at standard implementation
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
getAccountByHomeId(homeAccountId: string): AccountInfo | null {
|
|
334
|
+
const currentAccount = this.operatingContext.getActiveAccount();
|
|
335
|
+
if (currentAccount !== undefined) {
|
|
336
|
+
if (currentAccount.homeAccountId === homeAccountId) {
|
|
337
|
+
return this.nestedAppAuthAdapter.fromNaaAccountInfo(
|
|
338
|
+
currentAccount
|
|
339
|
+
);
|
|
340
|
+
} else {
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
} else {
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
getAccountByLocalId(localId: string): AccountInfo | null {
|
|
349
|
+
const currentAccount = this.operatingContext.getActiveAccount();
|
|
350
|
+
if (currentAccount !== undefined) {
|
|
351
|
+
if (currentAccount.localAccountId === localId) {
|
|
352
|
+
return this.nestedAppAuthAdapter.fromNaaAccountInfo(
|
|
353
|
+
currentAccount
|
|
354
|
+
);
|
|
355
|
+
} else {
|
|
356
|
+
return null;
|
|
357
|
+
}
|
|
358
|
+
} else {
|
|
359
|
+
return null;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
getAccountByUsername(userName: string): AccountInfo | null {
|
|
364
|
+
const currentAccount = this.operatingContext.getActiveAccount();
|
|
365
|
+
if (currentAccount !== undefined) {
|
|
366
|
+
if (currentAccount.username === userName) {
|
|
367
|
+
return this.nestedAppAuthAdapter.fromNaaAccountInfo(
|
|
368
|
+
currentAccount
|
|
369
|
+
);
|
|
370
|
+
} else {
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
373
|
+
} else {
|
|
374
|
+
return null;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
getAllAccounts(): AccountInfo[] {
|
|
378
|
+
const currentAccount = this.operatingContext.getActiveAccount();
|
|
379
|
+
if (currentAccount !== undefined) {
|
|
380
|
+
return [
|
|
381
|
+
this.nestedAppAuthAdapter.fromNaaAccountInfo(currentAccount),
|
|
382
|
+
];
|
|
383
|
+
} else {
|
|
384
|
+
return [];
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
handleRedirectPromise(
|
|
388
|
+
hash?: string | undefined // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
389
|
+
): Promise<AuthenticationResult | null> {
|
|
390
|
+
throw NestedAppAuthError.createUnsupportedError();
|
|
391
|
+
}
|
|
392
|
+
loginPopup(
|
|
393
|
+
request?: PopupRequest | undefined // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
394
|
+
): Promise<AuthenticationResult> {
|
|
395
|
+
if (request !== undefined) {
|
|
396
|
+
return this.acquireTokenInteractive(request);
|
|
397
|
+
} else {
|
|
398
|
+
throw NestedAppAuthError.createUnsupportedError();
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
402
|
+
loginRedirect(request?: RedirectRequest | undefined): Promise<void> {
|
|
403
|
+
throw NestedAppAuthError.createUnsupportedError();
|
|
404
|
+
}
|
|
405
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
406
|
+
logout(logoutRequest?: EndSessionRequest | undefined): Promise<void> {
|
|
407
|
+
throw NestedAppAuthError.createUnsupportedError();
|
|
408
|
+
}
|
|
409
|
+
logoutRedirect(
|
|
410
|
+
logoutRequest?: EndSessionRequest | undefined // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
411
|
+
): Promise<void> {
|
|
412
|
+
throw NestedAppAuthError.createUnsupportedError();
|
|
413
|
+
}
|
|
414
|
+
logoutPopup(
|
|
415
|
+
logoutRequest?: EndSessionPopupRequest | undefined // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
416
|
+
): Promise<void> {
|
|
417
|
+
throw NestedAppAuthError.createUnsupportedError();
|
|
418
|
+
}
|
|
419
|
+
ssoSilent(
|
|
420
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
421
|
+
request: Partial<
|
|
422
|
+
Omit<
|
|
423
|
+
CommonAuthorizationUrlRequest,
|
|
424
|
+
| "requestedClaimsHash"
|
|
425
|
+
| "responseMode"
|
|
426
|
+
| "codeChallenge"
|
|
427
|
+
| "codeChallengeMethod"
|
|
428
|
+
| "nativeBroker"
|
|
429
|
+
>
|
|
430
|
+
>
|
|
431
|
+
): Promise<AuthenticationResult> {
|
|
432
|
+
return this.acquireTokenSilentInternal(request as SilentRequest);
|
|
433
|
+
}
|
|
434
|
+
getTokenCache(): ITokenCache {
|
|
435
|
+
throw NestedAppAuthError.createUnsupportedError();
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Returns the logger instance
|
|
440
|
+
*/
|
|
441
|
+
public getLogger(): Logger {
|
|
442
|
+
return this.logger;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* Replaces the default logger set in configurations with new Logger with new configurations
|
|
447
|
+
* @param logger Logger instance
|
|
448
|
+
*/
|
|
449
|
+
setLogger(logger: Logger): void {
|
|
450
|
+
this.logger = logger;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
454
|
+
setActiveAccount(account: AccountInfo | null): void {
|
|
455
|
+
/*
|
|
456
|
+
* StandardController uses this to allow the developer to set the active account
|
|
457
|
+
* in the nested app auth scenario the active account is controlled by the app hosting the nested app
|
|
458
|
+
*/
|
|
459
|
+
this.logger.warning("nestedAppAuth does not support setActiveAccount");
|
|
460
|
+
return;
|
|
461
|
+
}
|
|
462
|
+
getActiveAccount(): AccountInfo | null {
|
|
463
|
+
const currentAccount = this.operatingContext.getActiveAccount();
|
|
464
|
+
if (currentAccount !== undefined) {
|
|
465
|
+
return this.nestedAppAuthAdapter.fromNaaAccountInfo(currentAccount);
|
|
466
|
+
} else {
|
|
467
|
+
return null;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
471
|
+
initializeWrapperLibrary(sku: WrapperSKU, version: string): void {
|
|
472
|
+
/*
|
|
473
|
+
* Standard controller uses this to set the sku and version of the wrapper library in the storage
|
|
474
|
+
* we do nothing here
|
|
475
|
+
*/
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
479
|
+
setNavigationClient(navigationClient: INavigationClient): void {
|
|
480
|
+
this.logger.warning(
|
|
481
|
+
"setNavigationClient is not supported in nested app auth"
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
getConfiguration(): BrowserConfiguration {
|
|
485
|
+
return this.config;
|
|
486
|
+
}
|
|
487
|
+
isBrowserEnv(): boolean {
|
|
488
|
+
return this.operatingContext.isBrowserEnvironment();
|
|
489
|
+
}
|
|
490
|
+
getBrowserCrypto(): ICrypto {
|
|
491
|
+
return this.browserCrypto;
|
|
492
|
+
}
|
|
493
|
+
getPerformanceClient(): IPerformanceClient {
|
|
494
|
+
throw NestedAppAuthError.createUnsupportedError();
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
getRedirectResponse(): Map<string, Promise<AuthenticationResult | null>> {
|
|
498
|
+
throw NestedAppAuthError.createUnsupportedError();
|
|
499
|
+
}
|
|
500
|
+
preflightBrowserEnvironmentCheck(
|
|
501
|
+
interactionType: InteractionType, // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
502
|
+
setInteractionInProgress?: boolean | undefined // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
503
|
+
): void {
|
|
504
|
+
throw NestedAppAuthError.createUnsupportedError();
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
508
|
+
async clearCache(logoutRequest?: ClearCacheRequest): Promise<void> {
|
|
509
|
+
throw NestedAppAuthError.createUnsupportedError();
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
513
|
+
async hydrateCache(
|
|
514
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
515
|
+
result: AuthenticationResult,
|
|
516
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
517
|
+
request:
|
|
518
|
+
| SilentRequest
|
|
519
|
+
| SsoSilentRequest
|
|
520
|
+
| RedirectRequest
|
|
521
|
+
| PopupRequest
|
|
522
|
+
): Promise<void> {
|
|
523
|
+
throw NestedAppAuthError.createUnsupportedError();
|
|
524
|
+
}
|
|
525
|
+
}
|