/** * Iframe executor for browser environments. * * This executor runs code in a sandboxed iframe, providing DOM isolation * and configurable security policies via the sandbox attribute. * * Key characteristics: * - Per-execution lifecycle: fresh iframe for each execute() call * - Configurable sandbox attributes (default: allow-scripts only) * - No shared module support (use MainThreadExecutor for that) * - Communication via postMessage */ import type { IExecutor, ExecuteOptions, ExecuteResult } from "../types"; /** * Options for creating an IframeExecutor. */ export interface IframeExecutorOptions { /** * Sandbox attributes for the iframe. * @default ["allow-scripts"] * * Common options: * - "allow-scripts": Required for code execution * - "allow-same-origin": Enables localStorage, cookies (reduces isolation) * - "allow-modals": Enables alert/confirm/prompt * * Security note: "allow-scripts" + "allow-same-origin" together allows * the iframe code to potentially remove the sandbox via script. */ sandbox?: string[]; /** * Default timeout in milliseconds. * @default 30000 */ defaultTimeout?: number; /** * Container element for iframes. * Iframes are created hidden (display: none). * @default document.body */ container?: HTMLElement; } /** * Executor that runs code in a sandboxed iframe. * * Each execute() call creates a fresh iframe, runs the code, and destroys * the iframe. This provides clean isolation between executions. * * Note: This executor does NOT support shared modules. The iframe runs * in complete isolation. Use MainThreadExecutor if you need shared modules. * * @example * ```ts * // Default: strict sandboxing (allow-scripts only) * const executor = createIframeExecutor(); * * // With additional permissions * const executor = createIframeExecutor({ * sandbox: ["allow-scripts", "allow-same-origin"], * }); * * const result = await executor.execute(bundledCode, { * entryExport: 'main', * context: { args: ['--verbose'] }, * timeout: 5000, * }); * console.log(result.logs); * ``` */ export declare class IframeExecutor implements IExecutor { private options; constructor(options?: IframeExecutorOptions); execute(code: string, options?: ExecuteOptions): Promise; } /** * Create an iframe executor. * * @param options - Executor options * @returns A new IframeExecutor instance */ export declare function createIframeExecutor(options?: IframeExecutorOptions): IframeExecutor; //# sourceMappingURL=iframe-executor.d.ts.map