Editar

Compartilhar via


TokenCache class

In-memory token cache manager

Constructors

TokenCache(NodeStorage, Logger, ICachePlugin)

Methods

deserialize(string)

Deserializes JSON to in-memory cache. JSON should be in MSAL cache schema format

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

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

getAllAccounts()

API that retrieves all accounts currently in cache to the user

getKVStore()

Fetches the cache key-value map

hasChanged()

Set to true if cache state has changed since last time serialize or writeToPersistence was called

removeAccount(AccountInfo)

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

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<AccountInfo | null>

Parameters

homeAccountId

string

unique identifier for an account (uid.utid)

Returns

Promise<AccountInfo | null>

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<AccountInfo | null>

Parameters

localAccountId

string

unique identifier of an account (sub/obj when homeAccountId cannot be populated)

Returns

Promise<AccountInfo | null>

getAllAccounts()

API that retrieves all accounts currently in cache to the user

function getAllAccounts(): Promise<AccountInfo[]>

Returns

Promise<AccountInfo[]>

getKVStore()

Fetches the cache key-value map

function getKVStore(): CacheKVStore

Returns

hasChanged()

Set to true if cache state has changed since last time serialize or writeToPersistence was called

function hasChanged(): boolean

Returns

boolean

removeAccount(AccountInfo)

API to remove a specific account and the relevant data from cache

function removeAccount(account: AccountInfo): Promise<void>

Parameters

account

AccountInfo

AccountInfo passed by the user

Returns

Promise<void>

serialize()

Serializes in memory cache to JSON

function serialize(): string

Returns

string