@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
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
CommonAuthorizationCodeRequest,
|
|
11
11
|
AuthorizationCodeClient,
|
|
12
12
|
AuthError,
|
|
13
|
-
Constants,
|
|
14
13
|
UrlString,
|
|
15
14
|
ServerAuthorizationCodeResponse,
|
|
16
15
|
ProtocolUtils,
|
|
@@ -29,11 +28,16 @@ import {
|
|
|
29
28
|
BrowserAuthErrorCodes,
|
|
30
29
|
} from "../error/BrowserAuthError";
|
|
31
30
|
import { InteractionType, ApiId } from "../utils/BrowserConstants";
|
|
32
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
initiateAuthRequest,
|
|
33
|
+
monitorIframeForHash,
|
|
34
|
+
} from "../interaction_handler/SilentHandler";
|
|
33
35
|
import { SsoSilentRequest } from "../request/SsoSilentRequest";
|
|
34
36
|
import { NativeMessageHandler } from "../broker/nativeBroker/NativeMessageHandler";
|
|
35
37
|
import { NativeInteractionClient } from "./NativeInteractionClient";
|
|
36
38
|
import { AuthenticationResult } from "../response/AuthenticationResult";
|
|
39
|
+
import { InteractionHandler } from "../interaction_handler/InteractionHandler";
|
|
40
|
+
import * as BrowserUtils from "../utils/BrowserUtils";
|
|
37
41
|
|
|
38
42
|
export class SilentIframeClient extends StandardInteractionClient {
|
|
39
43
|
protected apiId: ApiId;
|
|
@@ -114,13 +118,7 @@ export class SilentIframeClient extends StandardInteractionClient {
|
|
|
114
118
|
},
|
|
115
119
|
InteractionType.Silent
|
|
116
120
|
);
|
|
117
|
-
|
|
118
|
-
silentRequest.state,
|
|
119
|
-
silentRequest.nonce,
|
|
120
|
-
silentRequest.authority,
|
|
121
|
-
silentRequest.loginHint || Constants.EMPTY_STRING,
|
|
122
|
-
silentRequest.account || null
|
|
123
|
-
);
|
|
121
|
+
BrowserUtils.preconnect(silentRequest.authority);
|
|
124
122
|
|
|
125
123
|
const serverTelemetryManager = this.initializeServerTelemetryManager(
|
|
126
124
|
this.apiId
|
|
@@ -152,7 +150,6 @@ export class SilentIframeClient extends StandardInteractionClient {
|
|
|
152
150
|
(e as AuthError).setCorrelationId(this.correlationId);
|
|
153
151
|
serverTelemetryManager.cacheFailedRequest(e);
|
|
154
152
|
}
|
|
155
|
-
this.browserStorage.cleanRequestByState(silentRequest.state);
|
|
156
153
|
throw e;
|
|
157
154
|
}
|
|
158
155
|
}
|
|
@@ -179,9 +176,10 @@ export class SilentIframeClient extends StandardInteractionClient {
|
|
|
179
176
|
authClient: AuthorizationCodeClient,
|
|
180
177
|
silentRequest: AuthorizationUrlRequest
|
|
181
178
|
): Promise<AuthenticationResult> {
|
|
179
|
+
const correlationId = silentRequest.correlationId;
|
|
182
180
|
this.performanceClient.addQueueMeasurement(
|
|
183
181
|
PerformanceEvents.SilentIframeClientTokenHelper,
|
|
184
|
-
|
|
182
|
+
correlationId
|
|
185
183
|
);
|
|
186
184
|
|
|
187
185
|
// Create auth code request and generate PKCE params
|
|
@@ -191,7 +189,7 @@ export class SilentIframeClient extends StandardInteractionClient {
|
|
|
191
189
|
PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest,
|
|
192
190
|
this.logger,
|
|
193
191
|
this.performanceClient,
|
|
194
|
-
|
|
192
|
+
correlationId
|
|
195
193
|
)(silentRequest);
|
|
196
194
|
|
|
197
195
|
// Create authorize request url
|
|
@@ -200,7 +198,7 @@ export class SilentIframeClient extends StandardInteractionClient {
|
|
|
200
198
|
PerformanceEvents.GetAuthCodeUrl,
|
|
201
199
|
this.logger,
|
|
202
200
|
this.performanceClient,
|
|
203
|
-
|
|
201
|
+
correlationId
|
|
204
202
|
)({
|
|
205
203
|
...silentRequest,
|
|
206
204
|
nativeBroker: NativeMessageHandler.isNativeAvailable(
|
|
@@ -212,38 +210,60 @@ export class SilentIframeClient extends StandardInteractionClient {
|
|
|
212
210
|
});
|
|
213
211
|
|
|
214
212
|
// Create silent handler
|
|
215
|
-
const
|
|
213
|
+
const interactionHandler = new InteractionHandler(
|
|
216
214
|
authClient,
|
|
217
215
|
this.browserStorage,
|
|
218
216
|
authCodeRequest,
|
|
219
217
|
this.logger,
|
|
220
|
-
this.config.system,
|
|
221
218
|
this.performanceClient
|
|
222
219
|
);
|
|
223
220
|
// Get the frame handle for the silent request
|
|
224
221
|
const msalFrame = await invokeAsync(
|
|
225
|
-
|
|
222
|
+
initiateAuthRequest,
|
|
226
223
|
PerformanceEvents.SilentHandlerInitiateAuthRequest,
|
|
227
224
|
this.logger,
|
|
228
225
|
this.performanceClient,
|
|
229
|
-
|
|
230
|
-
)(
|
|
226
|
+
correlationId
|
|
227
|
+
)(
|
|
228
|
+
navigateUrl,
|
|
229
|
+
this.performanceClient,
|
|
230
|
+
this.logger,
|
|
231
|
+
correlationId,
|
|
232
|
+
this.config.system.navigateFrameWait
|
|
233
|
+
);
|
|
231
234
|
// Monitor the window for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.
|
|
232
235
|
const hash = await invokeAsync(
|
|
233
|
-
|
|
236
|
+
monitorIframeForHash,
|
|
234
237
|
PerformanceEvents.SilentHandlerMonitorIframeForHash,
|
|
235
238
|
this.logger,
|
|
236
239
|
this.performanceClient,
|
|
237
|
-
|
|
238
|
-
)(
|
|
240
|
+
correlationId
|
|
241
|
+
)(
|
|
242
|
+
msalFrame,
|
|
243
|
+
this.config.system.iframeHashTimeout,
|
|
244
|
+
this.config.system.pollIntervalMilliseconds,
|
|
245
|
+
this.performanceClient,
|
|
246
|
+
this.logger,
|
|
247
|
+
correlationId
|
|
248
|
+
);
|
|
249
|
+
if (!hash) {
|
|
250
|
+
// No hash is present
|
|
251
|
+
this.logger.error(
|
|
252
|
+
"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."
|
|
253
|
+
);
|
|
254
|
+
throw createBrowserAuthError(BrowserAuthErrorCodes.hashEmptyError);
|
|
255
|
+
} else if (!UrlString.hashContainsKnownProperties(hash)) {
|
|
256
|
+
this.logger.error(
|
|
257
|
+
"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."
|
|
258
|
+
);
|
|
259
|
+
this.logger.errorPii(`The hash detected in the iframe is: ${hash}`);
|
|
260
|
+
throw createBrowserAuthError(
|
|
261
|
+
BrowserAuthErrorCodes.hashDoesNotContainKnownProperties
|
|
262
|
+
);
|
|
263
|
+
}
|
|
239
264
|
// Deserialize hash fragment response parameters.
|
|
240
265
|
const serverParams: ServerAuthorizationCodeResponse =
|
|
241
266
|
UrlString.getDeserializedHash(hash);
|
|
242
|
-
const state = this.validateAndExtractStateFromHash(
|
|
243
|
-
serverParams,
|
|
244
|
-
InteractionType.Silent,
|
|
245
|
-
authCodeRequest.correlationId
|
|
246
|
-
);
|
|
247
267
|
|
|
248
268
|
if (serverParams.accountId) {
|
|
249
269
|
this.logger.verbose(
|
|
@@ -266,11 +286,11 @@ export class SilentIframeClient extends StandardInteractionClient {
|
|
|
266
286
|
this.nativeMessageHandler,
|
|
267
287
|
serverParams.accountId,
|
|
268
288
|
this.browserStorage,
|
|
269
|
-
|
|
289
|
+
correlationId
|
|
270
290
|
);
|
|
271
291
|
const { userRequestState } = ProtocolUtils.parseRequestState(
|
|
272
292
|
this.browserCrypto,
|
|
273
|
-
state
|
|
293
|
+
silentRequest.state
|
|
274
294
|
);
|
|
275
295
|
return invokeAsync(
|
|
276
296
|
nativeInteractionClient.acquireToken.bind(
|
|
@@ -279,23 +299,23 @@ export class SilentIframeClient extends StandardInteractionClient {
|
|
|
279
299
|
PerformanceEvents.NativeInteractionClientAcquireToken,
|
|
280
300
|
this.logger,
|
|
281
301
|
this.performanceClient,
|
|
282
|
-
|
|
302
|
+
correlationId
|
|
283
303
|
)({
|
|
284
304
|
...silentRequest,
|
|
285
305
|
state: userRequestState,
|
|
286
306
|
prompt: silentRequest.prompt || PromptValue.NONE,
|
|
287
|
-
}).finally(() => {
|
|
288
|
-
this.browserStorage.cleanRequestByState(state);
|
|
289
307
|
});
|
|
290
308
|
}
|
|
291
309
|
|
|
292
310
|
// Handle response from hash string
|
|
293
311
|
return invokeAsync(
|
|
294
|
-
|
|
312
|
+
interactionHandler.handleCodeResponseFromHash.bind(
|
|
313
|
+
interactionHandler
|
|
314
|
+
),
|
|
295
315
|
PerformanceEvents.HandleCodeResponseFromHash,
|
|
296
316
|
this.logger,
|
|
297
317
|
this.performanceClient,
|
|
298
|
-
|
|
299
|
-
)(hash,
|
|
318
|
+
correlationId
|
|
319
|
+
)(hash, silentRequest);
|
|
300
320
|
}
|
|
301
321
|
}
|
|
@@ -53,7 +53,6 @@ export class SilentRefreshClient extends StandardInteractionClient {
|
|
|
53
53
|
silentRequest.authority,
|
|
54
54
|
silentRequest.azureCloudOptions
|
|
55
55
|
);
|
|
56
|
-
this.logger.verbose("Refresh token client created");
|
|
57
56
|
// Send request to renew token. Auth module will throw errors if token cannot be renewed.
|
|
58
57
|
return invokeAsync(
|
|
59
58
|
refreshTokenClient.acquireTokenByRefreshToken.bind(
|
|
@@ -63,24 +62,11 @@ export class SilentRefreshClient extends StandardInteractionClient {
|
|
|
63
62
|
this.logger,
|
|
64
63
|
this.performanceClient,
|
|
65
64
|
request.correlationId
|
|
66
|
-
)(silentRequest)
|
|
67
|
-
|
|
68
|
-
.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
fromCache: result.fromCache,
|
|
72
|
-
requestId: result.requestId,
|
|
73
|
-
},
|
|
74
|
-
request.correlationId
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
return result;
|
|
78
|
-
})
|
|
79
|
-
.catch((e: AuthError) => {
|
|
80
|
-
(e as AuthError).setCorrelationId(this.correlationId);
|
|
81
|
-
serverTelemetryManager.cacheFailedRequest(e);
|
|
82
|
-
throw e;
|
|
83
|
-
});
|
|
65
|
+
)(silentRequest).catch((e: AuthError) => {
|
|
66
|
+
(e as AuthError).setCorrelationId(this.correlationId);
|
|
67
|
+
serverTelemetryManager.cacheFailedRequest(e);
|
|
68
|
+
throw e;
|
|
69
|
+
}) as Promise<AuthenticationResult>;
|
|
84
70
|
}
|
|
85
71
|
|
|
86
72
|
/**
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
BrowserStateObject,
|
|
38
38
|
} from "../utils/BrowserProtocolUtils";
|
|
39
39
|
import { EndSessionRequest } from "../request/EndSessionRequest";
|
|
40
|
-
import
|
|
40
|
+
import * as BrowserUtils from "../utils/BrowserUtils";
|
|
41
41
|
import { RedirectRequest } from "../request/RedirectRequest";
|
|
42
42
|
import { PopupRequest } from "../request/PopupRequest";
|
|
43
43
|
import { SsoSilentRequest } from "../request/SsoSilentRequest";
|
|
@@ -7,17 +7,13 @@ import {
|
|
|
7
7
|
AuthorizationCodePayload,
|
|
8
8
|
CommonAuthorizationCodeRequest,
|
|
9
9
|
AuthorizationCodeClient,
|
|
10
|
-
AuthorityFactory,
|
|
11
|
-
Authority,
|
|
12
|
-
INetworkModule,
|
|
13
10
|
CcsCredential,
|
|
14
11
|
Logger,
|
|
15
12
|
ServerError,
|
|
16
13
|
IPerformanceClient,
|
|
17
14
|
PerformanceEvents,
|
|
18
15
|
invokeAsync,
|
|
19
|
-
|
|
20
|
-
ClientAuthErrorCodes,
|
|
16
|
+
CcsCredentialType,
|
|
21
17
|
} from "@azure/msal-common";
|
|
22
18
|
|
|
23
19
|
import { BrowserCacheManager } from "../cache/BrowserCacheManager";
|
|
@@ -25,10 +21,8 @@ import {
|
|
|
25
21
|
createBrowserAuthError,
|
|
26
22
|
BrowserAuthErrorCodes,
|
|
27
23
|
} from "../error/BrowserAuthError";
|
|
28
|
-
import { TemporaryCacheKeys } from "../utils/BrowserConstants";
|
|
29
24
|
import { AuthenticationResult } from "../response/AuthenticationResult";
|
|
30
|
-
|
|
31
|
-
export type InteractionParams = {};
|
|
25
|
+
import { AuthorizationUrlRequest } from "../request/AuthorizationUrlRequest";
|
|
32
26
|
|
|
33
27
|
/**
|
|
34
28
|
* Abstract class which defines operations for a browser interaction handling class.
|
|
@@ -60,34 +54,22 @@ export class InteractionHandler {
|
|
|
60
54
|
*/
|
|
61
55
|
async handleCodeResponseFromHash(
|
|
62
56
|
locationHash: string,
|
|
63
|
-
|
|
64
|
-
authority: Authority,
|
|
65
|
-
networkModule: INetworkModule
|
|
57
|
+
request: AuthorizationUrlRequest
|
|
66
58
|
): Promise<AuthenticationResult> {
|
|
67
59
|
this.performanceClient.addQueueMeasurement(
|
|
68
60
|
PerformanceEvents.HandleCodeResponseFromHash,
|
|
69
|
-
|
|
61
|
+
request.correlationId
|
|
70
62
|
);
|
|
71
63
|
// Check that location hash isn't empty.
|
|
72
64
|
if (!locationHash) {
|
|
73
65
|
throw createBrowserAuthError(BrowserAuthErrorCodes.hashEmptyError);
|
|
74
66
|
}
|
|
75
67
|
|
|
76
|
-
// Handle code response.
|
|
77
|
-
const stateKey = this.browserStorage.generateStateKey(state);
|
|
78
|
-
const requestState = this.browserStorage.getTemporaryCache(stateKey);
|
|
79
|
-
if (!requestState) {
|
|
80
|
-
throw createClientAuthError(
|
|
81
|
-
ClientAuthErrorCodes.stateNotFound,
|
|
82
|
-
"Cached State"
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
68
|
let authCodeResponse;
|
|
87
69
|
try {
|
|
88
70
|
authCodeResponse = this.authModule.handleFragmentResponse(
|
|
89
71
|
locationHash,
|
|
90
|
-
|
|
72
|
+
request.state
|
|
91
73
|
);
|
|
92
74
|
} catch (e) {
|
|
93
75
|
if (
|
|
@@ -108,8 +90,8 @@ export class InteractionHandler {
|
|
|
108
90
|
PerformanceEvents.HandleCodeResponseFromServer,
|
|
109
91
|
this.logger,
|
|
110
92
|
this.performanceClient,
|
|
111
|
-
|
|
112
|
-
)(authCodeResponse,
|
|
93
|
+
request.correlationId
|
|
94
|
+
)(authCodeResponse, request);
|
|
113
95
|
}
|
|
114
96
|
|
|
115
97
|
/**
|
|
@@ -122,65 +104,46 @@ export class InteractionHandler {
|
|
|
122
104
|
*/
|
|
123
105
|
async handleCodeResponseFromServer(
|
|
124
106
|
authCodeResponse: AuthorizationCodePayload,
|
|
125
|
-
|
|
126
|
-
authority: Authority,
|
|
127
|
-
networkModule: INetworkModule,
|
|
107
|
+
request: AuthorizationUrlRequest,
|
|
128
108
|
validateNonce: boolean = true
|
|
129
109
|
): Promise<AuthenticationResult> {
|
|
130
110
|
this.performanceClient.addQueueMeasurement(
|
|
131
111
|
PerformanceEvents.HandleCodeResponseFromServer,
|
|
132
|
-
|
|
112
|
+
request.correlationId
|
|
133
113
|
);
|
|
134
114
|
this.logger.trace(
|
|
135
115
|
"InteractionHandler.handleCodeResponseFromServer called"
|
|
136
116
|
);
|
|
137
117
|
|
|
138
|
-
// Handle code response.
|
|
139
|
-
const stateKey = this.browserStorage.generateStateKey(state);
|
|
140
|
-
const requestState = this.browserStorage.getTemporaryCache(stateKey);
|
|
141
|
-
if (!requestState) {
|
|
142
|
-
throw createClientAuthError(
|
|
143
|
-
ClientAuthErrorCodes.stateNotFound,
|
|
144
|
-
"Cached State"
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
// Get cached items
|
|
149
|
-
const nonceKey = this.browserStorage.generateNonceKey(requestState);
|
|
150
|
-
const cachedNonce = this.browserStorage.getTemporaryCache(nonceKey);
|
|
151
|
-
|
|
152
118
|
// Assign code to request
|
|
153
119
|
this.authCodeRequest.code = authCodeResponse.code;
|
|
154
120
|
|
|
155
121
|
// Check for new cloud instance
|
|
156
122
|
if (authCodeResponse.cloud_instance_host_name) {
|
|
157
123
|
await invokeAsync(
|
|
158
|
-
this.
|
|
124
|
+
this.authModule.updateAuthority.bind(this.authModule),
|
|
159
125
|
PerformanceEvents.UpdateTokenEndpointAuthority,
|
|
160
126
|
this.logger,
|
|
161
127
|
this.performanceClient,
|
|
162
|
-
|
|
163
|
-
)(
|
|
164
|
-
authCodeResponse.cloud_instance_host_name,
|
|
165
|
-
authority,
|
|
166
|
-
networkModule
|
|
167
|
-
);
|
|
128
|
+
request.correlationId
|
|
129
|
+
)(authCodeResponse.cloud_instance_host_name, request.correlationId);
|
|
168
130
|
}
|
|
169
131
|
|
|
170
132
|
// Nonce validation not needed when redirect not involved (e.g. hybrid spa, renewing token via rt)
|
|
171
133
|
if (validateNonce) {
|
|
172
|
-
|
|
134
|
+
// TODO: Assigning "response nonce" to "request nonce" is confusing. Refactor the function doing validation to accept request nonce directly
|
|
135
|
+
authCodeResponse.nonce = request.nonce || undefined;
|
|
173
136
|
}
|
|
174
137
|
|
|
175
|
-
authCodeResponse.state =
|
|
138
|
+
authCodeResponse.state = request.state;
|
|
176
139
|
|
|
177
140
|
// Add CCS parameters if available
|
|
178
141
|
if (authCodeResponse.client_info) {
|
|
179
142
|
this.authCodeRequest.clientInfo = authCodeResponse.client_info;
|
|
180
143
|
} else {
|
|
181
|
-
const
|
|
182
|
-
if (
|
|
183
|
-
this.authCodeRequest.ccsCredential =
|
|
144
|
+
const ccsCred = this.createCcsCredentials(request);
|
|
145
|
+
if (ccsCred) {
|
|
146
|
+
this.authCodeRequest.ccsCredential = ccsCred;
|
|
184
147
|
}
|
|
185
148
|
}
|
|
186
149
|
|
|
@@ -190,62 +153,29 @@ export class InteractionHandler {
|
|
|
190
153
|
PerformanceEvents.AuthClientAcquireToken,
|
|
191
154
|
this.logger,
|
|
192
155
|
this.performanceClient,
|
|
193
|
-
|
|
156
|
+
request.correlationId
|
|
194
157
|
)(this.authCodeRequest, authCodeResponse)) as AuthenticationResult;
|
|
195
|
-
this.browserStorage.cleanRequestByState(state);
|
|
196
158
|
return tokenResponse;
|
|
197
159
|
}
|
|
198
160
|
|
|
199
161
|
/**
|
|
200
|
-
*
|
|
201
|
-
* @param cloudInstanceHostname
|
|
202
|
-
* @param authority
|
|
203
|
-
* @param networkModule
|
|
162
|
+
* Build ccs creds if available
|
|
204
163
|
*/
|
|
205
|
-
protected
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
)
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
networkModule,
|
|
219
|
-
this.browserStorage,
|
|
220
|
-
authority.options,
|
|
221
|
-
this.logger,
|
|
222
|
-
this.performanceClient,
|
|
223
|
-
this.authCodeRequest.correlationId
|
|
224
|
-
);
|
|
225
|
-
this.authModule.updateAuthority(cloudInstanceAuthority);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Looks up ccs creds in the cache
|
|
230
|
-
*/
|
|
231
|
-
protected checkCcsCredentials(): CcsCredential | null {
|
|
232
|
-
// Look up ccs credential in temp cache
|
|
233
|
-
const cachedCcsCred = this.browserStorage.getTemporaryCache(
|
|
234
|
-
TemporaryCacheKeys.CCS_CREDENTIAL,
|
|
235
|
-
true
|
|
236
|
-
);
|
|
237
|
-
if (cachedCcsCred) {
|
|
238
|
-
try {
|
|
239
|
-
return JSON.parse(cachedCcsCred) as CcsCredential;
|
|
240
|
-
} catch (e) {
|
|
241
|
-
this.authModule.logger.error(
|
|
242
|
-
"Cache credential could not be parsed"
|
|
243
|
-
);
|
|
244
|
-
this.authModule.logger.errorPii(
|
|
245
|
-
`Cache credential could not be parsed: ${cachedCcsCred}`
|
|
246
|
-
);
|
|
247
|
-
}
|
|
164
|
+
protected createCcsCredentials(
|
|
165
|
+
request: AuthorizationUrlRequest
|
|
166
|
+
): CcsCredential | null {
|
|
167
|
+
if (request.account) {
|
|
168
|
+
return {
|
|
169
|
+
credential: request.account.homeAccountId,
|
|
170
|
+
type: CcsCredentialType.HOME_ACCOUNT_ID,
|
|
171
|
+
};
|
|
172
|
+
} else if (request.loginHint) {
|
|
173
|
+
return {
|
|
174
|
+
credential: request.loginHint,
|
|
175
|
+
type: CcsCredentialType.UPN,
|
|
176
|
+
};
|
|
248
177
|
}
|
|
178
|
+
|
|
249
179
|
return null;
|
|
250
180
|
}
|
|
251
181
|
}
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
import {
|
|
7
7
|
AuthorizationCodeClient,
|
|
8
8
|
CommonAuthorizationCodeRequest,
|
|
9
|
-
ICrypto,
|
|
10
|
-
Authority,
|
|
11
|
-
INetworkModule,
|
|
12
9
|
Logger,
|
|
13
10
|
ServerError,
|
|
14
11
|
IPerformanceClient,
|
|
15
12
|
createClientAuthError,
|
|
16
13
|
ClientAuthErrorCodes,
|
|
14
|
+
CcsCredential,
|
|
15
|
+
invokeAsync,
|
|
16
|
+
PerformanceEvents,
|
|
17
17
|
} from "@azure/msal-common";
|
|
18
18
|
import {
|
|
19
19
|
createBrowserAuthError,
|
|
@@ -21,37 +21,36 @@ import {
|
|
|
21
21
|
} from "../error/BrowserAuthError";
|
|
22
22
|
import { ApiId, TemporaryCacheKeys } from "../utils/BrowserConstants";
|
|
23
23
|
import { BrowserCacheManager } from "../cache/BrowserCacheManager";
|
|
24
|
-
import { InteractionHandler, InteractionParams } from "./InteractionHandler";
|
|
25
24
|
import { INavigationClient } from "../navigation/INavigationClient";
|
|
26
25
|
import { NavigationOptions } from "../navigation/NavigationOptions";
|
|
27
26
|
import { AuthenticationResult } from "../response/AuthenticationResult";
|
|
28
27
|
|
|
29
|
-
export type RedirectParams =
|
|
28
|
+
export type RedirectParams = {
|
|
30
29
|
navigationClient: INavigationClient;
|
|
31
30
|
redirectTimeout: number;
|
|
32
31
|
redirectStartPage: string;
|
|
33
32
|
onRedirectNavigate?: (url: string) => void | boolean;
|
|
34
33
|
};
|
|
35
34
|
|
|
36
|
-
export class RedirectHandler
|
|
37
|
-
|
|
35
|
+
export class RedirectHandler {
|
|
36
|
+
authModule: AuthorizationCodeClient;
|
|
37
|
+
browserStorage: BrowserCacheManager;
|
|
38
|
+
authCodeRequest: CommonAuthorizationCodeRequest;
|
|
39
|
+
logger: Logger;
|
|
40
|
+
performanceClient: IPerformanceClient;
|
|
38
41
|
|
|
39
42
|
constructor(
|
|
40
43
|
authCodeModule: AuthorizationCodeClient,
|
|
41
44
|
storageImpl: BrowserCacheManager,
|
|
42
45
|
authCodeRequest: CommonAuthorizationCodeRequest,
|
|
43
46
|
logger: Logger,
|
|
44
|
-
browserCrypto: ICrypto,
|
|
45
47
|
performanceClient: IPerformanceClient
|
|
46
48
|
) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
performanceClient
|
|
53
|
-
);
|
|
54
|
-
this.browserCrypto = browserCrypto;
|
|
49
|
+
this.authModule = authCodeModule;
|
|
50
|
+
this.browserStorage = storageImpl;
|
|
51
|
+
this.authCodeRequest = authCodeRequest;
|
|
52
|
+
this.logger = logger;
|
|
53
|
+
this.performanceClient = performanceClient;
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
/**
|
|
@@ -144,9 +143,7 @@ export class RedirectHandler extends InteractionHandler {
|
|
|
144
143
|
*/
|
|
145
144
|
async handleCodeResponseFromHash(
|
|
146
145
|
locationHash: string,
|
|
147
|
-
state: string
|
|
148
|
-
authority: Authority,
|
|
149
|
-
networkModule: INetworkModule
|
|
146
|
+
state: string
|
|
150
147
|
): Promise<AuthenticationResult> {
|
|
151
148
|
this.logger.verbose("RedirectHandler.handleCodeResponse called");
|
|
152
149
|
|
|
@@ -197,10 +194,15 @@ export class RedirectHandler extends InteractionHandler {
|
|
|
197
194
|
|
|
198
195
|
// Check for new cloud instance
|
|
199
196
|
if (authCodeResponse.cloud_instance_host_name) {
|
|
200
|
-
await
|
|
197
|
+
await invokeAsync(
|
|
198
|
+
this.authModule.updateAuthority.bind(this.authModule),
|
|
199
|
+
PerformanceEvents.UpdateTokenEndpointAuthority,
|
|
200
|
+
this.logger,
|
|
201
|
+
this.performanceClient,
|
|
202
|
+
this.authCodeRequest.correlationId
|
|
203
|
+
)(
|
|
201
204
|
authCodeResponse.cloud_instance_host_name,
|
|
202
|
-
|
|
203
|
-
networkModule
|
|
205
|
+
this.authCodeRequest.correlationId
|
|
204
206
|
);
|
|
205
207
|
}
|
|
206
208
|
|
|
@@ -226,4 +228,28 @@ export class RedirectHandler extends InteractionHandler {
|
|
|
226
228
|
this.browserStorage.cleanRequestByState(state);
|
|
227
229
|
return tokenResponse;
|
|
228
230
|
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Looks up ccs creds in the cache
|
|
234
|
+
*/
|
|
235
|
+
protected checkCcsCredentials(): CcsCredential | null {
|
|
236
|
+
// Look up ccs credential in temp cache
|
|
237
|
+
const cachedCcsCred = this.browserStorage.getTemporaryCache(
|
|
238
|
+
TemporaryCacheKeys.CCS_CREDENTIAL,
|
|
239
|
+
true
|
|
240
|
+
);
|
|
241
|
+
if (cachedCcsCred) {
|
|
242
|
+
try {
|
|
243
|
+
return JSON.parse(cachedCcsCred) as CcsCredential;
|
|
244
|
+
} catch (e) {
|
|
245
|
+
this.authModule.logger.error(
|
|
246
|
+
"Cache credential could not be parsed"
|
|
247
|
+
);
|
|
248
|
+
this.authModule.logger.errorPii(
|
|
249
|
+
`Cache credential could not be parsed: ${cachedCcsCred}`
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
229
255
|
}
|