@enactprotocol/security
Version:
Backend security library for signing enact documents
37 lines (36 loc) • 1.56 kB
TypeScript
import { CryptoUtils } from './crypto';
import type { KeyPair } from './types';
export interface KeyMetadata {
keyId: string;
created: string;
algorithm: string;
description?: string;
}
export declare class KeyManager {
private static readonly TRUSTED_KEYS_DIR;
private static readonly PRIVATE_KEYS_DIR;
private static ensureDirectories;
private static getPublicKeyPath;
private static getPrivateKeyPath;
private static getMetadataPath;
static generateAndStoreKey(keyId: string, description?: string): KeyPair;
static storeKey(keyId: string, keyPair: KeyPair, description?: string): void;
static getKey(keyId: string): KeyPair | undefined;
static getPublicKey(keyId: string): string | undefined;
static getKeyMetadata(keyId: string): KeyMetadata | undefined;
static keyExists(keyId: string): boolean;
static removeKey(keyId: string): boolean;
static listKeys(): string[];
static listTrustedKeys(): string[];
static getAllTrustedPublicKeys(): string[];
static listPrivateKeys(): string[];
static getAllPrivateKeys(): CryptoUtils.PrivateKey[];
static exportKey(keyId: string): KeyPair | undefined;
static importKey(keyId: string, privateKey: string, description?: string): KeyPair;
static importPublicKey(keyId: string, publicKey: string, description?: string): void;
static getStoragePaths(): {
trustedKeys: string;
privateKeys: string;
};
static exportKeyToFile(keyId: string, outputPath: string, includePrivateKey?: boolean): void;
}