編集

次の方法で共有


NodeStorage class

This class implements Storage for node, reading cache from user specified storage location or an extension library

Extends

CacheManager

Constructors

NodeStorage(Logger, string, ICrypto)

Methods

cacheToInMemoryCache(CacheKVStore)

Converts cacheKVStore to InMemoryCache

clear()

Clears all cache entries created by MSAL (except tokens).

containsKey(string)

Checks whether key is in cache.

emitChange()

Invoke the callback when cache changes

generateInMemoryCache(string)

Initialize in memory cache from an exisiting cache vault

generateJsonCache(InMemoryCache)

retrieves the final JSON

getAccessTokenCredential(string)

fetch the accessToken credential

getAccount(string)

fetch the account entity

getAppMetadata(string)

fetch appMetadata entity from the platform cache

getAuthorityMetadata(string)

fetch authority metadata entity from the platform cache

getAuthorityMetadataKeys()

Get all authority metadata keys

getCache()

get the current cache key-value store

getIdTokenCredential(string)

fetch the idToken credential

getInMemoryCache()

gets the current in memory cache for the client

getItem(string)

Gets cache item with given key.

getKeys()

Gets all keys in window.

getRefreshTokenCredential(string)

fetch the refreshToken credential

getServerTelemetry(string)

fetch server telemetry entity from the platform cache

getThrottlingCache(string)

fetch throttling entity from the platform cache

inMemoryCacheToCache(InMemoryCache)

converts inMemoryCache to CacheKVStore

registerChangeEmitter(() => void)

Queue up callbacks

removeItem(string)

Removes the cache item from memory with the given key.

setAccessTokenCredential(AccessTokenEntity)

set accessToken credential

setAccount(AccountEntity)

set account entity

setAppMetadata(AppMetadataEntity)

set appMetadata entity to the platform cache

setAuthorityMetadata(string, AuthorityMetadataEntity)

set authority metadata entity to the platform cache

setCache(CacheKVStore)

sets the current cache (key value store)

setIdTokenCredential(IdTokenEntity)

set idToken credential

setInMemoryCache(InMemoryCache)

sets the current in memory cache for the client

setItem(string, ValidCacheType)

Gets cache item with given key-value

setRefreshTokenCredential(RefreshTokenEntity)

set refreshToken credential

setServerTelemetry(string, ServerTelemetryEntity)

set server telemetry entity to the platform cache

setThrottlingCache(string, ThrottlingEntity)

set throttling entity to the platform cache

updateCredentialCacheKey(string, ValidCredentialType)

Updates a credential's cache key if the current cache key is outdated

Inherited Methods

generateAuthorityMetadataCacheKey(string)

returns cache key used for cloud instance metadata

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

getAllAccounts()

Returns all accounts in cache

getAppMetadataFilteredBy(AppMetadataFilter)

retrieve appMetadata matching all provided filters; if no filter is set, get all appMetadata

getAuthorityMetadataByAlias(string)

retrieve authorityMetadata that contains a matching alias

getCredentialsFilteredBy(CredentialFilter)

retrieve credentails matching all provided filters; if no filter is set, get all credentials

isAppMetadataFOCI(string, string)

Return the family_id value associated with FOCI

readAccessTokenFromCache(string, AccountInfo, BaseAuthRequest)

Retrieve AccessTokenEntity from cache

readAccountFromCache(AccountInfo)

Retrieve AccountEntity from cache

readAccountFromCacheWithNativeAccountId(string)

Retrieve AccountEntity from cache

readAppMetadataFromCache(string, string)

Retrieve AppMetadataEntity from cache

readCacheRecord(AccountInfo, string, BaseAuthRequest, string)

Retrieve the cached credentials into a cacherecord

readIdTokenFromCache(string, AccountInfo)

Retrieve IdTokenEntity from cache

readRefreshTokenFromCache(string, AccountInfo, boolean)

Helper to retrieve the appropriate refresh token from cache

removeAccount(string)

returns a boolean if the given account is removed

removeAccountContext(AccountEntity)

Removes credentials associated with the provided account

removeAllAccounts()

Removes all accounts and related tokens from cache.

removeAppMetadata()

Removes all app metadata objects from cache.

removeCredential(CredentialEntity)

returns a boolean if the given credential is removed

saveCacheRecord(CacheRecord)

saves a cache record

toObject<T>(T, object)

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()

get the current cache key-value store

function getCache(): CacheKVStore

Returns

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