@azure/msal-browser 4.11.1 → 4.13.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 +1 -0
- package/dist/app/PublicClientApplication.d.ts.map +1 -1
- package/dist/app/PublicClientApplication.mjs +3 -2
- package/dist/app/PublicClientApplication.mjs.map +1 -1
- package/dist/app/PublicClientNext.mjs +1 -1
- package/dist/broker/nativeBroker/IPlatformAuthHandler.d.ts +12 -0
- package/dist/broker/nativeBroker/IPlatformAuthHandler.d.ts.map +1 -0
- package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
- package/dist/broker/nativeBroker/PlatformAuthDOMHandler.d.ts +30 -0
- package/dist/broker/nativeBroker/PlatformAuthDOMHandler.d.ts.map +1 -0
- package/dist/broker/nativeBroker/PlatformAuthDOMHandler.mjs +143 -0
- package/dist/broker/nativeBroker/PlatformAuthDOMHandler.mjs.map +1 -0
- package/dist/broker/nativeBroker/{NativeMessageHandler.d.ts → PlatformAuthExtensionHandler.d.ts} +16 -16
- package/dist/broker/nativeBroker/PlatformAuthExtensionHandler.d.ts.map +1 -0
- package/dist/broker/nativeBroker/{NativeMessageHandler.mjs → PlatformAuthExtensionHandler.mjs} +66 -58
- package/dist/broker/nativeBroker/PlatformAuthExtensionHandler.mjs.map +1 -0
- package/dist/broker/nativeBroker/PlatformAuthProvider.d.ts +26 -0
- package/dist/broker/nativeBroker/PlatformAuthProvider.d.ts.map +1 -0
- package/dist/broker/nativeBroker/PlatformAuthProvider.mjs +108 -0
- package/dist/broker/nativeBroker/PlatformAuthProvider.mjs.map +1 -0
- package/dist/broker/nativeBroker/{NativeRequest.d.ts → PlatformAuthRequest.d.ts} +34 -3
- package/dist/broker/nativeBroker/PlatformAuthRequest.d.ts.map +1 -0
- package/dist/broker/nativeBroker/{NativeResponse.d.ts → PlatformAuthResponse.d.ts} +24 -2
- package/dist/broker/nativeBroker/PlatformAuthResponse.d.ts.map +1 -0
- package/dist/cache/AccountManager.mjs +1 -1
- package/dist/cache/AsyncMemoryStorage.mjs +1 -1
- package/dist/cache/BrowserCacheManager.d.ts +6 -2
- package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
- package/dist/cache/BrowserCacheManager.mjs +29 -3
- package/dist/cache/BrowserCacheManager.mjs.map +1 -1
- package/dist/cache/CacheHelpers.mjs +1 -1
- package/dist/cache/CookieStorage.mjs +1 -1
- package/dist/cache/DatabaseStorage.mjs +1 -1
- package/dist/cache/LocalStorage.mjs +1 -1
- package/dist/cache/MemoryStorage.mjs +1 -1
- package/dist/cache/SessionStorage.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/IController.d.ts +1 -1
- package/dist/controllers/IController.d.ts.map +1 -1
- package/dist/controllers/NestedAppAuthController.d.ts +1 -1
- package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
- package/dist/controllers/NestedAppAuthController.mjs +4 -2
- package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
- package/dist/controllers/StandardController.d.ts +4 -3
- package/dist/controllers/StandardController.d.ts.map +1 -1
- package/dist/controllers/StandardController.mjs +56 -30
- 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.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.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.d.ts +10 -1
- package/dist/event/EventMessage.d.ts.map +1 -1
- package/dist/event/EventMessage.mjs +1 -1
- package/dist/event/EventMessage.mjs.map +1 -1
- package/dist/event/EventType.d.ts +1 -0
- package/dist/event/EventType.d.ts.map +1 -1
- package/dist/event/EventType.mjs +2 -1
- package/dist/event/EventType.mjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/index.mjs.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.d.ts +3 -3
- package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
- package/dist/interaction_client/BaseInteractionClient.mjs +3 -3
- package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
- package/dist/interaction_client/{NativeInteractionClient.d.ts → PlatformAuthInteractionClient.d.ts} +21 -23
- package/dist/interaction_client/PlatformAuthInteractionClient.d.ts.map +1 -0
- package/dist/interaction_client/{NativeInteractionClient.mjs → PlatformAuthInteractionClient.mjs} +80 -111
- package/dist/interaction_client/PlatformAuthInteractionClient.mjs.map +1 -0
- package/dist/interaction_client/PopupClient.d.ts +2 -2
- package/dist/interaction_client/PopupClient.d.ts.map +1 -1
- package/dist/interaction_client/PopupClient.mjs +7 -7
- package/dist/interaction_client/PopupClient.mjs.map +1 -1
- package/dist/interaction_client/RedirectClient.d.ts +2 -2
- package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
- package/dist/interaction_client/RedirectClient.mjs +7 -8
- package/dist/interaction_client/RedirectClient.mjs.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.d.ts +2 -2
- package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentAuthCodeClient.mjs +3 -3
- package/dist/interaction_client/SilentCacheClient.mjs +1 -1
- package/dist/interaction_client/SilentIframeClient.d.ts +2 -2
- package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
- package/dist/interaction_client/SilentIframeClient.mjs +7 -8
- 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/SilentHandler.mjs +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/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/protocol/Authorize.d.ts +4 -4
- package/dist/protocol/Authorize.d.ts.map +1 -1
- package/dist/protocol/Authorize.mjs +10 -9
- package/dist/protocol/Authorize.mjs.map +1 -1
- package/dist/request/RequestHelpers.mjs +1 -1
- package/dist/response/ResponseHandler.mjs +1 -1
- package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
- package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
- package/dist/utils/BrowserConstants.d.ts +8 -1
- package/dist/utils/BrowserConstants.d.ts.map +1 -1
- package/dist/utils/BrowserConstants.mjs +11 -4
- package/dist/utils/BrowserConstants.mjs.map +1 -1
- package/dist/utils/BrowserProtocolUtils.mjs +1 -1
- package/dist/utils/BrowserUtils.mjs +1 -1
- package/dist/utils/MsalFrameStatsUtils.d.ts +3 -0
- package/dist/utils/MsalFrameStatsUtils.d.ts.map +1 -0
- package/dist/utils/MsalFrameStatsUtils.mjs +23 -0
- package/dist/utils/MsalFrameStatsUtils.mjs.map +1 -0
- package/lib/msal-browser.cjs +1600 -1323
- package/lib/msal-browser.cjs.map +1 -1
- package/lib/msal-browser.js +1600 -1323
- package/lib/msal-browser.js.map +1 -1
- package/lib/msal-browser.min.js +66 -66
- package/lib/types/app/PublicClientApplication.d.ts +1 -0
- package/lib/types/app/PublicClientApplication.d.ts.map +1 -1
- package/lib/types/broker/nativeBroker/IPlatformAuthHandler.d.ts +12 -0
- package/lib/types/broker/nativeBroker/IPlatformAuthHandler.d.ts.map +1 -0
- package/lib/types/broker/nativeBroker/PlatformAuthDOMHandler.d.ts +30 -0
- package/lib/types/broker/nativeBroker/PlatformAuthDOMHandler.d.ts.map +1 -0
- package/lib/types/broker/nativeBroker/{NativeMessageHandler.d.ts → PlatformAuthExtensionHandler.d.ts} +16 -16
- package/lib/types/broker/nativeBroker/PlatformAuthExtensionHandler.d.ts.map +1 -0
- package/lib/types/broker/nativeBroker/PlatformAuthProvider.d.ts +26 -0
- package/lib/types/broker/nativeBroker/PlatformAuthProvider.d.ts.map +1 -0
- package/lib/types/broker/nativeBroker/{NativeRequest.d.ts → PlatformAuthRequest.d.ts} +34 -3
- package/lib/types/broker/nativeBroker/PlatformAuthRequest.d.ts.map +1 -0
- package/lib/types/broker/nativeBroker/{NativeResponse.d.ts → PlatformAuthResponse.d.ts} +24 -2
- package/lib/types/broker/nativeBroker/PlatformAuthResponse.d.ts.map +1 -0
- package/lib/types/cache/BrowserCacheManager.d.ts +6 -2
- package/lib/types/cache/BrowserCacheManager.d.ts.map +1 -1
- package/lib/types/controllers/IController.d.ts +1 -1
- package/lib/types/controllers/IController.d.ts.map +1 -1
- package/lib/types/controllers/NestedAppAuthController.d.ts +1 -1
- package/lib/types/controllers/NestedAppAuthController.d.ts.map +1 -1
- package/lib/types/controllers/StandardController.d.ts +4 -3
- package/lib/types/controllers/StandardController.d.ts.map +1 -1
- package/lib/types/event/EventMessage.d.ts +10 -1
- package/lib/types/event/EventMessage.d.ts.map +1 -1
- package/lib/types/event/EventType.d.ts +1 -0
- package/lib/types/event/EventType.d.ts.map +1 -1
- package/lib/types/index.d.ts +2 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/interaction_client/BaseInteractionClient.d.ts +3 -3
- package/lib/types/interaction_client/BaseInteractionClient.d.ts.map +1 -1
- package/lib/types/interaction_client/{NativeInteractionClient.d.ts → PlatformAuthInteractionClient.d.ts} +21 -23
- package/lib/types/interaction_client/PlatformAuthInteractionClient.d.ts.map +1 -0
- package/lib/types/interaction_client/PopupClient.d.ts +2 -2
- package/lib/types/interaction_client/PopupClient.d.ts.map +1 -1
- package/lib/types/interaction_client/RedirectClient.d.ts +2 -2
- package/lib/types/interaction_client/RedirectClient.d.ts.map +1 -1
- package/lib/types/interaction_client/SilentAuthCodeClient.d.ts +2 -2
- package/lib/types/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
- package/lib/types/interaction_client/SilentIframeClient.d.ts +2 -2
- package/lib/types/interaction_client/SilentIframeClient.d.ts.map +1 -1
- package/lib/types/packageMetadata.d.ts +1 -1
- package/lib/types/protocol/Authorize.d.ts +4 -4
- package/lib/types/protocol/Authorize.d.ts.map +1 -1
- package/lib/types/utils/BrowserConstants.d.ts +8 -1
- package/lib/types/utils/BrowserConstants.d.ts.map +1 -1
- package/lib/types/utils/MsalFrameStatsUtils.d.ts +3 -0
- package/lib/types/utils/MsalFrameStatsUtils.d.ts.map +1 -0
- package/package.json +3 -2
- package/src/app/PublicClientApplication.ts +2 -1
- package/src/broker/nativeBroker/IPlatformAuthHandler.ts +17 -0
- package/src/broker/nativeBroker/PlatformAuthDOMHandler.ts +248 -0
- package/src/broker/nativeBroker/{NativeMessageHandler.ts → PlatformAuthExtensionHandler.ts} +90 -79
- package/src/broker/nativeBroker/PlatformAuthProvider.ts +164 -0
- package/src/broker/nativeBroker/{NativeRequest.ts → PlatformAuthRequest.ts} +41 -2
- package/src/broker/nativeBroker/{NativeResponse.ts → PlatformAuthResponse.ts} +25 -1
- package/src/cache/BrowserCacheManager.ts +40 -4
- package/src/controllers/IController.ts +4 -1
- package/src/controllers/NestedAppAuthController.ts +5 -1
- package/src/controllers/StandardController.ts +87 -46
- package/src/event/EventMessage.ts +11 -0
- package/src/event/EventType.ts +1 -0
- package/src/index.ts +3 -0
- package/src/interaction_client/BaseInteractionClient.ts +4 -4
- package/src/interaction_client/{NativeInteractionClient.ts → PlatformAuthInteractionClient.ts} +136 -167
- package/src/interaction_client/PopupClient.ts +8 -7
- package/src/interaction_client/RedirectClient.ts +12 -12
- package/src/interaction_client/SilentAuthCodeClient.ts +3 -3
- package/src/interaction_client/SilentIframeClient.ts +12 -12
- package/src/packageMetadata.ts +1 -1
- package/src/protocol/Authorize.ts +12 -10
- package/src/utils/BrowserConstants.ts +9 -1
- package/src/utils/MsalFrameStatsUtils.ts +32 -0
- package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +0 -1
- package/dist/broker/nativeBroker/NativeMessageHandler.mjs.map +0 -1
- package/dist/broker/nativeBroker/NativeRequest.d.ts.map +0 -1
- package/dist/broker/nativeBroker/NativeResponse.d.ts.map +0 -1
- package/dist/interaction_client/NativeInteractionClient.d.ts.map +0 -1
- package/dist/interaction_client/NativeInteractionClient.mjs.map +0 -1
- package/lib/types/broker/nativeBroker/NativeMessageHandler.d.ts.map +0 -1
- package/lib/types/broker/nativeBroker/NativeRequest.d.ts.map +0 -1
- package/lib/types/broker/nativeBroker/NativeResponse.d.ts.map +0 -1
- package/lib/types/interaction_client/NativeInteractionClient.d.ts.map +0 -1
|
@@ -63,8 +63,7 @@ import { SilentIframeClient } from "../interaction_client/SilentIframeClient.js"
|
|
|
63
63
|
import { SilentRefreshClient } from "../interaction_client/SilentRefreshClient.js";
|
|
64
64
|
import { TokenCache } from "../cache/TokenCache.js";
|
|
65
65
|
import { ITokenCache } from "../cache/ITokenCache.js";
|
|
66
|
-
import {
|
|
67
|
-
import { NativeMessageHandler } from "../broker/nativeBroker/NativeMessageHandler.js";
|
|
66
|
+
import { PlatformAuthInteractionClient } from "../interaction_client/PlatformAuthInteractionClient.js";
|
|
68
67
|
import { SilentRequest } from "../request/SilentRequest.js";
|
|
69
68
|
import {
|
|
70
69
|
NativeAuthError,
|
|
@@ -77,7 +76,7 @@ import {
|
|
|
77
76
|
BrowserAuthErrorCodes,
|
|
78
77
|
} from "../error/BrowserAuthError.js";
|
|
79
78
|
import { AuthorizationCodeRequest } from "../request/AuthorizationCodeRequest.js";
|
|
80
|
-
import {
|
|
79
|
+
import { PlatformAuthRequest } from "../broker/nativeBroker/PlatformAuthRequest.js";
|
|
81
80
|
import { StandardOperatingContext } from "../operatingcontext/StandardOperatingContext.js";
|
|
82
81
|
import { BaseOperatingContext } from "../operatingcontext/BaseOperatingContext.js";
|
|
83
82
|
import { IController } from "./IController.js";
|
|
@@ -87,6 +86,12 @@ import { createNewGuid } from "../crypto/BrowserCrypto.js";
|
|
|
87
86
|
import { initializeSilentRequest } from "../request/RequestHelpers.js";
|
|
88
87
|
import { InitializeApplicationRequest } from "../request/InitializeApplicationRequest.js";
|
|
89
88
|
import { generatePkceCodes } from "../crypto/PkceGenerator.js";
|
|
89
|
+
import {
|
|
90
|
+
getPlatformAuthProvider,
|
|
91
|
+
isPlatformAuthAllowed,
|
|
92
|
+
} from "../broker/nativeBroker/PlatformAuthProvider.js";
|
|
93
|
+
import { IPlatformAuthHandler } from "../broker/nativeBroker/IPlatformAuthHandler.js";
|
|
94
|
+
import { collectInstanceStats } from "../utils/MsalFrameStatsUtils.js";
|
|
90
95
|
|
|
91
96
|
function getAccountType(
|
|
92
97
|
account?: AccountInfo
|
|
@@ -156,7 +161,7 @@ export class StandardController implements IController {
|
|
|
156
161
|
>;
|
|
157
162
|
|
|
158
163
|
// Native Extension Provider
|
|
159
|
-
protected
|
|
164
|
+
protected platformAuthProvider: IPlatformAuthHandler | undefined;
|
|
160
165
|
|
|
161
166
|
// Hybrid auth code responses
|
|
162
167
|
private hybridAuthCodeResponses: Map<string, Promise<AuthenticationResult>>;
|
|
@@ -313,7 +318,10 @@ export class StandardController implements IController {
|
|
|
313
318
|
* Initializer function to perform async startup tasks such as connecting to WAM extension
|
|
314
319
|
* @param request {?InitializeApplicationRequest} correlation id
|
|
315
320
|
*/
|
|
316
|
-
async initialize(
|
|
321
|
+
async initialize(
|
|
322
|
+
request?: InitializeApplicationRequest,
|
|
323
|
+
isBroker?: boolean
|
|
324
|
+
): Promise<void> {
|
|
317
325
|
this.logger.trace("initialize called");
|
|
318
326
|
if (this.initialized) {
|
|
319
327
|
this.logger.info(
|
|
@@ -338,6 +346,13 @@ export class StandardController implements IController {
|
|
|
338
346
|
);
|
|
339
347
|
this.eventHandler.emitEvent(EventType.INITIALIZE_START);
|
|
340
348
|
|
|
349
|
+
// Broker applications are initialized twice, so we avoid double-counting it
|
|
350
|
+
if (!isBroker) {
|
|
351
|
+
try {
|
|
352
|
+
this.logMultipleInstances(initMeasurement);
|
|
353
|
+
} catch {}
|
|
354
|
+
}
|
|
355
|
+
|
|
341
356
|
await invokeAsync(
|
|
342
357
|
this.browserStorage.initialize.bind(this.browserStorage),
|
|
343
358
|
PerformanceEvents.InitializeCache,
|
|
@@ -348,12 +363,13 @@ export class StandardController implements IController {
|
|
|
348
363
|
|
|
349
364
|
if (allowPlatformBroker) {
|
|
350
365
|
try {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
366
|
+
// check if platform authentication is available via DOM or browser extension and create relevant handlers
|
|
367
|
+
this.platformAuthProvider = await getPlatformAuthProvider(
|
|
368
|
+
this.logger,
|
|
369
|
+
this.performanceClient,
|
|
370
|
+
initCorrelationId,
|
|
371
|
+
this.config.system.nativeBrokerHandshakeTimeout
|
|
372
|
+
);
|
|
357
373
|
} catch (e) {
|
|
358
374
|
this.logger.verbose(e as string);
|
|
359
375
|
}
|
|
@@ -455,18 +471,13 @@ export class StandardController implements IController {
|
|
|
455
471
|
}
|
|
456
472
|
|
|
457
473
|
const loggedInAccounts = this.getAllAccounts();
|
|
458
|
-
const platformBrokerRequest:
|
|
474
|
+
const platformBrokerRequest: PlatformAuthRequest | null =
|
|
459
475
|
this.browserStorage.getCachedNativeRequest();
|
|
460
476
|
const useNative =
|
|
461
|
-
platformBrokerRequest &&
|
|
462
|
-
|
|
463
|
-
this.config,
|
|
464
|
-
this.logger,
|
|
465
|
-
this.nativeExtensionProvider
|
|
466
|
-
) &&
|
|
467
|
-
this.nativeExtensionProvider &&
|
|
468
|
-
!hash;
|
|
477
|
+
platformBrokerRequest && this.platformAuthProvider && !hash;
|
|
478
|
+
|
|
469
479
|
let rootMeasurement: InProgressPerformanceEvent;
|
|
480
|
+
|
|
470
481
|
this.eventHandler.emitEvent(
|
|
471
482
|
EventType.HANDLE_REDIRECT_START,
|
|
472
483
|
InteractionType.Redirect
|
|
@@ -474,7 +485,7 @@ export class StandardController implements IController {
|
|
|
474
485
|
|
|
475
486
|
let redirectResponse: Promise<AuthenticationResult | null>;
|
|
476
487
|
try {
|
|
477
|
-
if (useNative && this.
|
|
488
|
+
if (useNative && this.platformAuthProvider) {
|
|
478
489
|
rootMeasurement = this.performanceClient.startMeasurement(
|
|
479
490
|
PerformanceEvents.AcquireTokenRedirect,
|
|
480
491
|
platformBrokerRequest?.correlationId || ""
|
|
@@ -482,7 +493,7 @@ export class StandardController implements IController {
|
|
|
482
493
|
this.logger.trace(
|
|
483
494
|
"handleRedirectPromise - acquiring token from native platform"
|
|
484
495
|
);
|
|
485
|
-
const nativeClient = new
|
|
496
|
+
const nativeClient = new PlatformAuthInteractionClient(
|
|
486
497
|
this.config,
|
|
487
498
|
this.browserStorage,
|
|
488
499
|
this.browserCrypto,
|
|
@@ -491,7 +502,7 @@ export class StandardController implements IController {
|
|
|
491
502
|
this.navigationClient,
|
|
492
503
|
ApiId.handleRedirectPromise,
|
|
493
504
|
this.performanceClient,
|
|
494
|
-
this.
|
|
505
|
+
this.platformAuthProvider,
|
|
495
506
|
platformBrokerRequest.accountId,
|
|
496
507
|
this.nativeInternalStorage,
|
|
497
508
|
platformBrokerRequest.correlationId
|
|
@@ -695,10 +706,10 @@ export class StandardController implements IController {
|
|
|
695
706
|
let result: Promise<void>;
|
|
696
707
|
|
|
697
708
|
if (
|
|
698
|
-
this.
|
|
709
|
+
this.platformAuthProvider &&
|
|
699
710
|
this.canUsePlatformBroker(request)
|
|
700
711
|
) {
|
|
701
|
-
const nativeClient = new
|
|
712
|
+
const nativeClient = new PlatformAuthInteractionClient(
|
|
702
713
|
this.config,
|
|
703
714
|
this.browserStorage,
|
|
704
715
|
this.browserCrypto,
|
|
@@ -707,7 +718,7 @@ export class StandardController implements IController {
|
|
|
707
718
|
this.navigationClient,
|
|
708
719
|
ApiId.acquireTokenRedirect,
|
|
709
720
|
this.performanceClient,
|
|
710
|
-
this.
|
|
721
|
+
this.platformAuthProvider,
|
|
711
722
|
this.getNativeAccountId(request),
|
|
712
723
|
this.nativeInternalStorage,
|
|
713
724
|
correlationId
|
|
@@ -719,7 +730,7 @@ export class StandardController implements IController {
|
|
|
719
730
|
e instanceof NativeAuthError &&
|
|
720
731
|
isFatalNativeAuthError(e)
|
|
721
732
|
) {
|
|
722
|
-
this.
|
|
733
|
+
this.platformAuthProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
|
|
723
734
|
const redirectClient =
|
|
724
735
|
this.createRedirectClient(correlationId);
|
|
725
736
|
return redirectClient.acquireToken(request);
|
|
@@ -836,7 +847,7 @@ export class StandardController implements IController {
|
|
|
836
847
|
e instanceof NativeAuthError &&
|
|
837
848
|
isFatalNativeAuthError(e)
|
|
838
849
|
) {
|
|
839
|
-
this.
|
|
850
|
+
this.platformAuthProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
|
|
840
851
|
const popupClient =
|
|
841
852
|
this.createPopupClient(correlationId);
|
|
842
853
|
return popupClient.acquireToken(request, pkce);
|
|
@@ -995,7 +1006,7 @@ export class StandardController implements IController {
|
|
|
995
1006
|
).catch((e: AuthError) => {
|
|
996
1007
|
// If native token acquisition fails for availability reasons fallback to standard flow
|
|
997
1008
|
if (e instanceof NativeAuthError && isFatalNativeAuthError(e)) {
|
|
998
|
-
this.
|
|
1009
|
+
this.platformAuthProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
|
|
999
1010
|
const silentIframeClient = this.createSilentIframeClient(
|
|
1000
1011
|
validRequest.correlationId
|
|
1001
1012
|
);
|
|
@@ -1152,7 +1163,7 @@ export class StandardController implements IController {
|
|
|
1152
1163
|
e instanceof NativeAuthError &&
|
|
1153
1164
|
isFatalNativeAuthError(e)
|
|
1154
1165
|
) {
|
|
1155
|
-
this.
|
|
1166
|
+
this.platformAuthProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
|
|
1156
1167
|
}
|
|
1157
1168
|
throw e;
|
|
1158
1169
|
});
|
|
@@ -1562,13 +1573,13 @@ export class StandardController implements IController {
|
|
|
1562
1573
|
cacheLookupPolicy?: CacheLookupPolicy
|
|
1563
1574
|
): Promise<AuthenticationResult> {
|
|
1564
1575
|
this.logger.trace("acquireTokenNative called");
|
|
1565
|
-
if (!this.
|
|
1576
|
+
if (!this.platformAuthProvider) {
|
|
1566
1577
|
throw createBrowserAuthError(
|
|
1567
1578
|
BrowserAuthErrorCodes.nativeConnectionNotEstablished
|
|
1568
1579
|
);
|
|
1569
1580
|
}
|
|
1570
1581
|
|
|
1571
|
-
const nativeClient = new
|
|
1582
|
+
const nativeClient = new PlatformAuthInteractionClient(
|
|
1572
1583
|
this.config,
|
|
1573
1584
|
this.browserStorage,
|
|
1574
1585
|
this.browserCrypto,
|
|
@@ -1577,7 +1588,7 @@ export class StandardController implements IController {
|
|
|
1577
1588
|
this.navigationClient,
|
|
1578
1589
|
apiId,
|
|
1579
1590
|
this.performanceClient,
|
|
1580
|
-
this.
|
|
1591
|
+
this.platformAuthProvider,
|
|
1581
1592
|
accountId || this.getNativeAccountId(request),
|
|
1582
1593
|
this.nativeInternalStorage,
|
|
1583
1594
|
request.correlationId
|
|
@@ -1595,16 +1606,23 @@ export class StandardController implements IController {
|
|
|
1595
1606
|
accountId?: string
|
|
1596
1607
|
): boolean {
|
|
1597
1608
|
this.logger.trace("canUsePlatformBroker called");
|
|
1609
|
+
if (!this.platformAuthProvider) {
|
|
1610
|
+
this.logger.trace(
|
|
1611
|
+
"canUsePlatformBroker: platform broker unavilable, returning false"
|
|
1612
|
+
);
|
|
1613
|
+
return false;
|
|
1614
|
+
}
|
|
1615
|
+
|
|
1598
1616
|
if (
|
|
1599
|
-
!
|
|
1617
|
+
!isPlatformAuthAllowed(
|
|
1600
1618
|
this.config,
|
|
1601
1619
|
this.logger,
|
|
1602
|
-
this.
|
|
1620
|
+
this.platformAuthProvider,
|
|
1603
1621
|
request.authenticationScheme
|
|
1604
1622
|
)
|
|
1605
1623
|
) {
|
|
1606
1624
|
this.logger.trace(
|
|
1607
|
-
"canUsePlatformBroker:
|
|
1625
|
+
"canUsePlatformBroker: isBrokerAvailable returned false, returning false"
|
|
1608
1626
|
);
|
|
1609
1627
|
return false;
|
|
1610
1628
|
}
|
|
@@ -1669,7 +1687,7 @@ export class StandardController implements IController {
|
|
|
1669
1687
|
this.navigationClient,
|
|
1670
1688
|
this.performanceClient,
|
|
1671
1689
|
this.nativeInternalStorage,
|
|
1672
|
-
this.
|
|
1690
|
+
this.platformAuthProvider,
|
|
1673
1691
|
correlationId
|
|
1674
1692
|
);
|
|
1675
1693
|
}
|
|
@@ -1688,7 +1706,7 @@ export class StandardController implements IController {
|
|
|
1688
1706
|
this.navigationClient,
|
|
1689
1707
|
this.performanceClient,
|
|
1690
1708
|
this.nativeInternalStorage,
|
|
1691
|
-
this.
|
|
1709
|
+
this.platformAuthProvider,
|
|
1692
1710
|
correlationId
|
|
1693
1711
|
);
|
|
1694
1712
|
}
|
|
@@ -1710,7 +1728,7 @@ export class StandardController implements IController {
|
|
|
1710
1728
|
ApiId.ssoSilent,
|
|
1711
1729
|
this.performanceClient,
|
|
1712
1730
|
this.nativeInternalStorage,
|
|
1713
|
-
this.
|
|
1731
|
+
this.platformAuthProvider,
|
|
1714
1732
|
correlationId
|
|
1715
1733
|
);
|
|
1716
1734
|
}
|
|
@@ -1729,7 +1747,7 @@ export class StandardController implements IController {
|
|
|
1729
1747
|
this.eventHandler,
|
|
1730
1748
|
this.navigationClient,
|
|
1731
1749
|
this.performanceClient,
|
|
1732
|
-
this.
|
|
1750
|
+
this.platformAuthProvider,
|
|
1733
1751
|
correlationId
|
|
1734
1752
|
);
|
|
1735
1753
|
}
|
|
@@ -1748,7 +1766,7 @@ export class StandardController implements IController {
|
|
|
1748
1766
|
this.eventHandler,
|
|
1749
1767
|
this.navigationClient,
|
|
1750
1768
|
this.performanceClient,
|
|
1751
|
-
this.
|
|
1769
|
+
this.platformAuthProvider,
|
|
1752
1770
|
correlationId
|
|
1753
1771
|
);
|
|
1754
1772
|
}
|
|
@@ -1768,7 +1786,7 @@ export class StandardController implements IController {
|
|
|
1768
1786
|
this.navigationClient,
|
|
1769
1787
|
ApiId.acquireTokenByCode,
|
|
1770
1788
|
this.performanceClient,
|
|
1771
|
-
this.
|
|
1789
|
+
this.platformAuthProvider,
|
|
1772
1790
|
correlationId
|
|
1773
1791
|
);
|
|
1774
1792
|
}
|
|
@@ -2280,10 +2298,10 @@ export class StandardController implements IController {
|
|
|
2280
2298
|
): Promise<AuthenticationResult> {
|
|
2281
2299
|
// if the cache policy is set to access_token only, we should not be hitting the native layer yet
|
|
2282
2300
|
if (
|
|
2283
|
-
|
|
2301
|
+
isPlatformAuthAllowed(
|
|
2284
2302
|
this.config,
|
|
2285
2303
|
this.logger,
|
|
2286
|
-
this.
|
|
2304
|
+
this.platformAuthProvider,
|
|
2287
2305
|
silentRequest.authenticationScheme
|
|
2288
2306
|
) &&
|
|
2289
2307
|
silentRequest.account.nativeAccountId
|
|
@@ -2302,8 +2320,7 @@ export class StandardController implements IController {
|
|
|
2302
2320
|
this.logger.verbose(
|
|
2303
2321
|
"acquireTokenSilent - native platform unavailable, falling back to web flow"
|
|
2304
2322
|
);
|
|
2305
|
-
this.
|
|
2306
|
-
|
|
2323
|
+
this.platformAuthProvider = undefined; // Prevent future requests from continuing to attempt
|
|
2307
2324
|
// Cache will not contain tokens, given that previous WAM requests succeeded. Skip cache and RT renewal and go straight to iframe renewal
|
|
2308
2325
|
throw createClientAuthError(
|
|
2309
2326
|
ClientAuthErrorCodes.tokenRefreshRequired
|
|
@@ -2386,6 +2403,30 @@ export class StandardController implements IController {
|
|
|
2386
2403
|
);
|
|
2387
2404
|
return res;
|
|
2388
2405
|
}
|
|
2406
|
+
|
|
2407
|
+
private logMultipleInstances(
|
|
2408
|
+
performanceEvent: InProgressPerformanceEvent
|
|
2409
|
+
): void {
|
|
2410
|
+
const clientId = this.config.auth.clientId;
|
|
2411
|
+
|
|
2412
|
+
if (!window) return;
|
|
2413
|
+
// @ts-ignore
|
|
2414
|
+
window.msal = window.msal || {};
|
|
2415
|
+
// @ts-ignore
|
|
2416
|
+
window.msal.clientIds = window.msal.clientIds || [];
|
|
2417
|
+
|
|
2418
|
+
// @ts-ignore
|
|
2419
|
+
const clientIds: string[] = window.msal.clientIds;
|
|
2420
|
+
|
|
2421
|
+
if (clientIds.length > 0) {
|
|
2422
|
+
this.logger.verbose(
|
|
2423
|
+
"There is already an instance of MSAL.js in the window."
|
|
2424
|
+
);
|
|
2425
|
+
}
|
|
2426
|
+
// @ts-ignore
|
|
2427
|
+
window.msal.clientIds.push(clientId);
|
|
2428
|
+
collectInstanceStats(clientId, performanceEvent, this.logger);
|
|
2429
|
+
}
|
|
2389
2430
|
}
|
|
2390
2431
|
|
|
2391
2432
|
/**
|
|
@@ -28,6 +28,16 @@ export type PopupEvent = {
|
|
|
28
28
|
popupWindow: Window;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Payload for the BrokerConnectionEstablished event
|
|
33
|
+
*/
|
|
34
|
+
export type BrokerConnectionEvent = {
|
|
35
|
+
/**
|
|
36
|
+
* The origin of the broker that is connected to the client
|
|
37
|
+
*/
|
|
38
|
+
pairwiseBrokerOrigin: string;
|
|
39
|
+
};
|
|
40
|
+
|
|
31
41
|
export type EventPayload =
|
|
32
42
|
| AccountInfo
|
|
33
43
|
| PopupRequest
|
|
@@ -37,6 +47,7 @@ export type EventPayload =
|
|
|
37
47
|
| EndSessionRequest
|
|
38
48
|
| AuthenticationResult
|
|
39
49
|
| PopupEvent
|
|
50
|
+
| BrokerConnectionEvent
|
|
40
51
|
| null;
|
|
41
52
|
|
|
42
53
|
export type EventError = AuthError | Error | null;
|
package/src/event/EventType.ts
CHANGED
|
@@ -30,5 +30,6 @@ export const EventType = {
|
|
|
30
30
|
LOGOUT_FAILURE: "msal:logoutFailure",
|
|
31
31
|
LOGOUT_END: "msal:logoutEnd",
|
|
32
32
|
RESTORE_FROM_BFCACHE: "msal:restoreFromBFCache",
|
|
33
|
+
BROKER_CONNECTION_ESTABLISHED: "msal:brokerConnectionEstablished",
|
|
33
34
|
} as const;
|
|
34
35
|
export type EventType = (typeof EventType)[keyof typeof EventType];
|
package/src/index.ts
CHANGED
|
@@ -86,6 +86,7 @@ export {
|
|
|
86
86
|
EventCallbackFunction,
|
|
87
87
|
EventMessageUtils,
|
|
88
88
|
PopupEvent,
|
|
89
|
+
BrokerConnectionEvent,
|
|
89
90
|
} from "./event/EventMessage.js";
|
|
90
91
|
export { EventType } from "./event/EventType.js";
|
|
91
92
|
export { EventHandler } from "./event/EventHandler.js";
|
|
@@ -160,3 +161,5 @@ export {
|
|
|
160
161
|
} from "@azure/msal-common/browser";
|
|
161
162
|
|
|
162
163
|
export { version } from "./packageMetadata.js";
|
|
164
|
+
|
|
165
|
+
export { isPlatformBrokerAvailable } from "./broker/nativeBroker/PlatformAuthProvider.js";
|
|
@@ -34,10 +34,10 @@ import { version } from "../packageMetadata.js";
|
|
|
34
34
|
import { BrowserConstants } from "../utils/BrowserConstants.js";
|
|
35
35
|
import * as BrowserUtils from "../utils/BrowserUtils.js";
|
|
36
36
|
import { INavigationClient } from "../navigation/INavigationClient.js";
|
|
37
|
-
import { NativeMessageHandler } from "../broker/nativeBroker/NativeMessageHandler.js";
|
|
38
37
|
import { AuthenticationResult } from "../response/AuthenticationResult.js";
|
|
39
38
|
import { ClearCacheRequest } from "../request/ClearCacheRequest.js";
|
|
40
39
|
import { createNewGuid } from "../crypto/BrowserCrypto.js";
|
|
40
|
+
import { IPlatformAuthHandler } from "../broker/nativeBroker/IPlatformAuthHandler.js";
|
|
41
41
|
|
|
42
42
|
export abstract class BaseInteractionClient {
|
|
43
43
|
protected config: BrowserConfiguration;
|
|
@@ -47,7 +47,7 @@ export abstract class BaseInteractionClient {
|
|
|
47
47
|
protected logger: Logger;
|
|
48
48
|
protected eventHandler: EventHandler;
|
|
49
49
|
protected navigationClient: INavigationClient;
|
|
50
|
-
protected
|
|
50
|
+
protected platformAuthProvider: IPlatformAuthHandler | undefined;
|
|
51
51
|
protected correlationId: string;
|
|
52
52
|
protected performanceClient: IPerformanceClient;
|
|
53
53
|
|
|
@@ -59,7 +59,7 @@ export abstract class BaseInteractionClient {
|
|
|
59
59
|
eventHandler: EventHandler,
|
|
60
60
|
navigationClient: INavigationClient,
|
|
61
61
|
performanceClient: IPerformanceClient,
|
|
62
|
-
|
|
62
|
+
platformAuthProvider?: IPlatformAuthHandler,
|
|
63
63
|
correlationId?: string
|
|
64
64
|
) {
|
|
65
65
|
this.config = config;
|
|
@@ -68,7 +68,7 @@ export abstract class BaseInteractionClient {
|
|
|
68
68
|
this.networkClient = this.config.system.networkClient;
|
|
69
69
|
this.eventHandler = eventHandler;
|
|
70
70
|
this.navigationClient = navigationClient;
|
|
71
|
-
this.
|
|
71
|
+
this.platformAuthProvider = platformAuthProvider;
|
|
72
72
|
this.correlationId = correlationId || createNewGuid();
|
|
73
73
|
this.logger = logger.clone(
|
|
74
74
|
BrowserConstants.MSAL_SKU,
|