import type { Key, KeyType } from '../crypto'; import type { Disposable } from '../plugins'; import type { EncryptedMessage, PlaintextMessage, WalletConfig, WalletConfigRekey, WalletExportImportConfig } from '../types'; import type { Buffer } from '../utils/buffer'; export interface Wallet extends Disposable { isInitialized: boolean; isProvisioned: boolean; create(walletConfig: WalletConfig): Promise; createAndOpen(walletConfig: WalletConfig): Promise; open(walletConfig: WalletConfig): Promise; rotateKey(walletConfig: WalletConfigRekey): Promise; close(): Promise; delete(): Promise; /** * Export the wallet to a file at the given path and encrypt it with the given key. * * @throws {WalletExportPathExistsError} When the export path already exists */ export(exportConfig: WalletExportImportConfig): Promise; import(walletConfig: WalletConfig, importConfig: WalletExportImportConfig): Promise; /** * Create a key with an optional private key and keyType. * * @param options.privateKey Buffer Private key (formerly called 'seed') * @param options.keyType KeyType the type of key that should be created * * @returns a `Key` instance * * @throws {WalletError} When an unsupported keytype is requested * @throws {WalletError} When the key could not be created * @throws {WalletKeyExistsError} When the key already exists in the wallet */ createKey(options: WalletCreateKeyOptions): Promise; sign(options: WalletSignOptions): Promise; verify(options: WalletVerifyOptions): Promise; pack(payload: Record, recipientKeys: string[], senderVerkey?: string): Promise; unpack(encryptedMessage: EncryptedMessage): Promise; generateNonce(): Promise; generateWalletKey(): Promise; /** * Get the key types supported by the wallet implementation. */ supportedKeyTypes: KeyType[]; } export interface WalletCreateKeyOptions { keyType: KeyType; seed?: Buffer; privateKey?: Buffer; } export interface WalletSignOptions { data: Buffer | Buffer[]; key: Key; } export interface WalletVerifyOptions { data: Buffer | Buffer[]; key: Key; signature: Buffer; } export interface UnpackedMessageContext { plaintextMessage: PlaintextMessage; senderKey?: string; recipientKey?: string; }