Skip to content

Commit

Permalink
Merge branch 'dev' into cached-account-change
Browse files Browse the repository at this point in the history
  • Loading branch information
hectormmg authored Oct 11, 2023
2 parents 129b96f + 3f02f79 commit 13ba16d
Show file tree
Hide file tree
Showing 13 changed files with 188 additions and 158 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "Preconnect to authority to speed up /token calls #6550",
"packageName": "@azure/msal-browser",
"email": "[email protected]",
"dependentChangeType": "patch"
}
3 changes: 1 addition & 2 deletions lib/msal-angular/src/msal.guard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { RouterTestingModule } from '@angular/router/testing';
import { Location } from '@angular/common';
import {
BrowserSystemOptions,
BrowserUtils,
InteractionType,
IPublicClientApplication,
LogLevel,
Expand Down Expand Up @@ -102,7 +101,7 @@ describe('MsalGuard', () => {

it('returns false if page with MSAL Guard is set as redirectUri', (done) => {
spyOn(UrlString, 'hashContainsKnownProperties').and.returnValue(true);
spyOn(BrowserUtils, 'isInIframe').and.returnValue(true);
spyOnProperty(window, 'parent', 'get').and.returnValue({ ...window });

guard.canActivate(routeMock, routeStateMock).subscribe((result) => {
expect(result).toBeFalse();
Expand Down
2 changes: 1 addition & 1 deletion lib/msal-browser/src/controllers/StandardController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import {
DEFAULT_REQUEST,
BrowserConstants,
} from "../utils/BrowserConstants";
import { BrowserUtils } from "../utils/BrowserUtils";
import * as BrowserUtils from "../utils/BrowserUtils";
import { RedirectRequest } from "../request/RedirectRequest";
import { PopupRequest } from "../request/PopupRequest";
import { SsoSilentRequest } from "../request/SsoSilentRequest";
Expand Down
7 changes: 2 additions & 5 deletions lib/msal-browser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
* @module @azure/msal-browser
*/

/**
* Warning: This set of exports is purely intended to be used by other MSAL libraries, and should be considered potentially unstable. We strongly discourage using them directly, you do so at your own risk.
* Breaking changes to these APIs will be shipped under a minor version, instead of a major version.
*/
import * as BrowserUtils from "./utils/BrowserUtils";
export { BrowserUtils };

export { PublicClientApplication } from "./app/PublicClientApplication";
export { IController } from "./controllers/IController";
Expand All @@ -32,7 +30,6 @@ export {
ApiId,
CacheLookupPolicy,
} from "./utils/BrowserConstants";
export { BrowserUtils } from "./utils/BrowserUtils";

/*
* export { IController} from "./controllers/IController";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { PopupRequest } from "../request/PopupRequest";
import { SsoSilentRequest } from "../request/SsoSilentRequest";
import { version } from "../packageMetadata";
import { BrowserConstants } from "../utils/BrowserConstants";
import { BrowserUtils } from "../utils/BrowserUtils";
import * as BrowserUtils from "../utils/BrowserUtils";
import { INavigationClient } from "../navigation/INavigationClient";
import { NativeMessageHandler } from "../broker/nativeBroker/NativeMessageHandler";
import { AuthenticationResult } from "../response/AuthenticationResult";
Expand Down
3 changes: 2 additions & 1 deletion lib/msal-browser/src/interaction_client/PopupClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
} from "../utils/BrowserConstants";
import { EndSessionPopupRequest } from "../request/EndSessionPopupRequest";
import { NavigationOptions } from "../navigation/NavigationOptions";
import { BrowserUtils } from "../utils/BrowserUtils";
import * as BrowserUtils from "../utils/BrowserUtils";
import { PopupRequest } from "../request/PopupRequest";
import { NativeInteractionClient } from "./NativeInteractionClient";
import { NativeMessageHandler } from "../broker/nativeBroker/NativeMessageHandler";
Expand Down Expand Up @@ -211,6 +211,7 @@ export class PopupClient extends StandardInteractionClient {
request,
InteractionType.Popup
);
BrowserUtils.preconnect(validRequest.authority);
this.browserStorage.updateCacheEntries(
validRequest.state,
validRequest.nonce,
Expand Down
2 changes: 1 addition & 1 deletion lib/msal-browser/src/interaction_client/RedirectClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
TemporaryCacheKeys,
} from "../utils/BrowserConstants";
import { RedirectHandler } from "../interaction_handler/RedirectHandler";
import { BrowserUtils } from "../utils/BrowserUtils";
import * as BrowserUtils from "../utils/BrowserUtils";
import { EndSessionRequest } from "../request/EndSessionRequest";
import { EventType } from "../event/EventType";
import { NavigationOptions } from "../navigation/NavigationOptions";
Expand Down
2 changes: 2 additions & 0 deletions lib/msal-browser/src/interaction_client/SilentIframeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { SsoSilentRequest } from "../request/SsoSilentRequest";
import { NativeMessageHandler } from "../broker/nativeBroker/NativeMessageHandler";
import { NativeInteractionClient } from "./NativeInteractionClient";
import { AuthenticationResult } from "../response/AuthenticationResult";
import * as BrowserUtils from "../utils/BrowserUtils";

export class SilentIframeClient extends StandardInteractionClient {
protected apiId: ApiId;
Expand Down Expand Up @@ -114,6 +115,7 @@ export class SilentIframeClient extends StandardInteractionClient {
},
InteractionType.Silent
);
BrowserUtils.preconnect(silentRequest.authority);
this.browserStorage.updateCacheEntries(
silentRequest.state,
silentRequest.nonce,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
BrowserStateObject,
} from "../utils/BrowserProtocolUtils";
import { EndSessionRequest } from "../request/EndSessionRequest";
import { BrowserUtils } from "../utils/BrowserUtils";
import * as BrowserUtils from "../utils/BrowserUtils";
import { RedirectRequest } from "../request/RedirectRequest";
import { PopupRequest } from "../request/PopupRequest";
import { SsoSilentRequest } from "../request/SsoSilentRequest";
Expand Down
Loading

1 comment on commit 13ba16d

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'msal-node client-credential Regression Test'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.10.

Benchmark suite Current: 13ba16d Previous: 13b2f8b Ratio
ConfidentialClientApplication#acquireTokenByClientCredential-fromCache-resourceIsFirstItemInTheCache 123544 ops/sec (±1.63%) 155075 ops/sec (±1.35%) 1.26
ConfidentialClientApplication#acquireTokenByClientCredential-fromCache-resourceIsLastItemInTheCache 119231 ops/sec (±1.79%) 151262 ops/sec (±1.46%) 1.27

This comment was automatically generated by workflow using github-action-benchmark.

CC: @bgavrilMS @Robbie-Microsoft

Please sign in to comment.