TokenCache class

記憶體內令牌快取管理器

屬性

persistence

方法

deserialize(string)

將 JSON 反序列化為記憶體內快取。 JSON 應該是 MSAL 快取結構格式

getAccountByHomeId(string)

回傳已登入的帳號,與 homeAccountId 相符。 (帳號物件在成功登入時建立)或當找不到匹配帳號時為空

getAccountByLocalId(string)

會回傳與 localAccountID 相符的登入帳號。 (帳號物件在成功登入時建立)或當找不到匹配帳號時為空

getAllAccounts(string)

API 會取回目前快取中的所有帳號給使用者

getCacheSnapshot()

取得 CacheKVStore 格式的快取快照

getKVStore()

擷取快取鍵值映射

hasChanged()

若快取狀態自上次序列化或 writeToPersistence 呼叫以來改變,則將 true 設定為

overwriteCache()

用持久快取覆蓋記憶體內快取

removeAccount(AccountInfo, string)

API 用來移除特定帳號及相關資料從快取中移除

serialize()

記憶體快取中的序列化轉為 JSON

建構函式詳細資料

TokenCache(NodeStorage, Logger, ICachePlugin)

new TokenCache(storage: NodeStorage, logger: Logger, cachePlugin?: ICachePlugin)

參數

storage

NodeStorage

logger
Logger
cachePlugin
ICachePlugin

屬性詳細資料

persistence

persistence: ICachePlugin

屬性值

方法詳細資料

deserialize(string)

將 JSON 反序列化為記憶體內快取。 JSON 應該是 MSAL 快取結構格式

function deserialize(cache: string)

參數

cache

string

blob格式快取

getAccountByHomeId(string)

回傳已登入的帳號,與 homeAccountId 相符。 (帳號物件在成功登入時建立)或當找不到匹配帳號時為空

function getAccountByHomeId(homeAccountId: string): Promise<null | AccountInfo>

參數

homeAccountId

string

帳戶唯一識別碼(UID.UTID)

傳回

Promise<null | AccountInfo>

getAccountByLocalId(string)

會回傳與 localAccountID 相符的登入帳號。 (帳號物件在成功登入時建立)或當找不到匹配帳號時為空

function getAccountByLocalId(localAccountId: string): Promise<null | AccountInfo>

參數

localAccountId

string

帳號的唯一識別碼(當無法填入 homeAccountId 時,使用 sub/obj)

傳回

Promise<null | AccountInfo>

getAllAccounts(string)

API 會取回目前快取中的所有帳號給使用者

function getAllAccounts(correlationId?: string): Promise<AccountInfo[]>

參數

correlationId

string

傳回

Promise<AccountInfo[]>

getCacheSnapshot()

取得 CacheKVStore 格式的快取快照

function getCacheSnapshot(): CacheKVStore

傳回

getKVStore()

擷取快取鍵值映射

function getKVStore(): CacheKVStore

傳回

hasChanged()

若快取狀態自上次序列化或 writeToPersistence 呼叫以來改變,則將 true 設定為

function hasChanged(): boolean

傳回

boolean

overwriteCache()

用持久快取覆蓋記憶體內快取

function overwriteCache(): Promise<void>

傳回

Promise<void>

removeAccount(AccountInfo, string)

API 用來移除特定帳號及相關資料從快取中移除

function removeAccount(account: AccountInfo, correlationId?: string): Promise<void>

參數

account
AccountInfo

使用者傳遞的 AccountInfo

correlationId

string

傳回

Promise<void>

serialize()

記憶體快取中的序列化轉為 JSON

function serialize(): string

傳回

string