@azure/msal-browser 3.10.0 → 3.11.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 (148) 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/AsyncMemoryStorage.d.ts +2 -3
  7. package/dist/cache/AsyncMemoryStorage.d.ts.map +1 -1
  8. package/dist/cache/AsyncMemoryStorage.mjs +4 -5
  9. package/dist/cache/AsyncMemoryStorage.mjs.map +1 -1
  10. package/dist/cache/BrowserCacheManager.d.ts +8 -27
  11. package/dist/cache/BrowserCacheManager.d.ts.map +1 -1
  12. package/dist/cache/BrowserCacheManager.mjs +48 -75
  13. package/dist/cache/BrowserCacheManager.mjs.map +1 -1
  14. package/dist/cache/BrowserStorage.mjs +1 -1
  15. package/dist/cache/DatabaseStorage.d.ts +1 -1
  16. package/dist/cache/DatabaseStorage.d.ts.map +1 -1
  17. package/dist/cache/DatabaseStorage.mjs +14 -4
  18. package/dist/cache/DatabaseStorage.mjs.map +1 -1
  19. package/dist/cache/{IAsyncMemoryStorage.d.ts → IAsyncStorage.d.ts} +1 -1
  20. package/dist/cache/IAsyncStorage.d.ts.map +1 -0
  21. package/dist/cache/MemoryStorage.mjs +1 -1
  22. package/dist/cache/TokenCache.mjs +1 -1
  23. package/dist/config/Configuration.mjs +1 -1
  24. package/dist/controllers/ControllerFactory.mjs +1 -1
  25. package/dist/controllers/IController.d.ts +1 -3
  26. package/dist/controllers/IController.d.ts.map +1 -1
  27. package/dist/controllers/NestedAppAuthController.d.ts +2 -3
  28. package/dist/controllers/NestedAppAuthController.d.ts.map +1 -1
  29. package/dist/controllers/NestedAppAuthController.mjs +21 -19
  30. package/dist/controllers/NestedAppAuthController.mjs.map +1 -1
  31. package/dist/controllers/StandardController.d.ts +5 -23
  32. package/dist/controllers/StandardController.d.ts.map +1 -1
  33. package/dist/controllers/StandardController.mjs +47 -127
  34. package/dist/controllers/StandardController.mjs.map +1 -1
  35. package/dist/controllers/UnknownOperatingContextController.d.ts +1 -2
  36. package/dist/controllers/UnknownOperatingContextController.d.ts.map +1 -1
  37. package/dist/controllers/UnknownOperatingContextController.mjs +28 -36
  38. package/dist/controllers/UnknownOperatingContextController.mjs.map +1 -1
  39. package/dist/crypto/BrowserCrypto.d.ts +5 -0
  40. package/dist/crypto/BrowserCrypto.d.ts.map +1 -1
  41. package/dist/crypto/BrowserCrypto.mjs +12 -2
  42. package/dist/crypto/BrowserCrypto.mjs.map +1 -1
  43. package/dist/crypto/CryptoOps.d.ts.map +1 -1
  44. package/dist/crypto/CryptoOps.mjs +28 -12
  45. package/dist/crypto/CryptoOps.mjs.map +1 -1
  46. package/dist/crypto/PkceGenerator.mjs +1 -1
  47. package/dist/crypto/SignedHttpRequest.mjs +1 -1
  48. package/dist/encode/Base64Decode.mjs +1 -1
  49. package/dist/encode/Base64Encode.mjs +1 -1
  50. package/dist/error/BrowserAuthError.mjs +1 -1
  51. package/dist/error/BrowserAuthErrorCodes.mjs +1 -1
  52. package/dist/error/BrowserConfigurationAuthError.mjs +1 -1
  53. package/dist/error/BrowserConfigurationAuthErrorCodes.mjs +1 -1
  54. package/dist/error/NativeAuthError.mjs +1 -1
  55. package/dist/error/NativeAuthErrorCodes.mjs +1 -1
  56. package/dist/error/NestedAppAuthError.mjs +1 -1
  57. package/dist/event/EventHandler.mjs +1 -1
  58. package/dist/event/EventMessage.mjs +1 -1
  59. package/dist/event/EventType.mjs +1 -1
  60. package/dist/index.d.ts +1 -1
  61. package/dist/index.d.ts.map +1 -1
  62. package/dist/index.mjs +2 -2
  63. package/dist/interaction_client/BaseInteractionClient.d.ts +1 -6
  64. package/dist/interaction_client/BaseInteractionClient.d.ts.map +1 -1
  65. package/dist/interaction_client/BaseInteractionClient.mjs +2 -43
  66. package/dist/interaction_client/BaseInteractionClient.mjs.map +1 -1
  67. package/dist/interaction_client/HybridSpaAuthorizationCodeClient.mjs +1 -1
  68. package/dist/interaction_client/NativeInteractionClient.mjs +1 -1
  69. package/dist/interaction_client/PopupClient.mjs +1 -1
  70. package/dist/interaction_client/RedirectClient.mjs +1 -1
  71. package/dist/interaction_client/SilentAuthCodeClient.mjs +1 -1
  72. package/dist/interaction_client/SilentCacheClient.d.ts +1 -9
  73. package/dist/interaction_client/SilentCacheClient.d.ts.map +1 -1
  74. package/dist/interaction_client/SilentCacheClient.mjs +3 -22
  75. package/dist/interaction_client/SilentCacheClient.mjs.map +1 -1
  76. package/dist/interaction_client/SilentIframeClient.mjs +1 -1
  77. package/dist/interaction_client/SilentRefreshClient.d.ts.map +1 -1
  78. package/dist/interaction_client/SilentRefreshClient.mjs +3 -2
  79. package/dist/interaction_client/SilentRefreshClient.mjs.map +1 -1
  80. package/dist/interaction_client/StandardInteractionClient.d.ts.map +1 -1
  81. package/dist/interaction_client/StandardInteractionClient.mjs +3 -2
  82. package/dist/interaction_client/StandardInteractionClient.mjs.map +1 -1
  83. package/dist/interaction_handler/InteractionHandler.mjs +1 -1
  84. package/dist/interaction_handler/RedirectHandler.mjs +1 -1
  85. package/dist/interaction_handler/SilentHandler.mjs +1 -1
  86. package/dist/naa/BridgeError.mjs +1 -1
  87. package/dist/naa/BridgeProxy.mjs +1 -1
  88. package/dist/naa/BridgeStatusCode.mjs +1 -1
  89. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts +3 -1
  90. package/dist/naa/mapping/NestedAppAuthAdapter.d.ts.map +1 -1
  91. package/dist/naa/mapping/NestedAppAuthAdapter.mjs +4 -3
  92. package/dist/naa/mapping/NestedAppAuthAdapter.mjs.map +1 -1
  93. package/dist/navigation/NavigationClient.mjs +1 -1
  94. package/dist/network/FetchClient.mjs +1 -1
  95. package/dist/operatingcontext/BaseOperatingContext.mjs +1 -1
  96. package/dist/operatingcontext/StandardOperatingContext.mjs +1 -1
  97. package/dist/operatingcontext/TeamsAppOperatingContext.mjs +1 -1
  98. package/dist/operatingcontext/UnknownOperatingContext.mjs +1 -1
  99. package/dist/packageMetadata.d.ts +1 -1
  100. package/dist/packageMetadata.mjs +2 -2
  101. package/dist/request/RequestHelpers.d.ts +14 -0
  102. package/dist/request/RequestHelpers.d.ts.map +1 -0
  103. package/dist/request/RequestHelpers.mjs +61 -0
  104. package/dist/request/RequestHelpers.mjs.map +1 -0
  105. package/dist/response/ResponseHandler.mjs +1 -1
  106. package/dist/telemetry/BrowserPerformanceClient.d.ts +1 -1
  107. package/dist/telemetry/BrowserPerformanceClient.d.ts.map +1 -1
  108. package/dist/telemetry/BrowserPerformanceClient.mjs +5 -5
  109. package/dist/telemetry/BrowserPerformanceClient.mjs.map +1 -1
  110. package/dist/telemetry/BrowserPerformanceMeasurement.mjs +1 -1
  111. package/dist/utils/BrowserConstants.mjs +1 -1
  112. package/dist/utils/BrowserProtocolUtils.mjs +1 -1
  113. package/dist/utils/BrowserUtils.d.ts +14 -3
  114. package/dist/utils/BrowserUtils.d.ts.map +1 -1
  115. package/dist/utils/BrowserUtils.mjs +37 -10
  116. package/dist/utils/BrowserUtils.mjs.map +1 -1
  117. package/lib/msal-browser.cjs +866 -584
  118. package/lib/msal-browser.cjs.map +1 -1
  119. package/lib/msal-browser.js +866 -584
  120. package/lib/msal-browser.js.map +1 -1
  121. package/lib/msal-browser.min.js +66 -66
  122. package/package.json +2 -2
  123. package/src/cache/AsyncMemoryStorage.ts +4 -6
  124. package/src/cache/BrowserCacheManager.ts +54 -90
  125. package/src/cache/DatabaseStorage.ts +14 -4
  126. package/src/controllers/IController.ts +1 -7
  127. package/src/controllers/NestedAppAuthController.ts +38 -23
  128. package/src/controllers/StandardController.ts +107 -179
  129. package/src/controllers/UnknownOperatingContextController.ts +28 -37
  130. package/src/crypto/BrowserCrypto.ts +11 -0
  131. package/src/crypto/CryptoOps.ts +31 -13
  132. package/src/index.ts +2 -0
  133. package/src/interaction_client/BaseInteractionClient.ts +0 -66
  134. package/src/interaction_client/SilentCacheClient.ts +11 -51
  135. package/src/interaction_client/SilentRefreshClient.ts +3 -2
  136. package/src/interaction_client/StandardInteractionClient.ts +8 -2
  137. package/src/naa/mapping/NestedAppAuthAdapter.ts +10 -2
  138. package/src/packageMetadata.ts +1 -1
  139. package/src/request/RequestHelpers.ts +112 -0
  140. package/src/telemetry/BrowserPerformanceClient.ts +18 -9
  141. package/src/utils/BrowserUtils.ts +50 -15
  142. package/dist/cache/CryptoKeyStore.d.ts +0 -19
  143. package/dist/cache/CryptoKeyStore.d.ts.map +0 -1
  144. package/dist/cache/CryptoKeyStore.mjs +0 -47
  145. package/dist/cache/CryptoKeyStore.mjs.map +0 -1
  146. package/dist/cache/IAsyncMemoryStorage.d.ts.map +0 -1
  147. package/src/cache/CryptoKeyStore.ts +0 -63
  148. /package/src/cache/{IAsyncMemoryStorage.ts → IAsyncStorage.ts} +0 -0
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "type": "git",
11
11
  "url": "https://github.com/AzureAD/microsoft-authentication-library-for-js.git"
