*Add protocol manager api
This commit is contained in:
parent
0d6219837a
commit
815c7a824c
|
@ -1,2 +1,3 @@
|
||||||
export * from "./rpc.js";
|
export * from "./rpc.js";
|
||||||
export * from "./plugin.js";
|
export * from "./plugin.js";
|
||||||
|
export * from "./swarm.js";
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { Logger } from "pino";
|
||||||
import SSLManager from "./ssl.js";
|
import SSLManager from "./ssl.js";
|
||||||
import type { HDKey } from "micro-ed25519-hdkey";
|
import type { HDKey } from "micro-ed25519-hdkey";
|
||||||
import type Config from "@lumeweb/cfg";
|
import type Config from "@lumeweb/cfg";
|
||||||
|
import type { ProtocolManager } from "./swarm.js";
|
||||||
|
|
||||||
export type PluginFunction = (api: PluginAPI) => Promise<void>;
|
export type PluginFunction = (api: PluginAPI) => Promise<void>;
|
||||||
|
|
||||||
|
@ -34,6 +35,7 @@ export declare class PluginAPI extends EventEmitter2 {
|
||||||
get seed(): Uint8Array;
|
get seed(): Uint8Array;
|
||||||
get identity(): HDKey;
|
get identity(): HDKey;
|
||||||
get ssl(): SSLManager;
|
get ssl(): SSLManager;
|
||||||
|
get protocols(): ProtocolManager;
|
||||||
loadPlugin(moduleName: string): (moduleName: string) => Promise<Plugin>;
|
loadPlugin(moduleName: string): (moduleName: string) => Promise<Plugin>;
|
||||||
registerMethod(methodName: string, method: RPCMethod): void;
|
registerMethod(methodName: string, method: RPCMethod): void;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
export type ProtocolHandler = (peer: any, muxer: any) => void;
|
||||||
|
|
||||||
|
export declare class ProtocolManager {
|
||||||
|
constructor(swarm: any);
|
||||||
|
register(name: string, handler: ProtocolHandler): boolean;
|
||||||
|
}
|
Loading…
Reference in New Issue