UNPKG

quarantiner

Version:

A script isolator that runs scripts inside a sandbox iframe

30 lines 1.25 kB
import Sandbox from './Sandbox'; import SandboxCreator from './SandboxCreator'; import SandboxInitialiser from './SandboxInitialiser'; export default class SandboxRepository { private readonly sandboxCreator; private readonly sandboxInitialiser; private readonly sandboxPromises; constructor(sandboxCreator: SandboxCreator, sandboxInitialiser: SandboxInitialiser); /** * Declares a sandbox. */ declareSandbox(name: string): Promise<Sandbox>; /** * Fetches a declared sandbox, resolving once it has completed initialisation. * * This will wait for all sandboxee scripts executed so far to either succeed or fail, * resolving the promise regardless once all have executed. * * Note that it is possible for further scripts to execute and call .quarantine(...) * after this point, in which case it is necessary to: * * `await quarantiner.getSandbox(...).getPendingSandboxeePromise()`. */ getSandbox(name: string): Promise<Sandbox>; /** * Adds a script to be executed inside a sandbox that may or may not have initialised yet. */ sandboxScript(name: string, scriptSrc: string): Promise<Sandbox>; } //# sourceMappingURL=SandboxRepository.d.ts.map