12
12
  },
13
- "version": "3.10.0",
13
+ "version": "3.11.1",
14
14
  "description": "Microsoft Authentication Library for js",
15
15
  "keywords": [
16
16
  "implicit",
@@ -101,6 +101,6 @@
101
101
  "typescript": "^4.9.5"
102
102
  },
103
103
  "dependencies": {
104
- "@azure/msal-common": "14.7.1"
104
+ "@azure/msal-common": "14.8.1"
105
105
  }
106
106
  }
@@ -9,7 +9,7 @@ import {
9
9
  BrowserAuthErrorCodes,
10
10
  } from "../error/BrowserAuthError";
11
11
  import { DatabaseStorage } from "./DatabaseStorage";
12
- import { IAsyncStorage } from "./IAsyncMemoryStorage";
12
+ import { IAsyncStorage } from "./IAsyncStorage";
13
13
  import { MemoryStorage } from "./MemoryStorage";
14
14
 
15
15
  /**
@@ -20,13 +20,11 @@ export class AsyncMemoryStorage<T> implements IAsyncStorage<T> {
20
20
  private inMemoryCache: MemoryStorage<T>;
21
21
  private indexedDBCache: DatabaseStorage<T>;
22
22
  private logger: Logger;
23
- private storeName: string;
24
23
 
25
- constructor(logger: Logger, storeName: string) {
24
+ constructor(logger: Logger) {
26
25
  this.inMemoryCache = new MemoryStorage<T>();
27
26
  this.indexedDBCache = new DatabaseStorage<T>();
28
27
  this.logger = logger;
29
- this.storeName = storeName;
30
28
  }
31
29
 
32
30
  private handleDatabaseAccessError(error: unknown): void {
@@ -132,9 +130,9 @@ export class AsyncMemoryStorage<T> implements IAsyncStorage<T> {
132
130
  */
