@azure/msal-browser 3.28.1 → 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 (228) 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 +11 -51
  13. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  14. package/dist/cache/BrowserCacheManager.mjs +42 -291
  15. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  16. package/dist/cache/CacheHelpers.d.ts +16 -0
  17. package/dist/cache/CacheHelpers.d.ts.map +1 -0
  18. package/dist/cache/CacheHelpers.mjs +46 -0
  19. package/dist/cache/CacheHelpers.mjs.map +1 -0
  20. package/dist/cache/CookieStorage.d.ts +3 -0
  21. package/dist/cache/CookieStorage.d.ts.map +1 -1
  22. package/dist/cache/CookieStorage.mjs +12 -1
  23. package/dist/cache/CookieStorage.mjs.map +1 -1
  24. package/dist/cache/DatabaseStorage.mjs +1 -1
  25. package/dist/cache/ITokenCache.d.ts +1 -1
  26. package/dist/cache/ITokenCache.d.ts.map +1 -1
  27. package/dist/cache/IWindowStorage.d.ts +12 -0
  28. package/dist/cache/IWindowStorage.d.ts.map +1 -1
  29. package/dist/cache/LocalStorage.d.ts +38 -1
  30. package/dist/cache/LocalStorage.d.ts.map +1 -1
  31. package/dist/cache/LocalStorage.mjs +183 -2
  32. package/dist/cache/LocalStorage.mjs.map +1 -1
  33. package/dist/cache/MemoryStorage.d.ts +3 -0
  34. package/dist/cache/MemoryStorage.d.ts.map +1 -1
  35. package/dist/cache/MemoryStorage.mjs +10 -1
  36. package/dist/cache/MemoryStorage.mjs.map +1 -1
  37. package/dist/cache/SessionStorage.d.ts +3 -0
  38. package/dist/cache/SessionStorage.d.ts.map +1 -1
  39. package/dist/cache/SessionStorage.mjs +10 -1
  40. package/dist/cache/SessionStorage.mjs.map +1 -1
  41. package/dist/cache/TokenCache.d.ts +1 -1
  42. package/dist/cache/TokenCache.d.ts.map +1 -1
  43. package/dist/cache/TokenCache.mjs +16 -15
  44. package/dist/cache/TokenCache.mjs.map +1 -1
  45. package/dist/config/Configuration.d.ts +2 -2
  46. package/dist/config/Configuration.d.ts.map +1 -1
  47. package/dist/config/Configuration.mjs +5 -5
  48. package/dist/config/Configuration.mjs.map +1 -1
  49. package/dist/controllers/ControllerFactory.mjs +1 -1
  50. package/dist/controllers/NestedAppAuthController.d.ts +4 -3
  51. package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
  52. package/dist/controllers/NestedAppAuthController.mjs +8 -6
  53. package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
  54. package/dist/controllers/StandardController.d.ts +2 -2
  55. package/dist/controllers/StandardController.d.ts.map +1 -1
  56. package/dist/controllers/StandardController.mjs +27 -22
  57. package/dist/controllers/StandardController.mjs.map +1 -1
  58. package/dist/controllers/UnknownOperatingContextController.d.ts +2 -2
  59. package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -1
  60. package/dist/controllers/UnknownOperatingContextController.mjs +3 -3
  61. package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -1
  62. package/dist/crypto/BrowserCrypto.d.ts +27 -0
  63. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  64. package/dist/crypto/BrowserCrypto.mjs +83 -3
  65. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  66. package/dist/crypto/CryptoOps.mjs +1 -1
  67. package/dist/crypto/PkceGenerator.mjs +1 -1
  68. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  69. package/dist/encode/Base64Decode.d.ts +5 -0
  70. package/dist/encode/Base64Decode.d.ts.map +1 -1
  71. package/dist/encode/Base64Decode.mjs +2 -2
  72. package/dist/encode/Base64Decode.mjs.map +1 -1
  73. package/dist/encode/Base64Encode.mjs +1 -1
  74. package/dist/error/BrowserAuthError.mjs +1 -1
  75. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  76. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  77. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  78. package/dist/error/NativeAuthError.mjs +1 -1
  79. package/dist/error/NativeAuthError.mjs.map +1 -1
  80. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  81. package/dist/error/NestedAppAuthError.mjs +1 -1
  82. package/dist/event/EventHandler.mjs +1 -1
  83. package/dist/event/EventMessage.mjs +1 -1
  84. package/dist/event/EventType.mjs +1 -1
  85. package/dist/index.d.ts +0 -1
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.mjs +1 -2
  88. package/dist/index.mjs.map +1 -1
  89. package/dist/interaction_client/BaseInteractionClient.mjs +1 -1
  90. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  91. package/dist/interaction_client/NativeInteractionClient.d.ts +2 -2
  92. package/dist/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  93. package/dist/interaction_client/NativeInteractionClient.mjs +6 -6
  94. package/dist/interaction_client/NativeInteractionClient.mjs.map +1 -1
  95. package/dist/interaction_client/PopupClient.d.ts.map +1 -1
  96. package/dist/interaction_client/PopupClient.mjs +4 -4
  97. package/dist/interaction_client/PopupClient.mjs.map +1 -1
  98. package/dist/interaction_client/RedirectClient.mjs +2 -2
  99. package/dist/interaction_client/RedirectClient.mjs.map +1 -1
  100. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  101. package/dist/interaction_client/SilentCacheClient.mjs +1 -1
  102. package/dist/interaction_client/SilentIframeClient.mjs +2 -2
  103. package/dist/interaction_client/SilentIframeClient.mjs.map +1 -1
  104. package/dist/interaction_client/SilentRefreshClient.mjs +1 -1
  105. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  106. package/dist/interaction_client/StandardInteractionClient.mjs +1 -8
  107. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  108. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  109. package/dist/interaction_handler/RedirectHandler.mjs +1 -1
  110. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  111. package/dist/naa/BridgeError.mjs +1 -1
  112. package/dist/naa/BridgeProxy.mjs +1 -1
  113. package/dist/naa/BridgeStatusCode.mjs +1 -1
  114. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +1 -1
  115. package/dist/navigation/NavigationClient.mjs +1 -1
  116. package/dist/network/FetchClient.mjs +1 -1
  117. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  118. package/dist/operatingcontext/NestedAppOperatingContext.mjs +1 -1
  119. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  120. package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
  121. package/dist/packageMetadata.d.ts +1 -1
  122. package/dist/packageMetadata.d.ts.map +1 -1
  123. package/dist/packageMetadata.mjs +2 -2
  124. package/dist/request/AuthorizationUrlRequest.d.ts +1 -1
  125. package/dist/request/AuthorizationUrlRequest.d.ts.map +1 -1
  126. package/dist/request/PopupRequest.d.ts +1 -1
  127. package/dist/request/PopupRequest.d.ts.map +1 -1
  128. package/dist/request/RedirectRequest.d.ts +1 -1
  129. package/dist/request/RedirectRequest.d.ts.map +1 -1
  130. package/dist/request/RequestHelpers.mjs +1 -1
  131. package/dist/request/SsoSilentRequest.d.ts +1 -1
  132. package/dist/request/SsoSilentRequest.d.ts.map +1 -1
  133. package/dist/response/ResponseHandler.mjs +1 -1
  134. package/dist/telemetry/BrowserPerformanceClient.mjs +1 -1
  135. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  136. package/dist/utils/BrowserConstants.mjs +1 -1
  137. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  138. package/dist/utils/BrowserUtils.mjs +1 -1
  139. package/lib/msal-browser.cjs +630 -650
  140. package/lib/msal-browser.cjs.map +1 -1
  141. package/lib/msal-browser.js +630 -650
  142. package/lib/msal-browser.js.map +1 -1
  143. package/lib/msal-browser.min.js +65 -66
  144. package/lib/types/broker/nativeBroker/NativeMessageHandler.d.ts +1 -1
  145. package/lib/types/broker/nativeBroker/NativeMessageHandler.d.ts.map +1 -1
  146. package/lib/types/broker/nativeBroker/NativeResponse.d.ts +1 -1
  147. package/lib/types/cache/BrowserCacheManager.d.ts +11 -51
  148. package/lib/types/cache/BrowserCacheManager.d.ts.map +1 -1
  149. package/lib/types/cache/CacheHelpers.d.ts +16 -0
  150. package/lib/types/cache/CacheHelpers.d.ts.map +1 -0
  151. package/lib/types/cache/CookieStorage.d.ts +3 -0
  152. package/lib/types/cache/CookieStorage.d.ts.map +1 -1
  153. package/lib/types/cache/ITokenCache.d.ts +1 -1
  154. package/lib/types/cache/ITokenCache.d.ts.map +1 -1
  155. package/lib/types/cache/IWindowStorage.d.ts +12 -0
  156. package/lib/types/cache/IWindowStorage.d.ts.map +1 -1
  157. package/lib/types/cache/LocalStorage.d.ts +38 -1
  158. package/lib/types/cache/LocalStorage.d.ts.map +1 -1
  159. package/lib/types/cache/MemoryStorage.d.ts +3 -0
  160. package/lib/types/cache/MemoryStorage.d.ts.map +1 -1
  161. package/lib/types/cache/SessionStorage.d.ts +3 -0
  162. package/lib/types/cache/SessionStorage.d.ts.map +1 -1
  163. package/lib/types/cache/TokenCache.d.ts +1 -1
  164. package/lib/types/cache/TokenCache.d.ts.map +1 -1
  165. package/lib/types/config/Configuration.d.ts +2 -2
  166. package/lib/types/config/Configuration.d.ts.map +1 -1
  167. package/lib/types/controllers/NestedAppAuthController.d.ts +4 -3
  168. package/lib/types/controllers/NestedAppAuthController.d.ts.map +1 -1
  169. package/lib/types/controllers/StandardController.d.ts +2 -2
  170. package/lib/types/controllers/StandardController.d.ts.map +1 -1
  171. package/lib/types/controllers/UnknownOperatingContextController.d.ts +2 -2
  172. package/lib/types/controllers/UnknownOperatingContextController.d.ts.map +1 -1
  173. package/lib/types/crypto/BrowserCrypto.d.ts +27 -0
  174. package/lib/types/crypto/BrowserCrypto.d.ts.map +1 -1
  175. package/lib/types/encode/Base64Decode.d.ts +5 -0
  176. package/lib/types/encode/Base64Decode.d.ts.map +1 -1
  177. package/lib/types/index.d.ts +0 -1
  178. package/lib/types/index.d.ts.map +1 -1
  179. package/lib/types/interaction_client/NativeInteractionClient.d.ts +2 -2
  180. package/lib/types/interaction_client/NativeInteractionClient.d.ts.map +1 -1
  181. package/lib/types/interaction_client/PopupClient.d.ts.map +1 -1
  182. package/lib/types/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  183. package/lib/types/packageMetadata.d.ts +1 -1
  184. package/lib/types/packageMetadata.d.ts.map +1 -1
  185. package/lib/types/request/AuthorizationUrlRequest.d.ts +1 -1
  186. package/lib/types/request/AuthorizationUrlRequest.d.ts.map +1 -1
  187. package/lib/types/request/PopupRequest.d.ts +1 -1
  188. package/lib/types/request/PopupRequest.d.ts.map +1 -1
  189. package/lib/types/request/RedirectRequest.d.ts +1 -1
  190. package/lib/types/request/RedirectRequest.d.ts.map +1 -1
  191. package/lib/types/request/SsoSilentRequest.d.ts +1 -1
  192. package/lib/types/request/SsoSilentRequest.d.ts.map +1 -1
  193. package/package.json +2 -2
  194. package/src/broker/nativeBroker/NativeMessageHandler.ts +7 -7
  195. package/src/broker/nativeBroker/NativeResponse.ts +1 -1
  196. package/src/cache/BrowserCacheManager.ts +95 -422
  197. package/src/cache/CacheHelpers.ts +52 -0
  198. package/src/cache/CookieStorage.ts +18 -0
  199. package/src/cache/ITokenCache.ts +1 -1
  200. package/src/cache/IWindowStorage.ts +14 -0
  201. package/src/cache/LocalStorage.ts +330 -1
  202. package/src/cache/MemoryStorage.ts +12 -0
  203. package/src/cache/SessionStorage.ts +12 -0
  204. package/src/cache/TokenCache.ts +42 -25
  205. package/src/config/Configuration.ts +6 -6
  206. package/src/controllers/NestedAppAuthController.ts +14 -6
  207. package/src/controllers/StandardController.ts +41 -22
  208. package/src/controllers/UnknownOperatingContextController.ts +6 -5
  209. package/src/crypto/BrowserCrypto.ts +120 -1
  210. package/src/encode/Base64Decode.ts +1 -1
  211. package/src/index.ts +0 -1
  212. package/src/interaction_client/NativeInteractionClient.ts +7 -6
  213. package/src/interaction_client/PopupClient.ts +9 -8
  214. package/src/interaction_client/RedirectClient.ts +1 -1
  215. package/src/interaction_client/SilentIframeClient.ts +1 -1
  216. package/src/interaction_client/StandardInteractionClient.ts +0 -8
  217. package/src/packageMetadata.ts +1 -1
  218. package/src/request/AuthorizationUrlRequest.ts +1 -1
  219. package/src/request/PopupRequest.ts +1 -1
  220. package/src/request/RedirectRequest.ts +1 -1
  221. package/src/request/SsoSilentRequest.ts +1 -1
  222. package/dist/cache/BrowserStorage.d.ts +0 -14
  223. package/dist/cache/BrowserStorage.d.ts.map +0 -1
  224. package/dist/cache/BrowserStorage.mjs +0 -46
  225. package/dist/cache/BrowserStorage.mjs.map +0 -1
  226. package/lib/types/cache/BrowserStorage.d.ts +0 -14
  227. package/lib/types/cache/BrowserStorage.d.ts.map +0 -1
  228. package/src/cache/BrowserStorage.ts +0 -52
