Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Stop looking in localStorage for temporary cache [#8579](https://github.com/AzureAD/microsoft-authentication-library-for-js/pull/8579)",
"packageName": "@azure/msal-browser",
"email": "-g",
"dependentChangeType": "patch"
Comment thread
tnorling marked this conversation as resolved.
}
28 changes: 5 additions & 23 deletions lib/msal-browser/src/cache/BrowserCacheManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1901,30 +1901,12 @@ export class BrowserCacheManager extends CacheManager {
correlationId: string,
generateKey?: boolean
): string | null {
this.logger.trace(
"BrowserCacheManager.getTemporaryCache called",
correlationId
);
const key = generateKey ? this.generateCacheKey(cacheKey) : cacheKey;
const value = this.temporaryCacheStorage.getItem(key);
if (!value) {
// If temp cache item not found in session/memory, check local storage for items set by old versions
if (
this.cacheConfig.cacheLocation ===
BrowserCacheLocation.LocalStorage
) {
const item = this.browserStorage.getItem(key);
if (item) {
this.logger.trace(
"BrowserCacheManager.getTemporaryCache: Temporary cache item found in local storage",
correlationId
);
return item;
}
}
this.logger.trace(
"BrowserCacheManager.getTemporaryCache: No cache item found in local storage",
correlationId
);
return null;
}
return value;
return this.temporaryCacheStorage.getItem(key);
Comment thread
tnorling marked this conversation as resolved.
}

/**
Expand Down
23 changes: 0 additions & 23 deletions lib/msal-browser/test/cache/BrowserCacheManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1875,29 +1875,6 @@ describe("BrowserCacheManager tests", () => {
expect(window.sessionStorage.getItem(msalCacheKey2)).toBe(cacheVal);
});

it("getTemporaryCache falls back to local storage if not found in session/memory storage", () => {
const testTempItemKey = "test-temp-item-key";
const testTempItemValue = "test-temp-item-value";
window.localStorage.setItem(testTempItemKey, testTempItemValue);
browserLocalStorage = new BrowserCacheManager(
TEST_CONFIG.MSAL_CLIENT_ID,
{
...cacheConfig,
cacheLocation: BrowserCacheLocation.LocalStorage,
},
browserCrypto,
logger,
new StubPerformanceClient(),
new EventHandler()
);
expect(
browserLocalStorage.getTemporaryCache(
testTempItemKey,
TEST_CONFIG.CORRELATION_ID
)
).toBe(testTempItemValue);
});

it("setItem", () => {
window.sessionStorage.setItem(msalCacheKey, cacheVal);
window.localStorage.setItem(msalCacheKey2, cacheVal);
Expand Down
Loading