133
131
  clearInMemory(): void {
134
132
  // InMemory cache is a Map instance, clear is straightforward
135
- this.logger.verbose(`Deleting in-memory keystore ${this.storeName}`);
133
+ this.logger.verbose(`Deleting in-memory keystore`);
136
134
  this.inMemoryCache.clear();
137
- this.logger.verbose(`In-memory keystore ${this.storeName} deleted`);
135
+ this.logger.verbose(`In-memory keystore deleted`);
138
136
  }
139
137
 
140
138
  /**
@@ -189,21 +189,12 @@ export class BrowserCacheManager extends CacheManager {
189
189
  PersistentCacheKeys.ERROR_DESC,
190
190
  ];
191
191
 
192
- keysToMigrate.forEach((cacheKey: string, index: number) =>
193
- this.migrateCacheEntry(cacheKey, values[index])
194
- );
195
- }
196
-
197
- /**
198
- * Utility function to help with migration.
199
- * @param newKey
200
- * @param value
201
- * @param storeAuthStateInCookie
202
- */
203
- protected migrateCacheEntry(newKey: string, value: string | null): void {
204
- if (value) {
205
- this.setTemporaryCache(newKey, value, true);
206
- }
192
+ keysToMigrate.forEach((cacheKey: string, index: number) => {
193
+ const value = values[index];
194
+ if (value) {
195
+ this.setTemporaryCache(cacheKey, value, true);
196
+ }
197
+ });
207
198
  }
