@azure/msal-browser 4.0.0-alpha.0 → 4.0.1

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 (185) 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/NativeMessageHandler.d.ts +1 -1
  5. package/dist/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
  6. package/dist/broker/nativeBroker/NativeMessageHandler.mjs +8 -8
  7. package/dist/broker/nativeBroker/NativeMessageHandler.mjs.map +1 -1
  8. package/dist/broker/nativeBroker/NativeResponse.d.ts +1 -1
  9. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  10. package/dist/cache/AccountManager.mjs +1 -1
  11. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  12. package/dist/cache/BrowserCacheManager.d.ts +9 -9
  13. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  14. package/dist/cache/BrowserCacheManager.mjs +19 -19
  15. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  16. package/dist/cache/CacheHelpers.mjs +1 -1
  17. package/dist/cache/CookieStorage.mjs +1 -1
  18. package/dist/cache/CookieStorage.mjs.map +1 -1
  19. package/dist/cache/DatabaseStorage.mjs +1 -1
  20. package/dist/cache/IWindowStorage.d.ts +2 -2
  21. package/dist/cache/IWindowStorage.d.ts.map +1 -1
  22. package/dist/cache/LocalStorage.d.ts +7 -3
  23. package/dist/cache/LocalStorage.d.ts.map +1 -1
  24. package/dist/cache/LocalStorage.mjs +48 -34
  25. package/dist/cache/LocalStorage.mjs.map +1 -1
  26. package/dist/cache/MemoryStorage.mjs +1 -1
  27. package/dist/cache/SessionStorage.mjs +1 -1
  28. package/dist/cache/TokenCache.d.ts.map +1 -1
  29. package/dist/cache/TokenCache.mjs +15 -14
  30. package/dist/cache/TokenCache.mjs.map +1 -1
  31. package/dist/config/Configuration.d.ts +2 -2
  32. package/dist/config/Configuration.d.ts.map +1 -1
  33. package/dist/config/Configuration.mjs +5 -5
  34. package/dist/config/Configuration.mjs.map +1 -1
  35. package/dist/controllers/ControllerFactory.mjs +1 -1
  36. package/dist/controllers/NestedAppAuthController.d.ts +4 -3
  37. package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
  38. package/dist/controllers/NestedAppAuthController.mjs +9 -7
  39. package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
  40. package/dist/controllers/StandardController.d.ts +2 -2
  41. package/dist/controllers/StandardController.d.ts.map +1 -1
  42. package/dist/controllers/StandardController.mjs +27 -23
  43. package/dist/controllers/StandardController.mjs.map +1 -1
  44. package/dist/controllers/UnknownOperatingContextController.d.ts +2 -2
  45. package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -1
  46. package/dist/controllers/UnknownOperatingContextController.mjs +3 -3
  47. package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -1
  48. package/dist/crypto/BrowserCrypto.d.ts +1 -1
  49. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  50. package/dist/crypto/BrowserCrypto.mjs +3 -3
  51. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  52. package/dist/crypto/CryptoOps.d.ts +1 -1
  53. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  54. package/dist/crypto/CryptoOps.mjs +3 -3
  55. package/dist/crypto/CryptoOps.mjs.map +1 -1
  56. package/dist/crypto/PkceGenerator.mjs +1 -1
  57. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  58. package/dist/encode/Base64Decode.mjs +1 -1
  59. package/dist/encode/Base64Encode.mjs +1 -1
  60. package/dist/error/BrowserAuthError.mjs +1 -1
  61. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  62. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  63. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  64. package/dist/error/NativeAuthError.mjs +1 -1
  65. package/dist/error/NativeAuthError.mjs.map +1 -1
  66. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  67. package/dist/error/NestedAppAuthError.mjs +1 -1
  68. package/dist/event/EventHandler.mjs +1 -1
  69. package/dist/event/EventMessage.mjs +1 -1
  70. package/dist/event/EventType.mjs +1 -1
  71. package/dist/index.mjs +1 -1
  72. package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
  73. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  74. package/dist/interaction_client/NativeInteractionClient.d.ts +1 -1
  75. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  76. package/dist/interaction_client/NativeInteractionClient.mjs +4 -4
  77. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  78. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  79. package/dist/interaction_client/PopupClient.mjs +4 -4
  80. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  81. package/dist/interaction_client/RedirectClient.mjs +2 -2
  82. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  83. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  84. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  85. package/dist/interaction_client/SilentIframeClient.mjs +2 -2
  86. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  87. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  88. package/dist/interaction_client/StandardInteractionClient.mjs +1 -1
  89. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  90. package/dist/interaction_handler/RedirectHandler.mjs +1 -1
  91. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  92. package/dist/naa/BridgeError.mjs +1 -1
  93. package/dist/naa/BridgeProxy.mjs +1 -1
  94. package/dist/naa/BridgeStatusCode.mjs +1 -1
  95. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  96. package/dist/navigation/NavigationClient.mjs +1 -1
  97. package/dist/network/FetchClient.mjs +1 -1
  98. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  99. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  100. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  101. package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
  102. package/dist/packageMetadata.d.ts +1 -1
  103. package/dist/packageMetadata.d.ts.map +1 -1
  104. package/dist/packageMetadata.mjs +2 -2
  105. package/dist/request/AuthorizationUrlRequest.d.ts +1 -1
  106. package/dist/request/AuthorizationUrlRequest.d.ts.map +1 -1
  107. package/dist/request/PopupRequest.d.ts +1 -1
  108. package/dist/request/PopupRequest.d.ts.map +1 -1
  109. package/dist/request/RedirectRequest.d.ts +1 -1
  110. package/dist/request/RedirectRequest.d.ts.map +1 -1
  111. package/dist/request/RequestHelpers.mjs +1 -1
  112. package/dist/request/SsoSilentRequest.d.ts +1 -1
  113. package/dist/request/SsoSilentRequest.d.ts.map +1 -1
  114. package/dist/response/ResponseHandler.mjs +1 -1
  115. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  116. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  117. package/dist/utils/BrowserConstants.mjs +1 -1
  118. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  119. package/dist/utils/BrowserUtils.d.ts.map +1 -1
  120. package/dist/utils/BrowserUtils.mjs +4 -2
  121. package/dist/utils/BrowserUtils.mjs.map +1 -1
  122. package/lib/msal-browser.cjs +238 -197
  123. package/lib/msal-browser.cjs.map +1 -1
  124. package/lib/msal-browser.js +238 -197
  125. package/lib/msal-browser.js.map +1 -1
  126. package/lib/msal-browser.min.js +63 -63
  127. package/lib/types/broker/nativeBroker/NativeMessageHandler.d.ts +1 -1
  128. package/lib/types/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
  129. package/lib/types/broker/nativeBroker/NativeResponse.d.ts +1 -1
  130. package/lib/types/cache/BrowserCacheManager.d.ts +9 -9
  131. package/lib/types/cache/BrowserCacheManager.d.ts.map +1 -1
  132. package/lib/types/cache/IWindowStorage.d.ts +2 -2
  133. package/lib/types/cache/IWindowStorage.d.ts.map +1 -1
  134. package/lib/types/cache/LocalStorage.d.ts +7 -3
  135. package/lib/types/cache/LocalStorage.d.ts.map +1 -1
  136. package/lib/types/cache/TokenCache.d.ts.map +1 -1
  137. package/lib/types/config/Configuration.d.ts +2 -2
  138. package/lib/types/config/Configuration.d.ts.map +1 -1
  139. package/lib/types/controllers/NestedAppAuthController.d.ts +4 -3
  140. package/lib/types/controllers/NestedAppAuthController.d.ts.map +1 -1
  141. package/lib/types/controllers/StandardController.d.ts +2 -2
  142. package/lib/types/controllers/StandardController.d.ts.map +1 -1
  143. package/lib/types/controllers/UnknownOperatingContextController.d.ts +2 -2
  144. package/lib/types/controllers/UnknownOperatingContextController.d.ts.map +1 -1
  145. package/lib/types/crypto/BrowserCrypto.d.ts +1 -1
  146. package/lib/types/crypto/BrowserCrypto.d.ts.map +1 -1
  147. package/lib/types/crypto/CryptoOps.d.ts +1 -1
  148. package/lib/types/crypto/CryptoOps.d.ts.map +1 -1
  149. package/lib/types/interaction_client/NativeInteractionClient.d.ts +1 -1
  150. package/lib/types/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  151. package/lib/types/interaction_client/PopupClient.d.ts.map +1 -1
  152. package/lib/types/packageMetadata.d.ts +1 -1
  153. package/lib/types/packageMetadata.d.ts.map +1 -1
  154. package/lib/types/request/AuthorizationUrlRequest.d.ts +1 -1
  155. package/lib/types/request/AuthorizationUrlRequest.d.ts.map +1 -1
  156. package/lib/types/request/PopupRequest.d.ts +1 -1
  157. package/lib/types/request/PopupRequest.d.ts.map +1 -1
  158. package/lib/types/request/RedirectRequest.d.ts +1 -1
  159. package/lib/types/request/RedirectRequest.d.ts.map +1 -1
  160. package/lib/types/request/SsoSilentRequest.d.ts +1 -1
  161. package/lib/types/request/SsoSilentRequest.d.ts.map +1 -1
  162. package/lib/types/utils/BrowserUtils.d.ts.map +1 -1
  163. package/package.json +2 -2
  164. package/src/broker/nativeBroker/NativeMessageHandler.ts +7 -7
  165. package/src/broker/nativeBroker/NativeResponse.ts +1 -1
  166. package/src/cache/BrowserCacheManager.ts +56 -30
  167. package/src/cache/IWindowStorage.ts +2 -2
  168. package/src/cache/LocalStorage.ts +142 -43
  169. package/src/cache/TokenCache.ts +28 -11
  170. package/src/config/Configuration.ts +6 -6
  171. package/src/controllers/NestedAppAuthController.ts +15 -7
  172. package/src/controllers/StandardController.ts +41 -24
  173. package/src/controllers/UnknownOperatingContextController.ts +6 -5
  174. package/src/crypto/BrowserCrypto.ts +4 -2
  175. package/src/crypto/CryptoOps.ts +8 -2
  176. package/src/interaction_client/NativeInteractionClient.ts +5 -4
  177. package/src/interaction_client/PopupClient.ts +9 -8
  178. package/src/interaction_client/RedirectClient.ts +1 -1
  179. package/src/interaction_client/SilentIframeClient.ts +1 -1
  180. package/src/packageMetadata.ts +1 -1
  181. package/src/request/AuthorizationUrlRequest.ts +1 -1
  182. package/src/request/PopupRequest.ts +1 -1
  183. package/src/request/RedirectRequest.ts +1 -1
  184. package/src/request/SsoSilentRequest.ts +1 -1
  185. package/src/utils/BrowserUtils.ts +3 -1
