{"version":3,"file":"BrowserCacheManager.js","sources":["../../src/cache/BrowserCacheManager.ts"],"sourcesContent":["/*\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { Constants, PersistentCacheKeys, StringUtils, CommonAuthorizationCodeRequest, ICrypto, AccountEntity, IdTokenEntity, AccessTokenEntity, RefreshTokenEntity, AppMetadataEntity, CacheManager, ServerTelemetryEntity, ThrottlingEntity, ProtocolUtils, Logger, AuthorityMetadataEntity, DEFAULT_CRYPTO_IMPLEMENTATION, AccountInfo, ActiveAccountFilters, CcsCredential, CcsCredentialType, IdToken, ValidCredentialType, ClientAuthError } from \"@azure/msal-common\";\nimport { CacheOptions } from \"../config/Configuration\";\nimport { BrowserAuthError } from \"../error/BrowserAuthError\";\nimport { BrowserCacheLocation, InteractionType, TemporaryCacheKeys, InMemoryCacheKeys } from \"../utils/BrowserConstants\";\nimport { BrowserStorage } from \"./BrowserStorage\";\nimport { MemoryStorage } from \"./MemoryStorage\";\nimport { IWindowStorage } from \"./IWindowStorage\";\nimport { BrowserProtocolUtils } from \"../utils/BrowserProtocolUtils\";\nimport { NativeTokenRequest } from \"../broker/nativeBroker/NativeRequest\";\n\n/**\n * This class implements the cache storage interface for MSAL through browser local or session storage.\n * Cookies are only used if storeAuthStateInCookie is true, and are only used for\n * parameters such as state and nonce, generally.\n */\nexport class BrowserCacheManager extends CacheManager {\n\n // Cache configuration, either set by user or default values.\n protected cacheConfig: Required;\n // Window storage object (either local or sessionStorage)\n protected browserStorage: IWindowStorage;\n // Internal in-memory storage object used for data used by msal that does not need to persist across page loads\n protected internalStorage: MemoryStorage;\n // Temporary cache\n protected temporaryCacheStorage: IWindowStorage;\n // Client id of application. Used in cache keys to partition cache correctly in the case of multiple instances of MSAL.\n protected logger: Logger;\n\n // Cookie life calculation (hours * minutes * seconds * ms)\n protected readonly COOKIE_LIFE_MULTIPLIER = 24 * 60 * 60 * 1000;\n\n constructor(clientId: string, cacheConfig: Required, cryptoImpl: ICrypto, logger: Logger) {\n super(clientId, cryptoImpl);\n\n this.cacheConfig = cacheConfig;\n this.logger = logger;\n this.internalStorage = new MemoryStorage();\n this.browserStorage = this.setupBrowserStorage(this.cacheConfig.cacheLocation);\n this.temporaryCacheStorage = this.setupTemporaryCacheStorage(this.cacheConfig.cacheLocation);\n\n // Migrate any cache entries from older versions of MSAL.\n this.migrateCacheEntries();\n }\n\n /**\n * Returns a window storage class implementing the IWindowStorage interface that corresponds to the configured cacheLocation.\n * @param cacheLocation\n */\n protected setupBrowserStorage(cacheLocation: BrowserCacheLocation | string): IWindowStorage {\n switch (cacheLocation) {\n case BrowserCacheLocation.LocalStorage:\n case BrowserCacheLocation.SessionStorage:\n try {\n // Temporary cache items will always be stored in session storage to mitigate problems caused by multiple tabs\n return new BrowserStorage(cacheLocation);\n } catch (e) {\n this.logger.verbose(e);\n break;\n }\n case BrowserCacheLocation.MemoryStorage:\n default:\n break;\n }\n this.cacheConfig.cacheLocation = BrowserCacheLocation.MemoryStorage;\n return new MemoryStorage();\n }\n\n /**\n *\n * @param cacheLocation\n */\n protected setupTemporaryCacheStorage(cacheLocation: BrowserCacheLocation | string): IWindowStorage {\n switch (cacheLocation) {\n case BrowserCacheLocation.LocalStorage:\n case BrowserCacheLocation.SessionStorage:\n try {\n // Temporary cache items will always be stored in session storage to mitigate problems caused by multiple tabs\n return new BrowserStorage(BrowserCacheLocation.SessionStorage);\n } catch (e) {\n this.logger.verbose(e);\n return this.internalStorage;\n }\n case BrowserCacheLocation.MemoryStorage:\n default:\n return this.internalStorage;\n }\n }\n\n /**\n * Migrate all old cache entries to new schema. No rollback supported.\n * @param storeAuthStateInCookie\n */\n protected migrateCacheEntries(): void {\n const idTokenKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ID_TOKEN}`;\n const clientInfoKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.CLIENT_INFO}`;\n const errorKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ERROR}`;\n const errorDescKey = `${Constants.CACHE_PREFIX}.${PersistentCacheKeys.ERROR_DESC}`;\n\n const idTokenValue = this.browserStorage.getItem(idTokenKey);\n const clientInfoValue = this.browserStorage.getItem(clientInfoKey);\n const errorValue = this.browserStorage.getItem(errorKey);\n const errorDescValue = this.browserStorage.getItem(errorDescKey);\n\n const values = [idTokenValue, clientInfoValue, errorValue, errorDescValue];\n const keysToMigrate = [PersistentCacheKeys.ID_TOKEN, PersistentCacheKeys.CLIENT_INFO, PersistentCacheKeys.ERROR, PersistentCacheKeys.ERROR_DESC];\n\n keysToMigrate.forEach((cacheKey:string, index: number) => this.migrateCacheEntry(cacheKey, values[index]));\n }\n\n /**\n * Utility function to help with migration.\n * @param newKey\n * @param value\n * @param storeAuthStateInCookie\n */\n protected migrateCacheEntry(newKey: string, value: string|null): void {\n if (value) {\n this.setTemporaryCache(newKey, value, true);\n }\n }\n\n /**\n * Parses passed value as JSON object, JSON.parse() will throw an error.\n * @param input\n */\n protected validateAndParseJson(jsonValue: string): object | null {\n try {\n const parsedJson = JSON.parse(jsonValue);\n /**\n * There are edge cases in which JSON.parse will successfully parse a non-valid JSON object\n * (e.g. JSON.parse will parse an escaped string into an unescaped string), so adding a type check\n * of the parsed value is necessary in order to be certain that the string represents a valid JSON object.\n *\n */\n return (parsedJson && typeof parsedJson === \"object\") ? parsedJson : null;\n } catch (error) {\n return null;\n }\n }\n\n /**\n * fetches the entry from the browser storage based off the key\n * @param key\n */\n getItem(key: string): string | null {\n return this.browserStorage.getItem(key);\n }\n\n /**\n * sets the entry in the browser storage\n * @param key\n * @param value\n */\n setItem(key: string, value: string): void {\n this.browserStorage.setItem(key, value);\n }\n\n /**\n * fetch the account entity from the platform cache\n * @param accountKey\n */\n getAccount(accountKey: string): AccountEntity | null {\n const account = this.getItem(accountKey);\n if (!account) {\n return null;\n }\n\n const parsedAccount = this.validateAndParseJson(account);\n if (!parsedAccount || !AccountEntity.isAccountEntity(parsedAccount)) {\n return null;\n }\n\n return CacheManager.toObject(new AccountEntity(), parsedAccount);\n }\n\n /**\n * set account entity in the platform cache\n * @param key\n * @param value\n */\n setAccount(account: AccountEntity): void {\n this.logger.trace(\"BrowserCacheManager.setAccount called\");\n const key = account.generateAccountKey();\n this.setItem(key, JSON.stringify(account));\n }\n\n /**\n * generates idToken entity from a string\n * @param idTokenKey\n */\n getIdTokenCredential(idTokenKey: string): IdTokenEntity | null {\n const value = this.getItem(idTokenKey);\n if (!value) {\n this.logger.trace(\"BrowserCacheManager.getIdTokenCredential: called, no cache hit\");\n return null;\n }\n\n const parsedIdToken = this.validateAndParseJson(value);\n if (!parsedIdToken || !IdTokenEntity.isIdTokenEntity(parsedIdToken)) {\n this.logger.trace(\"BrowserCacheManager.getIdTokenCredential: called, no cache hit\");\n return null;\n }\n\n this.logger.trace(\"BrowserCacheManager.getIdTokenCredential: cache hit\");\n return CacheManager.toObject(new IdTokenEntity(), parsedIdToken);\n }\n\n /**\n * set IdToken credential to the platform cache\n * @param idToken\n */\n setIdTokenCredential(idToken: IdTokenEntity): void {\n this.logger.trace(\"BrowserCacheManager.setIdTokenCredential called\");\n const idTokenKey = idToken.generateCredentialKey();\n\n this.setItem(idTokenKey, JSON.stringify(idToken));\n }\n\n /**\n * generates accessToken entity from a string\n * @param key\n */\n getAccessTokenCredential(accessTokenKey: string): AccessTokenEntity | null {\n const value = this.getItem(accessTokenKey);\n if (!value) {\n this.logger.trace(\"BrowserCacheManager.getAccessTokenCredential: called, no cache hit\");\n return null;\n }\n const parsedAccessToken = this.validateAndParseJson(value);\n if (!parsedAccessToken || !AccessTokenEntity.isAccessTokenEntity(parsedAccessToken)) {\n this.logger.trace(\"BrowserCacheManager.getAccessTokenCredential: called, no cache hit\");\n return null;\n }\n\n this.logger.trace(\"BrowserCacheManager.getAccessTokenCredential: cache hit\");\n return CacheManager.toObject(new AccessTokenEntity(), parsedAccessToken);\n }\n\n /**\n * set accessToken credential to the platform cache\n * @param accessToken\n */\n setAccessTokenCredential(accessToken: AccessTokenEntity): void {\n this.logger.trace(\"BrowserCacheManager.setAccessTokenCredential called\");\n const accessTokenKey = accessToken.generateCredentialKey();\n this.setItem(accessTokenKey, JSON.stringify(accessToken));\n }\n\n /**\n * generates refreshToken entity from a string\n * @param refreshTokenKey\n */\n getRefreshTokenCredential(refreshTokenKey: string): RefreshTokenEntity | null {\n const value = this.getItem(refreshTokenKey);\n if (!value) {\n this.logger.trace(\"BrowserCacheManager.getRefreshTokenCredential: called, no cache hit\");\n return null;\n }\n const parsedRefreshToken = this.validateAndParseJson(value);\n if (!parsedRefreshToken || !RefreshTokenEntity.isRefreshTokenEntity(parsedRefreshToken)) {\n this.logger.trace(\"BrowserCacheManager.getRefreshTokenCredential: called, no cache hit\");\n return null;\n }\n\n this.logger.trace(\"BrowserCacheManager.getRefreshTokenCredential: cache hit\");\n return CacheManager.toObject(new RefreshTokenEntity(), parsedRefreshToken);\n }\n\n /**\n * set refreshToken credential to the platform cache\n * @param refreshToken\n */\n setRefreshTokenCredential(refreshToken: RefreshTokenEntity): void {\n this.logger.trace(\"BrowserCacheManager.setRefreshTokenCredential called\");\n const refreshTokenKey = refreshToken.generateCredentialKey();\n this.setItem(refreshTokenKey, JSON.stringify(refreshToken));\n }\n\n /**\n * fetch appMetadata entity from the platform cache\n * @param appMetadataKey\n */\n getAppMetadata(appMetadataKey: string): AppMetadataEntity | null {\n const value = this.getItem(appMetadataKey);\n if (!value) {\n this.logger.trace(\"BrowserCacheManager.getAppMetadata: called, no cache hit\");\n return null;\n }\n\n const parsedMetadata = this.validateAndParseJson(value);\n if (!parsedMetadata || !AppMetadataEntity.isAppMetadataEntity(appMetadataKey, parsedMetadata)) {\n this.logger.trace(\"BrowserCacheManager.getAppMetadata: called, no cache hit\");\n return null;\n }\n\n this.logger.trace(\"BrowserCacheManager.getAppMetadata: cache hit\");\n return CacheManager.toObject(new AppMetadataEntity(), parsedMetadata);\n }\n\n /**\n * set appMetadata entity to the platform cache\n * @param appMetadata\n */\n setAppMetadata(appMetadata: AppMetadataEntity): void {\n this.logger.trace(\"BrowserCacheManager.setAppMetadata called\");\n const appMetadataKey = appMetadata.generateAppMetadataKey();\n this.setItem(appMetadataKey, JSON.stringify(appMetadata));\n }\n\n /**\n * fetch server telemetry entity from the platform cache\n * @param serverTelemetryKey\n */\n getServerTelemetry(serverTelemetryKey: string): ServerTelemetryEntity | null {\n const value = this.getItem(serverTelemetryKey);\n if (!value) {\n this.logger.trace(\"BrowserCacheManager.getServerTelemetry: called, no cache hit\");\n return null;\n }\n const parsedMetadata = this.validateAndParseJson(value);\n if (!parsedMetadata || !ServerTelemetryEntity.isServerTelemetryEntity(serverTelemetryKey, parsedMetadata)) {\n this.logger.trace(\"BrowserCacheManager.getServerTelemetry: called, no cache hit\");\n return null;\n }\n\n this.logger.trace(\"BrowserCacheManager.getServerTelemetry: cache hit\");\n return CacheManager.toObject(new ServerTelemetryEntity(), parsedMetadata);\n }\n\n /**\n * set server telemetry entity to the platform cache\n * @param serverTelemetryKey\n * @param serverTelemetry\n */\n setServerTelemetry(serverTelemetryKey: string, serverTelemetry: ServerTelemetryEntity): void {\n this.logger.trace(\"BrowserCacheManager.setServerTelemetry called\");\n this.setItem(serverTelemetryKey, JSON.stringify(serverTelemetry));\n }\n\n /**\n *\n */\n getAuthorityMetadata(key: string) : AuthorityMetadataEntity | null {\n const value = this.internalStorage.getItem(key);\n if (!value) {\n this.logger.trace(\"BrowserCacheManager.getAuthorityMetadata: called, no cache hit\");\n return null;\n }\n const parsedMetadata = this.validateAndParseJson(value);\n if (parsedMetadata && AuthorityMetadataEntity.isAuthorityMetadataEntity(key, parsedMetadata)) {\n this.logger.trace(\"BrowserCacheManager.getAuthorityMetadata: cache hit\");\n return CacheManager.toObject(new AuthorityMetadataEntity(), parsedMetadata);\n }\n return null;\n }\n\n /**\n *\n */\n getAuthorityMetadataKeys(): Array {\n const allKeys = this.internalStorage.getKeys();\n return allKeys.filter((key) => {\n return this.isAuthorityMetadata(key);\n });\n }\n\n /**\n * Sets wrapper metadata in memory\n * @param wrapperSKU\n * @param wrapperVersion\n */\n setWrapperMetadata(wrapperSKU: string, wrapperVersion: string): void {\n this.internalStorage.setItem(InMemoryCacheKeys.WRAPPER_SKU, wrapperSKU);\n this.internalStorage.setItem(InMemoryCacheKeys.WRAPPER_VER, wrapperVersion);\n }\n\n /**\n * Returns wrapper metadata from in-memory storage\n */\n getWrapperMetadata(): [string, string] {\n const sku = this.internalStorage.getItem(InMemoryCacheKeys.WRAPPER_SKU) || Constants.EMPTY_STRING;\n const version = this.internalStorage.getItem(InMemoryCacheKeys.WRAPPER_VER) || Constants.EMPTY_STRING;\n return [sku, version];\n }\n\n /**\n *\n * @param entity\n */\n setAuthorityMetadata(key: string, entity: AuthorityMetadataEntity): void {\n this.logger.trace(\"BrowserCacheManager.setAuthorityMetadata called\");\n this.internalStorage.setItem(key, JSON.stringify(entity));\n }\n\n /**\n * Gets the active account\n */\n getActiveAccount(): AccountInfo | null {\n const activeAccountKeyFilters = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);\n const activeAccountValueFilters = this.getItem(activeAccountKeyFilters);\n if (!activeAccountValueFilters) {\n // if new active account cache type isn't found, it's an old version, so look for that instead\n this.logger.trace(\"BrowserCacheManager.getActiveAccount: No active account filters cache schema found, looking for legacy schema\");\n const activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);\n const activeAccountValueLocal = this.getItem(activeAccountKeyLocal);\n if(!activeAccountValueLocal) {\n this.logger.trace(\"BrowserCacheManager.getActiveAccount: No active account found\");\n return null;\n }\n const activeAccount = this.getAccountInfoByFilter({localAccountId: activeAccountValueLocal})[0] || null;\n if(activeAccount) {\n this.logger.trace(\"BrowserCacheManager.getActiveAccount: Legacy active account cache schema found\");\n this.logger.trace(\"BrowserCacheManager.getActiveAccount: Adding active account filters cache schema\");\n this.setActiveAccount(activeAccount);\n return activeAccount;\n }\n return null;\n }\n const activeAccountValueObj = this.validateAndParseJson(activeAccountValueFilters) as AccountInfo;\n if(activeAccountValueObj) {\n this.logger.trace(\"BrowserCacheManager.getActiveAccount: Active account filters schema found\");\n return this.getAccountInfoByFilter({\n homeAccountId: activeAccountValueObj.homeAccountId,\n localAccountId: activeAccountValueObj.localAccountId\n })[0] || null;\n }\n this.logger.trace(\"BrowserCacheManager.getActiveAccount: No active account found\");\n return null;\n }\n\n /**\n * Sets the active account's localAccountId in cache\n * @param account\n */\n setActiveAccount(account: AccountInfo | null): void {\n const activeAccountKey = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT_FILTERS);\n const activeAccountKeyLocal = this.generateCacheKey(PersistentCacheKeys.ACTIVE_ACCOUNT);\n if (account) {\n this.logger.verbose(\"setActiveAccount: Active account set\");\n const activeAccountValue: ActiveAccountFilters = {\n homeAccountId: account.homeAccountId,\n localAccountId: account.localAccountId\n };\n this.browserStorage.setItem(activeAccountKey, JSON.stringify(activeAccountValue));\n this.browserStorage.setItem(activeAccountKeyLocal, account.localAccountId);\n } else {\n this.logger.verbose(\"setActiveAccount: No account passed, active account not set\");\n this.browserStorage.removeItem(activeAccountKey);\n this.browserStorage.removeItem(activeAccountKeyLocal);\n }\n }\n\n /**\n * Gets a list of accounts that match all of the filters provided\n * @param account\n */\n getAccountInfoByFilter(accountFilter: Partial>): AccountInfo[] {\n const allAccounts = this.getAllAccounts();\n this.logger.trace(`BrowserCacheManager.getAccountInfoByFilter: total ${allAccounts.length} accounts found`);\n\n return allAccounts.filter((accountObj) => {\n if (accountFilter.username && accountFilter.username.toLowerCase() !== accountObj.username.toLowerCase()) {\n return false;\n }\n\n if (accountFilter.homeAccountId && accountFilter.homeAccountId !== accountObj.homeAccountId) {\n return false;\n }\n\n if (accountFilter.localAccountId && accountFilter.localAccountId !== accountObj.localAccountId) {\n return false;\n }\n\n if (accountFilter.tenantId && accountFilter.tenantId !== accountObj.tenantId) {\n return false;\n }\n\n if (accountFilter.environment && accountFilter.environment !== accountObj.environment) {\n return false;\n }\n\n return true;\n });\n }\n\n /**\n * Checks the cache for accounts matching loginHint or SID\n * @param loginHint\n * @param sid\n */\n getAccountInfoByHints(loginHint?: string, sid?: string): AccountInfo | null {\n const matchingAccounts = this.getAllAccounts().filter((accountInfo) => {\n if (sid) {\n const accountSid = accountInfo.idTokenClaims && accountInfo.idTokenClaims[\"sid\"];\n return sid === accountSid;\n }\n\n if (loginHint) {\n return loginHint === accountInfo.username;\n }\n\n return false;\n });\n\n if (matchingAccounts.length === 1) {\n return matchingAccounts[0];\n } else if (matchingAccounts.length > 1) {\n throw ClientAuthError.createMultipleMatchingAccountsInCacheError();\n }\n\n return null;\n }\n\n /**\n * fetch throttling entity from the platform cache\n * @param throttlingCacheKey\n */\n getThrottlingCache(throttlingCacheKey: string): ThrottlingEntity | null {\n const value = this.getItem(throttlingCacheKey);\n if (!value) {\n this.logger.trace(\"BrowserCacheManager.getThrottlingCache: called, no cache hit\");\n return null;\n }\n\n const parsedThrottlingCache = this.validateAndParseJson(value);\n if (!parsedThrottlingCache || !ThrottlingEntity.isThrottlingEntity(throttlingCacheKey, parsedThrottlingCache)) {\n this.logger.trace(\"BrowserCacheManager.getThrottlingCache: called, no cache hit\");\n return null;\n }\n\n this.logger.trace(\"BrowserCacheManager.getThrottlingCache: cache hit\");\n return CacheManager.toObject(new ThrottlingEntity(), parsedThrottlingCache);\n }\n\n /**\n * set throttling entity to the platform cache\n * @param throttlingCacheKey\n * @param throttlingCache\n */\n setThrottlingCache(throttlingCacheKey: string, throttlingCache: ThrottlingEntity): void {\n this.logger.trace(\"BrowserCacheManager.setThrottlingCache called\");\n this.setItem(throttlingCacheKey, JSON.stringify(throttlingCache));\n }\n\n /**\n * Gets cache item with given key.\n * Will retrieve from cookies if storeAuthStateInCookie is set to true.\n * @param key\n */\n getTemporaryCache(cacheKey: string, generateKey?: boolean): string | null {\n const key = generateKey ? this.generateCacheKey(cacheKey) : cacheKey;\n if (this.cacheConfig.storeAuthStateInCookie) {\n const itemCookie = this.getItemCookie(key);\n if (itemCookie) {\n this.logger.trace(\"BrowserCacheManager.getTemporaryCache: storeAuthStateInCookies set to true, retrieving from cookies\");\n return itemCookie;\n }\n }\n\n const value = this.temporaryCacheStorage.getItem(key);\n if (!value) {\n // If temp cache item not found in session/memory, check local storage for items set by old versions\n if (this.cacheConfig.cacheLocation === BrowserCacheLocation.LocalStorage) {\n const item = this.browserStorage.getItem(key);\n if (item) {\n this.logger.trace(\"BrowserCacheManager.getTemporaryCache: Temporary cache item found in local storage\");\n return item;\n }\n }\n this.logger.trace(\"BrowserCacheManager.getTemporaryCache: No cache item found in local storage\");\n return null;\n }\n this.logger.trace(\"BrowserCacheManager.getTemporaryCache: Temporary cache item returned\");\n return value;\n }\n\n /**\n * Sets the cache item with the key and value given.\n * Stores in cookie if storeAuthStateInCookie is set to true.\n * This can cause cookie overflow if used incorrectly.\n * @param key\n * @param value\n */\n setTemporaryCache(cacheKey: string, value: string, generateKey?: boolean): void {\n const key = generateKey ? this.generateCacheKey(cacheKey) : cacheKey;\n\n this.temporaryCacheStorage.setItem(key, value);\n if (this.cacheConfig.storeAuthStateInCookie) {\n this.logger.trace(\"BrowserCacheManager.setTemporaryCache: storeAuthStateInCookie set to true, setting item cookie\");\n this.setItemCookie(key, value);\n }\n }\n\n /**\n * Removes the cache item with the given key.\n * Will also clear the cookie item if storeAuthStateInCookie is set to true.\n * @param key\n */\n removeItem(key: string): boolean {\n this.browserStorage.removeItem(key);\n this.temporaryCacheStorage.removeItem(key);\n if (this.cacheConfig.storeAuthStateInCookie) {\n this.logger.trace(\"BrowserCacheManager.removeItem: storeAuthStateInCookie is true, clearing item cookie\");\n this.clearItemCookie(key);\n }\n return true;\n }\n\n /**\n * Checks whether key is in cache.\n * @param key\n */\n containsKey(key: string): boolean {\n return this.browserStorage.containsKey(key) || this.temporaryCacheStorage.containsKey(key);\n }\n\n /**\n * Gets all keys in window.\n */\n getKeys(): string[] {\n return [\n ...this.browserStorage.getKeys(),\n ...this.temporaryCacheStorage.getKeys()\n ];\n }\n\n /**\n * Clears all cache entries created by MSAL.\n */\n async clear(): Promise {\n // Removes all accounts and their credentials\n await this.removeAllAccounts();\n this.removeAppMetadata();\n\n // Removes all remaining MSAL cache items\n this.getKeys().forEach((cacheKey: string) => {\n // Check if key contains msal prefix; For now, we are clearing all the cache items created by MSAL.js\n if ((this.browserStorage.containsKey(cacheKey) || this.temporaryCacheStorage.containsKey(cacheKey)) && ((cacheKey.indexOf(Constants.CACHE_PREFIX) !== -1) || (cacheKey.indexOf(this.clientId) !== -1))) {\n this.removeItem(cacheKey);\n }\n });\n\n this.internalStorage.clear();\n }\n\n /**\n * Add value to cookies\n * @param cookieName\n * @param cookieValue\n * @param expires\n */\n setItemCookie(cookieName: string, cookieValue: string, expires?: number): void {\n let cookieStr = `${encodeURIComponent(cookieName)}=${encodeURIComponent(cookieValue)};path=/;SameSite=Lax;`;\n if (expires) {\n const expireTime = this.getCookieExpirationTime(expires);\n cookieStr += `expires=${expireTime};`;\n }\n\n if (this.cacheConfig.secureCookies) {\n cookieStr += \"Secure;\";\n }\n\n document.cookie = cookieStr;\n }\n\n /**\n * Get one item by key from cookies\n * @param cookieName\n */\n getItemCookie(cookieName: string): string {\n const name = `${encodeURIComponent(cookieName)}=`;\n const cookieList = document.cookie.split(\";\");\n for (let i: number = 0; i < cookieList.length; i++) {\n let cookie = cookieList[i];\n while (cookie.charAt(0) === \" \") {\n cookie = cookie.substring(1);\n }\n if (cookie.indexOf(name) === 0) {\n return decodeURIComponent(cookie.substring(name.length, cookie.length));\n }\n }\n return Constants.EMPTY_STRING;\n }\n\n /**\n * Clear all msal-related cookies currently set in the browser. Should only be used to clear temporary cache items.\n */\n clearMsalCookies(): void {\n const cookiePrefix = `${Constants.CACHE_PREFIX}.${this.clientId}`;\n const cookieList = document.cookie.split(\";\");\n cookieList.forEach((cookie: string): void => {\n while (cookie.charAt(0) === \" \") {\n // eslint-disable-next-line no-param-reassign\n cookie = cookie.substring(1);\n }\n if (cookie.indexOf(cookiePrefix) === 0) {\n const cookieKey = cookie.split(\"=\")[0];\n this.clearItemCookie(cookieKey);\n }\n });\n }\n\n /**\n * Clear an item in the cookies by key\n * @param cookieName\n */\n clearItemCookie(cookieName: string): void {\n this.setItemCookie(cookieName, Constants.EMPTY_STRING, -1);\n }\n\n /**\n * Get cookie expiration time\n * @param cookieLifeDays\n */\n getCookieExpirationTime(cookieLifeDays: number): string {\n const today = new Date();\n const expr = new Date(today.getTime() + cookieLifeDays * this.COOKIE_LIFE_MULTIPLIER);\n return expr.toUTCString();\n }\n\n /**\n * Gets the cache object referenced by the browser\n */\n getCache(): object {\n return this.browserStorage;\n }\n\n /**\n * interface compat, we cannot overwrite browser cache; Functionality is supported by individual entities in browser\n */\n setCache(): void {\n // sets nothing\n }\n\n /**\n * Prepend msal. to each key; Skip for any JSON object as Key (defined schemas do not need the key appended: AccessToken Keys or the upcoming schema)\n * @param key\n * @param addInstanceId\n */\n generateCacheKey(key: string): string {\n const generatedKey = this.validateAndParseJson(key);\n if (!generatedKey) {\n if (StringUtils.startsWith(key, Constants.CACHE_PREFIX) || StringUtils.startsWith(key, PersistentCacheKeys.ADAL_ID_TOKEN)) {\n return key;\n }\n return `${Constants.CACHE_PREFIX}.${this.clientId}.${key}`;\n }\n\n return JSON.stringify(key);\n }\n\n /**\n * Create authorityKey to cache authority\n * @param state\n */\n generateAuthorityKey(stateString: string): string {\n const {\n libraryState: {\n id: stateId\n }\n } = ProtocolUtils.parseRequestState(this.cryptoImpl, stateString);\n\n return this.generateCacheKey(`${TemporaryCacheKeys.AUTHORITY}.${stateId}`);\n }\n\n /**\n * Create Nonce key to cache nonce\n * @param state\n */\n generateNonceKey(stateString: string): string {\n const {\n libraryState: {\n id: stateId\n }\n } = ProtocolUtils.parseRequestState(this.cryptoImpl, stateString);\n\n return this.generateCacheKey(`${TemporaryCacheKeys.NONCE_IDTOKEN}.${stateId}`);\n }\n\n /**\n * Creates full cache key for the request state\n * @param stateString State string for the request\n */\n generateStateKey(stateString: string): string {\n // Use the library state id to key temp storage for uniqueness for multiple concurrent requests\n const {\n libraryState: {\n id: stateId\n }\n } = ProtocolUtils.parseRequestState(this.cryptoImpl, stateString);\n return this.generateCacheKey(`${TemporaryCacheKeys.REQUEST_STATE}.${stateId}`);\n }\n\n /**\n * Gets the cached authority based on the cached state. Returns empty if no cached state found.\n */\n getCachedAuthority(cachedState: string): string | null {\n const stateCacheKey = this.generateStateKey(cachedState);\n const state = this.getTemporaryCache(stateCacheKey);\n if (!state) {\n return null;\n }\n\n const authorityCacheKey = this.generateAuthorityKey(state);\n return this.getTemporaryCache(authorityCacheKey);\n }\n\n /**\n * Updates account, authority, and state in cache\n * @param serverAuthenticationRequest\n * @param account\n */\n updateCacheEntries(state: string, nonce: string, authorityInstance: string, loginHint: string, account: AccountInfo|null): void {\n this.logger.trace(\"BrowserCacheManager.updateCacheEntries called\");\n // Cache the request state\n const stateCacheKey = this.generateStateKey(state);\n this.setTemporaryCache(stateCacheKey, state, false);\n\n // Cache the nonce\n const nonceCacheKey = this.generateNonceKey(state);\n this.setTemporaryCache(nonceCacheKey, nonce, false);\n\n // Cache authorityKey\n const authorityCacheKey = this.generateAuthorityKey(state);\n this.setTemporaryCache(authorityCacheKey, authorityInstance, false);\n\n if (account) {\n const ccsCredential: CcsCredential = {\n credential: account.homeAccountId,\n type: CcsCredentialType.HOME_ACCOUNT_ID\n };\n this.setTemporaryCache(TemporaryCacheKeys.CCS_CREDENTIAL, JSON.stringify(ccsCredential), true);\n } else if (!StringUtils.isEmpty(loginHint)) {\n const ccsCredential: CcsCredential = {\n credential: loginHint,\n type: CcsCredentialType.UPN\n };\n this.setTemporaryCache(TemporaryCacheKeys.CCS_CREDENTIAL, JSON.stringify(ccsCredential), true);\n }\n }\n\n /**\n * Reset all temporary cache items\n * @param state\n */\n resetRequestCache(state: string): void {\n this.logger.trace(\"BrowserCacheManager.resetRequestCache called\");\n // check state and remove associated cache items\n if (!StringUtils.isEmpty(state)) {\n this.getKeys().forEach(key => {\n if (key.indexOf(state) !== -1) {\n this.removeItem(key);\n }\n });\n }\n\n // delete generic interactive request parameters\n if (state) {\n this.removeItem(this.generateStateKey(state));\n this.removeItem(this.generateNonceKey(state));\n this.removeItem(this.generateAuthorityKey(state));\n }\n this.removeItem(this.generateCacheKey(TemporaryCacheKeys.REQUEST_PARAMS));\n this.removeItem(this.generateCacheKey(TemporaryCacheKeys.ORIGIN_URI));\n this.removeItem(this.generateCacheKey(TemporaryCacheKeys.URL_HASH));\n this.removeItem(this.generateCacheKey(TemporaryCacheKeys.CORRELATION_ID));\n this.removeItem(this.generateCacheKey(TemporaryCacheKeys.CCS_CREDENTIAL));\n this.removeItem(this.generateCacheKey(TemporaryCacheKeys.NATIVE_REQUEST));\n this.setInteractionInProgress(false);\n }\n\n /**\n * Removes temporary cache for the provided state\n * @param stateString\n */\n cleanRequestByState(stateString: string): void {\n this.logger.trace(\"BrowserCacheManager.cleanRequestByState called\");\n // Interaction is completed - remove interaction status.\n if (stateString) {\n const stateKey = this.generateStateKey(stateString);\n const cachedState = this.temporaryCacheStorage.getItem(stateKey);\n this.logger.infoPii(`BrowserCacheManager.cleanRequestByState: Removing temporary cache items for state: ${cachedState}`);\n this.resetRequestCache(cachedState || Constants.EMPTY_STRING);\n }\n this.clearMsalCookies();\n }\n\n /**\n * Looks in temporary cache for any state values with the provided interactionType and removes all temporary cache items for that state\n * Used in scenarios where temp cache needs to be cleaned but state is not known, such as clicking browser back button.\n * @param interactionType\n */\n cleanRequestByInteractionType(interactionType: InteractionType): void {\n this.logger.trace(\"BrowserCacheManager.cleanRequestByInteractionType called\");\n // Loop through all keys to find state key\n this.getKeys().forEach((key) => {\n // If this key is not the state key, move on\n if (key.indexOf(TemporaryCacheKeys.REQUEST_STATE) === -1) {\n return;\n }\n\n // Retrieve state value, return if not a valid value\n const stateValue = this.temporaryCacheStorage.getItem(key);\n if (!stateValue) {\n return;\n }\n // Extract state and ensure it matches given InteractionType, then clean request cache\n const parsedState = BrowserProtocolUtils.extractBrowserRequestState(this.cryptoImpl, stateValue);\n if (parsedState && parsedState.interactionType === interactionType) {\n this.logger.infoPii(`BrowserCacheManager.cleanRequestByInteractionType: Removing temporary cache items for state: ${stateValue}`);\n this.resetRequestCache(stateValue);\n }\n });\n this.clearMsalCookies();\n this.setInteractionInProgress(false);\n }\n\n cacheCodeRequest(authCodeRequest: CommonAuthorizationCodeRequest, browserCrypto: ICrypto): void {\n this.logger.trace(\"BrowserCacheManager.cacheCodeRequest called\");\n\n const encodedValue = browserCrypto.base64Encode(JSON.stringify(authCodeRequest));\n this.setTemporaryCache(TemporaryCacheKeys.REQUEST_PARAMS, encodedValue, true);\n }\n\n /**\n * Gets the token exchange parameters from the cache. Throws an error if nothing is found.\n */\n getCachedRequest(state: string, browserCrypto: ICrypto): CommonAuthorizationCodeRequest {\n this.logger.trace(\"BrowserCacheManager.getCachedRequest called\");\n // Get token request from cache and parse as TokenExchangeParameters.\n const encodedTokenRequest = this.getTemporaryCache(TemporaryCacheKeys.REQUEST_PARAMS, true);\n if (!encodedTokenRequest) {\n throw BrowserAuthError.createNoTokenRequestCacheError();\n }\n\n const parsedRequest = this.validateAndParseJson(browserCrypto.base64Decode(encodedTokenRequest)) as CommonAuthorizationCodeRequest;\n if (!parsedRequest) {\n throw BrowserAuthError.createUnableToParseTokenRequestCacheError();\n }\n this.removeItem(this.generateCacheKey(TemporaryCacheKeys.REQUEST_PARAMS));\n\n // Get cached authority and use if no authority is cached with request.\n if (StringUtils.isEmpty(parsedRequest.authority)) {\n const authorityCacheKey: string = this.generateAuthorityKey(state);\n const cachedAuthority = this.getTemporaryCache(authorityCacheKey);\n if (!cachedAuthority) {\n throw BrowserAuthError.createNoCachedAuthorityError();\n }\n parsedRequest.authority = cachedAuthority;\n }\n\n return parsedRequest;\n }\n\n /**\n * Gets cached native request for redirect flows\n */\n getCachedNativeRequest(): NativeTokenRequest | null {\n this.logger.trace(\"BrowserCacheManager.getCachedNativeRequest called\");\n const cachedRequest = this.getTemporaryCache(TemporaryCacheKeys.NATIVE_REQUEST, true);\n if (!cachedRequest) {\n this.logger.trace(\"BrowserCacheManager.getCachedNativeRequest: No cached native request found\");\n return null;\n }\n\n const parsedRequest = this.validateAndParseJson(cachedRequest) as NativeTokenRequest;\n if (!parsedRequest) {\n this.logger.error(\"BrowserCacheManager.getCachedNativeRequest: Unable to parse native request\");\n return null;\n }\n\n return parsedRequest;\n }\n\n isInteractionInProgress(matchClientId?: boolean): boolean {\n const clientId = this.getInteractionInProgress();\n\n if (matchClientId) {\n return clientId === this.clientId;\n } else {\n return !!clientId;\n }\n }\n\n getInteractionInProgress(): string | null {\n const key = `${Constants.CACHE_PREFIX}.${TemporaryCacheKeys.INTERACTION_STATUS_KEY}`;\n return this.getTemporaryCache(key, false);\n }\n\n setInteractionInProgress(inProgress: boolean): void {\n // Ensure we don't overwrite interaction in progress for a different clientId\n const key = `${Constants.CACHE_PREFIX}.${TemporaryCacheKeys.INTERACTION_STATUS_KEY}`;\n if (inProgress) {\n if (this.getInteractionInProgress()) {\n throw BrowserAuthError.createInteractionInProgressError();\n } else {\n // No interaction is in progress\n this.setTemporaryCache(key, this.clientId, false);\n }\n } else if (!inProgress && this.getInteractionInProgress() === this.clientId) {\n this.removeItem(key);\n }\n }\n\n /**\n * Returns username retrieved from ADAL or MSAL v1 idToken\n */\n getLegacyLoginHint(): string | null {\n // Only check for adal/msal token if no SSO params are being used\n const adalIdTokenString = this.getTemporaryCache(PersistentCacheKeys.ADAL_ID_TOKEN);\n if (adalIdTokenString) {\n this.browserStorage.removeItem(PersistentCacheKeys.ADAL_ID_TOKEN);\n this.logger.verbose(\"Cached ADAL id token retrieved.\");\n }\n\n // Check for cached MSAL v1 id token\n const msalIdTokenString = this.getTemporaryCache(PersistentCacheKeys.ID_TOKEN, true);\n if (msalIdTokenString) {\n this.removeItem(this.generateCacheKey(PersistentCacheKeys.ID_TOKEN));\n this.logger.verbose(\"Cached MSAL.js v1 id token retrieved\");\n }\n\n const cachedIdTokenString = msalIdTokenString || adalIdTokenString;\n if (cachedIdTokenString) {\n const cachedIdToken = new IdToken(cachedIdTokenString, this.cryptoImpl);\n if (cachedIdToken.claims && cachedIdToken.claims.preferred_username) {\n this.logger.verbose(\"No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 preferred_username as loginHint\");\n return cachedIdToken.claims.preferred_username;\n }\n else if (cachedIdToken.claims && cachedIdToken.claims.upn) {\n this.logger.verbose(\"No SSO params used and ADAL/MSAL v1 token retrieved, setting ADAL/MSAL v1 upn as loginHint\");\n return cachedIdToken.claims.upn;\n }\n else {\n this.logger.verbose(\"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.\");\n }\n }\n\n return null;\n }\n\n /**\n * Updates a credential's cache key if the current cache key is outdated\n */\n updateCredentialCacheKey(currentCacheKey: string, credential: ValidCredentialType): string {\n const updatedCacheKey = credential.generateCredentialKey();\n\n if (currentCacheKey !== updatedCacheKey) {\n const cacheItem = this.getItem(currentCacheKey);\n if (cacheItem) {\n this.removeItem(currentCacheKey);\n this.setItem(updatedCacheKey, cacheItem);\n this.logger.verbose(`Updated an outdated ${credential.credentialType} cache key`);\n return updatedCacheKey;\n } else {\n this.logger.error(`Attempted to update an outdated ${credential.credentialType} cache key but no item matching the outdated key was found in storage`);\n }\n }\n\n return currentCacheKey;\n }\n\n /**\n * Returns application id as redirect context during AcquireTokenRedirect flow.\n */\n getRedirectRequestContext(): string | null {\n return this.getTemporaryCache(TemporaryCacheKeys.REDIRECT_CONTEXT, true);\n }\n\n /**\n * Sets application id as the redirect context during AcquireTokenRedirect flow.\n * @param value\n */\n setRedirectRequestContext(value: string): void {\n this.setTemporaryCache(TemporaryCacheKeys.REDIRECT_CONTEXT, value, true);\n }\n}\n\nexport const DEFAULT_BROWSER_CACHE_MANAGER = (clientId: string, logger: Logger): BrowserCacheManager => {\n const cacheOptions = {\n cacheLocation: BrowserCacheLocation.MemoryStorage,\n store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