From a34b167c6ee7a50a80dc2559525c05e994715e36 Mon Sep 17 00:00:00 2001 From: XmiliaH Date: Tue, 5 Jul 2022 15:09:06 +0200 Subject: [PATCH] Add documentation --- README.md | 2 ++ index.d.ts | 2 ++ lib/nodevm.js | 1 + 3 files changed, 5 insertions(+) diff --git a/README.md b/README.md index 4146cec..eb8a282 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,8 @@ Unlike `VM`, `NodeVM` allows you to require modules in the same way that you wou * `require.context` - `host` (default) to require modules in the host and proxy them into the sandbox. `sandbox` to load, compile, and require modules in the sandbox. Except for `events`, built-in modules are always required in the host and proxied into the sandbox. * `require.import` - An array of modules to be loaded into NodeVM on start. * `require.resolve` - An additional lookup function in case a module wasn't found in one of the traditional node lookup paths. +* `require.customRequire` - Use instead of the `require` function to load modules from the host. +* `require.strict` - `false` to disable loading modules in strict mode (default: `true`). * `nesting` - **WARNING**: Allowing this is a security risk as scripts can create a NodeVM which can require any host module. `true` to enable VMs nesting (default: `false`). * `wrapper` - `commonjs` (default) to wrap script into CommonJS wrapper, `none` to retrieve value returned by the script. * `argv` - Array to be passed to `process.argv`. diff --git a/index.d.ts b/index.d.ts index 1e93c7a..9c93c69 100644 --- a/index.d.ts +++ b/index.d.ts @@ -24,6 +24,8 @@ export interface VMRequire { resolve?: (moduleName: string, parentDirname: string) => string | undefined; /** Custom require to require host and built-in modules. */ customRequire?: (id: string) => any; + /** Load modules in strict mode. (default: true) */ + strict?: boolean; } /** diff --git a/lib/nodevm.js b/lib/nodevm.js index b1236ee..a55a0e2 100644 --- a/lib/nodevm.js +++ b/lib/nodevm.js @@ -184,6 +184,7 @@ class NodeVM extends VM { * @param {resolveCallback} [options.require.resolve] - An additional lookup function in case a module wasn't * found in one of the traditional node lookup paths. * @param {customRequire} [options.require.customRequire=require] - Custom require to require host and built-in modules. + * @param {boolean} [option.require.strict=true] - Load required modules in strict mode. * @param {boolean} [options.nesting=false] - * WARNING: Allowing this is a security risk as scripts can create a NodeVM which can require any host module. * Allow nesting of VMs.