@@ -25,8 +25,6 @@ import {
25
25
  ActiveAccountFilters,
26
26
  CcsCredential,
27
27
  CcsCredentialType,
28
- AuthToken,
29
- ValidCredentialType,
30
28
  TokenKeys,
31
29
  CredentialType,
32
30
  CacheRecord,
@@ -39,6 +37,7 @@ import {
39
37
  CacheHelpers,
40
38
  StoreInCache,
41
39
  CacheError,
40
+ invokeAsync,
42
41
  } from "@azure/msal-common/browser";
43
42
  import { CacheOptions } from "../config/Configuration.js";
44
43
  import {
@@ -66,6 +65,7 @@ import { PopupRequest } from "../request/PopupRequest.js";
66
65
  import { base64Decode } from "../encode/Base64Decode.js";
67
66
  import { base64Encode } from "../encode/Base64Encode.js";
68
67
  import { CookieStorage } from "./CookieStorage.js";
68
+ import { getAccountKeys, getTokenKeys } from "./CacheHelpers.js";
69
69
 
70
70
  /**
71
71
  * This class implements the cache storage interface for MSAL through browser local or session storage.
@@ -86,15 +86,15 @@ export class BrowserCacheManager extends CacheManager {
86
86
  // Logger instance
87
87
  protected logger: Logger;
88
88
  // Telemetry perf client
89
- protected performanceClient?: IPerformanceClient;
89
+ protected performanceClient: IPerformanceClient;
90
90
 
91
91
  constructor(
92
92
  clientId: string,
93
93
  cacheConfig: Required<CacheOptions>,
94
94
  cryptoImpl: ICrypto,
95
95
  logger: Logger,
96
- staticAuthorityOptions?: StaticAuthorityOptions,
97
- performanceClient?: IPerformanceClient
96
+ performanceClient: IPerformanceClient,
97
+ staticAuthorityOptions?: StaticAuthorityOptions
98
98
  ) {
99
99
  super(clientId, cryptoImpl, logger, staticAuthorityOptions);
100
100
  this.cacheConfig = cacheConfig;
@@ -108,15 +108,13 @@ export class BrowserCacheManager extends CacheManager {
108
108
  );
109
109
  this.cookieStorage = new CookieStorage();
110
110
 
111
- // Migrate cache entries from older versions of MSAL.
112
- if (cacheConfig.cacheMigrationEnabled) {
113
- this.migrateCacheEntries();
114
- this.createKeyMaps();
115
- }
116
-
117
111
  this.performanceClient = performanceClient;
118
112
  }
119
113
 
114
+ async initialize(correlationId: string): Promise<void> {
115
+ await this.browserStorage.initialize(correlationId);
116
+ }
117
+
120
118
  /**
121
119
  * Returns a window storage class implementing the IWindowStorage interface that corresponds to the configured cacheLocation.
122
120
  * @param cacheLocation
@@ -127,7 +125,11 @@ export class BrowserCacheManager extends CacheManager {
127
125
  try {
128
126
  switch (cacheLocation) {
129
127
  case BrowserCacheLocation.LocalStorage:
130
- return new LocalStorage();
128
+ return new LocalStorage(
129
+ this.clientId,
130
+ this.logger,
131
+ this.performanceClient
132
+ );
131
133
  case BrowserCacheLocation.SessionStorage:
132
134
  return new SessionStorage();
133
135
  case BrowserCacheLocation.MemoryStorage:
@@ -141,188 +143,6 @@ export class BrowserCacheManager extends CacheManager {
141
143
  return new MemoryStorage();
142
144
  }
143
145
 
144
- /**
145
- * Migrate all old cache entries to new schema. No rollback supported.
146
- * @param storeAuthStateInCookie
147
- */
148
- protected migrateCacheEntries(): void {
149
- const idTokenKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ID_TOKEN}`;
150
- const clientInfoKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.CLIENT_INFO}`;
151
- const errorKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ERROR}`;
152
- const errorDescKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ERROR_DESC}`;
153
-
154
- const idTokenValue = this.browserStorage.getItem(idTokenKey);
155
- const clientInfoValue = this.browserStorage.getItem(clientInfoKey);
156
- const errorValue = this.browserStorage.getItem(errorKey);
157
- const errorDescValue = this.browserStorage.getItem(errorDescKey);
158
-
159
- const values = [
160
- idTokenValue,
161
- clientInfoValue,
162
- errorValue,
163
- errorDescValue,
164
- ];
165
- const keysToMigrate = [
166
- PersistentCacheKeys.ID_TOKEN,
167
- PersistentCacheKeys.CLIENT_INFO,
168
- PersistentCacheKeys.ERROR,
169
- PersistentCacheKeys.ERROR_DESC,
170
- ];
171
-
172
- keysToMigrate.forEach((cacheKey: string, index: number) => {
173
- const value = values[index];
174
- if (value) {
175
- this.setTemporaryCache(cacheKey, value, true);
176
- }
177
- });
178
- }
179
-
180
- /**
181
- * Searches all cache entries for MSAL accounts and creates the account key map
182
- * This is used to migrate users from older versions of MSAL which did not create the map.
183
- * @returns
184
- */
185
- private createKeyMaps(): void {
186
- this.logger.trace("BrowserCacheManager - createKeyMaps called.");
187
- const accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
188
- const tokenKeys = this.getItem(
189
- `${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`
190
- );
191
- if (accountKeys && tokenKeys) {
192
- this.logger.verbose(
193
- "BrowserCacheManager:createKeyMaps - account and token key maps already exist, skipping migration."
194
- );
195
- // Key maps already exist, no need to iterate through cache
196
- return;
197
- }
198
-
199
- const allKeys = this.browserStorage.getKeys();
200
- allKeys.forEach((key) => {
201
- if (this.isCredentialKey(key)) {
202
- // Get item, parse, validate and write key to map
203
- const value = this.getItem(key);
204
- if (value) {
205
- const credObj = this.validateAndParseJson(value);
206
- if (credObj && credObj.hasOwnProperty("credentialType")) {
207
- switch (credObj["credentialType"]) {
208
- case CredentialType.ID_TOKEN:
209
- if (CacheHelpers.isIdTokenEntity(credObj)) {
210
- this.logger.trace(
211
- "BrowserCacheManager:createKeyMaps - idToken found, saving key to token key map"
212
- );
213
- this.logger.tracePii(
214
- `BrowserCacheManager:createKeyMaps - idToken with key: ${key} found, saving key to token key map`
215
- );
216
- const idTokenEntity =
217
- credObj as IdTokenEntity;
218
- const newKey =
219
- this.updateCredentialCacheKey(
220
- key,
221
- idTokenEntity
222
- );
223
- this.addTokenKey(
224
- newKey,
225
- CredentialType.ID_TOKEN
226
- );
227
- return;
228
- } else {
229
- this.logger.trace(
230
- "BrowserCacheManager:createKeyMaps - key found matching idToken schema with value containing idToken credentialType field but value failed IdTokenEntity validation, skipping."
231
- );
232
- this.logger.tracePii(
233
- `BrowserCacheManager:createKeyMaps - failed idToken validation on key: ${key}`
234
- );
235
- }
236
- break;
237
- case CredentialType.ACCESS_TOKEN:
238
- case CredentialType.ACCESS_TOKEN_WITH_AUTH_SCHEME:
239
- if (CacheHelpers.isAccessTokenEntity(credObj)) {
240
- this.logger.trace(
241
- "BrowserCacheManager:createKeyMaps - accessToken found, saving key to token key map"
242
- );
243
- this.logger.tracePii(
244
- `BrowserCacheManager:createKeyMaps - accessToken with key: ${key} found, saving key to token key map`
245
- );
246
- const accessTokenEntity =
247
- credObj as AccessTokenEntity;
248
- const newKey =
249
- this.updateCredentialCacheKey(
250
- key,
251
- accessTokenEntity
252
- );
253
- this.addTokenKey(
254
- newKey,
255
- CredentialType.ACCESS_TOKEN
256
- );
257
- return;
258
- } else {
259
- this.logger.trace(
260
- "BrowserCacheManager:createKeyMaps - key found matching accessToken schema with value containing accessToken credentialType field but value failed AccessTokenEntity validation, skipping."
261
- );
262
- this.logger.tracePii(
263
- `BrowserCacheManager:createKeyMaps - failed accessToken validation on key: ${key}`
264
- );
265
- }
266
- break;
267
- case CredentialType.REFRESH_TOKEN:
268
- if (
269
- CacheHelpers.isRefreshTokenEntity(credObj)
270
- ) {
271
- this.logger.trace(
272
- "BrowserCacheManager:createKeyMaps - refreshToken found, saving key to token key map"
273
- );
274
- this.logger.tracePii(
275
- `BrowserCacheManager:createKeyMaps - refreshToken with key: ${key} found, saving key to token key map`
276
- );
277
- const refreshTokenEntity =
278
- credObj as RefreshTokenEntity;
279
- const newKey =
280
- this.updateCredentialCacheKey(
281
- key,
282
- refreshTokenEntity
283
- );
284
- this.addTokenKey(
285
- newKey,
286
- CredentialType.REFRESH_TOKEN
287
- );
288
- return;
289
- } else {
290
- this.logger.trace(
291
- "BrowserCacheManager:createKeyMaps - key found matching refreshToken schema with value containing refreshToken credentialType field but value failed RefreshTokenEntity validation, skipping."
292
- );
293
- this.logger.tracePii(
294
- `BrowserCacheManager:createKeyMaps - failed refreshToken validation on key: ${key}`
295
- );
296
- }
297
- break;
298
- default:
299
- // If credentialType isn't one of our predefined ones, it may not be an MSAL cache value. Ignore.
300
- }
301
- }
302
- }
303
- }
304
-
305
- if (this.isAccountKey(key)) {
306
- const value = this.getItem(key);
307
- if (value) {
308
- const accountObj = this.validateAndParseJson(value);
309
- if (
310
- accountObj &&
311
- AccountEntity.isAccountEntity(accountObj)
312
- ) {
313
- this.logger.trace(
314
- "BrowserCacheManager:createKeyMaps - account found, saving key to account key map"
315
- );
316
- this.logger.tracePii(
317
- `BrowserCacheManager:createKeyMaps - account with key: ${key} found, saving key to account key map`
318
- );
319
- this.addAccountKeyToMap(key);
320
- }
321
- }
322
- }
323
- });
324
- }
325
-
326
146
  /**
327
147
  * Parses passed value as JSON object, JSON.parse() will throw an error.
328
148
  * @param input
@@ -344,46 +164,15 @@ export class BrowserCacheManager extends CacheManager {
344
164
  }
345
165
  }
346
166
 
347
- /**
348
- * fetches the entry from the browser storage based off the key
349
- * @param key
350
- */
351
- getItem(key: string): string | null {
352
- return this.browserStorage.getItem(key);
353
- }
354
-
355
- /**
356
- * sets the entry in the browser storage
357
- * @param key
358
- * @param value
359
- */
360
- setItem(key: string, value: string): void {
361
- this.browserStorage.setItem(key, value);
362
- }
363
-
364
- /**
365
- * fetch the account entity from the platform cache
366
- * @param accountKey
367
- */
368
- getAccount(accountKey: string, logger?: Logger): AccountEntity | null {
369
- this.logger.trace("BrowserCacheManager.getAccount called");
370
- const accountEntity = this.getCachedAccountEntity(accountKey);
371
-
372
- return this.updateOutdatedCachedAccount(
373
- accountKey,
374
- accountEntity,
375
- logger
376
- );
377
- }
378
-
379
167
  /**
380
168
  * Reads account from cache, deserializes it into an account entity and returns it.
381
169
  * If account is not found from the key, returns null and removes key from map.
382
170
  * @param accountKey
383
171
  * @returns
384
172
  */
