Vault

The Vault Aptitude provides the ability to read and write strings in either macOS' Keychain or Window's Credential Manager, depending on the system.

The vault Aptitude is not intended for storing large amounts of data.

remove

Removes the entry from the vault with the specified key.

import { vault } from '@oliveai/ldk';

const key = 'myKey';

vault.remove(key).then(() => {
    console.log(`Removed ${key} from the vault`);
});

exists

Returns true if an entry with the specified key is in the vault.

import { vault } from '@oliveai/ldk';

const key = 'myKey';

vault.exists(key).then((inVault) => {
    console.log(`${key} ${!inVault ? 'does not exist' : 'exists'} in the vault.`);
});

read

Returns the value stored in the vault with the specified key.

import { vault } from '@oliveai/ldk';

const key = 'myKey';

vault.read(key).then((value) => {
    console.log(`${key} maps to ${value}`);
});

write

Adds the given value to the vault with the specified key.

import { vault } from '@oliveai/ldk';

const key = 'myKey';
const value = 'some value to write';

vault.write(key, value).then(() => {
    console.log(`Wrote ${value} to ${key}`);
});

Last updated