UNPKG

beeline-cli

Version:

A terminal wallet for the Hive blockchain - type, sign, rule the chain

119 lines 3.83 kB
export interface PluginManifest { name: string; version: string; description: string; author: string; license?: string; repository?: string; keywords?: string[]; main: string; permissions: PluginPermission[]; dependencies?: Record<string, string>; beeline: { minVersion: string; maxVersion?: string; }; } export type PluginPermission = 'hive:read' | 'hive:write' | 'keys:read' | 'accounts:read' | 'network:http' | 'storage:read' | 'storage:write' | 'ui:commands' | 'ui:hooks' | 'system:exec'; export interface BeelinePlugin { manifest: PluginManifest; activate(context: PluginContext): Promise<void> | void; deactivate?(): Promise<void> | void; } export interface PluginContext { hive: PluginHiveAPI; keys: PluginKeysAPI; accounts: PluginAccountsAPI; ui: PluginUIAPI; storage: PluginStorageAPI; events: PluginEventBus; plugin: { name: string; version: string; dataPath: string; }; } export interface PluginHiveAPI { getBalance(account: string): Promise<any>; getAccount(account: string): Promise<any>; getDynamicGlobalProperties(): Promise<any>; sendOperation(op: any, key?: string): Promise<any>; } export interface PluginKeysAPI { listAccounts(): string[]; hasKey(account: string, role: string): boolean; } export interface PluginAccountsAPI { list(): string[]; getCurrent(): string | null; switch(account: string): Promise<boolean>; } export interface PluginUIAPI { registerCommand(command: PluginCommand): void; registerHook(event: HookEvent, handler: HookHandler): void; showMessage(message: string, type?: 'info' | 'success' | 'warning' | 'error'): void; prompt(message: string, options?: any): Promise<any>; } export interface PluginStorageAPI { get(key: string): Promise<any>; set(key: string, value: any): Promise<void>; delete(key: string): Promise<void>; clear(): Promise<void>; } export interface PluginEventBus { on(event: string, handler: (...args: any[]) => void): void; off(event: string, handler: (...args: any[]) => void): void; emit(event: string, ...args: any[]): void; } export interface PluginCommand { name: string; description: string; usage?: string; flags?: Record<string, any>; handler: (args: any, flags: any) => Promise<void>; } export type HookEvent = 'before:balance' | 'after:balance' | 'before:transfer' | 'after:transfer' | 'before:login' | 'after:login'; export type HookHandler = (context: HookContext) => Promise<void> | void; export interface HookContext { command: string; args: any; flags: any; result?: any; } export declare class PluginManager { private plugins; private eventBus; private dataDir; constructor(dataDir?: string); initialize(): Promise<void>; installPlugin(source: string): Promise<void>; loadPlugin(pluginPath: string): Promise<void>; unloadPlugin(name: string): Promise<void>; listPlugins(): LoadedPlugin[]; getPlugin(name: string): LoadedPlugin | undefined; private loadInstalledPlugins; private validateManifest; private checkPermissions; private getPermissionDescription; private isAllowedPluginPath; private isSafePluginFile; private createPluginContext; private createHiveAPI; private createKeysAPI; private createAccountsAPI; private createUIAPI; private createStorageAPI; private validateStorageKey; private validateStorageValue; private createEventBus; } interface LoadedPlugin { manifest: PluginManifest; plugin: BeelinePlugin; context: PluginContext; path: string; active: boolean; } export declare function getPluginManager(): PluginManager; export {}; //# sourceMappingURL=plugin-system.d.ts.map