@azure/msal-browser 4.12.0 → 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.
Files changed (199) hide show
  1. package/dist/app/IPublicClientApplication.mjs +1 -1
  2. package/dist/app/PublicClientApplication.mjs +1 -1
  3. package/dist/app/PublicClientNext.mjs +1 -1
  4. package/dist/broker/nativeBroker/IPlatformAuthHandler.d.ts +12 -0
  5. package/dist/broker/nativeBroker/IPlatformAuthHandler.d.ts.map +1 -0
  6. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  7. package/dist/broker/nativeBroker/PlatformAuthDOMHandler.d.ts +30 -0
  8. package/dist/broker/nativeBroker/PlatformAuthDOMHandler.d.ts.map +1 -0
  9. package/dist/broker/nativeBroker/PlatformAuthDOMHandler.mjs +143 -0
  10. package/dist/broker/nativeBroker/PlatformAuthDOMHandler.mjs.map +1 -0
  11. package/dist/broker/nativeBroker/{NativeMessageHandler.d.ts → PlatformAuthExtensionHandler.d.ts} +16 -16
  12. package/dist/broker/nativeBroker/PlatformAuthExtensionHandler.d.ts.map +1 -0
  13. package/dist/broker/nativeBroker/{NativeMessageHandler.mjs → PlatformAuthExtensionHandler.mjs} +66 -58
  14. package/dist/broker/nativeBroker/PlatformAuthExtensionHandler.mjs.map +1 -0
  15. package/dist/broker/nativeBroker/PlatformAuthProvider.d.ts +26 -0
  16. package/dist/broker/nativeBroker/PlatformAuthProvider.d.ts.map +1 -0
  17. package/dist/broker/nativeBroker/PlatformAuthProvider.mjs +108 -0
  18. package/dist/broker/nativeBroker/PlatformAuthProvider.mjs.map +1 -0
  19. package/dist/broker/nativeBroker/{NativeRequest.d.ts → PlatformAuthRequest.d.ts} +34 -3
  20. package/dist/broker/nativeBroker/PlatformAuthRequest.d.ts.map +1 -0
  21. package/dist/broker/nativeBroker/{NativeResponse.d.ts → PlatformAuthResponse.d.ts} +24 -2
  22. package/dist/broker/nativeBroker/PlatformAuthResponse.d.ts.map +1 -0
  23. package/dist/cache/AccountManager.mjs +1 -1
  24. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  25. package/dist/cache/BrowserCacheManager.d.ts +6 -2
  26. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  27. package/dist/cache/BrowserCacheManager.mjs +17 -2
  28. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  29. package/dist/cache/CacheHelpers.mjs +1 -1
  30. package/dist/cache/CookieStorage.mjs +1 -1
  31. package/dist/cache/DatabaseStorage.mjs +1 -1
  32. package/dist/cache/LocalStorage.mjs +1 -1
  33. package/dist/cache/MemoryStorage.mjs +1 -1
  34. package/dist/cache/SessionStorage.mjs +1 -1
  35. package/dist/cache/TokenCache.mjs +1 -1
  36. package/dist/config/Configuration.mjs +1 -1
  37. package/dist/controllers/ControllerFactory.mjs +1 -1
  38. package/dist/controllers/NestedAppAuthController.mjs +1 -1
  39. package/dist/controllers/StandardController.d.ts +2 -2
  40. package/dist/controllers/StandardController.d.ts.map +1 -1
  41. package/dist/controllers/StandardController.mjs +30 -29
  42. package/dist/controllers/StandardController.mjs.map +1 -1
  43. package/dist/controllers/UnknownOperatingContextController.mjs +1 -1
  44. package/dist/crypto/BrowserCrypto.mjs +1 -1
  45. package/dist/crypto/CryptoOps.mjs +1 -1
  46. package/dist/crypto/PkceGenerator.mjs +1 -1
  47. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  48. package/dist/encode/Base64Decode.mjs +1 -1
  49. package/dist/encode/Base64Encode.mjs +1 -1
  50. package/dist/error/BrowserAuthError.mjs +1 -1
  51. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  52. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  53. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  54. package/dist/error/NativeAuthError.mjs +1 -1
  55. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  56. package/dist/error/NestedAppAuthError.mjs +1 -1
  57. package/dist/event/EventHandler.mjs +1 -1
  58. package/dist/event/EventMessage.d.ts +10 -1
  59. package/dist/event/EventMessage.d.ts.map +1 -1
  60. package/dist/event/EventMessage.mjs +1 -1
  61. package/dist/event/EventMessage.mjs.map +1 -1
  62. package/dist/event/EventType.d.ts +1 -0
  63. package/dist/event/EventType.d.ts.map +1 -1
  64. package/dist/event/EventType.mjs +2 -1
  65. package/dist/event/EventType.mjs.map +1 -1
  66. package/dist/index.d.ts +2 -1
  67. package/dist/index.d.ts.map +1 -1
  68. package/dist/index.mjs +2 -1
  69. package/dist/index.mjs.map +1 -1
  70. package/dist/interaction_client/BaseInteractionClient.d.ts +3 -3
  71. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  72. package/dist/interaction_client/BaseInteractionClient.mjs +3 -3
  73. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  74. package/dist/interaction_client/{NativeInteractionClient.d.ts → PlatformAuthInteractionClient.d.ts} +21 -23
  75. package/dist/interaction_client/PlatformAuthInteractionClient.d.ts.map +1 -0
  76. package/dist/interaction_client/{NativeInteractionClient.mjs → PlatformAuthInteractionClient.mjs} +80 -111
  77. package/dist/interaction_client/PlatformAuthInteractionClient.mjs.map +1 -0
  78. package/dist/interaction_client/PopupClient.d.ts +2 -2
  79. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  80. package/dist/interaction_client/PopupClient.mjs +7 -7
  81. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  82. package/dist/interaction_client/RedirectClient.d.ts +2 -2
  83. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  84. package/dist/interaction_client/RedirectClient.mjs +7 -8
  85. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  86. package/dist/interaction_client/SilentAuthCodeClient.d.ts +2 -2
  87. package/dist/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  88. package/dist/interaction_client/SilentAuthCodeClient.mjs +3 -3
  89. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  90. package/dist/interaction_client/SilentIframeClient.d.ts +2 -2
  91. package/dist/interaction_client/SilentIframeClient.d.ts.map +1 -1
  92. package/dist/interaction_client/SilentIframeClient.mjs +7 -8
  93. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  94. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  95. package/dist/interaction_client/StandardInteractionClient.mjs +1 -1
  96. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  97. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  98. package/dist/naa/BridgeError.mjs +1 -1
  99. package/dist/naa/BridgeProxy.mjs +1 -1
  100. package/dist/naa/BridgeStatusCode.mjs +1 -1
  101. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  102. package/dist/navigation/NavigationClient.mjs +1 -1
  103. package/dist/network/FetchClient.mjs +1 -1
  104. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  105. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  106. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  107. package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
  108. package/dist/packageMetadata.d.ts +1 -1
  109. package/dist/packageMetadata.mjs +2 -2
  110. package/dist/protocol/Authorize.d.ts +4 -4
  111. package/dist/protocol/Authorize.d.ts.map +1 -1
  112. package/dist/protocol/Authorize.mjs +10 -9
  113. package/dist/protocol/Authorize.mjs.map +1 -1
  114. package/dist/request/RequestHelpers.mjs +1 -1
  115. package/dist/response/ResponseHandler.mjs +1 -1
  116. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  117. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  118. package/dist/utils/BrowserConstants.d.ts +8 -1
  119. package/dist/utils/BrowserConstants.d.ts.map +1 -1
  120. package/dist/utils/BrowserConstants.mjs +11 -4
  121. package/dist/utils/BrowserConstants.mjs.map +1 -1
  122. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  123. package/dist/utils/BrowserUtils.mjs +1 -1
  124. package/dist/utils/MsalFrameStatsUtils.mjs +1 -1
  125. package/lib/msal-browser.cjs +1539 -1318
  126. package/lib/msal-browser.cjs.map +1 -1
  127. package/lib/msal-browser.js +1539 -1318
  128. package/lib/msal-browser.js.map +1 -1
  129. package/lib/msal-browser.min.js +66 -66
  130. package/lib/types/broker/nativeBroker/IPlatformAuthHandler.d.ts +12 -0
  131. package/lib/types/broker/nativeBroker/IPlatformAuthHandler.d.ts.map +1 -0
  132. package/lib/types/broker/nativeBroker/PlatformAuthDOMHandler.d.ts +30 -0
  133. package/lib/types/broker/nativeBroker/PlatformAuthDOMHandler.d.ts.map +1 -0
  134. package/lib/types/broker/nativeBroker/{NativeMessageHandler.d.ts → PlatformAuthExtensionHandler.d.ts} +16 -16
  135. package/lib/types/broker/nativeBroker/PlatformAuthExtensionHandler.d.ts.map +1 -0
  136. package/lib/types/broker/nativeBroker/PlatformAuthProvider.d.ts +26 -0
  137. package/lib/types/broker/nativeBroker/PlatformAuthProvider.d.ts.map +1 -0
  138. package/lib/types/broker/nativeBroker/{NativeRequest.d.ts → PlatformAuthRequest.d.ts} +34 -3
  139. package/lib/types/broker/nativeBroker/PlatformAuthRequest.d.ts.map +1 -0
  140. package/lib/types/broker/nativeBroker/{NativeResponse.d.ts → PlatformAuthResponse.d.ts} +24 -2
  141. package/lib/types/broker/nativeBroker/PlatformAuthResponse.d.ts.map +1 -0
  142. package/lib/types/cache/BrowserCacheManager.d.ts +6 -2
  143. package/lib/types/cache/BrowserCacheManager.d.ts.map +1 -1
  144. package/lib/types/controllers/StandardController.d.ts +2 -2
  145. package/lib/types/controllers/StandardController.d.ts.map +1 -1
  146. package/lib/types/event/EventMessage.d.ts +10 -1
  147. package/lib/types/event/EventMessage.d.ts.map +1 -1
  148. package/lib/types/event/EventType.d.ts +1 -0
  149. package/lib/types/event/EventType.d.ts.map +1 -1
  150. package/lib/types/index.d.ts +2 -1
  151. package/lib/types/index.d.ts.map +1 -1
  152. package/lib/types/interaction_client/BaseInteractionClient.d.ts +3 -3
  153. package/lib/types/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  154. package/lib/types/interaction_client/{NativeInteractionClient.d.ts → PlatformAuthInteractionClient.d.ts} +21 -23
  155. package/lib/types/interaction_client/PlatformAuthInteractionClient.d.ts.map +1 -0
  156. package/lib/types/interaction_client/PopupClient.d.ts +2 -2
  157. package/lib/types/interaction_client/PopupClient.d.ts.map +1 -1
  158. package/lib/types/interaction_client/RedirectClient.d.ts +2 -2
  159. package/lib/types/interaction_client/RedirectClient.d.ts.map +1 -1
  160. package/lib/types/interaction_client/SilentAuthCodeClient.d.ts +2 -2
  161. package/lib/types/interaction_client/SilentAuthCodeClient.d.ts.map +1 -1
  162. package/lib/types/interaction_client/SilentIframeClient.d.ts +2 -2
  163. package/lib/types/interaction_client/SilentIframeClient.d.ts.map +1 -1
  164. package/lib/types/packageMetadata.d.ts +1 -1
  165. package/lib/types/protocol/Authorize.d.ts +4 -4
  166. package/lib/types/protocol/Authorize.d.ts.map +1 -1
  167. package/lib/types/utils/BrowserConstants.d.ts +8 -1
  168. package/lib/types/utils/BrowserConstants.d.ts.map +1 -1
  169. package/package.json +2 -2
  170. package/src/broker/nativeBroker/IPlatformAuthHandler.ts +17 -0
  171. package/src/broker/nativeBroker/PlatformAuthDOMHandler.ts +248 -0
  172. package/src/broker/nativeBroker/{NativeMessageHandler.ts → PlatformAuthExtensionHandler.ts} +90 -79
  173. package/src/broker/nativeBroker/PlatformAuthProvider.ts +164 -0
  174. package/src/broker/nativeBroker/{NativeRequest.ts → PlatformAuthRequest.ts} +41 -2
  175. package/src/broker/nativeBroker/{NativeResponse.ts → PlatformAuthResponse.ts} +25 -1
  176. package/src/cache/BrowserCacheManager.ts +27 -3
  177. package/src/controllers/StandardController.ts +51 -45
  178. package/src/event/EventMessage.ts +11 -0
  179. package/src/event/EventType.ts +1 -0
  180. package/src/index.ts +3 -0
  181. package/src/interaction_client/BaseInteractionClient.ts +4 -4
  182. package/src/interaction_client/{NativeInteractionClient.ts → PlatformAuthInteractionClient.ts} +136 -167
  183. package/src/interaction_client/PopupClient.ts +8 -7
  184. package/src/interaction_client/RedirectClient.ts +12 -12
  185. package/src/interaction_client/SilentAuthCodeClient.ts +3 -3
  186. package/src/interaction_client/SilentIframeClient.ts +12 -12
  187. package/src/packageMetadata.ts +1 -1
  188. package/src/protocol/Authorize.ts +12 -10
  189. package/src/utils/BrowserConstants.ts +9 -1
  190. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +0 -1
  191. package/dist/broker/nativeBroker/NativeMessageHandler.mjs.map +0 -1
  192. package/dist/broker/nativeBroker/NativeRequest.d.ts.map +0 -1
  193. package/dist/broker/nativeBroker/NativeResponse.d.ts.map +0 -1
  194. package/dist/interaction_client/NativeInteractionClient.d.ts.map +0 -1
  195. package/dist/interaction_client/NativeInteractionClient.mjs.map +0 -1
  196. package/lib/types/broker/nativeBroker/NativeMessageHandler.d.ts.map +0 -1
  197. package/lib/types/broker/nativeBroker/NativeRequest.d.ts.map +0 -1
  198. package/lib/types/broker/nativeBroker/NativeResponse.d.ts.map +0 -1
  199. 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 { NativeInteractionClient } from "../interaction_client/NativeInteractionClient.js";
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 { NativeTokenRequest } from "../broker/nativeBroker/NativeRequest.js";
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,11 @@ 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";
90
94
  import { collectInstanceStats } from "../utils/MsalFrameStatsUtils.js";
