Skip to content

Keychain

Secure storage for credentials.

The keychain is a secure storage for credentials, keys etc. Use the set() method to add values to the keychain. You can then later use the get() method to retrieve the value.

+contains

Check if keychain contains a key.

static contains(key: string): bool

Checks if the keychain contains the specified key.

Parameters

key
string
Key to look up in the keychain.

Return value

bool
True if the key exists in the keychain, otherwise false.


+set

Add value for a specified key to keychain.

static set(key: string, value: string)

Adds the the value to the keychain, assigning it to the specified key. If the key already exists in the keychain, the value is overwritten.

Values are securely stored in an encrypted database.

Parameters

key
string
Key which the value should be assigned to.

value
string
Value to assign to the specified key.


+get

Reads a value from the keychain.

static get(key: string): string

Reads the value for the specified key. If the key doesn't exist the method will throw an error. Used the contains method to check if a key exists in the keychain.

Parameters

key
string
Key to read value for.

Return value

string
Value assigned to the specified key.


+remove

Remove key from keychain.

static remove(key: string)

Parameters

key
string
Key to remove from the keychain.