TokenCache class
In-memory token cache manager
Constructors
Token |
Properties
persistence |
Methods
deserialize(string) | Deserializes JSON to in-memory cache. JSON should be in MSAL cache schema format |
get |
Returns the signed in account matching homeAccountId. (the account object is created at the time of successful login) or null when no matching account is found |
get |
Returns the signed in account matching localAccountId. (the account object is created at the time of successful login) or null when no matching account is found |
get |
API that retrieves all accounts currently in cache to the user |
get |
Gets cache snapshot in CacheKVStore format |
get |
Fetches the cache key-value map |
has |
Set to true if cache state has changed since last time serialize or writeToPersistence was called |
overwrite |
Overwrites in-memory cache with persistent cache |
remove |
API to remove a specific account and the relevant data from cache |
serialize() | Serializes in memory cache to JSON |
Constructor Details
TokenCache(NodeStorage, Logger, ICachePlugin)
new TokenCache(storage: NodeStorage, logger: Logger, cachePlugin?: ICachePlugin)
Parameters
- storage
-
NodeStorage
- logger
- Logger
- cachePlugin
- ICachePlugin
Property Details
persistence
Method Details
deserialize(string)
Deserializes JSON to in-memory cache. JSON should be in MSAL cache schema format
function deserialize(cache: string)
Parameters
- cache
-
string
blob formatted cache
getAccountByHomeId(string)
Returns the signed in account matching homeAccountId. (the account object is created at the time of successful login) or null when no matching account is found
function getAccountByHomeId(homeAccountId: string): Promise<null | AccountInfo>
Parameters
- homeAccountId
-
string
unique identifier for an account (uid.utid)
Returns
Promise<null | AccountInfo>
getAccountByLocalId(string)
Returns the signed in account matching localAccountId. (the account object is created at the time of successful login) or null when no matching account is found
function getAccountByLocalId(localAccountId: string): Promise<null | AccountInfo>
Parameters
- localAccountId
-
string
unique identifier of an account (sub/obj when homeAccountId cannot be populated)
Returns
Promise<null | AccountInfo>
getAllAccounts(string)
API that retrieves all accounts currently in cache to the user
function getAllAccounts(correlationId?: string): Promise<AccountInfo[]>
Parameters
- correlationId
-
string
Returns
Promise<AccountInfo[]>
getCacheSnapshot()
Gets cache snapshot in CacheKVStore format
function getCacheSnapshot(): CacheKVStore
Returns
getKVStore()
hasChanged()
Set to true if cache state has changed since last time serialize or writeToPersistence was called
function hasChanged(): boolean
Returns
boolean
overwriteCache()
Overwrites in-memory cache with persistent cache
function overwriteCache(): Promise<void>
Returns
Promise<void>
removeAccount(AccountInfo, string)
API to remove a specific account and the relevant data from cache
function removeAccount(account: AccountInfo, correlationId?: string): Promise<void>
Parameters
- account
- AccountInfo
AccountInfo passed by the user
- correlationId
-
string
Returns
Promise<void>
serialize()
Serializes in memory cache to JSON
function serialize(): string
Returns
string