@azure/msal-browser 3.28.1 → 3.30.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 (127) 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.mjs +1 -1
  5. package/dist/broker/nativeBroker/NativeStatusCodes.mjs +1 -1
  6. package/dist/cache/AccountManager.d.ts +7 -7
  7. package/dist/cache/AccountManager.d.ts.map +1 -1
  8. package/dist/cache/AccountManager.mjs +17 -15
  9. package/dist/cache/AccountManager.mjs.map +1 -1
  10. package/dist/cache/AsyncMemoryStorage.mjs +1 -1
  11. package/dist/cache/BrowserCacheManager.d.ts +35 -27
  12. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  13. package/dist/cache/BrowserCacheManager.mjs +187 -91
  14. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  15. package/dist/cache/BrowserStorage.mjs +1 -1
  16. package/dist/cache/CookieStorage.mjs +1 -1
  17. package/dist/cache/DatabaseStorage.mjs +1 -1
  18. package/dist/cache/LocalStorage.mjs +1 -1
  19. package/dist/cache/MemoryStorage.mjs +1 -1
  20. package/dist/cache/SessionStorage.mjs +1 -1
  21. package/dist/cache/TokenCache.d.ts.map +1 -1
  22. package/dist/cache/TokenCache.mjs +16 -15
  23. package/dist/cache/TokenCache.mjs.map +1 -1
  24. package/dist/config/Configuration.mjs +1 -1
  25. package/dist/controllers/ControllerFactory.mjs +1 -1
  26. package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
  27. package/dist/controllers/NestedAppAuthController.mjs +28 -18
  28. package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
  29. package/dist/controllers/StandardController.d.ts.map +1 -1
  30. package/dist/controllers/StandardController.mjs +16 -9
  31. package/dist/controllers/StandardController.mjs.map +1 -1
  32. package/dist/controllers/UnknownOperatingContextController.mjs +1 -1
  33. package/dist/crypto/BrowserCrypto.mjs +1 -1
  34. package/dist/crypto/CryptoOps.mjs +1 -1
  35. package/dist/crypto/PkceGenerator.mjs +1 -1
  36. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  37. package/dist/encode/Base64Decode.mjs +1 -1
  38. package/dist/encode/Base64Encode.mjs +1 -1
  39. package/dist/error/BrowserAuthError.mjs +1 -1
  40. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  41. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  42. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  43. package/dist/error/NativeAuthError.mjs +1 -1
  44. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  45. package/dist/error/NestedAppAuthError.mjs +1 -1
  46. package/dist/event/EventHandler.mjs +1 -1
  47. package/dist/event/EventMessage.mjs +1 -1
  48. package/dist/event/EventType.mjs +1 -1
  49. package/dist/index.mjs +1 -1
  50. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  51. package/dist/interaction_client/BaseInteractionClient.mjs +5 -5
  52. package/dist/interaction_client/BaseInteractionClient.mjs.map +1 -1
  53. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  54. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  55. package/dist/interaction_client/NativeInteractionClient.mjs +9 -7
  56. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  57. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  58. package/dist/interaction_client/PopupClient.mjs +2 -2
  59. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  60. package/dist/interaction_client/RedirectClient.d.ts.map +1 -1
  61. package/dist/interaction_client/RedirectClient.mjs +2 -2
  62. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  63. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  64. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  65. package/dist/interaction_client/SilentIframeClient.mjs +1 -1
  66. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  67. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  68. package/dist/interaction_client/StandardInteractionClient.mjs +3 -2
  69. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  70. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  71. package/dist/interaction_handler/RedirectHandler.mjs +1 -1
  72. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  73. package/dist/naa/BridgeError.mjs +1 -1
  74. package/dist/naa/BridgeProxy.mjs +1 -1
  75. package/dist/naa/BridgeStatusCode.mjs +1 -1
  76. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  77. package/dist/navigation/NavigationClient.mjs +1 -1
  78. package/dist/network/FetchClient.mjs +1 -1
  79. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  80. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  81. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  82. package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
  83. package/dist/packageMetadata.d.ts +1 -1
  84. package/dist/packageMetadata.mjs +2 -2
  85. package/dist/request/RequestHelpers.mjs +1 -1
  86. package/dist/response/ResponseHandler.mjs +1 -1
  87. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  88. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  89. package/dist/utils/BrowserConstants.d.ts +1 -0
  90. package/dist/utils/BrowserConstants.d.ts.map +1 -1
  91. package/dist/utils/BrowserConstants.mjs +2 -1
  92. package/dist/utils/BrowserConstants.mjs.map +1 -1
  93. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  94. package/dist/utils/BrowserUtils.mjs +1 -1
  95. package/lib/msal-browser.cjs +464 -343
  96. package/lib/msal-browser.cjs.map +1 -1
  97. package/lib/msal-browser.js +464 -343
  98. package/lib/msal-browser.js.map +1 -1
  99. package/lib/msal-browser.min.js +65 -66
  100. package/lib/types/cache/AccountManager.d.ts +7 -7
  101. package/lib/types/cache/AccountManager.d.ts.map +1 -1
  102. package/lib/types/cache/BrowserCacheManager.d.ts +35 -27
  103. package/lib/types/cache/BrowserCacheManager.d.ts.map +1 -1
  104. package/lib/types/cache/TokenCache.d.ts.map +1 -1
  105. package/lib/types/controllers/NestedAppAuthController.d.ts.map +1 -1
  106. package/lib/types/controllers/StandardController.d.ts.map +1 -1
  107. package/lib/types/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  108. package/lib/types/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  109. package/lib/types/interaction_client/PopupClient.d.ts.map +1 -1
  110. package/lib/types/interaction_client/RedirectClient.d.ts.map +1 -1
  111. package/lib/types/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  112. package/lib/types/packageMetadata.d.ts +1 -1
  113. package/lib/types/utils/BrowserConstants.d.ts +1 -0
  114. package/lib/types/utils/BrowserConstants.d.ts.map +1 -1
  115. package/package.json +3 -3
  116. package/src/cache/AccountManager.ts +40 -20
  117. package/src/cache/BrowserCacheManager.ts +332 -109
  118. package/src/cache/TokenCache.ts +25 -11
  119. package/src/controllers/NestedAppAuthController.ts +51 -18
  120. package/src/controllers/StandardController.ts +26 -7
  121. package/src/interaction_client/BaseInteractionClient.ts +5 -4
  122. package/src/interaction_client/NativeInteractionClient.ts +22 -12
  123. package/src/interaction_client/PopupClient.ts +2 -1
  124. package/src/interaction_client/RedirectClient.ts +2 -1
  125. package/src/interaction_client/StandardInteractionClient.ts +2 -1
  126. package/src/packageMetadata.ts +1 -1
  127. package/src/utils/BrowserConstants.ts +1 -0
