@azure/msal-browser 3.3.0 → 3.5.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.map +1 -1
- package/dist/app/PublicClientNext.mjs +4 -6
- package/dist/app/PublicClientNext.mjs.map +1 -1
- 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.map +1 -1
- package/dist/cache/BrowserCacheManager.mjs +26 -26
- 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.mjs +1 -1
- package/dist/controllers/ControllerFactory.d.ts +2 -8
- package/dist/controllers/ControllerFactory.d.ts.map +1 -1
- package/dist/controllers/ControllerFactory.mjs +21 -38
- 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.mjs +1 -1
- package/dist/controllers/StandardController.d.ts +4 -4
- package/dist/controllers/StandardController.d.ts.map +1 -1
- package/dist/controllers/StandardController.mjs +50 -51
- package/dist/controllers/StandardController.mjs.map +1 -1
- package/dist/controllers/UnknownOperatingContextController.mjs +1 -1
- package/dist/crypto/BrowserCrypto.mjs +1 -1
- package/dist/crypto/CryptoOps.d.ts +2 -2
- package/dist/crypto/CryptoOps.d.ts.map +1 -1
- package/dist/crypto/CryptoOps.mjs +4 -3
- 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.mjs +1 -1
- 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 +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/interaction_client/BaseInteractionClient.d.ts +0 -1
- package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.mjs +2 -3
- package/dist/interaction_client/BaseInteractionClient.mjs.map +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/NativeInteractionClient.mjs +4 -4
- package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
- package/dist/interaction_client/PopupClient.d.ts +1 -12
- package/dist/interaction_client/PopupClient.d.ts.map +1 -1
- package/dist/interaction_client/PopupClient.mjs +28 -111
- package/dist/interaction_client/PopupClient.mjs.map +1 -1
- package/dist/interaction_client/RedirectClient.d.ts +3 -3
- package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
- package/dist/interaction_client/RedirectClient.mjs +59 -50
- 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 +3 -5
- package/dist/interaction_client/SilentAuthCodeClient.mjs.map +1 -1
- package/dist/interaction_client/SilentCacheClient.mjs +1 -1
- package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentIframeClient.mjs +9 -23
- 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.d.ts +1 -6
- package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/StandardInteractionClient.mjs +2 -24
- package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
- 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 +30 -61
- 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 +30 -15
- package/dist/interaction_handler/RedirectHandler.mjs.map +1 -1
- package/dist/interaction_handler/SilentHandler.d.ts +2 -2
- package/dist/interaction_handler/SilentHandler.d.ts.map +1 -1
- package/dist/interaction_handler/SilentHandler.mjs +13 -7
- package/dist/interaction_handler/SilentHandler.mjs.map +1 -1
- package/dist/naa/BridgeError.mjs +1 -1
- package/dist/naa/BridgeProxy.mjs +1 -1
- package/dist/naa/BridgeStatusCode.mjs +1 -1
- package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
- 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.mjs +1 -1
- package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/response/ResponseHandler.d.ts +8 -0
- package/dist/response/ResponseHandler.d.ts.map +1 -0
- package/dist/response/ResponseHandler.mjs +46 -0
- package/dist/response/ResponseHandler.mjs.map +1 -0
- 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.d.ts +7 -14
- package/dist/utils/BrowserProtocolUtils.d.ts.map +1 -1
- package/dist/utils/BrowserProtocolUtils.mjs +17 -30
- package/dist/utils/BrowserProtocolUtils.mjs.map +1 -1
- package/dist/utils/BrowserUtils.mjs +1 -1
- package/lib/msal-browser.cjs +18434 -61
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +3037 -3733
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +68 -66
- package/package.json +2 -2
- package/src/app/PublicClientApplication.ts +4 -3
- package/src/app/PublicClientNext.ts +7 -5
- package/src/cache/BrowserCacheManager.ts +29 -50
- package/src/cache/TokenCache.ts +5 -4
- package/src/controllers/ControllerFactory.ts +30 -49
- package/src/controllers/IController.ts +0 -6
- package/src/controllers/StandardController.ts +70 -85
- package/src/crypto/CryptoOps.ts +5 -3
- package/src/index.ts +1 -0
- package/src/interaction_client/BaseInteractionClient.ts +1 -2
- package/src/interaction_client/NativeInteractionClient.ts +4 -3
- package/src/interaction_client/PopupClient.ts +72 -196
- package/src/interaction_client/RedirectClient.ts +111 -100
- package/src/interaction_client/SilentAuthCodeClient.ts +1 -12
- package/src/interaction_client/SilentIframeClient.ts +17 -44
- package/src/interaction_client/SilentRefreshClient.ts +5 -19
- package/src/interaction_client/StandardInteractionClient.ts +2 -48
- package/src/interaction_handler/InteractionHandler.ts +39 -112
- package/src/interaction_handler/RedirectHandler.ts +52 -30
- package/src/interaction_handler/SilentHandler.ts +12 -5
- package/src/packageMetadata.ts +1 -1
- package/src/response/ResponseHandler.ts +73 -0
- package/src/utils/BrowserProtocolUtils.ts +17 -36
|
@@ -18,6 +18,9 @@ import {
|
|
|
18
18
|
IPerformanceClient,
|
|
19
19
|
PerformanceEvents,
|
|
20
20
|
ProtocolMode,
|
|
21
|
+
invokeAsync,
|
|
22
|
+
ServerResponseType,
|
|
23
|
+
UrlUtils,
|
|
21
24
|
} from "@azure/msal-common";
|
|
22
25
|
import { StandardInteractionClient } from "./StandardInteractionClient";
|
|
23
26
|
import {
|
|
@@ -43,6 +46,7 @@ import { EventHandler } from "../event/EventHandler";
|
|
|
43
46
|
import { INavigationClient } from "../navigation/INavigationClient";
|
|
44
47
|
import { EventError } from "../event/EventMessage";
|
|
45
48
|
import { AuthenticationResult } from "../response/AuthenticationResult";
|
|
49
|
+
import * as ResponseHandler from "../response/ResponseHandler";
|
|
46
50
|
|
|
47
51
|
export class RedirectClient extends StandardInteractionClient {
|
|
48
52
|
protected nativeStorage: BrowserCacheManager;
|
|
@@ -78,19 +82,19 @@ export class RedirectClient extends StandardInteractionClient {
|
|
|
78
82
|
* @param request
|
|
79
83
|
*/
|
|
80
84
|
async acquireToken(request: RedirectRequest): Promise<void> {
|
|
81
|
-
|
|
85
|
+
const validRequest = await invokeAsync(
|
|
86
|
+
this.initializeAuthorizationRequest.bind(this),
|
|
82
87
|
PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
);
|
|
88
|
+
this.logger,
|
|
89
|
+
this.performanceClient,
|
|
90
|
+
this.correlationId
|
|
91
|
+
)(request, InteractionType.Redirect);
|
|
92
|
+
|
|
89
93
|
this.browserStorage.updateCacheEntries(
|
|
90
94
|
validRequest.state,
|
|
91
95
|
validRequest.nonce,
|
|
92
96
|
validRequest.authority,
|
|
93
|
-
validRequest.loginHint ||
|
|
97
|
+
validRequest.loginHint || "",
|
|
94
98
|
validRequest.account || null
|
|
95
99
|
);
|
|
96
100
|
const serverTelemetryManager = this.initializeServerTelemetryManager(
|
|
@@ -113,25 +117,27 @@ export class RedirectClient extends StandardInteractionClient {
|
|
|
113
117
|
|
|
114
118
|
try {
|
|
115
119
|
// Create auth code request and generate PKCE params
|
|
116
|
-
this.performanceClient.setPreQueueTime(
|
|
117
|
-
PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest,
|
|
118
|
-
request.correlationId
|
|
119
|
-
);
|
|
120
120
|
const authCodeRequest: CommonAuthorizationCodeRequest =
|
|
121
|
-
await
|
|
121
|
+
await invokeAsync(
|
|
122
|
+
this.initializeAuthorizationCodeRequest.bind(this),
|
|
123
|
+
PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest,
|
|
124
|
+
this.logger,
|
|
125
|
+
this.performanceClient,
|
|
126
|
+
this.correlationId
|
|
127
|
+
)(validRequest);
|
|
122
128
|
|
|
123
129
|
// Initialize the client
|
|
124
|
-
|
|
130
|
+
const authClient: AuthorizationCodeClient = await invokeAsync(
|
|
131
|
+
this.createAuthCodeClient.bind(this),
|
|
125
132
|
PerformanceEvents.StandardInteractionClientCreateAuthCodeClient,
|
|
126
|
-
|
|
133
|
+
this.logger,
|
|
134
|
+
this.performanceClient,
|
|
135
|
+
this.correlationId
|
|
136
|
+
)(
|
|
137
|
+
serverTelemetryManager,
|
|
138
|
+
validRequest.authority,
|
|
139
|
+
validRequest.azureCloudOptions
|
|
127
140
|
);
|
|
128
|
-
const authClient: AuthorizationCodeClient =
|
|
129
|
-
await this.createAuthCodeClient(
|
|
130
|
-
serverTelemetryManager,
|
|
131
|
-
validRequest.authority,
|
|
132
|
-
validRequest.azureCloudOptions
|
|
133
|
-
);
|
|
134
|
-
this.logger.verbose("Auth code client created");
|
|
135
141
|
|
|
136
142
|
// Create redirect interaction handler.
|
|
137
143
|
const interactionHandler = new RedirectHandler(
|
|
@@ -139,7 +145,6 @@ export class RedirectClient extends StandardInteractionClient {
|
|
|
139
145
|
this.browserStorage,
|
|
140
146
|
authCodeRequest,
|
|
141
147
|
this.logger,
|
|
142
|
-
this.browserCrypto,
|
|
143
148
|
this.performanceClient
|
|
144
149
|
);
|
|
145
150
|
|
|
@@ -199,33 +204,13 @@ export class RedirectClient extends StandardInteractionClient {
|
|
|
199
204
|
);
|
|
200
205
|
return null;
|
|
201
206
|
}
|
|
202
|
-
const
|
|
203
|
-
hash ||
|
|
207
|
+
const [serverParams, responseString] = this.getRedirectResponse(
|
|
208
|
+
hash || ""
|
|
204
209
|
);
|
|
205
|
-
if (!
|
|
210
|
+
if (!serverParams) {
|
|
206
211
|
// Not a recognized server response hash or hash not associated with a redirect request
|
|
207
212
|
this.logger.info(
|
|
208
|
-
"handleRedirectPromise did not detect a response
|
|
209
|
-
);
|
|
210
|
-
this.browserStorage.cleanRequestByInteractionType(
|
|
211
|
-
InteractionType.Redirect
|
|
212
|
-
);
|
|
213
|
-
return null;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
let state: string;
|
|
217
|
-
try {
|
|
218
|
-
// Deserialize hash fragment response parameters.
|
|
219
|
-
const serverParams: ServerAuthorizationCodeResponse =
|
|
220
|
-
UrlString.getDeserializedHash(responseHash);
|
|
221
|
-
state = this.validateAndExtractStateFromHash(
|
|
222
|
-
serverParams,
|
|
223
|
-
InteractionType.Redirect
|
|
224
|
-
);
|
|
225
|
-
this.logger.verbose("State extracted from hash");
|
|
226
|
-
} catch (e) {
|
|
227
|
-
this.logger.info(
|
|
228
|
-
`handleRedirectPromise was unable to extract state due to: ${e}`
|
|
213
|
+
"handleRedirectPromise did not detect a response as a result of a redirect. Cleaning temporary cache."
|
|
229
214
|
);
|
|
230
215
|
this.browserStorage.cleanRequestByInteractionType(
|
|
231
216
|
InteractionType.Redirect
|
|
@@ -251,12 +236,7 @@ export class RedirectClient extends StandardInteractionClient {
|
|
|
251
236
|
) {
|
|
252
237
|
// We are on the page we need to navigate to - handle hash
|
|
253
238
|
this.logger.verbose(
|
|
254
|
-
"Current page is loginRequestUrl, handling
|
|
255
|
-
);
|
|
256
|
-
const handleHashResult = await this.handleHash(
|
|
257
|
-
responseHash,
|
|
258
|
-
state,
|
|
259
|
-
serverTelemetryManager
|
|
239
|
+
"Current page is loginRequestUrl, handling response"
|
|
260
240
|
);
|
|
261
241
|
|
|
262
242
|
if (loginRequestUrl.indexOf("#") > -1) {
|
|
@@ -264,14 +244,18 @@ export class RedirectClient extends StandardInteractionClient {
|
|
|
264
244
|
BrowserUtils.replaceHash(loginRequestUrl);
|
|
265
245
|
}
|
|
266
246
|
|
|
247
|
+
const handleHashResult = await this.handleResponse(
|
|
248
|
+
serverParams,
|
|
249
|
+
serverTelemetryManager
|
|
250
|
+
);
|
|
251
|
+
|
|
267
252
|
return handleHashResult;
|
|
268
253
|
} else if (!this.config.auth.navigateToLoginRequestUrl) {
|
|
269
254
|
this.logger.verbose(
|
|
270
|
-
"NavigateToLoginRequestUrl set to false, handling
|
|
255
|
+
"NavigateToLoginRequestUrl set to false, handling response"
|
|
271
256
|
);
|
|
272
|
-
return this.
|
|
273
|
-
|
|
274
|
-
state,
|
|
257
|
+
return this.handleResponse(
|
|
258
|
+
serverParams,
|
|
275
259
|
serverTelemetryManager
|
|
276
260
|
);
|
|
277
261
|
} else if (
|
|
@@ -284,7 +268,7 @@ export class RedirectClient extends StandardInteractionClient {
|
|
|
284
268
|
*/
|
|
285
269
|
this.browserStorage.setTemporaryCache(
|
|
286
270
|
TemporaryCacheKeys.URL_HASH,
|
|
287
|
-
|
|
271
|
+
responseString,
|
|
288
272
|
true
|
|
289
273
|
);
|
|
290
274
|
const navigationOptions: NavigationOptions = {
|
|
@@ -329,9 +313,8 @@ export class RedirectClient extends StandardInteractionClient {
|
|
|
329
313
|
|
|
330
314
|
// If navigateInternal implementation returns false, handle the hash now
|
|
331
315
|
if (!processHashOnRedirect) {
|
|
332
|
-
return this.
|
|
333
|
-
|
|
334
|
-
state,
|
|
316
|
+
return this.handleResponse(
|
|
317
|
+
serverParams,
|
|
335
318
|
serverTelemetryManager
|
|
336
319
|
);
|
|
337
320
|
}
|
|
@@ -355,18 +338,45 @@ export class RedirectClient extends StandardInteractionClient {
|
|
|
355
338
|
* Returns null if interactionType in the state value is not "redirect" or the hash does not contain known properties
|
|
356
339
|
* @param hash
|
|
357
340
|
*/
|
|
358
|
-
protected
|
|
341
|
+
protected getRedirectResponse(
|
|
342
|
+
userProvidedResponse: string
|
|
343
|
+
): [ServerAuthorizationCodeResponse | null, string] {
|
|
359
344
|
this.logger.verbose("getRedirectResponseHash called");
|
|
360
345
|
// Get current location hash from window or cache.
|
|
361
|
-
|
|
362
|
-
|
|
346
|
+
let responseString = userProvidedResponse;
|
|
347
|
+
if (!responseString) {
|
|
348
|
+
if (
|
|
349
|
+
this.config.auth.OIDCOptions.serverResponseType ===
|
|
350
|
+
ServerResponseType.QUERY
|
|
351
|
+
) {
|
|
352
|
+
responseString = window.location.search;
|
|
353
|
+
} else {
|
|
354
|
+
responseString = window.location.hash;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
let response = UrlUtils.getDeserializedResponse(responseString);
|
|
358
|
+
|
|
359
|
+
if (response) {
|
|
360
|
+
try {
|
|
361
|
+
ResponseHandler.validateInteractionType(
|
|
362
|
+
response,
|
|
363
|
+
this.browserCrypto,
|
|
364
|
+
InteractionType.Redirect
|
|
365
|
+
);
|
|
366
|
+
} catch (e) {
|
|
367
|
+
if (e instanceof AuthError) {
|
|
368
|
+
this.logger.error(
|
|
369
|
+
`Interaction type validation failed due to ${e.errorCode}: ${e.errorMessage}`
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
return [null, ""];
|
|
373
|
+
}
|
|
363
374
|
|
|
364
|
-
if (isResponseHash) {
|
|
365
375
|
BrowserUtils.clearHash(window);
|
|
366
376
|
this.logger.verbose(
|
|
367
377
|
"Hash contains known properties, returning response hash"
|
|
368
378
|
);
|
|
369
|
-
return
|
|
379
|
+
return [response, responseString];
|
|
370
380
|
}
|
|
371
381
|
|
|
372
382
|
const cachedHash = this.browserStorage.getTemporaryCache(
|
|
@@ -377,10 +387,17 @@ export class RedirectClient extends StandardInteractionClient {
|
|
|
377
387
|
this.browserStorage.generateCacheKey(TemporaryCacheKeys.URL_HASH)
|
|
378
388
|
);
|
|
379
389
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
390
|
+
if (cachedHash) {
|
|
391
|
+
response = UrlUtils.getDeserializedResponse(cachedHash);
|
|
392
|
+
if (response) {
|
|
393
|
+
this.logger.verbose(
|
|
394
|
+
"Hash does not contain known properties, returning cached hash"
|
|
395
|
+
);
|
|
396
|
+
return [response, cachedHash];
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
return [null, ""];
|
|
384
401
|
}
|
|
385
402
|
|
|
386
403
|
/**
|
|
@@ -388,16 +405,17 @@ export class RedirectClient extends StandardInteractionClient {
|
|
|
388
405
|
* @param hash
|
|
389
406
|
* @param state
|
|
390
407
|
*/
|
|
391
|
-
protected async
|
|
392
|
-
|
|
393
|
-
state: string,
|
|
408
|
+
protected async handleResponse(
|
|
409
|
+
serverParams: ServerAuthorizationCodeResponse,
|
|
394
410
|
serverTelemetryManager: ServerTelemetryManager
|
|
395
411
|
): Promise<AuthenticationResult> {
|
|
396
|
-
const
|
|
397
|
-
|
|
412
|
+
const state = serverParams.state;
|
|
413
|
+
if (!state) {
|
|
414
|
+
throw createBrowserAuthError(BrowserAuthErrorCodes.noStateInHash);
|
|
415
|
+
}
|
|
398
416
|
|
|
399
|
-
const
|
|
400
|
-
|
|
417
|
+
const cachedRequest = this.browserStorage.getCachedRequest(state);
|
|
418
|
+
this.logger.verbose("handleResponse called, retrieved cached request");
|
|
401
419
|
|
|
402
420
|
if (serverParams.accountId) {
|
|
403
421
|
this.logger.verbose(
|
|
@@ -444,15 +462,15 @@ export class RedirectClient extends StandardInteractionClient {
|
|
|
444
462
|
BrowserAuthErrorCodes.noCachedAuthorityError
|
|
445
463
|
);
|
|
446
464
|
}
|
|
447
|
-
|
|
465
|
+
|
|
466
|
+
const authClient = await invokeAsync(
|
|
467
|
+
this.createAuthCodeClient.bind(this),
|
|
448
468
|
PerformanceEvents.StandardInteractionClientCreateAuthCodeClient,
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
);
|
|
455
|
-
this.logger.verbose("Auth code client created");
|
|
469
|
+
this.logger,
|
|
470
|
+
this.performanceClient,
|
|
471
|
+
this.correlationId
|
|
472
|
+
)(serverTelemetryManager, currentAuthority);
|
|
473
|
+
|
|
456
474
|
ThrottlingUtils.removeThrottle(
|
|
457
475
|
this.browserStorage,
|
|
458
476
|
this.config.auth.clientId,
|
|
@@ -463,15 +481,9 @@ export class RedirectClient extends StandardInteractionClient {
|
|
|
463
481
|
this.browserStorage,
|
|
464
482
|
cachedRequest,
|
|
465
483
|
this.logger,
|
|
466
|
-
this.browserCrypto,
|
|
467
484
|
this.performanceClient
|
|
468
485
|
);
|
|
469
|
-
return await interactionHandler.
|
|
470
|
-
hash,
|
|
471
|
-
state,
|
|
472
|
-
authClient.authority,
|
|
473
|
-
this.networkClient
|
|
474
|
-
);
|
|
486
|
+
return await interactionHandler.handleCodeResponse(serverParams, state);
|
|
475
487
|
}
|
|
476
488
|
|
|
477
489
|
/**
|
|
@@ -501,15 +513,14 @@ export class RedirectClient extends StandardInteractionClient {
|
|
|
501
513
|
timeout: this.config.system.redirectNavigationTimeout,
|
|
502
514
|
noHistory: false,
|
|
503
515
|
};
|
|
504
|
-
|
|
516
|
+
|
|
517
|
+
const authClient = await invokeAsync(
|
|
518
|
+
this.createAuthCodeClient.bind(this),
|
|
505
519
|
PerformanceEvents.StandardInteractionClientCreateAuthCodeClient,
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
logoutRequest && logoutRequest.authority
|
|
511
|
-
);
|
|
512
|
-
this.logger.verbose("Auth code client created");
|
|
520
|
+
this.logger,
|
|
521
|
+
this.performanceClient,
|
|
522
|
+
this.correlationId
|
|
523
|
+
)(serverTelemetryManager, logoutRequest && logoutRequest.authority);
|
|
513
524
|
|
|
514
525
|
if (authClient.authority.protocolMode === ProtocolMode.OIDC) {
|
|
515
526
|
try {
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
Logger,
|
|
9
9
|
CommonAuthorizationCodeRequest,
|
|
10
10
|
AuthError,
|
|
11
|
-
Constants,
|
|
12
11
|
IPerformanceClient,
|
|
13
12
|
PerformanceEvents,
|
|
14
13
|
invokeAsync,
|
|
@@ -81,13 +80,6 @@ export class SilentAuthCodeClient extends StandardInteractionClient {
|
|
|
81
80
|
this.performanceClient,
|
|
82
81
|
request.correlationId
|
|
83
82
|
)(request, InteractionType.Silent);
|
|
84
|
-
this.browserStorage.updateCacheEntries(
|
|
85
|
-
silentRequest.state,
|
|
86
|
-
silentRequest.nonce,
|
|
87
|
-
silentRequest.authority,
|
|
88
|
-
silentRequest.loginHint || Constants.EMPTY_STRING,
|
|
89
|
-
silentRequest.account || null
|
|
90
|
-
);
|
|
91
83
|
|
|
92
84
|
const serverTelemetryManager = this.initializeServerTelemetryManager(
|
|
93
85
|
this.apiId
|
|
@@ -137,9 +129,7 @@ export class SilentAuthCodeClient extends StandardInteractionClient {
|
|
|
137
129
|
cloud_graph_host_name: request.cloudGraphHostName,
|
|
138
130
|
cloud_instance_host_name: request.cloudInstanceHostName,
|
|
139
131
|
},
|
|
140
|
-
silentRequest
|
|
141
|
-
authClient.authority,
|
|
142
|
-
this.networkClient,
|
|
132
|
+
silentRequest,
|
|
143
133
|
false
|
|
144
134
|
);
|
|
145
135
|
} catch (e) {
|
|
@@ -147,7 +137,6 @@ export class SilentAuthCodeClient extends StandardInteractionClient {
|
|
|
147
137
|
(e as AuthError).setCorrelationId(this.correlationId);
|
|
148
138
|
serverTelemetryManager.cacheFailedRequest(e);
|
|
149
139
|
}
|
|
150
|
-
this.browserStorage.cleanRequestByState(silentRequest.state);
|
|
151
140
|
throw e;
|
|
152
141
|
}
|
|
153
142
|
}
|
|
@@ -10,13 +10,11 @@ import {
|
|
|
10
10
|
CommonAuthorizationCodeRequest,
|
|
11
11
|
AuthorizationCodeClient,
|
|
12
12
|
AuthError,
|
|
13
|
-
Constants,
|
|
14
|
-
UrlString,
|
|
15
|
-
ServerAuthorizationCodeResponse,
|
|
16
13
|
ProtocolUtils,
|
|
17
14
|
IPerformanceClient,
|
|
18
15
|
PerformanceEvents,
|
|
19
16
|
invokeAsync,
|
|
17
|
+
invoke,
|
|
20
18
|
} from "@azure/msal-common";
|
|
21
19
|
import { StandardInteractionClient } from "./StandardInteractionClient";
|
|
22
20
|
import { AuthorizationUrlRequest } from "../request/AuthorizationUrlRequest";
|
|
@@ -39,6 +37,7 @@ import { NativeInteractionClient } from "./NativeInteractionClient";
|
|
|
39
37
|
import { AuthenticationResult } from "../response/AuthenticationResult";
|
|
40
38
|
import { InteractionHandler } from "../interaction_handler/InteractionHandler";
|
|
41
39
|
import * as BrowserUtils from "../utils/BrowserUtils";
|
|
40
|
+
import * as ResponseHandler from "../response/ResponseHandler";
|
|
42
41
|
|
|
43
42
|
export class SilentIframeClient extends StandardInteractionClient {
|
|
44
43
|
protected apiId: ApiId;
|
|
@@ -120,13 +119,6 @@ export class SilentIframeClient extends StandardInteractionClient {
|
|
|
120
119
|
InteractionType.Silent
|
|
121
120
|
);
|
|
122
121
|
BrowserUtils.preconnect(silentRequest.authority);
|
|
123
|
-
this.browserStorage.updateCacheEntries(
|
|
124
|
-
silentRequest.state,
|
|
125
|
-
silentRequest.nonce,
|
|
126
|
-
silentRequest.authority,
|
|
127
|
-
silentRequest.loginHint || Constants.EMPTY_STRING,
|
|
128
|
-
silentRequest.account || null
|
|
129
|
-
);
|
|
130
122
|
|
|
131
123
|
const serverTelemetryManager = this.initializeServerTelemetryManager(
|
|
132
124
|
this.apiId
|
|
@@ -158,7 +150,6 @@ export class SilentIframeClient extends StandardInteractionClient {
|
|
|
158
150
|
(e as AuthError).setCorrelationId(this.correlationId);
|
|
159
151
|
serverTelemetryManager.cacheFailedRequest(e);
|
|
160
152
|
}
|
|
161
|
-
this.browserStorage.cleanRequestByState(silentRequest.state);
|
|
162
153
|
throw e;
|
|
163
154
|
}
|
|
164
155
|
}
|
|
@@ -240,8 +231,9 @@ export class SilentIframeClient extends StandardInteractionClient {
|
|
|
240
231
|
correlationId,
|
|
241
232
|
this.config.system.navigateFrameWait
|
|
242
233
|
);
|
|
234
|
+
const responseType = this.config.auth.OIDCOptions.serverResponseType;
|
|
243
235
|
// Monitor the window for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.
|
|
244
|
-
const
|
|
236
|
+
const responseString = await invokeAsync(
|
|
245
237
|
monitorIframeForHash,
|
|
246
238
|
PerformanceEvents.SilentHandlerMonitorIframeForHash,
|
|
247
239
|
this.logger,
|
|
@@ -253,31 +245,16 @@ export class SilentIframeClient extends StandardInteractionClient {
|
|
|
253
245
|
this.config.system.pollIntervalMilliseconds,
|
|
254
246
|
this.performanceClient,
|
|
255
247
|
this.logger,
|
|
256
|
-
correlationId
|
|
257
|
-
|
|
258
|
-
if (!hash) {
|
|
259
|
-
// No hash is present
|
|
260
|
-
this.logger.error(
|
|
261
|
-
"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."
|
|
262
|
-
);
|
|
263
|
-
throw createBrowserAuthError(BrowserAuthErrorCodes.hashEmptyError);
|
|
264
|
-
} else if (!UrlString.hashContainsKnownProperties(hash)) {
|
|
265
|
-
this.logger.error(
|
|
266
|
-
"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."
|
|
267
|
-
);
|
|
268
|
-
this.logger.errorPii(`The hash detected in the iframe is: ${hash}`);
|
|
269
|
-
throw createBrowserAuthError(
|
|
270
|
-
BrowserAuthErrorCodes.hashDoesNotContainKnownProperties
|
|
271
|
-
);
|
|
272
|
-
}
|
|
273
|
-
// Deserialize hash fragment response parameters.
|
|
274
|
-
const serverParams: ServerAuthorizationCodeResponse =
|
|
275
|
-
UrlString.getDeserializedHash(hash);
|
|
276
|
-
const state = this.validateAndExtractStateFromHash(
|
|
277
|
-
serverParams,
|
|
278
|
-
InteractionType.Silent,
|
|
279
|
-
correlationId
|
|
248
|
+
correlationId,
|
|
249
|
+
responseType
|
|
280
250
|
);
|
|
251
|
+
const serverParams = invoke(
|
|
252
|
+
ResponseHandler.deserializeResponse,
|
|
253
|
+
PerformanceEvents.DeserializeResponse,
|
|
254
|
+
this.logger,
|
|
255
|
+
this.performanceClient,
|
|
256
|
+
this.correlationId
|
|
257
|
+
)(responseString, responseType, this.logger);
|
|
281
258
|
|
|
282
259
|
if (serverParams.accountId) {
|
|
283
260
|
this.logger.verbose(
|
|
@@ -304,7 +281,7 @@ export class SilentIframeClient extends StandardInteractionClient {
|
|
|
304
281
|
);
|
|
305
282
|
const { userRequestState } = ProtocolUtils.parseRequestState(
|
|
306
283
|
this.browserCrypto,
|
|
307
|
-
state
|
|
284
|
+
silentRequest.state
|
|
308
285
|
);
|
|
309
286
|
return invokeAsync(
|
|
310
287
|
nativeInteractionClient.acquireToken.bind(
|
|
@@ -318,20 +295,16 @@ export class SilentIframeClient extends StandardInteractionClient {
|
|
|
318
295
|
...silentRequest,
|
|
319
296
|
state: userRequestState,
|
|
320
297
|
prompt: silentRequest.prompt || PromptValue.NONE,
|
|
321
|
-
}).finally(() => {
|
|
322
|
-
this.browserStorage.cleanRequestByState(state);
|
|
323
298
|
});
|
|
324
299
|
}
|
|
325
300
|
|
|
326
301
|
// Handle response from hash string
|
|
327
302
|
return invokeAsync(
|
|
328
|
-
interactionHandler.
|
|
329
|
-
|
|
330
|
-
),
|
|
331
|
-
PerformanceEvents.HandleCodeResponseFromHash,
|
|
303
|
+
interactionHandler.handleCodeResponse.bind(interactionHandler),
|
|
304
|
+
PerformanceEvents.HandleCodeResponse,
|
|
332
305
|
this.logger,
|
|
333
306
|
this.performanceClient,
|
|
334
307
|
correlationId
|
|
335
|
-
)(
|
|
308
|
+
)(serverParams, silentRequest);
|
|
336
309
|
}
|
|
337
310
|
}
|
|
@@ -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
|
/**
|
|
@@ -12,7 +12,6 @@ import {
|
|
|
12
12
|
AuthorityOptions,
|
|
13
13
|
Authority,
|
|
14
14
|
AuthorityFactory,
|
|
15
|
-
ServerAuthorizationCodeResponse,
|
|
16
15
|
UrlString,
|
|
17
16
|
CommonEndSessionRequest,
|
|
18
17
|
ProtocolUtils,
|
|
@@ -28,14 +27,7 @@ import { BaseInteractionClient } from "./BaseInteractionClient";
|
|
|
28
27
|
import { AuthorizationUrlRequest } from "../request/AuthorizationUrlRequest";
|
|
29
28
|
import { BrowserConstants, InteractionType } from "../utils/BrowserConstants";
|
|
30
29
|
import { version } from "../packageMetadata";
|
|
31
|
-
import {
|
|
32
|
-
createBrowserAuthError,
|
|
33
|
-
BrowserAuthErrorCodes,
|
|
34
|
-
} from "../error/BrowserAuthError";
|
|
35
|
-
import {
|
|
36
|
-
BrowserProtocolUtils,
|
|
37
|
-
BrowserStateObject,
|
|
38
|
-
} from "../utils/BrowserProtocolUtils";
|
|
30
|
+
import { BrowserStateObject } from "../utils/BrowserProtocolUtils";
|
|
39
31
|
import { EndSessionRequest } from "../request/EndSessionRequest";
|
|
40
32
|
import * as BrowserUtils from "../utils/BrowserUtils";
|
|
41
33
|
import { RedirectRequest } from "../request/RedirectRequest";
|
|
@@ -57,7 +49,7 @@ export abstract class StandardInteractionClient extends BaseInteractionClient {
|
|
|
57
49
|
): Promise<CommonAuthorizationCodeRequest> {
|
|
58
50
|
this.performanceClient.addQueueMeasurement(
|
|
59
51
|
PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest,
|
|
60
|
-
|
|
52
|
+
this.correlationId
|
|
61
53
|
);
|
|
62
54
|
const generatedPkceParams = await invokeAsync(
|
|
63
55
|
generatePkceCodes,
|
|
@@ -294,44 +286,6 @@ export abstract class StandardInteractionClient extends BaseInteractionClient {
|
|
|
294
286
|
};
|
|
295
287
|
}
|
|
296
288
|
|
|
297
|
-
/**
|
|
298
|
-
* @param hash
|
|
299
|
-
* @param interactionType
|
|
300
|
-
*/
|
|
301
|
-
protected validateAndExtractStateFromHash(
|
|
302
|
-
serverParams: ServerAuthorizationCodeResponse,
|
|
303
|
-
interactionType: InteractionType,
|
|
304
|
-
requestCorrelationId?: string
|
|
305
|
-
): string {
|
|
306
|
-
this.logger.verbose(
|
|
307
|
-
"validateAndExtractStateFromHash called",
|
|
308
|
-
requestCorrelationId
|
|
309
|
-
);
|
|
310
|
-
if (!serverParams.state) {
|
|
311
|
-
throw createBrowserAuthError(BrowserAuthErrorCodes.noStateInHash);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
const platformStateObj =
|
|
315
|
-
BrowserProtocolUtils.extractBrowserRequestState(
|
|
316
|
-
this.browserCrypto,
|
|
317
|
-
serverParams.state
|
|
318
|
-
);
|
|
319
|
-
if (!platformStateObj) {
|
|
320
|
-
throw createBrowserAuthError(
|
|
321
|
-
BrowserAuthErrorCodes.unableToParseState
|
|
322
|
-
);
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
if (platformStateObj.interactionType !== interactionType) {
|
|
326
|
-
throw createBrowserAuthError(
|
|
327
|
-
BrowserAuthErrorCodes.stateInteractionTypeMismatch
|
|
328
|
-
);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
this.logger.verbose("Returning state from hash", requestCorrelationId);
|
|
332
|
-
return serverParams.state;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
289
|
/**
|
|
336
290
|
* Used to get a discovered version of the default authority.
|
|
337
291
|
* @param requestAuthority
|