91
95
 
92
96
  function getAccountType(
@@ -157,7 +161,7 @@ export class StandardController implements IController {
157
161
  >;
158
162
 
159
163
  // Native Extension Provider
160
- protected nativeExtensionProvider: NativeMessageHandler | undefined;
164
+ protected platformAuthProvider: IPlatformAuthHandler | undefined;
161
165
 
162
166
  // Hybrid auth code responses
163
167
  private hybridAuthCodeResponses: Map<string, Promise<AuthenticationResult>>;
@@ -359,12 +363,13 @@ export class StandardController implements IController {
359
363
 
360
364
  if (allowPlatformBroker) {
361
365
  try {
362
- this.nativeExtensionProvider =
363
- await NativeMessageHandler.createProvider(
364
- this.logger,
365
- this.config.system.nativeBrokerHandshakeTimeout,
366
- this.performanceClient
367
- );
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
+ );
368
373
  } catch (e) {
369
374
  this.logger.verbose(e as string);
370
375
  }
@@ -466,18 +471,13 @@ export class StandardController implements IController {
466
471
  }
467
472
 
468
473
  const loggedInAccounts = this.getAllAccounts();
469
- const platformBrokerRequest: NativeTokenRequest | null =
474
+ const platformBrokerRequest: PlatformAuthRequest | null =
470
475
  this.browserStorage.getCachedNativeRequest();
471
476
  const useNative =
472
- platformBrokerRequest &&
473
- NativeMessageHandler.isPlatformBrokerAvailable(
474
- this.config,
475
- this.logger,
476
- this.nativeExtensionProvider
477
- ) &&
478
- this.nativeExtensionProvider &&
479
- !hash;
477
+ platformBrokerRequest && this.platformAuthProvider && !hash;
478
+
480
479
  let rootMeasurement: InProgressPerformanceEvent;
480
+
481
481
  this.eventHandler.emitEvent(
482
482
  EventType.HANDLE_REDIRECT_START,
483
483
  InteractionType.Redirect
@@ -485,7 +485,7 @@ export class StandardController implements IController {
485
485
 
486
486
  let redirectResponse: Promise<AuthenticationResult | null>;
487
487
  try {
488
- if (useNative && this.nativeExtensionProvider) {
488
+ if (useNative && this.platformAuthProvider) {
489
489
  rootMeasurement = this.performanceClient.startMeasurement(
490
490
  PerformanceEvents.AcquireTokenRedirect,
491
491
  platformBrokerRequest?.correlationId || ""
@@ -493,7 +493,7 @@ export class StandardController implements IController {
493
493
  this.logger.trace(
494
494
  "handleRedirectPromise - acquiring token from native platform"
495
495
  );
496
- const nativeClient = new NativeInteractionClient(
496
+ const nativeClient = new PlatformAuthInteractionClient(
497
497
  this.config,
498
498
  this.browserStorage,
499
499
  this.browserCrypto,
@@ -502,7 +502,7 @@ export class StandardController implements IController {
502
502
  this.navigationClient,
503
503
  ApiId.handleRedirectPromise,
504
504
  this.performanceClient,
505
- this.nativeExtensionProvider,
505
+ this.platformAuthProvider,
506
506
  platformBrokerRequest.accountId,
507
507
  this.nativeInternalStorage,
508
508
  platformBrokerRequest.correlationId
@@ -706,10 +706,10 @@ export class StandardController implements IController {
706
706
  let result: Promise<void>;
707
707
 
708
708
  if (
709
- this.nativeExtensionProvider &&
709
+ this.platformAuthProvider &&
710
710
  this.canUsePlatformBroker(request)
711
711
  ) {
712
- const nativeClient = new NativeInteractionClient(
712
+ const nativeClient = new PlatformAuthInteractionClient(
713
713
  this.config,
714
714
  this.browserStorage,
715
715
  this.browserCrypto,
@@ -718,7 +718,7 @@ export class StandardController implements IController {
718
718
  this.navigationClient,
719
719
  ApiId.acquireTokenRedirect,
720
720
  this.performanceClient,
721
- this.nativeExtensionProvider,
721
+ this.platformAuthProvider,
722
722
  this.getNativeAccountId(request),
723
723
  this.nativeInternalStorage,
724
724
  correlationId
@@ -730,7 +730,7 @@ export class StandardController implements IController {
730
730
  e instanceof NativeAuthError &&
731
731
  isFatalNativeAuthError(e)
732
732
  ) {
733
- this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
733
+ this.platformAuthProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
734
734
  const redirectClient =
735
735
  this.createRedirectClient(correlationId);
736
736
  return redirectClient.acquireToken(request);
@@ -847,7 +847,7 @@ export class StandardController implements IController {
847
847
  e instanceof NativeAuthError &&
848
848
  isFatalNativeAuthError(e)
849
849
  ) {
850
- this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
850
+ this.platformAuthProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
851
851
  const popupClient =
852
852
  this.createPopupClient(correlationId);
853
853
  return popupClient.acquireToken(request, pkce);
@@ -1006,7 +1006,7 @@ export class StandardController implements IController {
1006
1006
  ).catch((e: AuthError) => {
1007
1007
  // If native token acquisition fails for availability reasons fallback to standard flow
1008
1008
  if (e instanceof NativeAuthError && isFatalNativeAuthError(e)) {
1009
- this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
1009
+ this.platformAuthProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
1010
1010
  const silentIframeClient = this.createSilentIframeClient(
1011
1011
  validRequest.correlationId
1012
1012
  );
@@ -1163,7 +1163,7 @@ export class StandardController implements IController {
1163
1163
  e instanceof NativeAuthError &&
1164
1164
  isFatalNativeAuthError(e)
1165
1165
  ) {
1166
- this.nativeExtensionProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
1166
+ this.platformAuthProvider = undefined; // If extension gets uninstalled during session prevent future requests from continuing to attempt
1167
1167
  }
1168
1168
  throw e;
1169
1169
  });
@@ -1573,13 +1573,13 @@ export class StandardController implements IController {
1573
1573
  cacheLookupPolicy?: CacheLookupPolicy
1574
1574
  ): Promise<AuthenticationResult> {
1575
1575
  this.logger.trace("acquireTokenNative called");
1576
- if (!this.nativeExtensionProvider) {
1576
+ if (!this.platformAuthProvider) {
1577
1577
  throw createBrowserAuthError(
1578
1578
  BrowserAuthErrorCodes.nativeConnectionNotEstablished
1579
1579
  );
1580
1580
  }
1581
1581
 
1582
- const nativeClient = new NativeInteractionClient(
1582
+ const nativeClient = new PlatformAuthInteractionClient(
1583
1583
  this.config,
1584
1584
  this.browserStorage,
1585
1585
  this.browserCrypto,
@@ -1588,7 +1588,7 @@ export class StandardController implements IController {
1588
1588
  this.navigationClient,
1589
1589
  apiId,
1590
1590
  this.performanceClient,
1591
- this.nativeExtensionProvider,
1591
+ this.platformAuthProvider,
1592
1592
  accountId || this.getNativeAccountId(request),
1593
1593
  this.nativeInternalStorage,
1594
1594
  request.correlationId
@@ -1606,16 +1606,23 @@ export class StandardController implements IController {
1606
1606
  accountId?: string
1607
1607
  ): boolean {
1608
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
+
1609
1616
  if (
1610
- !NativeMessageHandler.isPlatformBrokerAvailable(
1617
+ !isPlatformAuthAllowed(
1611
1618
  this.config,
1612
1619
  this.logger,
1613
- this.nativeExtensionProvider,
1620
+ this.platformAuthProvider,
1614
1621
  request.authenticationScheme
1615
1622
  )
1616
1623
  ) {
1617
1624
  this.logger.trace(
1618
- "canUsePlatformBroker: isPlatformBrokerAvailable returned false, returning false"
1625
+ "canUsePlatformBroker: isBrokerAvailable returned false, returning false"
1619
1626
  );
1620
1627
  return false;
1621
1628
  }
@@ -1680,7 +1687,7 @@ export class StandardController implements IController {
1680
1687
  this.navigationClient,
1681
1688
  this.performanceClient,
1682
1689
  this.nativeInternalStorage,
1683
- this.nativeExtensionProvider,
1690
+ this.platformAuthProvider,
1684
1691
  correlationId
1685
1692
  );
1686
1693
  }
@@ -1699,7 +1706,7 @@ export class StandardController implements IController {
1699
1706
  this.navigationClient,
1700
1707
  this.performanceClient,
1701
1708
  this.nativeInternalStorage,
1702
- this.nativeExtensionProvider,
1709
+ this.platformAuthProvider,
1703
1710
  correlationId
1704
1711
  );
1705
1712
  }
@@ -1721,7 +1728,7 @@ export class StandardController implements IController {
1721
1728
  ApiId.ssoSilent,
1722
1729
  this.performanceClient,
1723
1730
  this.nativeInternalStorage,
1724
- this.nativeExtensionProvider,
1731
+ this.platformAuthProvider,
1725
1732
  correlationId
1726
1733
  );
1727
1734
  }
@@ -1740,7 +1747,7 @@ export class StandardController implements IController {
1740
1747
  this.eventHandler,
1741
1748
  this.navigationClient,
1742
1749
  this.performanceClient,
1743
- this.nativeExtensionProvider,
1750
+ this.platformAuthProvider,
1744
1751
  correlationId
1745
1752
  );
1746
1753
  }
@@ -1759,7 +1766,7 @@ export class StandardController implements IController {
1759
1766
  this.eventHandler,
1760
1767
  this.navigationClient,
1761
1768
  this.performanceClient,
1762
- this.nativeExtensionProvider,
1769
+ this.platformAuthProvider,
1763
1770
  correlationId
1764
1771
  );
1765
1772
  }
@@ -1779,7 +1786,7 @@ export class StandardController implements IController {
1779
1786
  this.navigationClient,
1780
1787
  ApiId.acquireTokenByCode,
1781
1788
  this.performanceClient,
1782
- this.nativeExtensionProvider,
1789
+ this.platformAuthProvider,
1783
1790
  correlationId
1784
1791
  );
1785
1792
  }
@@ -2291,10 +2298,10 @@ export class StandardController implements IController {
2291
2298
  ): Promise<AuthenticationResult> {
2292
2299
  // if the cache policy is set to access_token only, we should not be hitting the native layer yet
2293
2300
  if (
2294
- NativeMessageHandler.isPlatformBrokerAvailable(
2301
+ isPlatformAuthAllowed(
2295
2302
  this.config,
2296
2303
  this.logger,
2297
- this.nativeExtensionProvider,
2304
+ this.platformAuthProvider,
2298
2305
  silentRequest.authenticationScheme
2299
2306
  ) &&
2300
2307
  silentRequest.account.nativeAccountId
@@ -2313,8 +2320,7 @@ export class StandardController implements IController {
2313
2320
  this.logger.verbose(
2314
2321
  "acquireTokenSilent - native platform unavailable, falling back to web flow"
2315
2322
  );
2316
- this.nativeExtensionProvider = undefined; // Prevent future requests from continuing to attempt
2317
-
2323
+ this.platformAuthProvider = undefined; // Prevent future requests from continuing to attempt
2318
2324
  // Cache will not contain tokens, given that previous WAM requests succeeded. Skip cache and RT renewal and go straight to iframe renewal
2319
2325
  throw createClientAuthError(
2320
2326
  ClientAuthErrorCodes.tokenRefreshRequired
@@ -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;
@@ -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 nativeMessageHandler: NativeMessageHandler | undefined;
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
- nativeMessageHandler?: NativeMessageHandler,
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.nativeMessageHandler = nativeMessageHandler;
71
+ this.platformAuthProvider = platformAuthProvider;
72
72
  this.correlationId = correlationId || createNewGuid();
73
73
  this.logger = logger.clone(
74
74
  BrowserConstants.MSAL_SKU,