@@ -85,6 +85,8 @@ export class TokenCache implements ITokenCache {
85
85
  BrowserAuthErrorCodes.nonBrowserEnvironment
86
86
  );
87
87
  }
88
+ const correlationId =
89
+ request.correlationId || BrowserCrypto.createNewGuid();
88
90
 
89
91
  const idTokenClaims = response.id_token
90
92
  ? AuthToken.extractTokenClaims(response.id_token, base64Decode)
@@ -115,6 +117,7 @@ export class TokenCache implements ITokenCache {
115
117
  const cacheRecordAccount: AccountEntity = this.loadAccount(
116
118
  request,
117
119
  options.clientInfo || response.client_info || "",
120
+ correlationId,
118
121
  idTokenClaims,
119
122
  authority
120
123
  );
@@ -123,7 +126,8 @@ export class TokenCache implements ITokenCache {
123
126
  response,
124
127
  cacheRecordAccount.homeAccountId,
125
128
  cacheRecordAccount.environment,
126
- cacheRecordAccount.realm
129
+ cacheRecordAccount.realm,
130
+ correlationId
127
131
  );
128
132
 
129
133
  const accessToken = this.loadAccessToken(
@@ -132,13 +136,15 @@ export class TokenCache implements ITokenCache {
132
136
  cacheRecordAccount.homeAccountId,
133
137
  cacheRecordAccount.environment,
134
138
  cacheRecordAccount.realm,
135
- options
139
+ options,
140
+ correlationId
136
141
  );
137
142
 
138
143
  const refreshToken = this.loadRefreshToken(
139
144
  response,
140
145
  cacheRecordAccount.homeAccountId,
141
- cacheRecordAccount.environment
146
+ cacheRecordAccount.environment,
147
+ correlationId
142
148
  );
143
149
 
144
150
  return this.generateAuthenticationResult(
@@ -166,6 +172,7 @@ export class TokenCache implements ITokenCache {
166
172
  private loadAccount(
167
173
  request: SilentRequest,
168
174
  clientInfo: string,
175
+ correlationId: string,
169
176
  idTokenClaims?: TokenClaims,
170
177
  authority?: Authority
171
178
  ): AccountEntity {
@@ -175,7 +182,7 @@ export class TokenCache implements ITokenCache {
175
182
  const accountEntity = AccountEntity.createFromAccountInfo(
176
183
  request.account
177
184
  );
178
- this.storage.setAccount(accountEntity);
185
+ this.storage.setAccount(accountEntity, correlationId);
179
186
  return accountEntity;
180
187
  } else if (!authority || (!clientInfo && !idTokenClaims)) {
181
188
  this.logger.error(
@@ -201,6 +208,7 @@ export class TokenCache implements ITokenCache {
201
208
  authority,
202
209
  homeAccountId,
203
210
  base64Decode,
211
+ correlationId,
204
212
  idTokenClaims,
205
213
  clientInfo,
206
214
  authority.hostnameAndPort,
@@ -210,7 +218,7 @@ export class TokenCache implements ITokenCache {
210
218
  this.logger
211
219
  );
212
220
 
213
- this.storage.setAccount(cachedAccount);
221
+ this.storage.setAccount(cachedAccount, correlationId);
214
222
  return cachedAccount;
215
223
  }
216
224
 
@@ -226,7 +234,8 @@ export class TokenCache implements ITokenCache {
226
234
  response: ExternalTokenResponse,
227
235
  homeAccountId: string,
228
236
  environment: string,
229
- tenantId: string
237
+ tenantId: string,
238
+ correlationId: string
230
239
  ): IdTokenEntity | null {
231
240
  if (!response.id_token) {
232
241
  this.logger.verbose("TokenCache - no id token found in response");
@@ -242,7 +251,7 @@ export class TokenCache implements ITokenCache {
242
251
  tenantId
243
252
  );
244
253
 
245
- this.storage.setIdTokenCredential(idTokenEntity);
254
+ this.storage.setIdTokenCredential(idTokenEntity, correlationId);
246
255
  return idTokenEntity;
247
256
  }
248
257
 
@@ -261,7 +270,8 @@ export class TokenCache implements ITokenCache {
261
270
  homeAccountId: string,
262
271
  environment: string,
263
272
  tenantId: string,
264
- options: LoadTokenOptions
273
+ options: LoadTokenOptions,
274
+ correlationId: string
265
275
  ): AccessTokenEntity | null {
266
276
  if (!response.access_token) {
267
277
  this.logger.verbose(
@@ -309,7 +319,7 @@ export class TokenCache implements ITokenCache {
309
319
  base64Decode
310
320
  );
311
321
 
312
- this.storage.setAccessTokenCredential(accessTokenEntity);
322
+ this.storage.setAccessTokenCredential(accessTokenEntity, correlationId);
313
323
  return accessTokenEntity;
314
324
  }
315
325
 
@@ -324,7 +334,8 @@ export class TokenCache implements ITokenCache {
324
334
  private loadRefreshToken(
325
335
  response: ExternalTokenResponse,
326
336
  homeAccountId: string,
327
- environment: string
337
+ environment: string,
338
+ correlationId: string
328
339
  ): RefreshTokenEntity | null {
329
340
  if (!response.refresh_token) {
330
341
  this.logger.verbose(
@@ -344,7 +355,10 @@ export class TokenCache implements ITokenCache {
344
355
  response.refresh_token_expires_in
345
356
  );
346
357
 
347
- this.storage.setRefreshTokenCredential(refreshTokenEntity);
358
+ this.storage.setRefreshTokenCredential(
359
+ refreshTokenEntity,
360
+ correlationId
361
+ );
348
362
  return refreshTokenEntity;
349
363
  }
350
364
 
@@ -53,6 +53,7 @@ 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 * as BrowserCrypto from "../crypto/BrowserCrypto.js";
56
57
 
57
58
  export class NestedAppAuthController implements IController {
58
59
  // OperatingContext
@@ -131,13 +132,19 @@ export class NestedAppAuthController implements IController {
131
132
  // Set the active account if available
132
133
  const accountContext = this.bridgeProxy.getAccountContext();
133
134
  if (accountContext) {
135
+ const correlationId = BrowserCrypto.createNewGuid();
134
136
  const cachedAccount = AccountManager.getAccount(
135
137
  accountContext,
136
138
  this.logger,
137
- this.browserStorage
139
+ this.browserStorage,
140
+ correlationId
138
141
  );
139
142
 
140
- AccountManager.setActiveAccount(cachedAccount, this.browserStorage);
143
+ AccountManager.setActiveAccount(
144
+ cachedAccount,
145
+ this.browserStorage,
146
+ correlationId
147
+ );
141
148
  }
142
149
  }
143
150
 
@@ -224,7 +231,10 @@ export class NestedAppAuthController implements IController {
224
231
  // cache the tokens in the response
225
232
  await this.hydrateCache(result, request);
226
233
 
227
- this.browserStorage.setActiveAccount(result.account);
234
+ this.browserStorage.setActiveAccount(
235
+ result.account,
236
+ result.correlationId
237
+ );
228
238
  this.eventHandler.emitEvent(
229
239
  EventType.ACQUIRE_TOKEN_SUCCESS,
230
240
  InteractionType.Popup,
@@ -318,7 +328,10 @@ export class NestedAppAuthController implements IController {
318
328
  // cache the tokens in the response
319
329
  await this.hydrateCache(result, request);
320
330
 
321
- this.browserStorage.setActiveAccount(result.account);
331
+ this.browserStorage.setActiveAccount(
332
+ result.account,
333
+ result.correlationId
334
+ );
322
335
  this.eventHandler.emitEvent(
323
336
  EventType.ACQUIRE_TOKEN_SUCCESS,
324
337
  InteractionType.Silent,
@@ -428,13 +441,16 @@ export class NestedAppAuthController implements IController {
428
441
  private async acquireTokenFromCacheInternal(
429
442
  request: SilentRequest
430
443
  ): Promise<AuthenticationResult | null> {
444
+ const correlationId =
445
+ request.correlationId || BrowserCrypto.createNewGuid();
431
446
  const accountContext = this.bridgeProxy.getAccountContext();
432
447
  let currentAccount = null;
433
448
  if (accountContext) {
434
449
  const hubAccount = AccountManager.getAccount(
435
450
  accountContext,
436
451
  this.logger,
437
- this.browserStorage
452
+ this.browserStorage,
453
+ correlationId
438
454
  );
439
455
  // always prioritize for hub account context, the reqirement of `request.account` will be removed soon
440
456
  currentAccount = hubAccount || request.account;
@@ -454,8 +470,7 @@ export class NestedAppAuthController implements IController {
454
470
 
455
471
  const authRequest: BaseAuthRequest = {
456
472
  ...request,
457
- correlationId:
458
- request.correlationId || this.browserCrypto.createNewGuid(),
473
+ correlationId: correlationId,
459
474
  authority: request.authority || currentAccount.environment,
460
475
  scopes: request.scopes?.length
461
476
  ? request.scopes
@@ -469,8 +484,7 @@ export class NestedAppAuthController implements IController {
469
484
  authRequest,
470
485
  tokenKeys,
471
486
  currentAccount.tenantId,
472
- this.performanceClient,
473
- authRequest.correlationId
487
+ this.performanceClient
474
488
  );
475
489
 
476
490
  // If there is no access token, log it and return null
@@ -490,10 +504,10 @@ export class NestedAppAuthController implements IController {
490
504
 
491
505
  const cachedIdToken = this.browserStorage.getIdToken(
492
506
  currentAccount,
507
+ authRequest.correlationId,
493
508
  tokenKeys,
494
509
  currentAccount.tenantId,
495
- this.performanceClient,
496
- authRequest.correlationId
510
+ this.performanceClient
497
511
  );
498
512
 
499
513
  if (!cachedIdToken) {
@@ -636,10 +650,12 @@ export class NestedAppAuthController implements IController {
636
650
  * @returns Array of AccountInfo objects in cache
637
651
  */
638
652
  getAllAccounts(accountFilter?: AccountFilter): AccountInfo[] {
653
+ const correlationId = BrowserCrypto.createNewGuid();
639
654
  return AccountManager.getAllAccounts(
640
655
  this.logger,
641
656
  this.browserStorage,
642
657
  this.isBrowserEnv(),
658
+ correlationId,
643
659
  accountFilter
644
660
  );
645
661
  }
@@ -650,10 +666,12 @@ export class NestedAppAuthController implements IController {
650
666
  * @returns The first account found in the cache matching the provided filter or null if no account could be found.
651
667
  */
652
668
  getAccount(accountFilter: AccountFilter): AccountInfo | null {
669
+ const correlationId = BrowserCrypto.createNewGuid();
653
670
  return AccountManager.getAccount(
654
671
  accountFilter,
655
672
  this.logger,
656
- this.browserStorage
673
+ this.browserStorage,
674
+ correlationId
657
675
  );
658
676
  }
659
677
 
@@ -666,10 +684,12 @@ export class NestedAppAuthController implements IController {
666
684
  * @returns The account object stored in MSAL
667
685
  */
668
686
  getAccountByUsername(username: string): AccountInfo | null {
687
+ const correlationId = BrowserCrypto.createNewGuid();
669
688
  return AccountManager.getAccountByUsername(
670
689
  username,
671
690
  this.logger,
672
- this.browserStorage
691
+ this.browserStorage,
692
+ correlationId
673
693
  );
674
694
  }
675
695
 
@@ -681,10 +701,12 @@ export class NestedAppAuthController implements IController {
681
701
  * @returns The account object stored in MSAL
682
702
  */
683
703
  getAccountByHomeId(homeAccountId: string): AccountInfo | null {
704
+ const correlationId = BrowserCrypto.createNewGuid();
684
705
  return AccountManager.getAccountByHomeId(
685
706
  homeAccountId,
686
707
  this.logger,
687
- this.browserStorage
708
+ this.browserStorage,
709
+ correlationId
688
710
  );
689
711
  }
690
712
 
@@ -696,10 +718,12 @@ export class NestedAppAuthController implements IController {
696
718
  * @returns The account object stored in MSAL
697
719
  */
698
720
  getAccountByLocalId(localAccountId: string): AccountInfo | null {
721
+ const correlationId = BrowserCrypto.createNewGuid();
699
722
  return AccountManager.getAccountByLocalId(
700
723
  localAccountId,
701
724
  this.logger,
702
- this.browserStorage
725
+ this.browserStorage,
726
+ correlationId
703
727
  );
704
728
  }
705
729
 
@@ -712,14 +736,23 @@ export class NestedAppAuthController implements IController {
712
736
  * StandardController uses this to allow the developer to set the active account
713
737
  * in the nested app auth scenario the active account is controlled by the app hosting the nested app
714
738
  */
715
- return AccountManager.setActiveAccount(account, this.browserStorage);
739
+ const correlationId = BrowserCrypto.createNewGuid();
740
+ return AccountManager.setActiveAccount(
741
+ account,
742
+ this.browserStorage,
743
+ correlationId
744
+ );
716
745
  }
717
746
 
718
747
  /**
719
748
  * Gets the currently active account
720
749
  */
721
750
  getActiveAccount(): AccountInfo | null {
722
- return AccountManager.getActiveAccount(this.browserStorage);
751
+ const correlationId = BrowserCrypto.createNewGuid();
752
+ return AccountManager.getActiveAccount(
753
+ this.browserStorage,
754
+ correlationId
755
+ );
723
756
  }
724
757
 
725
758
  // #endregion
@@ -842,7 +875,7 @@ export class NestedAppAuthController implements IController {
842
875
  result.cloudGraphHostName,
843
876
  result.msGraphHost
844
877
  );
845
- this.browserStorage.setAccount(accountEntity);
878
+ this.browserStorage.setAccount(accountEntity, result.correlationId);
846
879
  return this.browserStorage.hydrateCache(result, request);
847
880
  }
848
881
  }
@@ -1366,10 +1366,12 @@ export class StandardController implements IController {
1366
1366
  * @returns Array of AccountInfo objects in cache
1367
1367
  */
1368
1368
  getAllAccounts(accountFilter?: AccountFilter): AccountInfo[] {
1369
+ const correlationId = this.getRequestCorrelationId();
1369
1370
  return AccountManager.getAllAccounts(
1370
1371
  this.logger,
1371
1372
  this.browserStorage,
1372
1373
  this.isBrowserEnvironment,
1374
+ correlationId,
1373
1375
  accountFilter
1374
1376
  );
1375
1377
  }
@@ -1380,10 +1382,12 @@ export class StandardController implements IController {
1380
1382
  * @returns The first account found in the cache matching the provided filter or null if no account could be found.
1381
1383
  */
1382
1384
  getAccount(accountFilter: AccountFilter): AccountInfo | null {
1385
+ const correlationId = this.getRequestCorrelationId();
1383
1386
  return AccountManager.getAccount(
1384
1387
  accountFilter,
1385
1388
  this.logger,
1386
- this.browserStorage
1389
+ this.browserStorage,
1390
+ correlationId
1387
1391
  );
1388
1392
  }
1389
1393
 
@@ -1396,10 +1400,12 @@ export class StandardController implements IController {
1396
1400
  * @returns The account object stored in MSAL
1397
1401
  */
1398
1402
  getAccountByUsername(username: string): AccountInfo | null {
1403
+ const correlationId = this.getRequestCorrelationId();
1399
1404
  return AccountManager.getAccountByUsername(
1400
1405
  username,
1401
1406
  this.logger,
1402
- this.browserStorage
1407
+ this.browserStorage,
1408
+ correlationId
1403
1409
  );
1404
1410
  }
1405
1411
 
@@ -1411,10 +1417,12 @@ export class StandardController implements IController {
1411
1417
  * @returns The account object stored in MSAL
1412
1418
  */
1413
1419
  getAccountByHomeId(homeAccountId: string): AccountInfo | null {
1420
+ const correlationId = this.getRequestCorrelationId();
1414
1421
  return AccountManager.getAccountByHomeId(
1415
1422
  homeAccountId,
1416
1423
  this.logger,
1417
- this.browserStorage
1424
+ this.browserStorage,
1425
+ correlationId
1418
1426
  );
1419
1427
  }
1420
1428
 
@@ -1426,10 +1434,12 @@ export class StandardController implements IController {
1426
1434
  * @returns The account object stored in MSAL
1427
1435
  */
1428
1436
  getAccountByLocalId(localAccountId: string): AccountInfo | null {
1437
+ const correlationId = this.getRequestCorrelationId();
1429
1438
  return AccountManager.getAccountByLocalId(
1430
1439
  localAccountId,
1431
1440
  this.logger,
1432
- this.browserStorage
1441
+ this.browserStorage,
1442
+ correlationId
1433
1443
  );
1434
1444
  }
1435
1445
 
@@ -1438,14 +1448,23 @@ export class StandardController implements IController {
1438
1448
  * @param account
1439
1449
  */
1440
1450
  setActiveAccount(account: AccountInfo | null): void {
1441
- AccountManager.setActiveAccount(account, this.browserStorage);
1451
+ const correlationId = this.getRequestCorrelationId();
1452
+ AccountManager.setActiveAccount(
1453
+ account,
1454
+ this.browserStorage,
1455
+ correlationId
1456
+ );
1442
1457
  }
1443
1458
 
1444
1459
  /**
1445
1460
  * Gets the currently active account
1446
1461
  */
1447
1462
  getActiveAccount(): AccountInfo | null {
1448
- return AccountManager.getActiveAccount(this.browserStorage);
1463
+ const correlationId = this.getRequestCorrelationId();
1464
+ return AccountManager.getActiveAccount(
1465
+ this.browserStorage,
1466
+ correlationId
1467
+ );
1449
1468
  }
1450
1469
 
1451
1470
  // #endregion
@@ -1472,7 +1491,7 @@ export class StandardController implements IController {
1472
1491
  result.cloudGraphHostName,
1473
1492
  result.msGraphHost
1474
1493
  );
1475
- this.browserStorage.setAccount(accountEntity);
1494
+ this.browserStorage.setAccount(accountEntity, result.correlationId);
1476
1495
 
1477
1496
  if (result.fromNativeBroker) {
1478
1497
  this.logger.verbose(
@@ -93,17 +93,18 @@ export abstract class BaseInteractionClient {
93
93
  if (
94
94
  AccountEntity.accountInfoIsEqual(
95
95
  account,
96
- this.browserStorage.getActiveAccount(),
96
+ this.browserStorage.getActiveAccount(this.correlationId),
97
97
  false
98
98
  )
99
99
  ) {
100
100
  this.logger.verbose("Setting active account to null");
101
- this.browserStorage.setActiveAccount(null);
101
+ this.browserStorage.setActiveAccount(null, this.correlationId);
102
102
  }
103
103
  // Clear given account.
104
104
  try {
105
105
  await this.browserStorage.removeAccount(
106
- AccountEntity.generateAccountCacheKey(account)
106
+ AccountEntity.generateAccountCacheKey(account),
107
+ this.correlationId
107
108
  );
108
109
  this.logger.verbose(
109
110
  "Cleared cache items belonging to the account provided in the logout request."
@@ -120,7 +121,7 @@ export abstract class BaseInteractionClient {
120
121
  this.correlationId
121
122
  );
122
123
  // Clear all accounts and tokens
123
- await this.browserStorage.clear();
124
+ await this.browserStorage.clear(this.correlationId);
124
125
  // Clear any stray keys from IndexedDB
125
126
  await this.browserCrypto.clearKeystore();
126
127
  } catch (e) {
@@ -281,9 +281,12 @@ export class NativeInteractionClient extends BaseInteractionClient {
281
281
  throw createClientAuthError(ClientAuthErrorCodes.noAccountFound);
282
282
  }
283
283
  // fetch the account from browser cache
284
- const account = this.browserStorage.getBaseAccountInfo({
285
- nativeAccountId,
286
- });
284
+ const account = this.browserStorage.getBaseAccountInfo(
285
+ {
286
+ nativeAccountId,
287
+ },
288
+ request.correlationId
289
+ );
287
290
 
288
291
  if (!account) {
289
292
  throw createClientAuthError(ClientAuthErrorCodes.noAccountFound);
@@ -487,9 +490,12 @@ export class NativeInteractionClient extends BaseInteractionClient {
487
490
  );
488
491
 
489
492
  const cachedhomeAccountId =
490
- this.browserStorage.getAccountInfoFilteredBy({
491
- nativeAccountId: request.accountId,
492
- })?.homeAccountId;
493
+ this.browserStorage.getAccountInfoFilteredBy(
494
+ {
495
+ nativeAccountId: request.accountId,
496
+ },
497
+ this.correlationId
498
+ )?.homeAccountId;
493
499
 
494
500
  if (
495
501
  homeAccountIdentifier !== cachedhomeAccountId &&
@@ -509,6 +515,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
509
515
  authority,
510
516
  homeAccountIdentifier,
511
517
  base64Decode,
518
+ this.correlationId,
512
519
  idTokenClaims,
513
520
  response.client_info,
514
521
  undefined, // environment
@@ -724,14 +731,16 @@ export class NativeInteractionClient extends BaseInteractionClient {
724
731
  */
725
732
  cacheAccount(accountEntity: AccountEntity): void {
726
733
  // Store the account info and hence `nativeAccountId` in browser cache
727
- this.browserStorage.setAccount(accountEntity);
734
+ this.browserStorage.setAccount(accountEntity, this.correlationId);
728
735
 
729
736
  // Remove any existing cached tokens for this account in browser storage
730
- this.browserStorage.removeAccountContext(accountEntity).catch((e) => {
731
- this.logger.error(
732
- `Error occurred while removing account context from browser storage. ${e}`
733
- );
734
- });
737
+ this.browserStorage
738
+ .removeAccountContext(accountEntity, this.correlationId)
739
+ .catch((e) => {
740
+ this.logger.error(
741
+ `Error occurred while removing account context from browser storage. ${e}`
742
+ );
743
+ });
735
744
  }
736
745
 
737
746
  /**
@@ -796,6 +805,7 @@ export class NativeInteractionClient extends BaseInteractionClient {
796
805
 
797
806
  void this.nativeStorageManager.saveCacheRecord(
798
807
  nativeCacheRecord,
808
+ request.correlationId,
799
809
  request.storeInCache
800
810
  );
801
811
  }
@@ -408,7 +408,8 @@ export class PopupClient extends StandardInteractionClient {
408
408
  authClient.authority.protocolMode === ProtocolMode.OIDC
409
409
  ) {
410
410
  void this.browserStorage.removeAccount(
411
- validRequest.account?.homeAccountId
411
+ validRequest.account?.homeAccountId,
412
+ this.correlationId
412
413
  );
413
414
 
414
415
  this.eventHandler.emitEvent(
@@ -567,7 +567,8 @@ export class RedirectClient extends StandardInteractionClient {
567
567
  } catch {
568
568
  if (validLogoutRequest.account?.homeAccountId) {
569
569
  void this.browserStorage.removeAccount(
570
- validLogoutRequest.account?.homeAccountId
570
+ validLogoutRequest.account?.homeAccountId,
571
+ this.correlationId
571
572
  );
572
573
 
573
574
  this.eventHandler.emitEvent(
@@ -368,7 +368,8 @@ export abstract class StandardInteractionClient extends BaseInteractionClient {
368
368
  }
369
369
 
370
370
  const account =
371
- request.account || this.browserStorage.getActiveAccount();
371
+ request.account ||
372
+ this.browserStorage.getActiveAccount(this.correlationId);
372
373
  if (account) {
373
374
  this.logger.verbose(
374
375
  "Setting validated request account",
@@ -1,3 +1,3 @@
1
1
  /* eslint-disable header/header */
2
2
  export const name = "@azure/msal-browser";
3
- export const version = "3.28.1";
3
+ export const version = "3.30.0";
@@ -100,6 +100,7 @@ export type TemporaryCacheKeys =
100
100
  export const StaticCacheKeys = {
101
101
  ACCOUNT_KEYS: "msal.account.keys",
102
102
  TOKEN_KEYS: "msal.token.keys",
103
+ VERSION: "msal.version",
103
104
  } as const;
104
105
  export type StaticCacheKeys =
105
106
  (typeof StaticCacheKeys)[keyof typeof StaticCacheKeys];