208
199
 
209
200
  /**
@@ -1206,11 +1197,18 @@ export class BrowserCacheManager extends CacheManager {
1206
1197
 
1207
1198
  /**
1208
1199
  * Removes the cache item with the given key.
1209
- * Will also clear the cookie item if storeAuthStateInCookie is set to true.
1210
1200
  * @param key
1211
1201
  */
1212
1202
  removeItem(key: string): void {
1213
1203
  this.browserStorage.removeItem(key);
1204
+ }
1205
+
1206
+ /**
1207
+ * Removes the temporary cache item with the given key.
1208
+ * Will also clear the cookie item if storeAuthStateInCookie is set to true.
1209
+ * @param key
1210
+ */
1211
+ removeTemporaryItem(key: string): void {
1214
1212
  this.temporaryCacheStorage.removeItem(key);
1215
1213
  if (this.cacheConfig.storeAuthStateInCookie) {
1216
1214
  this.logger.trace(
@@ -1220,25 +1218,11 @@ export class BrowserCacheManager extends CacheManager {
1220
1218
  }
1221
1219
  }
1222
1220
 
1223
- /**
1224
- * Checks whether key is in cache.
1225
- * @param key
1226
- */
1227
- containsKey(key: string): boolean {
1228
- return (
1229
- this.browserStorage.containsKey(key) ||
1230
- this.temporaryCacheStorage.containsKey(key)
1231
- );
1232
- }
1233
-
1234
1221
  /**
1235
1222
  * Gets all keys in window.
1236
1223
  */
1237
1224
  getKeys(): string[] {
1238
- return [
1239
- ...this.browserStorage.getKeys(),
1240
- ...this.temporaryCacheStorage.getKeys(),
1241
- ];
1225
+ return this.browserStorage.getKeys();
1242
1226
  }
1243
1227
 
1244
1228
  /**
@@ -1249,16 +1233,23 @@ export class BrowserCacheManager extends CacheManager {
1249
1233
  await this.removeAllAccounts();
1250
1234
  this.removeAppMetadata();
1251
1235
 
1236
+ // Remove temp storage first to make sure any cookies are cleared
1237
+ this.temporaryCacheStorage.getKeys().forEach((cacheKey: string) => {
1238
+ if (
1239
+ cacheKey.indexOf(Constants.CACHE_PREFIX) !== -1 ||
1240
+ cacheKey.indexOf(this.clientId) !== -1
1241
+ ) {
1242
+ this.removeTemporaryItem(cacheKey);
1243
+ }
1244
+ });
1245
+
1252
1246
  // Removes all remaining MSAL cache items
1253
- this.getKeys().forEach((cacheKey: string) => {
1254
- // Check if key contains msal prefix; For now, we are clearing all the cache items created by MSAL.js
1247
+ this.browserStorage.getKeys().forEach((cacheKey: string) => {
1255
1248
  if (
1256
- (this.browserStorage.containsKey(cacheKey) ||
1257
- this.temporaryCacheStorage.containsKey(cacheKey)) &&
1258
- (cacheKey.indexOf(Constants.CACHE_PREFIX) !== -1 ||
1259
- cacheKey.indexOf(this.clientId) !== -1)
1249
+ cacheKey.indexOf(Constants.CACHE_PREFIX) !== -1 ||
1250
+ cacheKey.indexOf(this.clientId) !== -1
1260
1251
  ) {
1261
- this.removeItem(cacheKey);
1252
+ this.browserStorage.removeItem(cacheKey);
1262
1253
  }
1263
1254
  });
1264
1255
 
@@ -1305,6 +1296,7 @@ export class BrowserCacheManager extends CacheManager {
1305
1296
  * @param cookieName
1306
1297
  * @param cookieValue
1307
1298
  * @param expires
1299
+ * @deprecated
1308
1300
  */
1309
1301
  setItemCookie(
1310
1302
  cookieName: string,
@@ -1329,6 +1321,7 @@ export class BrowserCacheManager extends CacheManager {
1329
1321
  /**
1330
1322
  * Get one item by key from cookies
1331
1323
  * @param cookieName
1324
+ * @deprecated
1332
1325
  */
1333
1326
  getItemCookie(cookieName: string): string {
1334
1327
  const name = `${encodeURIComponent(cookieName)}=`;
@@ -1349,6 +1342,7 @@ export class BrowserCacheManager extends CacheManager {
1349
1342
 
1350
1343
  /**
1351
1344
  * Clear all msal-related cookies currently set in the browser. Should only be used to clear temporary cache items.
1345
+ * @deprecated
1352
1346
  */
1353
1347
  clearMsalCookies(): void {
1354
1348
  const cookiePrefix = `${Constants.CACHE_PREFIX}.${this.clientId}`;
@@ -1368,6 +1362,7 @@ export class BrowserCacheManager extends CacheManager {
1368
1362
  /**
1369
1363
  * Clear an item in the cookies by key
1370
1364
  * @param cookieName
1365
+ * @deprecated
1371
1366
  */
1372
1367
  clearItemCookie(cookieName: string): void {
1373
1368
  this.setItemCookie(cookieName, Constants.EMPTY_STRING, -1);
@@ -1376,6 +1371,7 @@ export class BrowserCacheManager extends CacheManager {
1376
1371
  /**
1377
1372
  * Get cookie expiration time
1378
1373
  * @param cookieLifeDays
1374
+ * @deprecated
1379
1375
  */
1380
1376
  getCookieExpirationTime(cookieLifeDays: number): string {
1381
1377
  const today = new Date();
@@ -1385,20 +1381,6 @@ export class BrowserCacheManager extends CacheManager {
1385
1381
  return expr.toUTCString();
1386
1382
  }
1387
1383
 
1388
- /**
1389
- * Gets the cache object referenced by the browser
1390
- */
1391
- getCache(): object {
1392
- return this.browserStorage;
1393
- }
1394
-
1395
- /**
1396
- * interface compat, we cannot overwrite browser cache; Functionality is supported by individual entities in browser
1397
- */
1398
- setCache(): void {
1399
- // sets nothing
1400
- }
1401
-
1402
1384
  /**
1403
1385
  * Prepend msal.<client-id> to each key; Skip for any JSON object as Key (defined schemas do not need the key appended: AccessToken Keys or the upcoming schema)
1404
1386
  * @param key
@@ -1531,29 +1513,33 @@ export class BrowserCacheManager extends CacheManager {
1531
1513
  this.logger.trace("BrowserCacheManager.resetRequestCache called");
1532
1514
  // check state and remove associated cache items
1533
1515
  if (state) {
1534
- this.getKeys().forEach((key) => {
1516
+ this.temporaryCacheStorage.getKeys().forEach((key) => {
1535
1517
  if (key.indexOf(state) !== -1) {
1536
- this.removeItem(key);
1518
+ this.removeTemporaryItem(key);
1537
1519
  }
1538
1520
  });
1539
1521
 
1540
1522
  // delete generic interactive request parameters
1541
- this.removeItem(this.generateStateKey(state));
1542
- this.removeItem(this.generateNonceKey(state));
1543
- this.removeItem(this.generateAuthorityKey(state));
1523
+ this.removeTemporaryItem(this.generateStateKey(state));
1524
+ this.removeTemporaryItem(this.generateNonceKey(state));
1525
+ this.removeTemporaryItem(this.generateAuthorityKey(state));
1544
1526
  }
1545
- this.removeItem(
1527
+ this.removeTemporaryItem(
1546
1528
  this.generateCacheKey(TemporaryCacheKeys.REQUEST_PARAMS)
1547
1529
  );
1548
- this.removeItem(this.generateCacheKey(TemporaryCacheKeys.ORIGIN_URI));
1549
- this.removeItem(this.generateCacheKey(TemporaryCacheKeys.URL_HASH));
1550
- this.removeItem(
1530
+ this.removeTemporaryItem(
1531
+ this.generateCacheKey(TemporaryCacheKeys.ORIGIN_URI)
1532
+ );
1533
+ this.removeTemporaryItem(
1534
+ this.generateCacheKey(TemporaryCacheKeys.URL_HASH)
1535
+ );
1536
+ this.removeTemporaryItem(
1551
1537
  this.generateCacheKey(TemporaryCacheKeys.CORRELATION_ID)
1552
1538
  );
1553
- this.removeItem(
1539
+ this.removeTemporaryItem(
1554
1540
  this.generateCacheKey(TemporaryCacheKeys.CCS_CREDENTIAL)
1555
1541
  );
1556
- this.removeItem(
1542
+ this.removeTemporaryItem(
1557
1543
  this.generateCacheKey(TemporaryCacheKeys.NATIVE_REQUEST)
1558
1544
  );
1559
1545
  this.setInteractionInProgress(false);
@@ -1587,7 +1573,7 @@ export class BrowserCacheManager extends CacheManager {
1587
1573
  "BrowserCacheManager.cleanRequestByInteractionType called"
1588
1574
  );
1589
1575
  // Loop through all keys to find state key
1590
- this.getKeys().forEach((key) => {
1576
+ this.temporaryCacheStorage.getKeys().forEach((key) => {
1591
1577
  // If this key is not the state key, move on
1592
1578
  if (key.indexOf(TemporaryCacheKeys.REQUEST_STATE) === -1) {
1593
1579
  return;
@@ -1656,7 +1642,7 @@ export class BrowserCacheManager extends CacheManager {
1656
1642
  BrowserAuthErrorCodes.unableToParseTokenRequestCacheError
1657
1643
  );
1658
1644
  }
1659
- this.removeItem(
1645
+ this.removeTemporaryItem(
1660
1646
  this.generateCacheKey(TemporaryCacheKeys.REQUEST_PARAMS)
1661
1647
  );
1662
1648
 
@@ -1735,7 +1721,7 @@ export class BrowserCacheManager extends CacheManager {
1735
1721
  !inProgress &&
1736
1722
  this.getInteractionInProgress() === this.clientId
1737
1723
  ) {
1738
- this.removeItem(key);
1724
+ this.removeTemporaryItem(key);
1739
1725
  }
1740
1726
  }
1741
1727
 
@@ -1759,7 +1745,7 @@ export class BrowserCacheManager extends CacheManager {
1759
1745
  true
1760
1746
  );
1761
1747
  if (msalIdTokenString) {
1762
- this.removeItem(
1748
+ this.browserStorage.removeItem(
1763
1749
  this.generateCacheKey(PersistentCacheKeys.ID_TOKEN)
1764
1750
  );
1765
1751
  this.logger.verbose("Cached MSAL.js v1 id token retrieved");
@@ -1803,7 +1789,7 @@ export class BrowserCacheManager extends CacheManager {
1803
1789
  if (currentCacheKey !== updatedCacheKey) {
1804
1790
  const cacheItem = this.getItem(currentCacheKey);
1805
1791
  if (cacheItem) {
1806
- this.removeItem(currentCacheKey);
1792
+ this.browserStorage.removeItem(currentCacheKey);
1807
1793
  this.setItem(updatedCacheKey, cacheItem);
1808
1794
  this.logger.verbose(
1809
1795
  `Updated an outdated ${credential.credentialType} cache key`
@@ -1819,28 +1805,6 @@ export class BrowserCacheManager extends CacheManager {
1819
1805
  return currentCacheKey;
1820
1806
  }
1821
1807
 
1822
- /**
1823
- * Returns application id as redirect context during AcquireTokenRedirect flow.
1824
- */
1825
- getRedirectRequestContext(): string | null {
1826
- return this.getTemporaryCache(
1827
- TemporaryCacheKeys.REDIRECT_CONTEXT,
1828
- true
1829
- );
1830
- }
1831
-
1832
- /**
1833
- * Sets application id as the redirect context during AcquireTokenRedirect flow.
1834
- * @param value
1835
- */
1836
- setRedirectRequestContext(value: string): void {
1837
- this.setTemporaryCache(
1838
- TemporaryCacheKeys.REDIRECT_CONTEXT,
1839
- value,
1840
- true
1841
- );
1842
- }
1843
-
1844
1808
  /**
1845
1809
  * Builds credential entities from AuthenticationResult object and saves the resulting credentials to the cache
1846
1810
  * @param result
@@ -8,7 +8,7 @@ import {
8
8
  BrowserAuthErrorCodes,
9
9
  } from "../error/BrowserAuthError";
10
10
  import { DB_NAME, DB_TABLE_NAME, DB_VERSION } from "../utils/BrowserConstants";
11
- import { IAsyncStorage } from "./IAsyncMemoryStorage";
11
+ import { IAsyncStorage } from "./IAsyncStorage";
12
12
 
13
13
  interface IDBOpenDBRequestEvent extends Event {
14
14
  target: IDBOpenDBRequest & EventTarget;
@@ -279,9 +279,19 @@ export class DatabaseStorage<T> implements IAsyncStorage<T> {
279
279
 
280
280
  return new Promise<boolean>((resolve: Function, reject: Function) => {
281
281
  const deleteDbRequest = window.indexedDB.deleteDatabase(DB_NAME);
282
- deleteDbRequest.addEventListener("success", () => resolve(true));
283
- deleteDbRequest.addEventListener("blocked", () => resolve(true));
284
- deleteDbRequest.addEventListener("error", () => reject(false));
282
+ const id = setTimeout(() => reject(false), 200); // Reject if events aren't raised within 200ms
283
+ deleteDbRequest.addEventListener("success", () => {
284
+ clearTimeout(id);
285
+ return resolve(true);
286
+ });
287
+ deleteDbRequest.addEventListener("blocked", () => {
288
+ clearTimeout(id);
289
+ return resolve(true);
290
+ });
291
+ deleteDbRequest.addEventListener("error", () => {
292
+ clearTimeout(id);
293
+ return reject(false);
294
+ });
285
295
  });
286
296
  }
287
297
  }
@@ -15,7 +15,7 @@ import { PopupRequest } from "../request/PopupRequest";
15
15
  import { SilentRequest } from "../request/SilentRequest";
16
16
  import { SsoSilentRequest } from "../request/SsoSilentRequest";
17
17
  import { EndSessionRequest } from "../request/EndSessionRequest";
18
- import { ApiId, InteractionType, WrapperSKU } from "../utils/BrowserConstants";
18
+ import { ApiId, WrapperSKU } from "../utils/BrowserConstants";
19
19
  import { INavigationClient } from "../navigation/INavigationClient";
20
20
  import { EndSessionPopupRequest } from "../request/EndSessionPopupRequest";
21
21
  import { ITokenCache } from "../cache/ITokenCache";
@@ -119,10 +119,4 @@ export interface IController {
119
119
 
120
120
  /** @internal */
121
121
  getEventHandler(): EventHandler;
122
-
123
- /** @internal */
124
- preflightBrowserEnvironmentCheck(
125
- interactionType: InteractionType,
126
- isAppEmbedded?: boolean
127
- ): void;
128
122
  }
@@ -116,25 +116,43 @@ export class NestedAppAuthController implements IController {
116
116
  return Promise.resolve();
117
117
  }
118
118
 
119
+ private ensureValidRequest<
120
+ T extends
121
+ | SsoSilentRequest
122
+ | SilentRequest
123
+ | PopupRequest
124
+ | RedirectRequest
125
+ >(request: T): T {
126
+ if (request?.correlationId) {
127
+ return request;
128
+ }
129
+ return {
130
+ ...request,
131
+ correlationId: this.browserCrypto.createNewGuid(),
132
+ };
133
+ }
134
+
119
135
  private async acquireTokenInteractive(
120
136
  request: PopupRequest | RedirectRequest
121
137
  ): Promise<AuthenticationResult> {
138
+ const validRequest = this.ensureValidRequest(request);
139
+
122
140
  this.eventHandler.emitEvent(
123
141
  EventType.ACQUIRE_TOKEN_START,
124
142
  InteractionType.Popup,
125
- request
143
+ validRequest
126
144
  );
127
145
 
128
146
  const atPopupMeasurement = this.performanceClient.startMeasurement(
129
147
  PerformanceEvents.AcquireTokenPopup,
130
- request.correlationId
148
+ validRequest.correlationId
131
149
  );
132
150
 
133
151
  atPopupMeasurement?.add({ nestedAppAuthRequest: true });
134
152
 
135
153
  try {
136
154
  const naaRequest =
137
- this.nestedAppAuthAdapter.toNaaTokenRequest(request);
155
+ this.nestedAppAuthAdapter.toNaaTokenRequest(validRequest);
138
156
  const reqTimestamp = TimeUtils.nowSeconds();
139
157
  const response = await this.bridgeProxy.getTokenInteractive(
140
158
  naaRequest
@@ -173,11 +191,12 @@ export class NestedAppAuthController implements IController {
173
191
  e as EventError
174
192
  );
175
193
 
176
- atPopupMeasurement.end({
177
- errorCode: error.errorCode,
178
- subErrorCode: error.subError,
179
- success: false,
180
- });
194
+ atPopupMeasurement.end(
195
+ {
196
+ success: false,
197
+ },
198
+ e
199
+ );
181
200
 
182
201
  throw error;
183
202
  }
@@ -186,15 +205,16 @@ export class NestedAppAuthController implements IController {
186
205
  private async acquireTokenSilentInternal(
187
206
  request: SilentRequest
188
207
  ): Promise<AuthenticationResult> {
208
+ const validRequest = this.ensureValidRequest(request);
189
209
  this.eventHandler.emitEvent(
190
210
  EventType.ACQUIRE_TOKEN_START,
191
211
  InteractionType.Silent,
192
- request
212
+ validRequest
193
213
  );
194
214
 
195
215
  const ssoSilentMeasurement = this.performanceClient.startMeasurement(
196
216
  PerformanceEvents.SsoSilent,
197
- request.correlationId
217
+ validRequest.correlationId
198
218
  );
199
219
 
200
220
  ssoSilentMeasurement?.increment({
@@ -207,7 +227,7 @@ export class NestedAppAuthController implements IController {
207
227
 
208
228
  try {
209
229
  const naaRequest =
210
- this.nestedAppAuthAdapter.toNaaTokenRequest(request);
230
+ this.nestedAppAuthAdapter.toNaaTokenRequest(validRequest);
211
231
  const reqTimestamp = TimeUtils.nowSeconds();
212
232
  const response = await this.bridgeProxy.getTokenSilent(naaRequest);
213
233
 
@@ -241,11 +261,12 @@ export class NestedAppAuthController implements IController {
241
261
  null,
242
262
  e as EventError
243
263
  );
244
- ssoSilentMeasurement?.end({
245
- errorCode: error.errorCode,
246
- subErrorCode: error.subError,
247
- success: false,
248
- });
264
+ ssoSilentMeasurement?.end(
265
+ {
266
+ success: false,
267
+ },
268
+ e
269
+ );
249
270
  throw error;
250
271
  }
251
272
  }
@@ -392,7 +413,7 @@ export class NestedAppAuthController implements IController {
392
413
  handleRedirectPromise(
393
414
  hash?: string | undefined // eslint-disable-line @typescript-eslint/no-unused-vars
394
415
  ): Promise<AuthenticationResult | null> {
395
- throw NestedAppAuthError.createUnsupportedError();
416
+ return Promise.resolve(null);
396
417
  }
397
418
  loginPopup(
398
419
  request?: PopupRequest | undefined // eslint-disable-line @typescript-eslint/no-unused-vars
@@ -502,12 +523,6 @@ export class NestedAppAuthController implements IController {
502
523
  getRedirectResponse(): Map<string, Promise<AuthenticationResult | null>> {
503
524
  throw NestedAppAuthError.createUnsupportedError();
504
525
  }
505
- preflightBrowserEnvironmentCheck(
506
- interactionType: InteractionType, // eslint-disable-line @typescript-eslint/no-unused-vars
507
- setInteractionInProgress?: boolean | undefined // eslint-disable-line @typescript-eslint/no-unused-vars
508
- ): void {
509
- throw NestedAppAuthError.createUnsupportedError();
510
- }
511
526
 
512
527
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
513
528
  async clearCache(logoutRequest?: ClearCacheRequest): Promise<void> {