Limit methods server add on can access

Reviewed By: mweststrate

Differential Revision: D34076174

fbshipit-source-id: e51a1b08dab54de6b7dc82ca59ec18a10f81ddd7
This commit is contained in:
Andrey Goncharov
2022-02-28 03:50:34 -08:00
committed by Facebook GitHub Bot
parent b80755721c
commit b9294645d3
2 changed files with 14 additions and 3 deletions

View File

@@ -13,12 +13,15 @@ import {
ServerAddOnDesktopToModuleConnection,
FlipperServerForServerAddOn,
} from './ServerAddOnDesktopToModuleConnection';
import {ServerAddOnModuleToDesktopConnection} from './ServerAddOnModuleToDesktopConnection';
import {
ServerAddOnModuleToDesktopConnection,
ServerAddOnPluginConnection,
} from './ServerAddOnModuleToDesktopConnection';
type ServerAddOnCleanup = () => Promise<void>;
interface ServerAddOnModule {
serverAddOn?: (
connection: ServerAddOnModuleToDesktopConnection,
connection: ServerAddOnPluginConnection,
{flipperServer}: {flipperServer: FlipperServerForServerAddOn},
) => Promise<ServerAddOnCleanup>;
}

View File

@@ -29,7 +29,15 @@ export type ServerAddOnModuleToDesktopConnectionEvents = {
message: ExecuteMessage;
};
export class ServerAddOnModuleToDesktopConnection extends EventEmitter {
export interface ServerAddOnPluginConnection {
send(method: string, params: unknown): void;
receive(method: string, receiver: FlipperPluginReceiver): void;
}
export class ServerAddOnModuleToDesktopConnection
extends EventEmitter
implements ServerAddOnPluginConnection
{
private subscriptions: Map<string, FlipperPluginReceiver> = new Map();
send(method: string, params: unknown) {