NodeStorage class
This class implements Storage for node, reading cache from user specified storage location or an extension library
- Extends
-
CacheManager
Constructors
Node |
Methods
cache |
Converts cacheKVStore to InMemoryCache |
clear() | Clears all cache entries created by MSAL (except tokens). |
contains |
Checks whether key is in cache. |
emit |
Invoke the callback when cache changes |
generate |
Initialize in memory cache from an exisiting cache vault |
generate |
retrieves the final JSON |
get |
fetch the accessToken credential |
get |
fetch the account entity |
get |
fetch appMetadata entity from the platform cache |
get |
fetch authority metadata entity from the platform cache |
get |
Get all authority metadata keys |
get |
get the current cache key-value store |
get |
fetch the idToken credential |
get |
gets the current in memory cache for the client |
get |
Gets cache item with given key. |
get |
Gets all keys in window. |
get |
fetch the refreshToken credential |
get |
fetch server telemetry entity from the platform cache |
get |
fetch throttling entity from the platform cache |
in |
converts inMemoryCache to CacheKVStore |
register |
Queue up callbacks |
remove |
Removes the cache item from memory with the given key. |
set |
set accessToken credential |
set |
set account entity |
set |
set appMetadata entity to the platform cache |
set |
set authority metadata entity to the platform cache |
set |
sets the current cache (key value store) |
set |
set idToken credential |
set |
sets the current in memory cache for the client |
set |
Gets cache item with given key-value |
set |
set refreshToken credential |
set |
set server telemetry entity to the platform cache |
set |
set throttling entity to the platform cache |
update |
Updates a credential's cache key if the current cache key is outdated |
Inherited Methods
generate |
returns cache key used for cloud instance metadata |
get |
retrieve accounts matching all provided filters; if no filter is set, get all accounts not checking for casing as keys are all generated in lower case, remember to convert to lower case if object properties are compared |
get |
Returns all accounts in cache |
get |
retrieve appMetadata matching all provided filters; if no filter is set, get all appMetadata |
get |
retrieve authorityMetadata that contains a matching alias |
get |
retrieve credentails matching all provided filters; if no filter is set, get all credentials |
is |
Return the family_id value associated with FOCI |
read |
Retrieve AccessTokenEntity from cache |
read |
Retrieve AccountEntity from cache |
read |
Retrieve AccountEntity from cache |
read |
Retrieve AppMetadataEntity from cache |
read |
Retrieve the cached credentials into a cacherecord |
read |
Retrieve IdTokenEntity from cache |
read |
Helper to retrieve the appropriate refresh token from cache |
remove |
returns a boolean if the given account is removed |
remove |
Removes credentials associated with the provided account |
remove |
Removes all accounts and related tokens from cache. |
remove |
Removes all app metadata objects from cache. |
remove |
returns a boolean if the given credential is removed |
save |
saves a cache record |
to |
Helper to convert serialized data to object |
Constructor Details
NodeStorage(Logger, string, ICrypto)
new NodeStorage(logger: Logger, clientId: string, cryptoImpl: ICrypto)
Parameters
- logger
-
Logger
- clientId
-
string
- cryptoImpl
-
ICrypto
Method Details
cacheToInMemoryCache(CacheKVStore)
Converts cacheKVStore to InMemoryCache
function cacheToInMemoryCache(cache: CacheKVStore): InMemoryCache
Parameters
- cache
- CacheKVStore
key value store
Returns
clear()
Clears all cache entries created by MSAL (except tokens).
function clear(): Promise<void>
Returns
Promise<void>
containsKey(string)
Checks whether key is in cache.
function containsKey(key: string): boolean
Parameters
- key
-
string
look up key for a cache entity
Returns
boolean
emitChange()
Invoke the callback when cache changes
function emitChange()
generateInMemoryCache(string)
Initialize in memory cache from an exisiting cache vault
static function generateInMemoryCache(cache: string): InMemoryCache
Parameters
- cache
-
string
blob formatted cache (JSON)
Returns
generateJsonCache(InMemoryCache)
retrieves the final JSON
static function generateJsonCache(inMemoryCache: InMemoryCache): JsonCache
Parameters
- inMemoryCache
- InMemoryCache
itemised cache read from the JSON
Returns
getAccessTokenCredential(string)
fetch the accessToken credential
function getAccessTokenCredential(accessTokenKey: string): AccessTokenEntity | null
Parameters
- accessTokenKey
-
string
lookup key to fetch cache type AccessTokenEntity
Returns
AccessTokenEntity | null
getAccount(string)
fetch the account entity
function getAccount(accountKey: string): AccountEntity | null
Parameters
- accountKey
-
string
lookup key to fetch cache type AccountEntity
Returns
AccountEntity | null
getAppMetadata(string)
fetch appMetadata entity from the platform cache
function getAppMetadata(appMetadataKey: string): AppMetadataEntity | null
Parameters
- appMetadataKey
-
string
lookup key to fetch cache type AppMetadataEntity
Returns
AppMetadataEntity | null
getAuthorityMetadata(string)
fetch authority metadata entity from the platform cache
function getAuthorityMetadata(key: string): AuthorityMetadataEntity | null
Parameters
- key
-
string
lookup key to fetch cache type AuthorityMetadataEntity
Returns
AuthorityMetadataEntity | null
getAuthorityMetadataKeys()
Get all authority metadata keys
function getAuthorityMetadataKeys(): Array<string>
Returns
Array<string>
getCache()
getIdTokenCredential(string)
fetch the idToken credential
function getIdTokenCredential(idTokenKey: string): IdTokenEntity | null
Parameters
- idTokenKey
-
string
lookup key to fetch cache type IdTokenEntity
Returns
IdTokenEntity | null
getInMemoryCache()
gets the current in memory cache for the client
function getInMemoryCache(): InMemoryCache
Returns
getItem(string)
Gets cache item with given key.
function getItem(key: string): ValidCacheType
Parameters
- key
-
string
lookup key for the cache entry
Returns
ValidCacheType
getKeys()
Gets all keys in window.
function getKeys(): string[]
Returns
string[]
getRefreshTokenCredential(string)
fetch the refreshToken credential
function getRefreshTokenCredential(refreshTokenKey: string): RefreshTokenEntity | null
Parameters
- refreshTokenKey
-
string
lookup key to fetch cache type RefreshTokenEntity
Returns
RefreshTokenEntity | null
getServerTelemetry(string)
fetch server telemetry entity from the platform cache
function getServerTelemetry(serverTelemetrykey: string): ServerTelemetryEntity | null
Parameters
- serverTelemetrykey
-
string
lookup key to fetch cache type ServerTelemetryEntity
Returns
ServerTelemetryEntity | null
getThrottlingCache(string)
fetch throttling entity from the platform cache
function getThrottlingCache(throttlingCacheKey: string): ThrottlingEntity | null
Parameters
- throttlingCacheKey
-
string
lookup key to fetch cache type ThrottlingEntity
Returns
ThrottlingEntity | null
inMemoryCacheToCache(InMemoryCache)
converts inMemoryCache to CacheKVStore
function inMemoryCacheToCache(inMemoryCache: InMemoryCache): CacheKVStore
Parameters
- inMemoryCache
- InMemoryCache
kvstore map for inmemory
Returns
registerChangeEmitter(() => void)
Queue up callbacks
function registerChangeEmitter(func: () => void)
Parameters
- func
-
() => void
a callback function for cache change indication
removeItem(string)
Removes the cache item from memory with the given key.
function removeItem(key: string): boolean
Parameters
- key
-
string
lookup key to remove a cache entity
Returns
boolean
setAccessTokenCredential(AccessTokenEntity)
set accessToken credential
function setAccessTokenCredential(accessToken: AccessTokenEntity)
Parameters
- accessToken
-
AccessTokenEntity
cache value to be set of type AccessTokenEntity
setAccount(AccountEntity)
set account entity
function setAccount(account: AccountEntity)
Parameters
- account
-
AccountEntity
cache value to be set of type AccountEntity
setAppMetadata(AppMetadataEntity)
set appMetadata entity to the platform cache
function setAppMetadata(appMetadata: AppMetadataEntity)
Parameters
- appMetadata
-
AppMetadataEntity
cache value to be set of type AppMetadataEntity
setAuthorityMetadata(string, AuthorityMetadataEntity)
set authority metadata entity to the platform cache
function setAuthorityMetadata(key: string, metadata: AuthorityMetadataEntity)
Parameters
- key
-
string
lookup key to fetch cache type AuthorityMetadataEntity
- metadata
-
AuthorityMetadataEntity
cache value to be set of type AuthorityMetadataEntity
setCache(CacheKVStore)
sets the current cache (key value store)
function setCache(cache: CacheKVStore)
Parameters
- cache
- CacheKVStore
setIdTokenCredential(IdTokenEntity)
set idToken credential
function setIdTokenCredential(idToken: IdTokenEntity)
Parameters
- idToken
-
IdTokenEntity
cache value to be set of type IdTokenEntity
setInMemoryCache(InMemoryCache)
sets the current in memory cache for the client
function setInMemoryCache(inMemoryCache: InMemoryCache)
Parameters
- inMemoryCache
- InMemoryCache
key value map in memory
setItem(string, ValidCacheType)
Gets cache item with given key-value
function setItem(key: string, value: ValidCacheType)
Parameters
- key
-
string
lookup key for the cache entry
- value
-
ValidCacheType
value of the cache entry
setRefreshTokenCredential(RefreshTokenEntity)
set refreshToken credential
function setRefreshTokenCredential(refreshToken: RefreshTokenEntity)
Parameters
- refreshToken
-
RefreshTokenEntity
cache value to be set of type RefreshTokenEntity
setServerTelemetry(string, ServerTelemetryEntity)
set server telemetry entity to the platform cache
function setServerTelemetry(serverTelemetryKey: string, serverTelemetry: ServerTelemetryEntity)
Parameters
- serverTelemetryKey
-
string
lookup key to fetch cache type ServerTelemetryEntity
- serverTelemetry
-
ServerTelemetryEntity
cache value to be set of type ServerTelemetryEntity
setThrottlingCache(string, ThrottlingEntity)
set throttling entity to the platform cache
function setThrottlingCache(throttlingCacheKey: string, throttlingCache: ThrottlingEntity)
Parameters
- throttlingCacheKey
-
string
lookup key to fetch cache type ThrottlingEntity
- throttlingCache
-
ThrottlingEntity
cache value to be set of type ThrottlingEntity
updateCredentialCacheKey(string, ValidCredentialType)
Updates a credential's cache key if the current cache key is outdated
function updateCredentialCacheKey(currentCacheKey: string, credential: ValidCredentialType): string
Parameters
- currentCacheKey
-
string
- credential
-
ValidCredentialType
Returns
string
Inherited Method Details
generateAuthorityMetadataCacheKey(string)
returns cache key used for cloud instance metadata
function generateAuthorityMetadataCacheKey(authority: string): string
Parameters
- authority
-
string
Returns
string
Inherited From CacheManager.generateAuthorityMetadataCacheKey
getAccountsFilteredBy(AccountFilter)
retrieve accounts matching all provided filters; if no filter is set, get all accounts not checking for casing as keys are all generated in lower case, remember to convert to lower case if object properties are compared
function getAccountsFilteredBy(accountFilter?: AccountFilter): AccountCache
Parameters
- accountFilter
-
AccountFilter
Returns
AccountCache
Inherited From CacheManager.getAccountsFilteredBy
getAllAccounts()
Returns all accounts in cache
function getAllAccounts(): AccountInfo[]
Returns
AccountInfo[]
Inherited From CacheManager.getAllAccounts
getAppMetadataFilteredBy(AppMetadataFilter)
retrieve appMetadata matching all provided filters; if no filter is set, get all appMetadata
function getAppMetadataFilteredBy(filter: AppMetadataFilter): AppMetadataCache
Parameters
- filter
-
AppMetadataFilter
Returns
AppMetadataCache
Inherited From CacheManager.getAppMetadataFilteredBy
getAuthorityMetadataByAlias(string)
retrieve authorityMetadata that contains a matching alias
function getAuthorityMetadataByAlias(host: string): AuthorityMetadataEntity | null
Parameters
- host
-
string
Returns
AuthorityMetadataEntity | null
Inherited From CacheManager.getAuthorityMetadataByAlias
getCredentialsFilteredBy(CredentialFilter)
retrieve credentails matching all provided filters; if no filter is set, get all credentials
function getCredentialsFilteredBy(filter: CredentialFilter): CredentialCache
Parameters
- filter
-
CredentialFilter
Returns
CredentialCache
Inherited From CacheManager.getCredentialsFilteredBy
isAppMetadataFOCI(string, string)
Return the family_id value associated with FOCI
function isAppMetadataFOCI(environment: string, clientId: string): boolean
Parameters
- environment
-
string
- clientId
-
string
Returns
boolean
Inherited From CacheManager.isAppMetadataFOCI
readAccessTokenFromCache(string, AccountInfo, BaseAuthRequest)
Retrieve AccessTokenEntity from cache
function readAccessTokenFromCache(clientId: string, account: AccountInfo, request: BaseAuthRequest): AccessTokenEntity | null
Parameters
- clientId
-
string
- account
-
AccountInfo
- request
-
BaseAuthRequest
Returns
AccessTokenEntity | null
Inherited From CacheManager.readAccessTokenFromCache
readAccountFromCache(AccountInfo)
Retrieve AccountEntity from cache
function readAccountFromCache(account: AccountInfo): AccountEntity | null
Parameters
- account
-
AccountInfo
Returns
AccountEntity | null
Inherited From CacheManager.readAccountFromCache
readAccountFromCacheWithNativeAccountId(string)
Retrieve AccountEntity from cache
function readAccountFromCacheWithNativeAccountId(nativeAccountId: string): AccountEntity | null
Parameters
- nativeAccountId
-
string
Returns
AccountEntity | null
AccountEntity or Null
Inherited From CacheManager.readAccountFromCacheWithNativeAccountId
readAppMetadataFromCache(string, string)
Retrieve AppMetadataEntity from cache
function readAppMetadataFromCache(environment: string, clientId: string): AppMetadataEntity | null
Parameters
- environment
-
string
- clientId
-
string
Returns
AppMetadataEntity | null
Inherited From CacheManager.readAppMetadataFromCache
readCacheRecord(AccountInfo, string, BaseAuthRequest, string)
Retrieve the cached credentials into a cacherecord
function readCacheRecord(account: AccountInfo, clientId: string, request: BaseAuthRequest, environment: string): CacheRecord
Parameters
- account
-
AccountInfo
- clientId
-
string
- request
-
BaseAuthRequest
- environment
-
string
Returns
CacheRecord
Inherited From CacheManager.readCacheRecord
readIdTokenFromCache(string, AccountInfo)
Retrieve IdTokenEntity from cache
function readIdTokenFromCache(clientId: string, account: AccountInfo): IdTokenEntity | null
Parameters
- clientId
-
string
- account
-
AccountInfo
Returns
IdTokenEntity | null
Inherited From CacheManager.readIdTokenFromCache
readRefreshTokenFromCache(string, AccountInfo, boolean)
Helper to retrieve the appropriate refresh token from cache
function readRefreshTokenFromCache(clientId: string, account: AccountInfo, familyRT: boolean): RefreshTokenEntity | null
Parameters
- clientId
-
string
- account
-
AccountInfo
- familyRT
-
boolean
Returns
RefreshTokenEntity | null
Inherited From CacheManager.readRefreshTokenFromCache
removeAccount(string)
returns a boolean if the given account is removed
function removeAccount(accountKey: string): Promise<boolean>
Parameters
- accountKey
-
string
Returns
Promise<boolean>
Inherited From CacheManager.removeAccount
removeAccountContext(AccountEntity)
Removes credentials associated with the provided account
function removeAccountContext(account: AccountEntity): Promise<boolean>
Parameters
- account
-
AccountEntity
Returns
Promise<boolean>
Inherited From CacheManager.removeAccountContext
removeAllAccounts()
Removes all accounts and related tokens from cache.
function removeAllAccounts(): Promise<boolean>
Returns
Promise<boolean>
Inherited From CacheManager.removeAllAccounts
removeAppMetadata()
Removes all app metadata objects from cache.
function removeAppMetadata(): boolean
Returns
boolean
Inherited From CacheManager.removeAppMetadata
removeCredential(CredentialEntity)
returns a boolean if the given credential is removed
function removeCredential(credential: CredentialEntity): Promise<boolean>
Parameters
- credential
-
CredentialEntity
Returns
Promise<boolean>
Inherited From CacheManager.removeCredential
saveCacheRecord(CacheRecord)
saves a cache record
function saveCacheRecord(cacheRecord: CacheRecord): Promise<void>
Parameters
- cacheRecord
-
CacheRecord
Returns
Promise<void>
Inherited From CacheManager.saveCacheRecord
toObject<T>(T, object)
Helper to convert serialized data to object
static function toObject<T>(obj: T, json: object): T
Parameters
- obj
-
T
- json
-
object
Returns
T
Inherited From CacheManager.toObject