Documentation ¶
Index ¶
- func OpenOSFilesystem(base string) afero.Fs
- type E
- func (e *E) AddBuiltin(name string, sensitive bool, module moduleDefiner) error
- func (e *E) AddRemoteBuiltin(name string, module moduleDefiner) error
- func (e *E) AnchorModules(path string) error
- func (e *E) Close() error
- func (e *E) ConnectStdio(in io.Reader, out, err io.Writer)
- func (e *E) InteractiveEval(code string) (interface{}, error)
- func (e *E) IsRestrictedModule(err error) (error, bool)
- func (e *E) SetStderr(buf io.Writer) error
- func (e *E) Unrestrict(name string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OpenOSFilesystem ¶
Types ¶
type E ¶
type E struct {
// contains filtered or unexported fields
}
E contains the engine used to run all javascript code
func New ¶
New returns an empty engine with the bare minimum global objects required to run any workload
func (*E) AddBuiltin ¶
AddBuiltin module, if the module is marked as sensitve, the module will be marked as dangerous and restrict (users need to call Unrestrict to enable the module for local/trusted scripts).
If senstive is false, the module will be available for local/trusted scripts right after this function returns.
To add a module for remote use, call AddRemoteBuiltin.
func (*E) AddRemoteBuiltin ¶
AddRemoteBuiltin adds the given module and exposes it to all scripts (local/trusted/remote)
Be careful with which types of modules are defined for remote scripts as there won't be any restrictions on what functions a remote script can make.
func (*E) AnchorModules ¶
func (*E) ConnectStdio ¶
ConnectStdio changes the std in/out/err streams from the default descard ones to ones that connect to the given ones.
If an entry is nil, the one already configured in the engine is kept
func (*E) InteractiveEval ¶
func (*E) Unrestrict ¶
Unrestrict the given module and allows access to it from local sources or other trusted sources.