diff --git a/change/@azure-msal-browser-08e8affc-ae18-41c2-821d-112c37fbdbdb.json b/change/@azure-msal-browser-08e8affc-ae18-41c2-821d-112c37fbdbdb.json new file mode 100644 index 0000000000..bb20de401b --- /dev/null +++ b/change/@azure-msal-browser-08e8affc-ae18-41c2-821d-112c37fbdbdb.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "Remove isBroker flag from initialize, #8075 ", + "packageName": "@azure/msal-browser", + "email": "thomas.norling@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/lib/msal-browser/apiReview/msal-browser.api.md b/lib/msal-browser/apiReview/msal-browser.api.md index 64595b085a..b6da7e017c 100644 --- a/lib/msal-browser/apiReview/msal-browser.api.md +++ b/lib/msal-browser/apiReview/msal-browser.api.md @@ -743,7 +743,7 @@ export interface IController { // (undocumented) hydrateCache(result: AuthenticationResult, request: SilentRequest | SsoSilentRequest | RedirectRequest | PopupRequest): Promise; // (undocumented) - initialize(request?: InitializeApplicationRequest, isBroker?: boolean): Promise; + initialize(request?: InitializeApplicationRequest): Promise; // (undocumented) initializeWrapperLibrary(sku: WrapperSKU, version: string): void; // @internal (undocumented) diff --git a/lib/msal-browser/src/app/PublicClientApplication.ts b/lib/msal-browser/src/app/PublicClientApplication.ts index 3da723eaf3..5b89d46aae 100644 --- a/lib/msal-browser/src/app/PublicClientApplication.ts +++ b/lib/msal-browser/src/app/PublicClientApplication.ts @@ -96,7 +96,7 @@ export class PublicClientApplication implements IPublicClientApplication { * @param request {?InitializeApplicationRequest} */ async initialize(request?: InitializeApplicationRequest): Promise { - return this.controller.initialize(request, this.isBroker); + return this.controller.initialize(request); } /** diff --git a/lib/msal-browser/src/controllers/IController.ts b/lib/msal-browser/src/controllers/IController.ts index 41c46df22c..9fe7f5181d 100644 --- a/lib/msal-browser/src/controllers/IController.ts +++ b/lib/msal-browser/src/controllers/IController.ts @@ -28,10 +28,7 @@ import { EventType } from "../event/EventType.js"; export interface IController { // TODO: Make request mandatory in the next major version? - initialize( - request?: InitializeApplicationRequest, - isBroker?: boolean - ): Promise; + initialize(request?: InitializeApplicationRequest): Promise; acquireTokenPopup(request: PopupRequest): Promise; diff --git a/lib/msal-browser/src/controllers/NestedAppAuthController.ts b/lib/msal-browser/src/controllers/NestedAppAuthController.ts index 60e44a7835..552a27b893 100644 --- a/lib/msal-browser/src/controllers/NestedAppAuthController.ts +++ b/lib/msal-browser/src/controllers/NestedAppAuthController.ts @@ -157,11 +157,7 @@ export class NestedAppAuthController implements IController { * Specific implementation of initialize function for NestedAppAuthController * @returns */ - async initialize( - request?: InitializeApplicationRequest, - // eslint-disable-next-line @typescript-eslint/no-unused-vars - isBroker?: boolean - ): Promise { + async initialize(request?: InitializeApplicationRequest): Promise { const initCorrelationId = request?.correlationId || createNewGuid(); await this.browserStorage.initialize(initCorrelationId); return Promise.resolve(); diff --git a/lib/msal-browser/src/controllers/StandardController.ts b/lib/msal-browser/src/controllers/StandardController.ts index 1d2a36e6fd..2c7d2aae98 100644 --- a/lib/msal-browser/src/controllers/StandardController.ts +++ b/lib/msal-browser/src/controllers/StandardController.ts @@ -286,10 +286,7 @@ export class StandardController implements IController { * Initializer function to perform async startup tasks such as connecting to WAM extension * @param request {?InitializeApplicationRequest} correlation id */ - async initialize( - request?: InitializeApplicationRequest, - isBroker?: boolean - ): Promise { + async initialize(request?: InitializeApplicationRequest): Promise { const correlationId = this.getRequestCorrelationId(request); this.logger.trace("initialize called", correlationId); if (this.initialized) { @@ -319,12 +316,7 @@ export class StandardController implements IController { ); this.eventHandler.emitEvent(EventType.INITIALIZE_START); - // Broker applications are initialized twice, so we avoid double-counting it - if (!isBroker) { - try { - this.logMultipleInstances(initMeasurement, initCorrelationId); - } catch {} - } + this.logMultipleInstances(initMeasurement, initCorrelationId); await invokeAsync( this.browserStorage.initialize.bind(this.browserStorage), diff --git a/lib/msal-browser/test/app/PublicClientApplication.spec.ts b/lib/msal-browser/test/app/PublicClientApplication.spec.ts index 9a083d5ad8..f714ee6188 100644 --- a/lib/msal-browser/test/app/PublicClientApplication.spec.ts +++ b/lib/msal-browser/test/app/PublicClientApplication.spec.ts @@ -682,26 +682,6 @@ describe("PublicClientApplication.ts Class Unit Tests", () => { expect(preGenerateSpy).toHaveBeenCalledTimes(1); }); - - it("passes in isBroker in request", async () => { - pca = new PublicClientApplication({ - auth: { - clientId: TEST_CONFIG.MSAL_CLIENT_ID, - }, - system: { - allowPlatformBroker: false, - }, - }); - const initializeControllerSpy = jest.spyOn( - StandardController.prototype, - "initialize" - ); - await pca.initialize(); - expect(initializeControllerSpy).toHaveBeenCalledWith( - undefined, - false - ); - }); }); describe("handleRedirectPromise", () => {