@libp2p/keychain
Version:
Key management and cryptographically protected messages
61 lines • 2.17 kB
TypeScript
import { serviceCapabilities } from '@libp2p/interface';
import type { KeychainComponents, KeychainInit, Keychain as KeychainInterface, KeyInfo } from './index.ts';
import type { PrivateKey } from '@libp2p/interface';
export declare function keyId(key: PrivateKey): Promise<string>;
/**
* Manages the life cycle of a key. Keys are encrypted at rest using PKCS #8.
*
* A key in the store has two entries
* - '/info/*key-name*', contains the KeyInfo for the key
* - '/pkcs8/*key-name*', contains the PKCS #8 for the key
*
*/
export declare class Keychain implements KeychainInterface {
private readonly components;
private readonly init;
private readonly log;
private readonly self;
/**
* Creates a new instance of a key chain
*/
constructor(components: KeychainComponents, init: KeychainInit);
readonly [Symbol.toStringTag] = "@libp2p/keychain";
readonly [serviceCapabilities]: string[];
/**
* Generates the options for a keychain. A random salt is produced.
*
* @returns {object}
*/
static generateOptions(): KeychainInit;
/**
* Gets an object that can encrypt/decrypt protected data.
* The default options for a keychain.
*
* @returns {object}
*/
static get options(): KeychainInit;
findKeyByName(name: string): Promise<KeyInfo>;
findKeyById(id: string): Promise<KeyInfo>;
importKey(name: string, key: PrivateKey): Promise<KeyInfo>;
exportKey(name: string): Promise<PrivateKey>;
removeKey(name: string): Promise<KeyInfo>;
/**
* List all the keys.
*
* @returns {Promise<KeyInfo[]>}
*/
listKeys(): Promise<KeyInfo[]>;
/**
* Rename a key
*
* @param {string} oldName - The old local key name; must already exist.
* @param {string} newName - The new local key name; must not already exist.
* @returns {Promise<KeyInfo>}
*/
renameKey(oldName: string, newName: string): Promise<KeyInfo>;
/**
* Rotate keychain password and re-encrypt all associated keys
*/
rotateKeychainPass(oldPass: string, newPass: string): Promise<void>;
}
//# sourceMappingURL=keychain.d.ts.map