sandbox 0.8.6 → 1.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/sandbox.mjs +3 -0
- package/dist/cli.d.ts +11 -0
- package/dist/cli.js +27 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +46 -0
- package/package.json +32 -28
- package/.npmignore +0 -2
- package/README.md +0 -128
- package/UNLICENSE +0 -25
- package/build/Makefile +0 -350
- package/build/Release/.deps/Release/obj.target/sandbox/src/sandbox.o.d +0 -20
- package/build/Release/.deps/Release/sandbox.node.d +0 -1
- package/build/Release/linker.lock +0 -0
- package/build/Release/obj.target/sandbox/src/sandbox.o +0 -0
- package/build/Release/sandbox.node +0 -0
- package/build/binding.Makefile +0 -6
- package/build/config.gypi +0 -36
- package/build/gyp-mac-tool +0 -512
- package/build/sandbox.target.mk +0 -156
- package/example/example.js +0 -64
- package/lib/sandbox.js +0 -124
- package/lib/shovel.js +0 -113
- package/test/sandbox.js +0 -119
- package/tmp.js +0 -8
package/bin/sandbox.mjs
ADDED
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This module is re-exported from `@vercel/sandbox-cli`.
|
|
3
|
+
*
|
|
4
|
+
* It provides a programmatic interface to embed the Vercel Sandbox CLI
|
|
5
|
+
* in a different CLI or application.
|
|
6
|
+
*
|
|
7
|
+
* @module sandbox/cli
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
* @private
|
|
10
|
+
*/
|
|
11
|
+
export * from "@vercel/sandbox-cli";
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* This module is re-exported from `@vercel/sandbox-cli`.
|
|
4
|
+
*
|
|
5
|
+
* It provides a programmatic interface to embed the Vercel Sandbox CLI
|
|
6
|
+
* in a different CLI or application.
|
|
7
|
+
*
|
|
8
|
+
* @module sandbox/cli
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
* @private
|
|
11
|
+
*/
|
|
12
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
16
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}) : (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
o[k2] = m[k];
|
|
22
|
+
}));
|
|
23
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
24
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
__exportStar(require("@vercel/sandbox-cli"), exports);
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A programmatic interface to interact with Vercel Sandboxes.
|
|
3
|
+
*
|
|
4
|
+
* Using this package you can create, destroy, and run commands on Vercel Sandboxes.
|
|
5
|
+
*
|
|
6
|
+
* @see https://vercel.com/docs/vercel-sandbox
|
|
7
|
+
*
|
|
8
|
+
* @example Create a sandbox and run a command on the remote machine
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { Sandbox } from 'sandbox'
|
|
11
|
+
*
|
|
12
|
+
* const sandbox = await Sandbox.create();
|
|
13
|
+
* await sandbox.runCommand({
|
|
14
|
+
* cmd: 'echo',
|
|
15
|
+
* args: ['Hello, World!'],
|
|
16
|
+
* stdout: process.stdout,
|
|
17
|
+
* stderr: process.stderr,
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @example Grab an existing sandbox by its ID:
|
|
22
|
+
* ```typescript
|
|
23
|
+
* import { Sandbox } from 'sandbox'
|
|
24
|
+
*
|
|
25
|
+
* const sandbox = await Sandbox.get({ sandboxId: "sbx_..." });
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @packageDocumentation
|
|
29
|
+
*/
|
|
30
|
+
export * from "@vercel/sandbox";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* A programmatic interface to interact with Vercel Sandboxes.
|
|
4
|
+
*
|
|
5
|
+
* Using this package you can create, destroy, and run commands on Vercel Sandboxes.
|
|
6
|
+
*
|
|
7
|
+
* @see https://vercel.com/docs/vercel-sandbox
|
|
8
|
+
*
|
|
9
|
+
* @example Create a sandbox and run a command on the remote machine
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { Sandbox } from 'sandbox'
|
|
12
|
+
*
|
|
13
|
+
* const sandbox = await Sandbox.create();
|
|
14
|
+
* await sandbox.runCommand({
|
|
15
|
+
* cmd: 'echo',
|
|
16
|
+
* args: ['Hello, World!'],
|
|
17
|
+
* stdout: process.stdout,
|
|
18
|
+
* stderr: process.stderr,
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @example Grab an existing sandbox by its ID:
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import { Sandbox } from 'sandbox'
|
|
25
|
+
*
|
|
26
|
+
* const sandbox = await Sandbox.get({ sandboxId: "sbx_..." });
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @packageDocumentation
|
|
30
|
+
*/
|
|
31
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
32
|
+
if (k2 === undefined) k2 = k;
|
|
33
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
34
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
35
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
36
|
+
}
|
|
37
|
+
Object.defineProperty(o, k2, desc);
|
|
38
|
+
}) : (function(o, m, k, k2) {
|
|
39
|
+
if (k2 === undefined) k2 = k;
|
|
40
|
+
o[k2] = m[k];
|
|
41
|
+
}));
|
|
42
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
43
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
__exportStar(require("@vercel/sandbox"), exports);
|
package/package.json
CHANGED
|
@@ -1,35 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sandbox",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"Dominic Tarr (http://cyber-hobo.blogspot.com)"
|
|
10
|
-
],
|
|
11
|
-
"version": "0.8.6",
|
|
12
|
-
"main": "./lib/sandbox",
|
|
13
|
-
"directories": {
|
|
14
|
-
"lib": "./lib"
|
|
3
|
+
"version": "1.0.0-beta.1",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"sandbox": "./bin/sandbox.mjs"
|
|
15
9
|
},
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"default": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"./cli": {
|
|
16
|
+
"default": "./dist/cli.js",
|
|
17
|
+
"types": "./dist/cli.d.ts"
|
|
18
|
+
}
|
|
23
19
|
},
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
20
|
+
"files": [
|
|
21
|
+
"README.md",
|
|
22
|
+
"dist",
|
|
23
|
+
"bin"
|
|
24
|
+
],
|
|
25
|
+
"private": false,
|
|
26
|
+
"keywords": [],
|
|
27
|
+
"author": "",
|
|
28
|
+
"license": "ISC",
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@vercel/sandbox": "1.0.0-beta.0",
|
|
31
|
+
"@vercel/sandbox-cli": "1.0.0-beta.0"
|
|
27
32
|
},
|
|
28
33
|
"scripts": {
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
"url": "http://github.com/gf3/sandbox/raw/master/UNLICENSE"
|
|
34
|
+
"clean": "rm -rf node_modules dist",
|
|
35
|
+
"build": "tsc",
|
|
36
|
+
"typedoc": "turbo run build && typedoc",
|
|
37
|
+
"typecheck": "tsc --noEmit"
|
|
34
38
|
}
|
|
35
|
-
}
|
|
39
|
+
}
|
package/.npmignore
DELETED
package/README.md
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
# Node Sandbox
|
|
2
|
-
|
|
3
|
-
A nifty javascript sandbox for node.js.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
## Some features
|
|
7
|
-
|
|
8
|
-
- Can be used to execute untrusted code.
|
|
9
|
-
- Support for timeouts (e.g. prevent infinite loops)
|
|
10
|
-
- Support for memory errors (and memory errors)
|
|
11
|
-
- Handles errors gracefully
|
|
12
|
-
- Restricted code (cannot access node.js methods)
|
|
13
|
-
- Supports `console.log` and `print` utility methods
|
|
14
|
-
- Supports interprocess messaging with the sandboxed code
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
## Example
|
|
18
|
-
|
|
19
|
-
Be sure to check out [example/example.js](https://github.com/gf3/sandbox/blob/master/example/example.js)
|
|
20
|
-
|
|
21
|
-
```javascript
|
|
22
|
-
var s = new Sandbox();
|
|
23
|
-
s.run('1 + 1 + " apples"', function(output) {
|
|
24
|
-
// output.result == "2 apples"
|
|
25
|
-
});
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
## Documentation
|
|
30
|
-
|
|
31
|
-
### `Sandbox`#`run`(`code`, `hollaback`)
|
|
32
|
-
|
|
33
|
-
* `code` {`String`} — string of Javascript to be executed.
|
|
34
|
-
* `hollaback` {`Function`} — called after execution with a single argument, `output`.
|
|
35
|
-
- `output` is an object with two properties: `result` and `console`. The `result`
|
|
36
|
-
property is an inspected string of the return value of the code. The `console`
|
|
37
|
-
property is an array of all console output.
|
|
38
|
-
|
|
39
|
-
For example, given the following code:
|
|
40
|
-
|
|
41
|
-
```javascript
|
|
42
|
-
function add(a, b){
|
|
43
|
-
console.log(a);
|
|
44
|
-
console.log(b);
|
|
45
|
-
return a + b;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
add(20, 22);
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
The resulting output object is:
|
|
52
|
-
|
|
53
|
-
```javascript
|
|
54
|
-
{
|
|
55
|
-
result: "42",
|
|
56
|
-
console: ["20", "22"]
|
|
57
|
-
}
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### `Sandbox`#`postMessage`(`message`)
|
|
61
|
-
|
|
62
|
-
* `message` {`String`} - message to send to the sandboxed code
|
|
63
|
-
|
|
64
|
-
For example, the following code will send a message from outside of the sandbox in
|
|
65
|
-
and then the sandboxed code will respond with its own message. Note that the sandboxed
|
|
66
|
-
code handles incoming messages by defining a global `onmessage` function and can
|
|
67
|
-
send messages to the outside using the `postMessage` function.
|
|
68
|
-
|
|
69
|
-
Sandboxed code:
|
|
70
|
-
```javascript
|
|
71
|
-
onmessage = function(message){
|
|
72
|
-
if (message === 'hello from outside') {
|
|
73
|
-
postMessage('hello from inside');
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
Sandbox:
|
|
79
|
-
```
|
|
80
|
-
var sandbox = new Sandbox();
|
|
81
|
-
sandbox.run(sandboxed_code);
|
|
82
|
-
sandbox.on('message', function(message){
|
|
83
|
-
// Handle message sent from the inside
|
|
84
|
-
// In this example message will be 'hello from inside'
|
|
85
|
-
});
|
|
86
|
-
sandbox.postMessage('hello from outside');
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
The process will ONLY be considered finished if `onmessage` is NOT a function.
|
|
90
|
-
If `onmessage` is defined the sandbox will assume that it is waiting for an
|
|
91
|
-
incoming message.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
## Installation & Running
|
|
95
|
-
|
|
96
|
-
Let's get it! The easiest way is through npm:
|
|
97
|
-
|
|
98
|
-
npm install sandbox
|
|
99
|
-
|
|
100
|
-
Or if you'd like to play with the code, see the examples, run the tests,
|
|
101
|
-
what-the-fuck-ever...
|
|
102
|
-
|
|
103
|
-
git clone git://github.com/gf3/sandbox.git
|
|
104
|
-
|
|
105
|
-
And run some examples:
|
|
106
|
-
|
|
107
|
-
node example/example.js
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
## Tests
|
|
111
|
-
|
|
112
|
-
To run the tests simply run the test file with node.
|
|
113
|
-
|
|
114
|
-
npm test
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
## License
|
|
118
|
-
|
|
119
|
-
Sandbox is [UNLICENSED](http://unlicense.org/).
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
## Contributors
|
|
123
|
-
|
|
124
|
-
- [Gianni Chiappetta](http://github.com/gf3) – [gf3.ca](http://gf3.ca)
|
|
125
|
-
- [Bradley Meck](https://github.com/bmeck)
|
|
126
|
-
- [Dominic Tarr](http://github.com/dominictarr) – [cyber-hobo.blogspot.com](http://cyber-hobo.blogspot.com/)
|
|
127
|
-
- [Eli Mallon](https://github.com/iameli) – [iame.li](http://iame.li/)
|
|
128
|
-
- [Evan Schwartz](https://github.com/emschwartz)
|
package/UNLICENSE
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
This is free and unencumbered software released into the public domain.
|
|
2
|
-
|
|
3
|
-
Anyone is free to copy, modify, publish, use, compile, sell, or
|
|
4
|
-
distribute this software, either in source code form or as a compiled
|
|
5
|
-
binary, for any purpose, commercial or non-commercial, and by any
|
|
6
|
-
means.
|
|
7
|
-
|
|
8
|
-
In jurisdictions that recognize copyright laws, the author or authors
|
|
9
|
-
of this software dedicate any and all copyright interest in the
|
|
10
|
-
software to the public domain. We make this dedication for the benefit
|
|
11
|
-
of the public at large and to the detriment of our heirs and
|
|
12
|
-
successors. We intend this dedication to be an overt act of
|
|
13
|
-
relinquishment in perpetuity of all present and future rights to this
|
|
14
|
-
software under copyright law.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
-
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
20
|
-
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
21
|
-
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
-
OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
-
|
|
24
|
-
For more information, please refer to <http://unlicense.org/>
|
|
25
|
-
|