Skip to main content

Interface: TokenStorage

Defines interface for token storage. Token and Token.Metadata are treated as independent entities, which enables them to be stored in different locations. This may be more relevant in mobile environments, where Token data can be written to a secure location (which requires biometrics to access) and Token.Metadata, containing only non-sensitive info can be stored in a more accessible location and used to query which tokens are available (without prompting biometrics)

Remarks​

Default implementation provided based on localStorage

Properties​

emitter​

readonly emitter: TokenStorageEventEmitter


defaultTokenId​

readonly defaultTokenId: null | string

In memory cached value of the default Credential's id

Methods​

setDefaultTokenId()​

setDefaultTokenId(id): void

Updates the stored default Credential id

Parameters​

• id: null | string

Returns​

void


allIDs()​

allIDs(): string[]

Returns all Token.id | Token ids in storage

Returns​

string[]


add()​

add(token, metadata?): void

Writes a Token to storage

Parameters​

• token: Token

raw JSON representation of Token

• metadata?: Metadata

non-sensitive data regarding the stored Token which will be used in storage queries

Returns​

void


replace()​

replace(id, token): void

Updates the Token value in storage for a given id | Token.id. Used by operations like Credential.refresh

Parameters​

• id: string

• token: Token

Returns​

void


remove()​

remove(id): void

Removes the Token value for a given id | Token.id from storage

Parameters​

• id: string

Returns​

void

Remarks​

NOTE: This does not revoke tokens. They are only removed from storage!


get()​

get(id): null | Token

Retrieves a Token from storage

Parameters​

• id: string

Returns​

null | Token

Remarks​

This may prompt user for biometrics in certain mobile environments


getMetadata()​

getMetadata(id): null | Metadata

Retieves Token.Metadata for a given Token.id | id

Parameters​

• id: string

Returns​

null | Metadata

Remarks​

Token.Metadata will be written to less-protected location and therefore will not prompt biometrics


setMetadata()​

setMetadata(metadata): void

Writes Token.Metadata for a given Token to storage

Parameters​

• metadata: Metadata

Returns​

void


clear()​

clear(): void

Clears all Tokens from storage

Returns​

void

Remarks​

NOTE: This does not revoke tokens. They are only removed from storage!