@azure/msal-browser 3.21.0 → 3.22.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 +1 -1
- package/dist/app/PublicClientNext.mjs +1 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.mjs +1 -1
- package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
- package/dist/cache/AccountManager.mjs +1 -1
- package/dist/cache/AsyncMemoryStorage.mjs +1 -1
- package/dist/cache/BrowserCacheManager.d.ts +0 -25
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.mjs +1 -71
- package/dist/cache/BrowserCacheManager.mjs.map +1 -1
- package/dist/cache/BrowserStorage.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.mjs +1 -1
- package/dist/controllers/ControllerFactory.mjs +1 -1
- package/dist/controllers/NestedAppAuthController.mjs +1 -1
- package/dist/controllers/StandardController.mjs +1 -1
- package/dist/controllers/UnknownOperatingContextController.mjs +1 -1
- package/dist/crypto/BrowserCrypto.mjs +1 -1
- package/dist/crypto/CryptoOps.mjs +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.d.ts +0 -1
- package/dist/error/BrowserAuthError.d.ts.map +1 -1
- package/dist/error/BrowserAuthError.mjs +2 -3
- package/dist/error/BrowserAuthError.mjs.map +1 -1
- package/dist/error/BrowserAuthErrorCodes.d.ts +0 -1
- package/dist/error/BrowserAuthErrorCodes.d.ts.map +1 -1
- package/dist/error/BrowserAuthErrorCodes.mjs +3 -4
- package/dist/error/BrowserAuthErrorCodes.mjs.map +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.mjs +1 -1
- package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
- package/dist/interaction_client/NativeInteractionClient.mjs +1 -1
- package/dist/interaction_client/PopupClient.d.ts +2 -15
- package/dist/interaction_client/PopupClient.d.ts.map +1 -1
- package/dist/interaction_client/PopupClient.mjs +55 -81
- 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 +5 -36
- package/dist/interaction_client/RedirectClient.mjs.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.mjs +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 +3 -3
- package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
- package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
- package/dist/interaction_client/StandardInteractionClient.mjs +1 -1
- package/dist/interaction_handler/InteractionHandler.mjs +1 -1
- package/dist/interaction_handler/RedirectHandler.d.ts.map +1 -1
- package/dist/interaction_handler/RedirectHandler.mjs +1 -2
- package/dist/interaction_handler/RedirectHandler.mjs.map +1 -1
- package/dist/interaction_handler/SilentHandler.mjs +1 -1
- package/dist/naa/BridgeError.mjs +1 -1
- package/dist/naa/BridgeProxy.d.ts.map +1 -1
- package/dist/naa/BridgeProxy.mjs +3 -8
- package/dist/naa/BridgeProxy.mjs.map +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/NestedAppOperatingContext.mjs +1 -1
- package/dist/operatingcontext/StandardOperatingContext.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/request/RequestHelpers.mjs +1 -1
- package/dist/response/ResponseHandler.mjs +1 -1
- package/dist/telemetry/BrowserPerformanceClient.d.ts +0 -4
- package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/BrowserPerformanceClient.mjs +2 -2
- package/dist/telemetry/BrowserPerformanceClient.mjs.map +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
- package/dist/utils/BrowserConstants.d.ts +0 -2
- package/dist/utils/BrowserConstants.d.ts.map +1 -1
- package/dist/utils/BrowserConstants.mjs +1 -3
- package/dist/utils/BrowserConstants.mjs.map +1 -1
- package/dist/utils/BrowserProtocolUtils.mjs +1 -1
- package/dist/utils/BrowserUtils.mjs +1 -1
- package/lib/msal-browser.cjs +287 -428
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +287 -428
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +62 -62
- package/package.json +2 -2
- package/src/cache/BrowserCacheManager.ts +0 -95
- package/src/error/BrowserAuthError.ts +0 -2
- package/src/error/BrowserAuthErrorCodes.ts +0 -1
- package/src/interaction_client/PopupClient.ts +118 -202
- package/src/interaction_client/RedirectClient.ts +1 -58
- package/src/interaction_client/SilentIframeClient.ts +1 -2
- package/src/interaction_handler/RedirectHandler.ts +0 -1
- package/src/naa/BridgeProxy.ts +2 -7
- package/src/packageMetadata.ts +1 -1
- package/src/telemetry/BrowserPerformanceClient.ts +1 -1
- package/src/utils/BrowserConstants.ts +0 -2
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/AzureAD/microsoft-authentication-library-for-js.git"
|
|
12
12
|
},
|
|
13
|
-
"version": "3.
|
|
13
|
+
"version": "3.22.0",
|
|
14
14
|
"description": "Microsoft Authentication Library for js",
|
|
15
15
|
"keywords": [
|
|
16
16
|
"implicit",
|
|
@@ -104,6 +104,6 @@
|
|
|
104
104
|
"typescript": "^4.9.5"
|
|
105
105
|
},
|
|
106
106
|
"dependencies": {
|
|
107
|
-
"@azure/msal-common": "14.14.
|
|
107
|
+
"@azure/msal-common": "14.14.2"
|
|
108
108
|
}
|
|
109
109
|
}
|
|
@@ -1552,9 +1552,6 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
1552
1552
|
this.removeTemporaryItem(
|
|
1553
1553
|
this.generateCacheKey(TemporaryCacheKeys.NATIVE_REQUEST)
|
|
1554
1554
|
);
|
|
1555
|
-
this.removeTemporaryItem(
|
|
1556
|
-
this.generateCacheKey(TemporaryCacheKeys.REDIRECT_REQUEST)
|
|
1557
|
-
);
|
|
1558
1555
|
this.setInteractionInProgress(false);
|
|
1559
1556
|
}
|
|
1560
1557
|
|
|
@@ -1616,98 +1613,6 @@ export class BrowserCacheManager extends CacheManager {
|
|
|
1616
1613
|
this.setInteractionInProgress(false);
|
|
1617
1614
|
}
|
|
1618
1615
|
|
|
1619
|
-
/**
|
|
1620
|
-
* Create request retry key to cache retry status
|
|
1621
|
-
*/
|
|
1622
|
-
generateRequestRetriedKey(): string {
|
|
1623
|
-
return `${Constants.CACHE_PREFIX}.${TemporaryCacheKeys.REQUEST_RETRY}.${this.clientId}`;
|
|
1624
|
-
}
|
|
1625
|
-
|
|
1626
|
-
/**
|
|
1627
|
-
* Gets the request retry value from the cache
|
|
1628
|
-
*/
|
|
1629
|
-
getRequestRetried(): number | null {
|
|
1630
|
-
const requestRetriedKey = this.generateRequestRetriedKey();
|
|
1631
|
-
const cachedRetryNumber = this.getTemporaryCache(requestRetriedKey);
|
|
1632
|
-
if (!cachedRetryNumber) {
|
|
1633
|
-
return null;
|
|
1634
|
-
}
|
|
1635
|
-
return parseInt(cachedRetryNumber);
|
|
1636
|
-
}
|
|
1637
|
-
|
|
1638
|
-
/**
|
|
1639
|
-
* Sets the request retry value to "retried" in the cache
|
|
1640
|
-
*/
|
|
1641
|
-
setRequestRetried(): void {
|
|
1642
|
-
this.logger.trace("BrowserCacheManager.setRequestRetried called");
|
|
1643
|
-
const requestRetriedKey = this.generateRequestRetriedKey();
|
|
1644
|
-
this.setTemporaryCache(requestRetriedKey, "1", false);
|
|
1645
|
-
}
|
|
1646
|
-
|
|
1647
|
-
/**
|
|
1648
|
-
* Removes all request retry values in the cache
|
|
1649
|
-
*/
|
|
1650
|
-
removeRequestRetried(): void {
|
|
1651
|
-
const requestRetriedKey = this.generateRequestRetriedKey();
|
|
1652
|
-
this.removeTemporaryItem(requestRetriedKey);
|
|
1653
|
-
}
|
|
1654
|
-
|
|
1655
|
-
/**
|
|
1656
|
-
* Caches the redirectRequest in the cache
|
|
1657
|
-
* @param redirectRequest
|
|
1658
|
-
*/
|
|
1659
|
-
cacheRedirectRequest(redirectRequest: RedirectRequest): void {
|
|
1660
|
-
this.logger.trace("BrowserCacheManager.cacheRedirectRequest called");
|
|
1661
|
-
const { ...restParams } = redirectRequest;
|
|
1662
|
-
delete restParams.onRedirectNavigate;
|
|
1663
|
-
const encodedValue = JSON.stringify(restParams);
|
|
1664
|
-
|
|
1665
|
-
this.setTemporaryCache(
|
|
1666
|
-
TemporaryCacheKeys.REDIRECT_REQUEST,
|
|
1667
|
-
encodedValue,
|
|
1668
|
-
true
|
|
1669
|
-
);
|
|
1670
|
-
}
|
|
1671
|
-
|
|
1672
|
-
/**
|
|
1673
|
-
* Gets redirect request from the cache. Logs an error and returns undefined if nothing is found.
|
|
1674
|
-
*/
|
|
1675
|
-
getCachedRedirectRequest(): RedirectRequest | undefined {
|
|
1676
|
-
this.logger.trace(
|
|
1677
|
-
"BrowserCacheManager.getCachedRedirectRequest called"
|
|
1678
|
-
);
|
|
1679
|
-
const cachedRedirectRequest = this.getTemporaryCache(
|
|
1680
|
-
TemporaryCacheKeys.REDIRECT_REQUEST,
|
|
1681
|
-
true
|
|
1682
|
-
);
|
|
1683
|
-
if (!cachedRedirectRequest) {
|
|
1684
|
-
this.logger.error(`No cached redirect request found.`);
|
|
1685
|
-
} else {
|
|
1686
|
-
this.removeTemporaryItem(
|
|
1687
|
-
this.generateCacheKey(TemporaryCacheKeys.REDIRECT_REQUEST)
|
|
1688
|
-
);
|
|
1689
|
-
let parsedRequest: RedirectRequest;
|
|
1690
|
-
try {
|
|
1691
|
-
parsedRequest = JSON.parse(
|
|
1692
|
-
cachedRedirectRequest
|
|
1693
|
-
) as RedirectRequest;
|
|
1694
|
-
} catch (e) {
|
|
1695
|
-
this.logger.errorPii(
|
|
1696
|
-
`Attempted to parse: ${cachedRedirectRequest}`
|
|
1697
|
-
);
|
|
1698
|
-
this.logger.error(
|
|
1699
|
-
`Parsing cached redirect request threw with error: ${e}`
|
|
1700
|
-
);
|
|
1701
|
-
return;
|
|
1702
|
-
}
|
|
1703
|
-
|
|
1704
|
-
if (parsedRequest) {
|
|
1705
|
-
return parsedRequest;
|
|
1706
|
-
}
|
|
1707
|
-
}
|
|
1708
|
-
return;
|
|
1709
|
-
}
|
|
1710
|
-
|
|
1711
1616
|
cacheCodeRequest(authCodeRequest: CommonAuthorizationCodeRequest): void {
|
|
1712
1617
|
this.logger.trace("BrowserCacheManager.cacheCodeRequest called");
|
|
1713
1618
|
|
|
@@ -92,8 +92,6 @@ export const BrowserAuthErrorMessages = {
|
|
|
92
92
|
"Invalid base64 encoded string.",
|
|
93
93
|
[BrowserAuthErrorCodes.invalidPopTokenRequest]:
|
|
94
94
|
"Invalid PoP token request. The request should not have both a popKid value and signPopToken set to true.",
|
|
95
|
-
[BrowserAuthErrorCodes.failedToRetry]:
|
|
96
|
-
"Unable to retry failed auth code redemption due to usage of the onRedirectNavigate request parameter. Please set onRedirectNavigate on the PublicClientApplication configuration instead or call loginRedirect again.",
|
|
97
95
|
};
|
|
98
96
|
|
|
99
97
|
/**
|
|
@@ -56,4 +56,3 @@ export const uninitializedPublicClientApplication =
|
|
|
56
56
|
export const nativePromptNotSupported = "native_prompt_not_supported";
|
|
57
57
|
export const invalidBase64String = "invalid_base64_string";
|
|
58
58
|
export const invalidPopTokenRequest = "invalid_pop_token_request";
|
|
59
|
-
export const failedToRetry = "failed_to_retry";
|
|
@@ -20,7 +20,6 @@ import {
|
|
|
20
20
|
ServerResponseType,
|
|
21
21
|
invokeAsync,
|
|
22
22
|
invoke,
|
|
23
|
-
ServerError,
|
|
24
23
|
} from "@azure/msal-common";
|
|
25
24
|
import { StandardInteractionClient } from "./StandardInteractionClient";
|
|
26
25
|
import { EventType } from "../event/EventType";
|
|
@@ -48,7 +47,6 @@ import { PopupWindowAttributes } from "../request/PopupWindowAttributes";
|
|
|
48
47
|
import { EventError } from "../event/EventMessage";
|
|
49
48
|
import { AuthenticationResult } from "../response/AuthenticationResult";
|
|
50
49
|
import * as ResponseHandler from "../response/ResponseHandler";
|
|
51
|
-
import { AuthorizationUrlRequest } from "../request/AuthorizationUrlRequest";
|
|
52
50
|
|
|
53
51
|
export type PopupParams = {
|
|
54
52
|
popup?: Window | null;
|
|
@@ -184,7 +182,7 @@ export class PopupClient extends StandardInteractionClient {
|
|
|
184
182
|
}
|
|
185
183
|
|
|
186
184
|
/**
|
|
187
|
-
* Helper which
|
|
185
|
+
* Helper which obtains an access_token for your API via opening a popup window in the user's browser
|
|
188
186
|
* @param validRequest
|
|
189
187
|
* @param popupName
|
|
190
188
|
* @param popup
|
|
@@ -213,20 +211,19 @@ export class PopupClient extends StandardInteractionClient {
|
|
|
213
211
|
|
|
214
212
|
BrowserUtils.preconnect(validRequest.authority);
|
|
215
213
|
|
|
216
|
-
let authClient: AuthorizationCodeClient | undefined;
|
|
217
|
-
|
|
218
214
|
try {
|
|
219
215
|
// Create auth code request and generate PKCE params
|
|
220
|
-
const authCodeRequest =
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
216
|
+
const authCodeRequest: CommonAuthorizationCodeRequest =
|
|
217
|
+
await invokeAsync(
|
|
218
|
+
this.initializeAuthorizationCodeRequest.bind(this),
|
|
219
|
+
PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest,
|
|
220
|
+
this.logger,
|
|
221
|
+
this.performanceClient,
|
|
222
|
+
this.correlationId
|
|
223
|
+
)(validRequest);
|
|
227
224
|
|
|
228
225
|
// Initialize the client
|
|
229
|
-
authClient = await invokeAsync(
|
|
226
|
+
const authClient: AuthorizationCodeClient = await invokeAsync(
|
|
230
227
|
this.createAuthCodeClient.bind(this),
|
|
231
228
|
PerformanceEvents.StandardInteractionClientCreateAuthCodeClient,
|
|
232
229
|
this.logger,
|
|
@@ -239,218 +236,137 @@ export class PopupClient extends StandardInteractionClient {
|
|
|
239
236
|
validRequest.account
|
|
240
237
|
);
|
|
241
238
|
|
|
242
|
-
|
|
243
|
-
this.
|
|
244
|
-
PerformanceEvents.PopupClientTokenHelper,
|
|
239
|
+
const isNativeBroker = NativeMessageHandler.isNativeAvailable(
|
|
240
|
+
this.config,
|
|
245
241
|
this.logger,
|
|
246
|
-
this.
|
|
247
|
-
|
|
248
|
-
)(
|
|
249
|
-
authClient,
|
|
250
|
-
authCodeRequest,
|
|
251
|
-
validRequest,
|
|
252
|
-
request,
|
|
253
|
-
popupName,
|
|
254
|
-
popupWindowAttributes,
|
|
255
|
-
popup
|
|
242
|
+
this.nativeMessageHandler,
|
|
243
|
+
request.authenticationScheme
|
|
256
244
|
);
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
245
|
+
// Start measurement for server calls with native brokering enabled
|
|
246
|
+
let fetchNativeAccountIdMeasurement;
|
|
247
|
+
if (isNativeBroker) {
|
|
248
|
+
fetchNativeAccountIdMeasurement =
|
|
249
|
+
this.performanceClient.startMeasurement(
|
|
250
|
+
PerformanceEvents.FetchAccountIdWithNativeBroker,
|
|
251
|
+
request.correlationId
|
|
252
|
+
);
|
|
261
253
|
}
|
|
262
254
|
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
255
|
+
// Create acquire token url.
|
|
256
|
+
const navigateUrl = await authClient.getAuthCodeUrl({
|
|
257
|
+
...validRequest,
|
|
258
|
+
nativeBroker: isNativeBroker,
|
|
259
|
+
});
|
|
267
260
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
261
|
+
// Create popup interaction handler.
|
|
262
|
+
const interactionHandler = new InteractionHandler(
|
|
263
|
+
authClient,
|
|
264
|
+
this.browserStorage,
|
|
265
|
+
authCodeRequest,
|
|
266
|
+
this.logger,
|
|
267
|
+
this.performanceClient
|
|
268
|
+
);
|
|
275
269
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
270
|
+
// Show the UI once the url has been created. Get the window handle for the popup.
|
|
271
|
+
const popupParameters: PopupParams = {
|
|
272
|
+
popup,
|
|
273
|
+
popupName,
|
|
274
|
+
popupWindowAttributes,
|
|
275
|
+
};
|
|
276
|
+
const popupWindow: Window = this.initiateAuthRequest(
|
|
277
|
+
navigateUrl,
|
|
278
|
+
popupParameters
|
|
279
|
+
);
|
|
280
|
+
this.eventHandler.emitEvent(
|
|
281
|
+
EventType.POPUP_OPENED,
|
|
282
|
+
InteractionType.Popup,
|
|
283
|
+
{ popupWindow },
|
|
284
|
+
null
|
|
281
285
|
);
|
|
282
286
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest,
|
|
286
|
-
this.logger,
|
|
287
|
-
this.performanceClient,
|
|
288
|
-
this.correlationId
|
|
289
|
-
)(validRequest);
|
|
287
|
+
// Monitor the window for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.
|
|
288
|
+
const responseString = await this.monitorPopupForHash(popupWindow);
|
|
290
289
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
PerformanceEvents.
|
|
290
|
+
const serverParams = invoke(
|
|
291
|
+
ResponseHandler.deserializeResponse,
|
|
292
|
+
PerformanceEvents.DeserializeResponse,
|
|
294
293
|
this.logger,
|
|
295
294
|
this.performanceClient,
|
|
296
295
|
this.correlationId
|
|
297
296
|
)(
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
297
|
+
responseString,
|
|
298
|
+
this.config.auth.OIDCOptions.serverResponseType,
|
|
299
|
+
this.logger
|
|
300
|
+
);
|
|
301
|
+
// Remove throttle if it exists
|
|
302
|
+
ThrottlingUtils.removeThrottle(
|
|
303
|
+
this.browserStorage,
|
|
304
|
+
this.config.auth.clientId,
|
|
305
|
+
authCodeRequest
|
|
305
306
|
);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/**
|
|
310
|
-
* Helper which obtains an access_token for your API via opening a popup window in the user's browser
|
|
311
|
-
* @param authClient
|
|
312
|
-
* @param authCodeRequest
|
|
313
|
-
* @param validRequest
|
|
314
|
-
* @param request
|
|
315
|
-
* @param popupName
|
|
316
|
-
* @param popupWindowAttributes
|
|
317
|
-
* @param popup
|
|
318
|
-
* @returns A promise that is fulfilled when this function has completed, or rejected if an error was raised.
|
|
319
|
-
*/
|
|
320
|
-
protected async acquireTokenPopupAsyncHelper(
|
|
321
|
-
authClient: AuthorizationCodeClient,
|
|
322
|
-
authCodeRequest: CommonAuthorizationCodeRequest,
|
|
323
|
-
validRequest: AuthorizationUrlRequest,
|
|
324
|
-
request: PopupRequest,
|
|
325
|
-
popupName: string,
|
|
326
|
-
popupWindowAttributes: PopupWindowAttributes,
|
|
327
|
-
popup?: Window | null
|
|
328
|
-
): Promise<AuthenticationResult> {
|
|
329
|
-
const correlationId = validRequest.correlationId;
|
|
330
|
-
this.performanceClient.addQueueMeasurement(
|
|
331
|
-
PerformanceEvents.PopupClientTokenHelper,
|
|
332
|
-
correlationId
|
|
333
|
-
);
|
|
334
|
-
|
|
335
|
-
const isNativeBroker = NativeMessageHandler.isNativeAvailable(
|
|
336
|
-
this.config,
|
|
337
|
-
this.logger,
|
|
338
|
-
this.nativeMessageHandler,
|
|
339
|
-
request.authenticationScheme
|
|
340
|
-
);
|
|
341
307
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
fetchNativeAccountIdMeasurement =
|
|
346
|
-
this.performanceClient.startMeasurement(
|
|
347
|
-
PerformanceEvents.FetchAccountIdWithNativeBroker,
|
|
348
|
-
request.correlationId
|
|
308
|
+
if (serverParams.accountId) {
|
|
309
|
+
this.logger.verbose(
|
|
310
|
+
"Account id found in hash, calling WAM for token"
|
|
349
311
|
);
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
// Create popup interaction handler.
|
|
359
|
-
const interactionHandler = new InteractionHandler(
|
|
360
|
-
authClient,
|
|
361
|
-
this.browserStorage,
|
|
362
|
-
authCodeRequest,
|
|
363
|
-
this.logger,
|
|
364
|
-
this.performanceClient
|
|
365
|
-
);
|
|
366
|
-
|
|
367
|
-
// Show the UI once the url has been created. Get the window handle for the popup.
|
|
368
|
-
const popupParameters: PopupParams = {
|
|
369
|
-
popup,
|
|
370
|
-
popupName,
|
|
371
|
-
popupWindowAttributes,
|
|
372
|
-
};
|
|
373
|
-
const popupWindow: Window = this.initiateAuthRequest(
|
|
374
|
-
navigateUrl,
|
|
375
|
-
popupParameters
|
|
376
|
-
);
|
|
377
|
-
this.eventHandler.emitEvent(
|
|
378
|
-
EventType.POPUP_OPENED,
|
|
379
|
-
InteractionType.Popup,
|
|
380
|
-
{ popupWindow },
|
|
381
|
-
null
|
|
382
|
-
);
|
|
383
|
-
|
|
384
|
-
// Monitor the window for the hash. Return the string value and close the popup when the hash is received. Default timeout is 60 seconds.
|
|
385
|
-
const responseString = await this.monitorPopupForHash(popupWindow);
|
|
386
|
-
|
|
387
|
-
const serverParams = invoke(
|
|
388
|
-
ResponseHandler.deserializeResponse,
|
|
389
|
-
PerformanceEvents.DeserializeResponse,
|
|
390
|
-
this.logger,
|
|
391
|
-
this.performanceClient,
|
|
392
|
-
this.correlationId
|
|
393
|
-
)(
|
|
394
|
-
responseString,
|
|
395
|
-
this.config.auth.OIDCOptions.serverResponseType,
|
|
396
|
-
this.logger
|
|
397
|
-
);
|
|
398
|
-
// Remove throttle if it exists
|
|
399
|
-
ThrottlingUtils.removeThrottle(
|
|
400
|
-
this.browserStorage,
|
|
401
|
-
this.config.auth.clientId,
|
|
402
|
-
authCodeRequest
|
|
403
|
-
);
|
|
312
|
+
// end measurement for server call with native brokering enabled
|
|
313
|
+
if (fetchNativeAccountIdMeasurement) {
|
|
314
|
+
fetchNativeAccountIdMeasurement.end({
|
|
315
|
+
success: true,
|
|
316
|
+
isNativeBroker: true,
|
|
317
|
+
});
|
|
318
|
+
}
|
|
404
319
|
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
320
|
+
if (!this.nativeMessageHandler) {
|
|
321
|
+
throw createBrowserAuthError(
|
|
322
|
+
BrowserAuthErrorCodes.nativeConnectionNotEstablished
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
const nativeInteractionClient = new NativeInteractionClient(
|
|
326
|
+
this.config,
|
|
327
|
+
this.browserStorage,
|
|
328
|
+
this.browserCrypto,
|
|
329
|
+
this.logger,
|
|
330
|
+
this.eventHandler,
|
|
331
|
+
this.navigationClient,
|
|
332
|
+
ApiId.acquireTokenPopup,
|
|
333
|
+
this.performanceClient,
|
|
334
|
+
this.nativeMessageHandler,
|
|
335
|
+
serverParams.accountId,
|
|
336
|
+
this.nativeStorage,
|
|
337
|
+
validRequest.correlationId
|
|
338
|
+
);
|
|
339
|
+
const { userRequestState } = ProtocolUtils.parseRequestState(
|
|
340
|
+
this.browserCrypto,
|
|
341
|
+
validRequest.state
|
|
342
|
+
);
|
|
343
|
+
return await nativeInteractionClient.acquireToken({
|
|
344
|
+
...validRequest,
|
|
345
|
+
state: userRequestState,
|
|
346
|
+
prompt: undefined, // Server should handle the prompt, ideally native broker can do this part silently
|
|
414
347
|
});
|
|
415
348
|
}
|
|
416
349
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
}
|
|
422
|
-
const nativeInteractionClient = new NativeInteractionClient(
|
|
423
|
-
this.config,
|
|
424
|
-
this.browserStorage,
|
|
425
|
-
this.browserCrypto,
|
|
426
|
-
this.logger,
|
|
427
|
-
this.eventHandler,
|
|
428
|
-
this.navigationClient,
|
|
429
|
-
ApiId.acquireTokenPopup,
|
|
430
|
-
this.performanceClient,
|
|
431
|
-
this.nativeMessageHandler,
|
|
432
|
-
serverParams.accountId,
|
|
433
|
-
this.nativeStorage,
|
|
434
|
-
validRequest.correlationId
|
|
435
|
-
);
|
|
436
|
-
const { userRequestState } = ProtocolUtils.parseRequestState(
|
|
437
|
-
this.browserCrypto,
|
|
438
|
-
validRequest.state
|
|
350
|
+
// Handle response from hash string.
|
|
351
|
+
const result = await interactionHandler.handleCodeResponse(
|
|
352
|
+
serverParams,
|
|
353
|
+
validRequest
|
|
439
354
|
);
|
|
440
|
-
return nativeInteractionClient.acquireToken({
|
|
441
|
-
...validRequest,
|
|
442
|
-
state: userRequestState,
|
|
443
|
-
prompt: undefined, // Server should handle the prompt, ideally native broker can do this part silently
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
355
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
356
|
+
return result;
|
|
357
|
+
} catch (e) {
|
|
358
|
+
if (popup) {
|
|
359
|
+
// Close the synchronous popup if an error is thrown before the window unload event is registered
|
|
360
|
+
popup.close();
|
|
361
|
+
}
|
|
452
362
|
|
|
453
|
-
|
|
363
|
+
if (e instanceof AuthError) {
|
|
364
|
+
(e as AuthError).setCorrelationId(this.correlationId);
|
|
365
|
+
serverTelemetryManager.cacheFailedRequest(e);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
throw e;
|
|
369
|
+
}
|
|
454
370
|
}
|
|
455
371
|
|
|
456
372
|
/**
|
|
@@ -22,12 +22,10 @@ import {
|
|
|
22
22
|
ServerResponseType,
|
|
23
23
|
UrlUtils,
|
|
24
24
|
InProgressPerformanceEvent,
|
|
25
|
-
ServerError,
|
|
26
25
|
} from "@azure/msal-common";
|
|
27
26
|
import { StandardInteractionClient } from "./StandardInteractionClient";
|
|
28
27
|
import {
|
|
29
28
|
ApiId,
|
|
30
|
-
BrowserConstants,
|
|
31
29
|
InteractionType,
|
|
32
30
|
TemporaryCacheKeys,
|
|
33
31
|
} from "../utils/BrowserConstants";
|
|
@@ -85,14 +83,6 @@ export class RedirectClient extends StandardInteractionClient {
|
|
|
85
83
|
* @param request
|
|
86
84
|
*/
|
|
87
85
|
async acquireToken(request: RedirectRequest): Promise<void> {
|
|
88
|
-
if (request.onRedirectNavigate) {
|
|
89
|
-
this.logger.warning(
|
|
90
|
-
"Unable to cache redirect request, onRedirectNavigate request option has been deprecated. Please set onRedirectNavigate on PublicClientApplication config instead."
|
|
91
|
-
);
|
|
92
|
-
} else {
|
|
93
|
-
this.browserStorage.cacheRedirectRequest(request);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
86
|
const validRequest = await invokeAsync(
|
|
97
87
|
this.initializeAuthorizationRequest.bind(this),
|
|
98
88
|
PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest,
|
|
@@ -344,57 +334,10 @@ export class RedirectClient extends StandardInteractionClient {
|
|
|
344
334
|
(e as AuthError).setCorrelationId(this.correlationId);
|
|
345
335
|
serverTelemetryManager.cacheFailedRequest(e);
|
|
346
336
|
}
|
|
347
|
-
|
|
348
|
-
if (
|
|
349
|
-
e instanceof ServerError &&
|
|
350
|
-
e.errorCode === BrowserConstants.INVALID_GRANT_ERROR
|
|
351
|
-
) {
|
|
352
|
-
this.performanceClient.addFields(
|
|
353
|
-
{
|
|
354
|
-
retryError: e.errorCode,
|
|
355
|
-
},
|
|
356
|
-
this.correlationId
|
|
357
|
-
);
|
|
358
|
-
|
|
359
|
-
const requestRetried = this.browserStorage.getRequestRetried();
|
|
360
|
-
|
|
361
|
-
if (requestRetried) {
|
|
362
|
-
this.logger.error(
|
|
363
|
-
"Retried request already detected. Throwing error."
|
|
364
|
-
);
|
|
365
|
-
this.browserStorage.removeRequestRetried();
|
|
366
|
-
throw e;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
const redirectRequest =
|
|
370
|
-
this.browserStorage.getCachedRedirectRequest();
|
|
371
|
-
if (!redirectRequest) {
|
|
372
|
-
this.logger.error(
|
|
373
|
-
"Unable to retry. Please retry with redirect request"
|
|
374
|
-
);
|
|
375
|
-
this.browserStorage.setRequestRetried();
|
|
376
|
-
throw createBrowserAuthError(
|
|
377
|
-
BrowserAuthErrorCodes.failedToRetry
|
|
378
|
-
);
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
this.browserStorage.setRequestRetried();
|
|
382
|
-
|
|
383
|
-
await this.acquireToken(redirectRequest);
|
|
384
|
-
return null;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
this.browserStorage.removeTemporaryItem(
|
|
388
|
-
this.browserStorage.generateCacheKey(
|
|
389
|
-
TemporaryCacheKeys.REDIRECT_REQUEST
|
|
390
|
-
)
|
|
391
|
-
);
|
|
392
|
-
this.browserStorage.removeRequestRetried();
|
|
393
|
-
throw e;
|
|
394
|
-
} finally {
|
|
395
337
|
this.browserStorage.cleanRequestByInteractionType(
|
|
396
338
|
InteractionType.Redirect
|
|
397
339
|
);
|
|
340
|
+
throw e;
|
|
398
341
|
}
|
|
399
342
|
}
|
|
400
343
|
|
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
PerformanceEvents,
|
|
16
16
|
invokeAsync,
|
|
17
17
|
invoke,
|
|
18
|
-
ServerError,
|
|
19
18
|
} from "@azure/msal-common";
|
|
20
19
|
import { StandardInteractionClient } from "./StandardInteractionClient";
|
|
21
20
|
import { AuthorizationUrlRequest } from "../request/AuthorizationUrlRequest";
|
|
@@ -160,7 +159,7 @@ export class SilentIframeClient extends StandardInteractionClient {
|
|
|
160
159
|
|
|
161
160
|
if (
|
|
162
161
|
!authClient ||
|
|
163
|
-
!(e instanceof
|
|
162
|
+
!(e instanceof AuthError) ||
|
|
164
163
|
e.errorCode !== BrowserConstants.INVALID_GRANT_ERROR
|
|
165
164
|
) {
|
|
166
165
|
throw e;
|
package/src/naa/BridgeProxy.ts
CHANGED
|
@@ -16,7 +16,6 @@ import { IBridgeProxy } from "./IBridgeProxy";
|
|
|
16
16
|
import { InitContext } from "./InitContext";
|
|
17
17
|
import { TokenRequest } from "./TokenRequest";
|
|
18
18
|
import * as BrowserCrypto from "../crypto/BrowserCrypto";
|
|
19
|
-
import { supportsBrowserPerformanceNow } from "../telemetry/BrowserPerformanceClient";
|
|
20
19
|
|
|
21
20
|
declare global {
|
|
22
21
|
interface Window {
|
|
@@ -82,9 +81,7 @@ export class BridgeProxy implements IBridgeProxy {
|
|
|
82
81
|
messageType: "NestedAppAuthRequest",
|
|
83
82
|
method: "GetInitContext",
|
|
84
83
|
requestId: BrowserCrypto.createNewGuid(),
|
|
85
|
-
sendTime:
|
|
86
|
-
? window.performance.now()
|
|
87
|
-
: Date.now(),
|
|
84
|
+
sendTime: Date.now(),
|
|
88
85
|
};
|
|
89
86
|
const request: BridgeRequest = {
|
|
90
87
|
requestId: message.requestId,
|
|
@@ -160,9 +157,7 @@ export class BridgeProxy implements IBridgeProxy {
|
|
|
160
157
|
messageType: "NestedAppAuthRequest",
|
|
161
158
|
method: method,
|
|
162
159
|
requestId: BrowserCrypto.createNewGuid(),
|
|
163
|
-
sendTime:
|
|
164
|
-
? window.performance.now()
|
|
165
|
-
: Date.now(),
|
|
160
|
+
sendTime: Date.now(),
|
|
166
161
|
...requestParams,
|
|
167
162
|
};
|
|
168
163
|
|
package/src/packageMetadata.ts
CHANGED