virgil-sdk
Version:
Virgil Security Services SDK
54 lines (53 loc) • 1.99 kB
TypeScript
import { IStorageAdapter } from './adapters/IStorageAdapter';
export interface IKeyStorageConfig {
/**
* Path to folder where to store the data (Node.js only).
*/
dir?: string;
/**
* Name of the IndexedDB database where to store the data (Browsers only).
*/
name?: string;
/**
* The {@link IStorageAdapter} implementation to be used as a storage backend.
*/
adapter?: IStorageAdapter;
}
/**
* Class representing a storage container for private key data.
* Use this class if you need to load the keys stored with
* version 4.x of this library. For new code, use the
* {@link PrivateKeyStorage} instead.
*
* @deprecated since version 5.0
*/
export declare class KeyStorage {
private adapter;
constructor(config?: IKeyStorageConfig | string);
/**
* Checks whether a private key data with the given name exist in persistent storage.
* @param {string} name - Name to check.
* @returns {Promise<boolean>} - True if key data exist, otherwise false.
*/
exists(name: string): Promise<boolean>;
/**
* Loads the private key data by the given name.
* @param {string} name - Name of key data to load.
* @returns {Promise<string | null>} - Private key data as a string,
* or null if there is no data for the given name.
*/
load(name: string): Promise<string | null>;
/**
* Removes the private key data stored under the given name from persistent storage.
* @param {string} name - Name of the key data to remove.
* @returns {Promise<boolean>} - True if the key has been removed, otherwise false.
*/
remove(name: string): Promise<boolean>;
/**
* Persists the private key data under the given name.
* @param {string} name - Name of the key data.
* @param {string} data - The key data.
* @returns {Promise<void>}
*/
save(name: string, data: string): Promise<void>;
}