@dapplets/dapplet-extension
Version:
The Bridge to the Augmented Web.
21 lines (20 loc) • 1.02 kB
TypeScript
import { SandboxInitializationParams } from '../../common/types';
/**
* The IFrameContainer class creates and manages a sandboxed iframe within the web page context.
* It serves as a secure container for running dapplets and overcomes restrictions like
* Content Security Policy (CSP) that prevent direct usage of certain features like WebWorkers.
* It sends commands to the iframe to create and terminate dapplet workers and to send messages
* to them.
*/
export declare class IFrameContainer {
private _messageListenersByWorkerId;
private _iframe;
constructor();
addWorkerListener(workerId: string, listener: (message: any) => void): void;
removeWorkerListener(workerId: string, listener: (message: any) => void): void;
postMessageToWorker(workerId: string, workerMessage: any): void;
createWorker(dappletScript: string, injectorInitParams: SandboxInitializationParams): string;
terminateWorker(workerId: string): void;
destroy(): void;
private _sandboxIframeListener;
}