385
- getCachedAccountEntity(accountKey: string): AccountEntity | null {
386
- const serializedAccount = this.getItem(accountKey);
173
+ getAccount(accountKey: string): AccountEntity | null {
174
+ this.logger.trace("BrowserCacheManager.getAccount called");
175
+ const serializedAccount = this.browserStorage.getUserData(accountKey);
387
176
  if (!serializedAccount) {
388
177
  this.removeAccountKeyFromMap(accountKey);
389
178
  return null;
@@ -405,10 +194,18 @@ export class BrowserCacheManager extends CacheManager {
405
194
  * set account entity in the platform cache
406
195
  * @param account
407
196
  */
408
- setAccount(account: AccountEntity): void {
197
+ async setAccount(
198
+ account: AccountEntity,
199
+ correlationId: string
200
+ ): Promise<void> {
409
201
  this.logger.trace("BrowserCacheManager.setAccount called");
410
202
  const key = account.generateAccountKey();
411
- this.setItem(key, JSON.stringify(account));
203
+ await invokeAsync(
204
+ this.browserStorage.setUserData.bind(this.browserStorage),
205
+ PerformanceEvents.SetUserData,
206
+ this.logger,
207
+ this.performanceClient
208
+ )(key, JSON.stringify(account), correlationId);
412
209
  this.addAccountKeyToMap(key);
413
210
  }
414
211
 
@@ -417,16 +214,7 @@ export class BrowserCacheManager extends CacheManager {
417
214
  * @returns
418
215
  */
419
216
  getAccountKeys(): Array<string> {
420
- this.logger.trace("BrowserCacheManager.getAccountKeys called");
421
- const accountKeys = this.getItem(StaticCacheKeys.ACCOUNT_KEYS);
422
- if (accountKeys) {
423
- return JSON.parse(accountKeys);
424
- }
425
-
426
- this.logger.verbose(
427
- "BrowserCacheManager.getAccountKeys - No account keys found"
428
- );
429
- return [];
217
+ return getAccountKeys(this.browserStorage);
430
218
  }
431
219
 
432
220
  /**
@@ -442,7 +230,7 @@ export class BrowserCacheManager extends CacheManager {
442
230
  if (accountKeys.indexOf(key) === -1) {
443
231
  // Only add key if it does not already exist in the map
444
232
  accountKeys.push(key);
445
- this.setItem(
233
+ this.browserStorage.setItem(
446
234
  StaticCacheKeys.ACCOUNT_KEYS,
447
235
  JSON.stringify(accountKeys)
448
236
  );
@@ -469,7 +257,7 @@ export class BrowserCacheManager extends CacheManager {
469
257
  const removalIndex = accountKeys.indexOf(key);
470
258
  if (removalIndex > -1) {
471
259
  accountKeys.splice(removalIndex, 1);
472
- this.setItem(
260
+ this.browserStorage.setItem(
473
261
  StaticCacheKeys.ACCOUNT_KEYS,
474
262
  JSON.stringify(accountKeys)
475
263
  );
@@ -492,15 +280,6 @@ export class BrowserCacheManager extends CacheManager {
492
280
  this.removeAccountKeyFromMap(key);
493
281
  }
494
282
 
495
- /**
496
- * Remove account entity from the platform cache if it's outdated
497
- * @param accountKey
498
- */
499
- removeOutdatedAccount(accountKey: string): void {
500
- this.removeItem(accountKey);
501
- this.removeAccountKeyFromMap(accountKey);
502
- }
503
-
504
283
  /**
505
284
  * Removes given idToken from the cache and from the key map
506
285
  * @param key
@@ -533,35 +312,7 @@ export class BrowserCacheManager extends CacheManager {
533
312
  * @returns
534
313
  */
535
314
  getTokenKeys(): TokenKeys {
536
- this.logger.trace("BrowserCacheManager.getTokenKeys called");
537
- const item = this.getItem(
538
- `${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`
539
- );
540
- if (item) {
541
- const tokenKeys = this.validateAndParseJson(item);
542
- if (
543
- tokenKeys &&
544
- tokenKeys.hasOwnProperty("idToken") &&
545
- tokenKeys.hasOwnProperty("accessToken") &&
546
- tokenKeys.hasOwnProperty("refreshToken")
547
- ) {
548
- return tokenKeys as TokenKeys;
549
- } else {
550
- this.logger.error(
551
- "BrowserCacheManager.getTokenKeys - Token keys found but in an unknown format. Returning empty key map."
552
- );
553
- }
554
- } else {
555
- this.logger.verbose(
556
- "BrowserCacheManager.getTokenKeys - No token keys found"
557
- );
558
- }
559
-
560
- return {
561
- idToken: [],
562
- accessToken: [],
563
- refreshToken: [],
564
- };
315
+ return getTokenKeys(this.clientId, this.browserStorage);
565
316
  }
566
317
 
567
318
  /**
@@ -607,7 +358,7 @@ export class BrowserCacheManager extends CacheManager {
607
358
  );
608
359
  }
609
360
 
610
- this.setItem(
361
+ this.browserStorage.setItem(
611
362
  `${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`,
612
363
  JSON.stringify(tokenKeys)
613
364
  );
@@ -680,7 +431,7 @@ export class BrowserCacheManager extends CacheManager {
680
431
  );
681
432
  }
682
433
 
683
- this.setItem(
434
+ this.browserStorage.setItem(
684
435
  `${StaticCacheKeys.TOKEN_KEYS}.${this.clientId}`,
685
436
  JSON.stringify(tokenKeys)
686
437
  );
@@ -691,7 +442,7 @@ export class BrowserCacheManager extends CacheManager {
691
442
  * @param idTokenKey
692
443
  */
693
444
  getIdTokenCredential(idTokenKey: string): IdTokenEntity | null {
694
- const value = this.getItem(idTokenKey);
445
+ const value = this.browserStorage.getUserData(idTokenKey);
695
446
  if (!value) {
696
447
  this.logger.trace(
697
448
  "BrowserCacheManager.getIdTokenCredential: called, no cache hit"
@@ -719,11 +470,19 @@ export class BrowserCacheManager extends CacheManager {
719
470
  * set IdToken credential to the platform cache
720
471
  * @param idToken
721
472
  */
722
- setIdTokenCredential(idToken: IdTokenEntity): void {
473
+ async setIdTokenCredential(
474
+ idToken: IdTokenEntity,
475
+ correlationId: string
476
+ ): Promise<void> {
723
477
  this.logger.trace("BrowserCacheManager.setIdTokenCredential called");
724
478
  const idTokenKey = CacheHelpers.generateCredentialKey(idToken);
725
479
 
726
- this.setItem(idTokenKey, JSON.stringify(idToken));
480
+ await invokeAsync(
481
+ this.browserStorage.setUserData.bind(this.browserStorage),
482
+ PerformanceEvents.SetUserData,
483
+ this.logger,
484
+ this.performanceClient
485
+ )(idTokenKey, JSON.stringify(idToken), correlationId);
727
486
 
728
487
  this.addTokenKey(idTokenKey, CredentialType.ID_TOKEN);
729
488
  }
@@ -733,7 +492,7 @@ export class BrowserCacheManager extends CacheManager {
733
492
  * @param key
734
493
  */
735
494
  getAccessTokenCredential(accessTokenKey: string): AccessTokenEntity | null {
736
- const value = this.getItem(accessTokenKey);
495
+ const value = this.browserStorage.getUserData(accessTokenKey);
737
496
  if (!value) {
738
497
  this.logger.trace(
739
498
  "BrowserCacheManager.getAccessTokenCredential: called, no cache hit"
@@ -763,12 +522,20 @@ export class BrowserCacheManager extends CacheManager {
763
522
  * set accessToken credential to the platform cache
764
523
  * @param accessToken
765
524
  */
766
- setAccessTokenCredential(accessToken: AccessTokenEntity): void {
525
+ async setAccessTokenCredential(
526
+ accessToken: AccessTokenEntity,
527
+ correlationId: string
528
+ ): Promise<void> {
767
529
  this.logger.trace(
768
530
  "BrowserCacheManager.setAccessTokenCredential called"
769
531
  );
770
532
  const accessTokenKey = CacheHelpers.generateCredentialKey(accessToken);
771
- this.setItem(accessTokenKey, JSON.stringify(accessToken));
533
+ await invokeAsync(
534
+ this.browserStorage.setUserData.bind(this.browserStorage),
535
+ PerformanceEvents.SetUserData,
536
+ this.logger,
537
+ this.performanceClient
538
+ )(accessTokenKey, JSON.stringify(accessToken), correlationId);
772
539
 
773
540
  this.addTokenKey(accessTokenKey, CredentialType.ACCESS_TOKEN);
774
541
  }
@@ -780,7 +547,7 @@ export class BrowserCacheManager extends CacheManager {
780
547
  getRefreshTokenCredential(
781
548
  refreshTokenKey: string
782
549
  ): RefreshTokenEntity | null {
783
- const value = this.getItem(refreshTokenKey);
550
+ const value = this.browserStorage.getUserData(refreshTokenKey);
784
551
  if (!value) {
785
552
  this.logger.trace(
786
553
  "BrowserCacheManager.getRefreshTokenCredential: called, no cache hit"
@@ -810,13 +577,21 @@ export class BrowserCacheManager extends CacheManager {
810
577
  * set refreshToken credential to the platform cache
811
578
  * @param refreshToken
812
579
  */
813
- setRefreshTokenCredential(refreshToken: RefreshTokenEntity): void {
580
+ async setRefreshTokenCredential(
581
+ refreshToken: RefreshTokenEntity,
582
+ correlationId: string
583
+ ): Promise<void> {
814
584
  this.logger.trace(
815
585
  "BrowserCacheManager.setRefreshTokenCredential called"
816
586
  );
817
587
  const refreshTokenKey =
818
588
  CacheHelpers.generateCredentialKey(refreshToken);
819
- this.setItem(refreshTokenKey, JSON.stringify(refreshToken));
589
+ await invokeAsync(
590
+ this.browserStorage.setUserData.bind(this.browserStorage),
591
+ PerformanceEvents.SetUserData,
592
+ this.logger,
593
+ this.performanceClient
594
+ )(refreshTokenKey, JSON.stringify(refreshToken), correlationId);
820
595
 
821
596
  this.addTokenKey(refreshTokenKey, CredentialType.REFRESH_TOKEN);
822
597
  }
@@ -826,7 +601,7 @@ export class BrowserCacheManager extends CacheManager {
826
601
  * @param appMetadataKey
827
602
  */
828
603
  getAppMetadata(appMetadataKey: string): AppMetadataEntity | null {
829
- const value = this.getItem(appMetadataKey);
604
+ const value = this.browserStorage.getItem(appMetadataKey);
830
605
  if (!value) {
831
606
  this.logger.trace(
832
607
  "BrowserCacheManager.getAppMetadata: called, no cache hit"
@@ -856,7 +631,10 @@ export class BrowserCacheManager extends CacheManager {
856
631
  setAppMetadata(appMetadata: AppMetadataEntity): void {
857
632
  this.logger.trace("BrowserCacheManager.setAppMetadata called");
858
633
  const appMetadataKey = CacheHelpers.generateAppMetadataKey(appMetadata);
859
- this.setItem(appMetadataKey, JSON.stringify(appMetadata));
634
+ this.browserStorage.setItem(
635
+ appMetadataKey,
636
+ JSON.stringify(appMetadata)
637
+ );
860
638
  }
861
639
 
862
640
  /**
@@ -866,7 +644,7 @@ export class BrowserCacheManager extends CacheManager {
866
644
  getServerTelemetry(
867
645
  serverTelemetryKey: string
868
646
  ): ServerTelemetryEntity | null {
869
- const value = this.getItem(serverTelemetryKey);
647
+ const value = this.browserStorage.getItem(serverTelemetryKey);
870
648
  if (!value) {
871
649
  this.logger.trace(
872
650
  "BrowserCacheManager.getServerTelemetry: called, no cache hit"
@@ -901,7 +679,10 @@ export class BrowserCacheManager extends CacheManager {
901
679
  serverTelemetry: ServerTelemetryEntity
902
680
  ): void {
903
681
  this.logger.trace("BrowserCacheManager.setServerTelemetry called");
904
- this.setItem(serverTelemetryKey, JSON.stringify(serverTelemetry));
682
+ this.browserStorage.setItem(
683
+ serverTelemetryKey,
684
+ JSON.stringify(serverTelemetry)
685
+ );
905
686
  }
906
687
 
907
688
  /**
@@ -980,35 +761,13 @@ export class BrowserCacheManager extends CacheManager {
980
761
  const activeAccountKeyFilters = this.generateCacheKey(
981
762
  PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS
982
763
  );
983
- const activeAccountValueFilters = this.getItem(activeAccountKeyFilters);
764
+ const activeAccountValueFilters = this.browserStorage.getItem(
765
+ activeAccountKeyFilters
766
+ );
984
767
  if (!activeAccountValueFilters) {
985
- // if new active account cache type isn't found, it's an old version, so look for that instead
986
768
  this.logger.trace(
987
- "BrowserCacheManager.getActiveAccount: No active account filters cache schema found, looking for legacy schema"
988
- );
989
- const activeAccountKeyLocal = this.generateCacheKey(
990
- PersistentCacheKeys.ACTIVE_ACCOUNT
769
+ "BrowserCacheManager.getActiveAccount: No active account filters found"
991
770
  );
992
- const activeAccountValueLocal = this.getItem(activeAccountKeyLocal);
993
- if (!activeAccountValueLocal) {
994
- this.logger.trace(
995
- "BrowserCacheManager.getActiveAccount: No active account found"
996
- );
997
- return null;
998
- }
999
- const activeAccount = this.getAccountInfoFilteredBy({
1000
- localAccountId: activeAccountValueLocal,
1001
- });
1002
- if (activeAccount) {
1003
- this.logger.trace(
1004
- "BrowserCacheManager.getActiveAccount: Legacy active account cache schema found"
1005
- );
1006
- this.logger.trace(
1007
- "BrowserCacheManager.getActiveAccount: Adding active account filters cache schema"
1008
- );
1009
- this.setActiveAccount(activeAccount);
1010
- return activeAccount;
1011
- }
1012
771
  return null;
1013
772
  }
1014
773
  const activeAccountValueObj = this.validateAndParseJson(
@@ -1038,9 +797,6 @@ export class BrowserCacheManager extends CacheManager {
1038
797
  const activeAccountKey = this.generateCacheKey(
1039
798
  PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS
1040
799
  );
1041
- const activeAccountKeyLocal = this.generateCacheKey(
1042
- PersistentCacheKeys.ACTIVE_ACCOUNT
1043
- );
1044
800
  if (account) {
1045
801
  this.logger.verbose("setActiveAccount: Active account set");
1046
802
  const activeAccountValue: ActiveAccountFilters = {
@@ -1052,16 +808,11 @@ export class BrowserCacheManager extends CacheManager {
1052
808
  activeAccountKey,
1053
809
  JSON.stringify(activeAccountValue)
1054
810
  );
1055
- this.browserStorage.setItem(
1056
- activeAccountKeyLocal,
1057
- account.localAccountId
1058
- );
1059
811
  } else {
1060
812
  this.logger.verbose(
1061
813
  "setActiveAccount: No account passed, active account not set"
1062
814
  );
1063
815
  this.browserStorage.removeItem(activeAccountKey);
1064
- this.browserStorage.removeItem(activeAccountKeyLocal);
1065
816
  }
1066
817
  }
1067
818
 
@@ -1070,7 +821,7 @@ export class BrowserCacheManager extends CacheManager {
1070
821
  * @param throttlingCacheKey
1071
822
  */
1072
823
  getThrottlingCache(throttlingCacheKey: string): ThrottlingEntity | null {
1073
- const value = this.getItem(throttlingCacheKey);
824
+ const value = this.browserStorage.getItem(throttlingCacheKey);
1074
825
  if (!value) {
1075
826
  this.logger.trace(
1076
827
  "BrowserCacheManager.getThrottlingCache: called, no cache hit"
@@ -1106,7 +857,10 @@ export class BrowserCacheManager extends CacheManager {
1106
857
  throttlingCache: ThrottlingEntity
1107
858
  ): void {
1108
859
  this.logger.trace("BrowserCacheManager.setThrottlingCache called");
1109
- this.setItem(throttlingCacheKey, JSON.stringify(throttlingCache));
860
+ this.browserStorage.setItem(
861
+ throttlingCacheKey,
862
+ JSON.stringify(throttlingCache)
863
+ );
1110
864
  }
1111
865
 
1112
866
  /**
@@ -1287,10 +1041,7 @@ export class BrowserCacheManager extends CacheManager {
1287
1041
  generateCacheKey(key: string): string {
1288
1042
  const generatedKey = this.validateAndParseJson(key);
1289
1043
  if (!generatedKey) {
1290
- if (
1291
- StringUtils.startsWith(key, Constants.CACHE_PREFIX) ||
1292
- StringUtils.startsWith(key, PersistentCacheKeys.ADAL_ID_TOKEN)
1293
- ) {
1044
+ if (StringUtils.startsWith(key, Constants.CACHE_PREFIX)) {
1294
1045
  return key;
1295
1046
  }
1296
1047
  return `${Constants.CACHE_PREFIX}.${this.clientId}.${key}`;
@@ -1621,86 +1372,6 @@ export class BrowserCacheManager extends CacheManager {
1621
1372
  }
1622
1373
  }
1623
1374
 
1624
- /**
1625
- * Returns username retrieved from ADAL or MSAL v1 idToken
1626
- * @deprecated
1627
- */
1628
- getLegacyLoginHint(): string | null {
1629
- // Only check for adal/msal token if no SSO params are being used
1630
- const adalIdTokenString = this.getTemporaryCache(
1631
- PersistentCacheKeys.ADAL_ID_TOKEN
1632
- );
1633
- if (adalIdTokenString) {
1634
- this.browserStorage.removeItem(PersistentCacheKeys.ADAL_ID_TOKEN);
1635
- this.logger.verbose("Cached ADAL id token retrieved.");
1636
- }
1637
-
1638
- // Check for cached MSAL v1 id token
1639
- const msalIdTokenString = this.getTemporaryCache(
1640
- PersistentCacheKeys.ID_TOKEN,
1641
- true
1642
- );
1643
- if (msalIdTokenString) {
1644
- this.browserStorage.removeItem(
1645
- this.generateCacheKey(PersistentCacheKeys.ID_TOKEN)
1646
- );
1647
- this.logger.verbose("Cached MSAL.js v1 id token retrieved");
1648
- }
1649
-
1650
- const cachedIdTokenString = msalIdTokenString || adalIdTokenString;
1651
- if (cachedIdTokenString) {
1652
- const idTokenClaims = AuthToken.extractTokenClaims(
1653
- cachedIdTokenString,
1654
- base64Decode
1655
- );
1656
- if (idTokenClaims.preferred_username) {
1657
- this.logger.verbose(
1658
- "No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 preferred_username as loginHint"
1659
- );
1660
- return idTokenClaims.preferred_username;
1661
- } else if (idTokenClaims.upn) {
1662
- this.logger.verbose(
1663
- "No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 upn as loginHint"
1664
- );
1665
- return idTokenClaims.upn;
1666
- } else {
1667
- this.logger.verbose(
1668
- "No SSO params used and ADAL/MSAL v1 token retrieved, however, no account hint claim found. Enable preferred_username or upn id token claim to get SSO."
1669
- );
1670
- }
1671
- }
1672
-
1673
- return null;
1674
- }
1675
-
1676
- /**
1677
- * Updates a credential's cache key if the current cache key is outdated
1678
- */
1679
- updateCredentialCacheKey(
1680
- currentCacheKey: string,
1681
- credential: ValidCredentialType
1682
- ): string {
1683
- const updatedCacheKey = CacheHelpers.generateCredentialKey(credential);
1684
-
1685
- if (currentCacheKey !== updatedCacheKey) {
1686
- const cacheItem = this.getItem(currentCacheKey);
1687
- if (cacheItem) {
1688
- this.browserStorage.removeItem(currentCacheKey);
1689
- this.setItem(updatedCacheKey, cacheItem);
1690
- this.logger.verbose(
1691
- `Updated an outdated ${credential.credentialType} cache key`
1692
- );
1693
- return updatedCacheKey;
1694
- } else {
1695
- this.logger.error(
1696
- `Attempted to update an outdated ${credential.credentialType} cache key but no item matching the outdated key was found in storage`
1697
- );
1698
- }
1699
- }
1700
-
1701
- return currentCacheKey;
1702
- }
1703
-
1704
1375
  /**
1705
1376
  * Builds credential entities from AuthenticationResult object and saves the resulting credentials to the cache
1706
1377
  * @param result
@@ -1757,7 +1428,7 @@ export class BrowserCacheManager extends CacheManager {
1757
1428
  idToken: idTokenEntity,
1758
1429
  accessToken: accessTokenEntity,
1759
1430
  };
1760
- return this.saveCacheRecord(cacheRecord);
1431
+ return this.saveCacheRecord(cacheRecord, result.correlationId);
1761
1432
  }
1762
1433
 
1763
1434
  /**
@@ -1768,14 +1439,14 @@ export class BrowserCacheManager extends CacheManager {
1768
1439
  */
1769
1440
  async saveCacheRecord(
1770
1441
  cacheRecord: CacheRecord,
1771
- storeInCache?: StoreInCache,
1772
- correlationId?: string
1442
+ correlationId: string,
1443
+ storeInCache?: StoreInCache
1773
1444
  ): Promise<void> {
1774
1445
  try {
1775
1446
  await super.saveCacheRecord(
1776
1447
  cacheRecord,
1777
- storeInCache,
1778
- correlationId
1448
+ correlationId,
1449
+ storeInCache
1779
1450
  );
1780
1451
  } catch (e) {
1781
1452
  if (
@@ -1804,7 +1475,8 @@ export class BrowserCacheManager extends CacheManager {
1804
1475
 
1805
1476
  export const DEFAULT_BROWSER_CACHE_MANAGER = (
1806
1477
  clientId: string,
1807
- logger: Logger
1478
+ logger: Logger,
1479
+ performanceClient: IPerformanceClient
1808
1480
  ): BrowserCacheManager => {
1809
1481
  const cacheOptions: Required<CacheOptions> = {
1810
1482
  cacheLocation: BrowserCacheLocation.MemoryStorage,
@@ -1818,6 +1490,7 @@ export const DEFAULT_BROWSER_CACHE_MANAGER = (
1818
1490
  clientId,
1819
1491
  cacheOptions,
1820
1492
  DEFAULT_CRYPTO_IMPLEMENTATION,
1821
- logger
1493
+ logger,
1494
+ performanceClient
1822
1495
  );
1823
1496
  };