UNPKG

virgil-sdk

Version:
59 lines (58 loc) 2.25 kB
import { IPrivateKey, IPrivateKeyExporter } from '../types'; import { IKeyEntryStorage } from './KeyEntryStorage/IKeyEntryStorage'; /** * Interface of a single entry in {@link PrivateKeyStorage}. */ export interface IPrivateKeyEntry { privateKey: IPrivateKey; meta?: { [key: string]: string; }; } /** * Class responsible for storage of private keys. */ export declare class PrivateKeyStorage { private privateKeyExporter; private keyEntryStorage; /** * Initializes a new instance of `PrivateKeyStorage`. * @param {IPrivateKeyExporter} privateKeyExporter - Object responsible for * exporting private key bytes from `IPrivateKey` objects and importing * private key bytes into `IPrivateKey` objects. * @param {IKeyEntryStorage} keyEntryStorage - Object responsible for * persistence of private keys data. */ constructor(privateKeyExporter: IPrivateKeyExporter, keyEntryStorage?: IKeyEntryStorage); /** * Persists the given `privateKey` and `meta` under the given `name`. * If an entry with the same name already exists rejects the returned * Promise with {@link PrivateKeyExistsError} error. * * @param {string} name - Name of the private key. * @param {IPrivateKey} privateKey - The private key object. * @param {Object<string, string>} [meta] - Optional metadata to store with the key. * * @returns {Promise<void>} */ store(name: string, privateKey: IPrivateKey, meta?: { [key: string]: string; }): Promise<void>; /** * Retrieves the private key with the given `name` from persistent storage. * If private with the given name does not exist, resolves the returned * Promise with `null`. * * @param {string} name - Name of the private key to load. * @returns {Promise<IPrivateKeyEntry|null>} */ load(name: string): Promise<IPrivateKeyEntry | null>; /** * Removes the private key entry with the given `name` from persistent * storage. * * @param {string} name - Name of the private key to remove. * @returns {Promise<void>} */ delete(name: string): Promise<void>; }