@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
|
@@ -0,0 +1,383 @@
|
|
|
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
|
+
AccountFilter,
|
|
16
|
+
} from "@azure/msal-common";
|
|
17
|
+
import { ITokenCache } from "../cache/ITokenCache";
|
|
18
|
+
import { BrowserConfiguration } from "../config/Configuration";
|
|
19
|
+
import {
|
|
20
|
+
BrowserCacheManager,
|
|
21
|
+
DEFAULT_BROWSER_CACHE_MANAGER,
|
|
22
|
+
} from "../cache/BrowserCacheManager";
|
|
23
|
+
import { INavigationClient } from "../navigation/INavigationClient";
|
|
24
|
+
import { AuthorizationCodeRequest } from "../request/AuthorizationCodeRequest";
|
|
25
|
+
import { EndSessionPopupRequest } from "../request/EndSessionPopupRequest";
|
|
26
|
+
import { EndSessionRequest } from "../request/EndSessionRequest";
|
|
27
|
+
import { PopupRequest } from "../request/PopupRequest";
|
|
28
|
+
import { RedirectRequest } from "../request/RedirectRequest";
|
|
29
|
+
import { SilentRequest } from "../request/SilentRequest";
|
|
30
|
+
import { SsoSilentRequest } from "../request/SsoSilentRequest";
|
|
31
|
+
import { AuthenticationResult } from "../response/AuthenticationResult";
|
|
32
|
+
import { ApiId, WrapperSKU, InteractionType } from "../utils/BrowserConstants";
|
|
33
|
+
import { IController } from "./IController";
|
|
34
|
+
import { UnknownOperatingContext } from "../operatingcontext/UnknownOperatingContext";
|
|
35
|
+
import { CryptoOps } from "../crypto/CryptoOps";
|
|
36
|
+
import {
|
|
37
|
+
blockAPICallsBeforeInitialize,
|
|
38
|
+
blockNonBrowserEnvironment,
|
|
39
|
+
} from "../utils/BrowserUtils";
|
|
40
|
+
import { EventHandler } from "../event/EventHandler";
|
|
41
|
+
import { EventCallbackFunction } from "../event/EventMessage";
|
|
42
|
+
import { ClearCacheRequest } from "../request/ClearCacheRequest";
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* UnknownOperatingContextController class
|
|
46
|
+
*
|
|
47
|
+
* - Until initialize method is called, this controller is the default
|
|
48
|
+
* - AFter initialize method is called, this controller will be swapped out for the appropriate controller
|
|
49
|
+
* if the operating context can be determined; otherwise this controller will continued be used
|
|
50
|
+
*
|
|
51
|
+
* - Why do we have this? We don't want to dynamically import (download) all of the code in StandardController if we don't need to.
|
|
52
|
+
*
|
|
53
|
+
* - Only includes implementation for getAccounts and handleRedirectPromise
|
|
54
|
+
* - All other methods are will throw initialization error (because either initialize method or the factory method were not used)
|
|
55
|
+
* - This controller is necessary for React Native wrapper, server side rendering and any other scenario where we don't have a DOM
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
export class UnknownOperatingContextController implements IController {
|
|
59
|
+
// OperatingContext
|
|
60
|
+
protected readonly operatingContext: UnknownOperatingContext;
|
|
61
|
+
|
|
62
|
+
// Logger
|
|
63
|
+
protected logger: Logger;
|
|
64
|
+
|
|
65
|
+
// Storage interface implementation
|
|
66
|
+
protected readonly browserStorage: BrowserCacheManager;
|
|
67
|
+
|
|
68
|
+
// Input configuration by developer/user
|
|
69
|
+
protected readonly config: BrowserConfiguration;
|
|
70
|
+
|
|
71
|
+
// Performance telemetry client
|
|
72
|
+
protected readonly performanceClient: IPerformanceClient;
|
|
73
|
+
|
|
74
|
+
// Crypto interface implementation
|
|
75
|
+
protected readonly browserCrypto: ICrypto;
|
|
76
|
+
|
|
77
|
+
// Flag to indicate if in browser environment
|
|
78
|
+
protected isBrowserEnvironment: boolean;
|
|
79
|
+
|
|
80
|
+
// Flag representing whether or not the initialize API has been called and completed
|
|
81
|
+
protected initialized: boolean = false;
|
|
82
|
+
|
|
83
|
+
protected readonly eventHandler: EventHandler;
|
|
84
|
+
|
|
85
|
+
constructor(operatingContext: UnknownOperatingContext) {
|
|
86
|
+
this.operatingContext = operatingContext;
|
|
87
|
+
|
|
88
|
+
this.isBrowserEnvironment =
|
|
89
|
+
this.operatingContext.isBrowserEnvironment();
|
|
90
|
+
|
|
91
|
+
this.config = operatingContext.getConfig();
|
|
92
|
+
|
|
93
|
+
this.logger = operatingContext.getLogger();
|
|
94
|
+
|
|
95
|
+
// Initialize performance client
|
|
96
|
+
this.performanceClient = this.config.telemetry.client;
|
|
97
|
+
|
|
98
|
+
// Initialize the crypto class.
|
|
99
|
+
this.browserCrypto = this.isBrowserEnvironment
|
|
100
|
+
? new CryptoOps(this.logger, this.performanceClient)
|
|
101
|
+
: DEFAULT_CRYPTO_IMPLEMENTATION;
|
|
102
|
+
|
|
103
|
+
// Initialize the browser storage class.
|
|
104
|
+
this.browserStorage = this.isBrowserEnvironment
|
|
105
|
+
? new BrowserCacheManager(
|
|
106
|
+
this.config.auth.clientId,
|
|
107
|
+
this.config.cache,
|
|
108
|
+
this.browserCrypto,
|
|
109
|
+
this.logger
|
|
110
|
+
)
|
|
111
|
+
: DEFAULT_BROWSER_CACHE_MANAGER(
|
|
112
|
+
this.config.auth.clientId,
|
|
113
|
+
this.logger
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
this.eventHandler = new EventHandler(this.logger, this.browserCrypto);
|
|
117
|
+
}
|
|
118
|
+
getBrowserStorage(): BrowserCacheManager {
|
|
119
|
+
return this.browserStorage;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
getEventHandler(): EventHandler {
|
|
123
|
+
return this.eventHandler;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
127
|
+
getAccount(accountFilter: AccountFilter): AccountInfo | null {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
131
|
+
getAccountByHomeId(homeAccountId: string): AccountInfo | null {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
135
|
+
getAccountByLocalId(localAccountId: string): AccountInfo | null {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
139
|
+
getAccountByUsername(username: string): AccountInfo | null {
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
getAllAccounts(): AccountInfo[] {
|
|
143
|
+
return [];
|
|
144
|
+
}
|
|
145
|
+
initialize(): Promise<void> {
|
|
146
|
+
this.initialized = true;
|
|
147
|
+
return Promise.resolve();
|
|
148
|
+
}
|
|
149
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
150
|
+
acquireTokenPopup(request: PopupRequest): Promise<AuthenticationResult> {
|
|
151
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
152
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
153
|
+
return {} as Promise<AuthenticationResult>;
|
|
154
|
+
}
|
|
155
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
156
|
+
acquireTokenRedirect(request: RedirectRequest): Promise<void> {
|
|
157
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
158
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
159
|
+
return Promise.resolve();
|
|
160
|
+
}
|
|
161
|
+
acquireTokenSilent(
|
|
162
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
163
|
+
silentRequest: SilentRequest
|
|
164
|
+
): Promise<AuthenticationResult> {
|
|
165
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
166
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
167
|
+
return {} as Promise<AuthenticationResult>;
|
|
168
|
+
}
|
|
169
|
+
acquireTokenByCode(
|
|
170
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
171
|
+
request: AuthorizationCodeRequest
|
|
172
|
+
): Promise<AuthenticationResult> {
|
|
173
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
174
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
175
|
+
return {} as Promise<AuthenticationResult>;
|
|
176
|
+
}
|
|
177
|
+
acquireTokenNative(
|
|
178
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
179
|
+
request:
|
|
180
|
+
| PopupRequest
|
|
181
|
+
| SilentRequest
|
|
182
|
+
| Partial<
|
|
183
|
+
Omit<
|
|
184
|
+
CommonAuthorizationUrlRequest,
|
|
185
|
+
| "responseMode"
|
|
186
|
+
| "codeChallenge"
|
|
187
|
+
| "codeChallengeMethod"
|
|
188
|
+
| "requestedClaimsHash"
|
|
189
|
+
| "nativeBroker"
|
|
190
|
+
>
|
|
191
|
+
>,
|
|
192
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
193
|
+
apiId: ApiId,
|
|
194
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
195
|
+
accountId?: string | undefined
|
|
196
|
+
): Promise<AuthenticationResult> {
|
|
197
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
198
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
199
|
+
return {} as Promise<AuthenticationResult>;
|
|
200
|
+
}
|
|
201
|
+
acquireTokenByRefreshToken(
|
|
202
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
203
|
+
commonRequest: CommonSilentFlowRequest,
|
|
204
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
205
|
+
silentRequest: SilentRequest
|
|
206
|
+
): Promise<AuthenticationResult> {
|
|
207
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
208
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
209
|
+
return {} as Promise<AuthenticationResult>;
|
|
210
|
+
}
|
|
211
|
+
addEventCallback(callback: EventCallbackFunction): string | null {
|
|
212
|
+
return this.eventHandler.addEventCallback(callback);
|
|
213
|
+
}
|
|
214
|
+
removeEventCallback(callbackId: string): void {
|
|
215
|
+
this.eventHandler.removeEventCallback(callbackId);
|
|
216
|
+
}
|
|
217
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
218
|
+
addPerformanceCallback(callback: PerformanceCallbackFunction): string {
|
|
219
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
220
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
221
|
+
return "";
|
|
222
|
+
}
|
|
223
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
224
|
+
removePerformanceCallback(callbackId: string): boolean {
|
|
225
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
226
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
enableAccountStorageEvents(): void {
|
|
230
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
231
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
232
|
+
}
|
|
233
|
+
disableAccountStorageEvents(): void {
|
|
234
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
235
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
handleRedirectPromise(
|
|
239
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
240
|
+
hash?: string | undefined
|
|
241
|
+
): Promise<AuthenticationResult | null> {
|
|
242
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
243
|
+
return Promise.resolve(null);
|
|
244
|
+
}
|
|
245
|
+
loginPopup(
|
|
246
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
247
|
+
request?: PopupRequest | undefined
|
|
248
|
+
): Promise<AuthenticationResult> {
|
|
249
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
250
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
251
|
+
return {} as Promise<AuthenticationResult>;
|
|
252
|
+
}
|
|
253
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
254
|
+
loginRedirect(request?: RedirectRequest | undefined): Promise<void> {
|
|
255
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
256
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
257
|
+
return {} as Promise<void>;
|
|
258
|
+
}
|
|
259
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
260
|
+
logout(logoutRequest?: EndSessionRequest | undefined): Promise<void> {
|
|
261
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
262
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
263
|
+
return {} as Promise<void>;
|
|
264
|
+
}
|
|
265
|
+
logoutRedirect(
|
|
266
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
267
|
+
logoutRequest?: EndSessionRequest | undefined
|
|
268
|
+
): Promise<void> {
|
|
269
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
270
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
271
|
+
return {} as Promise<void>;
|
|
272
|
+
}
|
|
273
|
+
logoutPopup(
|
|
274
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
275
|
+
logoutRequest?: EndSessionPopupRequest | undefined
|
|
276
|
+
): Promise<void> {
|
|
277
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
278
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
279
|
+
return {} as Promise<void>;
|
|
280
|
+
}
|
|
281
|
+
ssoSilent(
|
|
282
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
283
|
+
request: Partial<
|
|
284
|
+
Omit<
|
|
285
|
+
CommonAuthorizationUrlRequest,
|
|
286
|
+
| "responseMode"
|
|
287
|
+
| "codeChallenge"
|
|
288
|
+
| "codeChallengeMethod"
|
|
289
|
+
| "requestedClaimsHash"
|
|
290
|
+
| "nativeBroker"
|
|
291
|
+
>
|
|
292
|
+
>
|
|
293
|
+
): Promise<AuthenticationResult> {
|
|
294
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
295
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
296
|
+
return {} as Promise<AuthenticationResult>;
|
|
297
|
+
}
|
|
298
|
+
getTokenCache(): ITokenCache {
|
|
299
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
300
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
301
|
+
return {} as ITokenCache;
|
|
302
|
+
}
|
|
303
|
+
getLogger(): Logger {
|
|
304
|
+
return this.logger;
|
|
305
|
+
}
|
|
306
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
307
|
+
setLogger(logger: Logger): void {
|
|
308
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
309
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
310
|
+
}
|
|
311
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
312
|
+
setActiveAccount(account: AccountInfo | null): void {
|
|
313
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
314
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
315
|
+
}
|
|
316
|
+
getActiveAccount(): AccountInfo | null {
|
|
317
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
318
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
319
|
+
return null;
|
|
320
|
+
}
|
|
321
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
322
|
+
initializeWrapperLibrary(sku: WrapperSKU, version: string): void {
|
|
323
|
+
this.browserStorage.setWrapperMetadata(sku, version);
|
|
324
|
+
}
|
|
325
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
326
|
+
setNavigationClient(navigationClient: INavigationClient): void {
|
|
327
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
328
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
329
|
+
}
|
|
330
|
+
getConfiguration(): BrowserConfiguration {
|
|
331
|
+
return this.config;
|
|
332
|
+
}
|
|
333
|
+
isBrowserEnv(): boolean {
|
|
334
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
335
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
336
|
+
return true;
|
|
337
|
+
}
|
|
338
|
+
getBrowserCrypto(): ICrypto {
|
|
339
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
340
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
341
|
+
return {} as ICrypto;
|
|
342
|
+
}
|
|
343
|
+
getPerformanceClient(): IPerformanceClient {
|
|
344
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
345
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
346
|
+
return {} as IPerformanceClient;
|
|
347
|
+
}
|
|
348
|
+
getRedirectResponse(): Map<string, Promise<AuthenticationResult | null>> {
|
|
349
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
350
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
351
|
+
return {} as Map<string, Promise<AuthenticationResult | null>>;
|
|
352
|
+
}
|
|
353
|
+
preflightBrowserEnvironmentCheck(
|
|
354
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
355
|
+
interactionType: InteractionType,
|
|
356
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
357
|
+
isAppEmbedded?: boolean | undefined
|
|
358
|
+
): void {
|
|
359
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
360
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
364
|
+
async clearCache(logoutRequest?: ClearCacheRequest): Promise<void> {
|
|
365
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
366
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
370
|
+
async hydrateCache(
|
|
371
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
372
|
+
result: AuthenticationResult,
|
|
373
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
374
|
+
request:
|
|
375
|
+
| SilentRequest
|
|
376
|
+
| SsoSilentRequest
|
|
377
|
+
| RedirectRequest
|
|
378
|
+
| PopupRequest
|
|
379
|
+
): Promise<void> {
|
|
380
|
+
blockAPICallsBeforeInitialize(this.initialized);
|
|
381
|
+
blockNonBrowserEnvironment(this.isBrowserEnvironment);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { BrowserStringUtils } from "../utils/BrowserStringUtils";
|
|
7
6
|
import {
|
|
8
7
|
createBrowserAuthError,
|
|
9
8
|
BrowserAuthErrorCodes,
|
|
@@ -64,7 +63,8 @@ export async function sha256Digest(
|
|
|
64
63
|
PerformanceEvents.Sha256Digest,
|
|
65
64
|
correlationId
|
|
66
65
|
);
|
|
67
|
-
const
|
|
66
|
+
const encoder = new TextEncoder();
|
|
67
|
+
const data = encoder.encode(dataString);
|
|
68
68
|
return window.crypto.subtle.digest(
|
|
69
69
|
S256_HASH_ALG,
|
|
70
70
|
data
|
package/src/crypto/CryptoOps.ts
CHANGED
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
import { base64Encode, urlEncode, urlEncodeArr } from "../encode/Base64Encode";
|
|
16
16
|
import { base64Decode } from "../encode/Base64Decode";
|
|
17
17
|
import * as BrowserCrypto from "./BrowserCrypto";
|
|
18
|
-
import { BrowserStringUtils } from "../utils/BrowserStringUtils";
|
|
19
18
|
import {
|
|
20
19
|
createBrowserAuthError,
|
|
21
20
|
BrowserAuthErrorCodes,
|
|
@@ -109,7 +108,7 @@ export class CryptoOps implements ICrypto {
|
|
|
109
108
|
};
|
|
110
109
|
|
|
111
110
|
const publicJwkString: string =
|
|
112
|
-
|
|
111
|
+
getSortedObjectString(pubKeyThumprintObj);
|
|
113
112
|
const publicJwkHash = await this.hashString(publicJwkString);
|
|
114
113
|
|
|
115
114
|
// Generate Thumbprint for Private Key
|
|
@@ -180,8 +179,7 @@ export class CryptoOps implements ICrypto {
|
|
|
180
179
|
const publicKeyJwk = await BrowserCrypto.exportJwk(
|
|
181
180
|
cachedKeyPair.publicKey
|
|
182
181
|
);
|
|
183
|
-
const publicKeyJwkString =
|
|
184
|
-
BrowserStringUtils.getSortedObjectString(publicKeyJwk);
|
|
182
|
+
const publicKeyJwkString = getSortedObjectString(publicKeyJwk);
|
|
185
183
|
|
|
186
184
|
// Base64URL encode public key thumbprint with keyId only: BASE64URL({ kid: "FULL_PUBLIC_KEY_HASH" })
|
|
187
185
|
const encodedKeyIdThumbprint = urlEncode(JSON.stringify({ kid: kid }));
|
|
@@ -203,7 +201,8 @@ export class CryptoOps implements ICrypto {
|
|
|
203
201
|
const tokenString = `${encodedShrHeader}.${encodedPayload}`;
|
|
204
202
|
|
|
205
203
|
// Sign token
|
|
206
|
-
const
|
|
204
|
+
const encoder = new TextEncoder();
|
|
205
|
+
const tokenBuffer = encoder.encode(tokenString);
|
|
207
206
|
const signatureBuffer = await BrowserCrypto.sign(
|
|
208
207
|
cachedKeyPair.privateKey,
|
|
209
208
|
tokenBuffer
|
|
@@ -233,3 +232,7 @@ export class CryptoOps implements ICrypto {
|
|
|
233
232
|
return urlEncodeArr(hashBytes);
|
|
234
233
|
}
|
|
235
234
|
}
|
|
235
|
+
|
|
236
|
+
function getSortedObjectString(obj: object): string {
|
|
237
|
+
return JSON.stringify(obj, Object.keys(obj).sort());
|
|
238
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { AuthError } from "@azure/msal-common";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* NestedAppAuthErrorMessage class containing string constants used by error codes and messages.
|
|
10
|
+
*/
|
|
11
|
+
export const NestedAppAuthErrorMessage = {
|
|
12
|
+
unsupportedMethod: {
|
|
13
|
+
code: "unsupported_method",
|
|
14
|
+
desc: "The PKCE code challenge and verifier could not be generated.",
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export class NestedAppAuthError extends AuthError {
|
|
19
|
+
constructor(errorCode: string, errorMessage?: string) {
|
|
20
|
+
super(errorCode, errorMessage);
|
|
21
|
+
|
|
22
|
+
Object.setPrototypeOf(this, NestedAppAuthError.prototype);
|
|
23
|
+
this.name = "NestedAppAuthError";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public static createUnsupportedError(): NestedAppAuthError {
|
|
27
|
+
return new NestedAppAuthError(
|
|
28
|
+
NestedAppAuthErrorMessage.unsupportedMethod.code,
|
|
29
|
+
NestedAppAuthErrorMessage.unsupportedMethod.desc
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -8,12 +8,11 @@
|
|
|
8
8
|
* @module @azure/msal-browser
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
* Breaking changes to these APIs will be shipped under a minor version, instead of a major version.
|
|
14
|
-
*/
|
|
11
|
+
import * as BrowserUtils from "./utils/BrowserUtils";
|
|
12
|
+
export { BrowserUtils };
|
|
15
13
|
|
|
16
14
|
export { PublicClientApplication } from "./app/PublicClientApplication";
|
|
15
|
+
export { PublicClientNext } from "./app/PublicClientNext";
|
|
17
16
|
export { IController } from "./controllers/IController";
|
|
18
17
|
export {
|
|
19
18
|
Configuration,
|
|
@@ -32,12 +31,6 @@ export {
|
|
|
32
31
|
ApiId,
|
|
33
32
|
CacheLookupPolicy,
|
|
34
33
|
} from "./utils/BrowserConstants";
|
|
35
|
-
export { BrowserUtils } from "./utils/BrowserUtils";
|
|
36
|
-
|
|
37
|
-
/*
|
|
38
|
-
* export { IController} from "./controllers/IController";
|
|
39
|
-
* export { StandardController } from "./controllers/StandardController";
|
|
40
|
-
*/
|
|
41
34
|
|
|
42
35
|
// Browser Errors
|
|
43
36
|
export {
|
|
@@ -32,7 +32,7 @@ import { PopupRequest } from "../request/PopupRequest";
|
|
|
32
32
|
import { SsoSilentRequest } from "../request/SsoSilentRequest";
|
|
33
33
|
import { version } from "../packageMetadata";
|
|
34
34
|
import { BrowserConstants } from "../utils/BrowserConstants";
|
|
35
|
-
import
|
|
35
|
+
import * as BrowserUtils from "../utils/BrowserUtils";
|
|
36
36
|
import { INavigationClient } from "../navigation/INavigationClient";
|
|
37
37
|
import { NativeMessageHandler } from "../broker/nativeBroker/NativeMessageHandler";
|
|
38
38
|
import { AuthenticationResult } from "../response/AuthenticationResult";
|
|
@@ -238,9 +238,10 @@ export class NativeInteractionClient extends BaseInteractionClient {
|
|
|
238
238
|
throw createClientAuthError(ClientAuthErrorCodes.noAccountFound);
|
|
239
239
|
}
|
|
240
240
|
// fetch the account from browser cache
|
|
241
|
-
const account = this.browserStorage.
|
|
241
|
+
const account = this.browserStorage.getBaseAccountInfo({
|
|
242
242
|
nativeAccountId,
|
|
243
243
|
});
|
|
244
|
+
|
|
244
245
|
if (!account) {
|
|
245
246
|
throw createClientAuthError(ClientAuthErrorCodes.noAccountFound);
|
|
246
247
|
}
|
|
@@ -254,9 +255,15 @@ export class NativeInteractionClient extends BaseInteractionClient {
|
|
|
254
255
|
const result = await this.silentCacheClient.acquireToken(
|
|
255
256
|
silentRequest
|
|
256
257
|
);
|
|
258
|
+
|
|
259
|
+
const fullAccount = {
|
|
260
|
+
...account,
|
|
261
|
+
idTokenClaims: result?.idTokenClaims as TokenClaims,
|
|
262
|
+
};
|
|
263
|
+
|
|
257
264
|
return {
|
|
258
265
|
...result,
|
|
259
|
-
account,
|
|
266
|
+
account: fullAccount,
|
|
260
267
|
};
|
|
261
268
|
} catch (e) {
|
|
262
269
|
throw e;
|
|
@@ -572,6 +579,15 @@ export class NativeInteractionClient extends BaseInteractionClient {
|
|
|
572
579
|
idTokenClaims.tid ||
|
|
573
580
|
Constants.EMPTY_STRING;
|
|
574
581
|
|
|
582
|
+
const fullAccountEntity: AccountEntity = idTokenClaims
|
|
583
|
+
? Object.assign(new AccountEntity(), {
|
|
584
|
+
...accountEntity,
|
|
585
|
+
idTokenClaims: idTokenClaims,
|
|
586
|
+
})
|
|
587
|
+
: accountEntity;
|
|
588
|
+
|
|
589
|
+
const accountInfo = fullAccountEntity.getAccountInfo();
|
|
590
|
+
|
|
575
591
|
// generate PoP token as needed
|
|
576
592
|
const responseAccessToken = await this.generatePopAccessToken(
|
|
577
593
|
response,
|
|
@@ -587,7 +603,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
|
|
|
587
603
|
uniqueId: uid,
|
|
588
604
|
tenantId: tid,
|
|
589
605
|
scopes: responseScopes.asArray(),
|
|
590
|
-
account:
|
|
606
|
+
account: accountInfo,
|
|
591
607
|
idToken: response.id_token,
|
|
592
608
|
idTokenClaims: idTokenClaims,
|
|
593
609
|
accessToken: responseAccessToken,
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
} from "../utils/BrowserConstants";
|
|
31
31
|
import { EndSessionPopupRequest } from "../request/EndSessionPopupRequest";
|
|
32
32
|
import { NavigationOptions } from "../navigation/NavigationOptions";
|
|
33
|
-
import
|
|
33
|
+
import * as BrowserUtils from "../utils/BrowserUtils";
|
|
34
34
|
import { PopupRequest } from "../request/PopupRequest";
|
|
35
35
|
import { NativeInteractionClient } from "./NativeInteractionClient";
|
|
36
36
|
import { NativeMessageHandler } from "../broker/nativeBroker/NativeMessageHandler";
|
|
@@ -211,6 +211,7 @@ export class PopupClient extends StandardInteractionClient {
|
|
|
211
211
|
request,
|
|
212
212
|
InteractionType.Popup
|
|
213
213
|
);
|
|
214
|
+
BrowserUtils.preconnect(validRequest.authority);
|
|
214
215
|
this.browserStorage.updateCacheEntries(
|
|
215
216
|
validRequest.state,
|
|
216
217
|
validRequest.nonce,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
TemporaryCacheKeys,
|
|
27
27
|
} from "../utils/BrowserConstants";
|
|
28
28
|
import { RedirectHandler } from "../interaction_handler/RedirectHandler";
|
|
29
|
-
import
|
|
29
|
+
import * as BrowserUtils from "../utils/BrowserUtils";
|
|
30
30
|
import { EndSessionRequest } from "../request/EndSessionRequest";
|
|
31
31
|
import { EventType } from "../event/EventType";
|
|
32
32
|
import { NavigationOptions } from "../navigation/NavigationOptions";
|
|
@@ -24,11 +24,11 @@ import {
|
|
|
24
24
|
BrowserAuthErrorCodes,
|
|
25
25
|
} from "../error/BrowserAuthError";
|
|
26
26
|
import { InteractionType, ApiId } from "../utils/BrowserConstants";
|
|
27
|
-
import { SilentHandler } from "../interaction_handler/SilentHandler";
|
|
28
27
|
import { AuthorizationCodeRequest } from "../request/AuthorizationCodeRequest";
|
|
29
28
|
import { HybridSpaAuthorizationCodeClient } from "./HybridSpaAuthorizationCodeClient";
|
|
30
29
|
import { NativeMessageHandler } from "../broker/nativeBroker/NativeMessageHandler";
|
|
31
30
|
import { AuthenticationResult } from "../response/AuthenticationResult";
|
|
31
|
+
import { InteractionHandler } from "../interaction_handler/InteractionHandler";
|
|
32
32
|
|
|
33
33
|
export class SilentAuthCodeClient extends StandardInteractionClient {
|
|
34
34
|
private apiId: ApiId;
|
|
@@ -113,18 +113,19 @@ export class SilentAuthCodeClient extends StandardInteractionClient {
|
|
|
113
113
|
this.logger.verbose("Auth code client created");
|
|
114
114
|
|
|
115
115
|
// Create silent handler
|
|
116
|
-
const
|
|
116
|
+
const interactionHandler = new InteractionHandler(
|
|
117
117
|
authClient,
|
|
118
118
|
this.browserStorage,
|
|
119
119
|
authCodeRequest,
|
|
120
120
|
this.logger,
|
|
121
|
-
this.config.system,
|
|
122
121
|
this.performanceClient
|
|
123
122
|
);
|
|
124
123
|
|
|
125
124
|
// Handle auth code parameters from request
|
|
126
125
|
return invokeAsync(
|
|
127
|
-
|
|
126
|
+
interactionHandler.handleCodeResponseFromServer.bind(
|
|
127
|
+
interactionHandler
|
|
128
|
+
),
|
|
128
129
|
PerformanceEvents.HandleCodeResponseFromServer,
|
|
129
130
|
this.logger,
|
|
130
131
|
this.performanceClient,
|
|
@@ -30,6 +30,10 @@ export class SilentCacheClient extends StandardInteractionClient {
|
|
|
30
30
|
async acquireToken(
|
|
31
31
|
silentRequest: CommonSilentFlowRequest
|
|
32
32
|
): Promise<AuthenticationResult> {
|
|
33
|
+
this.performanceClient.addQueueMeasurement(
|
|
34
|
+
PerformanceEvents.SilentCacheClientAcquireToken,
|
|
35
|
+
silentRequest.correlationId
|
|
36
|
+
);
|
|
33
37
|
// Telemetry manager only used to increment cacheHits here
|
|
34
38
|
const serverTelemetryManager = this.initializeServerTelemetryManager(
|
|
35
39
|
ApiId.acquireTokenSilent_silentFlow
|
|
@@ -43,9 +47,13 @@ export class SilentCacheClient extends StandardInteractionClient {
|
|
|
43
47
|
this.logger.verbose("Silent auth client created");
|
|
44
48
|
|
|
45
49
|
try {
|
|
46
|
-
const response = await
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
const response = await invokeAsync(
|
|
51
|
+
silentAuthClient.acquireCachedToken.bind(silentAuthClient),
|
|
52
|
+
PerformanceEvents.SilentFlowClientAcquireCachedToken,
|
|
53
|
+
this.logger,
|
|
54
|
+
this.performanceClient,
|
|
55
|
+
silentRequest.correlationId
|
|
56
|
+
)(silentRequest);
|
|
49
57
|
const authResponse = response[0] as AuthenticationResult;
|
|
50
58
|
|
|
51
59
|
this.performanceClient.addFields(
|