*Add protocol manager api

This commit is contained in:
Derrick Hammer 2022-12-30 01:06:29 -05:00
parent 0d6219837a
commit 815c7a824c
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
3 changed files with 9 additions and 0 deletions

View File

@ -1,2 +1,3 @@
export * from "./rpc.js"; export * from "./rpc.js";
export * from "./plugin.js"; export * from "./plugin.js";
export * from "./swarm.js";

View File

@ -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;
} }

6
src/swarm.ts Normal file
View File

@ -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;
}