@@ -192,9 +192,9 @@ export type BrowserSystemOptions = SystemOptions & {
192
192
  */
193
193
  allowRedirectInIframe?: boolean;
194
194
  /**
195
- * Flag to enable native broker support (e.g. acquiring tokens from WAM on Windows)
195
+ * Flag to enable native broker support (e.g. acquiring tokens from WAM on Windows, MacBroker on Mac)
196
196
  */
197
- allowNativeBroker?: boolean;
197
+ allowPlatformBroker?: boolean;
198
198
  /**
199
199
  * Sets the timeout for waiting for the native broker handshake to resolve
200
200
  */
@@ -340,7 +340,7 @@ export function buildConfiguration(
340
340
  redirectNavigationTimeout: DEFAULT_REDIRECT_TIMEOUT_MS,
341
341
  asyncPopups: false,
342
342
  allowRedirectInIframe: false,
343
- allowNativeBroker: false,
343
+ allowPlatformBroker: false,
344
344
  nativeBrokerHandshakeTimeout:
345
345
  userInputSystem?.nativeBrokerHandshakeTimeout ||
346
346
  DEFAULT_NATIVE_BROKER_HANDSHAKE_TIMEOUT_MS,
@@ -376,14 +376,14 @@ export function buildConfiguration(
376
376
  );
377
377
  }
378
378
 
379
- // Throw an error if user has set allowNativeBroker to true without being in AAD protocol mode
379
+ // Throw an error if user has set allowPlatformBroker to true without being in AAD protocol mode
380
380
  if (
381
381
  userInputAuth?.protocolMode &&
382
382
  userInputAuth.protocolMode !== ProtocolMode.AAD &&
383
- providedSystemOptions?.allowNativeBroker
383
+ providedSystemOptions?.allowPlatformBroker
384
384
  ) {
385
385
  throw createClientConfigurationError(
386
- ClientConfigurationErrorCodes.cannotAllowNativeBroker
386
+ ClientConfigurationErrorCodes.cannotAllowPlatformBroker
387
387
  );
388
388
  }
389
389
 
@@ -53,6 +53,8 @@ import {
53
53
  } from "../cache/BrowserCacheManager.js";
54
54
  import { ClearCacheRequest } from "../request/ClearCacheRequest.js";
55
55
  import * as AccountManager from "../cache/AccountManager.js";
56
+ import { InitializeApplicationRequest } from "../request/InitializeApplicationRequest.js";
57
+ import { createNewGuid } from "../crypto/BrowserCrypto.js";
56
58
 
57
59
  export class NestedAppAuthController implements IController {
58
60
  // OperatingContext
@@ -102,7 +104,7 @@ export class NestedAppAuthController implements IController {
102
104
 
103
105
  // Initialize the crypto class.
104
106
  this.browserCrypto = operatingContext.isBrowserEnvironment()
105
- ? new CryptoOps(this.logger, this.performanceClient)
107
+ ? new CryptoOps(this.logger, this.performanceClient, true)
106
108
  : DEFAULT_CRYPTO_IMPLEMENTATION;
107
109
 
108
110
  // Initialize the browser storage class.
@@ -112,11 +114,13 @@ export class NestedAppAuthController implements IController {
112
114
  this.config.cache,
113
115
  this.browserCrypto,
114
116
  this.logger,
117
+ this.performanceClient,
115
118
  buildStaticAuthorityOptions(this.config.auth)
116
119
  )
117
120
  : DEFAULT_BROWSER_CACHE_MANAGER(
118
121
  this.config.auth.clientId,
119
- this.logger
122
+ this.logger,
123
+ this.performanceClient
120
124
  );
121
125
 
122
126
  this.eventHandler = new EventHandler(this.logger);
@@ -157,8 +161,9 @@ export class NestedAppAuthController implements IController {
157
161
  * Specific implementation of initialize function for NestedAppAuthController
158
162
  * @returns
159
163
  */
160
- async initialize(): Promise<void> {
161
- await this.browserStorage.initialize();
164
+ async initialize(request?: InitializeApplicationRequest): Promise<void> {
165
+ const initCorrelationId = request?.correlationId || createNewGuid();
166
+ await this.browserStorage.initialize(initCorrelationId);
162
167
  return Promise.resolve();
163
168
  }
164
169
 
@@ -568,7 +573,7 @@ export class NestedAppAuthController implements IController {
568
573
  | "responseMode"
569
574
  | "codeChallenge"
570
575
  | "codeChallengeMethod"
571
- | "nativeBroker"
576
+ | "platformBroker"
572
577
  >
573
578
  >
574
579
  | PopupRequest,
@@ -761,7 +766,7 @@ export class NestedAppAuthController implements IController {
761
766
  | "responseMode"
762
767
  | "codeChallenge"
763
768
  | "codeChallengeMethod"
764
- | "nativeBroker"
769
+ | "platformBroker"
765
770
  >
766
771
  >
767
772
  ): Promise<AuthenticationResult> {
@@ -842,7 +847,10 @@ export class NestedAppAuthController implements IController {
842
847
  result.cloudGraphHostName,
843
848
  result.msGraphHost
844
849
  );
845
- await this.browserStorage.setAccount(accountEntity);
850
+ await this.browserStorage.setAccount(
851
+ accountEntity,
852
+ result.correlationId
853
+ );
846
854
  return this.browserStorage.hydrateCache(result, request);
847
855
  }
848
856
  }
@@ -242,12 +242,13 @@ export class StandardController implements IController {
242
242
  this.config.cache,
243
243
  this.browserCrypto,
244
244
  this.logger,
245
- buildStaticAuthorityOptions(this.config.auth),
246
- this.performanceClient
245
+ this.performanceClient,
246
+ buildStaticAuthorityOptions(this.config.auth)
247
247
  )
248
248
  : DEFAULT_BROWSER_CACHE_MANAGER(
249
249
  this.config.auth.clientId,
250
- this.logger
250
+ this.logger,
251
+ this.performanceClient
251
252
  );
252
253
 
253
254
  // initialize in memory storage for native flows
@@ -264,7 +265,6 @@ export class StandardController implements IController {
264
265
  nativeCacheOptions,
265
266
  this.browserCrypto,
266
267
  this.logger,
267
- undefined,
268
268
  this.performanceClient
269
269
  );
270
270
 
@@ -331,18 +331,24 @@ export class StandardController implements IController {
331
331
  return;
332
332
  }
333
333
 
334
- await this.browserStorage.initialize();
335
-
336
334
  const initCorrelationId =
337
335
  request?.correlationId || this.getRequestCorrelationId();
338
- const allowNativeBroker = this.config.system.allowNativeBroker;
336
+ const allowPlatformBroker = this.config.system.allowPlatformBroker;
339
337
  const initMeasurement = this.performanceClient.startMeasurement(
340
338
  PerformanceEvents.InitializeClientApplication,
341
339
  initCorrelationId
342
340
  );
343
341
  this.eventHandler.emitEvent(EventType.INITIALIZE_START);
344
342
 
345
- if (allowNativeBroker) {
343
+ await invokeAsync(
344
+ this.browserStorage.initialize.bind(this.browserStorage),
345
+ PerformanceEvents.InitializeCache,
346
+ this.logger,
347
+ this.performanceClient,
348
+ initCorrelationId
349
+ )(initCorrelationId);
350
+
351
+ if (allowPlatformBroker) {
346
352
  try {
347
353
  this.nativeExtensionProvider =
348
354
  await NativeMessageHandler.createProvider(
@@ -373,7 +379,10 @@ export class StandardController implements IController {
373
379
 
374
380
  this.initialized = true;
375
381
  this.eventHandler.emitEvent(EventType.INITIALIZE_END);
376
- initMeasurement.end({ allowNativeBroker, success: true });
382
+ initMeasurement.end({
383
+ allowPlatformBroker: allowPlatformBroker,
384
+ success: true,
385
+ });
377
386
  }
378
387
 
379
388
  // #region Redirect Flow
@@ -433,7 +442,7 @@ export class StandardController implements IController {
433
442
  this.browserStorage.getCachedNativeRequest();
434
443
  const useNative =
435
444
  request &&
436
- NativeMessageHandler.isNativeAvailable(
445
+ NativeMessageHandler.isPlatformBrokerAvailable(
437
446
  this.config,
438
447
  this.logger,
439
448
  this.nativeExtensionProvider
@@ -656,7 +665,10 @@ export class StandardController implements IController {
656
665
 
657
666
  let result: Promise<void>;
658
667
 
659
- if (this.nativeExtensionProvider && this.canUseNative(request)) {
668
+ if (
669
+ this.nativeExtensionProvider &&
670
+ this.canUsePlatformBroker(request)
671
+ ) {
660
672
  const nativeClient = new NativeInteractionClient(
661
673
  this.config,
662
674
  this.browserStorage,
@@ -770,7 +782,7 @@ export class StandardController implements IController {
770
782
 
771
783
  let result: Promise<AuthenticationResult>;
772
784
 
773
- if (this.canUseNative(request)) {
785
+ if (this.canUsePlatformBroker(request)) {
774
786
  result = this.acquireTokenNative(
775
787
  {
776
788
  ...request,
@@ -939,7 +951,7 @@ export class StandardController implements IController {
939
951
 
940
952
  let result: Promise<AuthenticationResult>;
941
953
 
942
- if (this.canUseNative(validRequest)) {
954
+ if (this.canUsePlatformBroker(validRequest)) {
943
955
  result = this.acquireTokenNative(
944
956
  validRequest,
945
957
  ApiId.ssoSilent
@@ -1087,7 +1099,9 @@ export class StandardController implements IController {
1087
1099
  }
1088
1100
  return await response;
1089
1101
  } else if (request.nativeAccountId) {
1090
- if (this.canUseNative(request, request.nativeAccountId)) {
1102
+ if (
1103
+ this.canUsePlatformBroker(request, request.nativeAccountId)
1104
+ ) {
1091
1105
  const result = await this.acquireTokenNative(
1092
1106
  {
1093
1107
  ...request,
@@ -1474,7 +1488,10 @@ export class StandardController implements IController {
1474
1488
  result.cloudGraphHostName,
1475
1489
  result.msGraphHost
1476
1490
  );
1477
- await this.browserStorage.setAccount(accountEntity);
1491
+ await this.browserStorage.setAccount(
1492
+ accountEntity,
1493
+ result.correlationId
1494
+ );
1478
1495
 
1479
1496
  if (result.fromNativeBroker) {
1480
1497
  this.logger.verbose(
@@ -1524,16 +1541,16 @@ export class StandardController implements IController {
1524
1541
  }
1525
1542
 
1526
1543
  /**
1527
- * Returns boolean indicating if this request can use the native broker
1544
+ * Returns boolean indicating if this request can use the platform broker
1528
1545
  * @param request
1529
1546
  */
1530
- public canUseNative(
1547
+ public canUsePlatformBroker(
1531
1548
  request: RedirectRequest | PopupRequest | SsoSilentRequest,
1532
1549
  accountId?: string
1533
1550
  ): boolean {
1534
- this.logger.trace("canUseNative called");
1551
+ this.logger.trace("canUsePlatformBroker called");
1535
1552
  if (
1536
- !NativeMessageHandler.isNativeAvailable(
1553
+ !NativeMessageHandler.isPlatformBrokerAvailable(
1537
1554
  this.config,
1538
1555
  this.logger,
1539
1556
  this.nativeExtensionProvider,
@@ -1541,7 +1558,7 @@ export class StandardController implements IController {
1541
1558
  )
1542
1559
  ) {
1543
1560
  this.logger.trace(
1544
- "canUseNative: isNativeAvailable returned false, returning false"
1561
+ "canUsePlatformBroker: isPlatformBrokerAvailable returned false, returning false"
1545
1562
  );
1546
1563
  return false;
1547
1564
  }
@@ -1552,12 +1569,12 @@ export class StandardController implements IController {
1552
1569
  case PromptValue.CONSENT:
1553
1570
  case PromptValue.LOGIN:
1554
1571
  this.logger.trace(
1555
- "canUseNative: prompt is compatible with native flow"
1572
+ "canUsePlatformBroker: prompt is compatible with platform broker flow"
1556
1573
  );
1557
1574
  break;
1558
1575
  default:
1559
1576
  this.logger.trace(
1560
- `canUseNative: prompt = ${request.prompt} is not compatible with native flow, returning false`
1577
+ `canUsePlatformBroker: prompt = ${request.prompt} is not compatible with platform broker flow, returning false`
1561
1578
  );
1562
1579
  return false;
1563
1580
  }
@@ -1565,7 +1582,7 @@ export class StandardController implements IController {
1565
1582
 
1566
1583
  if (!accountId && !this.getNativeAccountId(request)) {
1567
1584
  this.logger.trace(
1568
- "canUseNative: nativeAccountId is not available, returning false"
1585
+ "canUsePlatformBroker: nativeAccountId is not available, returning false"
1569
1586
  );
1570
1587
  return false;
1571
1588
  }
@@ -2254,7 +2271,7 @@ export class StandardController implements IController {
2254
2271
  cacheLookupPolicy: CacheLookupPolicy
2255
2272
  ): Promise<AuthenticationResult> {
2256
2273
  if (
2257
- NativeMessageHandler.isNativeAvailable(
2274
+ NativeMessageHandler.isPlatformBrokerAvailable(
2258
2275
  this.config,
2259
2276
  this.logger,
2260
2277
  this.nativeExtensionProvider,
@@ -105,12 +105,13 @@ export class UnknownOperatingContextController implements IController {
105
105
  this.config.cache,
106
106
  this.browserCrypto,
107
107
  this.logger,
108
- undefined,
109
- this.performanceClient
108
+ this.performanceClient,
109
+ undefined
110
110
  )
111
111
  : DEFAULT_BROWSER_CACHE_MANAGER(
112
112
  this.config.auth.clientId,
113
- this.logger
113
+ this.logger,
114
+ this.performanceClient
114
115
  );
115
116
  }
116
117
  getBrowserStorage(): BrowserCacheManager {
@@ -180,7 +181,7 @@ export class UnknownOperatingContextController implements IController {
180
181
  | "codeChallenge"
181
182
  | "codeChallengeMethod"
182
183
  | "requestedClaimsHash"
183
- | "nativeBroker"
184
+ | "platformBroker"
184
185
  >
185
186
  >,
186
187
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -287,7 +288,7 @@ export class UnknownOperatingContextController implements IController {
287
288
  | "codeChallenge"
288
289
  | "codeChallengeMethod"
289
290
  | "requestedClaimsHash"
290
- | "nativeBroker"
291
+ | "platformBroker"
291
292
  >
292
293
  >
293
294
  ): Promise<AuthenticationResult> {
@@ -58,7 +58,9 @@ const keygenAlgorithmOptions: RsaHashedKeyGenParams = {
58
58
  /**
59
59
  * Check whether browser crypto is available.
60
60
  */
61
- export function validateCryptoAvailable(): void {
61
+ export function validateCryptoAvailable(
62
+ skipValidateSubtleCrypto: boolean
63
+ ): void {
62
64
  if (!window) {
63
65
  throw createBrowserAuthError(
64
66
  BrowserAuthErrorCodes.nonBrowserEnvironment
@@ -67,7 +69,7 @@ export function validateCryptoAvailable(): void {
67
69
  if (!window.crypto) {
68
70
  throw createBrowserAuthError(BrowserAuthErrorCodes.cryptoNonExistent);
69
71
  }
70
- if (!window.crypto.subtle) {
72
+ if (!skipValidateSubtleCrypto && !window.crypto.subtle) {
71
73
  throw createBrowserAuthError(
72
74
  BrowserAuthErrorCodes.cryptoNonExistent,
73
75
  SUBTLE_SUBERROR
@@ -50,10 +50,16 @@ export class CryptoOps implements ICrypto {
50
50
  private static EXTRACTABLE: boolean = true;
51
51
  private cache: AsyncMemoryStorage<CachedKeyPair>;
52
52
 
53
- constructor(logger: Logger, performanceClient?: IPerformanceClient) {
53
+ constructor(
54
+ logger: Logger,
55
+ performanceClient?: IPerformanceClient,
56
+ skipValidateSubtleCrypto?: boolean
57
+ ) {
54
58
  this.logger = logger;
55
59
  // Browser crypto needs to be validated first before any other classes can be set.
56
- BrowserCrypto.validateCryptoAvailable();
60
+ BrowserCrypto.validateCryptoAvailable(
61
+ skipValidateSubtleCrypto ?? false
62
+ );
57
63
  this.cache = new AsyncMemoryStorage<CachedKeyPair>(this.logger);
58
64
  this.performanceClient = performanceClient;
59
65
  }
@@ -530,7 +530,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
530
530
 
531
531
  // cache accounts and tokens in the appropriate storage
532
532
  await this.cacheAccount(baseAccount);
533
- this.cacheNativeTokens(
533
+ await this.cacheNativeTokens(
534
534
  response,
535
535
  request,
536
536
  homeAccountIdentifier,
@@ -724,7 +724,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
724
724
  */
725
725
  async cacheAccount(accountEntity: AccountEntity): Promise<void> {
726
726
  // Store the account info and hence `nativeAccountId` in browser cache
727
- await this.browserStorage.setAccount(accountEntity);
727
+ await this.browserStorage.setAccount(accountEntity, this.correlationId);
728
728
 
729
729
  // Remove any existing cached tokens for this account in browser storage
730
730
  this.browserStorage.removeAccountContext(accountEntity).catch((e) => {
@@ -752,7 +752,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
752
752
  responseAccessToken: string,
753
753
  tenantId: string,
754
754
  reqTimestamp: number
755
- ): void {
755
+ ): Promise<void> {
756
756
  const cachedIdToken: IdTokenEntity | null =
757
757
  CacheHelpers.createIdTokenEntity(
758
758
  homeAccountIdentifier,
@@ -794,8 +794,9 @@ export class NativeInteractionClient extends BaseInteractionClient {
794
794
  accessToken: cachedAccessToken,
795
795
  };
796
796
 
797
- void this.nativeStorageManager.saveCacheRecord(
797
+ return this.nativeStorageManager.saveCacheRecord(
798
798
  nativeCacheRecord,
799
+ this.correlationId,
799
800
  request.storeInCache
800
801
  );
801
802
  }
@@ -227,15 +227,16 @@ export class PopupClient extends StandardInteractionClient {
227
227
  account: validRequest.account,
228
228
  });
229
229
 
230
- const isNativeBroker = NativeMessageHandler.isNativeAvailable(
231
- this.config,
232
- this.logger,
233
- this.nativeMessageHandler,
234
- request.authenticationScheme
235
- );
230
+ const isPlatformBroker =
231
+ NativeMessageHandler.isPlatformBrokerAvailable(
232
+ this.config,
233
+ this.logger,
234
+ this.nativeMessageHandler,
235
+ request.authenticationScheme
236
+ );
236
237
  // Start measurement for server calls with native brokering enabled
237
238
  let fetchNativeAccountIdMeasurement;
238
- if (isNativeBroker) {
239
+ if (isPlatformBroker) {
239
240
  fetchNativeAccountIdMeasurement =
240
241
  this.performanceClient.startMeasurement(
241
242
  PerformanceEvents.FetchAccountIdWithNativeBroker,
@@ -246,7 +247,7 @@ export class PopupClient extends StandardInteractionClient {
246
247
  // Create acquire token url.
247
248
  const navigateUrl = await authClient.getAuthCodeUrl({
248
249
  ...validRequest,
249
- nativeBroker: isNativeBroker,
250
+ platformBroker: isPlatformBroker,
250
251
  });
251
252
 
252
253
  // Create popup interaction handler.
@@ -170,7 +170,7 @@ export class RedirectClient extends StandardInteractionClient {
170
170
  // Create acquire token url.
171
171
  const navigateUrl = await authClient.getAuthCodeUrl({
172
172
  ...validRequest,
173
- nativeBroker: NativeMessageHandler.isNativeAvailable(
173
+ platformBroker: NativeMessageHandler.isPlatformBrokerAvailable(
174
174
  this.config,
175
175
  this.logger,
176
176
  this.nativeMessageHandler,
@@ -239,7 +239,7 @@ export class SilentIframeClient extends StandardInteractionClient {
239
239
  correlationId
240
240
  )({
241
241
  ...silentRequest,
242
- nativeBroker: NativeMessageHandler.isNativeAvailable(
242
+ platformBroker: NativeMessageHandler.isPlatformBrokerAvailable(
243
243
  this.config,
244
244
  this.logger,
245
245
  this.nativeMessageHandler,
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable header/header */
2
2
  export const name = "@azure/msal-browser";
3
- export const version = "4.0.0-alpha.0";
3
+ export const version = "4.0.1";
@@ -10,7 +10,7 @@ import { CommonAuthorizationUrlRequest } from "@azure/msal-common/browser";
10
10
  */
11
11
  export type AuthorizationUrlRequest = Omit<
12
12
  CommonAuthorizationUrlRequest,
13
- "state" | "nonce" | "requestedClaimsHash" | "nativeBroker"
13
+ "state" | "nonce" | "requestedClaimsHash" | "platformBroker"
14
14
  > & {
15
15
  state: string;
16
16
  nonce: string;
@@ -46,7 +46,7 @@ export type PopupRequest = Partial<
46
46
  | "codeChallenge"
47
47
  | "codeChallengeMethod"
48
48
  | "requestedClaimsHash"
49
- | "nativeBroker"
49
+ | "platformBroker"
50
50
  >
51
51
  > & {
52
52
  scopes: Array<string>;
@@ -44,7 +44,7 @@ export type RedirectRequest = Partial<
44
44
  | "codeChallenge"
45
45
  | "codeChallengeMethod"
46
46
  | "requestedClaimsHash"
47
- | "nativeBroker"
47
+ | "platformBroker"
48
48
  >
49
49
  > & {
50
50
  scopes: Array<string>;
@@ -40,7 +40,7 @@ export type SsoSilentRequest = Partial<
40
40
  | "codeChallenge"
41
41
  | "codeChallengeMethod"
42
42
  | "requestedClaimsHash"
43
- | "nativeBroker"
43
+ | "platformBroker"
44
44
  >
45
45
  > & {
46
46
  tokenBodyParameters?: StringDict;
@@ -67,7 +67,9 @@ export function isInPopup(): boolean {
67
67
  * Returns current window URL as redirect uri
68
68
  */
69
69
  export function getCurrentUri(): string {
70
- return window.location.href.split("?")[0].split("#")[0];
70
+ return typeof window !== "undefined" && window.location
71
+ ? window.location.href.split("?")[0].split("#")[0]
72
+ : "";
71
73
  }
72
74
 
73
75
  /**